PAIR: Depiction-Invariant Representation Learning for Optical Chemical Structure Recognition

Christina Yi Jin, Yuan Jin, Ziyang Chen, Baochen Wang, Qing ZhangarXiv 2026

TL;DR

Chemists draw the exact same molecule in wildly different ways—rotations, quirky fonts, blurry patent scans—which easily trips up AI models trying to read scientific literature. Instead of manually hunting for individual atoms and bonds, PAIR teaches vision models to focus on molecular identity by forcing representations of messy real-world images and clean computer renders to agree. This drop-in framework boosts chemical recognition across multiple model scales and achieves a massive leap forward on notoriously tricky "wildcard" patent molecules.

What Problem Does This Paper Address?

Imagine reading a musical score written in ten different handwritings, from crisp digital print to a coffee-stained napkin sketch. That is the daily reality of Optical Chemical Structure Recognition (OCSR)—the task of converting 2D drawings of molecules from papers and patents into machine-readable text strings like SMILES (a standard notation for chemical graphs).

Current top-tier OCSR systems try to solve this explicitly: they detect individual atoms and bonds like puzzle pieces and stitch the graph back together. While effective on familiar styles, this doesn't stop the visual encoder from getting distracted by how a molecule is drawn. Change the font, tweak the bond angles, or add scan noise, and these pipelines can stumble. The authors ask a fundamental question: instead of just supervising the final output, can we force the model's internal representations to ignore artistic style altogether and organize strictly around the underlying chemical identity?

Methods

Enter PAIR (Paired-view Alignment for Invariant Recognition), a training framework that treats different drawings of the same molecule as views of the same underlying truth.

Figure 1. The framework of Depiction-Invariant Representation Learning (PAIR).

During training, PAIR takes two images of the same molecule—a noisy "real" image from a document and a clean, synthetically "rendered" image—and passes them through a shared image encoder. What happens next combines standard building blocks in a clever new way:

  1. Shared Learnable Queries: Borrowed from vision-language architectures (like BLIP-2's Q-Former), a small set of learnable query tokens uses cross-attention to extract a compact summary of the molecule from each image's spatial features.
  2. Cross-View Contrastive Alignment: Using a CLIP-style contrastive loss, PAIR pulls the pooled query summaries of the same molecule together in embedding space while pushing different molecules apart.
  3. Residual Query Refinement (The Secret Sauce): Pure invariance can accidentally scrub away tiny, crucial details (like a single charge or bond order). To prevent this, PAIR adds the aligned query tokens back into the original spatial image features via a residual connection before sending them to an autoregressive SMILES text decoder.

At inference time, the training wheels come off: you only feed in a single real-world image, and the model decodes its structure directly.

Datasets

No new datasets were introduced; PAIR was trained and tested on established chemical benchmarks:

  • Training: Paired views from MolGallery and the real-image supervised fine-tuning split of MolParser-7M (with a 403-image validation split).
  • Evaluation (6 diverse test sets): Real-world patent scans (USPTO), chemical catalogs (UOB), scientific journals (ACS), synthetically rendered molecules (Indigo), and two subsets from WildMol: Simple (conventional structures) and Markush (complex, generalized patent structures featuring variable placeholder groups).

Key Insights and Ideas

  • Invariance vs. Chemical Sufficiency is a Balancing Act: You might assume cranking up the contrastive alignment weight ($\lambda$) always helps. Not so! As shown below, pushing depictions to look too identical eventually hurts exact accuracy because the model blurs away fine-grained structural details. Residual fusion rescues those local spatial cues, peaking neatly around $\lambda = 0.5$.
Figure 2. The framework of Depiction-Invariant Representation Learning (PAIR).
  • Pushing Strangers Apart Matters Most: When analyzing the learned embeddings, PAIR's biggest impact wasn't making matching molecules look slightly closer—it was drastically lowering the accidental similarity between different molecules, creating clean, distinct pockets for each chemical graph.
  • Implicit Learning Conquers Markush Structures: Markush structures (used in patents to claim whole families of molecules at once using variable "R-groups") break traditional atom-and-bond detectors. Without any hardcoded Markush rules, PAIR thrives here simply by learning to ignore chaotic drawing variations while preserving local text/group details.

Key Results

The authors plugged PAIR into three diverse backbones: a tiny 10M-parameter specialist (Mobile-V2), a 256M vision-language model (SmolVLM), and a 2B vision-language model (Qwen3-VL-2B).

  • Benchmark Accuracy: PAIR improves mean accuracy across all three backbones. The largest variant (PAIR-2B) achieves the highest overall exact accuracy across the six datasets (85.92% reported in the text; 87.29% in Table 1), beating its Qwen3-VL-2B baseline on five of six benchmarks (dipping slightly by 1.56 points only on synthetic Indigo images).
  • Markush Breakthrough: On Markush structures, PAIR-2B hits roughly 61.2%–62.7% accuracy, outperforming the strong task-specific OCSR model Mobile-V2 (53.09%) by roughly 10 percentage points—while older graph-based tools like MolScribe score just 11.30%.
  • Better "Near Misses": Even when PAIR misses an exact match, its partial graph recovery jumps substantially. On Mobile-V2, PAIR boosts Tanimoto fingerprint similarity from 0.6139 to 0.7228 and bond (edge) recall from 0.7038 to 0.8508.
  • Near-Perfect Cross-View Retrieval: Given a messy real drawing, PAIR-V2 retrieves its clean rendered twin at Rank-1 98.71% of the time (up from 85.05%).

Limitations and Future Work

  • Stereochemistry Left on the Table: The current evaluation ignores 3D spatial bond orientations (like dashed or wedged bonds indicating chirality). Whether cross-view alignment preserves subtle 3D cues remains an open question.
  • No Formal Guarantees: PAIR empirically approximates depiction invariance, but performance still varies by backbone, dataset style, and contrastive weight tuning—and better partial graph recovery doesn't always yield a 100% exact string match.
  • Next Steps: Future work could explore chemically informed contrastive losses (so structurally similar cousin molecules aren't pushed apart as harshly as unrelated ones), adaptive alignment weights, and full support for stereochemistry.

Summary updated

BibTeX
@misc{jin2026pair,
  author = {Christina Yi Jin and Yuan Jin and Ziyang Chen and Baochen Wang and Qing Zhang},
  title = {{PAIR: Depiction-Invariant Representation Learning for Optical Chemical Structure Recognition}},
  year = {2026},
  eprint = {2611.40395},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2611.40395},
}
Figure