SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2406.02066 · ICML · 2024

Preference Optimization for Molecule Synthesis with Conditional Residual Energy-based Models

Hanjun Dai, Peng Liu, Yue Zhao, Songtao Liu

arXiv · PDF · Open in the Atlas

Code that ran

10 of 20 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 0 violated it and 0 have no contract verdict; 10 failures of our instrument; 10 no recorded run), measured 2026-11-22; repository links from the Papers with Code archive attributed under CC BY-SA, no affiliation; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2406.02066.json · badge: /api/ran/2406.02066.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
SongtaoLiu0823/CREBM canonical (classifier label)
classifier basis: census
8 ran · 2 no recorded run
songtaoliu0823/crebm canonical (classifier label)
classifier basis: classifier_2025
2 ran · 8 no recorded run
FunctionStatusWhere it lives
get_attention_mask Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
SongtaoLiu0823/CREBM/FusionRetro/modeling.py
pointer only (licence: MIT); the stored copy get_code serves, from songtaoliu0823/fusionretro, is pointer only (licence: NONE) · get_code("aab6b0ababd814f1")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (MIT), but get_code serves the stored copy, first harvested from songtaoliu0823/fusionretro, and GitHub detected no licence in that repository when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

get_attention_mask Ran
ran; our contract draft was wrong, not the code
songtaoliu0823/crebm/Energy_function/reward_model.py
code served (permissive licence) · get_code("eec7bf6cd0c9ce7d")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1) and returned Tensor, ndim 4, dtype family float, shape (2, 5, 3, 4) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

torch.manual_seed(0)

# Construct a mask tensor
# The function expects mask to have shape (batch_size, seq_len, seq_len) or similar
# It will be expanded to (num_attention_heads, batch_size, seq_len, seq_len)
# Then permuted to (batch_size, num_attention_heads, seq_len, seq_len)
# Using distinct sizes: batch=2, seq_len=3, seq_len=4
mask = torch.ones(2, 3, 4)

num_attention_heads = 5

ARGS = {
    "mask": mask,
    "num_attention_heads": num_attention_heads,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 4, dtype family float, shape (2, 5, 3, 4) — shape (2, 5, 3, 4) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
get_attention_mask_reward Ran
ran; our contract draft was wrong, not the code
SongtaoLiu0823/CREBM/FusionRetro/reward_model.py
code served (permissive licence) · get_code("d9192da44e7497f4")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Tensor, ndim 4, dtype family float, shape (2, 8, 4, 4) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

torch.manual_seed(0)

# mask: needs to be a tensor that can be expanded and permuted
# The function expands it to (num_attention_heads, batch_size, seq_len, seq_len)
# then permutes to (batch_size, num_attention_heads, seq_len, seq_len)
# So mask should have shape (batch_size, seq_len, seq_len) or be broadcastable

mask = torch.ones(2, 4, 4)  # batch_size=2, seq_len=4, seq_len=4

num_attention_heads = 8

ARGS = {
    "mask": mask,
    "num_attention_heads": num_attention_heads,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 4, dtype family float, shape (2, 8, 4, 4) — shape (2, 8, 4, 4) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
get_dataset Ran
ran; our contract draft was wrong, not the code
SongtaoLiu0823/CREBM/Forward_model/forward_preprocess.py
code served (permissive licence) · get_code("eff77b1103611612")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned tuple, ndim 2, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import os
import tempfile
from pathlib import Path

# Create temporary directory structure with mock data files
temp_dir = tempfile.mkdtemp()
data_dir = os.path.join(temp_dir, 'data')
os.makedirs(data_dir, exist_ok=True)

# Create mock data files
train_data = [
    "hello world>>goodbye world",
    "how are you>>i am fine"
]

test_data = [
    "what is this>>this is a test",
    "foo bar>>baz qux"
]

val_data = [
    "input one>>output one",
    "input two>>output two"
]

# Write to files
with open(os.path.join(data_dir, 'augmented_train.txt'), 'w') as f:
    f.write('\n'.join(train_data))

with open(os.path.join(data_dir, 'test.txt'), 'w') as f:
    f.write('\n'.join(test_data))

with open(os.path.join(data_dir, 'val.txt'), 'w') as f:
    f.write('\n'.join(val_data))

# Change to temp directory so relative paths work
original_cwd = os.getcwd()
os.chdir(temp_dir)

# Define ARGS
ARGS = {
    'phase': 'train'
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
tqdm — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple, ndim 2, dtype family float — a tuple output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
get_input_mask_reward Ran
ran; our contract draft was wrong, not the code
SongtaoLiu0823/CREBM/FusionRetro/reward_model.py
code served (permissive licence) · get_code("bda04ebfeae378ad")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Tensor, ndim 3, dtype family float, shape (2, 4, 4) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

torch.manual_seed(0)

# Construct a small tensor input x with shape (batch=2, length=4)
x = torch.randn(2, 4)

ARGS = {
    "x": x
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 3, dtype family float, shape (2, 4, 4) — shape (2, 4, 4) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
get_mem_attention_mask Ran
ran; our contract draft was wrong, not the code
SongtaoLiu0823/CREBM/FusionRetro/modeling.py
pointer only (licence: MIT); the stored copy get_code serves, from songtaoliu0823/fusionretro, is pointer only (licence: NONE) · get_code("63f5e5133356e1ce")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (MIT), but get_code serves the stored copy, first harvested from songtaoliu0823/fusionretro, and GitHub detected no licence in that repository when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

get_model_dir Ran
ran; our contract draft was wrong, not the code
songtaoliu0823/crebm/GraphRetro/scripts/benchmarks/run_model.py
code served (permissive licence) · get_code("6ffa7d3b10e36bff")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1) and returned str. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

torch.manual_seed(0)

ARGS = {
    'model_name': 'single_edit'
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
get_position_embedding Ran
ran; our contract draft was wrong, not the code
SongtaoLiu0823/CREBM/Energy_function/reward_model.py
code served (permissive licence) · get_code("8a2fd49d7c7f70d1")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Tensor, ndim 3, dtype family float, shape (2, 3, 8) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

torch.manual_seed(0)

# x is used for:
# - x.shape[1] to get sequence length
# - x.shape[0] to get batch size
# - x.device to get device
# So x should be a tensor with shape (batch_size, seq_len, ...)

x = torch.randn(2, 3, 4)  # batch=2, seq_len=3, feature_dim=4

# embedding_size is used for:
# - embedding_size // 2 in range
# - division in the formula
# Should be an integer, make it distinct from other dims

embedding_size = 8

ARGS = {
    "x": x,
    "embedding_size": embedding_size,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 3, dtype family float, shape (2, 3, 8) — shape (2, 3, 8) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
get_position_embedding Ran
ran; our contract draft was wrong, not the code
SongtaoLiu0823/CREBM/FusionRetro/modeling.py
code served (permissive licence) · get_code("30d746b2a597c06c")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Tensor, ndim 4, dtype family float, shape (2, 3, 4, 8) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

torch.manual_seed(0)

# Construct x tensor with shape (batch_size, sequence_length, feature_dim)
# Using distinct sizes: batch=2, sequence=3, features=4
x = torch.randn(2, 3, 4)

# embedding_size should be an integer
embedding_size = 8

ARGS = {
    "x": x,
    "embedding_size": embedding_size
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 4, dtype family float, shape (2, 3, 4, 8) — shape (2, 3, 4, 8) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
get_position_embedding_reward Ran
ran; our contract draft was wrong, not the code
SongtaoLiu0823/CREBM/FusionRetro/reward_model.py
code served (permissive licence) · get_code("bc7b5841f4ac0765")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Tensor, ndim 3, dtype family float, shape (2, 4, 8) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

torch.manual_seed(0)

# x is a tensor with shape (batch_size, sequence_length, ...)
# The function accesses x.shape[0] and x.shape[1], and x.device
# So we need a 2D or higher tensor
x = torch.randn(2, 4)  # batch_size=2, sequence_length=4

# embedding_size is an integer used for embedding dimension
embedding_size = 8

ARGS = {
    "x": x,
    "embedding_size": embedding_size,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 3, dtype family float, shape (2, 4, 8) — shape (2, 4, 8) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
Decoder Not yet run
unverified (harvested, no recorded run)
songtaoliu0823/crebm/Energy_function/reward_model.py
code served (permissive licence) · get_code("504a163b8cca9e67")
How it ran

no invocation recorded.

DecoderLayer Not yet run
unverified (harvested, no recorded run)
songtaoliu0823/crebm/Energy_function/reward_model.py
code served (permissive licence) · get_code("d291fa98cd3fd2ba")
How it ran

no invocation recorded.

Embeddings Not yet run
unverified (harvested, no recorded run)
songtaoliu0823/crebm/Energy_function/reward_model.py
code served (permissive licence) · get_code("ae58f0fed04a3eba")
How it ran

no invocation recorded.

Encoder Not yet run
unverified (harvested, no recorded run)
songtaoliu0823/crebm/Energy_function/reward_model.py
code served (permissive licence) · get_code("54fe6546395e90b0")
How it ran

no invocation recorded.

EncoderLayer Not yet run
unverified (harvested, no recorded run)
songtaoliu0823/crebm/Energy_function/reward_model.py
code served (permissive licence) · get_code("b4ba32298cce6023")
How it ran

no invocation recorded.

MultiHeadAttention Not yet run
unverified (harvested, no recorded run)
songtaoliu0823/crebm/Energy_function/reward_model.py
code served (permissive licence) · get_code("35b3f91bfff1f5ce")
How it ran

no invocation recorded.

RewardTransformer Not yet run
unverified (harvested, no recorded run)
songtaoliu0823/crebm/Energy_function/reward_model.py
code served (permissive licence) · get_code("c02f128f73e14a42")
How it ran

no invocation recorded.

convert_symbols_to_inputs Not yet run
unverified (harvested, no recorded run)
SongtaoLiu0823/CREBM/Forward_model/forward_preprocess.py
code served (permissive licence) · get_code("84f89ccafcd7f616")
How it ran

no invocation recorded.

get_input_mask Not yet run
unverified (harvested, no recorded run)
SongtaoLiu0823/CREBM/Energy_function/reward_model.py
code served (permissive licence) · get_code("a241aff115771ddd")
How it ran

no invocation recorded.

get_position_embedding Not yet run
unverified (harvested, no recorded run)
songtaoliu0823/crebm/Energy_function/reward_model.py
code served (permissive licence) · get_code("492feba8c4b1b9ff")
How it ran

no invocation recorded.

Also present in other papers' code

Of 20 samples lifted from this paper's linked repositories, 20 carry a function identity and 0 do not. Of the 19 distinct functions with an identity, 6 are also present in other papers whose code we hold (6 with at least one paper dated earlier, 0 the same month, 0 later) and 13 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

FunctionAlso present inEarliest-datedOthers named
Embeddings
brick of this paper's assembly: model
1 other paper
1 dated earlier
2209.15315 (2022-09)
FusionRetro: Molecule Representation Fusion via In-Context Learning for Retrosynthetic Planning
Encoder
brick of this paper's assembly: model
1 other paper
1 dated earlier
2209.15315 (2022-09)
FusionRetro: Molecule Representation Fusion via In-Context Learning for Retrosynthetic Planning
get_attention_mask 1 other paper
1 dated earlier
2209.15315 (2022-09)
FusionRetro: Molecule Representation Fusion via In-Context Learning for Retrosynthetic Planning
get_mem_attention_mask 1 other paper
1 dated earlier
2209.15315 (2022-09)
FusionRetro: Molecule Representation Fusion via In-Context Learning for Retrosynthetic Planning
get_model_dir 1 other paper
1 dated earlier
2006.07038 (2020-06)
Learning Graph Models for Retrosynthesis Prediction
get_position_embedding 1 other paper
1 dated earlier
2209.15315 (2022-09)
FusionRetro: Molecule Representation Fusion via In-Context Learning for Retrosynthetic Planning

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-22.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

Molecule synthesis through machine learning is one of the fundamental problems in drug discovery. Current data-driven strategies employ onestep retrosynthesis models and search algorithms to predict synthetic routes in a top-bottom manner. Despite their effective performance, these strategies face limitations in the molecule synthetic route generation due to a greedy selection of the next molecule set without any lookahead. Furthermore, existing strategies cannot control the generation of synthetic routes based on possible criteria such as material costs, yields, and step count. In this work, we propose a general and principled framework via conditional residual energy-based models (EBMs), that focus on the quality of the entire synthetic route based on the specific criteria. By incorporating an additional energy-based function into our probabilistic model, our proposed algorithm can enhance the quality of the most probable synthetic routes (with higher probabilities) generated by various strategies in a plug-andplay fashion. Extensive experiments demonstrate that our framework can consistently boost performance across various strategies and outperforms previous state-of-the-art top-1 accuracy by a margin of 2.5%. Code is available at https:// github.com/SongtaoLiu0823/CREBM.

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2406.02066")
get_code_for_paper("2406.02066")
have("2406.02066")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2406.02066.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2406.02066.svg)](https://syntology.ai/paper/2406.02066)

Connect an agent — have() is free.