COMO
COMO (Closed-loop Optical Molecule recOgnition) is a deep learning framework that recognizes chemical structure diagrams from images and predicts SMILES strings with atom-level coordinates and bond matrices. It uses Minimum Risk Training (MRT) to directly optimize molecular-level, non-differentiable objectives.
Paper $\cdot$ PyPI $\cdot$ Hugging Face
Installation
pip install como-ocsr
Training requires a repository clone:
git clone https://github.com/netknowledge/COMO
cd COMO
pip install -e ".[training]"
Quick Start
import como
# Load pretrained checkpoints from Hugging Face
model = como.load_model("Keylab/COMO-Tanimoto")
# or download checkpoint files from HuggingFace:
# huggingface-cli download Keylab/COMO models/tanimoto/final.pth
model = como.load_model(checkpint_path="models/tanimoto/final.pth")
smiles = como.predict(model, "examples/sample_images/Metformin.png")
# -> CN(C)C(=N)N=C(N)N
See the getting-started guide for downloading checkpoints and the examples folder for runnable scripts and a notebook.
Training
The complete training pipeline is released in this repository: supervised MLE training, Minimum Risk Training (MRT), and the interleaved MLE + MRT joint recipe used for the released checkpoints.
# data preparation (idempotent; skips already-complete steps)
python scripts/data/prepare_pubchem_smiles.py
python scripts/data/prepare_uspto_mol.py
python scripts/data/prepare_molparser_mrt.py
python scripts/data/prepare_mol_discriminator.py
python scripts/data/prepare_benchmarks.py
# paper recipe: joint MLE + MRT with the visual reward (4 GPUs)
torchrun --nproc_per_node=4 scripts/train/train_joint_mle_mrt.py \
--smiles_list data/pubchem_smiles/pubchem_1M_seed2026.txt \
--mrt_every_n_steps 4 \
--reward_mode visual \
--visual_reward_encoder data/mol_discriminator/20260321_final.pth
All recipes, data licenses, and the exact hyperparameters of the released checkpoints: the training guide. Training data: Keylab/COMO training_data/.
Documentation
| Document | Contents |
|---|---|
| doc/getting_started.md | Install, checkpoint download, first prediction, benchmark evaluation |
| doc/api_reference.md | Full API reference (predict, predict_batch, evaluate, confidence signals, benchmarks) |
| doc/training.md | Training guide: recipes, data pipeline, licenses, reproducibility |
| examples/ | Runnable inference scripts + a guided notebook |
Model Weights
Pre-trained model weights are on HuggingFace (Keylab/COMO):
| Checkpoint | Reward Mode | Description |
|---|---|---|
models/tanimoto/final.pth |
Tanimoto | Joint MLE+MRT (Tanimoto reward) |
models/edit_distance/final.pth |
Edit Distance | Joint MLE+MRT (Edit Distance reward) |
models/visual/final.pth |
Visual | Joint MLE+MRT (Visual reward) |
Benchmark Datasets
Published as a HF Dataset with one config per benchmark:
Keylab/OCSR-Benchmarks
(CLEF, JPO, UOB, USPTO, USPTO-10K, Staker, ACS, WildMol-10K,
Indigo, ChemDraw) — full table and loading snippets in the
API reference.
Citation
If you use COMO in your research, please cite:
@article{lyu2026closed,
title={COMO: Closed-Loop Optical Molecule Recognition with Minimum Risk Training},
author={Lyu, Zhuoqi and Ke, Qing},
journal={arXiv preprint arXiv:2604.23546},
year={2026}
}
License
Code and model weights — all of COMO's source code (including the training/ pipeline and the examples) and the released .pth model weights are licensed under CC BY-NC 4.0 (non-commercial use only). See LICENSE for the full license text.
Training Data: mixed sources — see doc/training.md for the full table:
- PubChem subset: PubChem SMILES (public-domain; see PubChem terms)
- USPTO Mol: MolScribe (
yujieq/MolScribe); USPTO data is public domain - MolParser-SFT real images: UniParser/MolParser-7M — non-commercial use only
Benchmark Datasets: collected from existing public OCSR benchmarks; please refer to their original sources for license and attribution (table in doc/training.md).
Metadata
Release files for como-ocsr 1.3.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| como_ocsr-1.3.3.tar.gz | 57.6 kB | Without provenance | Details for como_ocsr-1.3.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| como_ocsr-1.3.3-py3-none-any.whl | Python 3 | none | any | Details for como_ocsr-1.3.3-py3-none-any.whl |
Total release size: 117.2 kB
Release files / como_ocsr-1.3.3.tar.gz
| Download URL | como_ocsr-1.3.3.tar.gz |
|---|---|
| Size | 57.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
05d38088dad047f3e4ba9f967ab8f126c139210d6c2941f877cceb46337652fb
|
|
BLAKE2b-256 checksum How to use checksums |
37277ef29af0c40862cde4eef224c909830f46e0f3393dc56427c36e80561c34
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.2
|
Release files / como_ocsr-1.3.3-py3-none-any.whl
| Download URL | como_ocsr-1.3.3-py3-none-any.whl |
|---|---|
| Size | 59.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
73e90873a8aee9175cb0bc6694d3a364b73a2bb3a968bdfd30c0ac1df0fa3c97
|
|
BLAKE2b-256 checksum How to use checksums |
633ecad95b1275fd8278dbfc81274fb451e4259d0479855393505773f9323752
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.2
|
Security for como-ocsr 1.3.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.