Skip to main content

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

from como.model import ComoModel
model = ComoModel.from_pretrained("Keylab/COMO-Tanimoto", device="cuda")

# or download checkpoint from HuggingFace:
# huggingface-cli download Keylab/COMO models/tanimoto/final.pth
import como
model = como.load_model("models/tanimoto/final.pth", device="cuda")

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.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for como-ocsr 1.3.2
File Size Uploaded Provenance Actions
como_ocsr-1.3.2.tar.gz 57.5 kB Without provenance Details for como_ocsr-1.3.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for como-ocsr 1.3.2
File Interpreter ABI Platform Actions
como_ocsr-1.3.2-py3-none-any.whl Python 3 none any Details for como_ocsr-1.3.2-py3-none-any.whl

Total release size: 117.1 kB

Release files / como_ocsr-1.3.2.tar.gz

Download URL como_ocsr-1.3.2.tar.gz
Size 57.5 kB
Tags Source
SHA-256 checksum
How to use checksums
27c48f1b95fea87f793aceaead1d6688f746b2fc1c35a48ff186d5a42da8c358
BLAKE2b-256 checksum
How to use checksums
93d0b12755cd4d810932ebc637697c9cdb3207ca15471a09d1ef5b335e4b3039
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.0

Release files / como_ocsr-1.3.2-py3-none-any.whl

Download URL como_ocsr-1.3.2-py3-none-any.whl
Size 59.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
05ed48a2b660eb9e7693fac5ee998ad2421947ff17aef193db95960c705bd04e
BLAKE2b-256 checksum
How to use checksums
d83fec75bc098b84342df31204d589dcee777bb64d78d8d616f0bbc4cc6381a7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.0

Security for como-ocsr 1.3.2

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.

Release history Release notifications | RSS feed

This release

1.3.2 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page