Repository navigation
Add MolDeTox resources server - #3437
Merged
Merged
Conversation
MolDeTox is a toxicity-aware molecular editing benchmark built from toxicity cliffs: pairs of structurally near-identical molecules with opposite measured toxicity. All eight QA configs are implemented against the pinned dataset revision 059e1926. Only the test split is reachable; `--split` is constrained rather than documented, because a free-form string quietly contradicted the README's test-only scope. Both prompt turns come from upstream. The dataset ships each user message in `question`, and the paper publishes a system prompt per task family as Appendix Tables H, I, J and K, which prompts.py carries verbatim. Sending no system message is a measurable divergence, not an upstream gap, so `--no-system-prompt` exists to reproduce it rather than to support it. Reward is exact match in every mode, but "exact" differs by task. Task 3 answers are whole molecules compared as canonical SMILES, or decoded from SAFE first with a failed reconstruction counted invalid. Tasks 1 and 2 answer with SAFE fragment sets, which carry unmatched attachment digits and genuinely do not parse as molecules, so they are compared as string multisets. The two fragment modes are separate because Appendix D defines different auxiliary metrics per task: D.1 gives Task 1 exact match and a set-based F1 only, while D.2 adds a fragment-level edit distance that is explicitly not a whole-string distance. Splitting them keeps the scoring mode the single thing that determines which metrics are produced. Scoring is deterministic and needs no judge model. Validation is model-free: every one of the 7,904 test golds scores 1.0 when fed back through verify(), and negative controls cover echoing the toxic input, undecodable SAFE, invalid SMILES, fragment reordering and attachment-digit relabelling. Only mean/reward and token counts are promoted to key_metrics. The similarity metrics must not be read as performance here: echoing the toxic input unchanged scores zero accuracy at mean Morgan Tanimoto 0.711, because cliff pairs are similar by construction. Three upstream metrics are deliberately not reported. BLEU-1 is bare clipped unigram precision, which is degenerate on SMILES. Levenshtein is None rather than the full gold length when a prediction is unusable. PRS needs desirability curves and weights the paper never states. Data preparation uses huggingface-hub directly rather than datasets. The eight configs are plain JSONL files at a pinned revision, both paths were compared over all eight and produce identical rows, and the dataset card is not honoured by the builder in any case. Co-Authored-By: Claude Opus 5 <[email protected]> Signed-off-by: Rima Shahbazyan <[email protected]>
The CI secrets scan reads the pinned Hugging Face commit SHA as a HexHighEntropyString and fails the job. It is a public revision identifier and the whole point of pinning is that it is readable. Fixed with an inline pragma, which is this repository's existing convention, rather than by regenerating a shared baseline. There is no .secrets.baseline here to regenerate, and touching one would put this branch in the path of every other open PR. Reproduced the finding locally with detect-secrets 1.5.0 before and after: one finding at prepare_moldetox.py:45, then zero across the whole server. The same SHA in the server README is not flagged. Added as a new commit rather than an amend: the branch is already published, and rewriting it would need a force-push, which the contributing guide disallows on upstream branches and which orphans inline review comments. Co-Authored-By: Claude Opus 5 <[email protected]> Signed-off-by: Rima Shahbazyan <[email protected]>
rimashahbazyan
temporarily deployed
to
public
September 16, 2026 16:56 — with
GitHub Actions
Inactive
rimashahbazyan
temporarily deployed
to
public
September 16, 2026 16:57 — with
GitHub Actions
Inactive
rimashahbazyan
temporarily deployed
to
public
September 16, 2026 16:58 — with
GitHub Actions
Inactive
rimashahbazyan
temporarily deployed
to
public
September 16, 2026 16:58 — with
GitHub Actions
Inactive
The implementation notes planned a benchmarks/moldetox/ entry and the server shipped without one, so `gym eval prepare --benchmark moldetox` did not exist and preparation was a documented script invocation instead. This adds the entry. Scoring and wiring stay in the resources server; this supplies data and a chain to its config. Registers task3_smiles_gen_single only. MolDeTox publishes a figure for each of its eight QA configs, so naming one canonical is a choice rather than a lookup: this is the config upstream headlines, and the one whose measured accuracy agrees with the published figure. The other seven stay reachable through the server's script, and both READMEs say so. prepare.py reuses the server's loader and row builder rather than reimplementing them, so the two paths cannot drift. Verified: the benchmark output is byte-identical to the server script's output for the same config, 943 rows, system and user turns in that order, zero unjoined toxicity-cliff rows. It drops agent_ref, which the server's script still emits as 21 others do. Routing comes from the config declaration and collate strips the field with a deprecation warning, so new code should not add it. `gym eval prepare --benchmark moldetox` was run end to end against the pinned revision, not just written. Co-Authored-By: Claude Opus 5 <[email protected]> Signed-off-by: Rima Shahbazyan <[email protected]>
rimashahbazyan
temporarily deployed
to
public
September 21, 2026 21:01 — with
GitHub Actions
Inactive
rimashahbazyan
temporarily deployed
to
public
September 21, 2026 21:03 — with
GitHub Actions
Inactive
rimashahbazyan
temporarily deployed
to
public
September 21, 2026 21:03 — with
GitHub Actions
Inactive
rimashahbazyan
temporarily deployed
to
public
September 21, 2026 21:04 — with
GitHub Actions
Inactive
bxyu-nvidia
approved these changes
Sep 21, 2026
Contributor
|
/ok to test 27b7938 |
16 tasks done
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Adds MolDeTox as a NeMo Gym environment: toxicity-aware molecular editing
built on toxicity cliffs — pairs of structurally similar molecules with
opposite measured toxicity for the same endpoint. Given a toxic molecule and an
endpoint, the model must produce the minimally-edited non-toxic partner.
Scoring is fully deterministic — canonical-SMILES and SAFE-fragment
comparison via RDKit. There is no judge model, no external service, and no
toxicity predictor anywhere in the scoring path; the gold answers are
experimentally measured pairs.
All eight upstream QA configs are covered: three tasks × single/multi, with
Task 3 in both SMILES and SAFE output form.
Benchmark at a glance
MolDeTox/MolDeTox, CC-BY-4.0, ungated059e1926fa62a07c3f01afadadf72cce154cfb7f— upstream revised the files on 2026-08-27 and split sizes changed, so the name alone is not a stable referenceConfigs
scoring_modetask1_singlefragments_task1task1_multifragments_task1task2_singlefragments_task2task2_multifragments_task2task3_smiles_gen_singlesmilestask3_smiles_gen_multismilestask3_safe_gen_singlesafetask3_safe_gen_multisafesingleandmultiare a property of the item — how many fragments must change— not a multi-turn protocol. Every config is one-shot. The ninth upstream config,
toxicitycliff, is the source pair table rather than a task; it is used only tojoin the toxic input molecule onto each row.
Published baselines — GPT-5.2, zero-shot, mean ± std over three runs
Tables D and E. Zero-shot is upstream's baseline reporting mode; its 4-shot
columns are a labelled variant that retrieves demonstrations from the train
split.
task1_singletask2_singletask3_safe_gen_singletask3_smiles_gen_singletask1_multitask2_multitask3_smiles_gen_multitask3_safe_gen_multiOnly four models appear under SMILES generation; the full 13-model roster appears
only under SAFE generation.
Task and scoring
Reward is exact match in every mode. What "exact" means differs:
smiles— canonical SMILES equality via RDKit.safe— the prediction is decoded to SMILES with the datamol SAFE decoder,then compared canonically. A failed reconstruction counts invalid, matching
upstream's Appendix D, rather than being masked.
fragments_task1,fragments_task2— string multiset over dot-separatedSAFE fragments. Order does not matter, multiplicity does. Individual SAFE
fragments carry unmatched attachment digits (
Cc1cccc6c1,C46) and genuinelydo not parse as molecules — verified, RDKit returns
Nonefor every one —so canonicalisation is impossible there and comparison is verbatim.
The two fragment modes share that reward and differ only in auxiliary metrics,
because Appendix D defines different ones per task. Splitting them means the
scoring mode alone determines what is produced.
smiles,safevalidity,tanimoto_rdk/maccs/morgan,levenshteinfragments_task1fragment_f1,n_fragments_predictedfragments_task2fragment_f1,n_fragments_predicted,levenshteinTwo definitions follow the paper rather than the obvious reading.
fragment_f1is over fragment sets, as Appendix D.1 writes it, so a repeated fragment
neither helps nor hurts. The Task 2
levenshteinis not a whole-string editdistance; Appendix D.2 says so outright and takes each predicted fragment's
minimum distance to any gold fragment, averaged. Appendix D.1 defines no distance
for Task 1, so none is emitted there.
Metrics a mode does not produce are
Nonerather than0.0, so an absent metricis never averaged in as a zero. Only
mean/rewardand token counts are promotedto
key_metrics; the similarity metrics stay inagent_metricsfor diagnosis,for the reason under Harness validation.
The user message is upstream's, verbatim. The shipped
questionfield is acomplete zero-shot prompt that already states the JSON output contract, so
prepareapplies no template.The system prompt is upstream's too, and is sent. The paper publishes one
per task family (Tables H, I, J, K);
prompts.pycarries them verbatim and thepreparer prepends the one matching the config. They restate the JSON contract
the
questionalready carries, but add role framing and a HARD CONSTRAINTSblock ("Output ONLY the JSON object. Do not include explanations, markdown, or
extra text."). An earlier version sent none;
--no-system-promptreproducesthat, for measurement rather than for reporting.
Reproducing
All commands run from the repository root with that environment active. Note
gym eval runaccepts--inputonly together with--no-serve, and--split exampleis rejected end-to-end because example files are committedsmoke samples.
Tests:
ng_test +entrypoint=resources_servers/moldetox(78 tests).Harness validation
Model-free, and stronger than any model comparison:
verify()scoresreward=1.0on 7,904 / 7,904 rows across all eight configs, every rowstatus
scored, zero exceptions.task3_smiles_gen_single; an undecodable SAFE string scoresvalidity=0; aninvalid SMILES is scored rather than silently dropped; fragment reordering and
SAFE attachment-digit relabelling both still score 1.0, which is correct for a
representation whose digits are arbitrary labels.
Echoing the toxic input is worth dwelling on: it scores 0.0 accuracy at mean
Morgan Tanimoto 0.711, because cliff pairs are similar by construction. A
do-nothing baseline looks strong on every similarity metric, so accuracy is the
only headline-safe number here.
get_key_metricsenforces that rather thanleaving it to the reader: only
mean/rewardand token counts are promoted.On comparing against the published numbers
Unlike most benchmarks in this repo, a run here is directly comparable in
protocol. Zero-shot is upstream's baseline mode, the prompts are upstream's
verbatim, the model (GPT-5.2) is on its roster, and Section 3.2 gives the
sampler: temperature 0.7, three runs per model. That makes the residual gaps
meaningful rather than expected, and they are real.
openai/openai/gpt-5.2viainference-api.nvidia.com/v1, zero-shot,temperature 0.7, three runs, on the four single-step configs, with
upstream's published system prompts sent. 11,565 completions, 0 API errors.
Temperature was confirmed honoured rather than silently ignored before the runs:
eight completions of one prompt give 2 distinct outputs at temperature 0.0, 5 at
0.7, and 6 at 2.0.
task1_singletask2_singletask3_smiles_gen_singletask3_safe_gen_singleTwo of four now differ, down from three. Two configs moved into agreement and
one moved out of it by overshooting.
Welch's t-test is the instrument because both sides estimate accuracy on the
same fixed task set, so task sampling is not a source of disagreement; what
varies is decoding, across runs. An earlier pass here used a Wilson binomial
interval and appeared to agree on all eight configs. That interval answers a
different question and is much wider, which is why it agreed. This table
supersedes it.
The two protocol corrections, measured
Two protocol errors were found and fixed, each by re-running rather than by
argument. Neither closed the gap on its own, and together they changed which
configs disagree rather than removing disagreement.
Temperature. The first runs set none, which the API resolved to 1.0;
Section 3.2 specifies 0.7. Matching it moved every config by under 0.4 points.
The system prompt. The paper publishes one per task family, as Tables H, I,
J and K, and the first runs sent none. Sending them raised three of four configs
by 0.4 to 1.3 points.
task1_singletask2_singletask3_smiles_gen_singletask3_safe_gen_singleThe effect is real and in the predicted direction on three configs, and the
mechanism is visible in the outputs: with the HARD CONSTRAINTS block the model
returns bare JSON instead of fenced or narrated answers, so less depends on our
extractor. But it is not the whole explanation.
task1_singleis untouched by itand remains two points low, and
task3_smiles_gen_singlemoved from agreement tosignificantly above upstream, which no single systematic deficit explains.
Sending the published system prompt is now the shipped default regardless of its
effect on the numbers, because it is what upstream specifies.
The four
multiconfigs were run once each at unset temperature and are reportedfor completeness only. They resolve 0 to 2 correct answers out of about 1,000, so
they discriminate essentially nothing:
task1_multitask3_smiles_gen_multitask2_multitask3_safe_gen_multiAuxiliary Task 3 metrics track closely, and were computed from the paper's prose
definitions with no upstream code to fit against, which is what makes the
agreement informative (ours / upstream, from the unset-temperature round):
task3_smiles_gen_singletask3_safe_gen_singleCandidate causes for the residual gap
Temperature and the system prompt are now controlled, and two configs still
disagree. What is left:
task1_singleis unmoved by either correction and sits two points lowacross six runs. It is the largest and most reliable disagreement, and the
system prompt changed it by 0.16 points, which is inside run-to-run noise.
Whatever drives it is not prompting.
task3_smiles_gen_singlenow overshoots. A harness that were simplylenient would overshoot everywhere; it does not. A plausible reading is that
our extractor recovers answers upstream's would have discarded, which would
raise us on the config where free-form SMILES is easiest to emit.
gateway, and
top_p, the token budget and the endpoint style are unstated.Known limitations. Note this predicts we score low on Task 2, and after the
system-prompt fix we no longer do.
The most informative next measurement is a second model from upstream's roster;
GPT-4o and Llama-3.1-8B-Instruct are both reachable. A constant offset across
models points at the harness, a varying one at the deployment. Causes 1 and 2
point in opposite directions, which a single systematic harness deficit does not
explain, so the deployment is the more likely common factor.
Deliberate divergences from upstream
which is degenerate on SMILES: the invalid string
C1CCscores a perfect 1.0against a 35-character gold, since every character occurs in it. Adding a
brevity penalty fixes that but moves the figure ~0.05 off upstream's, so the
metric is dropped rather than reported in a form that is either misleading or
incomparable.
levenshteinisNonewhen the prediction is not a usable molecule, sothose rows are excluded from the mean rather than charged the full gold length.
Charging them measured 10.07 against upstream's 6.70 on
task3_safe_gen_single,where ~7% of predictions do not decode and therefore have no string to compare
at all. Excluding them gives 7.04.
HBA, HBD, PSA, RotB) and states the reference molecule is the toxic input, but
leaves the per-property desirability functions and weights unstated as
"QED-inspired", with no implementation to check against. Those curves determine
the value entirely.
toxic_smilesis carried inverifier_metadataso PRS canbe added later without re-preparing data.
datasetsis not a direct dependency. The eight configs are plain.jsonlfiles at a pinned revision, andhf_hub_downloadplusjson.loadsreads them directly. Both paths were compared over all eight configs of the
pinned revision and produce identical rows. The dataset card is not honoured by
the builder in any case:
load_datasetreportsSome datasets params were ignored: ['type']and picks the JSON builder for the CSV config, which thenfails. This does not shrink the install. An earlier version of this
description claimed it dropped PyArrow and Pandas; that was wrong.
nemo-gymdeclares
datasetsin its own base dependencies, so those packages arriveregardless. What goes away is a duplicate direct declaration and a builder that
mis-selects here.
Known limitations
Task 1 asks the model to select fragments from the decomposition printed in
its own prompt — verified: the gold appears verbatim on 1026/1026 and 950/950
rows — so verbatim comparison is correct there. Task 2 asks it to invent a
replacement, so its writing (ring-closure digits, atom order) is model-chosen
and a chemically identical answer can score zero. Splicing the prediction into
common_safe_fragmentsand decoding reconstructs the corresponding Task 3 goldon 943/943 and 1033/1033 rows, so a canonical comparison is available.
Not done here because it changes the estimand away from upstream's, which
defines Task 2 accuracy over the raw fragment multiset.
task2_singleremainssignificantly below upstream at matched protocol (t = −6.14), consistent with
this being a contributing cause. Tracked, not silently ignored.
multiconfigs are near the floor (0–2 correct out of ~1,000).They are implemented and validated but carry almost no discriminative signal.
Data and licensing
metrics.pyand the scorer are original work implementing the paper's prosedefinitions.
FDA, and SIDER.
prepare_moldetox.pydownloads at runtime at a pinned revision;only the 5-row
data/example.jsonlsmoke sample is committed, which CC-BY-4.0permits with attribution.
rdkit(BSD-3) andsafe-mol(Apache-2.0). Neither is adiscretionary choice — RDKit is the cheminformatics toolkit upstream's metrics
are defined against, and
safe-molis the SAFE decoder the paper cites by URLas the one it uses. Both pinned (
rdkit==2025.9.6,safe-mol==0.2.1) becauseinstalling
safe-moldowngrades rdkit; the full validation and test suite werere-run under the downgrade and are clean.
testsplit is used. The ~202k-row train split is never read, and--splitis constrained totestso that stays true rather than resting onthe caller.
Checklist
update-readme-tablerewrote
README.mdto add the environment row, as CONTRIBUTING describes;the second pass is clean.
git commit -s).New-environment gates (CONTRIBUTING.md)
tests/test_app.py, 78 testsdata/example.jsonlexists with exactly 5 rowsdata/example_metrics.jsonreports"Number of examples": 5data/example_rollouts.jsonlexists with exactly 5 rolloutsdata/domain(knowledge)licensefieldverified: falseVerified directly:
gym env test --resources-server moldetox +should_validate_data=trueexits 0.