glyph-datasets / ocsr /README.md
alexandonian's picture
Add markush-eval/ip5m GT + sidecar; sync dataset card (Apache-2.0) and provenance wording
86f8e17 verified
|
Raw
History Blame Contribute Delete
7.13 kB
# glyph-datasets / ocsr
Data artifacts for the **OCSRGlyph** model. **Training** images are not stored
here: PubChem-format CSVs are rendered on the fly at train time (vendored EPAM
Indigo), and the image-backed training sets carry SMILES + relative paths only,
with the images re-fetched from the cited public sources. The one exception is
the frozen self-contained **eval** parquet `uspto_ocsr_benchmark.parquet`, which
embeds the 5,719 benchmark images (public-domain USPTO patent depictions) plus
their complete labels so `glyph ocsr eval` runs with no reconstruction. Every
other file is a benchmark label sidecar, training metadata (SMILES + optional
relative image paths), or the training recipe.
## Contents
| File | Data rows | Kind | Provenance |
|---|---|---|---|
| `uspto_ocsr_5719_complete.csv` | 5,719 | Benchmark labels | **Frozen, release-authoritative** USPTO-OCSR-5719. See split below. |
| `uspto_ocsr_5719_complete.csv.provenance.json` | — | Sidecar | Per-source counts + recovered/unrecovered image ids for the benchmark. |
| `uspto_ocsr_benchmark.parquet` | 5,719 | Benchmark (self-contained) | **Frozen** images + complete labels; the single artifact `glyph ocsr eval` auto-downloads. See below. |
| `uspto_ocsr_benchmark.parquet.provenance.json` | — | Sidecar | Image source repo+SHA, label completion, row/null counts, and sha256. |
| `adjacent_ring.csv` | 64,752 | Training (this work) | Pure-logic adjacent-ring-stereo **subset of PubChem-1M**. |
| `stereo_200k/train.csv` | 200,000 | Training metadata | Stereo-200K (external). SMILES + `file_path`; images re-fetched. |
| `stereo_200k/val.csv` | 2,000 | Training metadata | Stereo-200K validation split. |
| `stereo_200k_white/train.csv` | 200,000 | Training metadata | White-cropped variant of Stereo-200K (this work's preprocessing). |
| `stereo_200k_white/val.csv` | 2,000 | Training metadata | White-cropped validation split. |
| `ocsrglyph-recipe.json` | — | Training recipe | The OCSRGlyph hyperparameter recipe. |
Row counts are data rows (each CSV also has a 1-line header).
## Frozen USPTO-OCSR-5719 benchmark
`uspto_ocsr_5719_complete.csv` is the exact benchmark behind the published
headline numbers (A canonical 93.8, B chirality-kept 93.9, C graph 96.2, over
the full 5,719 rows). It is **frozen** — use this copy verbatim rather than
rebuilding, because a fresh rebuild against a newer MolScribe snapshot can drift
the null-label recovery.
`source_of_label` split (recorded in the `.provenance.json` sidecar):
- `hf_benchmark`: 5,704 — public `hheiden/USPTO_OCSR_benchmark` labelled rows.
- `molscribe_real`: 13 — null labels recovered from MolScribe `real/USPTO.csv`
(Qian et al., 2023).
- `none_unrecovered`: 2 — labels that could not be recovered.
- Total: 5,704 + 13 + 2 = **5,719**; 5,711 RDKit-scoreable, 8 unscoreable.
Columns: `image_id, smiles, source_of_label`. Images are the public benchmark's
patent depictions (referenced by `image_id`), not stored here.
### Self-contained eval parquet
`uspto_ocsr_benchmark.parquet` is the single artifact `glyph ocsr eval`
downloads: the 5,719 public benchmark images joined to the complete SMILES
labels (columns `id`, `image`, `smiles`, `selfies`, `inchi`, `mol`,
`source_of_label`; image bytes present for every row, zero null SMILES). It lets
the eval score end-to-end with no local reconstruction, and its
`.provenance.json` records the image source repo+SHA, the label completion, and
the file sha256.
**Credit.** The benchmark images and the `id`/`mol`/`selfies`/`inchi` fields come
verbatim from the public Hugging Face dataset
[`hheiden/USPTO_OCSR_benchmark`](https://huggingface.co/datasets/hheiden/USPTO_OCSR_benchmark),
whose depictions are drawn from **public-domain USPTO patent documents** — the
origin of this OCSR benchmark. That upstream release labels 5,704 of the 5,719
images; the 15 remaining labels are completed here (13 recovered from the
MolScribe `real/USPTO.csv` release, Qian et al. 2023; 2 left unrecovered), with
`source_of_label` recording per-row provenance. Only the label completion and the
join are this work; the images are not re-hosted beyond this frozen benchmark copy.
## adjacent_ring (this work)
`adjacent_ring.csv` is the only "this work" OCSR training set: a pure-logic
mined **subset of PubChem-1M**. A row is kept iff it has >=2 chiral centers with
at least two of them adjacent atoms in the same ring, the SMILES length is in
[50, 180], and RDKit can parse it. Scanning the 1,000,000-row PubChem-1M keeps
64,752 rows (6.48%). It is not a standalone dataset — whole rows are copied from
PubChem-1M, so it overlaps that source 100% by construction. Columns:
`pubchem_cid, InChI, SMILES, num_atoms`. Images render on the fly (Indigo).
(The mining rule is motivated by adjacent-ring-stereo "canary" patents, e.g.
US07320972 / US07320974; the *dataset* name is `adjacent_ring`.)
## Stereo-200K
`stereo_200k/` and `stereo_200k_white/` carry SMILES + relative `file_path`
metadata only; the images themselves are the public Hugging Face dataset
`Robert-zwr/Stereo-200k` (cite MolSight) and are re-fetched, not re-hosted here.
- `stereo_200k/` — paths into the raw Stereo-200K tree (`stereo/train/*.png`).
This is the set the training recipe and launcher reference
(`datasets/ocsr/stereo_200k`).
- `stereo_200k_white/` — the white-background + tight-crop preprocessing this
work applies (background->white, largest-cluster crop). The SMILES targets are
byte-identical to `stereo_200k`; only `file_path` differs (rewritten to the
cropped tree). The white-crop preprocessing is this work; the base images are
external.
## Data mix (recipe)
The published OCSRGlyph run trains on 2,209,724 rows:
- 1,000,000 PubChem-1M + 680,220 USPTO-680K (public MolNexTR sources,
`CYF200127/MolNexTR`), plus
- 2x 200,000 Stereo-200K + 2x 64,752 adjacent_ring.
The "x2" repeats are loader-level ConcatDataset weighting, not physical
duplication. `ocsrglyph-recipe.json` records the model/optimization knobs
(Swin-B/384 encoder, 6-layer transformer decoder, ImageNet-pretrained backbone,
effective batch 256, cosine LR 4e-4, label smoothing 0.1, seed 42); it mirrors
`configs/ocsr/ocsrglyph-stereo-enriched.yaml` in the code repo. The recipe's
`max_target_len` is 480 (the design cap); the trainer caps decode length at 256.
## Provenance summary
- **External public, referenced / re-fetched (no image bytes stored here):**
PubChem-1M, USPTO-680K, the Stereo-200K base images, and the MolScribe
recovery labels.
- **This work (transformed metadata):** `adjacent_ring.csv` (pure-logic mined
subset of PubChem-1M), the Stereo-200K white-crop preprocessing
(`stereo_200k_white`), the assembled 5,719 benchmark label composition, and
the training recipe.
- **Embedded copies:** the frozen self-contained eval parquet
`uspto_ocsr_benchmark.parquet` embeds the 5,719 `hheiden/USPTO_OCSR_benchmark`
images (public-domain USPTO patent depictions) plus the complete labels, so
`glyph ocsr eval` runs end-to-end with no reconstruction. It is the only
artifact here that carries upstream image bytes.