Abstract
Molecular structure recognition is the task of translating a molecular image into its graph structure. Significant variation in drawing styles and conventions exhibited in chemical literature poses a significant challenge for automating this task. In this paper, we propose MolScribe, a novel image-to-graph generation model that explicitly predicts atoms and bonds, along with their geometric layouts, to construct the molecular structure. Our model flexibly incorporates symbolic chemistry constraints to recognize chirality and expand abbreviated structures. We further develop data augmentation strategies to enhance the model robustness against domain shifts. In experiments on both synthetic and realistic molecular images, MolScribe significantly outperforms previous models, achieving 76-93% accuracy on public benchmarks. Chemists can also easily verify MolScribe's prediction, informed by its confidence estimation and atom-level alignment with the input image.
Introduction
For decades, chemical knowledge has been archived in the form of 2D images within journal articles and patents. Converting these images into machine-readable formats, such as SMILES strings or MOLfiles, is known as Optical Chemical Structure Recognition (OCSR). This task is complicated by the vast diversity in drawing conventions and styles used by different researchers and publishers.
Traditional rule-based systems are often too fragile to handle image noise or non-standard styles. Conversely, modern neural image-to-SMILES models, while more robust, often struggle with geometric reasoning, failing to correctly identify chirality or handle complex abbreviations because they lack an explicit representation of the molecular graph.
Methodology
MolScribe addresses these challenges through an image-to-graph architecture that integrates deep learning with symbolic chemistry logic.
The model utilizes a Swin Transformer as an image encoder and an autoregressive Transformer as a graph decoder. Unlike sequence-to-sequence models, MolScribe's decoder explicitly predicts a sequence of atoms, each defined by its chemical label and discretized 2D coordinates within the image. A separate feedforward network then evaluates pairs of predicted atoms to determine bond existence and type (e.g., single, double, or stereochemical wedges).
To ensure chemical accuracy, MolScribe incorporates symbolic constraints. It uses predicted coordinates and graph structure to apply formal chemistry rules via the RDKit library for stereochemistry determination. Additionally, a greedy algorithm expands abbreviated structures (superatoms) by checking chemical valency, allowing the model to handle complex groups not seen during training.
Experimental Results
MolScribe was trained on a dataset of 1.68 million examples, including synthetic data from PubChem and patent data from the USPTO. Evaluation was conducted across five public benchmarks and a new, more challenging ACS benchmark consisting of 331 images from American Chemical Society journals.
Key results include:
- State-of-the-Art Accuracy: MolScribe achieved 76–93% accuracy on public benchmarks, consistently outperforming existing models like DECIMER.
- Journal Performance: On the challenging ACS journal dataset, MolScribe reached 71.9% accuracy, a significant jump over the 59.8% achieved by baseline image-to-SMILES models.
- Human Efficiency: In a user study, MolScribe reduced the average time for a chemist to digitize a molecule from 137 seconds to just 20 seconds.
Conclusion
MolScribe demonstrates that combining neural "vision" with symbolic "chemistry logic" yields a system that is both robust and chemically accurate. By predicting atom coordinates, the model provides an interpretable alignment that allows chemists to easily verify results. While currently focused on single-molecule images, future work aims to extend MolScribe to complex reaction schemes and hand-drawn sketches.
Availability: The code and model are publicly available on GitHub.
Summary updated