<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Markush Structures on Hunter Heidenreich | ML Research Scientist</title><link>https://hunterheidenreich.com/notes/chemistry/optical-structure-recognition/markush/</link><description>Recent content in Markush Structures on Hunter Heidenreich | ML Research Scientist</description><image><title>Hunter Heidenreich | ML Research Scientist</title><url>https://hunterheidenreich.com/img/avatar.webp</url><link>https://hunterheidenreich.com/img/avatar.webp</link></image><generator>Hugo -- 0.147.7</generator><language>en-US</language><copyright>2026 Hunter Heidenreich</copyright><lastBuildDate>Tue, 07 Apr 2026 00:00:00 +0000</lastBuildDate><atom:link href="https://hunterheidenreich.com/notes/chemistry/optical-structure-recognition/markush/index.xml" rel="self" type="application/rss+xml"/><item><title>MarkushGrapher-2: End-to-End Markush Recognition</title><link>https://hunterheidenreich.com/notes/chemistry/optical-structure-recognition/markush/markushgrapher-2-multimodal-recognition/</link><pubDate>Mon, 06 Apr 2026 00:00:00 +0000</pubDate><guid>https://hunterheidenreich.com/notes/chemistry/optical-structure-recognition/markush/markushgrapher-2-multimodal-recognition/</guid><description>MarkushGrapher-2 fuses vision, text, and layout encoders with a dedicated OCR module for end-to-end Markush structure recognition from patent images.</description><content:encoded><![CDATA[<h2 id="a-multimodal-method-for-markush-structure-recognition">A Multimodal Method for Markush Structure Recognition</h2>
<p>This is a <strong>Method</strong> paper that introduces MarkushGrapher-2, a universal encoder-decoder model for recognizing both standard molecular structures and multimodal Markush structures from chemical images. The primary contribution is a dual-encoder architecture that fuses a pretrained OCSR (Optical Chemical Structure Recognition) vision encoder with a Vision-Text-Layout (VTL) encoder, connected through a dedicated ChemicalOCR module for end-to-end processing. The paper also introduces two new resources: a large-scale training dataset (USPTO-MOL-M) of real-world Markush structures extracted from USPTO patent MOL files, and IP5-M, a manually annotated benchmark of 1,000 Markush structures from five major patent offices.</p>
<h2 id="why-markush-structure-recognition-remains-challenging">Why Markush Structure Recognition Remains Challenging</h2>
<p><a href="https://en.wikipedia.org/wiki/Markush_structure">Markush structures</a> are compact representations used in patent documents to describe families of related molecules. They combine a visual backbone (atoms, bonds, variable regions) with textual definitions of substituents that can replace those variable regions. This multimodal nature makes them harder to parse than standard molecular diagrams.</p>
<p>Three factors limit automatic Markush recognition. First, visual styles vary across patent offices and publication years. Second, textual definitions lack standardization and often contain conditional or recursive descriptions. Third, real-world training data with comprehensive annotations is scarce. As a result, Markush structures are currently indexed only in two proprietary, manually curated databases: MARPAT and DWPIM.</p>
<p>Prior work, including the original <a href="/notes/chemistry/optical-structure-recognition/markush/markushgrapher/">MarkushGrapher</a>, required pre-annotated OCR outputs at inference time, limiting practical deployment. General-purpose models like GPT-5 and DeepSeek-OCR produce mostly chemically invalid outputs on Markush images, suggesting these lie outside their training distribution.</p>
<h2 id="dual-encoder-architecture-with-dedicated-chemicalocr">Dual-Encoder Architecture with Dedicated ChemicalOCR</h2>
<p>MarkushGrapher-2 uses two complementary encoding pipelines:</p>
<ol>
<li>
<p><strong>Vision encoder pipeline</strong>: The input image passes through a Swin-B Vision Transformer (taken from <a href="/notes/chemistry/optical-structure-recognition/image-to-graph/molscribe/">MolScribe</a>) pretrained for OCSR. This encoder extracts visual features representing molecular structures and remains frozen during training.</p>
</li>
<li>
<p><strong>Vision-Text-Layout (VTL) pipeline</strong>: The same image goes through ChemicalOCR, a compact 256M-parameter vision-language model fine-tuned from SmolDocling for OCR on chemical images. ChemicalOCR extracts character-level text and bounding boxes. These, combined with image patches, feed into a T5-base VTL encoder following the UDOP fusion paradigm, where visual and textual tokens are spatially aligned by bounding box overlap.</p>
</li>
</ol>
<p>The VTL encoder output is concatenated with projected embeddings from the vision encoder. This joint representation feeds a text decoder that auto-regressively generates a CXSMILES (ChemAxon Extended <a href="/notes/chemistry/molecular-representations/notations/smiles/">SMILES</a>) string describing the backbone structure and a substituent table listing variable group definitions.</p>
<h3 id="two-stage-training-strategy">Two-Stage Training Strategy</h3>
<p>Training proceeds in two phases:</p>
<ul>
<li>
<p><strong>Phase 1 (Adaptation)</strong>: The vision encoder is frozen. The MLP projector and text decoder train on 243K real-world image-SMILES pairs from MolScribe&rsquo;s USPTO dataset (3 epochs). This aligns the decoder to the pretrained OCSR feature space.</p>
</li>
<li>
<p><strong>Phase 2 (Fusion)</strong>: The vision encoder, projector, and ChemicalOCR are all frozen. The VTL encoder and text decoder train on a mix of 235K synthetic and 145K real-world Markush samples (2 epochs). The VTL encoder learns the features needed for CXSMILES and substituent table prediction without disrupting the established OCSR representations.</p>
</li>
</ul>
<p>The total model has 831M parameters, of which 744M are trainable.</p>
<h2 id="datasets-and-evaluation-benchmarks">Datasets and Evaluation Benchmarks</h2>
<h3 id="training-data">Training Data</h3>
<table>
  <thead>
      <tr>
          <th>Purpose</th>
          <th>Dataset</th>
          <th>Size</th>
          <th>Source</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>OCR pretraining</td>
          <td>Synthetic chemical structures</td>
          <td>235K</td>
          <td><a href="https://en.wikipedia.org/wiki/PubChem">PubChem</a> SMILES augmented to CXSMILES, rendered with annotations</td>
      </tr>
      <tr>
          <td>OCR fine-tuning</td>
          <td>Manual OCR annotations</td>
          <td>7K</td>
          <td>IP5 patent document crops</td>
      </tr>
      <tr>
          <td>Phase 1 (OCSR)</td>
          <td>MolScribe USPTO</td>
          <td>243K</td>
          <td>Real image-SMILES pairs</td>
      </tr>
      <tr>
          <td>Phase 2 (MMSR)</td>
          <td>Synthetic CXSMILES</td>
          <td>235K</td>
          <td>Same as OCR pretraining set</td>
      </tr>
      <tr>
          <td>Phase 2 (MMSR)</td>
          <td>MolParser dataset</td>
          <td>91K</td>
          <td>Real-world Markush, converted to CXSMILES</td>
      </tr>
      <tr>
          <td>Phase 2 (MMSR)</td>
          <td>USPTO-MOL-M</td>
          <td>54K</td>
          <td>Real-world, auto-extracted from USPTO MOL files (2010-2025)</td>
      </tr>
  </tbody>
</table>
<h3 id="evaluation-benchmarks">Evaluation Benchmarks</h3>
<p><strong>Markush benchmarks</strong>: M2S (103 samples), USPTO-M (74), WildMol-M (10K, semi-manual), and the new IP5-M (1,000 manually annotated from USPTO, JPO, KIPO, CNIPA, and EPO patents, 1980-2025).</p>
<p><strong>OCSR benchmarks</strong>: USPTO (5,719), JPO (450), UOB (5,740), WildMol (10K).</p>
<p>The primary metric is <strong>CXSMILES Accuracy (A)</strong>: a prediction is correct when (1) the predicted SMILES matches the ground truth by <a href="/notes/chemistry/molecular-representations/notations/inchi-2013/">InChIKey</a> equivalence, and (2) all Markush features (variable groups, positional and frequency variation indicators) are correctly represented. Stereochemistry is ignored during evaluation.</p>
<h3 id="results-markush-structure-recognition">Results: Markush Structure Recognition</h3>
<table>
  <thead>
      <tr>
          <th>Model</th>
          <th>M2S</th>
          <th>USPTO-M</th>
          <th>WildMol-M</th>
          <th>IP5-M</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>MolParser-Base</td>
          <td>39</td>
          <td>30</td>
          <td>38.1</td>
          <td>47.7</td>
      </tr>
      <tr>
          <td>MolScribe</td>
          <td>21</td>
          <td>7</td>
          <td>28.1</td>
          <td>22.3</td>
      </tr>
      <tr>
          <td>GPT-5</td>
          <td>3</td>
          <td>0</td>
          <td>-</td>
          <td>-</td>
      </tr>
      <tr>
          <td>DeepSeek-OCR</td>
          <td>0</td>
          <td>0</td>
          <td>1.9</td>
          <td>0.0</td>
      </tr>
      <tr>
          <td>MarkushGrapher-1</td>
          <td>38</td>
          <td>10</td>
          <td>32</td>
          <td>-</td>
      </tr>
      <tr>
          <td><strong>MarkushGrapher-2</strong></td>
          <td><strong>56</strong></td>
          <td><strong>13</strong></td>
          <td><strong>55</strong></td>
          <td><strong>48.0</strong></td>
      </tr>
  </tbody>
</table>
<p>On M2S, MarkushGrapher-2 achieves 56% CXSMILES accuracy vs. 38% for MarkushGrapher-1, a relative improvement of 47%. On WildMol-M (the largest benchmark at 10K samples), MarkushGrapher-2 reaches 55% vs. 38.1% for MolParser-Base and 32% for MarkushGrapher-1. GPT-5 and DeepSeek-OCR generate mostly chemically invalid outputs on Markush images: only 30% and 15% of their predictions are valid CXSMILES on M2S, respectively.</p>
<h3 id="results-standard-molecular-structure-recognition">Results: Standard Molecular Structure Recognition</h3>
<table>
  <thead>
      <tr>
          <th>Model</th>
          <th>WildMol</th>
          <th>JPO</th>
          <th>UOB</th>
          <th>USPTO</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>MolParser-Base</td>
          <td>76.9</td>
          <td>78.9</td>
          <td>91.8</td>
          <td>93.0</td>
      </tr>
      <tr>
          <td>MolScribe</td>
          <td>66.4</td>
          <td>76.2</td>
          <td>87.4</td>
          <td>93.1</td>
      </tr>
      <tr>
          <td>DECIMER 2.7</td>
          <td>56.0</td>
          <td>64.0</td>
          <td>88.3</td>
          <td>59.9</td>
      </tr>
      <tr>
          <td><a href="/notes/chemistry/optical-structure-recognition/image-to-graph/molgrapher/">MolGrapher</a></td>
          <td>45.5</td>
          <td>67.5</td>
          <td>94.9</td>
          <td>91.5</td>
      </tr>
      <tr>
          <td>DeepSeek-OCR</td>
          <td>25.8</td>
          <td>31.6</td>
          <td>78.7</td>
          <td>36.9</td>
      </tr>
      <tr>
          <td><strong>MarkushGrapher-2</strong></td>
          <td>68.4</td>
          <td>71.0</td>
          <td><strong>96.6</strong></td>
          <td>89.8</td>
      </tr>
  </tbody>
</table>
<p>MarkushGrapher-2 achieves the highest score on UOB (96.6%) and remains competitive on other OCSR benchmarks, despite being primarily optimized for Markush recognition.</p>
<h3 id="chemicalocr-vs-general-ocr">ChemicalOCR vs. General OCR</h3>
<table>
  <thead>
      <tr>
          <th>Model</th>
          <th>M2S F1</th>
          <th>USPTO-M F1</th>
          <th>IP5-M F1</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>PaddleOCR v5</td>
          <td>7.7</td>
          <td>1.2</td>
          <td>1.9</td>
      </tr>
      <tr>
          <td>EasyOCR</td>
          <td>10.2</td>
          <td>18.0</td>
          <td>18.4</td>
      </tr>
      <tr>
          <td><strong>ChemicalOCR</strong></td>
          <td><strong>87.2</strong></td>
          <td><strong>93.0</strong></td>
          <td><strong>86.5</strong></td>
      </tr>
  </tbody>
</table>
<p>General-purpose OCR tools fail on chemical images because they misinterpret bonds as characters and cannot parse chemical abbreviations. ChemicalOCR outperforms both by a large margin.</p>
<h2 id="ablation-results-and-key-findings">Ablation Results and Key Findings</h2>
<p><strong>OCR input is critical for Markush features.</strong> Without OCR, CXSMILES accuracy drops from 56% to 4% on M2S, and from 53.7% to 15.4% on IP5-M. The backbone structure accuracy ($A_{\text{InChIKey}}$) also drops substantially (from 80% to 39% on M2S), though the vision encoder alone can still recover some structural information. This confirms that textual cues (brackets, indices, variable definitions) are essential for Markush feature prediction.</p>
<p><strong>Two-phase training improves both tasks.</strong> Compared to single-phase (fusion only) training, the two-phase strategy improves CXSMILES accuracy from 44% to 50% on M2S and from 53.0% to 61.5% on JPO after the same number of epochs. Adapting the decoder to OCSR features before introducing the VTL encoder prevents the fusion process from degrading learned visual representations.</p>
<p><strong>Frequency variation indicators remain the hardest feature.</strong> On IP5-M, the per-feature breakdown shows 73.3% accuracy for backbone InChI, 74.8% for variable groups, 78.8% for positional variation, but only 30.7% for frequency variation (Sg groups). These repeating structural units are particularly challenging to represent and predict.</p>
<p><strong>Limitations</strong>: The model relies on accurate OCR as a prerequisite. Performance on USPTO-M (13% CXSMILES accuracy) lags behind other benchmarks, likely due to the older patent styles in that dataset. The paper does not report inference latency.</p>
<hr>
<h2 id="reproducibility-details">Reproducibility Details</h2>
<h3 id="data">Data</h3>
<table>
  <thead>
      <tr>
          <th>Purpose</th>
          <th>Dataset</th>
          <th>Size</th>
          <th>Notes</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>OCR pretraining</td>
          <td>Synthetic chemical images</td>
          <td>235K</td>
          <td>Generated from PubChem SMILES, augmented to CXSMILES</td>
      </tr>
      <tr>
          <td>OCR fine-tuning</td>
          <td>IP5 patent crops</td>
          <td>7K</td>
          <td>Manually annotated</td>
      </tr>
      <tr>
          <td>Phase 1 training</td>
          <td>MolScribe USPTO</td>
          <td>243K</td>
          <td>Public, real image-SMILES pairs</td>
      </tr>
      <tr>
          <td>Phase 2 training</td>
          <td>Synthetic + MolParser + USPTO-MOL-M</td>
          <td>380K</td>
          <td>Mix of synthetic (235K), MolParser (91K), USPTO-MOL-M (54K)</td>
      </tr>
      <tr>
          <td>Evaluation</td>
          <td>M2S, USPTO-M, WildMol-M, IP5-M</td>
          <td>103 to 10K</td>
          <td>Markush benchmarks</td>
      </tr>
      <tr>
          <td>Evaluation</td>
          <td>WildMol, JPO, UOB, USPTO</td>
          <td>450 to 10K</td>
          <td>OCSR benchmarks</td>
      </tr>
  </tbody>
</table>
<h3 id="models">Models</h3>
<table>
  <thead>
      <tr>
          <th>Component</th>
          <th>Architecture</th>
          <th>Parameters</th>
          <th>Status</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>Vision encoder</td>
          <td>Swin-B ViT (from MolScribe)</td>
          <td>~87M</td>
          <td>Frozen</td>
      </tr>
      <tr>
          <td>VTL encoder + decoder</td>
          <td>T5-base</td>
          <td>~744M trainable</td>
          <td>Trained</td>
      </tr>
      <tr>
          <td>ChemicalOCR</td>
          <td>SmolDocling-based VLM</td>
          <td>256M</td>
          <td>Fine-tuned, frozen in Phase 2</td>
      </tr>
      <tr>
          <td>MLP projector</td>
          <td>Linear projection</td>
          <td>-</td>
          <td>Trained in Phase 1, frozen in Phase 2</td>
      </tr>
      <tr>
          <td><strong>Total</strong></td>
          <td></td>
          <td><strong>831M</strong></td>
          <td></td>
      </tr>
  </tbody>
</table>
<h3 id="evaluation">Evaluation</h3>
<table>
  <thead>
      <tr>
          <th>Metric</th>
          <th>Definition</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>CXSMILES Accuracy (A)</td>
          <td>Percentage of samples where InChIKey matches AND all Markush features correct</td>
      </tr>
      <tr>
          <td>$A_{\text{InChIKey}}$</td>
          <td>Backbone structure accuracy only (ignoring Markush features)</td>
      </tr>
      <tr>
          <td>Table Accuracy</td>
          <td>Percentage of correctly predicted substituent tables</td>
      </tr>
      <tr>
          <td>Markush Accuracy</td>
          <td>Joint CXSMILES + Table accuracy</td>
      </tr>
      <tr>
          <td>OCR F1</td>
          <td>Bounding-box-level precision/recall at IoU &gt; 0.5</td>
      </tr>
  </tbody>
</table>
<h3 id="hardware">Hardware</h3>
<ul>
<li>Training: NVIDIA A100 GPU</li>
<li>Phase 1: 3 epochs, Adam optimizer, lr 5e-4, 1000 warmup steps, batch size 10, weight decay 1e-3</li>
<li>Phase 2: 2 epochs, batch size 8</li>
</ul>
<h3 id="artifacts">Artifacts</h3>
<table>
  <thead>
      <tr>
          <th>Artifact</th>
          <th>Type</th>
          <th>License</th>
          <th>Notes</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td><a href="https://github.com/DS4SD/MarkushGrapher">MarkushGrapher GitHub</a></td>
          <td>Code</td>
          <td>MIT</td>
          <td>Official implementation of MarkushGrapher-2 with models and datasets</td>
      </tr>
  </tbody>
</table>
<p><strong>Reproducibility classification</strong>: Highly Reproducible. Code, models, and datasets are all publicly released under an MIT license with documented training hyperparameters and a single A100 GPU requirement.</p>
<hr>
<h2 id="paper-information">Paper Information</h2>
<p><strong>Citation</strong>: Strohmeyer, T., Morin, L., Meijer, G. I., Weber, V., Nassar, A., &amp; Staar, P. (2026). MarkushGrapher-2: End-to-end Multimodal Recognition of Chemical Structures. In <em>Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)</em>.</p>
<p><strong>Publication</strong>: CVPR 2026</p>
<p><strong>Additional Resources</strong>:</p>
<ul>
<li><a href="https://github.com/DS4SD/MarkushGrapher">GitHub Repository (MIT License)</a></li>
<li><a href="https://arxiv.org/abs/2603.28550">arXiv Preprint</a></li>
</ul>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bibtex" data-lang="bibtex"><span style="display:flex;"><span><span style="color:#a6e22e">@misc</span>{strohmeyer2026markushgrapher,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">title</span>=<span style="color:#e6db74">{MarkushGrapher-2: End-to-end Multimodal Recognition of Chemical Structures}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">author</span>=<span style="color:#e6db74">{Strohmeyer, Tim and Morin, Lucas and Meijer, Gerhard Ingmar and Weber, Val\&#39;{e}ry and Nassar, Ahmed and Staar, Peter}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">year</span>=<span style="color:#e6db74">{2026}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">eprint</span>=<span style="color:#e6db74">{2603.28550}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">archiveprefix</span>=<span style="color:#e6db74">{arXiv}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">primaryclass</span>=<span style="color:#e6db74">{cs.CV}</span>
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div>]]></content:encoded></item><item><title>MarkushGrapher: Multi-modal Markush Structure Recognition</title><link>https://hunterheidenreich.com/notes/chemistry/optical-structure-recognition/markush/markushgrapher/</link><pubDate>Fri, 19 Dec 2025 00:00:00 +0000</pubDate><guid>https://hunterheidenreich.com/notes/chemistry/optical-structure-recognition/markush/markushgrapher/</guid><description>Multi-modal transformer combining vision, text, and layout encoding to extract complex Markush structures from patent documents with OCSR.</description><content:encoded><![CDATA[<h2 id="overcoming-unimodal-limitations-for-markush-structures">Overcoming Unimodal Limitations for Markush Structures</h2>
<p>The automated analysis of chemical literature, particularly patents, is critical for drug discovery and material science. A major bottleneck is the extraction of <strong>Markush structures</strong>, which are complex chemical templates that represent families of molecules using a core backbone image and textual variable definitions. Existing methods are limited because they either rely solely on images (OCSR) and miss the textual context, or focus solely on text and miss the structural backbone. This creates a practical need for a unified, multi-modal approach that jointly interprets visual and textual data to accurately extract these structures for prior-art search and database construction. This paper proposes a <strong>Method</strong> and introduces a new <strong>Resource</strong> (M2S dataset) to bridge this gap.</p>
<h2 id="markushgrapher-the-multi-modal-architecture">MarkushGrapher: The Multi-Modal Architecture</h2>
<p>The core innovation is <strong>MarkushGrapher</strong>, a multi-modal architecture that jointly encodes image, text, and layout information. Key contributions include:</p>
<ul>
<li><strong>Dual-Encoder Architecture</strong>: Combines a Vision-Text-Layout (VTL) encoder (based on UDOP) with a specialized, pre-trained Optical Chemical Structure Recognition (OCSR) encoder (MolScribe). Let $E_{\text{VTL}}$ represent the combined sequence embedding and $E_{\text{OCSR}}$ represent the domain-specific visual embeddings.</li>
<li><strong>Joint Recognition</strong>: The model autoregressively generates a sequential graph representation (Optimized CXSMILES) and a substituent table simultaneously. It uses cross-modal dependencies, allowing text to clarify ambiguous visual details like bond types.</li>
<li><strong>Synthetic Data Pipeline</strong>: A comprehensive pipeline generates realistic synthetic Markush structures (images and text) from PubChem data, overcoming the lack of labeled training data.</li>
<li><strong>Optimized Representation</strong>: A compacted version of CXSMILES moves variable groups into the SMILES string and adds explicit atom indexing to handle complex &ldquo;frequency&rdquo; and &ldquo;position&rdquo; variation indicators.</li>
</ul>
<h2 id="experimental-validation-on-the-new-m2s-benchmark">Experimental Validation on the New M2S Benchmark</h2>
<p>The authors validated their approach using the following setup:</p>
<ul>
<li><strong>Baselines</strong>: Compared against image-only chemistry models (DECIMER, MolScribe) and general-purpose multi-modal models (Uni-SMART, GPT-4o, Pixtral, Llama-3.2).</li>
<li><strong>Datasets</strong>: Evaluated on three benchmarks:
<ol>
<li><strong>MarkushGrapher-Synthetic</strong>: 1,000 generated samples.</li>
<li><strong>M2S</strong>: A new benchmark of 103 manually annotated real-world patent images.</li>
<li><strong>USPTO-Markush</strong>: 74 Markush backbone images from USPTO patents.</li>
</ol>
</li>
<li><strong>Ablation Studies</strong>: Analyzed the impact of the OCSR encoder, late fusion strategies, and the optimized CXSMILES format. Late fusion improved USPTO-Markush EM from 23% (VTL only) to 32% (Table 3). Removing R-group compression dropped M2S EM from 38% to 30%, and removing atom indexing dropped USPTO-Markush EM from 32% to 24% (Table 4).</li>
</ul>
<h2 id="key-results">Key Results</h2>
<ul>
<li><strong>Performance</strong>: MarkushGrapher outperformed all baselines. On the M2S benchmark, it achieved 38% Exact Match on CXSMILES (compared to 21% for MolScribe) and 29% Exact Match on tables. On USPTO-Markush, it reached 32% CXSMILES EM versus 7% for MolScribe.</li>
<li><strong>Markush Feature Recognition</strong>: The model can recognize complex Markush features like frequency variation (&lsquo;Sg&rsquo;) and position variation (&rsquo;m&rsquo;) indicators. DECIMER and MolScribe scored 0% on both &rsquo;m&rsquo; and &lsquo;Sg&rsquo; sections (Table 2), while MarkushGrapher achieved 76% on &rsquo;m&rsquo; and 31% on &lsquo;Sg&rsquo; sections on M2S.</li>
<li><strong>Cross-Modal Reasoning</strong>: Qualitative analysis showed the model can correctly infer visual details (such as bond order) that appear ambiguous in the image but become apparent with the text description.</li>
<li><strong>Robustness</strong>: The model generalizes well to real-world data despite being trained purely on synthetic data. On augmented versions of M2S and USPTO-Markush simulating low-quality scanned documents, it maintained 31% and 32% CXSMILES EM respectively (Table 6).</li>
</ul>
<h2 id="limitations">Limitations</h2>
<p>The authors note several limitations:</p>
<ul>
<li>MarkushGrapher does not currently handle abbreviations in chemical structures (e.g., &lsquo;OG&rsquo; for oxygen connected to a variable group).</li>
<li>The model relies on ground-truth OCR cells as input, requiring an external OCR model for practical deployment.</li>
<li>Substituent definitions that combine text with interleaved chemical structure drawings are not supported.</li>
<li>The model is trained to predict &rsquo;m&rsquo; sections connecting to all atoms in a cycle, which can technically violate valence constraints, though the output contains enough information to reconstruct only valid connections.</li>
</ul>
<hr>
<h2 id="reproducibility-details">Reproducibility Details</h2>
<h3 id="data">Data</h3>
<p><strong>Training Data</strong></p>
<ul>
<li><strong>Source</strong>: Synthetic dataset generated from PubChem SMILES.</li>
<li><strong>Size</strong>: 210,000 synthetic images.</li>
<li><strong>Pipeline</strong>:
<ol>
<li><strong>Selection</strong>: Sampled SMILES from PubChem based on substructure diversity.</li>
<li><strong>Augmentation</strong>: SMILES augmented to artificial CXSMILES using RDKit (inserting variable groups, frequency indicators).</li>
<li><strong>Rendering</strong>: Images rendered using Chemistry Development Kit (CDK) with randomized drawing parameters (font, bond width, spacing).</li>
<li><strong>Text Generation</strong>: Textual definitions generated using manual templates extracted from patents; 10% were paraphrased using Mistral-7B-Instruct-v0.3 to increase diversity.</li>
<li><strong>OCR</strong>: Bounding boxes extracted via a custom SVG parser aligned with MOL files.</li>
</ol>
</li>
</ul>
<p><strong>Evaluation Data</strong></p>
<ul>
<li><strong>M2S Dataset</strong>: 103 images from USPTO, EPO, and WIPO patents (1999-2023), manually annotated with CXSMILES and substituent tables.</li>
<li><strong>USPTO-Markush</strong>: 74 images from USPTO patents (2010-2016).</li>
<li><strong>MarkushGrapher-Synthetic</strong>: 1,000 samples generated via the pipeline.</li>
</ul>
<h3 id="algorithms">Algorithms</h3>
<ul>
<li><strong>Optimized CXSMILES</strong>:
<ul>
<li><strong>Compression</strong>: Variable groups moved from the extension block to the main SMILES string as special atoms to reduce sequence length.</li>
<li><strong>Indexing</strong>: Atom indices appended to each atom (e.g., <code>C:1</code>) to explicitly link the graph to the extension block (crucial for <code>m</code> and <code>Sg</code> sections).</li>
<li><strong>Vocabulary</strong>: Specific tokens used for atoms and bonds.</li>
</ul>
</li>
<li><strong>Augmentation</strong>: Standard image augmentations (shift, scale, blur, pepper noise, random lines) and OCR text augmentations (character substitution/insertion/deletion).</li>
</ul>
<h3 id="models">Models</h3>
<ul>
<li><strong>Architecture</strong>: Encoder-Decoder Transformer.
<ul>
<li><strong>VTL Encoder</strong>: T5-large encoder (initialized from UDOP) that processes image patches, text tokens, and layout (bounding boxes).</li>
<li><strong>OCSR Encoder</strong>: Vision encoder from MolScribe (Swin Transformer), frozen during training.</li>
<li><strong>Text Decoder</strong>: T5-large decoder.</li>
</ul>
</li>
<li><strong>Fusion Strategy</strong>: <strong>Late Fusion</strong>. The core multi-modal alignment combines the textual layout features with specialized chemical vision explicitly. The fused representation relies on the VTL output $e_1$ concatenated with the MLP-projected OCSR output $e_2$ before decoding:
$$ e = e_1(v, t, l) \oplus \text{MLP}(e_2(v)) $$</li>
<li><strong>Parameters</strong>: 831M total (744M trainable).</li>
</ul>
<h3 id="evaluation">Evaluation</h3>
<p><strong>Metrics</strong>:</p>
<ul>
<li><strong>CXSMILES Exact Match (EM)</strong>: Requires perfect match of SMILES string, variable groups, <code>m</code> sections, and <code>Sg</code> sections (ignoring stereochemistry).</li>
<li><strong>Tanimoto Score</strong>: Similarity of RDKit DayLight fingerprints (Markush features removed).</li>
<li><strong>Table Exact Match</strong>: All variable groups and substituents must match.</li>
<li><strong>Table F1-Score</strong>: Aggregated recall and precision of substituents per variable group.</li>
</ul>
<h3 id="hardware">Hardware</h3>
<ul>
<li><strong>Compute</strong>: Trained on a single NVIDIA H100 GPU.</li>
<li><strong>Training Config</strong>: 10 epochs, batch size of 10, ADAM optimizer, learning rate 5e-4, 100 warmup steps, weight decay 1e-3.</li>
</ul>
<h3 id="artifacts">Artifacts</h3>
<table>
  <thead>
      <tr>
          <th>Artifact</th>
          <th>Type</th>
          <th>License</th>
          <th>Notes</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td><a href="https://github.com/DS4SD/MarkushGrapher">MarkushGrapher</a></td>
          <td>Code</td>
          <td>MIT</td>
          <td>Official implementation</td>
      </tr>
  </tbody>
</table>
<hr>
<h2 id="paper-information">Paper Information</h2>
<p><strong>Citation</strong>: Morin, L., Weber, V., Nassar, A., Meijer, G. I., Van Gool, L., Li, Y., &amp; Staar, P. (2025). MarkushGrapher: Joint Visual and Textual Recognition of Markush Structures. <em>2025 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)</em>, 14505-14515. <a href="https://doi.org/10.1109/CVPR52734.2025.01352">https://doi.org/10.1109/CVPR52734.2025.01352</a></p>
<p><strong>Publication</strong>: CVPR 2025</p>
<p><strong>Additional Resources</strong>:</p>
<ul>
<li><a href="https://github.com/DS4SD/MarkushGrapher">GitHub Repository</a></li>
</ul>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bibtex" data-lang="bibtex"><span style="display:flex;"><span><span style="color:#a6e22e">@inproceedings</span>{morinMarkushGrapherJointVisual2025,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">title</span> = <span style="color:#e6db74">{MarkushGrapher: Joint Visual and Textual Recognition of Markush Structures}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">shorttitle</span> = <span style="color:#e6db74">{MarkushGrapher}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">booktitle</span> = <span style="color:#e6db74">{2025 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">author</span> = <span style="color:#e6db74">{Morin, Lucas and Weber, Valéry and Nassar, Ahmed and Meijer, Gerhard Ingmar and Van Gool, Luc and Li, Yawei and Staar, Peter}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">year</span> = <span style="color:#e6db74">{2025}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">month</span> = jun,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">pages</span> = <span style="color:#e6db74">{14505--14515}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">doi</span> = <span style="color:#e6db74">{10.1109/CVPR52734.2025.01352}</span>
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div>]]></content:encoded></item><item><title>One Strike, You're Out: Detecting Markush Structures</title><link>https://hunterheidenreich.com/notes/chemistry/optical-structure-recognition/markush/jurriaans-markush-detection-2023/</link><pubDate>Thu, 18 Dec 2025 00:00:00 +0000</pubDate><guid>https://hunterheidenreich.com/notes/chemistry/optical-structure-recognition/markush/jurriaans-markush-detection-2023/</guid><description>Patch-based CNN method for detecting Markush structures in chemical images, addressing low signal-to-noise ratios in OCSR.</description><content:encoded><![CDATA[<h2 id="methodology-and-classification">Methodology and Classification</h2>
<p>This is a <strong>Method</strong> paper (Classification: $\Psi_{\text{Method}}$).</p>
<p>It proposes a patch-based classification pipeline to solve a technical failure mode in Optical Chemical Structure Recognition (OCSR). Distinct rhetorical indicators include a baseline comparison (CNN vs. traditional ORB), ablation studies (architecture, pretraining), and a focus on evaluating the filtering efficacy against a known failure mode.</p>
<h2 id="the-markush-structure-challenge">The Markush Structure Challenge</h2>
<p><strong>The Problem</strong>: Optical Chemical Structure Recognition (OCSR) tools convert 2D images of molecules into machine-readable formats. These tools struggle with &ldquo;Markush structures,&rdquo; generic structural templates used frequently in patents that contain variables rather than specific atoms (e.g., $R$, $X$, $Y$).</p>
<p><strong>The Gap</strong>: Markush structures are difficult to detect because they often appear as small indicators (a single &ldquo;R&rdquo; or variable) within a large image, resulting in a very low Signal-to-Noise Ratio (SNR). Existing OCSR research pipelines typically bypass this by manually excluding these structures from their datasets.</p>
<p><strong>The Goal</strong>: To build an automated filter that can identify images containing Markush structures so they can be removed from OCSR pipelines, improving overall database quality without requiring manual data curation.</p>
<h2 id="patch-based-classification-pipeline">Patch-Based Classification Pipeline</h2>
<p>The core technical contribution is an end-to-end deep learning pipeline tailored for low-SNR chemical images where standard global resizing or cropping fails due to large variations in image resolution and pixel scales.</p>
<ul>
<li><strong>Patch Generation</strong>: The system slices input images into overlapping patches generated from two offset grids, ensuring that variables falling on boundaries are fully captured in at least one crop.</li>
<li><strong>Targeted Annotation</strong>: The labels rely on pixel-level bounding boxes around Markush indicators, minimizing the noise that would otherwise overwhelm a full-image classification attempt.</li>
<li><strong>Inference Strategy</strong>: During inference, the query image is broken into patches, individually classified, and aggregated entirely using a maximum pooling rule where $X = \max_{i=1}^{n} \{ x_i \}$.</li>
<li><strong>Evaluation</strong>: Provides the first systematic comparison between fixed-feature extraction (ORB + XGBoost) and end-to-end deep learning for this specific domain.</li>
</ul>
<h2 id="experimental-setup-and-baselines">Experimental Setup and Baselines</h2>
<p>The authors compared two distinct paradigms on a manually annotated dataset:</p>
<ol>
<li>
<p><strong>Fixed-Feature Baseline</strong>: Used <strong>ORB</strong> (Oriented FAST and Rotated BRIEF) to detect keypoints and match them against a template bank of known Markush symbols. Features (match counts, Hamming distances) were fed into an <strong>XGBoost</strong> model.</p>
</li>
<li>
<p><strong>Deep Learning Method</strong>: Fine-tuned <strong>ResNet18</strong> and <strong>Inception V3</strong> models on the generated image patches.</p>
<ul>
<li><strong>Ablations</strong>: Contrasted pretraining sources, evaluating general domain (ImageNet) against chemistry-specific domain (USPTO images).</li>
<li><strong>Fine-tuning</strong>: Compared full-network fine-tuning against freezing all but the fully connected layers.</li>
</ul>
</li>
</ol>
<p>To handle significant class imbalance, the primary evaluation metric was the Macro F1 score, defined as:</p>
<p>$$ \text{Macro F1} = \frac{1}{N} \sum_{i=1}^{N} \frac{2 \cdot \text{precision}_i \cdot \text{recall}_i}{\text{precision}_i + \text{recall}_i} $$</p>
<h2 id="performance-outcomes">Performance Outcomes</h2>
<ul>
<li>
<p><strong>CNN vs. ORB</strong>: Deep learning architectures outperformed the fixed-feature baseline. The best model (<strong>Inception V3</strong> pretrained on ImageNet) achieved an image-level Macro F1 of <strong>0.928</strong>, compared to <strong>0.701</strong> (image-level) for the ORB baseline, and a patch-level Macro F1 of <strong>0.917</strong>.</p>
</li>
<li>
<p><strong>The Pretraining Surprise</strong>: Counterintuitively, ImageNet pretraining consistently outperformed the domain-specific USPTO pretraining. The authors hypothesize that the filters learned from ImageNet pretraining generalize well outside the ImageNet domain, though why the USPTO-pretrained filters underperform remains unclear.</p>
</li>
<li>
<p><strong>Full Model Tuning</strong>: Unfreezing the entire network yielded higher performance than tuning only the classifier head, indicating that standard low-level visual filters require substantial adaptation to reliably distinguish chemical line drawings.</p>
</li>
<li>
<p><strong>Limitations and Edge Cases</strong>: The best CNN achieved an ROC AUC of <strong>0.97</strong> on the primary patch test set, while the ORB baseline scored <strong>0.81</strong> on the auxiliary dataset (the paper notes these ROC curves are not directly comparable due to different evaluation sets). The aggregation metric ($X = \max \{ x_i \}$) is naive and has not been optimized. Furthermore, the patching approach creates inherent label noise when a Markush indicator is cleanly bisected by a patch edge, potentially forcing the network to learn incomplete visual features.</p>
</li>
</ul>
<hr>
<h2 id="reproducibility-details">Reproducibility Details</h2>
<h3 id="data">Data</h3>
<p>The study used a primary dataset labeled by domain experts and a larger auxiliary dataset for evaluation.</p>
<table>
  <thead>
      <tr>
          <th>Purpose</th>
          <th>Dataset</th>
          <th>Size</th>
          <th>Notes</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td><strong>Training/Val</strong></td>
          <td><strong>Primary Dataset</strong></td>
          <td>272 Images</td>
          <td>Manually annotated with bounding boxes for Markush indicators. Split 60/20/20.</td>
      </tr>
      <tr>
          <td><strong>Evaluation</strong></td>
          <td><strong>Auxiliary Dataset</strong></td>
          <td>~5.4k Images</td>
          <td>5117 complete structures, 317 Markush. Used for image-level testing only (no bbox).</td>
      </tr>
  </tbody>
</table>
<p><strong>Patch Generation</strong>:</p>
<ul>
<li>Images are cropped into patches of size <strong>224x224</strong> (ResNet) or <strong>299x299</strong> (Inception).</li>
<li>Patches are generated from 2 grids offset by half the patch width/height to ensure annotations aren&rsquo;t lost on edges.</li>
<li><strong>Labeling Rule</strong>: A patch is labeled &ldquo;Markush&rdquo; if &gt;50% of an annotation&rsquo;s pixels fall inside it.</li>
</ul>
<h3 id="algorithms">Algorithms</h3>
<p><strong>ORB (Baseline)</strong>:</p>
<ul>
<li>Matches query images against a bank of template patches containing Markush indicators.</li>
<li><strong>Features</strong>: Number of keypoints, number of matches, Hamming distance of best 5 matches.</li>
<li><strong>Classifier</strong>: XGBoost trained on these features.</li>
<li><strong>Hyperparameters</strong>: Search over number of features (500-2000) and template patches (50-250).</li>
</ul>
<p><strong>Training Configuration</strong>:</p>
<ul>
<li><strong>Framework</strong>: PyTorch with Optuna for optimization.</li>
<li><strong>Optimization</strong>: 25 trials per configuration.</li>
<li><strong>Augmentations</strong>: Random perspective shift, posterization, sharpness/blur.</li>
</ul>
<h3 id="models">Models</h3>
<p>Two main architectures were compared.</p>
<table>
  <thead>
      <tr>
          <th>Model</th>
          <th>Input Size</th>
          <th>Parameters</th>
          <th>Pretraining Source</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td><strong>ResNet18</strong></td>
          <td>224x224</td>
          <td>11.5M</td>
          <td>ImageNet</td>
      </tr>
      <tr>
          <td><strong>Inception V3</strong></td>
          <td>299x299</td>
          <td>23.8M</td>
          <td>ImageNet &amp; USPTO</td>
      </tr>
  </tbody>
</table>
<p><strong>Best Configuration</strong>: Inception V3, ImageNet weights, Full Model fine-tuning (all layers unfrozen).</p>
<h3 id="evaluation">Evaluation</h3>
<p>Primary metric was <strong>Macro F1</strong> due to class imbalance.</p>
<table>
  <thead>
      <tr>
          <th>Metric</th>
          <th>Best CNN (Inception V3)</th>
          <th>Baseline (ORB)</th>
          <th>Notes</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td><strong>Patch Test F1</strong></td>
          <td>$0.917 \pm 0.014$</td>
          <td>N/A</td>
          <td>ORB does not support patch-level</td>
      </tr>
      <tr>
          <td><strong>Image Test F1</strong></td>
          <td>$0.928 \pm 0.035$</td>
          <td>$0.701 \pm 0.052$</td>
          <td>CNN aggregates patch predictions</td>
      </tr>
      <tr>
          <td><strong>Aux Test F1</strong></td>
          <td>0.914</td>
          <td>0.533</td>
          <td>Evaluation on large secondary dataset</td>
      </tr>
      <tr>
          <td><strong>ROC AUC</strong></td>
          <td>0.97</td>
          <td>0.81</td>
          <td></td>
      </tr>
  </tbody>
</table>
<h3 id="hardware">Hardware</h3>
<ul>
<li><strong>GPU</strong>: Tesla V100-SXM2-16GB</li>
<li><strong>CPU</strong>: Intel Xeon E5-2686 @ 2.30GHz</li>
<li><strong>RAM</strong>: 64 GB</li>
</ul>
<h3 id="artifacts">Artifacts</h3>
<table>
  <thead>
      <tr>
          <th>Artifact</th>
          <th>Type</th>
          <th>License</th>
          <th>Notes</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td><a href="https://github.com/Thomasjurriaans/markush-recognition-msc-thesis">GitHub Repository</a></td>
          <td>Code</td>
          <td>Apache-2.0</td>
          <td>MSc thesis code: CNN training, ORB baseline, evaluation scripts</td>
      </tr>
  </tbody>
</table>
<p>The primary dataset was manually annotated by Elsevier domain experts and is not publicly available. The auxiliary dataset (from Elsevier) is also not public. Pre-trained model weights are not released in the repository.</p>
<hr>
<h2 id="paper-information">Paper Information</h2>
<p><strong>Citation</strong>: Jurriaans, T., Szarkowska, K., Nalisnick, E., Schwörer, M., Thorne, C., &amp; Akhondi, S. (2023). One Strike, You&rsquo;re Out: Detecting Markush Structures in Low Signal-to-Noise Ratio Images. <em>arXiv preprint arXiv:2311.14633</em>. <a href="https://doi.org/10.48550/arXiv.2311.14633">https://doi.org/10.48550/arXiv.2311.14633</a></p>
<p><strong>Publication</strong>: arXiv 2023</p>
<p><strong>Additional Resources</strong>:</p>
<ul>
<li><a href="https://github.com/Thomasjurriaans/markush-recognition-msc-thesis">GitHub Repository</a></li>
</ul>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bibtex" data-lang="bibtex"><span style="display:flex;"><span><span style="color:#a6e22e">@misc</span>{jurriaansOneStrikeYoure2023,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">title</span> = <span style="color:#e6db74">{One {{Strike}}, {{You}}&#39;re {{Out}}: {{Detecting Markush Structures}} in {{Low Signal-to-Noise Ratio Images}}}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">shorttitle</span> = <span style="color:#e6db74">{One {{Strike}}, {{You}}&#39;re {{Out}}}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">author</span> = <span style="color:#e6db74">{Jurriaans, Thomas and Szarkowska, Kinga and Nalisnick, Eric and Schwoerer, Markus and Thorne, Camilo and Akhondi, Saber}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">year</span> = <span style="color:#ae81ff">2023</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">month</span> = nov,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">number</span> = <span style="color:#e6db74">{arXiv:2311.14633}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">eprint</span> = <span style="color:#e6db74">{2311.14633}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">primaryclass</span> = <span style="color:#e6db74">{cs}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">publisher</span> = <span style="color:#e6db74">{arXiv}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">doi</span> = <span style="color:#e6db74">{10.48550/arXiv.2311.14633}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">archiveprefix</span> = <span style="color:#e6db74">{arXiv}</span>
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div>]]></content:encoded></item></channel></rss>