<?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>Molecular Representations on Hunter Heidenreich | ML Research Scientist</title><link>https://hunterheidenreich.com/notes/chemistry/molecular-representations/</link><description>Recent content in Molecular Representations 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>Thu, 09 Apr 2026 00:00:00 +0000</lastBuildDate><atom:link href="https://hunterheidenreich.com/notes/chemistry/molecular-representations/index.xml" rel="self" type="application/rss+xml"/><item><title>Materials Representations for ML Review</title><link>https://hunterheidenreich.com/notes/chemistry/molecular-representations/notations/materials-representations-ml-review/</link><pubDate>Mon, 06 Apr 2026 00:00:00 +0000</pubDate><guid>https://hunterheidenreich.com/notes/chemistry/molecular-representations/notations/materials-representations-ml-review/</guid><description>Review of representation strategies for encoding solid-state materials as ML inputs, covering structural descriptors, crystal graphs, and generative models.</description><content:encoded><![CDATA[<h2 id="a-systematization-of-material-representations">A Systematization of Material Representations</h2>
<p>This paper is a <strong>Systematization</strong> that organizes and categorizes the strategies researchers use to convert solid-state materials into numerical representations suitable for machine learning models. Rather than proposing a new method, the review provides a structured taxonomy of existing approaches, connecting each to the practical constraints of data availability, computational cost, and prediction targets. It covers structural descriptors, graph-based learned representations, compositional features, transfer learning, and generative models for inverse design.</p>
<h2 id="why-material-representations-matter">Why Material Representations Matter</h2>
<p>Machine learning has enabled rapid property prediction for materials, but every ML pipeline depends on how the material is encoded as a numerical input. The authors identify three guiding principles for effective representations:</p>
<ol>
<li><strong>Similarity preservation</strong>: Similar materials should have similar representations, and dissimilar materials should diverge in representation space.</li>
<li><strong>Domain coverage</strong>: The representation should be constructable for every material in the target domain.</li>
<li><strong>Cost efficiency</strong>: Computing the representation should be cheaper than computing the target property directly (e.g., via <a href="https://en.wikipedia.org/wiki/Density_functional_theory">DFT</a>).</li>
</ol>
<p>In practice, materials scientists face several barriers. Atomistic structures span diverse space groups, supercell sizes, and disorder parameters. Real material performance depends on defects, microstructure, and interfaces. Structural information often requires expensive experimental or computational effort to obtain. Datasets in materials science tend to be small, sparse, and biased toward well-studied systems.</p>
<h2 id="structural-descriptors-local-global-and-topological">Structural Descriptors: Local, Global, and Topological</h2>
<p>The review covers three families of hand-crafted structural descriptors that encode atomic positions and types.</p>
<h3 id="local-descriptors">Local Descriptors</h3>
<p>Local descriptors characterize the environment around each atom. Atom-centered symmetry functions (ACSF), introduced by Behler and Parrinello, define radial and angular functions:</p>
<p>$$
G_{i}^{1} = \sum_{j \neq i}^{\text{neighbors}} e^{-\eta(R_{ij} - R_{s})^{2}} f_{c}(R_{ij})
$$</p>
<p>$$
G_{i}^{2} = 2^{1-\zeta} \sum_{j,k \neq i}^{\text{neighbors}} (1 + \lambda \cos \theta_{ijk})^{\zeta} e^{-\eta(R_{ij}^{2} + R_{ik}^{2} + R_{jk}^{2})} f_{c}(R_{ij}) f_{c}(R_{ik}) f_{c}(R_{jk})
$$</p>
<p>The Smooth Overlap of Atomic Positions (SOAP), proposed by Bartók et al., defines atomic neighborhood density as a sum of Gaussians and computes a rotationally invariant kernel through expansion in radial functions and <a href="https://en.wikipedia.org/wiki/Spherical_harmonics">spherical harmonics</a>:</p>
<p>$$
\rho_{i}(\mathbf{r}) = \sum_{j} \exp\left(-\frac{|\mathbf{r} - \mathbf{r}_{ij}|^{2}}{2\sigma^{2}}\right) = \sum_{nlm} c_{nlm} g_{n}(\mathbf{r}) Y_{lm}(\hat{\mathbf{r}})
$$</p>
<p>The power spectrum $\mathbf{p}(\mathbf{r}) \equiv \sum_{m} c_{nlm}(c_{n&rsquo;lm})^{*}$ serves as a vector descriptor of the local environment. SOAP has seen wide adoption both as a similarity metric and as input to ML models.</p>
<p><a href="https://en.wikipedia.org/wiki/Voronoi_diagram">Voronoi tessellation</a> provides another local approach, segmenting space into cells and extracting features like effective coordination numbers, cell volumes, and neighbor properties.</p>
<h3 id="global-descriptors">Global Descriptors</h3>
<p>Global descriptors encode the full structure. The Coulomb matrix models electrostatic interactions between atoms:</p>
<p>$$
M_{i,j} = \begin{cases} Z_{i}^{2.4} &amp; \text{for } i = j \\ \frac{Z_{i}Z_{j}}{|r_{i} - r_{j}|} &amp; \text{for } i \neq j \end{cases}
$$</p>
<p>Other global methods include partial radial distribution functions (PRDF), the many-body tensor representation (MBTR), and cluster expansions. The Atomic Cluster Expansion (ACE) framework generalizes cluster expansions to continuous environments and has become a foundation for modern deep learning potentials.</p>
<h3 id="topological-descriptors">Topological Descriptors</h3>
<p><a href="https://en.wikipedia.org/wiki/Persistent_homology">Persistent homology</a> from topological data analysis (TDA) identifies geometric features at multiple length scales. Topological descriptors capture pore geometries in porous materials and have outperformed traditional structural descriptors for predicting CO$_{2}$ adsorption in metal-organic frameworks and methane storage in <a href="https://en.wikipedia.org/wiki/Zeolite">zeolites</a>. A caveat is the $O(N^{3})$ worst-case computational cost per filtration.</p>
<h2 id="crystal-graph-neural-networks">Crystal Graph Neural Networks</h2>
<p>Graph neural networks bypass manual feature engineering by learning representations directly from structural data. Materials are converted to graphs $G(V, E)$ where nodes represent atoms and edges connect neighbors within a cutoff radius, with periodic boundary conditions.</p>
<p>Key architectures discussed include:</p>
<table>
  <thead>
      <tr>
          <th>Model</th>
          <th>Key Innovation</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>CGCNN</td>
          <td>Crystal graph convolutions for broad property prediction</td>
      </tr>
      <tr>
          <td>MEGNet</td>
          <td>Materials graph networks with global state attributes</td>
      </tr>
      <tr>
          <td>ALIGNN</td>
          <td>Line graph neural networks incorporating three-body angular features</td>
      </tr>
      <tr>
          <td>Equivariant GNNs</td>
          <td>E(3)-equivariant message passing for tensorial properties</td>
      </tr>
  </tbody>
</table>
<p>The review identifies several limitations. Graph convolutions based on local neighborhoods can fail to capture long-range interactions or periodicity-dependent properties (e.g., lattice parameters, phonon spectra). Strategies to address this include concatenation with hand-tuned descriptors, plane-wave periodic basis modulation, and reciprocal-space features.</p>
<p>A major practical restriction is the requirement for relaxed atomic positions. Graphs built from unrelaxed crystal prototypes lose information about geometric distortions, degrading accuracy. Approaches to mitigate this include data augmentation with perturbed structures, Bayesian optimization of prototypes, and surrogate force-field relaxation.</p>
<p>Equivariant models that introduce higher-order tensors to node and edge features, constrained to transform correctly under E(3) operations, achieve state-of-the-art accuracy and can match structural descriptor performance even in low-data (~100 datapoints) regimes.</p>
<h2 id="compositional-descriptors-without-structure">Compositional Descriptors Without Structure</h2>
<p>When crystal structures are unavailable, representations can be built purely from stoichiometry and tabulated atomic properties (radii, electronegativity, valence electrons). Despite their simplicity, these methods have distinct advantages: zero computational overhead, accessibility to non-experts, and robustness for high-throughput screening.</p>
<p>Key methods include:</p>
<ul>
<li><strong>MagPie</strong>: 145 input features derived from elemental properties</li>
<li><strong>SISSO</strong>: Compressive sensing over algebraic combinations of atomic properties, capable of discovering interpretable descriptors (e.g., a new tolerance factor $\tau$ for perovskite stability)</li>
<li><strong>ElemNet</strong>: Deep neural network using only fractional stoichiometry as input, outperforming MagPie with &gt;3,000 training points</li>
<li><strong>ROOST</strong>: Fully-connected compositional graph with attention-based message passing, achieving strong performance with only hundreds of examples</li>
<li><strong>CrabNet</strong>: Self-attention on element embeddings with fractional encoding, handling dopant-level concentrations via log-scale inputs</li>
</ul>
<p>Compositional models cannot distinguish polymorphs and generally underperform structural approaches. They are most valuable when atomistic resolution is unavailable.</p>
<h2 id="defects-surfaces-and-grain-boundaries">Defects, Surfaces, and Grain Boundaries</h2>
<p>The review extends beyond idealized unit cells to practical materials challenges:</p>
<p><strong>Point defects</strong>: Representations of the pristine bulk can predict vacancy formation energies through linear relationships with band structure descriptors. Frey et al. proposed using relative differences between defect and parent structure properties, requiring no DFT on the defect itself.</p>
<p><strong>Surfaces and catalysis</strong>: Binding energy prediction for catalysis requires representations beyond the bulk unit cell. The d-band center for metals and oxygen 2p-band center for metal oxides serve as simple electronic descriptors, following the <a href="https://en.wikipedia.org/wiki/Sabatier_principle">Sabatier principle</a> that optimal catalytic activity requires intermediate binding strength. Graph neural networks trained on the Open Catalyst 2020 dataset (&gt;1 million DFT energies) have enabled broader screening, though errors remain high for certain adsorbates and non-metallic surfaces.</p>
<p><strong>Grain boundaries</strong>: SOAP descriptors computed for atoms near grain boundaries and clustered into local environment classes can predict grain boundary energy, mobility, and shear coupling. This approach provides interpretable structure-property relationships.</p>
<h2 id="transfer-learning-across-representations">Transfer Learning Across Representations</h2>
<p>When target datasets are small, transfer learning leverages representations learned from large, related datasets. The standard procedure involves: (1) pretraining on a large dataset (e.g., all Materials Project formation energies), (2) freezing parameters up to a chosen depth, and (3) either fine-tuning remaining layers or extracting features for a separate model.</p>
<p>Key findings from the review:</p>
<ul>
<li>Transfer learning is most effective when the source dataset is orders of magnitude larger than the target</li>
<li>Physically related tasks transfer better (e.g., Open Catalyst absorption energies transfer well to new adsorbates, less so to unrelated small molecules)</li>
<li>Earlier neural network layers learn more general representations and transfer better across properties</li>
<li>Multi-depth feature extraction, combining activations from multiple layers, can improve transfer</li>
<li>Predictions from surrogate models can serve as additional descriptors, expanding screening domains by orders of magnitude</li>
</ul>
<h2 id="generative-models-for-crystal-inverse-design">Generative Models for Crystal Inverse Design</h2>
<p>Generative models for solid-state materials face challenges beyond molecular generation: more diverse atomic species, the need to specify both positions and lattice parameters, non-unique definitions (rotations, translations, supercell scaling), and large unit cells (&gt;100 atoms for zeolites and MOFs).</p>
<p>The review traces the progression of approaches:</p>
<ol>
<li><strong>Voxel representations</strong>: Discretize unit cells into volume elements. Early work (iMatGen, Court et al.) demonstrated feasibility but was restricted to specific chemistries or cubic systems.</li>
<li><strong>Continuous coordinate models</strong>: Point cloud and invertible representations allowed broader chemical spaces but lacked symmetry invariances.</li>
<li><strong>Symmetry-aware models</strong>: Crystal Diffusion <a href="/notes/machine-learning/generative-models/autoencoding-variational-bayes/">VAE</a> (CDVAE) uses periodic graphs and SE(3)-equivariant message passing for translationally and rotationally invariant generation, establishing benchmark tasks for the field.</li>
<li><strong>Constrained models for porous materials</strong>: Approaches like SmVAE represent MOFs through their topological building blocks (RFcodes), ensuring all generated structures are physically valid.</li>
</ol>
<h2 id="open-problems-and-future-directions">Open Problems and Future Directions</h2>
<p>The review highlights four high-impact open questions:</p>
<ol>
<li><strong>Local vs. global descriptor trade-offs</strong>: Local descriptors (SOAP) excel for short-range interactions but struggle with long-range physics. Global descriptors model periodicity but lack generality across space groups. Combining local and long-range features could provide more universal models.</li>
<li><strong>Prediction from unrelaxed prototypes</strong>: ML force fields can relax structures at a fraction of DFT cost, potentially expanding screening domains. Key questions remain about required training data scale and generalizability.</li>
<li><strong>Applicability of compositional descriptors</strong>: The performance gap between compositional and structural models may be property-dependent, being smaller for properties like band gap that depend on global features rather than local site energies.</li>
<li><strong>Extensions of generative models</strong>: Diffusion-based architectures have improved on voxel approaches for small unit cells, but extending to microstructure, dimensionality, and surface generation remains open.</li>
</ol>
<hr>
<h2 id="reproducibility-details">Reproducibility Details</h2>
<p>This paper is a review and does not present new experimental results or release any novel code, data, or models. The paper is open-access (hybrid OA at Annual Reviews) and the arXiv preprint is freely available. The following artifacts table covers key publicly available resources discussed in the review.</p>
<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://arxiv.org/abs/2301.08813">arXiv preprint (2301.08813)</a></td>
          <td>Other</td>
          <td>arXiv (open access)</td>
          <td>Free preprint version</td>
      </tr>
      <tr>
          <td><a href="https://materialsproject.org">Materials Project</a></td>
          <td>Dataset</td>
          <td>CC-BY-4.0</td>
          <td>DFT energies, band gaps, structures for &gt;100,000 compounds</td>
      </tr>
      <tr>
          <td><a href="https://oqmd.org">OQMD</a></td>
          <td>Dataset</td>
          <td>CC-BY-4.0</td>
          <td>Open Quantum Materials Database, &gt;600,000 DFT entries</td>
      </tr>
      <tr>
          <td><a href="https://github.com/Open-Catalyst-Project/ocp">Open Catalyst 2020 (OC20)</a></td>
          <td>Dataset</td>
          <td>CC-BY-4.0</td>
          <td>&gt;1,000,000 DFT surface adsorption energies</td>
      </tr>
      <tr>
          <td><a href="https://aflowlib.org">AFLOW</a></td>
          <td>Dataset</td>
          <td>Public</td>
          <td>High-throughput ab initio library, &gt;3,000,000 entries</td>
      </tr>
      <tr>
          <td><a href="https://github.com/hackingmaterials/matminer">Matminer</a></td>
          <td>Code</td>
          <td>BSD</td>
          <td>Open-source toolkit for materials data mining and featurization</td>
      </tr>
  </tbody>
</table>
<h3 id="algorithms">Algorithms</h3>
<p>The review covers: ACSF, SOAP, Voronoi tessellation, Coulomb matrices, PRDF, MBTR, cluster expansions, ACE, persistent homology, CGCNN, MEGNet, ALIGNN, E(3)-equivariant GNNs, MagPie, SISSO, ElemNet, ROOST, CrabNet, VAE, GAN, and diffusion-based crystal generators.</p>
<h3 id="hardware">Hardware</h3>
<p>No new experiments are conducted. Hardware requirements vary by the referenced methods (DFT calculations require HPC; GNN training typically requires 1-8 GPUs).</p>
<h3 id="reproducibility-status">Reproducibility Status</h3>
<p><strong>Partially Reproducible</strong>: The review paper itself is open-access. All major datasets discussed (Materials Project, OQMD, OC20, AFLOW) are publicly available under permissive licenses. Most referenced model implementations (CGCNN, MEGNet, ALIGNN, ROOST, CDVAE) have open-source code. No novel artifacts are released by the authors.</p>
<hr>
<h2 id="paper-information">Paper Information</h2>
<p><strong>Citation</strong>: Damewood, J., Karaguesian, J., Lunger, J. R., Tan, A. R., Xie, M., Peng, J., &amp; Gómez-Bombarelli, R. (2023). Representations of Materials for Machine Learning. <em>Annual Review of Materials Research</em>, 53. <a href="https://doi.org/10.1146/annurev-matsci-080921-085947">https://doi.org/10.1146/annurev-matsci-080921-085947</a></p>
<p><strong>Publication</strong>: Annual Review of Materials Research, 2023</p>
<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">@article</span>{damewood2023representations,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">title</span>=<span style="color:#e6db74">{Representations of Materials for Machine Learning}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">author</span>=<span style="color:#e6db74">{Damewood, James and Karaguesian, Jessica and Lunger, Jaclyn R. and Tan, Aik Rui and Xie, Mingrou and Peng, Jiayu and G{\&#39;o}mez-Bombarelli, Rafael}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">journal</span>=<span style="color:#e6db74">{Annual Review of Materials Research}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">volume</span>=<span style="color:#e6db74">{53}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">year</span>=<span style="color:#e6db74">{2023}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">doi</span>=<span style="color:#e6db74">{10.1146/annurev-matsci-080921-085947}</span>
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div>]]></content:encoded></item><item><title>InChI: The International Chemical Identifier</title><link>https://hunterheidenreich.com/notes/chemistry/molecular-representations/notations/inchi/</link><pubDate>Mon, 06 Apr 2026 00:00:00 +0000</pubDate><guid>https://hunterheidenreich.com/notes/chemistry/molecular-representations/notations/inchi/</guid><description>InChI is IUPAC's open, layered chemical identifier that encodes molecular structure hierarchically for database interoperability and search.</description><content:encoded><![CDATA[<h2 id="overview">Overview</h2>
<p><strong>InChI (International Chemical Identifier)</strong> is an open, non-proprietary chemical structure identifier developed by <a href="https://iupac.org/">IUPAC</a> and <a href="https://www.nist.gov/">NIST</a>. Unlike <a href="/notes/chemistry/molecular-representations/notations/smiles/">SMILES</a>, which linearizes a molecular graph through depth-first traversal, InChI decomposes a molecule into a hierarchy of <strong>layers</strong> (connectivity, hydrogen atoms, charge, stereochemistry) that build progressively from the molecular formula to full stereochemical detail. This layered design means that two representations of the same molecule always produce the same InChI, even if their input drawings differ in atom ordering or layout.</p>
<p>InChI was created to solve a specific problem: linking chemical information across databases on the open web. Before InChI, interoperability between chemical databases depended on proprietary identifiers (like CAS Registry Numbers) or format-dependent representations. The project began at a March 2000 IUPAC meeting and is maintained by the <a href="https://www.inchi-trust.org/">InChI Trust</a>, a UK charity supported by publishers and database providers. The algorithm&rsquo;s source code is <a href="https://github.com/IUPAC-InChI/InChI">open source</a>.</p>
<h3 id="key-characteristics">Key Characteristics</h3>
<ul>
<li><strong>Canonical by design</strong>: Every valid molecular structure maps to exactly one standard InChI string, regardless of how the structure was drawn or which atoms were numbered first. This uniqueness is built into the algorithm, not added as a post-processing step.</li>
<li><strong>Hierarchical layers</strong>: Information is organized from general (molecular formula) to specific (stereochemistry, isotopes). This allows matching at different levels of detail: a query with unknown stereochemistry can match against structures with known stereochemistry by comparing only the connectivity layers.</li>
<li><strong>Web-searchable via InChIKey</strong>: Because InChI strings contain characters (<code>/</code>, <code>+</code>, <code>=</code>) that break web search engines, the 27-character InChIKey hash provides a fixed-length, search-friendly identifier.</li>
<li><strong>Non-proprietary and open</strong>: Governed by IUPAC through the InChI Trust. The algorithm, source code, and specification are freely available.</li>
<li><strong>Machine-optimized</strong>: Designed for programmatic parsing and database operations rather than human readability. Compare with SMILES, which prioritizes human readability.</li>
</ul>
<h2 id="layered-structure">Layered Structure</h2>
<p>An InChI string begins with the prefix <code>InChI=</code> followed by a version number, then a series of layers separated by <code>/</code>. Each layer encodes a specific aspect of the molecular structure.</p>
<h3 id="layer-breakdown">Layer Breakdown</h3>
<p>For L-alanine (an amino acid with a chiral center):</p>
<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-text" data-lang="text"><span style="display:flex;"><span>InChI=1S/C3H7NO2/c1-2(4)3(5)6/h2H,4H2,1H3,(H,5,6)/t2-/m0/s1
</span></span><span style="display:flex;"><span>       │  │      │            │                   │   │  │
</span></span><span style="display:flex;"><span>       │  │      │            │                   │   │  └─ /s: stereo type (1=absolute)
</span></span><span style="display:flex;"><span>       │  │      │            │                   │   └─ /m: parity inversion flag
</span></span><span style="display:flex;"><span>       │  │      │            │                   └─ /t: tetrahedral parity
</span></span><span style="display:flex;"><span>       │  │      │            └─ /h: hydrogen layer
</span></span><span style="display:flex;"><span>       │  │      └─ /c: connectivity layer
</span></span><span style="display:flex;"><span>       │  └─ molecular formula
</span></span><span style="display:flex;"><span>       └─ version (1S = standard InChI v1)
</span></span></code></pre></div><p>The full set of layers, in order:</p>
<ol>
<li><strong>Main layer</strong>: Molecular formula (e.g., <code>C3H7NO2</code>)</li>
<li><strong>Connectivity (<code>/c</code>)</strong>: Atom-to-atom connections, excluding bond orders. Atoms are numbered starting from 1, and connections are listed as pairs.</li>
<li><strong>Hydrogen (<code>/h</code>)</strong>: Hydrogen atom assignments, distinguishing mobile (tautomeric) from fixed hydrogens</li>
<li><strong>Charge (<code>/q</code>) and proton balance (<code>/p</code>)</strong>: Net charge and protonation state</li>
<li><strong>Double bond stereochemistry (<code>/b</code>)</strong>: E/Z configuration around double bonds</li>
<li><strong>Tetrahedral stereochemistry (<code>/t</code>)</strong>: R/S configuration at sp3 centers</li>
<li><strong>Parity inversion (<code>/m</code>)</strong>: Relates computed parity to actual configuration</li>
<li><strong>Stereo type (<code>/s</code>)</strong>: Whether stereochemistry is absolute, relative, or racemic</li>
<li><strong>Isotope layer (<code>/i</code>)</strong>: Isotopic labeling (e.g., deuterium, carbon-13)</li>
</ol>
<h3 id="standard-vs-non-standard-inchi">Standard vs. Non-Standard InChI</h3>
<p>The <code>S</code> in <code>InChI=1S/</code> indicates a <strong>Standard InChI</strong>, which uses a fixed set of normalization options to guarantee that any software producing Standard InChI will generate the same string for the same molecule. Non-standard InChI allows custom options (such as the Fixed-H layer <code>/f</code>, which distinguishes specific tautomeric forms) but sacrifices cross-implementation consistency.</p>
<h2 id="the-inchikey">The InChIKey</h2>
<p>InChI strings can be arbitrarily long for large molecules, and their <code>/</code>, <code>+</code>, and <code>=</code> characters cause problems for web search engines. The <strong>InChIKey</strong> addresses both issues by hashing the InChI into a fixed 27-character string:</p>
<p>$$
\text{InChIKey} = f_{\text{SHA-256}}(\text{InChI})
$$</p>
<h3 id="structure">Structure</h3>
<p>An InChIKey has the format <code>XXXXXXXXXXXXXX-XXXXXXXXXX-X</code>:</p>
<ul>
<li><strong>First block (14 characters)</strong>: SHA-256 hash of the connectivity layer (molecular skeleton)</li>
<li><strong>Second block (10 characters)</strong>: 8 characters encoding stereochemistry and isotopes, plus a standard/non-standard flag (<code>S</code> or <code>N</code>) and a version indicator (<code>A</code> for v1)</li>
<li><strong>Third block (1 character)</strong>: Protonation flag (<code>N</code> for neutral)</li>
</ul>
<p>For example, L-alanine:</p>
<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-text" data-lang="text"><span style="display:flex;"><span>InChIKey: QNAYBMKLOCPYGJ-REOHCLBHSA-N
</span></span><span style="display:flex;"><span>          │                │          │
</span></span><span style="display:flex;"><span>          └─ connectivity  └─ stereo  └─ protonation
</span></span></code></pre></div><h3 id="collision-risk">Collision Risk</h3>
<p>Because the InChIKey is a hash, collisions are theoretically possible. The first block provides $2^{65}$ possible values for connectivity, making accidental collisions extremely unlikely for practical database sizes (estimated 1 in $10^{12}$ chance for $10^9$ compounds). It is important to distinguish InChIKey collisions (a mathematical inevitability of hashing, but rare in practice) from InChI collisions (bugs in the algorithm, which are very rare and targeted by the certification suite).</p>
<h2 id="working-with-inchi-in-python">Working with InChI in Python</h2>
<p>The RDKit library provides InChI support through its built-in functions:</p>
<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-python" data-lang="python"><span style="display:flex;"><span><span style="color:#f92672">from</span> rdkit <span style="color:#f92672">import</span> Chem
</span></span><span style="display:flex;"><span><span style="color:#f92672">from</span> rdkit.Chem.inchi <span style="color:#f92672">import</span> MolFromInchi, MolToInchi, InchiToInchiKey
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># SMILES -&gt; InChI</span>
</span></span><span style="display:flex;"><span>mol <span style="color:#f92672">=</span> Chem<span style="color:#f92672">.</span>MolFromSmiles(<span style="color:#e6db74">&#34;C[C@@H](N)C(=O)O&#34;</span>)  <span style="color:#75715e"># L-alanine</span>
</span></span><span style="display:flex;"><span>inchi <span style="color:#f92672">=</span> MolToInchi(mol)
</span></span><span style="display:flex;"><span>print(inchi)
</span></span><span style="display:flex;"><span><span style="color:#75715e"># -&gt; InChI=1S/C3H7NO2/c1-2(4)3(5)6/h2H,4H2,1H3,(H,5,6)/t2-/m0/s1</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># InChI -&gt; Molecule -&gt; SMILES</span>
</span></span><span style="display:flex;"><span>mol2 <span style="color:#f92672">=</span> MolFromInchi(inchi)
</span></span><span style="display:flex;"><span>print(Chem<span style="color:#f92672">.</span>MolToSmiles(mol2))
</span></span><span style="display:flex;"><span><span style="color:#75715e"># -&gt; C[C@@H](N)C(=O)O</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># InChI -&gt; InChIKey</span>
</span></span><span style="display:flex;"><span>key <span style="color:#f92672">=</span> InchiToInchiKey(inchi)
</span></span><span style="display:flex;"><span>print(key)
</span></span><span style="display:flex;"><span><span style="color:#75715e"># -&gt; QNAYBMKLOCPYGJ-REOHCLBHSA-N</span>
</span></span></code></pre></div><h3 id="layer-level-matching">Layer-Level Matching</h3>
<p>Because InChI is hierarchical, you can compare molecules at different levels of detail by truncating layers. Two molecules that differ only in stereochemistry will share the same connectivity layers:</p>
<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-python" data-lang="python"><span style="display:flex;"><span><span style="color:#f92672">from</span> rdkit <span style="color:#f92672">import</span> Chem
</span></span><span style="display:flex;"><span><span style="color:#f92672">from</span> rdkit.Chem.inchi <span style="color:#f92672">import</span> MolToInchi, InchiToInchiKey
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># L-alanine and D-alanine differ only in chirality</span>
</span></span><span style="display:flex;"><span>l_ala <span style="color:#f92672">=</span> Chem<span style="color:#f92672">.</span>MolFromSmiles(<span style="color:#e6db74">&#34;C[C@@H](N)C(=O)O&#34;</span>)
</span></span><span style="display:flex;"><span>d_ala <span style="color:#f92672">=</span> Chem<span style="color:#f92672">.</span>MolFromSmiles(<span style="color:#e6db74">&#34;C[C@H](N)C(=O)O&#34;</span>)
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>l_inchi <span style="color:#f92672">=</span> MolToInchi(l_ala)
</span></span><span style="display:flex;"><span>d_inchi <span style="color:#f92672">=</span> MolToInchi(d_ala)
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># Full InChIs differ (different /t and /m layers)</span>
</span></span><span style="display:flex;"><span>print(l_inchi)
</span></span><span style="display:flex;"><span><span style="color:#75715e"># -&gt; InChI=1S/C3H7NO2/c1-2(4)3(5)6/h2H,4H2,1H3,(H,5,6)/t2-/m0/s1</span>
</span></span><span style="display:flex;"><span>print(d_inchi)
</span></span><span style="display:flex;"><span><span style="color:#75715e"># -&gt; InChI=1S/C3H7NO2/c1-2(4)3(5)6/h2H,4H2,1H3,(H,5,6)/t2-/m1/s1</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># First block of InChIKey is identical (same connectivity)</span>
</span></span><span style="display:flex;"><span>l_key <span style="color:#f92672">=</span> InchiToInchiKey(l_inchi)
</span></span><span style="display:flex;"><span>d_key <span style="color:#f92672">=</span> InchiToInchiKey(d_inchi)
</span></span><span style="display:flex;"><span>print(l_key[:<span style="color:#ae81ff">14</span>] <span style="color:#f92672">==</span> d_key[:<span style="color:#ae81ff">14</span>])
</span></span><span style="display:flex;"><span><span style="color:#75715e"># -&gt; True (same molecular skeleton)</span>
</span></span><span style="display:flex;"><span>print(l_key <span style="color:#f92672">==</span> d_key)
</span></span><span style="display:flex;"><span><span style="color:#75715e"># -&gt; False (different stereochemistry)</span>
</span></span></code></pre></div><h2 id="inchi-in-machine-learning">InChI in Machine Learning</h2>
<p>InChI was designed for database interoperability, not for machine learning. Its hierarchical, layer-based structure differs fundamentally from the sequential, atom-by-atom encoding used by <a href="/notes/chemistry/molecular-representations/notations/smiles/">SMILES</a> and <a href="/notes/chemistry/molecular-representations/notations/selfies/">SELFIES</a>. This has practical implications for ML applications.</p>
<h3 id="optical-chemical-structure-recognition">Optical Chemical Structure Recognition</h3>
<p>InChI is widely used as an output format for <a href="/posts/what-is-ocsr/">optical chemical structure recognition (OCSR)</a> systems that extract molecular structures from images in scientific literature. Because InChI is canonical, it provides an unambiguous target for image-to-text models.</p>
<p><a href="/notes/chemistry/optical-structure-recognition/image-to-sequence/image2inchi/">Image2InChI</a> uses an improved SwinTransformer encoder with attention-based feature fusion to convert molecular images directly to InChI strings, achieving 99.8% accuracy on the BMS dataset. The <a href="/notes/chemistry/optical-structure-recognition/image-to-sequence/vit-inchi-transformer/">ViT-InChI Transformer</a> takes a similar approach with a Vision Transformer backbone.</p>
<p>In a <a href="/notes/chemistry/optical-structure-recognition/benchmarks/rajan-string-representations-2022/">systematic comparison of string representations for OCSR</a>, Rajan et al. (2022) evaluated SMILES, DeepSMILES, SELFIES, and InChI using the same transformer architecture. InChI strings are longer than SMILES (producing more tokens for the decoder), which increases sequence modeling difficulty. SMILES achieved the highest exact match accuracy (88.62%), while SELFIES achieved 100% structural validity.</p>
<h3 id="chemical-name-translation">Chemical Name Translation</h3>
<p>InChI&rsquo;s canonical structure makes it a natural intermediate representation for translating between chemical names and structures. <a href="/notes/chemistry/molecular-representations/name-translation/handsel-inchi-iupac-2021/">Handsel et al. (2021)</a> trained a sequence-to-sequence Transformer to translate InChI identifiers to IUPAC names character-by-character, achieving 91% accuracy on organic compounds from PubChem (10 million training pairs). <a href="/notes/chemistry/molecular-representations/name-translation/stout/">STOUT</a> converts through SELFIES as an intermediate but validates outputs against InChI for structural equivalence.</p>
<h3 id="representation-comparison-for-ml">Representation Comparison for ML</h3>
<p>InChI&rsquo;s design trade-offs position it differently from SMILES and SELFIES for machine learning:</p>
<table>
  <thead>
      <tr>
          <th>Property</th>
          <th>InChI</th>
          <th>SMILES</th>
          <th>SELFIES</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>Uniqueness</td>
          <td>Canonical by design</td>
          <td>Requires canonicalization algorithm</td>
          <td>Via SMILES roundtrip</td>
      </tr>
      <tr>
          <td>Validity guarantee</td>
          <td>N/A (not generative)</td>
          <td>No</td>
          <td>Yes (every string is valid)</td>
      </tr>
      <tr>
          <td>Human readability</td>
          <td>Low (machine-optimized)</td>
          <td>High</td>
          <td>Moderate</td>
      </tr>
      <tr>
          <td>String length</td>
          <td>Longest</td>
          <td>Shortest</td>
          <td>Moderate</td>
      </tr>
      <tr>
          <td>Primary ML use</td>
          <td>OCSR output, database linking</td>
          <td>Generation, property prediction</td>
          <td>Generation with validity</td>
      </tr>
      <tr>
          <td>Tokenization</td>
          <td>Complex (layers, separators)</td>
          <td>Regex-based atom tokens</td>
          <td>Bracket-delimited tokens</td>
      </tr>
  </tbody>
</table>
<p>InChI&rsquo;s length and structural complexity (layer separators, parenthetical groupings, comma-delimited atom lists) make it less common as a direct input representation for generative models. Most molecular language models use SMILES or SELFIES for generation tasks, and convert to InChI only for canonicalized comparison or database lookup.</p>
<h2 id="limitations">Limitations</h2>
<h3 id="tautomerism">Tautomerism</h3>
<p>InChI v1 handles many tautomeric forms by normalizing mobile hydrogen atoms in the <code>/h</code> layer. However, certain tautomeric transformations (such as 1,4-oxime/nitroso conversions) can produce different InChIs for what chemists consider the same compound. This is a <a href="/notes/chemistry/molecular-representations/notations/inchi-and-tautomers/">known limitation targeted for InChI v2</a>, with 86 tautomeric transformation rules compiled and validated across 400M+ structures to inform the update.</p>
<h3 id="inorganic-and-organometallic-chemistry">Inorganic and Organometallic Chemistry</h3>
<p>The original InChI specification was designed primarily for organic molecules. Metal-ligand bonds, coordination compounds, and extended solid-state structures posed challenges. The <a href="/notes/chemistry/molecular-representations/notations/inchi-2025/">InChI v1.07 release</a> addresses this with dedicated handling for metal-ligand bonds, though complete coverage of all inorganic chemistry remains an ongoing effort.</p>
<h3 id="not-designed-for-generation">Not Designed for Generation</h3>
<p>Unlike SMILES (which can be generated token-by-token through depth-first graph traversal) or SELFIES (which guarantees validity by construction), InChI&rsquo;s layered format does not lend itself to autoregressive generation. A generative model would need to produce internally consistent layers: the connectivity layer must agree with the molecular formula, the hydrogen layer must be consistent with the connectivity, and the stereochemistry layers must reference valid atom indices. This cross-layer dependency makes InChI poorly suited as a target for token-by-token molecular generation, which is why most generative chemistry models use SMILES or SELFIES.</p>
<h3 id="irreversibility-of-inchikey">Irreversibility of InChIKey</h3>
<p>The InChIKey is a one-way hash. An InChIKey cannot be converted back to an InChI or a molecular structure. It is useful only for search and comparison, not for structure retrieval (without a lookup table).</p>
<h2 id="variants-and-extensions">Variants and Extensions</h2>
<h3 id="rinchi-reactions">RInChI: Reactions</h3>
<p><a href="/notes/chemistry/molecular-representations/notations/rinchi/">RInChI (Reaction InChI)</a> extends InChI to represent chemical reactions by combining the InChIs of reactants, products, and agents into a single identifier. It provides a canonical identifier for reactions, enabling reaction database searching and duplicate detection (Grethe et al., 2018).</p>
<h3 id="minchi-mixtures">MInChI: Mixtures</h3>
<p><a href="/notes/chemistry/molecular-representations/notations/mixfile-minchi/">MInChI (Mixture InChI)</a> represents mixtures of substances, combined with the Mixfile format for storing detailed mixture composition data. This extends the InChI framework to complex multi-component systems like formulations and alloys (Clark et al., 2019).</p>
<h3 id="ninchi-nanomaterials">NInChI: Nanomaterials</h3>
<p><a href="/notes/chemistry/molecular-representations/notations/ninchi-alpha/">NInChI</a> proposes a hierarchical adaptation of InChI for nanomaterial identification. Traditional chemical identifiers break down at the nanoscale, where a single &ldquo;entity&rdquo; may consist of millions of atoms arranged in layers, coatings, and surface functionalizations (Lynch et al., 2020).</p>
<h2 id="references">References</h2>
<ul>
<li>Heller, S., McNaught, A., Pletnev, I., Stein, S., &amp; Tchekhovskoi, D. (2015). InChI, the IUPAC International Chemical Identifier. <a href="https://doi.org/10.1186/s13321-015-0068-4"><em>Journal of Cheminformatics</em>, <em>7</em>(1), 23.</a></li>
<li>Heller, S., McNaught, A., Stein, S., Tchekhovskoi, D., &amp; Pletnev, I. (2013). InChI - the worldwide chemical structure identifier standard. <a href="https://doi.org/10.1186/1758-2946-5-7"><em>Journal of Cheminformatics</em>, <em>5</em>(1), 7.</a></li>
<li>Grethe, G., Blanke, G., Kraut, H., &amp; Goodman, J. M. (2018). International Chemical Identifier for reactions (RInChI). <a href="https://doi.org/10.1186/s13321-018-0277-8"><em>Journal of Cheminformatics</em>, <em>10</em>(1), 22.</a></li>
<li>Clark, A. M., McEwen, L. R., Gedeck, P., &amp; Bunin, B. A. (2019). Capturing mixture composition: an open machine-readable format for representing mixed substances. <a href="https://doi.org/10.1186/s13321-019-0357-4"><em>Journal of Cheminformatics</em>, <em>11</em>(1), 33.</a></li>
<li>Lynch, I., et al. (2020). Can an InChI for nano address the need for a simplified representation of complex nanomaterials across experimental and nanoinformatics studies? <a href="https://doi.org/10.3390/nano10122493"><em>Nanomaterials</em>, <em>10</em>(12), 2493.</a></li>
<li><a href="https://www.inchi-trust.org/">InChI Trust</a></li>
<li><a href="https://github.com/IUPAC-InChI/InChI">InChI GitHub Repository</a></li>
</ul>
]]></content:encoded></item><item><title>MoMu: Bridging Molecular Graphs and Natural Language</title><link>https://hunterheidenreich.com/notes/chemistry/molecular-representations/multimodal/momu-molecular-multimodal-foundation/</link><pubDate>Sat, 28 Mar 2026 00:00:00 +0000</pubDate><guid>https://hunterheidenreich.com/notes/chemistry/molecular-representations/multimodal/momu-molecular-multimodal-foundation/</guid><description>MoMu bridges molecular graphs and natural language via contrastive pre-training, enabling cross-modal retrieval, captioning, and property prediction.</description><content:encoded><![CDATA[<h2 id="bridging-molecular-graphs-and-natural-language-through-contrastive-learning">Bridging Molecular Graphs and Natural Language Through Contrastive Learning</h2>
<p>MoMu (Molecular Multimodal foundation model) is a <strong>Method</strong> paper that proposes a multimodal pre-training approach to associate molecular graphs with natural language descriptions. The primary contribution is a dual-encoder architecture, consisting of a Graph Isomorphism Network (GIN) for molecular graphs and a BERT-based text encoder, jointly trained through contrastive learning on weakly-correlated graph-text pairs collected from scientific literature. The pre-trained model supports four downstream capabilities: cross-modal retrieval (graph-to-text and text-to-graph), molecule captioning, zero-shot text-to-graph molecule generation, and molecular property prediction.</p>
<h2 id="why-single-modality-models-are-insufficient-for-molecular-understanding">Why Single-Modality Models Are Insufficient for Molecular Understanding</h2>
<p>Existing AI models for molecular tasks generally operate on a single modality and learn a single cognitive ability. Language-based models process <a href="/notes/chemistry/molecular-representations/notations/smiles/">SMILES</a> strings or natural language texts and handle tasks like property prediction from strings, literature comprehension, or SMILES-based generation. Graph-based models use molecular graph representations and handle graph-level property prediction or graph generation. Neither category connects structural information from molecular graphs with the rich semantic knowledge encoded in scientific texts.</p>
<p>Prior work by Zeng et al. (KV-PLM) jointly modeled molecule-related texts and SMILES strings, but SMILES representations have inherent drawbacks: they are one-dimensional and may lose structural information, they cannot capture structural similarities between molecules, and a single molecule can have multiple valid SMILES representations. Molecular graphs, by contrast, are more intuitive and better reveal functional structures. Human experts learn molecular knowledge by associating both graphical representations and textual descriptions, yet no prior model bridged these two modalities directly.</p>
<p>The key challenge is the scarcity of paired molecular graph-text data compared to general image-text datasets. Additionally, learning specialized molecular knowledge requires foundational cognitive abilities in both the graph and text domains, making training from scratch infeasible with limited data.</p>
<h2 id="contrastive-pre-training-with-inter-modal-and-intra-modal-objectives">Contrastive Pre-Training with Inter-Modal and Intra-Modal Objectives</h2>
<p>MoMu consists of two encoders initialized from pre-trained unimodal models: a GIN graph encoder initialized from GraphCL self-supervised weights, and a BERT text encoder initialized from either Sci-BERT (yielding MoMu-S) or KV-PLM (yielding MoMu-K).</p>
<h3 id="data-collection">Data Collection</h3>
<p>The authors collect approximately 15,613 molecular graph-document pairs by:</p>
<ol>
<li>Gathering names, synonyms, and SMILES for the top 50K compounds in <a href="https://en.wikipedia.org/wiki/PubChem">PubChem</a></li>
<li>Converting SMILES to molecular graphs using the OGB <code>smiles2graph</code> function</li>
<li>Retrieving related text from the S2ORC corpus (136M+ papers) by querying with molecule names, filtering to Medicine, Biology, Chemistry, and Computer Science fields</li>
<li>Restricting retrieval to abstract, introduction, and conclusion sections to avoid experimental data artifacts</li>
</ol>
<h3 id="contrastive-training-objective">Contrastive Training Objective</h3>
<p>For each graph-text pair in a mini-batch of $N$ pairs, MoMu applies two graph augmentations (node dropping and subgraph extraction) to create two augmented graphs, and randomly samples two sentences from the document. This produces $2N$ graph representations ${z_1^G, \tilde{z}_1^G, \ldots, z_N^G, \tilde{z}_N^G}$ and $2N$ text representations ${z_1^T, \tilde{z}_1^T, \ldots, z_N^T, \tilde{z}_N^T}$.</p>
<p>The cross-modal contrastive loss for a pair $(z_i^G, z_i^T)$ is:</p>
<p>$$
\ell_i^{(z_i^G, z_i^T)} = -\log \frac{\exp(\text{sim}(z_i^G, z_i^T) / \tau)}{\sum_{j=1}^{N} \exp(\text{sim}(z_i^G, z_j^T) / \tau)}
$$</p>
<p>where $\tau$ is the temperature parameter and $\text{sim}(\cdot, \cdot)$ projects both representations into a shared 256-dimensional space before computing cosine similarity. The total cross-modal loss includes four contrastive terms for each pair: $(z_i^G, z_i^T)$, $(\tilde{z}_i^G, z_i^T)$, $(z_i^G, \tilde{z}_i^T)$, and $(\tilde{z}_i^G, \tilde{z}_i^T)$.</p>
<p>An intra-modal graph contrastive loss further strengthens the graph encoder:</p>
<p>$$
\ell_i^{(z_i^G, \tilde{z}_i^G)} = -\log \frac{\exp(\text{sim}(z_i^G, \tilde{z}_i^G) / \tau)}{\sum_{j=1}^{N} \exp(\text{sim}(z_i^G, \tilde{z}_j^G) / \tau)}
$$</p>
<h3 id="zero-shot-text-to-graph-generation">Zero-Shot Text-to-Graph Generation</h3>
<p>MoMu enables a zero-shot generation pipeline by combining the pre-trained MoMu encoders with MoFlow, a flow-based molecular generator. Given an input text description $x^T$, the method:</p>
<ol>
<li>Samples a latent variable $q$ from MoFlow&rsquo;s Gaussian prior $P(q)$</li>
<li>Generates a molecular graph through MoFlow&rsquo;s reverse flows: $\hat{E} = f_g^{-1}(q_e)$ and $\hat{V} = f_c^{-1}(q_v \mid GN(\hat{E}))$</li>
<li>Feeds $\hat{V}$ (using soft atom type probabilities instead of hard assignments) into MoMu&rsquo;s graph encoder</li>
<li>Optimizes $q$ to maximize the cosine similarity between the resulting graph and text representations:</li>
</ol>
<p>$$
\ell_q = -\text{sim}(z^G, z^T) / \tau
$$</p>
<p>All MoMu and MoFlow parameters are frozen; only $q$ is updated via Adam for up to 500 iterations. The final molecule is obtained by applying argmax to the optimized probability matrices $\hat{V}$ and $\hat{E}$.</p>
<h2 id="evaluation-across-four-downstream-tasks">Evaluation Across Four Downstream Tasks</h2>
<h3 id="cross-modal-retrieval">Cross-Modal Retrieval</h3>
<p>MoMu is evaluated on the PCdes dataset (15K SMILES-description pairs from PubChem, split 10,500/1,500/3,000 for train/val/test). Retrieval is performed in mini-batches of 64 pairs, reporting top-1 accuracy and Recall@20.</p>
<p><strong>Graph-to-Text Retrieval (PCdes, fine-tuned)</strong>:</p>
<table>
  <thead>
      <tr>
          <th>Method</th>
          <th>Sentence Acc</th>
          <th>Sentence R@20</th>
          <th>Paragraph Acc</th>
          <th>Paragraph R@20</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>Sci-BERT</td>
          <td>50.38</td>
          <td>62.11</td>
          <td>62.57</td>
          <td>60.67</td>
      </tr>
      <tr>
          <td>KV-PLM</td>
          <td>53.79</td>
          <td>66.63</td>
          <td>64.81</td>
          <td>63.87</td>
      </tr>
      <tr>
          <td>KV-PLM*</td>
          <td>55.92</td>
          <td>68.59</td>
          <td>77.92</td>
          <td>75.93</td>
      </tr>
      <tr>
          <td>MoMu-S</td>
          <td>58.64</td>
          <td>80.59</td>
          <td>80.62</td>
          <td>79.11</td>
      </tr>
      <tr>
          <td>MoMu-K</td>
          <td>58.74</td>
          <td>81.29</td>
          <td>81.09</td>
          <td>80.15</td>
      </tr>
  </tbody>
</table>
<p><strong>Text-to-Graph Retrieval (PCdes, fine-tuned)</strong>:</p>
<table>
  <thead>
      <tr>
          <th>Method</th>
          <th>Sentence Acc</th>
          <th>Sentence R@20</th>
          <th>Paragraph Acc</th>
          <th>Paragraph R@20</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>Sci-BERT</td>
          <td>50.12</td>
          <td>68.02</td>
          <td>61.75</td>
          <td>60.77</td>
      </tr>
      <tr>
          <td>KV-PLM</td>
          <td>54.22</td>
          <td>71.80</td>
          <td>64.95</td>
          <td>64.27</td>
      </tr>
      <tr>
          <td>KV-PLM*</td>
          <td>55.61</td>
          <td>74.77</td>
          <td>77.03</td>
          <td>75.47</td>
      </tr>
      <tr>
          <td>MoMu-S</td>
          <td>55.44</td>
          <td>76.92</td>
          <td>80.22</td>
          <td>79.02</td>
      </tr>
      <tr>
          <td>MoMu-K</td>
          <td>54.94</td>
          <td>78.29</td>
          <td>81.45</td>
          <td>80.62</td>
      </tr>
  </tbody>
</table>
<p>In zero-shot retrieval (on a separate test set of 5,562 pairs not seen during pre-training), MoMu achieves approximately 39-46% accuracy compared to below 2% for Sci-BERT and KV-PLM, demonstrating strong generalization.</p>
<h3 id="molecule-captioning">Molecule Captioning</h3>
<p>MoMu&rsquo;s graph features are appended to MolT5&rsquo;s encoder inputs through a learned MLP mapping module on the ChEBI-20 dataset. Results show improvements in BLEU, METEOR, and Text2Mol scores when incorporating graph features, though ROUGE-L slightly drops. The graph structural information leads to more accurate captions for complex molecular structures.</p>
<h3 id="molecular-property-prediction">Molecular Property Prediction</h3>
<p>The pre-trained graph encoder from MoMu is fine-tuned on eight <a href="/notes/chemistry/molecular-design/property-prediction/moleculenet-benchmark-molecular-ml/">MoleculeNet</a> datasets using scaffold splitting and ROC-AUC evaluation (10 runs).</p>
<table>
  <thead>
      <tr>
          <th>Dataset</th>
          <th>No Pre-Train</th>
          <th>GraphCL</th>
          <th>MoMu-S</th>
          <th>MoMu-K</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>BBBP</td>
          <td>65.8</td>
          <td>69.7</td>
          <td><strong>70.5</strong></td>
          <td>70.1</td>
      </tr>
      <tr>
          <td>Tox21</td>
          <td>74.0</td>
          <td>73.9</td>
          <td>75.6</td>
          <td>75.6</td>
      </tr>
      <tr>
          <td>ToxCast</td>
          <td>63.4</td>
          <td>62.4</td>
          <td>63.4</td>
          <td>63.0</td>
      </tr>
      <tr>
          <td>SIDER</td>
          <td>57.3</td>
          <td>60.5</td>
          <td>60.5</td>
          <td>60.4</td>
      </tr>
      <tr>
          <td>ClinTox</td>
          <td>58.0</td>
          <td>76.0</td>
          <td><strong>79.9</strong></td>
          <td>77.4</td>
      </tr>
      <tr>
          <td>MUV</td>
          <td>71.8</td>
          <td>69.8</td>
          <td>70.5</td>
          <td>71.1</td>
      </tr>
      <tr>
          <td>HIV</td>
          <td>75.3</td>
          <td><strong>78.5</strong></td>
          <td>75.9</td>
          <td>76.2</td>
      </tr>
      <tr>
          <td>BACE</td>
          <td>70.1</td>
          <td>75.4</td>
          <td>76.7</td>
          <td>77.1</td>
      </tr>
      <tr>
          <td><strong>Average</strong></td>
          <td>66.96</td>
          <td>70.78</td>
          <td><strong>71.63</strong></td>
          <td>71.36</td>
      </tr>
  </tbody>
</table>
<p>MoMu-S achieves the best average ROC-AUC (71.63%) across all eight datasets, outperforming GraphCL (70.78%), the self-supervised method used to initialize MoMu&rsquo;s graph encoder. MoMu outperforms GraphCL on six of eight datasets. Notably, MoMu-S and MoMu-K perform comparably, indicating that KV-PLM&rsquo;s SMILES-based knowledge does not transfer well to graph-based representations.</p>
<h3 id="zero-shot-text-to-graph-generation-1">Zero-Shot Text-to-Graph Generation</h3>
<p>The method generates molecules from three types of text descriptions:</p>
<ol>
<li><strong>High-level vague descriptions</strong> (e.g., &ldquo;The molecule is beautiful&rdquo;): MoMu generates diverse, interpretable molecules where &ldquo;beautiful&rdquo; tends to produce locally symmetric and stretched graphs, &ldquo;versatile&rdquo; produces molecules with varied elements and functional groups, and &ldquo;strange&rdquo; produces cluttered, irregular structures.</li>
<li><strong>Functional descriptions</strong> (e.g., &ldquo;fluorescent molecules&rdquo;, &ldquo;high water solubility and barrier permeability with low toxicity&rdquo;): MoMu successfully generates molecules with appropriate functional groups and properties. For the solubility/permeability/toxicity query, MoMu generates molecules that satisfy three of three evaluable properties.</li>
<li><strong>Structural descriptions</strong> (e.g., &ldquo;molecules containing <a href="https://en.wikipedia.org/wiki/Nucleophile">nucleophilic</a> groups&rdquo;): MoMu generates diverse molecules with appropriate functional groups (amino, hydroxyl, carbonyl, halogen atoms).</li>
</ol>
<h2 id="promising-multimodal-transfer-with-clear-data-limitations">Promising Multimodal Transfer with Clear Data Limitations</h2>
<p>MoMu demonstrates that contrastive pre-training on weakly-correlated graph-text data can bridge molecular graphs and natural language in a shared representation space. The key findings are:</p>
<ol>
<li><strong>Cross-modal alignment works with limited data</strong>: With only 15K graph-text pairs (far fewer than the millions used in vision-language models like CLIP), MoMu achieves meaningful cross-modal retrieval and enables zero-shot generation.</li>
<li><strong>Multimodal supervision improves graph representations</strong>: The graph encoder supervised by text descriptions outperforms self-supervised methods (GraphCL, AttrMasking, ContextPred) on average across molecular property prediction benchmarks.</li>
<li><strong>SMILES knowledge does not transfer to graphs</strong>: MoMu-S and MoMu-K perform comparably across all tasks, showing that structural information learned from one-dimensional SMILES strings does not readily generalize to graph neural networks.</li>
</ol>
<h3 id="limitations">Limitations</h3>
<p>The authors acknowledge several important limitations:</p>
<ul>
<li><strong>Data scarcity</strong>: 15K graph-text pairs is substantially smaller than general image-text datasets, potentially leaving the common space insufficiently aligned.</li>
<li><strong>Noisy supervision</strong>: Retrieved texts may mention a molecule by name without describing its properties or structure, leading to spurious correlations.</li>
<li><strong>Generator constraints</strong>: The zero-shot generation method is limited by MoFlow&rsquo;s capacity (maximum 38 atoms, 9 element types from ZINC250K training).</li>
<li><strong>Property coverage</strong>: Generation quality degrades for molecular properties that appear infrequently or not at all in the training texts.</li>
</ul>
<h3 id="future-directions">Future Directions</h3>
<p>The authors propose four avenues: (1) collecting larger-scale multimodal molecular data including 3D conformations, (2) using strongly-correlated paired data with more advanced generators, (3) developing interpretable tools for the learned cross-modal space, and (4) wet-lab validation of generated molecules.</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>Pre-training</td>
          <td>Collected graph-text pairs (PubChem + S2ORC)</td>
          <td>15,613 pairs</td>
          <td>~37M paragraphs total; top 50K PubChem compounds</td>
      </tr>
      <tr>
          <td>Cross-modal retrieval</td>
          <td>PCdes</td>
          <td>15K pairs (10.5K/1.5K/3K split)</td>
          <td>SMILES-description pairs from PubChem</td>
      </tr>
      <tr>
          <td>Molecule captioning</td>
          <td>ChEBI-20</td>
          <td>~33K pairs</td>
          <td>Used with MolT5</td>
      </tr>
      <tr>
          <td>Text-to-graph generation</td>
          <td><a href="/notes/chemistry/datasets/zinc-22/">ZINC250K</a> (MoFlow)</td>
          <td>250K molecules</td>
          <td>Pre-trained generator, max 38 atoms</td>
      </tr>
      <tr>
          <td>Property prediction</td>
          <td>MoleculeNet (8 datasets)</td>
          <td>Varies</td>
          <td>BBBP, Tox21, ToxCast, SIDER, ClinTox, MUV, HIV, BACE</td>
      </tr>
  </tbody>
</table>
<h3 id="algorithms">Algorithms</h3>
<ul>
<li><strong>Graph augmentations</strong>: Node dropping (10% ratio) and subgraph extraction (80% of original size via random walk)</li>
<li><strong>Contrastive learning</strong>: InfoNCE loss with temperature $\tau = 0.1$, following the DeClip paradigm with both inter-modal and intra-modal objectives</li>
<li><strong>Zero-shot generation</strong>: Adam optimizer on latent variable $q$ for up to 500 iterations; formal charges prohibited in output</li>
</ul>
<h3 id="models">Models</h3>
<ul>
<li><strong>Graph encoder</strong>: GIN with 5 layers, 300-dimensional hidden size, initialized from GraphCL checkpoint</li>
<li><strong>Text encoder</strong>: BERT-base (768 hidden size), initialized from Sci-BERT or KV-PLM</li>
<li><strong>Projection heads</strong>: Two MLPs projecting graph (300-dim) and text (768-dim) features to 256-dimensional shared space</li>
<li><strong>Optimizer</strong>: AdamW, learning rate 0.0001, weight decay 1e-5, 300 epochs, batch size 256</li>
</ul>
<h3 id="evaluation">Evaluation</h3>
<table>
  <thead>
      <tr>
          <th>Task</th>
          <th>Metric</th>
          <th>Best Result</th>
          <th>Notes</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>G-T Retrieval (PCdes)</td>
          <td>Accuracy / R@20</td>
          <td>81.09 / 80.15 (paragraph)</td>
          <td>MoMu-K, fine-tuned</td>
      </tr>
      <tr>
          <td>T-G Retrieval (PCdes)</td>
          <td>Accuracy / R@20</td>
          <td>81.45 / 80.62 (paragraph)</td>
          <td>MoMu-K, fine-tuned</td>
      </tr>
      <tr>
          <td>Zero-shot G-T Retrieval</td>
          <td>Accuracy</td>
          <td>~46%</td>
          <td>vs. ~1.4% for baselines</td>
      </tr>
      <tr>
          <td>Property Prediction</td>
          <td>ROC-AUC (avg)</td>
          <td>71.63%</td>
          <td>MoMu-S, 8 MoleculeNet datasets</td>
      </tr>
      <tr>
          <td>Molecule Captioning</td>
          <td>Text2Mol</td>
          <td>Improved over MolT5</td>
          <td>MoMu + MolT5-large</td>
      </tr>
  </tbody>
</table>
<h3 id="hardware">Hardware</h3>
<ul>
<li>Pre-training: 8x NVIDIA Tesla V100 PCIe 32GB GPUs</li>
<li>Framework: PyTorch</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/BingSu12/MoMu">MoMu code</a></td>
          <td>Code</td>
          <td>Not specified</td>
          <td>Pre-training and downstream task code</td>
      </tr>
      <tr>
          <td><a href="https://github.com/yangzhao1230/GraphTextRetrieval">GraphTextRetrieval</a></td>
          <td>Code</td>
          <td>Not specified</td>
          <td>Data collection and cross-modal retrieval code</td>
      </tr>
      <tr>
          <td><a href="https://pan.baidu.com/s/1aHJoYTTZWDHPCcRuu9I7Fg">Pre-training dataset</a></td>
          <td>Dataset</td>
          <td>Not specified</td>
          <td>Hosted on Baidu Pan (Chinese cloud storage)</td>
      </tr>
  </tbody>
</table>
<hr>
<h2 id="paper-information">Paper Information</h2>
<p><strong>Citation</strong>: Su, B., Du, D., Yang, Z., Zhou, Y., Li, J., Rao, A., Sun, H., Lu, Z., &amp; Wen, J.-R. (2022). A Molecular Multimodal Foundation Model Associating Molecule Graphs with Natural Language. arXiv preprint arXiv:2209.05481.</p>
<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">@article</span>{su2022momu,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">title</span>=<span style="color:#e6db74">{A Molecular Multimodal Foundation Model Associating Molecule Graphs with Natural Language}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">author</span>=<span style="color:#e6db74">{Su, Bing and Du, Dazhao and Yang, Zhao and Zhou, Yujie and Li, Jiangmeng and Rao, Anyi and Sun, Hao and Lu, Zhiwu and Wen, Ji-Rong}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">journal</span>=<span style="color:#e6db74">{arXiv preprint arXiv:2209.05481}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">year</span>=<span style="color:#e6db74">{2022}</span>
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div>]]></content:encoded></item><item><title>MolFM: Trimodal Molecular Foundation Pre-training</title><link>https://hunterheidenreich.com/notes/chemistry/molecular-representations/multimodal/molfm-multimodal-molecular-foundation/</link><pubDate>Sat, 28 Mar 2026 00:00:00 +0000</pubDate><guid>https://hunterheidenreich.com/notes/chemistry/molecular-representations/multimodal/molfm-multimodal-molecular-foundation/</guid><description>MolFM fuses molecular graphs, biomedical text, and knowledge graphs via cross-modal attention for joint molecular representation learning.</description><content:encoded><![CDATA[<h2 id="trimodal-pre-training-for-molecular-understanding">Trimodal Pre-training for Molecular Understanding</h2>
<p>MolFM is a <strong>Method</strong> paper that introduces a multimodal molecular foundation model integrating three distinct sources of molecular knowledge: 2D molecular graphs, biomedical text, and knowledge graphs. The primary contribution is a pre-training framework that uses fine-grained cross-modal attention to fuse information across all three modalities, combined with theoretical justification from a deep metric learning perspective. MolFM achieves the best reported results (at time of publication) on cross-modal retrieval, molecule captioning, text-based molecule generation, and molecular property prediction.</p>
<h2 id="why-existing-molecular-models-fall-short">Why Existing Molecular Models Fall Short</h2>
<p>Prior multimodal molecular foundation models operate on at most two modalities (structures and text) and suffer from two key limitations. First, generative approaches like KV-PLM and MolT5 rely on 1D <a href="/notes/chemistry/molecular-representations/notations/smiles/">SMILES</a> strings, which cannot capture complex topological and spatial molecular properties such as macrocycles. Contrastive approaches like <a href="/notes/chemistry/molecular-representations/multimodal/momu-molecular-multimodal-foundation/">MoMu</a> and MoleculeSTM learn global alignment between molecule graphs and text but overlook fine-grained connections between specific substructures and textual descriptions.</p>
<p>Second, and more fundamentally, no prior model incorporates <a href="https://en.wikipedia.org/wiki/Knowledge_graph">knowledge graphs</a> as a third modality. Knowledge graphs encode global-level relationships among molecules, target ligands, diseases, and other biomedical entities. These relationships capture functional and structural similarity patterns that cannot be learned from individual molecule-text pairs alone. MolFM addresses both gaps by introducing cross-modal attention across all three modalities and providing theoretical guarantees about what the pre-training objectives learn.</p>
<h2 id="cross-modal-attention-and-metric-learning-guarantees">Cross-Modal Attention and Metric Learning Guarantees</h2>
<h3 id="architecture">Architecture</h3>
<p>MolFM uses three pre-trained single-modal encoders:</p>
<ul>
<li><strong>Molecular graph encoder</strong>: A 5-layer GIN (1.8M parameters) initialized from GraphMVP, producing atom-level features $h_{SA}$ and a graph-level feature $h_{SM}$</li>
<li><strong>Text encoder</strong>: A 6-layer transformer (61.8M parameters) initialized from KV-PLM&rsquo;s first 6 layers, producing token features $h_T$</li>
<li><strong>Knowledge graph encoder</strong>: A TransE model (12.6M parameters) trained on the knowledge graph for 500 epochs, producing entity features $h_K$</li>
</ul>
<p>A multimodal encoder (61.8M parameters, 6 transformer layers with cross-attention) fuses the three modalities. The cross-attention uses text token features as queries and the concatenation of atom features and knowledge graph neighbor features as keys and values. For each molecule, the knowledge graph input is the molecule&rsquo;s entity and $N=4$ randomly sampled one-hop neighbors.</p>
<h3 id="pre-training-objectives">Pre-training Objectives</h3>
<p>MolFM combines four losses:</p>
<p><strong>Structure-text contrastive (STC)</strong> aligns the global feature spaces of structure and text encoders using a symmetric InfoNCE loss:</p>
<p>$$\mathcal{L}_{stc} = -\frac{1}{2} \left[ \log \frac{\exp(s(z_S, z_T) / \tau)}{\sum_{S&rsquo; \in B} \exp(s(z_{S&rsquo;}, z_T) / \tau)} + \log \frac{\exp(s(z_S, z_T) / \tau)}{\sum_{T&rsquo; \in B} \exp(s(z_S, z_{T&rsquo;}) / \tau)} \right]$$</p>
<p>where $s(\cdot, \cdot)$ is cosine similarity and $\tau = 0.1$ is a temperature parameter.</p>
<p><strong>Cross-modal matching (CMM)</strong> predicts whether a structure-text-knowledge triplet corresponds to the same molecule, using cross-entropy over the multimodal encoder&rsquo;s CLS token:</p>
<p>$$\mathcal{L}_{cmm} = \sum_{(\tilde{S}, \tilde{T}, \tilde{K}) \in \tilde{B}} H\left[y_{cmm}(\tilde{S}, \tilde{T}, \tilde{K}),; p_{cmm}\left(\mathcal{M}_\theta(h_{\tilde{S}}, h_{\tilde{T}}, h_{\tilde{K}})\right)\right]$$</p>
<p><strong>Masked language modeling (MLM)</strong> predicts masked text tokens conditioned on all three modalities:</p>
<p>$$\mathcal{L}_{mlm} = H\left[y_{mlm}(\hat{T}),; p_{mlm}\left(\mathcal{M}_\theta(h_S, h_{\hat{T}}, h_K)\right)\right]$$</p>
<p><strong>Knowledge graph embedding (KGE)</strong> regularizes entity embeddings with a max-margin TransE loss:</p>
<p>$$\mathcal{L}_{kge} = \sum_{h \in K} \left[\max(0, d(h,r,t) - d(h,r,\tilde{t}) + \Delta) + \max(0, d(h,r,t) - d(\tilde{h},r,t) + \Delta)\right]$$</p>
<p>where $d(h,r,t) = | f(h) + g(r) - f(t) |_2$ and $\Delta = 0.2$.</p>
<p>The total pre-training loss is:</p>
<p>$$\mathcal{L} = \mathbb{E}_{(S,T,K)}\left[\mathcal{L}_{stc} + \mathcal{L}_{cmm} + \mathcal{L}_{mlm} + \mathcal{L}_{kge}\right]$$</p>
<h3 id="theoretical-justifications">Theoretical Justifications</h3>
<p>The authors provide metric learning interpretations for each objective. For CMM, they show that the loss is proportional to assigning higher scores to matched triplets and lower scores to unmatched ones, aligning the feature space across all three modalities.</p>
<p>For KGE, two lemmas provide guarantees about structurally and functionally similar molecules:</p>
<p><strong>Lemma 1</strong> (Structural similarity): For a symmetric structural-similarity relation $r_s$, the KGE loss satisfies:</p>
<p>$$\mathcal{L}_{kge}(h, r_s, t) \propto 2|f(h) - f(t)| - \mathbb{E}_{\tilde{t}}|f(h) - f(\tilde{t})| - \mathbb{E}_{\tilde{h}}|f(\tilde{h}) - f(t)|$$</p>
<p>This shows KGE pulls structurally similar molecules closer while pushing dissimilar ones apart.</p>
<p><strong>Lemma 2</strong> (Functional similarity): For molecules $h$ and $t$ that interact with a common entity $o$, the distance between their embeddings is upper-bounded:</p>
<p>$$|f(h) - f(t)| \leq \alpha,\mathbb{E}_{(e_1, r, e_2) \sim \mathcal{I}}\left[\mathcal{L}_{kge}(e_1, r, e_2)\right] + C$$</p>
<p>where $\alpha \approx 1$ and $C \approx 0$. This guarantees that minimizing KGE also brings functionally similar molecules closer in the embedding space.</p>
<h2 id="experiments-across-four-downstream-tasks">Experiments Across Four Downstream Tasks</h2>
<h3 id="pre-training-data">Pre-training Data</h3>
<p>MolFM pre-trains on 15K molecules from <a href="https://en.wikipedia.org/wiki/PubChem">PubChem</a> paired with 37M paragraphs from S2ORC. The knowledge graph contains 49K entities and 3.2M relations, constructed from <a href="https://en.wikipedia.org/wiki/DrugBank">DrugBank</a>, <a href="https://en.wikipedia.org/wiki/BindingDB">BindingDB</a>, and additional public databases with heuristic augmentation.</p>
<h3 id="cross-modal-retrieval">Cross-Modal Retrieval</h3>
<p>Evaluated on PCdes (paragraph-level) in zero-shot and fine-tuning settings. MolFM uses a re-ranking strategy that linearly combines cosine similarity with CMM logits over the top-$k$ retrieved candidates.</p>
<table>
  <thead>
      <tr>
          <th>Mode</th>
          <th>Model</th>
          <th>S-T MRR</th>
          <th>S-T R@1</th>
          <th>S-T R@10</th>
          <th>T-S MRR</th>
          <th>T-S R@1</th>
          <th>T-S R@10</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>Zero-shot</td>
          <td>MoMu</td>
          <td>9.89</td>
          <td>5.08</td>
          <td>18.93</td>
          <td>10.33</td>
          <td>4.90</td>
          <td>20.69</td>
      </tr>
      <tr>
          <td>Zero-shot</td>
          <td>MolFM</td>
          <td>21.42</td>
          <td>13.90</td>
          <td>36.21</td>
          <td>23.63</td>
          <td>16.14</td>
          <td>39.54</td>
      </tr>
      <tr>
          <td>Fine-tune</td>
          <td>MoMu</td>
          <td>34.29</td>
          <td>24.47</td>
          <td>53.84</td>
          <td>34.53</td>
          <td>24.87</td>
          <td>54.25</td>
      </tr>
      <tr>
          <td>Fine-tune</td>
          <td>MolFM</td>
          <td>39.56</td>
          <td>29.76</td>
          <td>58.63</td>
          <td>39.34</td>
          <td>29.39</td>
          <td>58.49</td>
      </tr>
  </tbody>
</table>
<p>MolFM achieves 12.13% and 5.04% absolute gains over MoMu under zero-shot and fine-tuning settings, respectively.</p>
<h3 id="molecule-captioning">Molecule Captioning</h3>
<p>Evaluated on ChEBI-20 using MolT5 decoders. MolFM&rsquo;s structure encoder features are concatenated with the MolT5 encoder outputs.</p>
<table>
  <thead>
      <tr>
          <th>Decoder</th>
          <th>Encoder</th>
          <th>BLEU-4</th>
          <th>ROUGE-L</th>
          <th>METEOR</th>
          <th>Text2Mol</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>MolT5-base</td>
          <td>MolT5-base</td>
          <td>0.457</td>
          <td>0.578</td>
          <td>0.569</td>
          <td>0.547</td>
      </tr>
      <tr>
          <td>MolT5-base</td>
          <td>MoMu</td>
          <td>0.462</td>
          <td>0.575</td>
          <td>0.576</td>
          <td>0.558</td>
      </tr>
      <tr>
          <td>MolT5-base</td>
          <td>GraphMVP</td>
          <td>0.491</td>
          <td>0.592</td>
          <td>0.599</td>
          <td>0.570</td>
      </tr>
      <tr>
          <td>MolT5-base</td>
          <td>MolFM</td>
          <td>0.498</td>
          <td>0.594</td>
          <td>0.607</td>
          <td>0.576</td>
      </tr>
  </tbody>
</table>
<h3 id="text-based-molecule-generation">Text-Based Molecule Generation</h3>
<p>Also on ChEBI-20 with MolT5 decoders. MolFM&rsquo;s text features are projected and fed to the decoder.</p>
<table>
  <thead>
      <tr>
          <th>Decoder</th>
          <th>Encoder</th>
          <th>Exact</th>
          <th>Valid</th>
          <th>Morgan FTS</th>
          <th>Text2Mol</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>MolT5-base</td>
          <td>MolT5-base</td>
          <td>0.082</td>
          <td>0.786</td>
          <td>0.601</td>
          <td>0.543</td>
      </tr>
      <tr>
          <td>MolT5-base</td>
          <td>MoMu</td>
          <td>0.183</td>
          <td>0.863</td>
          <td>0.678</td>
          <td>0.580</td>
      </tr>
      <tr>
          <td>MolT5-base</td>
          <td>MolFM</td>
          <td>0.210</td>
          <td>0.892</td>
          <td>0.697</td>
          <td>0.583</td>
      </tr>
  </tbody>
</table>
<h3 id="molecular-property-prediction">Molecular Property Prediction</h3>
<p>On <a href="/notes/chemistry/molecular-design/property-prediction/moleculenet-benchmark-molecular-ml/">MoleculeNet</a> (8 classification datasets), MolFM concatenates the structure feature and the multimodal encoder&rsquo;s CLS feature to predict properties.</p>
<table>
  <thead>
      <tr>
          <th>Model</th>
          <th>BBBP</th>
          <th>Tox21</th>
          <th>ClinTox</th>
          <th>HIV</th>
          <th>BACE</th>
          <th>Avg</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>GraphMVP</td>
          <td>72.4</td>
          <td>74.4</td>
          <td>77.5</td>
          <td>77.0</td>
          <td>81.2</td>
          <td>73.07</td>
      </tr>
      <tr>
          <td>DeepEIK</td>
          <td>72.1</td>
          <td>72.4</td>
          <td>89.7</td>
          <td>75.0</td>
          <td>80.5</td>
          <td>73.27</td>
      </tr>
      <tr>
          <td>MolFM (w/o T+K)</td>
          <td>72.2</td>
          <td>76.6</td>
          <td>78.6</td>
          <td>78.2</td>
          <td>82.6</td>
          <td>73.95</td>
      </tr>
      <tr>
          <td>MolFM (w/ T+K)</td>
          <td>72.9</td>
          <td>77.2</td>
          <td>79.7</td>
          <td>78.8</td>
          <td>83.9</td>
          <td>74.62</td>
      </tr>
  </tbody>
</table>
<p>With multimodal inputs, MolFM averages 74.62% ROC-AUC, a 1.55% absolute gain over GraphMVP.</p>
<h3 id="ablation-studies">Ablation Studies</h3>
<p>Zero-shot retrieval ablations reveal that cross-modal attention to atoms and CMM are the most critical components. Removing either causes a sharp drop (approximately 3% on S-T retrieval). Knowledge graph incorporation yields a 1.5% average improvement, with both attention to neighbors and KGE contributing marginally.</p>
<h2 id="key-findings-and-limitations">Key Findings and Limitations</h2>
<p>MolFM demonstrates that incorporating knowledge graphs as a third modality provides consistent improvements across all evaluated tasks. The theoretical analysis connecting pre-training objectives to deep metric learning provides interpretability for why the model works: STC and CMM align representations of the same molecule across modalities, while KGE pulls structurally and functionally similar molecules closer in the embedding space.</p>
<p>The cross-modal attention visualizations show that MolFM learns to associate specific atom substructures with relevant text tokens and knowledge graph entities. For example, the model correctly attends to functional groups mentioned in textual descriptions.</p>
<p>The authors acknowledge several limitations:</p>
<ol>
<li><strong>Data quality</strong>: The pre-training dataset (15K molecules) is small and may introduce biases</li>
<li><strong>Cold-start problem</strong>: MolFM provides limited benefit for newly emerged molecules lacking text and knowledge graph information</li>
<li><strong>Entity scope</strong>: The model focuses on molecules and does not incorporate proteins, genes, or cell lines, which could further improve biomedical understanding</li>
</ol>
<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>Pre-training (molecules)</td>
          <td>PubChem</td>
          <td>15K molecules</td>
          <td>Follows MoMu&rsquo;s pre-training data</td>
      </tr>
      <tr>
          <td>Pre-training (text)</td>
          <td>S2ORC</td>
          <td>37M paragraphs</td>
          <td>Biomedical literature paragraphs</td>
      </tr>
      <tr>
          <td>Knowledge graph</td>
          <td>DrugBank, BindingDB, public DBs</td>
          <td>49K entities, 3.2M relations</td>
          <td>Constructed with heuristics from MoCL</td>
      </tr>
      <tr>
          <td>Cross-modal retrieval</td>
          <td>PCdes</td>
          <td>Paragraph-level</td>
          <td>Test split</td>
      </tr>
      <tr>
          <td>Captioning/Generation</td>
          <td>ChEBI-20</td>
          <td>-</td>
          <td>Following MolT5 splits</td>
      </tr>
      <tr>
          <td>Property prediction</td>
          <td>MoleculeNet</td>
          <td>8 datasets</td>
          <td>Classification tasks, ROC-AUC metric</td>
      </tr>
  </tbody>
</table>
<h3 id="algorithms">Algorithms</h3>
<ul>
<li>Optimizer: AdamW with weight decay $1 \times 10^{-4}$</li>
<li>Learning rate: linear warmup to $1 \times 10^{-4}$ over 2,000 iterations, cosine annealing to $1 \times 10^{-5}$</li>
<li>Batch size: 128</li>
<li>Pre-training epochs: 300</li>
<li>Knowledge graph neighbors per molecule: $N = 4$</li>
<li>Temperature: $\tau = 0.1$</li>
<li>Margin: $\Delta = 0.2$</li>
</ul>
<h3 id="models">Models</h3>
<table>
  <thead>
      <tr>
          <th>Component</th>
          <th>Architecture</th>
          <th>Parameters</th>
          <th>Initialization</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>Graph encoder</td>
          <td>5-layer GIN</td>
          <td>1.8M</td>
          <td>GraphMVP</td>
      </tr>
      <tr>
          <td>Text encoder</td>
          <td>6-layer Transformer</td>
          <td>61.8M</td>
          <td>KV-PLM (first 6 layers)</td>
      </tr>
      <tr>
          <td>Knowledge encoder</td>
          <td>TransE</td>
          <td>12.6M</td>
          <td>Trained 500 epochs on KG</td>
      </tr>
      <tr>
          <td>Multimodal encoder</td>
          <td>6-layer Transformer + cross-attention</td>
          <td>61.8M</td>
          <td>KV-PLM (last 6 layers)</td>
      </tr>
      <tr>
          <td><strong>Total</strong></td>
          <td></td>
          <td><strong>~138M</strong></td>
          <td></td>
      </tr>
  </tbody>
</table>
<h3 id="evaluation">Evaluation</h3>
<table>
  <thead>
      <tr>
          <th>Task</th>
          <th>Metrics</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>Cross-modal retrieval</td>
          <td>MRR, Recall@1/5/10</td>
      </tr>
      <tr>
          <td>Molecule captioning</td>
          <td>BLEU-2/4, ROUGE-1/2/L, METEOR, Text2Mol</td>
      </tr>
      <tr>
          <td>Text-to-molecule generation</td>
          <td>BLEU, Exact ratio, Validity, Levenshtein, Fingerprint Tanimoto (MACCS/RDKit/Morgan), Text2Mol</td>
      </tr>
      <tr>
          <td>Property prediction</td>
          <td>ROC-AUC per dataset</td>
      </tr>
  </tbody>
</table>
<h3 id="hardware">Hardware</h3>
<ul>
<li>4 NVIDIA A100 GPUs for pre-training</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/BioFM/OpenBioMed">OpenBioMed</a></td>
          <td>Code</td>
          <td>MIT</td>
          <td>Official implementation including MolFM</td>
      </tr>
  </tbody>
</table>
<hr>
<h2 id="paper-information">Paper Information</h2>
<p><strong>Citation</strong>: Luo, Y., Yang, K., Hong, M., Liu, X. Y., &amp; Nie, Z. (2023). MolFM: A Multimodal Molecular Foundation Model. <em>arXiv preprint arXiv:2307.09484</em>.</p>
<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">@article</span>{luo2023molfm,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">title</span>=<span style="color:#e6db74">{MolFM: A Multimodal Molecular Foundation Model}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">author</span>=<span style="color:#e6db74">{Luo, Yizhen and Yang, Kai and Hong, Massimo and Liu, Xing Yi and Nie, Zaiqing}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">journal</span>=<span style="color:#e6db74">{arXiv preprint arXiv:2307.09484}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">year</span>=<span style="color:#e6db74">{2023}</span>
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div>]]></content:encoded></item><item><title>BioT5: Cross-Modal Integration of Biology and Chemistry</title><link>https://hunterheidenreich.com/notes/chemistry/molecular-representations/multimodal/biot5-cross-modal-biology/</link><pubDate>Sat, 28 Mar 2026 00:00:00 +0000</pubDate><guid>https://hunterheidenreich.com/notes/chemistry/molecular-representations/multimodal/biot5-cross-modal-biology/</guid><description>BioT5 is a T5-based pretraining framework that jointly models molecules, proteins, and natural language using SELFIES for robust molecular generation.</description><content:encoded><![CDATA[<h2 id="a-unified-pretraining-framework-for-molecules-proteins-and-text">A Unified Pretraining Framework for Molecules, Proteins, and Text</h2>
<p>BioT5 is a <strong>Method</strong> paper that introduces a comprehensive <a href="/notes/natural-language-processing/language-models/t5-text-to-text-transfer-transformer/">T5</a>-based pretraining framework for cross-modal integration of molecules, proteins, and natural language. The primary contribution is a multi-task pretraining approach that uses <a href="/notes/chemistry/molecular-representations/notations/selfies/">SELFIES</a> (instead of <a href="/notes/chemistry/molecular-representations/notations/smiles/">SMILES</a>) for 100% valid molecular representations, separate tokenization for each modality, and a combination of masked language modeling and translation objectives to connect structured biological data with unstructured scientific text. After fine-tuning, BioT5 (252M parameters) achieves state-of-the-art performance on 10 out of 15 downstream tasks spanning molecule property prediction, protein property prediction, drug-target interaction, protein-protein interaction, molecule captioning, and text-based molecule generation.</p>
<h2 id="bridging-the-gap-between-molecular-sequences-and-scientific-knowledge">Bridging the Gap Between Molecular Sequences and Scientific Knowledge</h2>
<p>Prior cross-modal models in computational biology face three recurring challenges. First, models like MolT5 and MolXPT rely on SMILES to represent molecules, but SMILES strings are syntactically fragile: random perturbations or model-generated sequences frequently produce invalid molecular structures. Edwards et al. (2022) and Li et al. (2023) both highlight this validity problem as a bottleneck for text-to-molecule generation. Second, the contextual information surrounding molecular and protein names in scientific literature (e.g., mentions in <a href="https://en.wikipedia.org/wiki/PubMed">PubMed</a> abstracts that describe properties, interactions, and experimental results) remains underutilized. Most models either ignore this context or treat it identically to structured database entries. Third, existing approaches like MolT5 and <a href="/notes/chemistry/llm-applications/galactica-large-language-model-for-science/">Galactica</a> share a single tokenizer and embedding space across molecules, proteins, and text. This leads to chemically incorrect tokenization: the bromine atom &ldquo;Br&rdquo; in SMILES gets split into &ldquo;B&rdquo; (boron) and &ldquo;r&rdquo;, producing erroneous downstream predictions.</p>
<p>BioT5 addresses all three issues simultaneously by adopting SELFIES for molecular representation, extracting entity-linked contextual knowledge from PubMed, and employing separate vocabularies for each modality.</p>
<h2 id="selfies-separate-tokenization-and-multi-task-pretraining">SELFIES, Separate Tokenization, and Multi-Task Pretraining</h2>
<p>The core innovations of BioT5 center on three design decisions:</p>
<h3 id="selfies-for-robust-molecular-representation">SELFIES for Robust Molecular Representation</h3>
<p>BioT5 replaces SMILES with SELFIES (Self-referencing Embedded Strings) for all molecular representations. Every permutation of symbols within the SELFIES alphabet generates a chemically valid molecular structure, guaranteeing 100% validity in generation tasks. Molecules from ZINC20 are converted from SMILES to SELFIES during data preprocessing.</p>
<h3 id="modality-specific-tokenization">Modality-Specific Tokenization</h3>
<p>Rather than sharing a single SentencePiece vocabulary across modalities, BioT5 maintains three separate dictionaries:</p>
<ul>
<li><strong>Molecules</strong>: Each SELFIES token corresponds to a chemically meaningful atom group enclosed in brackets (e.g., <code>[C]</code>, <code>[=C]</code>, <code>[Br]</code>).</li>
<li><strong>Proteins</strong>: Amino acids are prefixed with a special <code>&lt;p&gt;</code> token to distinguish them from text characters (e.g., <code>&lt;p&gt;M</code>, <code>&lt;p&gt;K</code>, <code>&lt;p&gt;R</code>).</li>
<li><strong>Text</strong>: The standard T5 vocabulary is retained.</li>
</ul>
<p>This prevents semantic conflation across modalities. The total vocabulary size is 35,073, and the model comprises 252M parameters using the T5-v1.1-base architecture.</p>
<h3 id="multi-task-pretraining-objectives">Multi-Task Pretraining Objectives</h3>
<p>BioT5 uses six pretraining tasks organized into three categories:</p>
<ol>
<li><strong>Single-modal T5 objective</strong>: Standard span corruption and recovery applied independently to molecule SELFIES (task 1), protein <a href="https://en.wikipedia.org/wiki/FASTA_format">FASTA</a> (task 2), and general text from C4 (task 3).</li>
<li><strong>Wrapped text T5 objective</strong> (task 4): Applied to PubMed articles where molecular names are replaced with corresponding SELFIES strings and gene names are appended with protein FASTA sequences, using BERN2 for named entity recognition and entity linking.</li>
<li><strong>Bidirectional translation</strong> (tasks 5 and 6): Molecule SELFIES to text description and vice versa (using 339K pairs from <a href="https://en.wikipedia.org/wiki/PubChem">PubChem</a>), and protein FASTA to text description and vice versa (using 569K pairs from <a href="https://en.wikipedia.org/wiki/UniProt">Swiss-Prot</a>).</li>
</ol>
<p>The translation direction is randomly sampled with probability 0.5 for each example. For downstream tasks, BioT5 uses prompt-based fine-tuning to cast all tasks into a sequence generation format, reducing the gap between pretraining and fine-tuning.</p>
<h2 id="evaluation-across-15-downstream-tasks">Evaluation Across 15 Downstream Tasks</h2>
<p>BioT5 is evaluated on 15 tasks organized into three categories: single-instance prediction, multi-instance prediction, and cross-modal generation.</p>
<h3 id="molecule-property-prediction-moleculenet">Molecule Property Prediction (MoleculeNet)</h3>
<p>BioT5 is evaluated on six binary classification tasks from <a href="/notes/chemistry/molecular-design/property-prediction/moleculenet-benchmark-molecular-ml/">MoleculeNet</a> using scaffold splitting: BBBP, Tox21, ClinTox, HIV, BACE, and SIDER. Results are averaged over three random runs.</p>
<table>
  <thead>
      <tr>
          <th>Dataset</th>
          <th>GEM</th>
          <th>MolXPT</th>
          <th>BioT5</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>BBBP</td>
          <td>72.4</td>
          <td>80.0</td>
          <td>77.7</td>
      </tr>
      <tr>
          <td>Tox21</td>
          <td>78.1</td>
          <td>77.1</td>
          <td>77.9</td>
      </tr>
      <tr>
          <td>ClinTox</td>
          <td>90.1</td>
          <td>95.3</td>
          <td>95.4</td>
      </tr>
      <tr>
          <td>HIV</td>
          <td>80.6</td>
          <td>78.1</td>
          <td><strong>81.0</strong></td>
      </tr>
      <tr>
          <td>BACE</td>
          <td>85.6</td>
          <td>88.4</td>
          <td><strong>89.4</strong></td>
      </tr>
      <tr>
          <td>SIDER</td>
          <td>67.2</td>
          <td>71.7</td>
          <td><strong>73.2</strong></td>
      </tr>
      <tr>
          <td><strong>Avg</strong></td>
          <td>79.0</td>
          <td>81.9</td>
          <td><strong>82.4</strong></td>
      </tr>
  </tbody>
</table>
<p>BioT5 achieves the best average AUROC (82.4) across all six datasets, surpassing both GNN-based methods (GEM) and language model baselines (MolXPT).</p>
<h3 id="protein-property-prediction-peer-benchmark">Protein Property Prediction (PEER Benchmark)</h3>
<p>On the PEER benchmark, BioT5 is evaluated on protein solubility and subcellular localization prediction:</p>
<table>
  <thead>
      <tr>
          <th>Model</th>
          <th>Params</th>
          <th>Solubility (Acc)</th>
          <th>Localization (Acc)</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>ESM-1b</td>
          <td>652.4M</td>
          <td>70.23</td>
          <td><strong>92.40</strong></td>
      </tr>
      <tr>
          <td>ProtBert</td>
          <td>419.9M</td>
          <td>68.15</td>
          <td>91.32</td>
      </tr>
      <tr>
          <td>BioT5</td>
          <td>252.1M</td>
          <td><strong>74.65</strong></td>
          <td>91.69</td>
      </tr>
  </tbody>
</table>
<p>BioT5 achieves the best solubility prediction accuracy (74.65%) despite being 2-3x smaller than dedicated protein language models like ESM-1b and ProtBert.</p>
<h3 id="drug-target-interaction-prediction">Drug-Target Interaction Prediction</h3>
<p>BioT5 is evaluated on three DTI datasets (BioSNAP, Human, BindingDB) with five random runs:</p>
<table>
  <thead>
      <tr>
          <th>Method</th>
          <th>BioSNAP AUROC</th>
          <th>Human AUROC</th>
          <th>BindingDB AUROC</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>DrugBAN</td>
          <td>0.903</td>
          <td>0.982</td>
          <td>0.960</td>
      </tr>
      <tr>
          <td>BioT5</td>
          <td><strong>0.937</strong></td>
          <td><strong>0.989</strong></td>
          <td><strong>0.963</strong></td>
      </tr>
  </tbody>
</table>
<p>BioT5 consistently outperforms DrugBAN and other specialized DTI models across all three datasets.</p>
<h3 id="molecule-captioning-and-text-based-molecule-generation">Molecule Captioning and Text-Based Molecule Generation</h3>
<p>On the ChEBI-20 dataset, BioT5 outperforms all baselines in molecule captioning:</p>
<table>
  <thead>
      <tr>
          <th>Model</th>
          <th>Params</th>
          <th>BLEU-4</th>
          <th>METEOR</th>
          <th>Text2Mol</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>MolT5-large</td>
          <td>783M</td>
          <td>0.508</td>
          <td>0.614</td>
          <td>0.582</td>
      </tr>
      <tr>
          <td>MolXPT</td>
          <td>350M</td>
          <td>0.505</td>
          <td>0.626</td>
          <td>0.594</td>
      </tr>
      <tr>
          <td>BioT5</td>
          <td>252M</td>
          <td><strong>0.556</strong></td>
          <td><strong>0.656</strong></td>
          <td><strong>0.603</strong></td>
      </tr>
  </tbody>
</table>
<p>For text-based molecule generation, BioT5 achieves an exact match score of 0.413 (vs. 0.311 for MolT5-large) while maintaining 100% validity, compared to 90.5% for MolT5-large. This demonstrates the direct benefit of SELFIES: every generated sequence is a valid molecule.</p>
<h3 id="protein-protein-interaction-prediction">Protein-Protein Interaction Prediction</h3>
<p>On the PEER PPI benchmarks (Yeast and Human), BioT5 achieves competitive results, outperforming fully fine-tuned ProtBert and ESM-1b on the Yeast dataset (64.89% vs. 63.72% for ProtBert) and placing second on Human (86.22% vs. 88.06% for ESM-1b with frozen weights).</p>
<h2 id="key-findings-limitations-and-future-directions">Key Findings, Limitations, and Future Directions</h2>
<p>BioT5 demonstrates that integrating molecular, protein, and textual modalities within a single pretraining framework yields consistent improvements across diverse biological tasks. Three factors drive BioT5&rsquo;s performance: (1) SELFIES guarantees 100% molecular validity in generation tasks, eliminating a persistent failure mode of SMILES-based models; (2) separate tokenization preserves the semantic integrity of each modality; (3) wrapped text pretraining on PubMed provides contextual biological knowledge that pure sequence models miss.</p>
<p>The authors acknowledge several limitations. BioT5 requires full-parameter fine-tuning for each downstream task because instruction-tuning does not generalize across tasks, and combining datasets via instructions causes data leakage (the authors note overlaps between BindingDB training data and BioSNAP/Human test sets). The model only handles sequence-format bio-entities and does not incorporate 2D or 3D structural information. Additional biological modalities such as DNA/RNA sequences and cell-level data are also left for future work.</p>
<p>The authors also note risks: BioT5 could potentially be misused to generate dangerous molecules, and it may fail to generate effective therapeutic molecules or produce compounds with adverse side effects.</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>Pretraining (molecules)</td>
          <td>ZINC20</td>
          <td>~300M molecules</td>
          <td>Converted from SMILES to SELFIES</td>
      </tr>
      <tr>
          <td>Pretraining (proteins)</td>
          <td><a href="https://en.wikipedia.org/wiki/UniProt">UniRef50</a></td>
          <td>27M proteins</td>
          <td>Filtered by length</td>
      </tr>
      <tr>
          <td>Pretraining (text)</td>
          <td>C4</td>
          <td>Large</td>
          <td>Standard T5 corpus</td>
      </tr>
      <tr>
          <td>Pretraining (wrapped text)</td>
          <td>PubMed</td>
          <td>33M articles</td>
          <td>Entity linking via BERN2</td>
      </tr>
      <tr>
          <td>Pretraining (molecule-text pairs)</td>
          <td>PubChem</td>
          <td>339K pairs</td>
          <td>Excludes ChEBI-20 molecules</td>
      </tr>
      <tr>
          <td>Pretraining (protein-text pairs)</td>
          <td>Swiss-Prot</td>
          <td>569K pairs</td>
          <td>High-quality annotations</td>
      </tr>
      <tr>
          <td>Evaluation (molecular properties)</td>
          <td>MoleculeNet</td>
          <td>6 datasets</td>
          <td>Scaffold splitting</td>
      </tr>
      <tr>
          <td>Evaluation (protein properties)</td>
          <td>PEER</td>
          <td>2 tasks</td>
          <td>Solubility and localization</td>
      </tr>
      <tr>
          <td>Evaluation (DTI)</td>
          <td>BioSNAP, Human, BindingDB</td>
          <td>3 datasets</td>
          <td>Binary classification</td>
      </tr>
      <tr>
          <td>Evaluation (PPI)</td>
          <td>Yeast, Human</td>
          <td>2 datasets</td>
          <td>From PEER benchmark</td>
      </tr>
      <tr>
          <td>Evaluation (generation)</td>
          <td>ChEBI-20</td>
          <td>33K pairs</td>
          <td>Molecule captioning and text-to-molecule</td>
      </tr>
  </tbody>
</table>
<h3 id="algorithms">Algorithms</h3>
<ul>
<li>Architecture: T5-v1.1-base (encoder-decoder transformer)</li>
<li>Optimizer: AdamW with RMS scaling</li>
<li>Learning rate: cosine annealing, base $1 \times 10^{-2}$, minimum $1 \times 10^{-5}$</li>
<li>Warmup steps: 10,000</li>
<li>Dropout: 0.0</li>
<li>Maximum input length: 512 tokens</li>
<li>Pretraining steps: 350K</li>
<li>Batch size: 96 per GPU (6 data types per batch)</li>
<li>Prompt-based fine-tuning for all downstream tasks</li>
</ul>
<h3 id="models">Models</h3>
<table>
  <thead>
      <tr>
          <th>Model</th>
          <th>Parameters</th>
          <th>Vocabulary Size</th>
          <th>Architecture</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>BioT5</td>
          <td>252M</td>
          <td>35,073</td>
          <td>T5-v1.1-base</td>
      </tr>
  </tbody>
</table>
<h3 id="evaluation">Evaluation</h3>
<ul>
<li>Molecule property prediction: AUROC on 6 MoleculeNet tasks (scaffold split, 3 runs)</li>
<li>Protein property prediction: accuracy on PEER benchmark (3 runs)</li>
<li>Drug-target interaction: AUROC, AUPRC, accuracy on 3 DTI datasets (5 runs)</li>
<li>Protein-protein interaction: accuracy on 2 PPI datasets (3 runs)</li>
<li>Molecule captioning: BLEU, ROUGE, METEOR, Text2Mol on ChEBI-20</li>
<li>Text-based molecule generation: BLEU, exact match, fingerprint similarities, FCD, validity on ChEBI-20</li>
</ul>
<h3 id="hardware">Hardware</h3>
<ul>
<li>8x NVIDIA A100 80GB GPUs for pretraining</li>
<li>Codebase: nanoT5</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/QizhiPei/BioT5">BioT5 Code</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>: Pei, Q., Zhang, W., Zhu, J., Wu, K., Gao, K., Wu, L., Xia, Y., &amp; Yan, R. (2023). BioT5: Enriching Cross-modal Integration in Biology with Chemical Knowledge and Natural Language Associations. <em>Proceedings of the 2023 Conference on Empirical Methods in Natural Language Processing</em>, 1102-1123. <a href="https://doi.org/10.18653/v1/2023.emnlp-main.70">https://doi.org/10.18653/v1/2023.emnlp-main.70</a></p>
<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>{pei2023biot5,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">title</span>=<span style="color:#e6db74">{BioT5: Enriching Cross-modal Integration in Biology with Chemical Knowledge and Natural Language Associations}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">author</span>=<span style="color:#e6db74">{Pei, Qizhi and Zhang, Wei and Zhu, Jinhua and Wu, Kehan and Gao, Kaiyuan and Wu, Lijun and Xia, Yingce and Yan, Rui}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">booktitle</span>=<span style="color:#e6db74">{Proceedings of the 2023 Conference on Empirical Methods in Natural Language Processing}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">pages</span>=<span style="color:#e6db74">{1102--1123}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">year</span>=<span style="color:#e6db74">{2023}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">publisher</span>=<span style="color:#e6db74">{Association for Computational Linguistics}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">doi</span>=<span style="color:#e6db74">{10.18653/v1/2023.emnlp-main.70}</span>
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div>]]></content:encoded></item><item><title>Mol2vec: Unsupervised ML with Chemical Intuition</title><link>https://hunterheidenreich.com/notes/chemistry/molecular-representations/encoders/mol2vec-unsupervised-chemical-intuition/</link><pubDate>Fri, 27 Mar 2026 00:00:00 +0000</pubDate><guid>https://hunterheidenreich.com/notes/chemistry/molecular-representations/encoders/mol2vec-unsupervised-chemical-intuition/</guid><description>Mol2vec applies Word2vec to Morgan substructures, learning dense vector representations of molecules that capture chemical similarity for property prediction.</description><content:encoded><![CDATA[<h2 id="word2vec-meets-cheminformatics">Word2vec Meets Cheminformatics</h2>
<p>Mol2vec is a <strong>Method</strong> paper that introduces an unsupervised approach for learning dense vector representations of molecular substructures. The core idea is a direct analogy to <a href="/notes/machine-learning/model-architectures/distributed-representations/">Word2vec</a> from natural language processing: molecular substructures (derived from the Morgan algorithm) are treated as &ldquo;words,&rdquo; and entire molecules are treated as &ldquo;sentences.&rdquo; By training on a large unlabeled corpus of 19.9 million compounds, Mol2vec produces embeddings where chemically related substructures occupy nearby regions of vector space. Compound-level vectors are then obtained by summing constituent substructure vectors, and these can serve as features for downstream supervised learning tasks.</p>
<h2 id="sparse-fingerprints-and-their-limitations">Sparse Fingerprints and Their Limitations</h2>
<p>Molecular fingerprints, particularly Morgan fingerprints (extended-connectivity fingerprints, ECFP), are among the most widely used molecular representations in cheminformatics. They perform well for similarity searching, virtual screening, and activity prediction. However, they suffer from several practical drawbacks:</p>
<ul>
<li><strong>High dimensionality and sparsity</strong>: Morgan fingerprints are typically hashed to fixed-length binary vectors (e.g., 2048 or 4096 bits), resulting in very sparse representations.</li>
<li><strong>Bit collisions</strong>: The hashing step can map distinct substructures to the same bit position, losing structural information.</li>
<li><strong>No learned relationships</strong>: Each bit is independent, so the representation does not encode any notion of chemical similarity between substructures.</li>
</ul>
<p>At the time of this work (2017), NLP techniques had started to appear in cheminformatics. The <a href="https://en.wikipedia.org/wiki/Tf%E2%80%93idf">tf-idf</a> method had been applied to Morgan fingerprints for compound-protein interaction prediction, and <a href="https://en.wikipedia.org/wiki/Latent_Dirichlet_allocation">Latent Dirichlet Allocation</a> had been used for chemical topic modeling. The Word2vec concept had been adapted for protein sequences (ProtVec) but had not yet been applied to small molecules. Mol2vec fills this gap.</p>
<h2 id="from-substructure-identifiers-to-dense-embeddings">From Substructure Identifiers to Dense Embeddings</h2>
<p>The central insight of Mol2vec is that the Morgan algorithm already produces a natural &ldquo;vocabulary&rdquo; of molecular substructures, and the order in which these substructures appear in a molecule provides local context, analogous to word order in a sentence.</p>
<h3 id="corpus-construction">Corpus Construction</h3>
<p>The training corpus was assembled from <a href="https://en.wikipedia.org/wiki/ZINC_database">ZINC</a> v15 and <a href="https://en.wikipedia.org/wiki/ChEMBL">ChEMBL</a> v23, merged and deduplicated, then filtered by molecular weight (12-600), heavy atom count (3-50), clogP (-5 to 7), and allowed elements (H, B, C, N, O, F, P, S, Cl, Br). This yielded 19.9 million compounds.</p>
<h3 id="sentence-generation">Sentence Generation</h3>
<p>For each molecule, the Morgan algorithm generates atom identifiers at radius 0 and radius 1. Each atom contributes two identifiers (one per radius), ordered according to the atom order in the canonical <a href="/notes/chemistry/molecular-representations/notations/smiles/">SMILES</a>. This sequence of identifiers forms a &ldquo;sentence&rdquo; for Word2vec training.</p>
<h3 id="word2vec-training">Word2vec Training</h3>
<p>The model was trained using the gensim implementation of Word2vec. After evaluating both CBOW and Skip-gram architectures with window sizes of 5, 10, and 20, and embedding dimensions of 100 and 300, the best configuration was:</p>
<ul>
<li><strong>Architecture</strong>: Skip-gram</li>
<li><strong>Window size</strong>: 10</li>
<li><strong>Embedding dimension</strong>: 300</li>
</ul>
<p>Rare identifiers appearing fewer than 3 times in the corpus were replaced with a special &ldquo;UNSEEN&rdquo; token, which learns a near-zero vector. This allows the model to handle novel substructures at inference time.</p>
<h3 id="compound-vector-generation">Compound Vector Generation</h3>
<p>The final vector for a molecule is the sum of all its substructure vectors:</p>
<p>$$\mathbf{v}_{\text{mol}} = \sum_{i=1}^{N} \mathbf{v}_{s_i}$$</p>
<p>where $\mathbf{v}_{s_i}$ is the 300-dimensional embedding for the $i$-th substructure identifier in the molecule. This summation implicitly captures substructure counts and importance through vector amplitude.</p>
<h2 id="benchmarking-across-regression-and-classification-tasks">Benchmarking Across Regression and Classification Tasks</h2>
<h3 id="datasets">Datasets</h3>
<p>The authors evaluated Mol2vec on four datasets:</p>
<table>
  <thead>
      <tr>
          <th>Dataset</th>
          <th>Task</th>
          <th>Size</th>
          <th>Description</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>ESOL</td>
          <td>Regression</td>
          <td>1,144</td>
          <td>Aqueous solubility prediction</td>
      </tr>
      <tr>
          <td>Ames</td>
          <td>Classification</td>
          <td>6,511</td>
          <td><a href="https://en.wikipedia.org/wiki/Mutagen">Mutagenicity</a> (balanced: 3,481 positive, 2,990 negative)</td>
      </tr>
      <tr>
          <td>Tox21</td>
          <td>Classification</td>
          <td>8,192</td>
          <td>12 human toxicity targets (imbalanced)</td>
      </tr>
      <tr>
          <td>Kinase</td>
          <td>Classification</td>
          <td>284 kinases</td>
          <td>Bioactivity from ChEMBL v23</td>
      </tr>
  </tbody>
</table>
<h3 id="machine-learning-methods">Machine Learning Methods</h3>
<p>Three ML methods were compared using both Mol2vec and Morgan FP features:</p>
<ul>
<li><strong>Random Forest (RF)</strong>: scikit-learn, 500 estimators</li>
<li><strong>Gradient Boosting Machine (GBM)</strong>: XGBoost, 2000 estimators, max depth 3, learning rate 0.1</li>
<li><strong>Deep Neural Network (DNN)</strong>: Keras/TensorFlow, 4 hidden layers with 2000 neurons each for Mol2vec; 1 hidden layer with 512 neurons for Morgan FP</li>
</ul>
<p>All models were validated using 20x 5-fold cross-validation with the <a href="https://en.wikipedia.org/wiki/Wilcoxon_signed-rank_test">Wilcoxon signed-rank test</a> for statistical comparison.</p>
<h3 id="esol-regression-results">ESOL Regression Results</h3>
<table>
  <thead>
      <tr>
          <th>Features</th>
          <th>Method</th>
          <th>$R^2_{\text{ext}}$</th>
          <th>MSE</th>
          <th>MAE</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>Descriptors</td>
          <td>MLR</td>
          <td>0.81 +/- 0.01</td>
          <td>0.82</td>
          <td>0.69</td>
      </tr>
      <tr>
          <td>Molecular Graph</td>
          <td>CNN</td>
          <td>0.93</td>
          <td>0.31 +/- 0.03</td>
          <td>0.40 +/- 0.00</td>
      </tr>
      <tr>
          <td>Morgan FP</td>
          <td>GBM</td>
          <td>0.66 +/- 0.00</td>
          <td>1.43 +/- 0.00</td>
          <td>0.88 +/- 0.00</td>
      </tr>
      <tr>
          <td>Mol2vec</td>
          <td>GBM</td>
          <td>0.86 +/- 0.00</td>
          <td>0.62 +/- 0.00</td>
          <td>0.60 +/- 0.00</td>
      </tr>
  </tbody>
</table>
<p>Mol2vec substantially outperformed Morgan FP ($R^2_{\text{ext}}$ 0.86 vs. 0.66) but did not match the best graph convolution methods ($R^2_{\text{ext}}$ ~0.93).</p>
<h3 id="classification-results-ames-and-tox21">Classification Results (Ames and Tox21)</h3>
<p>On the Ames dataset, Mol2vec and Morgan FP performed comparably (AUC 0.87 vs. 0.88), both matching or exceeding prior SVM and Naive Bayes results. On Tox21, both achieved an average AUC of 0.83, outperforming literature results from graph convolution (0.71) and DNN/SVM approaches (0.71-0.72).</p>
<h3 id="proteochemometric-pcm-extension">Proteochemometric (PCM) Extension</h3>
<p>Mol2vec was combined with ProtVec (protein sequence embeddings using the same Word2vec approach on 3-grams) by concatenating vectors, forming PCM2vec. This was evaluated using a rigorous 4-level cross-validation scheme:</p>
<ul>
<li><strong>CV1</strong>: New compound-target pairs</li>
<li><strong>CV2</strong>: New targets</li>
<li><strong>CV3</strong>: New compounds</li>
<li><strong>CV4</strong>: New compounds and targets</li>
</ul>
<p>On Tox21, PCM2vec improved predictions for new compound-target pairs (CV1: AUC 0.87 vs. 0.79 for Morgan FP) and new compounds (CV3: AUC 0.85 vs. 0.78). On the kinase dataset, PCM2vec approached the performance of classical PCM (Morgan + z-scales) while being alignment-independent, meaning it can be applied to proteins with low sequence similarity.</p>
<h2 id="chemical-intuition-and-practical-value">Chemical Intuition and Practical Value</h2>
<h3 id="embedding-quality">Embedding Quality</h3>
<p>The learned substructure embeddings capture meaningful chemical relationships. Hierarchical clustering of the 25 most common substructures shows expected groupings: aromatic carbons cluster together, aliphatic ring carbons form a separate group, and carbonyl carbons and oxygens are closely related. Similarly, t-SNE projections of amino acid vectors encoded by Mol2vec reproduce known amino acid relationships (e.g., similar distances between Glu/Gln and Asp/Asn pairs, reflecting the carboxylic acid to amide transition).</p>
<h3 id="key-findings">Key Findings</h3>
<ol>
<li><strong>Skip-gram with 300-dimensional embeddings</strong> provides the best Mol2vec representations, consistent with NLP best practices.</li>
<li><strong>Mol2vec excels at regression tasks</strong>, substantially outperforming Morgan FP on ESOL solubility prediction ($R^2_{\text{ext}}$ 0.86 vs. 0.66).</li>
<li><strong>Classification performance is competitive</strong> with Morgan FP across Ames and Tox21 datasets.</li>
<li><strong>PCM2vec enables alignment-independent proteochemometrics</strong>, extending PCM approaches to diverse protein families with low sequence similarity.</li>
<li><strong>Tree-based methods (RF, GBM) outperformed DNNs</strong> on these tasks, though the authors note further DNN tuning could help.</li>
</ol>
<h3 id="limitations">Limitations</h3>
<ul>
<li>The compound vector is a simple sum of substructure vectors, which discards information about substructure arrangement and molecular topology.</li>
<li>Only Morgan identifiers at radii 0 and 1 were used. Larger radii might capture more context but would increase vocabulary size.</li>
<li>DNN architectures were not extensively optimized, leaving open the question of how well Mol2vec pairs with deep learning.</li>
<li>The approach was benchmarked against Morgan FP but not against other learned representations such as graph neural networks in a controlled comparison.</li>
</ul>
<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>Pre-training</td>
          <td>ZINC v15 + ChEMBL v23</td>
          <td>19.9M compounds</td>
          <td>Filtered by MW, atom count, clogP, element types</td>
      </tr>
      <tr>
          <td>Evaluation</td>
          <td>ESOL</td>
          <td>1,144 compounds</td>
          <td>Aqueous solubility regression</td>
      </tr>
      <tr>
          <td>Evaluation</td>
          <td>Ames</td>
          <td>6,511 compounds</td>
          <td>Mutagenicity classification</td>
      </tr>
      <tr>
          <td>Evaluation</td>
          <td>Tox21</td>
          <td>8,192 compounds</td>
          <td>12 toxicity targets, retrieved via DeepChem</td>
      </tr>
      <tr>
          <td>Evaluation</td>
          <td>Kinase (ChEMBL v23)</td>
          <td>284 kinases</td>
          <td>IC50/Kd/Ki binding assays</td>
      </tr>
      <tr>
          <td>Protein corpus</td>
          <td><a href="https://en.wikipedia.org/wiki/UniProt">UniProt</a></td>
          <td>554,241 sequences</td>
          <td>For ProtVec training</td>
      </tr>
  </tbody>
</table>
<h3 id="algorithms">Algorithms</h3>
<ul>
<li><strong>Word2vec</strong>: Skip-gram, window size 10, 300-dimensional embeddings, min count 3</li>
<li><strong>Morgan algorithm</strong>: Radii 0 and 1 (119 and 19,831 unique identifiers respectively)</li>
<li><strong>UNSEEN token</strong>: Replaces identifiers occurring fewer than 3 times</li>
<li><strong>Compound vector</strong>: Sum of all substructure vectors</li>
</ul>
<h3 id="models">Models</h3>
<ul>
<li><strong>RF</strong>: scikit-learn, 500 estimators, sqrt features, balanced class weights</li>
<li><strong>GBM</strong>: XGBoost, 2000 estimators, max depth 3, learning rate 0.1</li>
<li><strong>DNN</strong>: Keras/TensorFlow, 4 layers x 2000 neurons (Mol2vec) or 1 layer x 512 neurons (Morgan FP), ReLU activation, dropout 0.1</li>
</ul>
<h3 id="evaluation">Evaluation</h3>
<table>
  <thead>
      <tr>
          <th>Metric</th>
          <th>Mol2vec Best</th>
          <th>Morgan FP Best</th>
          <th>Task</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>$R^2_{\text{ext}}$</td>
          <td>0.86 (GBM)</td>
          <td>0.66 (GBM)</td>
          <td>ESOL regression</td>
      </tr>
      <tr>
          <td>AUC</td>
          <td>0.87 (RF)</td>
          <td>0.88 (RF)</td>
          <td>Ames classification</td>
      </tr>
      <tr>
          <td>AUC</td>
          <td>0.83 (RF)</td>
          <td>0.83 (RF)</td>
          <td>Tox21 classification</td>
      </tr>
  </tbody>
</table>
<h3 id="hardware">Hardware</h3>
<p>Not specified in the paper.</p>
<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/samoturk/mol2vec">mol2vec</a></td>
          <td>Code</td>
          <td>BSD-3-Clause</td>
          <td>Python package with pre-trained model</td>
      </tr>
  </tbody>
</table>
<hr>
<h2 id="paper-information">Paper Information</h2>
<p><strong>Citation</strong>: Jaeger, S., Fulle, S., &amp; Turk, S. (2018). Mol2vec: Unsupervised Machine Learning Approach with Chemical Intuition. <em>Journal of Chemical Information and Modeling</em>, 58(1), 27-35. <a href="https://doi.org/10.1021/acs.jcim.7b00616">https://doi.org/10.1021/acs.jcim.7b00616</a></p>
<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">@article</span>{jaeger2018mol2vec,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">title</span>=<span style="color:#e6db74">{Mol2vec: Unsupervised Machine Learning Approach with Chemical Intuition}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">author</span>=<span style="color:#e6db74">{Jaeger, Sabrina and Fulle, Simone and Turk, Samo}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">journal</span>=<span style="color:#e6db74">{Journal of Chemical Information and Modeling}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">volume</span>=<span style="color:#e6db74">{58}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">number</span>=<span style="color:#e6db74">{1}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">pages</span>=<span style="color:#e6db74">{27--35}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">year</span>=<span style="color:#e6db74">{2018}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">publisher</span>=<span style="color:#e6db74">{American Chemical Society}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">doi</span>=<span style="color:#e6db74">{10.1021/acs.jcim.7b00616}</span>
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div>]]></content:encoded></item><item><title>MG-BERT: Graph BERT for Molecular Property Prediction</title><link>https://hunterheidenreich.com/notes/chemistry/molecular-representations/multimodal/mg-bert-molecular-graph-bert/</link><pubDate>Fri, 27 Mar 2026 00:00:00 +0000</pubDate><guid>https://hunterheidenreich.com/notes/chemistry/molecular-representations/multimodal/mg-bert-molecular-graph-bert/</guid><description>MG-BERT integrates graph neural network message passing into BERT with masked atom pretraining on 1.7M molecules for molecular property prediction.</description><content:encoded><![CDATA[<h2 id="a-graph-aware-bert-for-molecular-property-prediction">A Graph-Aware BERT for Molecular Property Prediction</h2>
<p>MG-BERT is a <strong>Method</strong> paper that adapts the BERT pretraining paradigm from NLP to molecular graphs. The primary contribution is a modified Transformer architecture that replaces global self-attention with bond-based local attention, allowing atoms to exchange information only through chemical bonds. This creates a deep message-passing network that avoids the oversmoothing problem of conventional graph neural networks (GNNs). Combined with a masked atom prediction pretraining strategy on 1.7 million unlabeled molecules from ChEMBL, MG-BERT learns context-sensitive atomic representations that transfer effectively to downstream property prediction tasks.</p>
<h2 id="data-scarcity-in-molecular-property-prediction">Data Scarcity in Molecular Property Prediction</h2>
<p><a href="/notes/chemistry/molecular-design/property-prediction/">Molecular property prediction</a> is central to drug discovery, particularly for ADMET (Absorption, Distribution, Metabolism, Excretion, and Toxicity) endpoints. While deep learning has advanced many domains, molecular property prediction faces a persistent challenge: labeled data scarcity. ADMET measurements require expensive, time-consuming experiments, and typical datasets contain only hundreds to thousands of examples.</p>
<p>Prior approaches fall into three categories, each with limitations:</p>
<ol>
<li><strong>Feature engineering</strong> (molecular fingerprints, descriptors): Requires expert design, suffers from low scalability, and fixed representations cannot be optimized for specific tasks.</li>
<li><strong>SMILES-based deep learning</strong> (CNNs, LSTMs, Transformers on SMILES strings): Must learn to parse molecular information from complex string syntax, increasing learning difficulty. Autoencoder-based methods (e.g., <a href="/notes/chemistry/molecular-representations/encoders/cddd-translation-molecular-descriptors/">CDDD</a>) learn fixed representations that cannot be fine-tuned.</li>
<li><strong>Graph neural networks</strong> (GAT, GCN): Can learn directly from molecular topology, but are limited to 2-3 layers due to oversmoothing, restricting their capacity to capture deep-level patterns.</li>
</ol>
<p>The BERT model from NLP demonstrated that self-supervised pretraining on large unlabeled corpora followed by fine-tuning on small labeled datasets can substantially improve downstream performance. <a href="/notes/chemistry/molecular-representations/encoders/smiles-bert/">SMILES-BERT</a> applied this idea to SMILES strings directly, but suffered from interpretability issues due to auxiliary characters in the SMILES syntax. MG-BERT addresses these limitations by operating directly on molecular graphs.</p>
<h2 id="bond-based-local-attention-and-masked-atom-pretraining">Bond-Based Local Attention and Masked Atom Pretraining</h2>
<p>The core innovation of MG-BERT has two components: a modified Transformer architecture for molecular graphs and a self-supervised pretraining strategy.</p>
<h3 id="architecture-modifications">Architecture Modifications</h3>
<p>The original BERT model uses three components: an embedding layer, Transformer encoder layers, and a task-specific output layer. MG-BERT makes three key modifications:</p>
<ol>
<li>
<p><strong>Atom embeddings replace word embeddings.</strong> The dictionary contains 16 tokens: 13 common atom types ([H], [C], [N], [O], [F], [S], [Cl], [P], [Br], [B], [I], [Si], [Se]), plus [UNK] for rare atoms, [MASK] for pretraining, and [GLOBAL] for graph-level readout.</p>
</li>
<li>
<p><strong>No positional encoding.</strong> Unlike sequential text, atoms in a molecular graph have no inherent ordering, so positional embeddings are removed.</p>
</li>
<li>
<p><strong>Local attention replaces global attention.</strong> The adjacency matrix of the molecular graph is used as a visibility matrix to modulate the attention scores. Each atom can only attend to atoms connected by chemical bonds. Formally, the attention is constrained so that:</p>
</li>
</ol>
<p>$$A&rsquo;_{ij} = \begin{cases} A_{ij} &amp; \text{if bond exists between } i \text{ and } j \\ -\infty &amp; \text{otherwise} \end{cases}$$</p>
<p>where $A_{ij}$ is the standard scaled dot-product attention score. This local message passing makes MG-BERT a variant of GNN, but one that can stack many layers (6 in the medium configuration) without oversmoothing, thanks to the residual connections inherited from the Transformer architecture.</p>
<ol start="4">
<li><strong>Supernode for graph-level readout.</strong> A [GLOBAL] supernode is added to each molecular graph, connected to all atoms. This node aggregates information from the entire molecule and serves as the molecular representation for downstream prediction.</li>
</ol>
<h3 id="masked-atom-prediction">Masked Atom Prediction</h3>
<p>The pretraining strategy mirrors BERT&rsquo;s masked language model but operates on atoms:</p>
<ul>
<li>15% of atoms in each molecule are randomly selected (at least one atom per molecule)</li>
<li>Of selected atoms: 80% are replaced with [MASK], 10% are randomly replaced with another atom type, and 10% remain unchanged</li>
<li>The model is trained to predict the original atom type at masked positions</li>
<li>Loss is computed only at masked positions</li>
</ul>
<h3 id="model-configurations">Model Configurations</h3>
<p>Three model sizes were compared:</p>
<table>
  <thead>
      <tr>
          <th>Configuration</th>
          <th>Layers</th>
          <th>Heads</th>
          <th>Embedding Size</th>
          <th>FFN Size</th>
          <th>Recovery Accuracy</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>MG-BERT Small</td>
          <td>3</td>
          <td>2</td>
          <td>128</td>
          <td>256</td>
          <td>95.27%</td>
      </tr>
      <tr>
          <td>MG-BERT Medium</td>
          <td>6</td>
          <td>4</td>
          <td>256</td>
          <td>512</td>
          <td>98.31%</td>
      </tr>
      <tr>
          <td>MG-BERT Large</td>
          <td>12</td>
          <td>8</td>
          <td>576</td>
          <td>1152</td>
          <td>98.35%</td>
      </tr>
  </tbody>
</table>
<p>The medium configuration was selected for all experiments because it achieved the best downstream performance, despite the large model having slightly higher pretraining recovery accuracy. The authors attribute this to overfitting risk with the larger model.</p>
<h2 id="experimental-setup-and-baselines">Experimental Setup and Baselines</h2>
<h3 id="pretraining">Pretraining</h3>
<p>MG-BERT was pretrained on 1.7 million compounds randomly selected from ChEMBL, with 10% held out for evaluation (1.53M training molecules). Molecules were converted to 2D undirected graphs using RDKit, with hydrogen atoms explicitly included. The model was pretrained for 10 epochs using Adam with learning rate 1e-4 and batch size 256.</p>
<h3 id="fine-tuning-datasets">Fine-tuning Datasets</h3>
<p>Sixteen datasets covering ADMET endpoints and common molecular properties were collected from ADMETlab and <a href="/notes/chemistry/molecular-design/property-prediction/moleculenet-benchmark-molecular-ml/">MoleculeNet</a>:</p>
<table>
  <thead>
      <tr>
          <th>Type</th>
          <th>Dataset</th>
          <th>Category</th>
          <th>Size</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>Regression</td>
          <td>Caco2</td>
          <td>Absorption</td>
          <td>979</td>
      </tr>
      <tr>
          <td>Regression</td>
          <td>logD</td>
          <td>Physicochemical</td>
          <td>10,354</td>
      </tr>
      <tr>
          <td>Regression</td>
          <td>logS</td>
          <td>Physicochemical</td>
          <td>5,045</td>
      </tr>
      <tr>
          <td>Regression</td>
          <td>PPB</td>
          <td>Distribution</td>
          <td>1,480</td>
      </tr>
      <tr>
          <td>Regression</td>
          <td>tox</td>
          <td>Toxicity</td>
          <td>7,295</td>
      </tr>
      <tr>
          <td>Regression</td>
          <td>ESOL</td>
          <td>Physicochemical</td>
          <td>1,128</td>
      </tr>
      <tr>
          <td>Regression</td>
          <td>FreeSolv</td>
          <td>Physicochemical</td>
          <td>642</td>
      </tr>
      <tr>
          <td>Regression</td>
          <td>Lipo</td>
          <td>Physicochemical</td>
          <td>4,200</td>
      </tr>
      <tr>
          <td>Classification</td>
          <td>Ames</td>
          <td>Toxicity</td>
          <td>6,719</td>
      </tr>
      <tr>
          <td>Classification</td>
          <td>BBB</td>
          <td>Distribution</td>
          <td>1,855</td>
      </tr>
      <tr>
          <td>Classification</td>
          <td>FDAMDD</td>
          <td>Toxicity</td>
          <td>795</td>
      </tr>
      <tr>
          <td>Classification</td>
          <td>H_HT</td>
          <td>Toxicity</td>
          <td>2,170</td>
      </tr>
      <tr>
          <td>Classification</td>
          <td>Pgp_inh</td>
          <td>Absorption</td>
          <td>2,125</td>
      </tr>
      <tr>
          <td>Classification</td>
          <td>Pgp_sub</td>
          <td>Absorption</td>
          <td>1,210</td>
      </tr>
      <tr>
          <td>Classification</td>
          <td>BACE</td>
          <td>Biophysics</td>
          <td>1,513</td>
      </tr>
      <tr>
          <td>Classification</td>
          <td>BBBP</td>
          <td>Physiology</td>
          <td>2,039</td>
      </tr>
  </tbody>
</table>
<p>Datasets were split 8:1:1 (train:validation:test) with stratified sampling by SMILES length. Each experiment was repeated 10 times with random splits, reporting mean and standard deviation. Regression was evaluated by R-squared, classification by ROC-AUC. Early stopping with a maximum of 100 epochs was used.</p>
<h3 id="baselines">Baselines</h3>
<p>Five baselines were compared:</p>
<ol>
<li><strong>ECFP4-XGBoost</strong>: Extended connectivity fingerprints (diameter 4) with gradient-boosted trees</li>
<li><strong>GAT</strong>: Graph Attention Network</li>
<li><strong>GCN</strong>: Graph Convolutional Network</li>
<li><strong>CDDD</strong>: Continuous and Data-Driven Descriptors (pretrained RNN encoder on SMILES with a fully connected network)</li>
<li><strong>SMILES-BERT</strong>: Original BERT applied directly to SMILES strings</li>
</ol>
<h3 id="ablation-studies">Ablation Studies</h3>
<p>Two ablation studies were conducted:</p>
<ol>
<li><strong>Pretraining effectiveness</strong>: Comparing pretrained vs. non-pretrained MG-BERT under identical hyperparameters</li>
<li><strong>Hydrogen atoms</strong>: Comparing MG-BERT with and without explicit hydrogen atoms in the molecular graph</li>
</ol>
<h2 id="consistent-improvements-across-admet-benchmarks">Consistent Improvements Across ADMET Benchmarks</h2>
<h3 id="main-results">Main Results</h3>
<p>MG-BERT consistently outperformed all baselines across all 16 datasets. Key results on the 11 ADMET datasets:</p>
<table>
  <thead>
      <tr>
          <th>Dataset</th>
          <th>ECFP4-XGBoost</th>
          <th>GAT</th>
          <th>GCN</th>
          <th>CDDD</th>
          <th>SMILES-BERT</th>
          <th>MG-BERT</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>Caco2 (R2)</td>
          <td>61.41</td>
          <td>69.16</td>
          <td>67.15</td>
          <td>73.42</td>
          <td>72.39</td>
          <td><strong>74.68</strong></td>
      </tr>
      <tr>
          <td>logD (R2)</td>
          <td>70.84</td>
          <td>84.62</td>
          <td>86.22</td>
          <td>85.85</td>
          <td>86.31</td>
          <td><strong>87.46</strong></td>
      </tr>
      <tr>
          <td>logS (R2)</td>
          <td>73.73</td>
          <td>84.06</td>
          <td>83.47</td>
          <td>84.01</td>
          <td>85.20</td>
          <td><strong>87.66</strong></td>
      </tr>
      <tr>
          <td>PPB (R2)</td>
          <td>55.11</td>
          <td>59.96</td>
          <td>57.34</td>
          <td>54.12</td>
          <td>62.37</td>
          <td><strong>65.94</strong></td>
      </tr>
      <tr>
          <td>Ames (AUC)</td>
          <td>87.21</td>
          <td>86.38</td>
          <td>87.04</td>
          <td>86.82</td>
          <td>87.69</td>
          <td><strong>89.33</strong></td>
      </tr>
      <tr>
          <td>BBB (AUC)</td>
          <td>94.62</td>
          <td>93.03</td>
          <td>92.67</td>
          <td>94.44</td>
          <td>94.02</td>
          <td><strong>95.41</strong></td>
      </tr>
      <tr>
          <td>BBBP (AUC)</td>
          <td>89.16</td>
          <td>90.33</td>
          <td>90.74</td>
          <td>91.12</td>
          <td>91.32</td>
          <td><strong>92.08</strong></td>
      </tr>
  </tbody>
</table>
<p>The overall improvement across all datasets was 28.1% (7.02% on classification, 21.28% on regression). Improvements were statistically significant at the 95% confidence level (paired t-test, P &lt;= 0.001).</p>
<h3 id="pretraining-ablation">Pretraining Ablation</h3>
<p>Pretraining improved performance by more than 2% on all datasets. The benefit was largest for small datasets: Caco2 improved by approximately 10 percentage points (64.79 to 74.68 R2), and FDAMDD improved by about 7.5 points (80.76 to 88.23 AUC). This confirms that self-supervised pretraining effectively addresses the labeled data scarcity problem.</p>
<h3 id="hydrogen-atom-ablation">Hydrogen Atom Ablation</h3>
<p>Including explicit hydrogen atoms improved pretraining recovery accuracy from 92.25% to 98.31% and consistently improved downstream performance. The authors provide an intuitive explanation: hydrogen atoms help determine bond counts for neighboring atoms, which is critical for the masked atom recovery task. They also show that removing hydrogens can make structurally distinct molecules (e.g., benzene and cyclohexane) indistinguishable at the graph level.</p>
<h3 id="interpretability-via-attention-visualization">Interpretability via Attention Visualization</h3>
<p>The authors provide two forms of interpretability analysis:</p>
<ol>
<li>
<p><strong>t-SNE visualization of atomic representations</strong>: Pretrained atomic representations cluster by atom type and, more specifically, by local chemical environment (e.g., aromatic carbons separate from aliphatic carbons, C-N bonds from C-O bonds). This demonstrates that pretraining captures neighborhood context beyond simple atom identity.</p>
</li>
<li>
<p><strong>Attention weight visualization</strong>: On the logD task, the supernode&rsquo;s attention focuses on polar groups (which govern lipophilicity). On the Ames mutagenicity task, attention concentrates on known mutagenic structural alerts (acylchloride, nitrosamide, azide groups). This provides chemically meaningful explanations for predictions.</p>
</li>
</ol>
<h3 id="limitations">Limitations</h3>
<p>The paper does not extensively discuss limitations, but several can be identified:</p>
<ul>
<li>The model uses only 2D molecular topology (atom types and bonds) without 3D conformational information or bond-type features</li>
<li>The atom dictionary is limited to 13 common types plus [UNK], which may lose information for molecules containing rarer elements</li>
<li>Evaluation is limited to ADMET-focused datasets; broader chemical spaces (e.g., materials, catalysts) are not tested</li>
<li>The comparison baselines do not include other graph-based pretraining methods (e.g., the contemporaneous Strategies for Pre-training Graph Neural Networks by Hu et al.)</li>
</ul>
<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>Pretraining</td>
          <td>ChEMBL (random subset)</td>
          <td>1.7M molecules (1.53M train)</td>
          <td>10% held out for evaluation</td>
      </tr>
      <tr>
          <td>Fine-tuning</td>
          <td>ADMETlab + MoleculeNet</td>
          <td>16 datasets (642-10,354 molecules)</td>
          <td>8:1:1 splits, stratified by SMILES length</td>
      </tr>
  </tbody>
</table>
<h3 id="algorithms">Algorithms</h3>
<ul>
<li><strong>Optimizer</strong>: Adam (pretraining: lr=1e-4, batch=256; fine-tuning: lr from {1e-5, 5e-5, 1e-4}, batch from {16, 32, 64})</li>
<li><strong>Pretraining epochs</strong>: 10</li>
<li><strong>Fine-tuning</strong>: Up to 100 epochs with early stopping</li>
<li><strong>Dropout</strong>: Optimized per task in range [0.0, 0.5]</li>
<li><strong>Masking</strong>: 15% of atoms (80% [MASK], 10% random, 10% unchanged)</li>
</ul>
<h3 id="models">Models</h3>
<ul>
<li><strong>Architecture</strong>: MG-BERT Medium (6 layers, 4 heads, embedding size 256, FFN size 512)</li>
<li><strong>Molecule processing</strong>: RDKit for graph conversion with explicit hydrogens</li>
</ul>
<h3 id="evaluation">Evaluation</h3>
<table>
  <thead>
      <tr>
          <th>Metric</th>
          <th>Task Type</th>
          <th>Notes</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>R-squared (R2)</td>
          <td>Regression</td>
          <td>Higher is better</td>
      </tr>
      <tr>
          <td>ROC-AUC</td>
          <td>Classification</td>
          <td>Higher is better</td>
      </tr>
      <tr>
          <td>Accuracy, RMSE</td>
          <td>Both</td>
          <td>Reported in supplementary Table S1</td>
      </tr>
  </tbody>
</table>
<p>All results averaged over 10 random splits with standard deviations reported.</p>
<h3 id="hardware">Hardware</h3>
<p>The paper does not specify hardware requirements (GPU type, training time, or memory usage).</p>
<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/zhang-xuan1314/Molecular-graph-BERT">Molecular-graph-BERT</a></td>
          <td>Code</td>
          <td>Not specified</td>
          <td>Jupyter Notebook implementation; last code push August 2021</td>
      </tr>
  </tbody>
</table>
<hr>
<h2 id="paper-information">Paper Information</h2>
<p><strong>Citation</strong>: Zhang, X.-C., Wu, C.-K., Yang, Z.-J., Wu, Z.-X., Yi, J.-C., Hsieh, C.-Y., Hou, T.-J., &amp; Cao, D.-S. (2021). MG-BERT: leveraging unsupervised atomic representation learning for molecular property prediction. <em>Briefings in Bioinformatics</em>, 22(6), bbab152. <a href="https://doi.org/10.1093/bib/bbab152">https://doi.org/10.1093/bib/bbab152</a></p>
<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">@article</span>{zhang2021mgbert,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">title</span>=<span style="color:#e6db74">{{MG-BERT}: leveraging unsupervised atomic representation learning for molecular property prediction}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">author</span>=<span style="color:#e6db74">{Zhang, Xiao-Chen and Wu, Cheng-Kun and Yang, Zhi-Jiang and Wu, Zhen-Xing and Yi, Jia-Cai and Hsieh, Chang-Yu and Hou, Ting-Jun and Cao, Dong-Sheng}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">journal</span>=<span style="color:#e6db74">{Briefings in Bioinformatics}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">volume</span>=<span style="color:#e6db74">{22}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">number</span>=<span style="color:#e6db74">{6}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">pages</span>=<span style="color:#e6db74">{bbab152}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">year</span>=<span style="color:#e6db74">{2021}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">publisher</span>=<span style="color:#e6db74">{Oxford University Press}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">doi</span>=<span style="color:#e6db74">{10.1093/bib/bbab152}</span>
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div>]]></content:encoded></item><item><title>DMP: Dual-View Molecule Pre-training (SMILES+GNN)</title><link>https://hunterheidenreich.com/notes/chemistry/molecular-representations/multimodal/dual-view-molecule-pretraining/</link><pubDate>Fri, 27 Mar 2026 00:00:00 +0000</pubDate><guid>https://hunterheidenreich.com/notes/chemistry/molecular-representations/multimodal/dual-view-molecule-pretraining/</guid><description>DMP pre-trains molecular encoders using both SMILES Transformer and GNN branches with a BYOL-style dual-view consistency loss for property prediction.</description><content:encoded><![CDATA[<h2 id="a-dual-branch-pre-training-method-for-molecular-property-prediction">A Dual-Branch Pre-training Method for Molecular Property Prediction</h2>
<p>DMP (Dual-view Molecule Pre-training) is a <strong>Method</strong> paper that introduces a pre-training framework combining two complementary molecular encoders: a Transformer operating on <a href="/notes/chemistry/molecular-representations/notations/smiles/">SMILES</a> strings and a Graph Neural Network (GNN) operating on molecular graphs. The two branches are trained jointly with masked language modeling (MLM) objectives plus a BYOL-style dual-view consistency loss. After pre-training on 10M <a href="https://en.wikipedia.org/wiki/PubChem">PubChem</a> molecules, either branch (or both) can be fine-tuned for downstream tasks. The authors recommend the Transformer branch based on empirical results. DMP achieves the best reported performance on 7 of 9 <a href="/notes/chemistry/molecular-design/property-prediction/moleculenet-benchmark-molecular-ml/">MoleculeNet</a> classification tasks and 3 retrosynthesis benchmarks (at the time of the 2021 arXiv version).</p>
<h2 id="why-combine-smiles-and-graph-views-for-molecules">Why Combine SMILES and Graph Views for Molecules</h2>
<p>Prior molecule pre-training methods used either graph representations with GNNs or SMILES representations with Transformers, but not both. The authors observe that the two views are complementary: Transformers handle molecules with large atom distances (long chains) well, while GNNs handle molecules with many concatenated rings better. Neither model alone captures the full range of molecular structures effectively.</p>
<p>Existing GNN-based pre-training methods (Hu et al. 2020, MolCLR, GROVER) and SMILES-based methods (<a href="/notes/chemistry/molecular-representations/encoders/chemberta/">ChemBERTa</a>, <a href="/notes/chemistry/molecular-representations/encoders/smiles-bert/">SMILES-BERT</a>) each have blind spots dictated by their input representation. DMP addresses this by pre-training both views simultaneously and enforcing representation consistency between them, so each branch benefits from the structural knowledge of the other.</p>
<h2 id="dual-view-consistency-with-byol-style-training">Dual-View Consistency with BYOL-Style Training</h2>
<p>The core innovation is the dual-view consistency objective, inspired by Bootstrap Your Own Latent (BYOL). Given a molecule $M$ with SMILES representation $M_s$ and graph representation $M_g$, DMP obtains high-level features from each branch:</p>
<ul>
<li><strong>Transformer branch</strong>: A RoBERTa-base model encodes the SMILES sequence. The [CLS] token output serves as the molecule representation $f_s$.</li>
<li><strong>GNN branch</strong>: A DeeperGCN network encodes the molecular graph. Mean+max pooling over atom representations yields $f_g$.</li>
</ul>
<p>The dual-view consistency loss uses nonlinear projection heads $\psi_g, \psi_s$ and prediction heads $\rho_g, \rho_s$:</p>
<p>$$
p_g = \psi_g(f_g), \quad q_g = \rho_g(p_g); \quad p_s = \psi_s(f_s), \quad q_s = \rho_s(p_s)
$$</p>
<p>The consistency loss maximizes cross-view <a href="https://en.wikipedia.org/wiki/Cosine_similarity">cosine similarity</a> with stop-gradient (SG) on the target:</p>
<p>$$
\ell_{\text{dual}}(\tilde{M}_g, \tilde{M}_s) = -\cos(q_s, \text{SG}(p_g)) - \cos(q_g, \text{SG}(p_s))
$$</p>
<p>where $\cos(p, q) = \frac{p^\top q}{|p|_2 |q|_2}$ and $\tilde{M}_g, \tilde{M}_s$ are the masked versions of the inputs. The stop-gradient prevents representation collapse without requiring negative samples or a momentum encoder.</p>
<p>The full training objective combines three losses:</p>
<ol>
<li><strong>MLM on Transformer</strong>: Recover masked tokens in SMILES sequences</li>
<li><strong>MLM on GNN</strong>: Recover masked atoms in molecular graphs</li>
<li><strong>Dual-view consistency</strong>: The BYOL-style loss above</li>
</ol>
<p>Both MLM objectives and the consistency loss are necessary. Ablations show that removing MLM (using only dual-view loss) degrades performance, and using two branches of the same type (two Transformers or two GNNs) is less effective than the heterogeneous Transformer+GNN combination.</p>
<h2 id="experiments-on-moleculenet-and-retrosynthesis">Experiments on MoleculeNet and Retrosynthesis</h2>
<h3 id="pre-training-setup">Pre-training Setup</h3>
<p>DMP is pre-trained on 10M molecules from PubChem (matching prior work). The Transformer branch uses RoBERTa-base (12 layers, hidden dim 768, 87M parameters). The GNN branch uses DeeperGCN (12 layers, hidden dim 384, 7.4M parameters). Combined, DMP has 104.1M parameters. Training runs for 200K iterations on 8 V100 GPUs over 3.8 days with Adam optimizer (lr = 5e-4, weight decay 0.01).</p>
<h3 id="molecular-property-prediction-moleculenet">Molecular Property Prediction (MoleculeNet)</h3>
<p>DMP is evaluated on 6 binary classification tasks (BBBP, Tox21, ClinTox, HIV, BACE, SIDER) using official DeepChem splits, and on 3 additional tasks (BBBP, SIDER, ClinTox classification + ESOL, QM7, QM8 regression) using scaffold splits from GROVER.</p>
<p>Key results on DeepChem splits (ROC-AUC %):</p>
<table>
  <thead>
      <tr>
          <th>Dataset</th>
          <th>MolCLR</th>
          <th>TF (MLM)</th>
          <th>DMP_TF</th>
          <th>DMP_TF+GNN</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>BBBP</td>
          <td>73.6</td>
          <td>74.9</td>
          <td><strong>78.1</strong></td>
          <td>77.8</td>
      </tr>
      <tr>
          <td>Tox21</td>
          <td>79.8</td>
          <td>77.6</td>
          <td><strong>78.8</strong></td>
          <td>79.1</td>
      </tr>
      <tr>
          <td>ClinTox</td>
          <td>93.2</td>
          <td>92.9</td>
          <td><strong>95.0</strong></td>
          <td>95.6</td>
      </tr>
      <tr>
          <td>HIV</td>
          <td>80.6</td>
          <td>80.2</td>
          <td><strong>81.0</strong></td>
          <td>81.4</td>
      </tr>
      <tr>
          <td>BACE</td>
          <td>89.0</td>
          <td>88.0</td>
          <td><strong>89.3</strong></td>
          <td>89.4</td>
      </tr>
      <tr>
          <td>SIDER</td>
          <td>68.0</td>
          <td>68.4</td>
          <td><strong>69.2</strong></td>
          <td>69.8</td>
      </tr>
  </tbody>
</table>
<p>On scaffold splits (comparison with GROVER and MPG):</p>
<table>
  <thead>
      <tr>
          <th>Dataset</th>
          <th>GROVER</th>
          <th>MPG</th>
          <th>DMP_TF</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>BBBP (AUC)</td>
          <td>0.940</td>
          <td>0.922</td>
          <td><strong>0.945</strong></td>
      </tr>
      <tr>
          <td>SIDER (AUC)</td>
          <td>0.658</td>
          <td>0.661</td>
          <td><strong>0.695</strong></td>
      </tr>
      <tr>
          <td>ClinTox (AUC)</td>
          <td>0.944</td>
          <td>0.963</td>
          <td><strong>0.968</strong></td>
      </tr>
      <tr>
          <td>ESOL (RMSE)</td>
          <td>0.831</td>
          <td>0.741</td>
          <td><strong>0.700</strong></td>
      </tr>
      <tr>
          <td>QM7 (MAE)</td>
          <td>72.6</td>
          <td>-</td>
          <td><strong>69.6</strong></td>
      </tr>
      <tr>
          <td>QM8 (MAE)</td>
          <td>0.0125</td>
          <td>-</td>
          <td><strong>0.0124</strong></td>
      </tr>
  </tbody>
</table>
<h3 id="retrosynthesis">Retrosynthesis</h3>
<p>DMP is tested on USPTO-50K (reaction type known/unknown) and USPTO-full. Using a &ldquo;DMP fusion&rdquo; approach (fusing pre-trained representations into a Transformer encoder-decoder for <a href="/notes/chemistry/molecular-design/reaction-prediction/">retrosynthesis</a>), DMP improves top-1 accuracy by 2-3 points over the baseline Transformer across all settings:</p>
<table>
  <thead>
      <tr>
          <th>Setting</th>
          <th>Transformer</th>
          <th>ChemBERTa fusion</th>
          <th>DMP fusion</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>USPTO-50K (unknown)</td>
          <td>42.3</td>
          <td>43.9</td>
          <td><strong>46.1</strong></td>
      </tr>
      <tr>
          <td>USPTO-50K (known)</td>
          <td>54.2</td>
          <td>56.4</td>
          <td><strong>57.5</strong></td>
      </tr>
      <tr>
          <td>USPTO-full</td>
          <td>42.9</td>
          <td>-</td>
          <td><strong>45.0</strong></td>
      </tr>
  </tbody>
</table>
<p>For GNN-based retrosynthesis, replacing GLN&rsquo;s GNN modules with DMP&rsquo;s pre-trained GNN branch improves top-1 accuracy from 52.5% to 54.2% (unknown type) and from 64.2% to 66.5% (known type).</p>
<h3 id="representation-quality">Representation Quality</h3>
<p><a href="https://en.wikipedia.org/wiki/T-distributed_stochastic_neighbor_embedding">t-SNE</a> visualization of pre-trained representations shows that DMP produces better scaffold-based clustering than either GNN-only or Transformer-only pre-training. The <a href="https://en.wikipedia.org/wiki/Davies%E2%80%93Bouldin_index">Davies-Bouldin index</a> improves from 3.56 (GNN) and 3.59 (Transformer) to 2.19 (DMP), indicating much tighter within-scaffold clusters.</p>
<h2 id="key-findings-and-limitations">Key Findings and Limitations</h2>
<p><strong>Key findings:</strong></p>
<ul>
<li>Combining heterogeneous views (SMILES + graph) during pre-training is more effective than using two branches of the same type. TF(x2) and GNN(x2) variants show smaller gains.</li>
<li>Both MLM and dual-view consistency loss contribute. Removing MLM (dual-view only) hurts performance, especially on BBBP (71.1 vs 78.1 with both losses).</li>
<li>The Transformer branch alone is recommended for downstream tasks, as it achieves strong results without adding GNN parameters at inference time.</li>
<li>Scaling pre-training data from 10M to 100M compounds yields marginal additional improvement.</li>
</ul>
<p><strong>Limitations acknowledged by the authors:</strong></p>
<ol>
<li>Training cost is higher than single-branch methods (3.8 days vs 2.5 days for TF-only on 8 V100s), since both branches must be trained jointly.</li>
<li>A fixed branch selection strategy is used at inference time. The authors note that a meta-controller for dynamic branch selection per molecule would be preferable.</li>
<li>The GNN branch uses simple atom masking without bond deletion or subgraph removal, leaving room for stronger graph-level pre-training objectives.</li>
</ol>
<p><strong>Relation to co-training:</strong> The authors clarify that DMP differs from classical <a href="https://en.wikipedia.org/wiki/Co-training">co-training</a> (Blum and Mitchell 1998) in that it does not require conditional independence between views and produces a pre-trained model rather than additional labeled data.</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>Pre-training</td>
          <td>PubChem subset</td>
          <td>10M compounds</td>
          <td>Same subset as MolCLR and ChemBERTa</td>
      </tr>
      <tr>
          <td>Pre-training (large)</td>
          <td>PubChem subset</td>
          <td>100M compounds</td>
          <td>Additional scale experiment</td>
      </tr>
      <tr>
          <td>Evaluation (classification)</td>
          <td>MoleculeNet (BBBP, Tox21, ClinTox, HIV, BACE, SIDER)</td>
          <td>1.5K-41K molecules</td>
          <td>Official DeepChem splits</td>
      </tr>
      <tr>
          <td>Evaluation (regression)</td>
          <td>MoleculeNet (ESOL, QM7, QM8)</td>
          <td>Varies</td>
          <td>Scaffold splits from GROVER</td>
      </tr>
      <tr>
          <td>Evaluation (retrosynthesis)</td>
          <td>USPTO-50K, USPTO-full</td>
          <td>50K / 950K reactions</td>
          <td>Splits from Dai et al. (2019)</td>
      </tr>
  </tbody>
</table>
<h3 id="algorithms">Algorithms</h3>
<ul>
<li><strong>Transformer branch</strong>: RoBERTa-base with MLM. SMILES tokenized using regex from Schwaller et al. (2019).</li>
<li><strong>GNN branch</strong>: DeeperGCN with 12 layers, atom masking for MLM.</li>
<li><strong>Dual-view loss</strong>: BYOL-style with 3-layer MLP projection heads and 2-layer MLP prediction heads, stop-gradient on targets.</li>
<li><strong>Optimizer</strong>: Adam (lr=5e-4, beta1=0.9, beta2=0.98, epsilon=1e-6), weight decay 0.01, 10K warmup steps, linear decay.</li>
</ul>
<h3 id="models">Models</h3>
<table>
  <thead>
      <tr>
          <th>Component</th>
          <th>Architecture</th>
          <th>Parameters</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>Transformer branch</td>
          <td>RoBERTa-base (12L, 768H, 12 heads)</td>
          <td>87M</td>
      </tr>
      <tr>
          <td>GNN branch</td>
          <td>DeeperGCN (12L, 384H)</td>
          <td>7.4M</td>
      </tr>
      <tr>
          <td>DMP (total)</td>
          <td>Transformer + GNN + projection/prediction heads</td>
          <td>104.1M</td>
      </tr>
  </tbody>
</table>
<h3 id="evaluation">Evaluation</h3>
<ul>
<li>Classification: ROC-AUC, averaged over 3 random seeds</li>
<li>Regression: RMSE (ESOL) or MAE (QM7, QM8)</li>
<li>Retrosynthesis: Top-k exact match accuracy (k=1,3,5,10,20,50)</li>
</ul>
<h3 id="hardware">Hardware</h3>
<ul>
<li>Pre-training: 8 NVIDIA V100 GPUs, batch size 12288 tokens, gradient accumulation 16x</li>
<li>Pre-training time: 3.8 days (DMP), 2.5 days (TF-only), 1.7 days (GNN-only)</li>
</ul>
<h3 id="artifacts">Artifacts</h3>
<p>No public code repository or pre-trained model weights were identified for this paper. The paper references GLN&rsquo;s code repository (<a href="https://github.com/Hanjun-Dai/GLN">https://github.com/Hanjun-Dai/GLN</a>) for the retrosynthesis baseline but does not release DMP-specific code.</p>
<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/Hanjun-Dai/GLN">GLN (baseline)</a></td>
          <td>Code</td>
          <td>MIT</td>
          <td>Retrosynthesis baseline, not DMP code</td>
      </tr>
  </tbody>
</table>
<hr>
<h2 id="paper-information">Paper Information</h2>
<p><strong>Citation</strong>: Zhu, J., Xia, Y., Wu, L., Xie, S., Zhou, W., Qin, T., Li, H., &amp; Liu, T.-Y. (2023). Dual-view Molecular Pre-training. In <em>Proceedings of the 29th ACM SIGKDD Conference on Knowledge Discovery and Data Mining</em> (pp. 3615-3627). <a href="https://doi.org/10.1145/3580305.3599317">https://doi.org/10.1145/3580305.3599317</a></p>
<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>{zhu2023dualview,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">title</span>=<span style="color:#e6db74">{Dual-view Molecular Pre-training}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">author</span>=<span style="color:#e6db74">{Zhu, Jinhua and Xia, Yingce and Wu, Lijun and Xie, Shufang and Zhou, Wengang and Qin, Tao and Li, Houqiang and Liu, Tie-Yan}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">booktitle</span>=<span style="color:#e6db74">{Proceedings of the 29th ACM SIGKDD Conference on Knowledge Discovery and Data Mining}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">pages</span>=<span style="color:#e6db74">{3615--3627}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">year</span>=<span style="color:#e6db74">{2023}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">doi</span>=<span style="color:#e6db74">{10.1145/3580305.3599317}</span>
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div>]]></content:encoded></item><item><title>X-MOL: Pre-training on 1.1B Molecules for SMILES</title><link>https://hunterheidenreich.com/notes/chemistry/molecular-representations/encoders/x-mol-pretraining-molecular-understanding/</link><pubDate>Thu, 26 Mar 2026 00:00:00 +0000</pubDate><guid>https://hunterheidenreich.com/notes/chemistry/molecular-representations/encoders/x-mol-pretraining-molecular-understanding/</guid><description>X-MOL pre-trains a shared encoder-decoder Transformer on 1.1 billion molecules, then fine-tunes for property prediction, reaction analysis, and generation.</description><content:encoded><![CDATA[<h2 id="a-unified-molecular-pre-training-framework">A Unified Molecular Pre-training Framework</h2>
<p>X-MOL is a <strong>Method</strong> paper that introduces a large-scale pre-training framework for <a href="/notes/chemistry/molecular-representations/notations/smiles/">SMILES</a>-based molecular understanding. The primary contribution is a Transformer encoder-decoder model pre-trained on 1.1 billion molecules from <a href="/notes/chemistry/datasets/zinc-22/">ZINC15</a>, which is then fine-tuned across five distinct molecular analysis tasks: molecular property prediction (classification and regression), chemical reaction productivity prediction, <a href="https://en.wikipedia.org/wiki/Drug_interaction">drug-drug interaction</a> (DDI) prediction, de novo molecule generation (distribution learning and goal-directed), and molecule optimization. The paper demonstrates that a single pre-trained model can serve as a universal foundation for diverse downstream chemistry tasks.</p>
<h2 id="bridging-scale-and-understanding-in-molecular-smiles">Bridging Scale and Understanding in Molecular SMILES</h2>
<p>Prior to X-MOL, most molecular analysis tasks were investigated individually with task-specific models. SMILES-based deep learning methods existed but lacked the benefit of large-scale pre-training that had proven transformative in NLP (BERT, RoBERTa, ERNIE, XLNet, <a href="/notes/natural-language-processing/language-models/t5-text-to-text-transfer-transformer/">T5</a>). Two challenges motivated this work:</p>
<ol>
<li><strong>SMILES sacrifices structural information for simplicity.</strong> While SMILES is a convenient linear representation, it does not directly encode molecular topology, making it harder for models to learn 3D structure from string input.</li>
<li><strong>Labelled molecular data is scarce.</strong> Most benchmark datasets (<a href="/notes/chemistry/molecular-design/property-prediction/moleculenet-benchmark-molecular-ml/">MoleculeNet</a>) contain only thousands of labelled examples, making it difficult to train large models from scratch without overfitting.</li>
</ol>
<p>The authors hypothesized that massive-scale pre-training on unlabelled SMILES could teach a model the grammar rules and implicit structural information in SMILES, providing a strong initialization for multiple downstream tasks.</p>
<h2 id="generative-pre-training-with-random-smiles">Generative Pre-training with Random SMILES</h2>
<p>The core innovation in X-MOL is a <strong>generative pre-training strategy</strong> that exploits the non-uniqueness of SMILES. A single molecule can be represented by many valid SMILES strings (<a href="/notes/chemistry/molecular-representations/notations/randomized-smiles-generative-models/">random SMILES</a>), depending on the starting atom, main chain selection, and ring-opening position. X-MOL trains the model to generate a valid alternative SMILES given an input SMILES of the same molecule, forcing the model to:</p>
<ol>
<li>Reconstruct the molecular structure from the input SMILES</li>
<li>Generate a valid output SMILES following SMILES grammar rules</li>
</ol>
<p>The architecture uses a shared-parameter encoder-decoder based on the Transformer. Unlike standard encoder-decoder models (e.g., for machine translation), X-MOL shares all parameters between encoder and decoder, forcing both encoding and decoding to occur in the same semantic space. The output SMILES is fully masked during training, and only unidirectional attention is permitted within the output sequence.</p>
<p>The self-attention mechanism computes attention for each character $i$ as:</p>
<p>$$
Z_{i} = \text{SoftMax}\left(\frac{Q_{i} \cdot K^{T}}{\sqrt{D}}\right) \cdot V
$$</p>
<p>where $Q_{i}$, $K$, and $V$ are the query, key, and value matrices, and $D$ is the feature dimension. The model uses 12 attention heads to capture different relational patterns.</p>
<h3 id="model-architecture">Model Architecture</h3>
<ul>
<li>12 Transformer encoder layers</li>
<li>768-dimensional hidden units</li>
<li>12 attention heads</li>
<li>Character-level SMILES tokenization (108 chemical characters plus 5 special tokens: [PAD], [CLS], [SEP], [MASK], [UNK])</li>
<li>Characters within square brackets and double digits preceded by &ldquo;%&rdquo; are treated as single tokens</li>
</ul>
<h3 id="data-augmentation-in-pre-training">Data Augmentation in Pre-training</h3>
<p>Because a molecule has multiple valid random SMILES, the output may differ from the predefined target. To handle this, X-MOL generates multiple training samples per molecule with the same input SMILES but different output random SMILES, and places these in the same mini-batch.</p>
<h2 id="experimental-setup-across-five-tasks">Experimental Setup Across Five Tasks</h2>
<p>X-MOL is fine-tuned with task-specific strategies organized into two categories: prediction tasks and generation tasks.</p>
<h3 id="prediction-tasks">Prediction Tasks</h3>
<p>For prediction tasks, the [CLS] token&rsquo;s output representation is passed through a fully connected network to produce predictions. The input format varies by task:</p>
<table>
  <thead>
      <tr>
          <th>Task</th>
          <th>Input Format</th>
          <th>Loss Function</th>
          <th>Metric</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>Property prediction (classification)</td>
          <td>Single SMILES</td>
          <td>Cross-entropy</td>
          <td>ROC-AUC</td>
      </tr>
      <tr>
          <td>Property prediction (regression)</td>
          <td>Single SMILES</td>
          <td>MSE</td>
          <td>RMSE</td>
      </tr>
      <tr>
          <td>Reaction productivity prediction</td>
          <td>Four SMILES (reactant, additive, base, ligand)</td>
          <td>MSE</td>
          <td>RMSE</td>
      </tr>
      <tr>
          <td>DDI prediction</td>
          <td>Two SMILES (drug pair)</td>
          <td>Cross-entropy</td>
          <td>Accuracy</td>
      </tr>
  </tbody>
</table>
<p><strong>Molecular Property Prediction (Classification):</strong> Four MoleculeNet benchmarks were used: HIV (41,127 compounds), BACE (1,513), <a href="https://en.wikipedia.org/wiki/Blood%E2%80%93brain_barrier">BBBP</a> (2,039), and ClinTox (1,484). Data were randomly split 20 times, and average ROC-AUC is reported.</p>
<p><strong>Molecular Property Prediction (Regression):</strong> Three MoleculeNet benchmarks: ESOL (1,128), FreeSolv (642), and Lipophilicity (4,200). Data augmentation with random SMILES was applied to the training set. Average RMSE over 20 random splits is reported.</p>
<p><strong>Chemical Reaction Productivity Prediction:</strong> The <a href="https://en.wikipedia.org/wiki/Cross-coupling_reaction">C-N cross-coupling</a> dataset (3,956 reactions) from Ahneman et al. was used with 10-fold cross-validation.</p>
<p><strong>DDI Prediction:</strong> The DeepDDI dataset (192,284 DDI pairs, 86 interaction types) was used as benchmark.</p>
<h3 id="generation-tasks">Generation Tasks</h3>
<table>
  <thead>
      <tr>
          <th>Task</th>
          <th>Generation Source</th>
          <th>Sampling Strategy</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>Distribution learning (DL) generation</td>
          <td>Fixed initial symbol ([CLS])</td>
          <td>Random sampling</td>
      </tr>
      <tr>
          <td>Goal-directed (GD) generation</td>
          <td>Unfixed initial symbol</td>
          <td>Random sampling</td>
      </tr>
      <tr>
          <td>Molecule optimization</td>
          <td>Input molecule</td>
          <td>Beam search (beam size = 4)</td>
      </tr>
  </tbody>
</table>
<p><strong>DL-based Generation:</strong> Evaluated on ZINC250K (249,456 molecules) using validity, uniqueness, and novelty.</p>
<p><strong>GD Generation:</strong> Also on ZINC250K, using QED as the goal property with target QED = 0.948 (the dataset maximum). 10,000 molecules were generated for evaluation.</p>
<p><strong>Molecule Optimization:</strong> Evaluated on ZINC250K with QED as the optimization goal. Molecular pairs were constructed by selecting pairs with <a href="https://en.wikipedia.org/wiki/Jaccard_index">Tanimoto similarity</a> in [0.6, 0.8], where the lower-QED molecule serves as input and the higher-QED molecule as target.</p>
<h3 id="key-results">Key Results</h3>
<p><strong>Classification (ROC-AUC, higher is better):</strong> X-MOL achieved state-of-the-art on all four datasets, outperforming both shallow learning methods and deep learning baselines including graph convolutional models.</p>
<p><strong>Regression (RMSE, lower is better):</strong> X-MOL achieved the best RMSE on ESOL, FreeSolv, and Lipophilicity.</p>
<p><strong>Reaction Productivity:</strong> X-MOL obtained an average RMSE of 0.0626, compared to the random forest baseline of 0.078.</p>
<p><strong>DDI Prediction:</strong> X-MOL achieved accuracy of 0.952, improving over DeepDDI&rsquo;s 0.924.</p>
<p><strong>DL-based Generation:</strong></p>
<table>
  <thead>
      <tr>
          <th>Method</th>
          <th>Validity</th>
          <th>Uniqueness</th>
          <th>Novelty</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>GCPN</td>
          <td>20%</td>
          <td>99.97%</td>
          <td>100%</td>
      </tr>
      <tr>
          <td>MRNN</td>
          <td>65%</td>
          <td>99.89%</td>
          <td>100%</td>
      </tr>
      <tr>
          <td>GraphAF</td>
          <td>68%</td>
          <td>99.10%</td>
          <td>100%</td>
      </tr>
      <tr>
          <td><strong>X-MOL</strong></td>
          <td><strong>85.28%</strong></td>
          <td><strong>99.91%</strong></td>
          <td><strong>100%</strong></td>
      </tr>
  </tbody>
</table>
<p><strong>GD Generation:</strong> X-MOL generated all top-3 molecules with QED = 0.948, matching the dataset maximum. GraphAF reached 0.948/0.948/0.947, while JT-VAE and MRNN fell further behind.</p>
<h3 id="knowledge-embedding-ablation">Knowledge Embedding Ablation</h3>
<p>The paper tested three additional embedding strategies to inject structural information into the model:</p>
<ul>
<li><strong>Link embedding:</strong> Encodes connection information between atoms (position of the previous connected atom)</li>
<li><strong>Ring embedding:</strong> Encodes ring structure information from SMILES number pairs</li>
<li><strong>Type embedding:</strong> Categorizes characters into 9 types (atoms, bonds, structural symbols)</li>
</ul>
<p>None of these additional embeddings improved performance on the HIV or DDI tasks, whether with or without pre-training. The authors conclude that SMILES already contains sufficient information for molecular understanding and that pre-training effectively extracts this information, a finding they label &ldquo;SMILES is all you need.&rdquo;</p>
<h3 id="attention-visualization">Attention Visualization</h3>
<p>The authors provide attention heatmap analysis demonstrating that:</p>
<ul>
<li>Middle layers (e.g., layer 9) reconstruct molecular structure by correctly identifying atom connectivity and ring closures</li>
<li>Later layers abstract higher-level features for property prediction</li>
<li>In multi-input prediction tasks (reaction productivity), attention reveals which reaction components are most important (e.g., the ligand receives highest cross-attention)</li>
<li>In generation tasks, attention patterns differ between DL (self-focused), GD (source-constrained), and optimization (gradual shift from input to output)</li>
</ul>
<h2 id="findings-limitations-and-future-directions">Findings, Limitations, and Future Directions</h2>
<p>X-MOL demonstrates that large-scale pre-training on SMILES can produce a single model that achieves competitive or state-of-the-art performance across five distinct molecular analysis tasks. The key findings are:</p>
<ol>
<li><strong>Scale enables SMILES understanding.</strong> Pre-training on 1.1 billion molecules allows the model to learn SMILES grammar rules well enough to outperform graph-based methods on molecule generation validity.</li>
<li><strong>Unified framework.</strong> A single pre-trained backbone serves classification, regression, reaction prediction, DDI prediction, and generative tasks through different fine-tuning strategies.</li>
<li><strong>SMILES is sufficient.</strong> Additional knowledge embeddings (link, ring, type) do not improve performance, suggesting pre-training extracts the necessary structural information from SMILES alone.</li>
<li><strong>Interpretable attention.</strong> Attention visualization confirms that the model reconstructs molecular structure internally.</li>
</ol>
<p><strong>Limitations</strong> (observed):</p>
<ul>
<li>The paper reports only MoleculeNet benchmarks with relatively few datasets. No scaffold splits or temporal splits are used; all splits are random, which can overestimate performance on structurally novel compounds.</li>
<li>Comparison baselines are somewhat dated (2018-2019 era methods), and the paper does not compare against concurrent SMILES pre-training methods.</li>
<li>The molecule generation validity (85.28%) is much higher than graph baselines like GCPN (20%), but later work achieved near 100% validity with constrained SMILES grammars.</li>
<li>No code or model weights have been publicly released, limiting independent verification.</li>
<li>The paper remains a bioRxiv preprint and has not been published in a peer-reviewed venue.</li>
</ul>
<p><strong>Future directions</strong> proposed by the authors include: better pre-training strategies, extension to graph-based representations, and fine-tuning on additional downstream tasks.</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>Pre-training</td>
          <td>ZINC15</td>
          <td>1.1 billion molecules</td>
          <td>Random SMILES augmentation</td>
      </tr>
      <tr>
          <td>Classification</td>
          <td>HIV (MoleculeNet)</td>
          <td>41,127</td>
          <td>Binary classification</td>
      </tr>
      <tr>
          <td>Classification</td>
          <td>BACE (MoleculeNet)</td>
          <td>1,513</td>
          <td>Binary classification</td>
      </tr>
      <tr>
          <td>Classification</td>
          <td>BBBP (MoleculeNet)</td>
          <td>2,039</td>
          <td>Binary classification</td>
      </tr>
      <tr>
          <td>Classification</td>
          <td>ClinTox (MoleculeNet)</td>
          <td>1,484</td>
          <td>Two sub-datasets, averaged</td>
      </tr>
      <tr>
          <td>Regression</td>
          <td>ESOL (MoleculeNet)</td>
          <td>1,128</td>
          <td>Water solubility</td>
      </tr>
      <tr>
          <td>Regression</td>
          <td>FreeSolv (MoleculeNet)</td>
          <td>642</td>
          <td>Hydration free energy</td>
      </tr>
      <tr>
          <td>Regression</td>
          <td>Lipophilicity (MoleculeNet)</td>
          <td>4,200</td>
          <td>logD at pH 7.4</td>
      </tr>
      <tr>
          <td>Reaction</td>
          <td>C-N cross-coupling</td>
          <td>3,956</td>
          <td>From Ahneman et al. (2018)</td>
      </tr>
      <tr>
          <td>DDI</td>
          <td>DeepDDI</td>
          <td>192,284 DDI pairs</td>
          <td>86 interaction types</td>
      </tr>
      <tr>
          <td>Generation</td>
          <td>ZINC250K</td>
          <td>249,456</td>
          <td>For DL, GD, and optimization</td>
      </tr>
  </tbody>
</table>
<h3 id="algorithms">Algorithms</h3>
<ul>
<li>Pre-training: Generative SMILES-to-SMILES with shared encoder-decoder Transformer</li>
<li>Fine-tuning prediction tasks: [CLS] token passed through fully connected layers</li>
<li>Fine-tuning generation tasks: Autoregressive generation with random sampling (DL, GD) or beam search (optimization)</li>
<li>Data augmentation: Random SMILES augmentation for regression tasks</li>
<li>Repeated training: 20 random splits with averaged results for classification/regression</li>
<li>10-fold cross-validation for reaction productivity</li>
</ul>
<h3 id="models">Models</h3>
<ul>
<li>12-layer Transformer, 768 hidden dimensions, 12 attention heads</li>
<li>Character-level tokenization: 108 chemical characters + 5 special tokens</li>
<li>Implemented in PaddlePaddle framework</li>
</ul>
<h3 id="evaluation">Evaluation</h3>
<table>
  <thead>
      <tr>
          <th>Task</th>
          <th>Metric</th>
          <th>X-MOL</th>
          <th>Best Baseline</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>HIV (classification)</td>
          <td>ROC-AUC</td>
          <td>State-of-the-art</td>
          <td>Previous best (various)</td>
      </tr>
      <tr>
          <td>BACE (classification)</td>
          <td>ROC-AUC</td>
          <td>State-of-the-art</td>
          <td>Previous best (various)</td>
      </tr>
      <tr>
          <td>BBBP (classification)</td>
          <td>ROC-AUC</td>
          <td>State-of-the-art</td>
          <td>Previous best (various)</td>
      </tr>
      <tr>
          <td>ClinTox (classification)</td>
          <td>ROC-AUC</td>
          <td>State-of-the-art</td>
          <td>Previous best (various)</td>
      </tr>
      <tr>
          <td>ESOL (regression)</td>
          <td>RMSE</td>
          <td>State-of-the-art</td>
          <td>Previous best (various)</td>
      </tr>
      <tr>
          <td>FreeSolv (regression)</td>
          <td>RMSE</td>
          <td>State-of-the-art</td>
          <td>Previous best (various)</td>
      </tr>
      <tr>
          <td>Lipophilicity (regression)</td>
          <td>RMSE</td>
          <td>State-of-the-art</td>
          <td>Previous best (various)</td>
      </tr>
      <tr>
          <td>C-N coupling</td>
          <td>RMSE</td>
          <td>0.0626</td>
          <td>0.078 (random forest)</td>
      </tr>
      <tr>
          <td>DDI prediction</td>
          <td>Accuracy</td>
          <td>0.952</td>
          <td>0.924 (DeepDDI)</td>
      </tr>
      <tr>
          <td>DL generation</td>
          <td>Validity</td>
          <td>85.28%</td>
          <td>68% (GraphAF)</td>
      </tr>
      <tr>
          <td>GD generation</td>
          <td>Top-3 QED</td>
          <td>All 0.948</td>
          <td>0.948/0.948/0.947 (GraphAF)</td>
      </tr>
  </tbody>
</table>
<h3 id="hardware">Hardware</h3>
<ul>
<li>Pre-training: 8/16 Tesla P40 GPUs (24 GB each), approximately 4 days</li>
<li>Data pre-processing: Over 1,000 CPUs with Hadoop</li>
</ul>
<h3 id="artifacts">Artifacts</h3>
<p>No code, model weights, or pre-trained checkpoints have been publicly released. The model was implemented in Baidu&rsquo;s PaddlePaddle framework, but no repository is available.</p>
<p><strong>Reproducibility status: Closed.</strong> While the datasets are all publicly available (ZINC15, MoleculeNet, ZINC250K, DeepDDI, C-N coupling), the model implementation, pre-trained weights, and fine-tuning code are not released. The computational requirements (1,000+ CPUs for data processing, 8-16 GPUs for 4 days of pre-training) are substantial.</p>
<hr>
<h2 id="paper-information">Paper Information</h2>
<p><strong>Citation</strong>: Xue, D., Zhang, H., Xiao, D., Gong, Y., Chuai, G., Sun, Y., Tian, H., Wu, H., Li, Y., &amp; Liu, Q. (2020). X-MOL: Large-scale pre-training for molecular understanding and diverse molecular analysis. <em>bioRxiv</em>.</p>
<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">@article</span>{xue2020xmol,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">title</span>=<span style="color:#e6db74">{X-MOL: large-scale pre-training for molecular understanding and diverse molecular analysis}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">author</span>=<span style="color:#e6db74">{Xue, Dongyu and Zhang, Han and Xiao, Dongling and Gong, Yukang and Chuai, Guohui and Sun, Yu and Tian, Hao and Wu, Hua and Li, Yukun and Liu, Qi}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">journal</span>=<span style="color:#e6db74">{bioRxiv}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">year</span>=<span style="color:#e6db74">{2020}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">doi</span>=<span style="color:#e6db74">{10.1101/2020.12.23.424259}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">publisher</span>=<span style="color:#e6db74">{Cold Spring Harbor Laboratory}</span>
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div>]]></content:encoded></item><item><title>Transformer Name-to-SMILES with Atom Count Losses</title><link>https://hunterheidenreich.com/notes/chemistry/molecular-representations/name-translation/transformer-chemical-name-to-smiles/</link><pubDate>Thu, 26 Mar 2026 00:00:00 +0000</pubDate><guid>https://hunterheidenreich.com/notes/chemistry/molecular-representations/name-translation/transformer-chemical-name-to-smiles/</guid><description>A Transformer seq2seq model translates chemical compound names to SMILES, using atom-count constraints and SMILES/InChI multi-task learning.</description><content:encoded><![CDATA[<h2 id="translating-chemical-names-to-structures-with-transformers">Translating Chemical Names to Structures with Transformers</h2>
<p>This is a <strong>Method</strong> paper that proposes using Transformer-based sequence-to-sequence models to predict chemical compound structures (represented as SMILES strings) from chemical compound names. The primary contribution is the application of neural machine translation techniques to the name-to-structure problem, along with two domain-specific improvements: an atom-count constraint loss function and a multi-task learning approach that jointly predicts SMILES and InChI strings.</p>
<h2 id="why-rule-based-name-to-structure-fails-for-synonyms">Why Rule-Based Name-to-Structure Fails for Synonyms</h2>
<p>Chemical compound names come in several varieties. IUPAC names follow systematic nomenclature and are well-handled by rule-based parsers like OPSIN. Database IDs (e.g., CAS registry numbers) can be resolved by dictionary lookup. The third category, Synonyms (which includes abbreviations, common names, and other informal designations), is problematic because naming patterns are complex and widely variable.</p>
<p>In preliminary experiments, rule-based tools achieved F-measures of 0.878 to 0.960 on IUPAC names but only 0.719 to 0.758 on Synonyms. This performance gap motivates a data-driven approach. The authors frame name-to-SMILES prediction as a machine translation problem: the source language is the chemical compound name and the target language is the SMILES string. A neural model trained on millions of name-SMILES pairs can learn patterns that rule-based systems miss, particularly for non-systematic nomenclature.</p>
<h2 id="atom-count-constraints-and-multi-task-learning">Atom-Count Constraints and Multi-Task Learning</h2>
<p>The paper introduces two improvements over a vanilla Transformer seq2seq model.</p>
<h3 id="atom-count-constraint-loss">Atom-Count Constraint Loss</h3>
<p>A correct structure prediction must contain the right number of atoms of each element. The authors add an auxiliary loss that penalizes the squared difference between the predicted and true atom counts for each element. The predicted atom counts are obtained by summing Gumbel-softmax outputs across all decoded positions.</p>
<p>For the $i$-th output token, the Gumbel-softmax probability vector is:</p>
<p>$$
y_{ij} = \frac{\exp\left((\log(\pi_{ij}) + g_{ij}) / \tau\right)}{\sum_{k=1}^{|\mathcal{V}|} \exp\left((\log(\pi_{ik}) + g_{ik}) / \tau\right)}
$$</p>
<p>where $\pi_{ij}$ is the model&rsquo;s softmax output, $g_{ij}$ is a Gumbel noise sample, and $\tau = 0.1$ is the temperature. The predicted token frequency vector is $\mathbf{y}^{pred} = \sum_{i=1}^{m} \mathbf{y}_i$, and the atom-count loss is:</p>
<p>$$
\mathcal{L}_{atom} = \frac{1}{|A|} \sum_{a \in A} \left(N_a(T) - y_{idx(a)}^{pred}\right)^2
$$</p>
<p>where $A$ is the set of chemical elements in the vocabulary, $N_a(T)$ returns the number of atoms of element $a$ in the correct SMILES string $T$, and $idx(a)$ returns the vocabulary index of element $a$. Only element tokens (e.g., &ldquo;C&rdquo;, &ldquo;O&rdquo;) are counted; bond symbols (e.g., &ldquo;=&rdquo;, &ldquo;#&rdquo;) are excluded.</p>
<p>The combined objective is:</p>
<p>$$
\mathcal{L}_{smiles} + \lambda_{atom} \mathcal{L}_{atom}
$$</p>
<p>with $\lambda_{atom} = 0.7$.</p>
<h3 id="multi-task-smilesinchi-prediction">Multi-Task SMILES/InChI Prediction</h3>
<p>SMILES and InChI strings encode the same chemical structure in different formats. The authors hypothesize that jointly predicting both representations can improve the shared encoder. The multi-task model shares the encoder between a SMILES decoder and an InChI decoder, minimizing:</p>
<p>$$
\mathcal{L}_{smiles} + \lambda_{inchi} \mathcal{L}_{inchi}
$$</p>
<p>where $\mathcal{L}_{inchi} = -\log P(I | X; \boldsymbol{\theta}_{enc}, \boldsymbol{\theta}_{inchi})$ and $\lambda_{inchi} = 0.3$.</p>
<h2 id="experimental-setup-and-evaluation">Experimental Setup and Evaluation</h2>
<h3 id="dataset">Dataset</h3>
<p>The dataset was constructed from PubChem dump data (97M compound records). Chemical compound names categorized as Synonyms were paired with canonical SMILES strings (converted via RDKit). Database-like IDs were filtered out using regular expressions. Duplicate names mapping to different CIDs were removed.</p>
<table>
  <thead>
      <tr>
          <th>Split</th>
          <th>Size</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>Training</td>
          <td>5,000,000</td>
      </tr>
      <tr>
          <td>Development</td>
          <td>1,113</td>
      </tr>
      <tr>
          <td>Test</td>
          <td>11,194</td>
      </tr>
  </tbody>
</table>
<h3 id="model-configuration">Model Configuration</h3>
<p>The Transformer uses 6 encoder/decoder layers, 8 attention heads, 512-dimensional embeddings, and 0.1 dropout. Training used label-smoothing cross-entropy ($\epsilon = 0.1$), Adam optimizer ($\beta_1 = 0.9$, $\beta_2 = 0.98$), and a warmup schedule with peak learning rate 0.0005 over 4,000 steps followed by inverse square root decay. Models were trained for 300,000 update steps. Final predictions averaged the last 10 checkpoints and used beam search (beam size 4, length penalty $\alpha = 0.6$, max output length 200).</p>
<h3 id="tokenization">Tokenization</h3>
<p>Three tokenization strategies were compared:</p>
<ul>
<li><strong>BPE</strong>: Byte pair encoding learned on chemical compound names (500 merge operations) via fastBPE</li>
<li><strong>OPSIN-TK</strong>: The OPSIN rule-based tokenizer</li>
<li><strong>OPSIN-TK+BPE</strong>: A hybrid where OPSIN handles tokenizable names and BPE handles the rest</li>
</ul>
<p>SMILES tokens were identified by regular expressions (elements as single tokens, remaining symbols as characters). InChI strings were tokenized by SentencePiece (vocabulary size 1,000).</p>
<h3 id="baselines">Baselines</h3>
<ul>
<li><strong>OPSIN</strong>: Open-source rule-based parser</li>
<li><strong>Tool A</strong> and <strong>Tool B</strong>: Two commercially available name-to-structure tools</li>
</ul>
<h3 id="results">Results</h3>
<table>
  <thead>
      <tr>
          <th>Method</th>
          <th>Tokenizer</th>
          <th>Recall</th>
          <th>Precision</th>
          <th>F-measure</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>OPSIN</td>
          <td>Rule-based</td>
          <td>0.693</td>
          <td>0.836</td>
          <td>0.758</td>
      </tr>
      <tr>
          <td>Tool A</td>
          <td>Rule-based</td>
          <td>0.711</td>
          <td>0.797</td>
          <td>0.752</td>
      </tr>
      <tr>
          <td>Tool B</td>
          <td>Rule-based</td>
          <td>0.653</td>
          <td>0.800</td>
          <td>0.719</td>
      </tr>
      <tr>
          <td>Transformer</td>
          <td>BPE</td>
          <td>0.793</td>
          <td>0.806</td>
          <td>0.799</td>
      </tr>
      <tr>
          <td>+ atomnum</td>
          <td>BPE</td>
          <td>0.798</td>
          <td>0.808</td>
          <td>0.803</td>
      </tr>
      <tr>
          <td>+ inchigen</td>
          <td>BPE</td>
          <td>0.810</td>
          <td>0.819</td>
          <td>0.814</td>
      </tr>
      <tr>
          <td>Transformer</td>
          <td>OPSIN-TK+BPE</td>
          <td>0.763</td>
          <td>0.873</td>
          <td>0.814</td>
      </tr>
      <tr>
          <td>+ atomnum</td>
          <td>OPSIN-TK+BPE</td>
          <td>0.768</td>
          <td>0.876</td>
          <td>0.818</td>
      </tr>
      <tr>
          <td>+ inchigen</td>
          <td>OPSIN-TK+BPE</td>
          <td>0.779</td>
          <td>0.886</td>
          <td>0.829</td>
      </tr>
      <tr>
          <td>Transformer</td>
          <td>OPSIN-TK</td>
          <td>0.755</td>
          <td>0.868</td>
          <td>0.808</td>
      </tr>
      <tr>
          <td>+ atomnum</td>
          <td>OPSIN-TK</td>
          <td>0.757</td>
          <td>0.867</td>
          <td>0.808</td>
      </tr>
      <tr>
          <td>+ inchigen</td>
          <td>OPSIN-TK</td>
          <td>0.754</td>
          <td>0.869</td>
          <td>0.807</td>
      </tr>
  </tbody>
</table>
<p>The best configuration (inchigen with OPSIN-TK+BPE) achieved an F-measure of 0.829, surpassing OPSIN by 0.071 points. The multi-task learning approach (inchigen) consistently outperformed the atom-count constraint alone (atomnum) across all tokenizer settings.</p>
<h2 id="key-findings-and-error-analysis">Key Findings and Error Analysis</h2>
<p>The Transformer-based approach produced grammatically correct SMILES strings (parseable by RDKit) for 99% of test examples, compared to 81.6-88.4% for the rule-based tools. Even when predictions were incorrect, they tended to be structurally similar to the correct answer. Using MACCS fingerprints and Jaccard (Tanimoto) similarity, the average similarity between incorrectly predicted and correct structures was 0.753.</p>
<p>The OPSIN-TK tokenizer yielded higher precision than BPE because approximately 11.5% (1,293 of 11,194) of test compounds could not be tokenized by OPSIN, reducing the number of outputs. BPE-based tokenizers achieved higher recall by covering all inputs. The hybrid OPSIN-TK+BPE approach balanced both, achieving the highest overall F-measure.</p>
<p><strong>Limitations</strong>: The paper does not evaluate on IUPAC names separately with the Transformer models (only comparing rule-based tools on IUPAC). The atom-count constraint and multi-task learning are not combined in a single model. The dataset is released but the training code is not. Hardware details and training times are not reported. The evaluation uses only exact-match F-measure and Jaccard similarity, without measuring partial credit for nearly-correct structures.</p>
<p><strong>Future work</strong>: The authors plan to explore additional tokenization methods, combine the atom-count constraint with multi-task learning, and apply the constraint loss to other chemistry problems including chemical reaction prediction.</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>Training</td>
          <td>PubChem Synonyms (custom split)</td>
          <td>5,000,000 pairs</td>
          <td>Chemical compound names to canonical SMILES</td>
      </tr>
      <tr>
          <td>Development</td>
          <td>PubChem Synonyms (custom split)</td>
          <td>1,113 pairs</td>
          <td>Filtered for duplicates</td>
      </tr>
      <tr>
          <td>Test</td>
          <td>PubChem Synonyms (custom split)</td>
          <td>11,194 pairs</td>
          <td>Filtered for duplicates; released as benchmark</td>
      </tr>
  </tbody>
</table>
<p>The authors state the dataset is released for future research. The data was constructed from the PubChem dump (97M compound records) using RDKit for SMILES canonicalization. Database-like IDs were removed with regular expressions and duplicate names across CIDs were filtered.</p>
<h3 id="algorithms">Algorithms</h3>
<ul>
<li>Transformer seq2seq (6 layers, 8 heads, 512-dim embeddings)</li>
<li>BPE tokenization via fastBPE (500 merge operations)</li>
<li>SentencePiece for InChI tokenization (vocabulary size 1,000)</li>
<li>Gumbel-softmax atom-count constraint ($\tau = 0.1$, $\lambda_{atom} = 0.7$)</li>
<li>Multi-task SMILES/InChI loss ($\lambda_{inchi} = 0.3$)</li>
<li>Adam optimizer ($\beta_1 = 0.9$, $\beta_2 = 0.98$, $\epsilon = 10^{-8}$)</li>
<li>Label smoothing ($\epsilon = 0.1$), 300K training steps</li>
<li>Beam search (beam size 4, length penalty $\alpha = 0.6$)</li>
</ul>
<h3 id="models">Models</h3>
<p>Standard Transformer architecture following Vaswani et al. (2017). No pre-trained weights or model checkpoints are released.</p>
<h3 id="evaluation">Evaluation</h3>
<table>
  <thead>
      <tr>
          <th>Metric</th>
          <th>Best Value</th>
          <th>Model</th>
          <th>Notes</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>F-measure</td>
          <td>0.829</td>
          <td>inchigen (OPSIN-TK+BPE)</td>
          <td>Highest overall</td>
      </tr>
      <tr>
          <td>Precision</td>
          <td>0.886</td>
          <td>inchigen (OPSIN-TK+BPE)</td>
          <td>Highest overall</td>
      </tr>
      <tr>
          <td>Recall</td>
          <td>0.810</td>
          <td>inchigen (BPE)</td>
          <td>Highest overall</td>
      </tr>
      <tr>
          <td>Grammatical correctness</td>
          <td>99%</td>
          <td>inchigen (BPE)</td>
          <td>SMILES parseable by RDKit</td>
      </tr>
      <tr>
          <td>Avg. Jaccard similarity (errors)</td>
          <td>0.753</td>
          <td>inchigen (BPE)</td>
          <td>On incorrect predictions only</td>
      </tr>
  </tbody>
</table>
<h3 id="hardware">Hardware</h3>
<p>Not reported.</p>
<hr>
<h2 id="paper-information">Paper Information</h2>
<p><strong>Citation</strong>: Omote, Y., Matsushita, K., Iwakura, T., Tamura, A., &amp; Ninomiya, T. (2020). Transformer-based Approach for Predicting Chemical Compound Structures. <em>Proceedings of the 1st Conference of the Asia-Pacific Chapter of the Association for Computational Linguistics and the 10th International Joint Conference on Natural Language Processing</em>, 154-162. <a href="https://doi.org/10.18653/v1/2020.aacl-main.19">https://doi.org/10.18653/v1/2020.aacl-main.19</a></p>
<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>{omote2020transformer,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">title</span>=<span style="color:#e6db74">{Transformer-based Approach for Predicting Chemical Compound Structures}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">author</span>=<span style="color:#e6db74">{Omote, Yutaro and Matsushita, Kyoumoto and Iwakura, Tomoya and Tamura, Akihiro and Ninomiya, Takashi}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">booktitle</span>=<span style="color:#e6db74">{Proceedings of the 1st Conference of the Asia-Pacific Chapter of the Association for Computational Linguistics and the 10th International Joint Conference on Natural Language Processing}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">pages</span>=<span style="color:#e6db74">{154--162}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">year</span>=<span style="color:#e6db74">{2020}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">publisher</span>=<span style="color:#e6db74">{Association for Computational Linguistics}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">doi</span>=<span style="color:#e6db74">{10.18653/v1/2020.aacl-main.19}</span>
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div>]]></content:encoded></item><item><title>Transformer CLMs for SMILES: Literature Review 2024</title><link>https://hunterheidenreich.com/notes/chemistry/molecular-representations/encoders/transformer-clms-smiles-review/</link><pubDate>Thu, 26 Mar 2026 00:00:00 +0000</pubDate><guid>https://hunterheidenreich.com/notes/chemistry/molecular-representations/encoders/transformer-clms-smiles-review/</guid><description>Review of transformer-based chemical language models for SMILES, covering encoder, decoder, and encoder-decoder architectures for molecular property prediction.</description><content:encoded><![CDATA[<h2 id="a-systematization-of-transformer-based-chemical-language-models">A Systematization of Transformer-Based Chemical Language Models</h2>
<p>This paper is a <strong>Systematization</strong> (literature review) that surveys the landscape of transformer-based chemical language models (CLMs) operating on SMILES representations. It organizes the field into three architectural categories (encoder-only, decoder-only, encoder-decoder), discusses tokenization strategies, pre-training and fine-tuning methodologies, and identifies open challenges and future research directions. The review covers approximately 30 distinct CLMs published through early 2024.</p>
<h2 id="why-review-transformer-clms-for-smiles">Why Review Transformer CLMs for SMILES?</h2>
<p>The chemical space is vast, with databases like ZINC20 exceeding 5.5 billion compounds, and the amount of unlabeled molecular data far outstrips available labeled data for specific tasks like toxicity prediction or binding affinity estimation. Traditional molecular representations (fingerprints, descriptors, graph-based methods) require expert-engineered features and extensive domain knowledge.</p>
<p>Transformer-based language models, originally developed for NLP, have emerged as a compelling alternative. By treating <a href="/notes/chemistry/molecular-representations/notations/smiles/">SMILES</a> strings as a &ldquo;chemical language,&rdquo; these models can leverage large-scale unsupervised pre-training on abundant unlabeled molecules, then fine-tune on small labeled datasets for specific downstream tasks. Earlier approaches like Seq2Seq and Seq3Seq fingerprint methods used RNN-based encoder-decoders, but these suffered from vanishing gradients and sequential processing bottlenecks when handling long SMILES sequences.</p>
<p>The authors motivate this review by noting that no prior survey has comprehensively organized transformer-based CLMs by architecture type while simultaneously covering tokenization, embedding strategies, and downstream application domains.</p>
<h2 id="architectural-taxonomy-encoder-decoder-and-encoder-decoder-models">Architectural Taxonomy: Encoder, Decoder, and Encoder-Decoder Models</h2>
<p>The core organizational contribution is a three-way taxonomy of transformer CLMs based on their architectural backbone.</p>
<h3 id="encoder-only-models-bert-family">Encoder-Only Models (BERT Family)</h3>
<p>These models capture bidirectional context, making them well suited for extracting molecular representations for property prediction tasks. The review covers:</p>
<ul>
<li><strong>BERT</strong> (Lee and Nam, 2022): Adapted for SMILES processing with linguistic knowledge infusion, using BPE tokenization</li>
<li><strong><a href="/notes/chemistry/molecular-representations/encoders/molbert-molecular-representations/">MOLBERT</a></strong> (Fabian et al., 2020): Chemistry-specific BERT for physicochemical property and bioactivity prediction</li>
<li><strong><a href="/notes/chemistry/molecular-representations/encoders/smiles-bert/">SMILES-BERT</a></strong> (Wang et al., 2019): BERT variant designed to learn molecular representations directly from SMILES without feature engineering</li>
<li><strong><a href="/notes/chemistry/molecular-representations/encoders/chemberta/">ChemBERTa</a> / <a href="/notes/chemistry/molecular-representations/encoders/chemberta-2/">ChemBERTa-2</a></strong> (Chithrananda et al., 2020; Ahmad et al., 2022): RoBERTa-based models optimized for chemical property prediction, with ChemBERTa-2 exploring multi-task pre-training</li>
<li><strong>GPT-MolBERTa</strong> (Balaji et al., 2023): Combines GPT molecular features with a RoBERTa backbone</li>
<li><strong><a href="/notes/chemistry/molecular-representations/encoders/molformer/">MoLFormer</a></strong> (Ross et al., 2022): Large-scale model trained on 1.1 billion molecules, published in Nature Machine Intelligence</li>
<li><strong><a href="/notes/chemistry/molecular-representations/encoders/selformer/">SELFormer</a></strong> (Yuksel et al., 2023): Operates on <a href="/notes/chemistry/molecular-representations/notations/selfies/">SELFIES</a> representations rather than SMILES</li>
<li><strong>Mol-BERT / MolRoPE-BERT</strong> (Li and Jiang, 2021; Liu et al., 2023): Differ in positional embedding strategy, with MolRoPE-BERT using rotary position embedding to handle longer sequences</li>
<li><strong>BET</strong> (Chen et al., 2021): Extracts predictive representations from hundreds of millions of molecules</li>
</ul>
<h3 id="decoder-only-models-gpt-family">Decoder-Only Models (GPT Family)</h3>
<p>These models excel at generative tasks, including de novo molecular design:</p>
<ul>
<li><strong>GPT-2-based model</strong> (Adilov, 2021): Generative pre-training from molecules</li>
<li><strong>MolXPT</strong> (Liu et al., 2023): Wraps molecules with text for generative pre-training, connecting chemical and natural language</li>
<li><strong>BioGPT</strong> (Luo et al., 2022): Focuses on biomedical text generation and mining</li>
<li><strong>MolGPT</strong> (Haroon et al., 2023): Uses relative attention to capture token distances and relationships for de novo drug design</li>
<li><strong>Mol-Instructions</strong> (Fang et al., 2023): Large-scale biomolecular instruction dataset for LLMs</li>
</ul>
<h3 id="encoder-decoder-models">Encoder-Decoder Models</h3>
<p>These combine encoding and generation capabilities for sequence-to-sequence tasks:</p>
<ul>
<li><strong><a href="/notes/chemistry/molecular-design/generation/autoregressive/chemformer/">Chemformer</a></strong> (Irwin et al., 2022): BART-based model for reaction prediction and molecular property prediction</li>
<li><strong>MolT5</strong> (adapted T5): Unified text-to-text framework for molecular tasks</li>
<li><strong><a href="/notes/chemistry/molecular-representations/encoders/smiles-transformer/">SMILES Transformer</a></strong> (Honda et al., 2019): Pre-trained molecular fingerprints for low-data drug discovery</li>
<li><strong><a href="/notes/chemistry/molecular-representations/encoders/x-mol-pretraining-molecular-understanding/">X-MOL</a></strong> (Xue et al., 2020): Large-scale pre-training for molecular understanding</li>
<li><strong><a href="/notes/chemistry/molecular-design/property-prediction/regression-transformer/">Regression Transformer</a></strong> (Born and Manica, 2023): Operates on <a href="/notes/chemistry/molecular-representations/notations/selfies/">SELFIES</a>, enabling concurrent regression and generation</li>
<li><strong>TransAntivirus</strong> (Mao et al., 2023): Specialized for antiviral drug design using IUPAC nomenclature</li>
</ul>
<h2 id="tokenization-embedding-and-pre-training-strategies">Tokenization, Embedding, and Pre-Training Strategies</h2>
<h3 id="smiles-tokenization">SMILES Tokenization</h3>
<p>The review identifies tokenization as a critical preprocessing step that affects downstream performance. SMILES tokenization differs from standard NLP tokenization because SMILES strings lack whitespace and use parentheses for branching rather than sentence separation. The key approaches include:</p>
<table>
  <thead>
      <tr>
          <th>Strategy</th>
          <th>Source</th>
          <th>Description</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td><a href="/notes/chemistry/molecular-representations/notations/atom-in-smiles-tokenization/">Atom-in-SMILES (AIS)</a></td>
          <td>Ucak et al. (2023)</td>
          <td>Atom-level tokens preserving chemical identity</td>
      </tr>
      <tr>
          <td><a href="/notes/chemistry/molecular-representations/notations/smiles-pair-encoding/">SMILES Pair Encoding (SPE)</a></td>
          <td>Li and Fourches (2021)</td>
          <td>BPE-inspired substructure tokenization</td>
      </tr>
      <tr>
          <td>Byte-Pair Encoding (BPE)</td>
          <td>Chithrananda et al. (2020); Lee and Nam (2022)</td>
          <td>Standard subword tokenization adapted for SMILES</td>
      </tr>
      <tr>
          <td>SMILESTokenizer</td>
          <td>Chithrananda et al. (2020)</td>
          <td>Character-level tokenization with chemical adjustments</td>
      </tr>
  </tbody>
</table>
<h3 id="positional-embeddings">Positional Embeddings</h3>
<p>The models use various positional encoding strategies: absolute, relative key, relative key-query, rotary (RoPE), and sinusoidal. Notably, SMILES-based models omit segmentation embeddings since SMILES data consists of single sequences rather than sentence pairs.</p>
<h3 id="pre-training-and-fine-tuning-pipeline">Pre-Training and Fine-Tuning Pipeline</h3>
<p>The standard workflow follows two phases:</p>
<ol>
<li><strong>Pre-training</strong>: Unsupervised training on large unlabeled SMILES databases (ZINC, PubChem, ChEMBL) using masked language modeling (MLM), where the model learns to predict masked tokens within SMILES strings</li>
<li><strong>Fine-tuning</strong>: Supervised adaptation on smaller labeled datasets for specific tasks (classification or regression)</li>
</ol>
<p>The self-attention mechanism, central to all transformer CLMs, is formulated as:</p>
<p>$$
Z = \text{Softmax}\left(\frac{(XW^Q)(XW^K)^T}{\sqrt{d_k}}\right) XW^V
$$</p>
<p>where $X \in \mathbb{R}^{N \times M}$ is the input feature matrix, $W^Q$, $W^K$, $W^V \in \mathbb{R}^{M \times d_k}$ are learnable weight matrices, and $\sqrt{d_k}$ is the scaling factor.</p>
<h2 id="benchmark-datasets-and-evaluation-landscape">Benchmark Datasets and Evaluation Landscape</h2>
<p>The review catalogs the standard evaluation ecosystem for CLMs. Pre-training databases include ZINC, PubChem, and ChEMBL. Fine-tuning and evaluation rely heavily on <a href="/notes/chemistry/molecular-design/property-prediction/moleculenet-benchmark-molecular-ml/">MoleculeNet</a> benchmarks:</p>
<table>
  <thead>
      <tr>
          <th>Category</th>
          <th>Datasets</th>
          <th>Task Type</th>
          <th>Example Size</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>Physical Chemistry</td>
          <td>ESOL, FreeSolv, Lipophilicity</td>
          <td>Regression</td>
          <td>642 to 4,200</td>
      </tr>
      <tr>
          <td>Biophysics</td>
          <td>PCBA, MUV, HIV, PDBbind, BACE</td>
          <td>Classification/Regression</td>
          <td>11,908 to 437,929</td>
      </tr>
      <tr>
          <td>Physiology</td>
          <td>BBBP, Tox21, ToxCast, SIDER, ClinTox</td>
          <td>Classification</td>
          <td>1,427 to 8,575</td>
      </tr>
  </tbody>
</table>
<p>The authors also propose four new fine-tuning datasets targeting diseases: COVID-19 drug compounds, cocrystal formation, antimalarial drugs (Plasmodium falciparum targets), and cancer gene expression/drug response data.</p>
<h2 id="challenges-limitations-and-future-directions">Challenges, Limitations, and Future Directions</h2>
<h3 id="current-challenges">Current Challenges</h3>
<p>The review identifies several persistent limitations:</p>
<ol>
<li><strong>Data efficiency</strong>: Despite transfer learning, transformer CLMs still require substantial pre-training data, and labeled datasets for specific tasks remain scarce</li>
<li><strong>Interpretability</strong>: The complexity of transformer architectures makes it difficult to understand how specific molecular features contribute to predictions</li>
<li><strong>Computational cost</strong>: Training large-scale models demands significant GPU resources, limiting accessibility</li>
<li><strong>Handling rare molecules</strong>: Models struggle with molecular structures that deviate significantly from training data distributions</li>
<li><strong>SMILES limitations</strong>: Non-unique representations, invalid strings, exceeded atom valency, and inadequate spatial information capture</li>
</ol>
<h3 id="smiles-representation-issues">SMILES Representation Issues</h3>
<p>The authors highlight five specific problems with SMILES as an input representation:</p>
<ul>
<li>Non-canonical representations reduce string uniqueness for the same molecule</li>
<li>Many symbol combinations produce chemically invalid outputs</li>
<li>Valid SMILES strings can encode chemically impossible molecules (e.g., exceeded valency)</li>
<li>Spatial information is inadequately captured</li>
<li>Syntactic and semantic robustness is limited</li>
</ul>
<h3 id="future-research-directions">Future Research Directions</h3>
<p>The review proposes several directions:</p>
<ul>
<li><strong>Alternative molecular representations</strong>: Exploring <a href="/notes/chemistry/molecular-representations/notations/selfies/">SELFIES</a>, <a href="/notes/chemistry/molecular-representations/notations/deepsmiles-adaptation-for-ml/">DeepSMILES</a>, IUPAC, and InChI beyond SMILES</li>
<li><strong>Role of SMILES token types</strong>: Strategic masking of metals, non-metals, bonds, and branches during MLM pre-training to identify which components are most critical</li>
<li><strong>Few-shot learning</strong>: Combining few-shot approaches with large-scale pre-trained CLMs for data-scarce scenarios</li>
<li><strong>Drug repurposing</strong>: Training CLMs to distinguish identical compounds with different biological activity profiles across therapeutic domains</li>
<li><strong>Improved benchmarks</strong>: Incorporating disease-specific datasets (malaria, cancer, COVID-19) for more realistic evaluation</li>
<li><strong>Ethical considerations</strong>: Addressing dual-use risks, data biases, and responsible open-source release of CLMs</li>
</ul>
<hr>
<h2 id="reproducibility-details">Reproducibility Details</h2>
<p>This is a literature review paper. It does not introduce new models, code, or experimental results. The reproducibility assessment focuses on the accessibility of the reviewed works and proposed datasets.</p>
<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>Pre-training</td>
          <td>ZINC20</td>
          <td>5.5B+ compounds</td>
          <td>Publicly available</td>
      </tr>
      <tr>
          <td>Pre-training</td>
          <td>PubChem</td>
          <td>100M+ compounds</td>
          <td>Publicly available</td>
      </tr>
      <tr>
          <td>Pre-training</td>
          <td>ChEMBL</td>
          <td>2M+ compounds</td>
          <td>Publicly available</td>
      </tr>
      <tr>
          <td>Fine-tuning</td>
          <td>MoleculeNet (8 datasets)</td>
          <td>642 to 437,929</td>
          <td>Standard benchmark suite</td>
      </tr>
      <tr>
          <td>Proposed</td>
          <td>COVID-19 drug compounds</td>
          <td>740</td>
          <td>From Harigua-Souiai et al. (2021)</td>
      </tr>
      <tr>
          <td>Proposed</td>
          <td>Cocrystal formation</td>
          <td>3,282</td>
          <td>From Mswahili et al. (2021)</td>
      </tr>
      <tr>
          <td>Proposed</td>
          <td>Antimalarial drugs</td>
          <td>4,794</td>
          <td>From Mswahili et al. (2024)</td>
      </tr>
      <tr>
          <td>Proposed</td>
          <td>Cancer gene/drug response</td>
          <td>201 drugs, 734 cell lines</td>
          <td>From Kim et al. (2021)</td>
      </tr>
  </tbody>
</table>
<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="http://dai.chungbuk.ac.kr/">DAI Lab website</a></td>
          <td>Other</td>
          <td>N/A</td>
          <td>Authors&rsquo; research lab</td>
      </tr>
  </tbody>
</table>
<p>No code, models, or evaluation scripts are released with this review. The paper does not include a supplementary materials section or GitHub repository.</p>
<h3 id="hardware">Hardware</h3>
<p>Not applicable (literature review).</p>
<hr>
<h2 id="paper-information">Paper Information</h2>
<p><strong>Citation</strong>: Mswahili, M. E., &amp; Jeong, Y.-S. (2024). Transformer-based models for chemical SMILES representation: A comprehensive literature review. <em>Heliyon</em>, 10(20), e39038. <a href="https://doi.org/10.1016/j.heliyon.2024.e39038">https://doi.org/10.1016/j.heliyon.2024.e39038</a></p>
<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">@article</span>{mswahili2024transformer,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">title</span>=<span style="color:#e6db74">{Transformer-based models for chemical {SMILES} representation: A comprehensive literature review}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">author</span>=<span style="color:#e6db74">{Mswahili, Medard Edmund and Jeong, Young-Seob}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">journal</span>=<span style="color:#e6db74">{Heliyon}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">volume</span>=<span style="color:#e6db74">{10}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">number</span>=<span style="color:#e6db74">{20}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">pages</span>=<span style="color:#e6db74">{e39038}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">year</span>=<span style="color:#e6db74">{2024}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">publisher</span>=<span style="color:#e6db74">{Elsevier}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">doi</span>=<span style="color:#e6db74">{10.1016/j.heliyon.2024.e39038}</span>
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div>]]></content:encoded></item><item><title>t-SMILES: Tree-Based Fragment Molecular Encoding</title><link>https://hunterheidenreich.com/notes/chemistry/molecular-representations/notations/t-smiles-fragment-molecular-representation/</link><pubDate>Thu, 26 Mar 2026 00:00:00 +0000</pubDate><guid>https://hunterheidenreich.com/notes/chemistry/molecular-representations/notations/t-smiles-fragment-molecular-representation/</guid><description>t-SMILES encodes fragmented molecules as SMILES-type strings via breadth-first traversal of full binary trees, reducing nesting depth and improving generation.</description><content:encoded><![CDATA[<h2 id="a-fragment-based-molecular-representation-method">A Fragment-Based Molecular Representation Method</h2>
<p>This is a <strong>Method</strong> paper that proposes t-SMILES (tree-based SMILES), a framework for representing molecules as SMILES-type strings derived from fragment-based decompositions. The primary contribution is an encoding algorithm that converts fragmented molecular graphs into full binary trees (FBTs) and then traverses them breadth-first to produce linear strings. Three coding variants are introduced: TSSA (shared atom), TSDY (dummy atom without ID), and TSID (dummy atom with ID). The framework achieves 100% theoretical validity, higher novelty scores, and improved distribution-learning metrics compared to classical <a href="/notes/chemistry/molecular-representations/notations/smiles/">SMILES</a>, <a href="/notes/chemistry/molecular-representations/notations/deepsmiles-adaptation-for-ml/">DeepSMILES</a>, and <a href="/notes/chemistry/molecular-representations/notations/selfies/">SELFIES</a> across ChEMBL, ZINC, and QM9 benchmarks.</p>
<h2 id="why-fragment-based-representations-matter-for-molecular-generation">Why Fragment-Based Representations Matter for Molecular Generation</h2>
<p>Classical SMILES encodes molecules via depth-first traversal of the molecular graph, requiring parentheses and ring identifiers to appear in matched pairs with deep nesting. When generative models (LSTM, Transformer) are trained on SMILES, they produce chemically invalid strings, particularly on small datasets, because they struggle to learn these long-range pairing constraints. DeepSMILES addresses some syntactical issues but still permits semantic violations (e.g., oxygen with three bonds). SELFIES guarantees 100% valid strings but at the cost of readability and, as the authors show, lower <a href="/notes/chemistry/molecular-design/generation/evaluation/frechet-chemnet-distance/">FCD</a> scores indicating generated molecules diverge from the training distribution.</p>
<p>Fragment-based approaches reduce the search space compared to atom-level methods and can provide insights into molecular recognition (e.g., protein-ligand interactions). However, existing fragment-based deep learning methods rely on fixed dictionaries of candidate fragments, creating in-vocabulary/out-of-vocabulary problems and high-dimensional sparse representations. The encoding of fragments as SMILES-type strings, rather than dictionary IDs, had not been systematically explored before this work.</p>
<p>The authors draw on the observation that fragments in organic molecules follow a <a href="https://en.wikipedia.org/wiki/Zipf's_law">Zipf-like</a> rank distribution similar to words in natural language, motivating the use of NLP techniques for fragment-based molecular modeling.</p>
<h2 id="core-innovation-binary-tree-encoding-of-fragmented-molecules">Core Innovation: Binary Tree Encoding of Fragmented Molecules</h2>
<p>The t-SMILES algorithm proceeds in three steps:</p>
<ol>
<li><strong>Fragmentation</strong>: A molecule is decomposed into valid chemical fragments using a chosen algorithm (JTVAE, BRICS, <a href="https://en.wikipedia.org/wiki/Matched_molecular_pair_analysis">MMPA</a>, or Scaffold), producing a fragmented molecular graph.</li>
<li><strong>Tree construction</strong>: The fragmented graph is converted into an Acyclic Molecular Tree (AMT), which is a reduced graph where nodes represent fragments and edges represent bonds between them. The AMT is then transformed into a Full Binary Tree (FBT), where every internal node has exactly two children.</li>
<li><strong>String generation</strong>: The FBT is traversed using breadth-first search (BFS) to produce the t-SMILES string.</li>
</ol>
<p>The framework introduces only two new symbols beyond standard SMILES: <code>&amp;</code> marks empty tree nodes (branch terminators providing global structural information), and <code>^</code> separates adjacent substructure segments (analogous to spaces between words in English).</p>
<h3 id="three-coding-variants">Three Coding Variants</h3>
<ul>
<li><strong>TSSA</strong> (shared atom): Two fragments share a real atom at their connection point. Produces the highest novelty scores and is recommended for goal-directed tasks.</li>
<li><strong>TSDY</strong> (dummy atom, no ID): Uses dummy atoms (marked with <code>*</code>) to indicate bonding points. Provides a balanced choice between novelty and distribution fidelity.</li>
<li><strong>TSID</strong> (dummy atom with ID): Uses numbered dummy atoms (<code>[n*]</code>) for unambiguous reconstruction. Produces the most faithful distribution reproduction and is recommended for distribution-learning tasks.</li>
</ul>
<h3 id="structural-advantages">Structural Advantages</h3>
<p>The key structural benefit is a dramatic reduction in nesting depth. For TSDY_M on ChEMBL, the proportion of tokens at nesting depth 0-1-2 increases from 68.0% (SMILES) to 99.3%, while depth 3-4-5 drops from 31.9% to 0.7%, and depth 6-11 drops from 0.1% to 0.0002%. The <code>&amp;</code> symbol, which encodes molecular topology, does not need to appear in pairs (unlike parentheses in SMILES), and its high frequency means it does not create a scarcity problem for learning.</p>
<p>The framework also supports a multi-code system where classical SMILES can be integrated as a special case called TS_Vanilla, and multiple fragmentation-based codes can be combined into hybrid models.</p>
<h3 id="reconstruction-and-data-augmentation">Reconstruction and Data Augmentation</h3>
<p>Molecules can be reconstructed from t-SMILES strings by reversing the process: rebuilding the FBT from the string, converting to AMT, and assembling fragments into a molecular graph. This reconstruction process can itself generate novel molecules without any model training by randomly assembling fragments. On ChEMBL, TSSA reconstruction achieves uniqueness above 0.98 and novelty above 0.68 for all four fragmentation algorithms, with 100% validity.</p>
<p>Data augmentation in t-SMILES operates at four levels: (1) different decomposition algorithms, (2) reconstruction, (3) enumeration of fragment strings, and (4) enumeration of FBTs. Unlike <a href="/notes/chemistry/molecular-representations/notations/randomized-smiles-generative-models/">SMILES enumeration</a> (which only produces different strings for the same molecule), t-SMILES reconstruction generates genuinely different molecules from the same fragment set.</p>
<h2 id="systematic-evaluation-across-multiple-benchmarks">Systematic Evaluation Across Multiple Benchmarks</h2>
<p>All experiments use MolGPT (a Transformer-decoder model) as the primary generative model. Three types of metrics are employed: distribution-learning benchmarks, goal-directed benchmarks, and Wasserstein distance metrics for physicochemical properties.</p>
<h3 id="low-resource-datasets-jnk3-and-aid1706">Low-Resource Datasets (JNK3 and AID1706)</h3>
<p>On <a href="https://en.wikipedia.org/wiki/MAPK10">JNK3</a> (923 active molecules), the authors investigate overfitting behavior across training epochs:</p>
<table>
  <thead>
      <tr>
          <th>Model</th>
          <th>Valid</th>
          <th>Novelty</th>
          <th>FCD</th>
          <th>Active Novel</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>SMILES [R200]</td>
          <td>0.795</td>
          <td>0.120</td>
          <td>0.584</td>
          <td>0.072</td>
      </tr>
      <tr>
          <td>SMILES [R2000]</td>
          <td>1.000</td>
          <td>0.001</td>
          <td>0.765</td>
          <td>0.004</td>
      </tr>
      <tr>
          <td>SELFIES [R200]</td>
          <td>1.000</td>
          <td>0.238</td>
          <td>0.544</td>
          <td>0.148</td>
      </tr>
      <tr>
          <td>SELFIES [R2000]</td>
          <td>1.000</td>
          <td>0.008</td>
          <td>0.767</td>
          <td>0.050</td>
      </tr>
      <tr>
          <td>TSSA_S [R300]</td>
          <td>1.000</td>
          <td>0.833</td>
          <td>0.564</td>
          <td>0.582</td>
      </tr>
      <tr>
          <td>TSSA_S [R5000]</td>
          <td>1.000</td>
          <td>0.817</td>
          <td>0.608</td>
          <td>0.564</td>
      </tr>
      <tr>
          <td>TF_TSSA_S [R5]</td>
          <td>1.000</td>
          <td>0.932</td>
          <td>0.483</td>
          <td>0.710</td>
      </tr>
      <tr>
          <td>TSSA_S_Rec50 [R10]</td>
          <td>1.000</td>
          <td>0.962</td>
          <td>0.389</td>
          <td>0.829</td>
      </tr>
  </tbody>
</table>
<p>Key findings: SMILES and DeepSMILES novelty scores collapse to near zero after 200 epochs, while t-SMILES novelty stabilizes around 0.8. The highest active-novel score of 0.829 comes from t-SMILES with reconstruction-based data augmentation. Transfer learning with t-SMILES maintains novelty of 0.710 at 5 epochs versus 0.526 for SMILES, and at 100 epochs the gap widens dramatically (0.569 vs. 0.023).</p>
<h3 id="distribution-learning-on-chembl">Distribution Learning on ChEMBL</h3>
<p>t-SMILES models outperform graph baselines (Graph MCTS, hG2G, MGM) and fragment-based methods (FASMIFRA). TSID_B and TSID_S achieve FCD scores of 0.909 while maintaining novelty of 0.941 and 0.933, surpassing SMILES (FCD 0.906, novelty 0.907) in both dimensions. TSDY and TSID models consistently outperform TSSA on distribution fidelity for larger molecules.</p>
<h3 id="goal-directed-tasks-on-chembl">Goal-Directed Tasks on ChEMBL</h3>
<p>On 20 <a href="/notes/chemistry/molecular-design/generation/evaluation/guacamol-benchmarking-de-novo-molecular-design/">GuacaMol</a> subtasks, different fragmentation algorithms excel at different tasks. The goal-directed reconstruction algorithm significantly outperforms random reconstruction. On the <a href="https://en.wikipedia.org/wiki/Sitagliptin">Sitagliptin</a> MPO task (T16.SMPO), the TSDY_M model with goal-directed reconstruction achieves a score of 0.930, compared to 0.598 for SMILES and 0.708 for CReM. On <a href="https://en.wikipedia.org/wiki/Valsartan">Valsartan</a> SMARTS (T18.VS), t-SMILES models reach 0.997 versus 0.985 for SMILES.</p>
<h3 id="distribution-learning-on-zinc-and-qm9">Distribution Learning on ZINC and QM9</h3>
<p>On ZINC, t-SMILES models significantly outperform existing fragment-based baselines (JTVAE, FragDgm). Seven t-SMILES models achieve both higher FCD and novelty scores than SELFIES. On QM9 (smaller molecules), all string-based models achieve high FCD scores (above 0.960), with t-SMILES performing better than existing string and graph approaches.</p>
<h3 id="physicochemical-properties">Physicochemical Properties</h3>
<p>Across ChEMBL and ZINC, TSDY and TSID models capture physicochemical property distributions (MolWt, LogP, SAScore, N_Atoms, N_Rings, etc.) more faithfully than TSSA models. Multiple t-SMILES models outperform SMILES in more than four out of nine property categories. Baseline models hG2G and JTVAE show the weakest pattern learning, producing molecules with fewer atoms and rings than the training data.</p>
<h2 id="key-findings-and-limitations">Key Findings and Limitations</h2>
<h3 id="main-results">Main Results</h3>
<ol>
<li>t-SMILES achieves 100% theoretical validity by fragmenting molecules into chemically valid pieces before encoding.</li>
<li>The framework avoids the overfitting problem on low-resource datasets, maintaining stable novelty scores where SMILES, DeepSMILES, and SELFIES collapse.</li>
<li>The multi-code system allows different coding algorithms to complement each other, with hybrid models accessing broader chemical space.</li>
<li>Goal-directed reconstruction significantly outperforms all baselines on targeted optimization tasks.</li>
<li>TSDY and TSID provide better distribution fidelity than TSSA on larger molecules, while TSSA excels at novelty generation for goal-directed tasks.</li>
</ol>
<h3 id="limitations">Limitations</h3>
<p>The authors acknowledge several limitations:</p>
<ul>
<li>Whether the tree structure of t-SMILES can be effectively learned by Large Language Models remains unexplored.</li>
<li>Only published fragmentation algorithms were tested; custom fragmentation schemes were not investigated.</li>
<li>Experiments on more complex (larger) molecules were not performed.</li>
<li>The reconstruction algorithm uses simple rules for fragment assembly; more sophisticated assembly methods (Monte Carlo tree search, CReM) could improve quality.</li>
</ul>
<h3 id="future-directions">Future Directions</h3>
<p>The authors suggest exploring advanced reconstruction and optimization algorithms, improved generative models, evolutionary techniques, and extending t-SMILES to property prediction, retrosynthesis, and reaction prediction tasks. The framework is also extensible to other string representations (t-DSMILES, t-SELFIES) by changing how fragments are encoded.</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>Low-resource evaluation</td>
          <td>JNK3</td>
          <td>923 active molecules</td>
          <td>Kinase inhibitors</td>
      </tr>
      <tr>
          <td>Low-resource evaluation</td>
          <td>AID1706</td>
          <td>329 active molecules</td>
          <td>SARS 3CLPro inhibitors</td>
      </tr>
      <tr>
          <td>Distribution learning</td>
          <td>ChEMBL</td>
          <td>Standard split</td>
          <td>Large drug-like molecules</td>
      </tr>
      <tr>
          <td>Distribution learning</td>
          <td>ZINC</td>
          <td>250K subset</td>
          <td>Medium drug-like molecules</td>
      </tr>
      <tr>
          <td>Distribution learning</td>
          <td>QM9</td>
          <td>~134K molecules</td>
          <td>Small organic molecules</td>
      </tr>
  </tbody>
</table>
<h3 id="algorithms">Algorithms</h3>
<ul>
<li><strong>Fragmentation</strong>: JTVAE, BRICS, MMPA, Scaffold (all via <a href="https://en.wikipedia.org/wiki/RDKit">RDKit</a>)</li>
<li><strong>Tree construction</strong>: AMT from reduced graph, then FBT transformation</li>
<li><strong>Traversal</strong>: Breadth-first search on FBT</li>
<li><strong>Generative model</strong>: MolGPT (Transformer decoder)</li>
<li><strong>Discriminative model</strong>: AttentiveFP for activity prediction on JNK3/AID1706</li>
</ul>
<h3 id="evaluation">Evaluation</h3>
<table>
  <thead>
      <tr>
          <th>Metric</th>
          <th>Description</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>Validity</td>
          <td>Fraction of generated strings that decode to valid molecules</td>
      </tr>
      <tr>
          <td>Uniqueness</td>
          <td>Fraction of distinct molecules among valid generations</td>
      </tr>
      <tr>
          <td>Novelty</td>
          <td>Fraction of generated molecules not in training set</td>
      </tr>
      <tr>
          <td>KLD</td>
          <td>Kullback-Leibler divergence for physicochemical property distributions</td>
      </tr>
      <tr>
          <td>FCD</td>
          <td>Frechet ChemNet Distance measuring chemical similarity to training set</td>
      </tr>
      <tr>
          <td>Active Novel</td>
          <td>Novel molecules predicted active by AttentiveFP</td>
      </tr>
  </tbody>
</table>
<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/juanniwu/t-SMILES">t-SMILES GitHub</a></td>
          <td>Code</td>
          <td>MIT</td>
          <td>Official implementation with training/generation scripts</td>
      </tr>
      <tr>
          <td><a href="https://doi.org/10.5281/ZENODO.10991703">Zenodo deposit</a></td>
          <td>Code + Data</td>
          <td>CC-BY-4.0</td>
          <td>Archived code and data</td>
      </tr>
      <tr>
          <td><a href="https://codeocean.com/capsule/3034546/tree">Code Ocean capsule</a></td>
          <td>Code</td>
          <td>Not specified</td>
          <td>Certified reproducible compute capsule</td>
      </tr>
  </tbody>
</table>
<h3 id="hardware">Hardware</h3>
<p>The paper mentions limited computational resources but does not specify exact GPU types or training times.</p>
<hr>
<h2 id="paper-information">Paper Information</h2>
<p><strong>Citation</strong>: Wu, J.-N., Wang, T., Chen, Y., Tang, L.-J., Wu, H.-L., &amp; Yu, R.-Q. (2024). t-SMILES: a fragment-based molecular representation framework for de novo ligand design. <em>Nature Communications</em>, 15, 4993.</p>
<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">@article</span>{wu2024tsmiles,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">title</span>=<span style="color:#e6db74">{t-SMILES: a fragment-based molecular representation framework for de novo ligand design}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">author</span>=<span style="color:#e6db74">{Wu, Juan-Ni and Wang, Tong and Chen, Yue and Tang, Li-Juan and Wu, Hai-Long and Yu, Ru-Qin}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">journal</span>=<span style="color:#e6db74">{Nature Communications}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">volume</span>=<span style="color:#e6db74">{15}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">number</span>=<span style="color:#e6db74">{1}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">pages</span>=<span style="color:#e6db74">{4993}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">year</span>=<span style="color:#e6db74">{2024}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">doi</span>=<span style="color:#e6db74">{10.1038/s41467-024-49388-6}</span>
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div>]]></content:encoded></item><item><title>Systematic Review of Deep Learning CLMs (2020-2024)</title><link>https://hunterheidenreich.com/notes/chemistry/molecular-representations/encoders/systematic-review-deep-learning-clms/</link><pubDate>Thu, 26 Mar 2026 00:00:00 +0000</pubDate><guid>https://hunterheidenreich.com/notes/chemistry/molecular-representations/encoders/systematic-review-deep-learning-clms/</guid><description>Systematic review of 72 deep learning molecular generation studies using MOSES and GuacaMol benchmarks across RNNs, transformers, VAEs, and GANs.</description><content:encoded><![CDATA[<h2 id="a-systematization-of-chemical-language-models-for-molecular-generation">A Systematization of Chemical Language Models for Molecular Generation</h2>
<p>This paper is a <strong>Systematization</strong> that provides a comprehensive, PRISMA-guided systematic review of deep learning chemical language models (CLMs) used for de novo molecular generation. The primary contribution is a structured statistical analysis of 72 retrieved articles from 2020 to June 2024, comparing architectures (RNNs, transformers, VAEs, GANs, S4 models), molecular representations, biased generation strategies, and quality metrics from the MOSES and GuacaMol benchmarking platforms. The review addresses five research questions about architecture configuration effects, best-performing architectures, impactful hyperparameters, common molecular representations, and effective biased generation methods.</p>
<h2 id="motivation-evaluating-four-years-of-generative-clm-progress">Motivation: Evaluating Four Years of Generative CLM Progress</h2>
<p>Deep learning molecular generation has expanded rapidly since 2018, when <a href="/notes/chemistry/molecular-design/generation/latent-space/automatic-chemical-design-vae/">Gomez-Bombarelli et al.</a> and <a href="/notes/chemistry/molecular-design/generation/autoregressive/lstm-drug-like-molecule-generation/">Segler et al.</a> demonstrated that deep generative models could learn to produce novel molecules from <a href="/notes/chemistry/molecular-representations/notations/smiles/">SMILES</a> representations. By 2020, multiple architectures (RNNs, transformers, VAEs, GANs) were being applied to chemical language modeling, and benchmarking platforms like <a href="/notes/chemistry/molecular-design/generation/evaluation/molecular-sets-moses/">MOSES</a> and <a href="/notes/chemistry/molecular-design/generation/evaluation/guacamol-benchmarking-de-novo-molecular-design/">GuacaMol</a> had been introduced to enable standardized evaluation.</p>
<p>Despite this growth, existing reviews largely focused on theoretical background or drug development applications rather than systematic statistical comparison of model performance. Few studies had examined how architecture choice, training dataset size, molecular representation format, and biased learning strategies interact to affect generation quality metrics like validity, uniqueness, and novelty. This review fills that gap by restricting the analysis to papers reporting MOSES or GuacaMol metrics, enabling quantitative cross-study comparison.</p>
<h2 id="prisma-based-systematic-review-methodology">PRISMA-Based Systematic Review Methodology</h2>
<p>The review follows the Preferred Reporting Items for Systematic Review and Meta-Analysis (PRISMA) guidelines. Articles were retrieved from Scopus, Web of Science, and Google Scholar using six Boolean search queries combining terms like &ldquo;Molecule Generation,&rdquo; &ldquo;Chemical Language Models,&rdquo; &ldquo;Deep Learning,&rdquo; and specific architecture names. The search window covered January 2020 to June 2024.</p>
<h3 id="eligibility-criteria">Eligibility Criteria</h3>
<p>Papers were included if they:</p>
<ol>
<li>Were written in English</li>
<li>Explicitly presented at least two metrics of uniqueness, validity, or novelty</li>
<li>Defined these metrics consistent with MOSES or GuacaMol concepts</li>
<li>Used deep learning generative models for de novo molecule design</li>
<li>Used conventional (non-quantum) deep learning methods</li>
<li>Were published between January 2020 and June 2024</li>
</ol>
<p>This yielded 48 articles from query-based search and 25 from citation search, totaling 72 articles. Of these, 62 used CLM approaches (string-based molecular representations) and 10 used graph-based representations.</p>
<h3 id="data-collection">Data Collection</h3>
<p>For each article, the authors extracted: journal details, database name, training dataset size, molecular representation type (<a href="/notes/chemistry/molecular-representations/notations/smiles/">SMILES</a>, <a href="/notes/chemistry/molecular-representations/notations/selfies/">SELFIES</a>, InChI, <a href="/notes/chemistry/molecular-representations/notations/deepsmiles-adaptation-for-ml/">DeepSMILES</a>), architecture details (embedding length, layers, hidden units, trainable parameters, dropout, temperature, batch size, epochs, learning rate, optimizer), biased method usage (TL, RL, conditional learning), and generation metrics (validity, uniqueness, novelty, scaffold diversity, SNN, FCD).</p>
<h3 id="evaluation-metrics">Evaluation Metrics</h3>
<p>The review focuses on three core MOSES metrics:</p>
<p>$$
\text{Validity}(V_m) = \frac{\text{Valid molecules}}{\text{Molecules produced}}
$$</p>
<p>$$
\text{Uniqueness} = \frac{\text{set}(V_m)}{V_m}
$$</p>
<p>$$
\text{Novelty} = 1 - \frac{V_m \cap T_d}{V_m}
$$</p>
<p>where $V_m$ denotes valid molecules and $T_d$ the training dataset.</p>
<h2 id="architecture-distribution-and-performance-comparison">Architecture Distribution and Performance Comparison</h2>
<h3 id="architecture-trends-2020-2024">Architecture Trends (2020-2024)</h3>
<p>The review found that RNNs and transformers dominate CLM usage, with a growing trend toward transformers over time. The breakdown across 62 CLM articles: 24 RNN-based, 23 transformer-based, 16 VAE-based, 8 GAN-based, and 1 S4-based model. Among RNN variants, LSTM was the most common, followed by GRU, despite GRU having fewer trainable parameters.</p>
<p>The increase in transformer adoption is attributed to self-attention mechanisms enabling parallel computation and effective long-range dependency capture. Meanwhile, GANs and VAEs saw lower adoption rates, partly due to higher memory and time complexity and reduced ability to generate large molecules.</p>
<h3 id="molecular-representations-and-databases">Molecular Representations and Databases</h3>
<p>SMILES was used exclusively in 77.27% of CLM articles, reflecting its wide database availability and compact format. <a href="/notes/chemistry/molecular-representations/notations/selfies/">SELFIES</a>, <a href="/notes/chemistry/molecular-representations/notations/deepsmiles-adaptation-for-ml/">DeepSMILES</a>, and InChI each appeared in smaller fractions. The dominant databases were ChEMBL and ZINC (27 articles each), followed by PubChem (4 articles). Approximately 71% of reviewed articles focused on drug discovery applications.</p>
<table>
  <thead>
      <tr>
          <th>Database</th>
          <th>Molecules (millions)</th>
          <th>Representation</th>
          <th>Articles</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>ChEMBL</td>
          <td>2.4</td>
          <td>SMILES, InChI</td>
          <td>27</td>
      </tr>
      <tr>
          <td>ZINC</td>
          <td>750</td>
          <td>SMILES</td>
          <td>27</td>
      </tr>
      <tr>
          <td>PubChem</td>
          <td>115.3</td>
          <td>SMILES, InChI</td>
          <td>4</td>
      </tr>
      <tr>
          <td>COCONUT</td>
          <td>0.695</td>
          <td>SMILES, InChI</td>
          <td>1</td>
      </tr>
      <tr>
          <td>DNA-Encoded Library</td>
          <td>1,040</td>
          <td>SMILES</td>
          <td>1</td>
      </tr>
  </tbody>
</table>
<h3 id="unbiased-model-performance">Unbiased Model Performance</h3>
<p><strong>Validity</strong>: No statistically significant differences were observed across architecture families. Transformers generally achieved high validity through self-attention mechanisms that retain uncompressed sequence information. However, one transformer model (TransMol) achieved only 6.9% validity when using stochastic sampling with Gaussian noise to explore unseen chemical space. GANs showed high dispersion, with validity as low as 8.5% when learning from gene expression signatures rather than molecular structures directly.</p>
<p><strong>Uniqueness</strong>: No significant differences in median uniqueness across architectures. Transformer-based models using masked self-attention achieved near-perfect uniqueness scores. Scaffold decoration and fragment-linking approaches sometimes compromised uniqueness due to overfit-driven redundancy.</p>
<p><strong>Validity-Novelty Trade-off</strong>: The authors propose a &ldquo;Valid/Sample&rdquo; metric (Validity x Novelty) and find an inverse trend between validity and novelty (Spearman $\rho = -0.3575$, p-value = 0.0618). Only 17.9% of models achieved above-median values for both validity (95.6%) and novelty (96.5%) simultaneously. SELFIES-based models achieve 100% validity by construction, which can help address this trade-off.</p>
<h3 id="biased-model-performance">Biased Model Performance</h3>
<p>The review examines three biased generation strategies:</p>
<p><strong>Transfer Learning (TL)</strong>: The most prevalent biased method, used across all architecture types. Fine-tuning transfers pre-trained parameters to a target model, requiring significantly fewer training molecules (median ~2,507 vs. ~1.1M for unbiased). TL does not significantly affect validity (p = 0.16) or novelty (p = 0.84), but uniqueness decreases significantly (median 90.2% vs. 97.9%, p = 0.014), likely due to overfitting on small target datasets.</p>
<table>
  <thead>
      <tr>
          <th>Metric</th>
          <th>Unbiased (median)</th>
          <th>TL Target (median)</th>
          <th>p-value</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>Training size</td>
          <td>1,128,920</td>
          <td>2,507</td>
          <td>&lt;0.0001</td>
      </tr>
      <tr>
          <td>Validity</td>
          <td>98.05%</td>
          <td>95.5%</td>
          <td>0.1602</td>
      </tr>
      <tr>
          <td>Uniqueness</td>
          <td>97.9%</td>
          <td>90.2%</td>
          <td>0.0144</td>
      </tr>
      <tr>
          <td>Novelty</td>
          <td>91.6%</td>
          <td>96.0%</td>
          <td>0.8438</td>
      </tr>
  </tbody>
</table>
<p><strong>Reinforcement Learning (RL)</strong>: Applied only to RNNs and transformers in the reviewed set. 90.1% of RL implementations used policy gradient methods with scoring functions for properties like synthesizability, binding affinity, and membrane permeability. No significant effects on generation metrics were observed.</p>
<table>
  <thead>
      <tr>
          <th>Metric</th>
          <th>Unbiased (median)</th>
          <th>RL Target (median)</th>
          <th>p-value</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>Validity</td>
          <td>91.1%</td>
          <td>96.5%</td>
          <td>0.1289</td>
      </tr>
      <tr>
          <td>Uniqueness</td>
          <td>99.9%</td>
          <td>89.7%</td>
          <td>0.0935</td>
      </tr>
      <tr>
          <td>Novelty</td>
          <td>91.5%</td>
          <td>93.5%</td>
          <td>0.2500</td>
      </tr>
  </tbody>
</table>
<p><strong>Conditional Learning (CL)</strong>: Integrates domain-specific data (properties, bioactivities, functional groups) directly into training via constraint tokens or property embeddings. Used primarily with encoder-decoder architectures (ARAEs, VAEs, transformers). CL does not significantly degrade generation metrics relative to unbiased models.</p>
<table>
  <thead>
      <tr>
          <th>Metric</th>
          <th>Unbiased (median)</th>
          <th>CL Target (median)</th>
          <th>p-value</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>Validity</td>
          <td>98.5%</td>
          <td>96.8%</td>
          <td>0.4648</td>
      </tr>
      <tr>
          <td>Uniqueness</td>
          <td>99.9%</td>
          <td>97.5%</td>
          <td>0.0753</td>
      </tr>
      <tr>
          <td>Novelty</td>
          <td>89.3%</td>
          <td>99.6%</td>
          <td>0.2945</td>
      </tr>
  </tbody>
</table>
<h2 id="key-findings-and-directions-for-chemical-language-models">Key Findings and Directions for Chemical Language Models</h2>
<h3 id="main-conclusions">Main Conclusions</h3>
<ol>
<li>
<p><strong>Transformers are overtaking RNNs</strong> as the dominant CLM architecture, driven by self-attention mechanisms that capture long-range dependencies without the gradient vanishing issues of recurrent models.</p>
</li>
<li>
<p><strong>SMILES remains dominant</strong> (77% of models) despite known limitations (non-uniqueness, syntax errors). SELFIES shows promise for improving the validity-novelty trade-off.</p>
</li>
<li>
<p><strong>No architecture achieves both high validity and high novelty easily.</strong> Only 17.9% of unbiased models exceeded medians for both metrics simultaneously, highlighting a fundamental tension in generative chemistry.</p>
</li>
<li>
<p><strong>Transfer learning requires only ~2,500 molecules</strong> to generate targeted compounds, compared to ~1.1M for unbiased training, but at the cost of reduced uniqueness.</p>
</li>
<li>
<p><strong>Combining biased methods</strong> (e.g., TL + RL, CL + TL) shows promise for multi-objective optimization and exploring distant regions of chemical space.</p>
</li>
<li>
<p><strong><a href="/notes/chemistry/molecular-design/generation/autoregressive/s4-chemical-language-modeling/">S4 models</a></strong> were newly introduced for CLMs in 2023, showing competitive performance with the dual nature of convolution during training and recurrent generation.</p>
</li>
</ol>
<h3 id="limitations">Limitations</h3>
<p>The review is restricted to papers reporting MOSES or GuacaMol metrics, which excludes many molecular generation studies that use alternative evaluation frameworks. The statistical comparisons rely on median values reported across different experimental settings, making direct architecture comparisons approximate. Graph-based approaches are included only for coarse comparison (10 of 72 articles) and are not the focus of the analysis.</p>
<hr>
<h2 id="reproducibility-details">Reproducibility Details</h2>
<h3 id="data">Data</h3>
<p>This is a systematic review, so no new models were trained. The authors collected metadata from 72 published articles. No datasets were generated or analyzed beyond the literature corpus.</p>
<h3 id="algorithms">Algorithms</h3>
<p>Statistical comparisons used Mann-Whitney U tests for paired samples. Spearman correlation was used to assess the validity-novelty relationship. Outlier identification used the Valid/Sample (Validity x Novelty) metric with box plot analysis.</p>
<h3 id="evaluation">Evaluation</h3>
<p>The review evaluates models using MOSES metrics: validity, uniqueness, novelty, scaffold diversity, scaffold novelty, fragment similarity, SNN, internal diversity, and <a href="/notes/chemistry/molecular-design/generation/evaluation/frechet-chemnet-distance/">FCD</a>. Statistical tests were applied to compare medians across architecture families and between biased and unbiased models.</p>
<h3 id="hardware">Hardware</h3>
<p>Not applicable (systematic review, no model training performed).</p>
<hr>
<h2 id="paper-information">Paper Information</h2>
<p><strong>Citation</strong>: Flores-Hernandez, H., &amp; Martínez-Ledesma, E. (2024). A systematic review of deep learning chemical language models in recent era. <em>Journal of Cheminformatics</em>, 16(1), 129. <a href="https://doi.org/10.1186/s13321-024-00916-y">https://doi.org/10.1186/s13321-024-00916-y</a></p>
<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">@article</span>{floreshernandez2024systematic,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">title</span>=<span style="color:#e6db74">{A systematic review of deep learning chemical language models in recent era}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">author</span>=<span style="color:#e6db74">{Flores-Hernandez, Hector and Mart{\&#39;i}nez-Ledesma, Emmanuel}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">journal</span>=<span style="color:#e6db74">{Journal of Cheminformatics}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">volume</span>=<span style="color:#e6db74">{16}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">number</span>=<span style="color:#e6db74">{1}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">pages</span>=<span style="color:#e6db74">{129}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">year</span>=<span style="color:#e6db74">{2024}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">publisher</span>=<span style="color:#e6db74">{BioMed Central}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">doi</span>=<span style="color:#e6db74">{10.1186/s13321-024-00916-y}</span>
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div>]]></content:encoded></item><item><title>Survey of Transformer Architectures in Molecular Science</title><link>https://hunterheidenreich.com/notes/chemistry/molecular-representations/encoders/transformers-molecular-science-review/</link><pubDate>Thu, 26 Mar 2026 00:00:00 +0000</pubDate><guid>https://hunterheidenreich.com/notes/chemistry/molecular-representations/encoders/transformers-molecular-science-review/</guid><description>A comprehensive review of 12 transformer architectures applied to molecular science, covering GPT, BERT, BART, graph transformers, and more.</description><content:encoded><![CDATA[<h2 id="a-systematization-of-transformer-architectures-for-molecular-science">A Systematization of Transformer Architectures for Molecular Science</h2>
<p>This paper is a <strong>Systematization</strong> review. It organizes and taxonomizes 12 families of transformer architectures that have been applied across molecular science, including chemistry, biology, and drug discovery. The primary contribution is not a new method or dataset, but a structured technical overview of the algorithmic internals of each transformer variant and their specific applications to molecular problems. The review covers 201 references and provides a unified treatment of how these architectures capture molecular patterns from sequential, graphical, and image-based data.</p>
<h2 id="bridging-the-gap-between-transformer-variants-and-molecular-applications">Bridging the Gap Between Transformer Variants and Molecular Applications</h2>
<p>Transformer-based models have become widespread in molecular science, yet the authors identify a gap: there is no organized taxonomy linking these diverse techniques in the existing literature. Individual papers introduce specific architectures or applications, but practitioners lack a unified reference that explains the technical differences between GPT, BERT, BART, graph transformers, and other variants in the context of molecular data. The review aims to fill this gap by providing an in-depth investigation of the algorithmic components of each model family, explaining how their architectural innovations contribute to processing complex molecular data. The authors note that the success of transformers in molecular science stems from several factors: the sequential nature of chemical and biological molecules (DNA, RNA, proteins, SMILES strings), the attention mechanism&rsquo;s ability to capture long-range dependencies within molecular structures, and the capacity for transfer learning through pre-training on large chemical and biological datasets.</p>
<h2 id="twelve-transformer-families-and-their-molecular-mechanisms">Twelve Transformer Families and Their Molecular Mechanisms</h2>
<p>The review covers transformer preliminaries before diving into 12 specific architecture families. The core self-attention mechanism computes:</p>
<p>$$
\text{Attention}(Q, K, V) = \text{softmax}\left(\frac{QK^T}{\sqrt{d_k}}\right)V
$$</p>
<p>where $d_k$ is the dimension of the key vectors. The position-wise feed-forward network is:</p>
<p>$$
\text{FFN}(x) = \max(0, xW_1 + b_1)W_2 + b_2
$$</p>
<p>The 12 architecture families covered are:</p>
<ol>
<li>
<p><strong>GPT (Generative Pre-trained Transformer)</strong>: Uses the decoder part of the transformer for autoregressive generation. Applications include MolGPT for molecular generation, DrugGPT for protein-ligand binding, and cMolGPT for target-specific de novo molecular generation.</p>
</li>
<li>
<p><strong>BERT (Bidirectional Encoder Representations from Transformers)</strong>: Uses transformer encoders with masked language modeling and next-sentence prediction for pre-training. Molecular applications include FP-BERT for molecular property prediction using composite fingerprint representations, Graph-BERT for protein-protein interaction identification, SMILES-BERT, and Mol-BERT.</p>
</li>
<li>
<p><strong>BART (Bidirectional and Auto-Regressive Transformers)</strong>: Functions as a denoising autoencoder with both encoder and decoder. Molecular applications include Chemformer for sequence-to-sequence chemistry tasks, MS2Mol for mass spectrometry analysis, and MolBART for molecular feature learning.</p>
</li>
<li>
<p><strong>Graph Transformer</strong>: Leverages self-attention on graph-structured data to capture global context. Applications include GraphSite for protein-DNA binding site prediction (using AlphaFold2 structure predictions), KPGT for knowledge-guided molecular graph pre-training, and PAGTN for establishing long-range dependencies in molecular graphs.</p>
</li>
<li>
<p><strong>Transformer-XL</strong>: Incorporates relative positional encoding for modeling long sequences. Used for small molecule retention time prediction, drug design with CHEMBL data (1.27 million molecules), and Heck reaction generation.</p>
</li>
<li>
<p><strong><a href="/notes/natural-language-processing/language-models/t5-text-to-text-transfer-transformer/">T5 (Text-to-Text Transfer Transformer)</a></strong>: Unifies NLP tasks into text-to-text mapping. T5Chem was pre-trained on 97 million molecules from PubChem and achieved 99.5% accuracy on reaction classification (USPTO 500 MT). C5T5 uses IUPAC naming for molecular optimization in drug discovery.</p>
</li>
<li>
<p><strong>Vision Transformer (ViT)</strong>: Applies transformer architecture to image patches. Used for organic molecule classification (97% accuracy with WGAN-generated data), bacterial identification via SERS, and molecular property prediction from mass spectrometry data (TransG-Net).</p>
</li>
<li>
<p><strong>DETR (Detection Transformer)</strong>: End-to-end object detection using transformers. Applied to cryo-EM particle picking (TransPicker), molecular structure image recognition (IMG2SMI), and cell segmentation (Cell-DETR).</p>
</li>
<li>
<p><strong>Conformer</strong>: Integrates convolutional modules into transformer structure. Used for DNA storage error correction (RRCC-DNN), drug-target affinity prediction (NG-DTA with Davis and Kiba datasets).</p>
</li>
<li>
<p><strong>CLIP (Contrastive Language-Image Pre-training)</strong>: Multimodal learning linking text and images. Applied to peptide design (Cut&amp;CLIP for protein degradation), gene identification (pathCLIP), and drug discovery (CLOOME for zero-shot transfer learning).</p>
</li>
<li>
<p><strong>Sparse Transformers</strong>: Use sparse attention matrices to reduce complexity to $O(n\sqrt{n})$. Applied to drug-target interaction prediction with gated cross-attention mechanisms.</p>
</li>
<li>
<p><strong>Mobile and Efficient Transformers</strong>: Compressed variants (TinyBERT, MobileBERT) for resource-constrained environments. Molormer uses ProbSparse self-attention for drug-drug interaction prediction. LOGO is a lightweight pre-trained language model for non-coding genome interpretation.</p>
</li>
</ol>
<h2 id="survey-organization-and-coverage-of-molecular-domains">Survey Organization and Coverage of Molecular Domains</h2>
<p>As a survey paper, this work does not present new experiments. Instead, it catalogues existing applications across multiple molecular domains:</p>
<p><strong>Drug Discovery and Design</strong>: GPT-based ligand design (DrugGPT), BART-based molecular generation (Chemformer, MolBART), graph transformer pre-training for molecular property prediction (KPGT), T5-based chemical reaction prediction (T5Chem), and sparse transformer methods for drug-target interactions.</p>
<p><strong>Protein Science</strong>: BERT-based protein-protein interaction prediction (Graph-BERT), graph transformer methods for protein-DNA binding (GraphSite with AlphaFold2 integration), conformer-based drug-target affinity prediction (NG-DTA), and CLIP-based peptide design (Cut&amp;CLIP).</p>
<p><strong>Molecular Property Prediction</strong>: FP-BERT for fingerprint-based prediction, SMILES-BERT and Mol-BERT for end-to-end prediction from SMILES, KPGT for knowledge-guided graph pre-training, and Transformer-XL for property modeling with relative positional encoding.</p>
<p><strong>Structural Biology</strong>: DETR-based cryo-EM particle picking (TransPicker), vision transformer applications in cell imaging, and Cell-DETR for instance segmentation in microscopy.</p>
<p><strong>Genomics</strong>: Conformer-based DNA storage error correction (RRCC-DNN), LOGO for non-coding genome interpretation, and MetaTransformer for metagenomic sequencing analysis.</p>
<h2 id="future-directions-and-limitations-of-the-survey">Future Directions and Limitations of the Survey</h2>
<p>The review concludes with four future directions:</p>
<ol>
<li>
<p><strong>ChatGPT integration into molecular science</strong>: Using LLMs for data analysis, literature review, and hypothesis generation in chemistry and biology.</p>
</li>
<li>
<p><strong>Multifunction transformers</strong>: Models that extract features across diverse molecular structures and sequences simultaneously.</p>
</li>
<li>
<p><strong>Molecular-aware transformers</strong>: Architectures that handle multiple data types (text, sequence, structure, image, energy, molecular dynamics, function) in a unified framework.</p>
</li>
<li>
<p><strong>Self-assessment transformers and superintelligence</strong>: Speculative discussion of models that learn from seemingly unrelated data sources.</p>
</li>
</ol>
<p>The review has several limitations worth noting. The coverage is broad but shallow: each architecture family receives only 1-2 pages of discussion, and the paper largely describes existing work rather than critically evaluating it. The review does not systematically compare the architectures against each other on common benchmarks. The future directions section (particularly the superintelligence discussion) is speculative and lacks concrete proposals. The paper also focuses primarily on technical architecture descriptions rather than analyzing failure modes, scalability challenges, or reproducibility concerns across the surveyed methods. As a review article, no new data were created or analyzed.</p>
<hr>
<h2 id="reproducibility-details">Reproducibility Details</h2>
<h3 id="data">Data</h3>
<p>This is a survey paper. No new datasets were created or used. The paper reviews applications involving datasets such as PubChem (97 million molecules for T5Chem), CHEMBL (1.27 million molecules for Transformer-XL drug design), USPTO 500 MT (reaction classification), ESOL (5,328 molecules for property prediction), and Davis/Kiba (drug-target affinity).</p>
<h3 id="algorithms">Algorithms</h3>
<p>No new algorithms are introduced. The paper provides mathematical descriptions of the core transformer components (self-attention, positional encoding, feed-forward networks, layer normalization) and describes how 12 architecture families modify these components.</p>
<h3 id="models">Models</h3>
<p>No new models are presented. The paper surveys existing models including MolGPT, DrugGPT, FP-BERT, SMILES-BERT, Chemformer, MolBART, GraphSite, KPGT, T5Chem, TransPicker, Cell-DETR, CLOOME, and Molormer, among others.</p>
<h3 id="evaluation">Evaluation</h3>
<p>No new evaluation is performed. Performance numbers cited from the literature include: T5Chem reaction classification accuracy of 99.5%, ViT organic molecule classification at 97%, Transformer-XL property prediction RMSE of 0.6 on ESOL, and Heck reaction generation feasibility rate of 47.76%.</p>
<h3 id="hardware">Hardware</h3>
<p>No hardware requirements are specified, as this is a survey paper.</p>
<table>
  <thead>
      <tr>
          <th>Artifact</th>
          <th>Type</th>
          <th>License</th>
          <th>Notes</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td><a href="https://onlinelibrary.wiley.com/doi/pdfdirect/10.1002/wcms.1725">Paper (open access)</a></td>
          <td>Paper</td>
          <td>CC-BY-NC-ND</td>
          <td>Open access via Wiley</td>
      </tr>
  </tbody>
</table>
<hr>
<h2 id="paper-information">Paper Information</h2>
<p><strong>Citation</strong>: Jiang, J., Ke, L., Chen, L., Dou, B., Zhu, Y., Liu, J., Zhang, B., Zhou, T., &amp; Wei, G.-W. (2024). Transformer technology in molecular science. <em>WIREs Computational Molecular Science</em>, 14(4), e1725. <a href="https://doi.org/10.1002/wcms.1725">https://doi.org/10.1002/wcms.1725</a></p>
<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">@article</span>{jiang2024transformer,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">title</span>=<span style="color:#e6db74">{Transformer technology in molecular science}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">author</span>=<span style="color:#e6db74">{Jiang, Jian and Ke, Lu and Chen, Long and Dou, Bozheng and Zhu, Yueying and Liu, Jie and Zhang, Bengong and Zhou, Tianshou and Wei, Guo-Wei}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">journal</span>=<span style="color:#e6db74">{WIREs Computational Molecular Science}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">volume</span>=<span style="color:#e6db74">{14}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">number</span>=<span style="color:#e6db74">{4}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">pages</span>=<span style="color:#e6db74">{e1725}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">year</span>=<span style="color:#e6db74">{2024}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">publisher</span>=<span style="color:#e6db74">{Wiley}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">doi</span>=<span style="color:#e6db74">{10.1002/wcms.1725}</span>
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div>]]></content:encoded></item><item><title>SPMM: A Bidirectional Molecular Foundation Model</title><link>https://hunterheidenreich.com/notes/chemistry/molecular-representations/multimodal/spmm-bidirectional-structure-property/</link><pubDate>Thu, 26 Mar 2026 00:00:00 +0000</pubDate><guid>https://hunterheidenreich.com/notes/chemistry/molecular-representations/multimodal/spmm-bidirectional-structure-property/</guid><description>SPMM is a multimodal molecular foundation model that aligns SMILES structures with property vectors for bidirectional generation and prediction tasks.</description><content:encoded><![CDATA[<h2 id="a-multimodal-foundation-model-for-structure-property-comprehension">A Multimodal Foundation Model for Structure-Property Comprehension</h2>
<p>This is a <strong>Method</strong> paper that introduces the Structure-Property Multi-Modal foundation model (SPMM), a transformer-based architecture that treats SMILES strings and molecular property vectors (PVs) as two separate modalities and learns to align them in a shared embedding space. The primary contribution is enabling bidirectional generation through a single pre-trained model: given a property vector, SPMM can generate molecules (inverse-QSAR), and given a SMILES string, it can predict all 53 properties simultaneously. The model also transfers to unimodal downstream tasks including MoleculeNet benchmarks and reaction prediction.</p>
<h2 id="bridging-the-gap-between-molecular-structure-and-properties">Bridging the Gap Between Molecular Structure and Properties</h2>
<p>Existing chemical pre-trained models typically learn representations from a single modality (SMILES, graphs, or fingerprints) and fine-tune for specific downstream tasks. While some approaches have attempted multimodal learning by combining SMILES with graph representations or InChI strings, these modalities encode nearly identical structural information, limiting the potential for emergent cross-modal knowledge.</p>
<p>The key gap SPMM addresses is the lack of multimodal pre-training that incorporates genuinely complementary modalities. Prior conditional molecule generation methods could typically control only a small number of properties simultaneously and required retraining when target properties changed. The authors draw on successes in vision-language pre-training (VLP), where aligning image and text modalities has enabled rich bidirectional understanding, and apply similar ideas to molecular structure and property domains.</p>
<h2 id="treating-property-vectors-as-a-language">Treating Property Vectors as a Language</h2>
<p>The core innovation in SPMM is treating a collection of 53 RDKit-computed molecular properties as a &ldquo;language&rdquo; where each property value is analogous to a word token. This design allows the model to attend to individual properties independently rather than treating the entire property vector as a single fixed-length condition.</p>
<h3 id="dual-stream-architecture">Dual-Stream Architecture</h3>
<p>SPMM follows the dual-stream VLP architecture. The model has three components:</p>
<ol>
<li><strong>SMILES Encoder</strong>: 6 BERT-base layers that encode tokenized SMILES (using a 300-subword BPE vocabulary) via self-attention</li>
<li><strong>PV Encoder</strong>: 6 BERT-base layers that encode the 53 normalized property values (each passed through a linear layer) with learnable positional embeddings</li>
<li><strong>Fusion Encoder</strong>: 6 BERT-base layers with cross-attention that combines both modalities, using one modality&rsquo;s features as queries and the other as keys/values</li>
</ol>
<h3 id="pre-training-objectives">Pre-training Objectives</h3>
<p>The model is pre-trained with four complementary losses:</p>
<p><strong>Contrastive Learning</strong> aligns SMILES and PV features in a shared embedding space. For [CLS] token outputs $\mathbf{S}_{cls}$ and $\mathbf{P}_{cls}$:</p>
<p>$$
\text{sim}(\mathbf{S}, \mathbf{P}) = \left(h_{S}(\mathbf{S}_{cls})\right)^{\top} h_{P}(\mathbf{P}_{cls})
$$</p>
<p>The intermodal similarities are computed with a learnable temperature $\tau$:</p>
<p>$$
s_{s2p} = \frac{\exp(\text{sim}(\mathbf{S}, \mathbf{P}) / \tau)}{\sum_{n=1}^{N} \exp(\text{sim}(\mathbf{S}, \mathbf{P}_{n}) / \tau)}
$$</p>
<p>The contrastive loss uses cross-entropy with one-hot labels (1 for same-molecule pairs):</p>
<p>$$
L_{\text{contrastive}} = \frac{1}{2}\left(H(y_{s2p}, s_{s2p}) + H(y_{p2s}, s_{p2s}) + H(y_{s2s}, s_{s2s}) + H(y_{p2p}, s_{p2p})\right)
$$</p>
<p><strong>Next Word Prediction (NWP)</strong> trains autoregressive SMILES generation conditioned on the PV:</p>
<p>$$
L_{NWP} = \sum_{i=1}^{n} H\left(y_{n}^{NWP}, p^{NWP}(s_{n} \mid s_{0:n-1}, \mathbf{P})\right)
$$</p>
<p><strong>Next Property Prediction (NPP)</strong> applies the same autoregressive concept to property values, using mean-square-error loss:</p>
<p>$$
L_{NPP} = \sum_{i=1}^{n} \left(p_{n} - \hat{p}_{n}(p_{0:n-1}, \mathbf{S})\right)^{2}
$$</p>
<p><strong>SMILES-PV Matching (SPM)</strong> is a binary classification loss predicting whether a SMILES-PV pair originated from the same molecule, trained with hard-negative mining.</p>
<p>The overall pre-training loss combines all four:</p>
<p>$$
L = \widetilde{L}_{\text{contrastive}} + \widetilde{L}_{NWP} + L_{NPP} + L_{SPM}
$$</p>
<p>where tildes indicate the use of momentum teacher distillation to soften one-hot labels, acknowledging that multiple valid SMILES-PV pairings may exist.</p>
<h3 id="random-property-masking">Random Property Masking</h3>
<p>During pre-training, 50% of property values are randomly replaced with a special [UNK] token. This serves three purposes: preventing overfitting to specific properties, augmenting data, and enabling flexible inference where users can specify any subset of the 53 properties as generation conditions. The model can handle all $2^{53}$ possible property combinations at inference time despite never seeing most of them during training.</p>
<h2 id="experiments-across-bidirectional-and-unimodal-tasks">Experiments Across Bidirectional and Unimodal Tasks</h2>
<h3 id="pv-to-smiles-generation-conditional-molecule-design">PV-to-SMILES Generation (Conditional Molecule Design)</h3>
<p>The authors evaluate SPMM on multiple generation scenarios using 1000 unseen PubChem PVs:</p>
<table>
  <thead>
      <tr>
          <th>Sampling</th>
          <th>Input PV</th>
          <th>Validity</th>
          <th>Uniqueness</th>
          <th>Novelty</th>
          <th>Norm. RMSE</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>Deterministic</td>
          <td>1000 unseen PVs</td>
          <td>0.995</td>
          <td>0.999</td>
          <td>0.961</td>
          <td>0.216</td>
      </tr>
      <tr>
          <td>Stochastic</td>
          <td>Full PV (molecule 1)</td>
          <td>0.974</td>
          <td>0.905</td>
          <td>0.998</td>
          <td>0.185</td>
      </tr>
      <tr>
          <td>Stochastic</td>
          <td>Molar mass = 150</td>
          <td>0.974</td>
          <td>0.945</td>
          <td>0.872</td>
          <td>0.192</td>
      </tr>
      <tr>
          <td>Stochastic</td>
          <td>4 properties controlled</td>
          <td>0.998</td>
          <td>0.981</td>
          <td>0.952</td>
          <td>0.257</td>
      </tr>
      <tr>
          <td>Stochastic</td>
          <td>No control (all [UNK])</td>
          <td>0.971</td>
          <td>0.991</td>
          <td>0.950</td>
          <td>-</td>
      </tr>
  </tbody>
</table>
<p>The normalized RMSE of 0.216 across 53 properties indicates that generated molecules closely match the input property conditions. The model can also perform unconditional generation (all properties masked) where outputs follow the pre-training distribution. The authors report that SPMM outperforms benchmark models including MolGAN, GraphVAE, and scaffold-based graph generative models in both conditional and unconditional settings (Supplementary Table 1).</p>
<h3 id="smiles-to-pv-generation-multi-property-prediction">SMILES-to-PV Generation (Multi-Property Prediction)</h3>
<p>When given 1000 unseen ZINC15 molecules, SPMM predicts all 53 properties autoregressively with a mean $r^{2}$ of 0.924 across all properties.</p>
<h3 id="moleculenet-benchmarks">MoleculeNet Benchmarks</h3>
<p>Using only the SMILES encoder (6 BERT layers), SPMM achieves best or competitive performance on 9 <a href="/notes/chemistry/molecular-design/property-prediction/moleculenet-benchmark-molecular-ml/">MoleculeNet</a> tasks:</p>
<table>
  <thead>
      <tr>
          <th>Dataset</th>
          <th>Metric</th>
          <th>SPMM</th>
          <th>Best Baseline</th>
          <th>Baseline Model</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>ESOL</td>
          <td>RMSE</td>
          <td>0.817</td>
          <td>0.798</td>
          <td>ChemRL-GEM</td>
      </tr>
      <tr>
          <td>LIPO</td>
          <td>RMSE</td>
          <td>0.681</td>
          <td>0.660</td>
          <td>ChemRL-GEM</td>
      </tr>
      <tr>
          <td>FreeSolv</td>
          <td>RMSE</td>
          <td>1.868</td>
          <td>1.877</td>
          <td>ChemRL-GEM</td>
      </tr>
      <tr>
          <td>BACE (reg)</td>
          <td>RMSE</td>
          <td>1.041</td>
          <td>1.047</td>
          <td><a href="/notes/chemistry/molecular-representations/encoders/molformer/">MolFormer</a></td>
      </tr>
      <tr>
          <td>Clearance</td>
          <td>RMSE</td>
          <td>42.607</td>
          <td>43.175</td>
          <td>MolFormer</td>
      </tr>
      <tr>
          <td>BBBP</td>
          <td>AUROC</td>
          <td>75.1%</td>
          <td>73.6%</td>
          <td>MolFormer</td>
      </tr>
      <tr>
          <td>BACE (cls)</td>
          <td>AUROC</td>
          <td>84.4%</td>
          <td>86.3%</td>
          <td>MolFormer</td>
      </tr>
      <tr>
          <td>ClinTox</td>
          <td>AUROC</td>
          <td>92.7%</td>
          <td>91.2%</td>
          <td>MolFormer</td>
      </tr>
      <tr>
          <td>SIDER</td>
          <td>AUROC</td>
          <td>66.9%</td>
          <td>67.2%</td>
          <td>ChemRL-GEM</td>
      </tr>
  </tbody>
</table>
<p>SPMM achieved best performance on 5 of 9 tasks, with notable gains on BBBP (75.1% vs. 73.6%) and ClinTox (92.7% vs. 91.2%). Without pre-training, all scores dropped substantially.</p>
<h3 id="dili-classification">DILI Classification</h3>
<p>On Drug-Induced Liver Injury prediction, SPMM achieved 92.6% AUROC, outperforming the 5-ensemble model of Ai et al. (90.4% AUROC) while using a single model.</p>
<h3 id="reaction-prediction">Reaction Prediction</h3>
<p>On USPTO-480k forward reaction prediction, SPMM achieved 91.5% top-1 accuracy, the highest among all models tested (including <a href="/notes/chemistry/molecular-design/generation/autoregressive/chemformer/">Chemformer</a> at 91.3%). On USPTO-50k retro-reaction prediction, SPMM reached 53.4% top-1 accuracy, second only to Chemformer (54.3%) among string-based models.</p>
<h2 id="bidirectional-generation-from-a-single-pre-trained-model">Bidirectional Generation From a Single Pre-trained Model</h2>
<p>SPMM demonstrates that multimodal pre-training with genuinely complementary modalities (structure and properties, rather than structurally redundant representations) enables a single foundation model to handle both generation directions and downstream unimodal tasks. Key findings include:</p>
<ol>
<li><strong>Flexible conditional generation</strong>: The [UNK] masking strategy allows controlling any subset of 53 properties at inference time without retraining, a capability not demonstrated by prior methods.</li>
<li><strong>Interpretable cross-attention</strong>: Attention visualizations show that the model learns chemically meaningful structure-property relationships (e.g., hydrogen bonding properties attend to oxygen and nitrogen atoms; ring count properties attend to ring tokens).</li>
<li><strong>Competitive unimodal transfer</strong>: Despite using only 6 BERT layers and 50M pre-training molecules (smaller than <a href="/notes/chemistry/molecular-representations/encoders/chemberta-2/">ChemBERTa-2</a>&rsquo;s 77M or Chemformer&rsquo;s 100M), the SMILES encoder alone achieves best or second-best results on 5 of 9 MoleculeNet tasks and the highest forward reaction prediction accuracy among tested models.</li>
</ol>
<h3 id="limitations">Limitations</h3>
<p>The authors acknowledge several limitations:</p>
<ul>
<li><strong>SMILES representation constraints</strong>: Implicit connectivity information in SMILES means small structural changes can cause drastic string changes. Graph representations could be a complementary alternative.</li>
<li><strong>Stereochemistry blindness</strong>: All 53 RDKit properties used are invariant to stereochemistry, meaning different stereoisomers produce identical PVs. The contrastive loss then forces their SMILES encoder outputs to converge, which the authors identify as the primary factor limiting MoleculeNet performance on stereo-sensitive tasks.</li>
<li><strong>No wet-lab validation</strong>: Generated molecules and predicted properties are not experimentally verified.</li>
</ul>
<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>Pre-training</td>
          <td>PubChem</td>
          <td>50M molecules</td>
          <td>SMILES + 53 RDKit properties</td>
      </tr>
      <tr>
          <td>Property prediction</td>
          <td>MoleculeNet (9 tasks)</td>
          <td>642-4200 per task</td>
          <td>Scaffold split via DeepChem (8:1:1)</td>
      </tr>
      <tr>
          <td>DILI classification</td>
          <td>Ai et al. dataset</td>
          <td>Not specified</td>
          <td>Following published preparation</td>
      </tr>
      <tr>
          <td>Forward reaction</td>
          <td>USPTO-480k</td>
          <td>479,035 pairs</td>
          <td>Reactant-product pairs</td>
      </tr>
      <tr>
          <td>Retro reaction</td>
          <td>USPTO-50k</td>
          <td>50,037 pairs</td>
          <td>Product-reactant pairs, no reaction types used</td>
      </tr>
      <tr>
          <td>SMILES-to-PV test</td>
          <td>ZINC15</td>
          <td>1000 molecules</td>
          <td>Not in pre-training set</td>
      </tr>
  </tbody>
</table>
<h3 id="algorithms">Algorithms</h3>
<ul>
<li><strong>Tokenization</strong>: BPE with 300-subword dictionary</li>
<li><strong>Property masking</strong>: 50% random replacement with [UNK] during pre-training</li>
<li><strong>Momentum distillation</strong>: EMA parameter $\lambda = 0.995$, soft-label mixing $\alpha$ linearly warmed from 0 to 0.4 over first epoch</li>
<li><strong>Contrastive queue</strong>: Size $k = 24{,}576$ for storing recent SMILES and PV instances</li>
<li><strong>Beam search</strong>: $k = 2$ for PV-to-SMILES generation</li>
<li><strong>SMILES augmentation</strong>: Random non-canonical augmentation with probability 0.5 for reaction tasks</li>
</ul>
<h3 id="models">Models</h3>
<ul>
<li><strong>Architecture</strong>: 6 BERT-base encoder layers each for SMILES encoder, PV encoder, and fusion encoder (18 total layers)</li>
<li><strong>Vocabulary</strong>: 300 BPE subwords for SMILES; 53 property tokens for PV</li>
<li><strong>Pre-trained weights</strong>: Available via GitHub</li>
</ul>
<h3 id="evaluation">Evaluation</h3>
<table>
  <thead>
      <tr>
          <th>Task</th>
          <th>Metric</th>
          <th>Value</th>
          <th>Notes</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>PV-to-SMILES (deterministic)</td>
          <td>Validity</td>
          <td>99.5%</td>
          <td>1000 unseen PubChem PVs</td>
      </tr>
      <tr>
          <td>PV-to-SMILES (deterministic)</td>
          <td>Normalized RMSE</td>
          <td>0.216</td>
          <td>Across 53 properties</td>
      </tr>
      <tr>
          <td>SMILES-to-PV</td>
          <td>Mean $r^{2}$</td>
          <td>0.924</td>
          <td>1000 ZINC15 molecules</td>
      </tr>
      <tr>
          <td>Forward reaction (USPTO-480k)</td>
          <td>Top-1 accuracy</td>
          <td>91.5%</td>
          <td>Best among all tested models</td>
      </tr>
      <tr>
          <td>Retro reaction (USPTO-50k)</td>
          <td>Top-1 accuracy</td>
          <td>53.4%</td>
          <td>Second-best string-based</td>
      </tr>
      <tr>
          <td>DILI classification</td>
          <td>AUROC</td>
          <td>92.6%</td>
          <td>Single model vs. 5-ensemble</td>
      </tr>
  </tbody>
</table>
<h3 id="hardware">Hardware</h3>
<ul>
<li><strong>Pre-training</strong>: 8 NVIDIA A100 GPUs, approximately 52,000 batch iterations, roughly 12 hours</li>
<li><strong>Batch size</strong>: 96</li>
<li><strong>Optimizer</strong>: AdamW with weight decay 0.02</li>
<li><strong>Learning rate</strong>: Warmed up to $10^{-4}$, cosine decay to $10^{-5}$</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/jinhojsk515/SPMM">SPMM Source Code</a></td>
          <td>Code</td>
          <td>Apache-2.0</td>
          <td>Official implementation with experimental scripts</td>
      </tr>
      <tr>
          <td><a href="https://doi.org/10.5281/zenodo.10567599">SPMM Zenodo Archive</a></td>
          <td>Code</td>
          <td>Apache-2.0</td>
          <td>Archived version for reproducibility</td>
      </tr>
      <tr>
          <td><a href="https://pubchem.ncbi.nlm.nih.gov/">PubChem</a></td>
          <td>Dataset</td>
          <td>Public domain</td>
          <td>50M molecules for pre-training</td>
      </tr>
      <tr>
          <td><a href="https://moleculenet.org/">MoleculeNet</a></td>
          <td>Dataset</td>
          <td>Varies</td>
          <td>Benchmark datasets via DeepChem</td>
      </tr>
  </tbody>
</table>
<hr>
<h2 id="paper-information">Paper Information</h2>
<p><strong>Citation</strong>: Chang, J., &amp; Ye, J. C. (2024). Bidirectional generation of structure and properties through a single molecular foundation model. <em>Nature Communications</em>, 15, 2323. <a href="https://doi.org/10.1038/s41467-024-46440-3">https://doi.org/10.1038/s41467-024-46440-3</a></p>
<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">@article</span>{chang2024bidirectional,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">title</span>=<span style="color:#e6db74">{Bidirectional generation of structure and properties through a single molecular foundation model}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">author</span>=<span style="color:#e6db74">{Chang, Jinho and Ye, Jong Chul}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">journal</span>=<span style="color:#e6db74">{Nature Communications}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">volume</span>=<span style="color:#e6db74">{15}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">pages</span>=<span style="color:#e6db74">{2323}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">year</span>=<span style="color:#e6db74">{2024}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">doi</span>=<span style="color:#e6db74">{10.1038/s41467-024-46440-3}</span>
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div>]]></content:encoded></item><item><title>SPE: Data-Driven SMILES Substructure Tokenization</title><link>https://hunterheidenreich.com/notes/chemistry/molecular-representations/notations/smiles-pair-encoding/</link><pubDate>Thu, 26 Mar 2026 00:00:00 +0000</pubDate><guid>https://hunterheidenreich.com/notes/chemistry/molecular-representations/notations/smiles-pair-encoding/</guid><description>SMILES Pair Encoding adapts byte pair encoding to learn chemically meaningful substructure tokens from SMILES, improving generation and QSAR prediction.</description><content:encoded><![CDATA[<h2 id="a-data-driven-tokenization-method-for-chemical-deep-learning">A Data-Driven Tokenization Method for Chemical Deep Learning</h2>
<p>This is a <strong>Method</strong> paper that introduces SMILES Pair Encoding (SPE), a tokenization algorithm adapted from <a href="https://en.wikipedia.org/wiki/Byte-pair_encoding">byte pair encoding (BPE)</a> in natural language processing. The primary contribution is a data-driven approach that learns a vocabulary of high-frequency SMILES substrings from a large chemical dataset and then uses that vocabulary to tokenize SMILES for downstream deep learning tasks. The authors provide an open-source Python package (SmilesPE) and demonstrate improvements on both molecular generation and <a href="https://en.wikipedia.org/wiki/Quantitative_structure%E2%80%93activity_relationship">QSAR</a> prediction benchmarks.</p>
<h2 id="limitations-of-atom-level-smiles-tokenization">Limitations of Atom-Level SMILES Tokenization</h2>
<p>SMILES-based deep learning models require tokenization to convert molecular strings into sequences of discrete units. The standard approaches have well-known drawbacks:</p>
<ul>
<li><strong>Character-level tokenization</strong> breaks SMILES character by character, splitting chemically meaningful multi-character atoms. For example, <code>[C@@H]</code> becomes six separate tokens (<code>[</code>, <code>C</code>, <code>@</code>, <code>@</code>, <code>H</code>, <code>]</code>), losing the stereochemistry information of a single carbon.</li>
<li><strong>Atom-level tokenization</strong> addresses some of these issues by treating multi-character element symbols (Cl, Br) and bracketed atoms ([nH], [O-]) as single tokens. However, these tokens still encode only individual atoms, not substructures.</li>
<li><strong>k-mer tokenization</strong> (sequences of k consecutive overlapping characters) captures some connectivity information but suffers from the out-of-vocabulary problem: the model cannot represent k-mers not seen during training.</li>
</ul>
<p>All three approaches produce relatively long input sequences (mean ~40 tokens per molecule on ChEMBL at the atom level), which increases computational cost for sequential architectures like RNNs and exacerbates long-range dependency issues.</p>
<h2 id="core-innovation-adapting-byte-pair-encoding-for-smiles">Core Innovation: Adapting Byte Pair Encoding for SMILES</h2>
<p>SPE adapts the byte pair encoding algorithm, originally developed for data compression and later adopted for subword tokenization in NLP, to the domain of chemical strings. The algorithm has two phases:</p>
<p><strong>Vocabulary training:</strong></p>
<ol>
<li>Tokenize SMILES from a large dataset (ChEMBL) at the atom level</li>
<li>Initialize the vocabulary with all unique atom-level tokens</li>
<li>Iteratively count the frequency of all adjacent token pairs, merge the most frequent pair into a new token, and add it to the vocabulary</li>
<li>Stop when either the maximum vocabulary size (MVS) or a minimum frequency threshold (FT) is reached</li>
</ol>
<p><strong>Tokenization:</strong> Given a trained SPE vocabulary, a new SMILES string is first tokenized at the atom level, then token pairs are iteratively merged according to their frequency rank in the vocabulary until no further merges are possible.</p>
<p>The key hyperparameters are MVS and FT. In the reported experiments, MVS was set to 30,000 and FT was set to 2,000. The vocabulary was trained on ~3.4 million SMILES (both canonical and one non-canonical variant per molecule) from ChEMBL25. The resulting vocabulary contained 3,002 unique SMILES substrings with lengths ranging from 1 to 22 atom-level characters.</p>
<p>The trained SPE vocabulary produces tokens that are human-readable and correspond to chemically meaningful substructures and functional groups. SPE tokenization reduces the mean sequence length from approximately 40 tokens (atom-level) to approximately 6 tokens on ChEMBL, a roughly 6-7x compression. This shorter representation directly reduces computational cost for RNN-based and other sequential models.</p>
<p>The algorithm is also compatible with other text-based molecular representations such as <a href="/notes/chemistry/molecular-representations/notations/deepsmiles-adaptation-for-ml/">DeepSMILES</a> and <a href="/notes/chemistry/molecular-representations/notations/selfies/">SELFIES</a>, since these share atom-level character structures that can serve as the starting point for pair merging.</p>
<h2 id="molecular-generation-and-qsar-prediction-experiments">Molecular Generation and QSAR Prediction Experiments</h2>
<h3 id="molecular-generation">Molecular Generation</h3>
<p>The authors trained AWD-LSTM language models with SPE and atom-level tokenization on 9 million SMILES (1 canonical + 5 non-canonical per compound from ChEMBL25). Each model sampled 1 million SMILES for evaluation. The AWD-LSTM architecture used an embedding size of 400, three LSTM layers with 1,152 hidden units each, and various dropout settings (embedding: 0.1, input: 0.6, weight: 0.5, hidden: 0.2). Models were trained for 10 epochs with a base learning rate of 0.008 using one-cycle scheduling.</p>
<table>
  <thead>
      <tr>
          <th>Metric</th>
          <th>SPE</th>
          <th>Atom-level</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>Validity</td>
          <td>0.941</td>
          <td>0.970</td>
      </tr>
      <tr>
          <td>Uniqueness</td>
          <td>0.994</td>
          <td>0.992</td>
      </tr>
      <tr>
          <td>Novelty</td>
          <td>0.983</td>
          <td>0.978</td>
      </tr>
      <tr>
          <td>Internal diversity</td>
          <td>0.897</td>
          <td>0.886</td>
      </tr>
      <tr>
          <td>Nearest neighbor similarity</td>
          <td>0.391</td>
          <td>0.386</td>
      </tr>
  </tbody>
</table>
<p>The SPE model generated a more diverse population of novel molecules at the cost of slightly lower validity (94.1% vs. 97.0%). Internal diversity is defined as:</p>
<p>$$
\text{Internal diversity} = 1 - \frac{1}{|G|} \sum_{(x_1, x_2) \in G \times G} T(x_1, x_2)
$$</p>
<p>where $T(x_1, x_2)$ is the Tanimoto similarity between molecules $x_1$ and $x_2$ using 1024-bit ECFP6 fingerprints. Nearest neighbor similarity (SNN) measures how well the generated set resembles the reference set:</p>
<p>$$
\text{SNN} = \frac{1}{|G|} \sum_{x_G \in G} \max_{x_R \in R} T(x_G, x_R)
$$</p>
<p>Substructure coverage analysis showed both models recovered the same top-1000 BRICS fragments (100% coverage), but SPE consistently outperformed atom-level tokenization on top-5000 coverage across all four substructure types: BRICS fragments (0.997 vs. 0.987), functional groups (0.688 vs. 0.659), scaffolds (0.872 vs. 0.825), and ring systems (0.781 vs. 0.761).</p>
<h3 id="qsar-prediction">QSAR Prediction</h3>
<p>QSAR models were built using the <a href="/notes/chemistry/molecular-design/property-prediction/molpmofit-transfer-learning-qsar/">MolPMoFiT transfer learning framework</a>, which pre-trains a language model on ChEMBL and then fine-tunes it for specific prediction tasks. The evaluation used 24 regression benchmarks (pIC50 values) from Cortes-Ciriano et al., covering targets ranging from 199 molecules (alpha-2a adrenergic receptor) to 5,010 molecules (<a href="https://en.wikipedia.org/wiki/KCNH2">hERG</a>). Models were evaluated on 10 random 80:10:10 splits using RMSE, R-squared, and MAE. Random forest models with 1024-bit ECFP6 were included as baseline comparisons.</p>
<p><a href="https://en.wikipedia.org/wiki/Effect_size">Cohen&rsquo;s d</a> effect sizes were computed to quantify performance differences between tokenization methods. SPE performed comparably or better than atom-level tokenization on 23 out of 24 datasets. Notable results with medium or large effect sizes favoring SPE included <a href="https://en.wikipedia.org/wiki/Cannabinoid_receptor_1">cannabinoid CB1 receptor</a> (large effect), A2a adrenergic receptor, LCK, estrogen receptor, and <a href="https://en.wikipedia.org/wiki/Aurora_kinase_A">Aurora-A kinase</a> (all medium effects). Against k-mer tokenization, SPE matched or outperformed on 22 out of 24 datasets.</p>
<p>Cohen&rsquo;s d is defined as:</p>
<p>$$
\text{Cohen&rsquo;s } d = \frac{\bar{x}_1 - \bar{x}_2}{\sqrt{(\text{SD}_1^2 + \text{SD}_2^2) / 2}}
$$</p>
<p>where $\bar{x}_1, \bar{x}_2$ are the group means and $\text{SD}_1, \text{SD}_2$ are the standard deviations. Thresholds of 0.2 (small), 0.5 (medium), and 0.8 (large) were used following standard recommendations.</p>
<p>SMILES-based deep learning models generally performed on par with or better than the RF baseline, with particularly strong advantages on the four largest datasets (<a href="https://en.wikipedia.org/wiki/Cyclooxygenase-2">COX-2</a>, <a href="https://en.wikipedia.org/wiki/Acetylcholinesterase">acetylcholinesterase</a>, erbB1, and hERG).</p>
<p>In addition to performance gains, SPE-based models trained on average 5 times faster than atom-level models due to the shorter input sequences.</p>
<h2 id="results-summary-and-future-directions">Results Summary and Future Directions</h2>
<p>The main findings of this study are:</p>
<ol>
<li>
<p><strong>SPE produces chemically meaningful tokens.</strong> The learned vocabulary contains human-readable SMILES substrings that correspond to common substructures and functional groups, making model interpretations more accessible.</p>
</li>
<li>
<p><strong>SPE compresses input sequences by ~6-7x.</strong> Mean token sequence length drops from ~40 (atom-level) to ~6 (SPE) on ChEMBL, yielding a ~5x training speedup.</p>
</li>
<li>
<p><strong>SPE improves molecular generation diversity.</strong> The SPE-based generative model produces molecules with higher novelty (98.3% vs. 97.8%), internal diversity (0.897 vs. 0.886), and substructure coverage, at the cost of slightly lower validity (94.1% vs. 97.0%).</p>
</li>
<li>
<p><strong>SPE matches or outperforms atom-level and k-mer tokenization on QSAR prediction.</strong> Across 24 benchmarks, SPE showed comparable or better performance in 23/24 comparisons against atom-level and 22/24 against k-mer tokenization.</p>
</li>
</ol>
<p><strong>Limitations acknowledged by the authors:</strong></p>
<ul>
<li>The SPE vocabulary is trained on a specific dataset (ChEMBL25) and may not optimally represent chemical spaces that differ significantly from drug-like compounds.</li>
<li>The validity rate for molecular generation is slightly lower than atom-level tokenization (94.1% vs. 97.0%), since longer substructure tokens can introduce invalid fragments.</li>
<li>The k-mer tokenization suffers from an out-of-vocabulary problem, which the authors address by replacing unseen 4-mers with <code>[UNK]</code> tokens, but this is a limitation of the comparison rather than of SPE itself.</li>
</ul>
<p><strong>Future directions:</strong> The authors suggest SPE could serve as a general tokenization method for SMILES-based deep learning, applicable to any task where SMILES strings are used as input (<a href="/notes/chemistry/molecular-design/generation/">generation</a>, <a href="/notes/chemistry/molecular-design/property-prediction/">property prediction</a>, <a href="/notes/chemistry/molecular-design/reaction-prediction/">reaction prediction</a>, retrosynthesis). The algorithm can also be applied to DeepSMILES and SELFIES representations without modification.</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>SPE vocabulary training</td>
          <td>ChEMBL25</td>
          <td>~3.4M SMILES</td>
          <td>1 canonical + 1 non-canonical per molecule</td>
      </tr>
      <tr>
          <td>Language model training</td>
          <td>ChEMBL25 augmented</td>
          <td>~9M SMILES</td>
          <td>1 canonical + 5 non-canonical per molecule</td>
      </tr>
      <tr>
          <td>Molecular generation evaluation</td>
          <td>Sampled from model</td>
          <td>1M SMILES per model</td>
          <td>Validated with RDKit</td>
      </tr>
      <tr>
          <td>QSAR benchmarks</td>
          <td>Cortes-Ciriano et al.</td>
          <td>24 datasets, 199-5010 molecules</td>
          <td>pIC50 regression tasks</td>
      </tr>
  </tbody>
</table>
<h3 id="algorithms">Algorithms</h3>
<ul>
<li>SPE vocabulary training: iterative pair merging with MVS=30,000 and FT=2,000</li>
<li>Language model: AWD-LSTM with embedding size 400, 3 LSTM layers with 1,152 hidden units</li>
<li>Dropout: embedding=0.1, input=0.6, weight=0.5, hidden=0.2</li>
<li>Training: 10 epochs, base learning rate 0.008, one-cycle policy</li>
<li>QSAR: MolPMoFiT transfer learning with 25x training augmentation and 15x validation augmentation</li>
<li>Test time augmentation: average of canonical + 4 augmented SMILES predictions</li>
<li>RF baseline: 500 trees, 1024-bit ECFP6, default scikit-learn parameters</li>
</ul>
<h3 id="models">Models</h3>
<ul>
<li>AWD-LSTM architecture from Merity et al. (2018)</li>
<li>MolPMoFiT framework from Li and Fourches (2020) for transfer learning QSAR</li>
</ul>
<h3 id="evaluation">Evaluation</h3>
<table>
  <thead>
      <tr>
          <th>Metric</th>
          <th>Task</th>
          <th>Notes</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>Validity, Uniqueness, Novelty</td>
          <td>Generation</td>
          <td>Basic quality metrics</td>
      </tr>
      <tr>
          <td>Internal diversity</td>
          <td>Generation</td>
          <td>1 - mean pairwise Tanimoto (ECFP6)</td>
      </tr>
      <tr>
          <td>Nearest neighbor similarity</td>
          <td>Generation</td>
          <td>Mean max Tanimoto to reference set</td>
      </tr>
      <tr>
          <td>Substructure coverage</td>
          <td>Generation</td>
          <td>BRICS, functional groups, scaffolds, ring systems</td>
      </tr>
      <tr>
          <td>RMSE, R-squared, MAE</td>
          <td>QSAR regression</td>
          <td>10 random 80:10:10 splits</td>
      </tr>
      <tr>
          <td>Cohen&rsquo;s d</td>
          <td>QSAR comparison</td>
          <td>Effect size between tokenization methods</td>
      </tr>
  </tbody>
</table>
<h3 id="hardware">Hardware</h3>
<p>Not explicitly specified in the paper.</p>
<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/XinhaoLi74/SmilesPE">SmilesPE</a></td>
          <td>Code</td>
          <td>Apache-2.0</td>
          <td>SPE tokenization Python package</td>
      </tr>
      <tr>
          <td><a href="https://github.com/XinhaoLi74/MolPMoFiT">MolPMoFiT</a></td>
          <td>Code</td>
          <td>Not specified</td>
          <td>Transfer learning QSAR framework</td>
      </tr>
  </tbody>
</table>
<hr>
<h2 id="paper-information">Paper Information</h2>
<p><strong>Citation</strong>: Li, X., &amp; Fourches, D. (2021). SMILES Pair Encoding: A Data-Driven Substructure Tokenization Algorithm for Deep Learning. <em>Journal of Chemical Information and Modeling</em>, 61(4), 1560-1569. <a href="https://doi.org/10.1021/acs.jcim.0c01127">https://doi.org/10.1021/acs.jcim.0c01127</a></p>
<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">@article</span>{li2021smiles,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">title</span>=<span style="color:#e6db74">{SMILES Pair Encoding: A Data-Driven Substructure Tokenization Algorithm for Deep Learning}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">author</span>=<span style="color:#e6db74">{Li, Xinhao and Fourches, Denis}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">journal</span>=<span style="color:#e6db74">{Journal of Chemical Information and Modeling}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">volume</span>=<span style="color:#e6db74">{61}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">number</span>=<span style="color:#e6db74">{4}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">pages</span>=<span style="color:#e6db74">{1560--1569}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">year</span>=<span style="color:#e6db74">{2021}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">publisher</span>=<span style="color:#e6db74">{American Chemical Society}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">doi</span>=<span style="color:#e6db74">{10.1021/acs.jcim.0c01127}</span>
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div>]]></content:encoded></item><item><title>Smirk: Complete Tokenization for Molecular Models</title><link>https://hunterheidenreich.com/notes/chemistry/molecular-representations/notations/smirk-tokenization-molecular-models/</link><pubDate>Thu, 26 Mar 2026 00:00:00 +0000</pubDate><guid>https://hunterheidenreich.com/notes/chemistry/molecular-representations/notations/smirk-tokenization-molecular-models/</guid><description>Smirk tokenizer achieves full OpenSMILES coverage with 165 tokens by decomposing bracketed atoms into glyphs, validated via n-gram proxy models.</description><content:encoded><![CDATA[<h2 id="a-method-for-complete-chemical-tokenization">A Method for Complete Chemical Tokenization</h2>
<p>This is a <strong>Method</strong> paper that introduces two new tokenizers for molecular foundation models: Smirk and Smirk-GPE. The primary contribution is a tokenization scheme that achieves complete coverage of the OpenSMILES specification using only 165 tokens, addressing the vocabulary gaps present in existing atom-wise tokenizers. The paper also proposes n-gram language models as low-cost proxy evaluators for tokenizer quality and validates these proxies against 18 transformer-based models across multiple benchmarks.</p>
<h2 id="vocabulary-gaps-in-molecular-tokenization">Vocabulary Gaps in Molecular Tokenization</h2>
<p>Molecular foundation models overwhelmingly use &ldquo;atom-wise&rdquo; tokenization, where SMILES strings are split at atom boundaries using a regular expression first proposed by Schwaller et al. A key pattern in this regex treats all &ldquo;bracketed atoms&rdquo; (e.g., <code>[C@@H]</code>, <code>[18F]</code>, <code>[Au+]</code>) as single, irreducible tokens. Since bracketed atoms encode isotopes, chirality, charge, hydrogen count, and element identity, the number of possible permutations under the OpenSMILES specification exceeds 28 trillion. In practice, existing atom-wise tokenizers maintain vocabularies of fewer than 3,000 tokens, leaving large portions of chemical space unrepresentable.</p>
<p>This gap has real consequences. Many chemistry-specific tokenizers emit the unknown token <code>[UNK]</code> at non-negligible frequencies, particularly on datasets with diverse elements and stereochemistry. For example, <a href="/notes/chemistry/molecular-representations/notations/smiles-pair-encoding/">SPE and APE</a> tokenizers produce <code>[UNK]</code> for roughly 19% of tokens on <a href="/notes/chemistry/molecular-design/property-prediction/moleculenet-benchmark-molecular-ml/">MoleculeNet</a> and approximately 50% on the tmQM transition metal complex dataset. Even models like <a href="/notes/chemistry/molecular-representations/encoders/selformer/">SELFormer</a> and <a href="/notes/chemistry/molecular-design/reaction-prediction/reactiont5-pretrained-limited-reaction-data/">ReactionT5</a> lack tokens for elements such as copper, ruthenium, gold, and uranium.</p>
<p>The authors also note a subtler issue: some open-vocabulary tokenizers (e.g., <a href="/notes/chemistry/molecular-representations/encoders/chemberta/">ChemBERTa&rsquo;s</a> BPE) conflate chemically distinct entities. The same <code>Sc</code> token may represent both a sulfur-carbon bond (in organic SMILES) and the element scandium (in <code>[Sc]</code>), creating ambiguity in downstream analysis.</p>
<h2 id="smirk-glyph-level-decomposition-of-smiles">Smirk: Glyph-Level Decomposition of SMILES</h2>
<p>The core insight behind Smirk is to fully decompose bracketed atoms into their constituent &ldquo;glyphs,&rdquo; the primitive symbols defined by the OpenSMILES specification (element symbols, chirality markers, charges, isotope numbers, hydrogen counts, and brackets themselves). This transforms tokenization from a word-level scheme (one token per bracketed atom) to a character-level scheme over chemically meaningful glyphs.</p>
<p>Smirk uses a two-stage tokenization process:</p>
<ol>
<li><strong>Atom decomposition</strong>: Split a SMILES string into atom-level units using a regex (e.g., <code>OC[C@@H][OH]</code> becomes <code>O C [C@@H] [OH]</code>).</li>
<li><strong>Glyph decomposition</strong>: Further split each unit into its constituent glyphs (e.g., <code>[C@@H]</code> becomes <code>[ C @@ H ]</code>).</li>
</ol>
<p>The two-stage process is necessary to resolve ambiguities. For example, <code>Sc</code> in an unbracketed context represents a sulfur-carbon bond, while <code>[Sc]</code> denotes scandium. This ambiguity occurs over half a million times in PubChem&rsquo;s compound dataset.</p>
<p>The resulting vocabulary contains only 165 tokens, requires no training, and by construction can faithfully tokenize any molecule that conforms to the OpenSMILES specification. The implementation is written in Rust using HuggingFace&rsquo;s Tokenizers library and is available on PyPI.</p>
<p><strong>Smirk-GPE</strong> (Glyph Pair Encoding) extends Smirk with a <a href="https://en.wikipedia.org/wiki/Byte-pair_encoding">BPE</a>-like compression step. After Smirk tokenization, adjacent tokens are merged using learned rules, reducing sequence length. Unlike standard BPE, merges operate on token IDs rather than character strings, preserving the distinction between chemically different entities that happen to share the same characters. Smirk-GPE was trained on 262 million molecules from Enamine REAL Space with a target vocabulary of 50,000 tokens, though training terminated at 2,300 tokens after exhausting all possible merges.</p>
<h2 id="evaluation-framework-intrinsic-metrics-n-gram-proxies-and-transformer-benchmarks">Evaluation Framework: Intrinsic Metrics, N-Gram Proxies, and Transformer Benchmarks</h2>
<p>The evaluation covers 34 tokenizers across three datasets (Enamine REALSpace, MoleculeNet, and tmQM) using both intrinsic and extrinsic metrics.</p>
<h3 id="intrinsic-metrics">Intrinsic Metrics</h3>
<p>Four intrinsic metrics are computed for each tokenizer:</p>
<p><strong>Fertility</strong> measures the mean tokenized sequence length. Higher fertility increases computational cost due to the quadratic scaling of attention:</p>
<p>$$
\text{cost} \propto \text{fertility}^2
$$</p>
<p><strong>Normalized entropy</strong> quantifies how close a tokenizer comes to the information-theoretic ideal where all tokens are equally probable:</p>
<p>$$
\eta = \frac{-1}{\log |V|} \sum_{x \in V} p(x) \log p(x)
$$</p>
<p>where $V$ is the vocabulary and $p(x)$ is the observed token probability. Higher normalized entropy correlates with better downstream performance.</p>
<p><strong>Token imbalance</strong> measures the distance between observed token frequencies and a uniform distribution:</p>
<p>$$
D = \frac{1}{2} \sum_{x \in V} |p(x) - |V|^{-1}|
$$</p>
<p><strong>Unknown token frequency</strong> captures the fraction of emitted tokens that are <code>[UNK]</code>. This metric is particularly revealing: all existing chemistry-specific tokenizers (SPE/APE, atom-wise, BPE, and Unigram variants) emit <code>[UNK]</code> at non-negligible rates, while NLP tokenizers, Smirk, and Smirk-GPE do not.</p>
<h3 id="n-gram-proxy-language-models">N-Gram Proxy Language Models</h3>
<p>The paper proposes using n-gram models as low-cost proxies for transformer-based evaluation. An n-gram estimates token likelihood with <a href="https://en.wikipedia.org/wiki/Additive_smoothing">add-one smoothing</a>:</p>
<p>$$
P_{n}(x_{i} \mid x_{i-n+1}, \dots, x_{i-1}) = \frac{C(x_{i-n+1}, \dots, x_{i}) + 1}{C(x_{i-n+1}, \dots, x_{i-1}) + |V|}
$$</p>
<p>where $C$ is the count function and $|V|$ is the vocabulary size. N-grams were &ldquo;pretrained&rdquo; on 1.6 billion SMILES from Enamine REAL Space and evaluated on validation splits. Cross-entropy loss and information loss from unknown tokens were computed.</p>
<p>To quantify information lost to <code>[UNK]</code> tokens, the authors compute the <a href="https://en.wikipedia.org/wiki/Kullback%E2%80%93Leibler_divergence">KL-divergence</a> between token distributions with and without unknown tokens, using a bidirectional character n-gram model:</p>
<p>$$
B_{n}(x_{i} \mid x_{i-n+1}, \dots, x_{i-1}, x_{i+1}, \dots, x_{i+n-1}) \propto \frac{C(x_{i-n+1}, \dots, x_{i}) + 1}{C(x_{i-n+1}, \dots, x_{i-1}) + |V|} \times \frac{C(x_{i}, \dots, x_{i+n-1}) + 1}{C(x_{i+1}, \dots, x_{i+n-1}) + |V|}
$$</p>
<h3 id="transformer-experiments">Transformer Experiments</h3>
<p>Eighteen encoder-only RoBERTa models (25M parameters each, excluding embeddings) were pretrained from scratch using masked language modeling on Enamine REAL Space (245M molecules, 30,000 steps). Each model used a different tokenizer, isolating the tokenizer&rsquo;s effect on performance. Finetuning was conducted on six regression and seven classification tasks from MoleculeNet and tmQM.</p>
<p>Linear fixed-effects models were used to estimate the standardized effect of each tokenization scheme relative to an atom-wise SMILES baseline.</p>
<h2 id="key-findings-and-practical-implications">Key Findings and Practical Implications</h2>
<h3 id="tokenizer-performance">Tokenizer Performance</h3>
<ul>
<li><strong>Smirk</strong> shows a positive effect on pretraining quality and downstream performance on tmQM (the dataset with the most bracketed atoms), but performs comparably to atom-wise tokenization on MoleculeNet tasks.</li>
<li><strong>SPE and APE</strong> tokenizers have a negative impact on both pretraining and downstream performance relative to the atom-wise baseline, likely due to their high <code>[UNK]</code> rates.</li>
<li><strong>Molecular encoding choice</strong> (<a href="/notes/chemistry/molecular-representations/notations/smiles-selfies-tokenization-chemical-lm/">SMILES vs. SELFIES</a>) has a negligible effect on performance.</li>
<li><strong>NLP tokenizers</strong> (GPT-4o, LLaMA, Gemma) score comparably to chemistry-specific tokenizers on intrinsic metrics and do not emit unknown tokens.</li>
</ul>
<h3 id="n-gram-proxy-validation">N-Gram Proxy Validation</h3>
<p>N-gram cross-entropy and information loss metrics show strong rank correlation (Spearman&rsquo;s $\rho$) with downstream transformer performance, validating their use as low-cost evaluation proxies. The effect sizes from n-gram and transformer experiments are directionally consistent.</p>
<h3 id="information-loss-from-unknown-tokens">Information Loss from Unknown Tokens</h3>
<p>Information loss is minimal for tokenizers with robust coverage but substantial for tokenizers with limited vocabularies on chemically diverse datasets. <a href="/notes/chemistry/molecular-representations/encoders/molformer/">MoLFormer</a> incurs only 0.1 nats/molecule on MoleculeNet but 40.3 nats/molecule on tmQM. Open-vocabulary tokenizers (Smirk, Smirk-GPE, NLP tokenizers) mitigate this degradation.</p>
<h3 id="practical-recommendations">Practical Recommendations</h3>
<p>The authors argue that molecular foundation models must encode the entire breadth of chemical space or risk obscuring critical features. Bracketed atoms encode information essential to clinically relevant pharmaceuticals (e.g., <a href="https://en.wikipedia.org/wiki/Amoxicillin">Amoxicillin</a>), industrial compounds (e.g., Tricalcium Silicate), and foundational chemistry (e.g., <a href="https://en.wikipedia.org/wiki/Cisplatin">Cisplatin</a>, where omitting the chiral marker erases medically relevant stereochemical information). The paper encourages the community to adopt open-vocabulary tokenizers and develop more chemically diverse benchmarks.</p>
<h3 id="limitations">Limitations</h3>
<ul>
<li>The analysis uses a single-point evaluation for transformer experiments, which may underestimate performance achievable with additional hyperparameter tuning.</li>
<li>Smirk-GPE&rsquo;s learned merges from REALSpace did not fully generalize to tmQM, as indicated by the token imbalance metric.</li>
<li>Current benchmarks (MoleculeNet) lack sufficient diversity to evaluate tokenizer robustness across the full periodic table, isotopes, charged species, and uncommon bond types.</li>
<li>The downstream impact of token ambiguities in BPE-based tokenizers (e.g., ChemBERTa&rsquo;s conflation of <code>Sc</code> as both sulfur-carbon and scandium) remains unclear.</li>
</ul>
<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>Pretraining</td>
          <td>Enamine REAL Space</td>
          <td>1.6B SMILES (n-gram), 245M molecules (transformer)</td>
          <td>80/10/10 train/val/test split</td>
      </tr>
      <tr>
          <td>Downstream evaluation</td>
          <td>MoleculeNet</td>
          <td>Multiple tasks</td>
          <td>6 regression + 7 classification tasks</td>
      </tr>
      <tr>
          <td>Downstream evaluation</td>
          <td>tmQM</td>
          <td>108K transition metal complexes</td>
          <td>OpenSMILES molecular encodings</td>
      </tr>
      <tr>
          <td>Smirk-GPE training</td>
          <td>Enamine REAL Space (subset)</td>
          <td>262M molecules</td>
          <td>Training split only</td>
      </tr>
  </tbody>
</table>
<h3 id="algorithms">Algorithms</h3>
<ul>
<li><strong>Smirk</strong>: Two-stage regex-based tokenization (atom decomposition, then glyph decomposition). No training required. Vocabulary: 165 tokens.</li>
<li><strong>Smirk-GPE</strong>: BPE-like compression on top of Smirk. Operates on token IDs (not strings) to preserve chemical disambiguation. Final vocabulary: 2,300 tokens.</li>
<li><strong>N-gram models</strong>: Add-one smoothing, bidirectional context ($2n - 2$ total context window). Implemented in Julia with exact integer arithmetic.</li>
</ul>
<h3 id="models">Models</h3>
<ul>
<li><strong>Architecture</strong>: RoBERTa-PreLayerNorm, 8 layers, 8 attention heads, hidden size 512, intermediate size 2048, max sequence length 2048. ~25M parameters (excluding embeddings).</li>
<li><strong>Pretraining</strong>: Masked language modeling, 30,000 steps, effective batch size 8192, FusedLamb optimizer, learning rate $1.6 \times 10^{-4}$.</li>
<li><strong>Finetuning</strong>: 100,000 steps, AdamW optimizer, effective batch size 128, learning rate $1.6 \times 10^{-4}$.</li>
</ul>
<h3 id="evaluation">Evaluation</h3>
<ul>
<li>MoleculeNet preferred metrics per task (AUROC for classification, MAE/RMSE for regression)</li>
<li>Fixed-effects models for standardized effect size estimation</li>
<li>Spearman&rsquo;s rank correlation between n-gram and transformer metrics</li>
</ul>
<h3 id="hardware">Hardware</h3>
<ul>
<li>Pretraining: 2x NVIDIA A100 GPUs (Delta system at NCSA)</li>
<li>Finetuning: 1x NVIDIA A40 GPU</li>
<li>N-gram models: CPU-based (Julia implementation)</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/BattModels/Smirk">Smirk tokenizer</a></td>
          <td>Code</td>
          <td>Apache-2.0</td>
          <td>Rust implementation with Python bindings, available on PyPI</td>
      </tr>
      <tr>
          <td>Model checkpoints</td>
          <td>Model</td>
          <td>Not specified</td>
          <td>Pretrained and finetuned checkpoints included in data release</td>
      </tr>
      <tr>
          <td>N-gram code</td>
          <td>Code</td>
          <td>Not specified</td>
          <td>Julia implementation included in data release</td>
      </tr>
  </tbody>
</table>
<hr>
<h2 id="paper-information">Paper Information</h2>
<p><strong>Citation</strong>: Wadell, A., Bhutani, A., &amp; Viswanathan, V. (2026). Tokenization for Molecular Foundation Models. <em>Journal of Chemical Information and Modeling</em>, 66(3), 1384-1393. <a href="https://doi.org/10.1021/acs.jcim.5c01856">https://doi.org/10.1021/acs.jcim.5c01856</a></p>
<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">@article</span>{wadell2026tokenization,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">title</span>=<span style="color:#e6db74">{Tokenization for Molecular Foundation Models}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">author</span>=<span style="color:#e6db74">{Wadell, Alexius and Bhutani, Anoushka and Viswanathan, Venkatasubramanian}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">journal</span>=<span style="color:#e6db74">{Journal of Chemical Information and Modeling}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">volume</span>=<span style="color:#e6db74">{66}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">number</span>=<span style="color:#e6db74">{3}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">pages</span>=<span style="color:#e6db74">{1384--1393}</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">publisher</span>=<span style="color:#e6db74">{American Chemical Society}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">doi</span>=<span style="color:#e6db74">{10.1021/acs.jcim.5c01856}</span>
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div>]]></content:encoded></item><item><title>SMILES-BERT: BERT-Style Pre-Training for Molecules</title><link>https://hunterheidenreich.com/notes/chemistry/molecular-representations/encoders/smiles-bert/</link><pubDate>Thu, 26 Mar 2026 00:00:00 +0000</pubDate><guid>https://hunterheidenreich.com/notes/chemistry/molecular-representations/encoders/smiles-bert/</guid><description>SMILES-BERT applies BERT-style masked pre-training to SMILES strings for molecular property prediction, using Transformer encoders fine-tuned on labeled data.</description><content:encoded><![CDATA[<h2 id="pre-training-transformers-on-smiles-for-molecular-properties">Pre-Training Transformers on SMILES for Molecular Properties</h2>
<p>SMILES-BERT is a <strong>Method</strong> paper that introduces a BERT-inspired pre-training and fine-tuning framework for molecular property prediction. The primary contribution is adapting the masked language model paradigm from NLP to <a href="/notes/chemistry/molecular-representations/notations/smiles/">SMILES strings</a>, enabling a Transformer encoder to learn molecular representations from large-scale unlabeled data before fine-tuning on smaller labeled datasets.</p>
<h2 id="limited-labels-in-molecular-property-prediction">Limited Labels in Molecular Property Prediction</h2>
<p>Molecular property prediction is central to drug discovery and chemical design, but obtaining labeled data requires expensive biological assays. Deep learning methods for this task fall into three categories: manually designed fingerprints (e.g., ECFP), graph-based methods (GCNs operating on molecular graphs), and sequence-based methods (RNNs or CNNs operating on SMILES strings).</p>
<p>Prior unsupervised approaches like <a href="/notes/chemistry/molecular-representations/encoders/seq2seq-fingerprint-molecular-embedding/">Seq2seq Fingerprint</a> used an encoder-decoder architecture to learn representations from unlabeled SMILES, but the decoder acts as scaffolding that consumes GPU memory during pre-training without contributing to downstream prediction. The semi-supervised Seq3seq Fingerprint improved on this by incorporating labeled data, but retained the encoder-decoder inefficiency. RNN-based methods also suffer from difficulty in parallel training and require careful tuning (gradient clipping, early stopping) to converge.</p>
<p>The authors identify two motivations: (1) building a semi-supervised model that effectively leverages large pools of unlabeled SMILES to improve prediction with limited labels, and (2) designing an architecture where the entire pre-trained model participates in fine-tuning (no wasted decoder parameters) and naturally supports parallel training.</p>
<h2 id="masked-smiles-recovery-with-transformer-encoders">Masked SMILES Recovery with Transformer Encoders</h2>
<p>The core innovation is the Masked SMILES Recovery pre-training task, directly analogous to BERT&rsquo;s masked language modeling. The model architecture is a stack of Transformer encoder layers, making it fully convolutional and parallelizable.</p>
<h3 id="architecture">Architecture</h3>
<p>SMILES-BERT uses 6 Transformer encoder layers, each with 4-head multi-head self-attention and feed-forward dimension of 1024. Each Transformer layer contains three components: a pre-attention feed-forward network, a self-attention layer, and a post-attention feed-forward network, all followed by layer normalization with residual connections.</p>
<p>The self-attention mechanism uses scaled dot-product attention:</p>
<p>$$
Z = \text{Softmax}\left(\frac{(XW^{Q})(XW^{K})^{T}}{\sqrt{d_{k}}}\right) XW^{V}
$$</p>
<p>where $X \in \mathbb{R}^{N \times M}$ is the input feature matrix, $W^{Q}$, $W^{K}$, $W^{V} \in \mathbb{R}^{M \times d_{k}}$ are the query, key, and value weight matrices, and $\sqrt{d_{k}}$ is the scaling factor.</p>
<p>Input SMILES are tokenized at the character level with token embeddings and positional embeddings. A special <code>&lt;GO&gt;</code> token is prepended to each SMILES, and its output representation is used for downstream classification/regression after fine-tuning.</p>
<h3 id="pre-training-masked-smiles-recovery">Pre-training: Masked SMILES Recovery</h3>
<p>Following BERT&rsquo;s masking strategy, 15% of tokens in each SMILES are selected for masking (minimum one per SMILES). Of the selected tokens:</p>
<ul>
<li>85% are replaced with a <code>&lt;MASK&gt;</code> token</li>
<li>10% are replaced with a random token from the vocabulary</li>
<li>5% are kept unchanged</li>
</ul>
<p>The model is trained to recover the original tokens at masked positions. The loss is computed only on the masked token outputs.</p>
<h3 id="fine-tuning">Fine-tuning</h3>
<p>After pre-training, a classifier or regressor head is added to the <code>&lt;GO&gt;</code> token output. The entire model (all Transformer layers plus the new head) is fine-tuned on the labeled dataset.</p>
<p>Key differences from the original BERT:</p>
<ol>
<li>Only the Masked SMILES Recovery task is used (BERT&rsquo;s next sentence prediction is dropped since SMILES have no consecutive-sentence structure)</li>
<li>Segment embeddings are removed</li>
<li>The architecture is smaller (6 layers, 4 heads, 1024 FFN dim) since SMILES have a much smaller vocabulary and shorter sequences than natural language</li>
</ol>
<p>The authors compared this configuration against a larger BERT-base setup (12 layers, 12 heads, 3072 FFN dim) and found no meaningful performance difference, confirming that the smaller model is sufficient for SMILES.</p>
<h2 id="experimental-setup-and-baseline-comparisons">Experimental Setup and Baseline Comparisons</h2>
<h3 id="pre-training-data">Pre-training Data</h3>
<p>SMILES-BERT was pre-trained on the <a href="/notes/chemistry/datasets/zinc-22/">ZINC database</a> with 18,671,355 training SMILES, 10,000 for validation, and 10,000 for evaluation. Pre-training ran for 10 epochs using the Adam optimizer with a warm-up strategy (learning rate from $10^{-9}$ to $10^{-4}$ over 4,000 steps, then inverse-square-root decay). Batch size was 256 and dropout was 0.1. The pre-training masked SMILES exact recovery rate reached 82.85% on the validation set.</p>
<h3 id="fine-tuning-datasets">Fine-tuning Datasets</h3>
<table>
  <thead>
      <tr>
          <th>Dataset</th>
          <th>Source</th>
          <th>Size</th>
          <th>Task</th>
          <th>Metric</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td><a href="https://en.wikipedia.org/wiki/Partition_coefficient">LogP</a></td>
          <td>NCATS/NIH</td>
          <td>10,850</td>
          <td>Classification (threshold 1.88)</td>
          <td>Accuracy</td>
      </tr>
      <tr>
          <td>PM2</td>
          <td>NCATS/NIH</td>
          <td>323,242</td>
          <td>Classification (threshold 0.024896)</td>
          <td>Accuracy</td>
      </tr>
      <tr>
          <td>PCBA-686978</td>
          <td><a href="https://en.wikipedia.org/wiki/PubChem">PubChem</a></td>
          <td>302,175</td>
          <td>Classification</td>
          <td>Accuracy</td>
      </tr>
  </tbody>
</table>
<p>All datasets were split 80/10/10 for train/validation/test. Fine-tuning used Adam with a fixed learning rate for 50 epochs, selecting the best model on validation data.</p>
<h3 id="baselines">Baselines</h3>
<ul>
<li><strong>Circular Fingerprint (CircularFP)</strong>: Manually designed hash-based fingerprint (ECFP family)</li>
<li><strong>Neural Fingerprint (NeuralFP)</strong>: Graph-based neural network replacing hash functions with learned layers</li>
<li><strong>Seq2seq Fingerprint (Seq2seqFP)</strong>: Unsupervised encoder-decoder model on SMILES</li>
<li><strong>Seq3seq Fingerprint (Seq3seqFP)</strong>: Semi-supervised encoder-decoder model on SMILES</li>
</ul>
<h3 id="results">Results</h3>
<table>
  <thead>
      <tr>
          <th>Method</th>
          <th>LogP</th>
          <th>PM2</th>
          <th>PCBA-686978</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>CircularFP</td>
          <td>~0.90</td>
          <td>0.6858</td>
          <td>~0.82</td>
      </tr>
      <tr>
          <td>NeuralFP</td>
          <td>~0.90</td>
          <td>0.6802</td>
          <td>~0.82</td>
      </tr>
      <tr>
          <td>Seq2seqFP</td>
          <td>~0.87</td>
          <td>0.6112</td>
          <td>~0.80</td>
      </tr>
      <tr>
          <td>Seq3seqFP</td>
          <td>~0.90</td>
          <td>0.7038</td>
          <td>~0.84</td>
      </tr>
      <tr>
          <td><strong>SMILES-BERT</strong></td>
          <td><strong>0.9154</strong></td>
          <td><strong>0.7589</strong></td>
          <td><strong>0.8784</strong></td>
      </tr>
  </tbody>
</table>
<p>SMILES-BERT outperformed all baselines on all three datasets. The improvement over Seq3seqFP was approximately 2% on LogP, 5.5% on PM2, and 3.8% on PCBA-686978. The results on PM2 (the largest labeled dataset) show that pre-training benefits persist even with substantial labeled data.</p>
<h3 id="structure-study">Structure Study</h3>
<table>
  <thead>
      <tr>
          <th>Configuration</th>
          <th>Layers</th>
          <th>Attention Heads</th>
          <th>FFN Dim</th>
          <th>LogP Accuracy</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>SMILES-BERT</td>
          <td>6</td>
          <td>4</td>
          <td>1024</td>
          <td>0.9154</td>
      </tr>
      <tr>
          <td>SMILES-BERT (large)</td>
          <td>12</td>
          <td>12</td>
          <td>3072</td>
          <td>0.9147</td>
      </tr>
  </tbody>
</table>
<p>The larger configuration provided no improvement, supporting the choice of the smaller, more efficient architecture.</p>
<h2 id="findings-limitations-and-future-directions">Findings, Limitations, and Future Directions</h2>
<p>SMILES-BERT demonstrated that BERT-style masked pre-training on SMILES strings produces transferable molecular representations that improve property prediction across datasets of varying sizes and property types.</p>
<p>Key findings:</p>
<ul>
<li>The Masked SMILES Recovery pre-training task transfers effectively to molecular property prediction</li>
<li>The full model participates in fine-tuning (no wasted decoder), making SMILES-BERT more parameter-efficient than encoder-decoder alternatives</li>
<li>A smaller Transformer configuration (6 layers, 4 heads) matches the performance of a BERT-base-sized model for SMILES data</li>
<li>Pre-training on ~18.7M SMILES from ZINC provides robust initialization across different downstream tasks</li>
</ul>
<p><strong>Limitations</strong>: The evaluation uses only classification accuracy as the metric, without reporting AUC-ROC, F1, or other metrics common in molecular property prediction. The comparison is limited to four baselines, and two of the three evaluation datasets (LogP, PM2) are non-public NIH datasets. The paper does not explore different pre-training dataset sizes or ablate the masking strategy. Only classification tasks are evaluated, though the architecture supports regression.</p>
<p><strong>Future work</strong>: The authors propose incorporating Quantitative Estimate of Druglikeness (QED) prediction as an additional pre-training task to warm up the model&rsquo;s classification capability, analogous to BERT&rsquo;s next sentence prediction.</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>Pre-training</td>
          <td>ZINC</td>
          <td>18,671,355 SMILES</td>
          <td>Publicly available database</td>
      </tr>
      <tr>
          <td>Fine-tuning</td>
          <td>LogP</td>
          <td>10,850</td>
          <td>Non-public, from NCATS/NIH</td>
      </tr>
      <tr>
          <td>Fine-tuning</td>
          <td>PM2</td>
          <td>323,242</td>
          <td>Non-public, from NCATS/NIH</td>
      </tr>
      <tr>
          <td>Fine-tuning</td>
          <td>PCBA-686978</td>
          <td>302,175</td>
          <td>Public, from PubChem BioAssay</td>
      </tr>
  </tbody>
</table>
<h3 id="algorithms">Algorithms</h3>
<ul>
<li>Pre-training: Adam optimizer, warm-up for 4,000 steps ($10^{-9}$ to $10^{-4}$), inverse-square-root LR schedule, batch size 256, dropout 0.1, 10 epochs</li>
<li>Fine-tuning: Adam optimizer, fixed LR (insensitive to choice among $10^{-5}$, $10^{-6}$, $10^{-7}$), 50 epochs, best model on validation</li>
</ul>
<h3 id="models">Models</h3>
<ul>
<li>6 Transformer encoder layers, 4-head multi-head attention, FFN dim 1024</li>
<li>Token embedding + positional embedding, <code>&lt;GO&gt;</code> special token</li>
<li>Implemented with FairSeq (Facebook AI Research Sequence-to-Sequence Toolkit)</li>
</ul>
<h3 id="evaluation">Evaluation</h3>
<table>
  <thead>
      <tr>
          <th>Metric</th>
          <th>SMILES-BERT</th>
          <th>Best Baseline (Seq3seqFP)</th>
          <th>Notes</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>LogP Accuracy</td>
          <td>0.9154</td>
          <td>~0.90</td>
          <td>~2% improvement</td>
      </tr>
      <tr>
          <td>PM2 Accuracy</td>
          <td>0.7589</td>
          <td>0.7038</td>
          <td>~5.5% improvement</td>
      </tr>
      <tr>
          <td>PCBA Accuracy</td>
          <td>0.8784</td>
          <td>~0.84</td>
          <td>~3.8% improvement</td>
      </tr>
  </tbody>
</table>
<h3 id="hardware">Hardware</h3>
<p>The paper mentions GPU training and NVIDIA GPU donation in acknowledgments but does not specify the exact GPU model or training time beyond noting that pre-training on a single GPU takes over a week for 10 epochs.</p>
<table>
  <thead>
      <tr>
          <th>Artifact</th>
          <th>Type</th>
          <th>License</th>
          <th>Notes</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>No public code or model release identified</td>
          <td>-</td>
          <td>-</td>
          <td>Paper does not provide a GitHub link or model checkpoint</td>
      </tr>
  </tbody>
</table>
<p><strong>Reproducibility status</strong>: Partially Reproducible. The ZINC pre-training data is public and the architecture is described in detail, but no code or pre-trained weights are released. Two of three evaluation datasets (LogP, PM2) are non-public.</p>
<hr>
<h2 id="paper-information">Paper Information</h2>
<p><strong>Citation</strong>: Wang, S., Guo, Y., Wang, Y., Sun, H., &amp; Huang, J. (2019). SMILES-BERT: Large Scale Unsupervised Pre-Training for Molecular Property Prediction. In <em>Proceedings of the 10th ACM International Conference on Bioinformatics, Computational Biology and Health Informatics (ACM-BCB &lsquo;19)</em>, 429-436. <a href="https://doi.org/10.1145/3307339.3342186">https://doi.org/10.1145/3307339.3342186</a></p>
<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>{wang2019smilesbert,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">title</span>=<span style="color:#e6db74">{SMILES-BERT: Large Scale Unsupervised Pre-Training for Molecular Property Prediction}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">author</span>=<span style="color:#e6db74">{Wang, Sheng and Guo, Yuzhi and Wang, Yuhong and Sun, Hongmao and Huang, Junzhou}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">booktitle</span>=<span style="color:#e6db74">{Proceedings of the 10th ACM International Conference on Bioinformatics, Computational Biology and Health Informatics}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">pages</span>=<span style="color:#e6db74">{429--436}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">year</span>=<span style="color:#e6db74">{2019}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">publisher</span>=<span style="color:#e6db74">{ACM}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">doi</span>=<span style="color:#e6db74">{10.1145/3307339.3342186}</span>
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div>]]></content:encoded></item><item><title>SMILES vs SELFIES Tokenization for Chemical LMs</title><link>https://hunterheidenreich.com/notes/chemistry/molecular-representations/notations/smiles-selfies-tokenization-chemical-lm/</link><pubDate>Thu, 26 Mar 2026 00:00:00 +0000</pubDate><guid>https://hunterheidenreich.com/notes/chemistry/molecular-representations/notations/smiles-selfies-tokenization-chemical-lm/</guid><description>Atom Pair Encoding (APE) tokenizer outperforms BPE on SMILES and SELFIES in RoBERTa-based chemical language models across MoleculeNet classification tasks.</description><content:encoded><![CDATA[<h2 id="atom-pair-encoding-for-chemical-language-modeling">Atom Pair Encoding for Chemical Language Modeling</h2>
<p>This is a <strong>Method</strong> paper that introduces Atom Pair Encoding (APE), a tokenization algorithm designed specifically for chemical string representations (<a href="/notes/chemistry/molecular-representations/notations/smiles/">SMILES</a> and <a href="/notes/chemistry/molecular-representations/notations/selfies/">SELFIES</a>). The primary contribution is demonstrating that a chemistry-aware tokenizer, which preserves atomic identity during subword merging, leads to improved molecular property classification accuracy in transformer-based models compared to the standard Byte Pair Encoding (BPE) approach.</p>
<h2 id="why-tokenization-matters-for-chemical-strings">Why Tokenization Matters for Chemical Strings</h2>
<p>Existing chemical language models based on BERT/RoBERTa architectures have typically relied on BPE for tokenizing SMILES and SELFIES strings. <a href="https://en.wikipedia.org/wiki/Byte-pair_encoding">Byte Pair Encoding (BPE)</a> was originally designed for natural language and data compression, where it excels at breaking words into meaningful subword units. When applied to chemical strings, BPE operates at the character level without understanding chemical semantics, leading to several problems:</p>
<ul>
<li><strong>Stray characters</strong>: BPE may create tokens like &ldquo;C)(&rdquo; that have no chemical meaning.</li>
<li><strong>Element splitting</strong>: Multi-character elements like chlorine (&ldquo;Cl&rdquo;) can be split into &ldquo;C&rdquo; and &ldquo;l&rdquo;, causing the model to misinterpret carbon and a dangling character.</li>
<li><strong>Lost structural context</strong>: BPE compresses sequences without considering how character position encodes molecular structure.</li>
</ul>
<p>Previous work on <a href="/notes/chemistry/molecular-representations/notations/smiles-pair-encoding/">SMILES Pair Encoding (SPE)</a> attempted to address this by iteratively merging SMILES substrings into chemically meaningful tokens. However, SPE had practical limitations: its Python implementation did not support SELFIES, and it produced a smaller vocabulary (~3000 tokens) than what the data could support. These gaps motivated the development of APE.</p>
<h2 id="the-ape-tokenizer-chemistry-aware-subword-merging">The APE Tokenizer: Chemistry-Aware Subword Merging</h2>
<p>APE draws inspiration from both BPE and SPE but addresses their shortcomings. The key design decisions are:</p>
<ol>
<li>
<p><strong>Atom-level initialization</strong>: Instead of starting from individual characters (as BPE does), APE begins with chemically valid atomic units. For SMILES, this means recognizing multi-character elements (e.g., &ldquo;Cl&rdquo;, &ldquo;Br&rdquo;) as single tokens. For SELFIES, each bracketed string (e.g., [C], [Ring1], [=O]) serves as the fundamental unit.</p>
</li>
<li>
<p><strong>Iterative pair merging</strong>: Like BPE, APE iteratively merges the most frequent adjacent token pairs. The difference is that the initial tokenization preserves atomic boundaries, so merged tokens always represent valid chemical substructures.</p>
</li>
<li>
<p><strong>Larger vocabulary</strong>: Using the same minimum frequency threshold of 2000, APE generates approximately 5300 unique tokens from the PubChem dataset, compared to SPE&rsquo;s approximately 3000. This richer vocabulary provides more expressive power for representing chemical substructures.</p>
</li>
<li>
<p><strong>SELFIES compatibility</strong>: APE natively supports both SMILES and SELFIES, using the bracketed token structure of SELFIES as its starting point for that representation.</p>
</li>
</ol>
<p>The tokenizer was trained on a subset of 2 million molecules from <a href="https://en.wikipedia.org/wiki/PubChem">PubChem</a> (10 million SMILES total). This produced four tokenizer variants: SMILES-BPE, SMILES-APE, SELFIES-BPE, and SELFIES-APE.</p>
<h2 id="pre-training-and-evaluation-on-moleculenet-benchmarks">Pre-training and Evaluation on MoleculeNet Benchmarks</h2>
<h3 id="model-architecture">Model architecture</h3>
<p>All four models use the RoBERTa architecture with 6 hidden layers, a hidden size of 768, an intermediate size of 1536, and 12 attention heads. Pre-training used masked language modeling (MLM) with 15% token masking on 1 million molecules from PubChem, with a validation set of 100,000 molecules. Each model was pre-trained for 20 epochs using AdamW, with hyperparameter optimization via Optuna.</p>
<h3 id="downstream-tasks">Downstream tasks</h3>
<p>The models were fine-tuned on three <a href="/notes/chemistry/molecular-design/property-prediction/moleculenet-benchmark-molecular-ml/">MoleculeNet</a> classification tasks:</p>
<table>
  <thead>
      <tr>
          <th>Dataset</th>
          <th>Category</th>
          <th>Compounds</th>
          <th>Tasks</th>
          <th>Metric</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>BBBP</td>
          <td>Physiology</td>
          <td>2,039</td>
          <td>1</td>
          <td>ROC-AUC</td>
      </tr>
      <tr>
          <td>HIV</td>
          <td>Biophysics</td>
          <td>41,127</td>
          <td>1</td>
          <td>ROC-AUC</td>
      </tr>
      <tr>
          <td>Tox21</td>
          <td>Physiology</td>
          <td>7,831</td>
          <td>12</td>
          <td>ROC-AUC</td>
      </tr>
  </tbody>
</table>
<p>Data was split 80/10/10 (train/validation/test) following MoleculeNet recommendations. Models were fine-tuned for 5 epochs with early stopping based on validation ROC-AUC.</p>
<h3 id="baselines">Baselines</h3>
<p>Results were compared against two text-based models (<a href="/notes/chemistry/molecular-representations/encoders/chemberta-2/">ChemBERTa-2</a> MTR-77M and <a href="/notes/chemistry/molecular-representations/encoders/selformer/">SELFormer</a>) and two graph-based models (D-MPNN from Chemprop and MoleculeNet Graph-Conv).</p>
<h3 id="main-results">Main results</h3>
<table>
  <thead>
      <tr>
          <th>Model</th>
          <th>BBBP ROC</th>
          <th>HIV ROC</th>
          <th>Tox21 ROC</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>SMILYAPE-1M</td>
          <td>0.754 +/- 0.006</td>
          <td>0.772 +/- 0.010</td>
          <td>0.838 +/- 0.002</td>
      </tr>
      <tr>
          <td>SMILYBPE-1M</td>
          <td>0.746 +/- 0.006</td>
          <td>0.754 +/- 0.015</td>
          <td>0.849 +/- 0.002</td>
      </tr>
      <tr>
          <td>SELFYAPE-1M</td>
          <td>0.735 +/- 0.015</td>
          <td>0.768 +/- 0.012</td>
          <td>0.842 +/- 0.002</td>
      </tr>
      <tr>
          <td>SELFYBPE-1M</td>
          <td>0.676 +/- 0.014</td>
          <td>0.709 +/- 0.012</td>
          <td>0.825 +/- 0.001</td>
      </tr>
      <tr>
          <td>ChemBERTa-2-MTR-77M</td>
          <td>0.698 +/- 0.014</td>
          <td>0.735 +/- 0.008</td>
          <td>0.790 +/- 0.003</td>
      </tr>
      <tr>
          <td>SELFormer</td>
          <td>0.716 +/- 0.021</td>
          <td>0.769 +/- 0.010</td>
          <td>0.838 +/- 0.005</td>
      </tr>
      <tr>
          <td>MoleculeNet-Graph-Conv</td>
          <td>0.690</td>
          <td>0.763</td>
          <td>0.829</td>
      </tr>
      <tr>
          <td>D-MPNN</td>
          <td>0.737</td>
          <td>0.776</td>
          <td>0.851</td>
      </tr>
  </tbody>
</table>
<p>APE consistently outperforms BPE for both SMILES and SELFIES. SMILYAPE achieves the best BBBP score (0.754), beating D-MPNN (0.737). On HIV, SMILYAPE (0.772) is competitive with D-MPNN (0.776). On Tox21, D-MPNN (0.851) leads, with SMILYBPE (0.849) and SELFYAPE (0.842) close behind.</p>
<h3 id="statistical-significance">Statistical significance</h3>
<p><a href="https://en.wikipedia.org/wiki/Mann%E2%80%93Whitney_U_test">Mann-Whitney U tests</a> confirmed statistically significant differences between SMILYAPE and SMILYBPE (p &lt; 0.05 on all datasets). Cliff&rsquo;s delta values indicate large effect sizes: 0.74 (BBBP), 0.70 (HIV), and -1.00 (Tox21, favoring BPE). For SELFIES models, SELFYAPE achieved Cliff&rsquo;s delta of 1.00 across all three datasets, indicating complete separation from SELFYBPE.</p>
<h2 id="key-findings-and-limitations">Key Findings and Limitations</h2>
<h3 id="ape-outperforms-bpe-by-preserving-atomic-identity">APE outperforms BPE by preserving atomic identity</h3>
<p>The consistent advantage of APE over BPE stems from APE&rsquo;s atom-level initialization. By starting with chemically valid units rather than individual characters, APE avoids creating nonsensical tokens that break chemical elements or mix structural delimiters with atoms.</p>
<h3 id="smiles-outperforms-selfies-with-ape-tokenization">SMILES outperforms SELFIES with APE tokenization</h3>
<p>SMILYAPE generally outperforms SELFYAPE across tasks. Attention weight analysis revealed that SMILYAPE assigns more weight to immediate neighboring tokens (0.108 vs. 0.096) and less to distant tokens (0.030 vs. 0.043). This pattern aligns with chemical intuition: bonding is primarily determined by directly connected atoms. SMILYAPE also produces more compact tokenizations (8.6 tokens per molecule vs. 11.9 for SELFYAPE), potentially allowing more efficient attention allocation.</p>
<h3 id="selfies-models-show-higher-inter-tokenizer-agreement">SELFIES models show higher inter-tokenizer agreement</h3>
<p>On the BBBP dataset, all true positives identified by SELFYBPE were also captured by SELFYAPE, with SELFYAPE achieving higher recall (61.68% vs. 55.14%). In contrast, SMILES-based models shared only 29.3% of true positives between APE and BPE variants, indicating that tokenization choice has a larger impact on SMILES models.</p>
<h3 id="limitations">Limitations</h3>
<ul>
<li>Pre-training used only 1 million molecules, compared to 77 million for ChemBERTa-2. Despite this, APE models were competitive or superior, but scaling effects remain unexplored.</li>
<li>Evaluation was limited to three binary classification tasks from MoleculeNet. Regression tasks, molecular generation, and reaction prediction were not tested.</li>
<li>The Tox21 result is notable: SMILYBPE outperforms SMILYAPE (0.849 vs. 0.838), suggesting APE&rsquo;s advantage may be task-dependent.</li>
<li>No comparison with recent atom-level tokenizers like <a href="/notes/chemistry/molecular-representations/notations/atom-in-smiles-tokenization/">Atom-in-SMILES</a> or newer approaches beyond SPE.</li>
</ul>
<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>Tokenizer training</td>
          <td>PubChem subset</td>
          <td>2M molecules</td>
          <td>SMILES strings converted to SELFIES via selfies library</td>
      </tr>
      <tr>
          <td>Pre-training</td>
          <td>PubChem subset</td>
          <td>1M molecules</td>
          <td>100K validation set</td>
      </tr>
      <tr>
          <td>Evaluation</td>
          <td>BBBP</td>
          <td>2,039 compounds</td>
          <td>80/10/10 split</td>
      </tr>
      <tr>
          <td>Evaluation</td>
          <td>HIV</td>
          <td>41,127 compounds</td>
          <td>80/10/10 split</td>
      </tr>
      <tr>
          <td>Evaluation</td>
          <td>Tox21</td>
          <td>7,831 compounds</td>
          <td>80/10/10 split, 12 tasks</td>
      </tr>
  </tbody>
</table>
<h3 id="algorithms">Algorithms</h3>
<ul>
<li>Tokenizers: BPE (via Hugging Face), APE (custom implementation, minimum frequency 2000)</li>
<li>Pre-training: Masked Language Modeling (15% masking) for 20 epochs</li>
<li>Optimizer: AdamW with Optuna hyperparameter search</li>
<li>Fine-tuning: 5 epochs with early stopping on validation ROC-AUC</li>
</ul>
<h3 id="models">Models</h3>
<ul>
<li>Architecture: RoBERTa with 6 layers, hidden size 768, intermediate size 1536, 12 attention heads</li>
<li>Four variants: SMILYAPE, SMILYBPE, SELFYAPE, SELFYBPE</li>
</ul>
<h3 id="evaluation">Evaluation</h3>
<table>
  <thead>
      <tr>
          <th>Metric</th>
          <th>SMILYAPE</th>
          <th>SMILYBPE</th>
          <th>SELFYAPE</th>
          <th>SELFYBPE</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>BBBP ROC-AUC</td>
          <td>0.754</td>
          <td>0.746</td>
          <td>0.735</td>
          <td>0.676</td>
      </tr>
      <tr>
          <td>HIV ROC-AUC</td>
          <td>0.772</td>
          <td>0.754</td>
          <td>0.768</td>
          <td>0.709</td>
      </tr>
      <tr>
          <td>Tox21 ROC-AUC</td>
          <td>0.838</td>
          <td>0.849</td>
          <td>0.842</td>
          <td>0.825</td>
      </tr>
  </tbody>
</table>
<h3 id="hardware">Hardware</h3>
<ul>
<li>NVIDIA RTX 3060 GPU with 12 GiB VRAM</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/mikemayuare/apetokenizer">APE Tokenizer</a></td>
          <td>Code</td>
          <td>Other (unspecified SPDX)</td>
          <td>Official APE tokenizer implementation</td>
      </tr>
      <tr>
          <td><a href="https://huggingface.co/datasets/mikemayuare/PubChem10M_SMILES_SELFIES">PubChem10M SMILES/SELFIES</a></td>
          <td>Dataset</td>
          <td>Not specified</td>
          <td>10M SMILES with SELFIES conversions</td>
      </tr>
      <tr>
          <td><a href="https://huggingface.co/mikemayuare">Pre-trained and fine-tuned models</a></td>
          <td>Model</td>
          <td>Not specified</td>
          <td>All four model variants on Hugging Face</td>
      </tr>
  </tbody>
</table>
<hr>
<h2 id="paper-information">Paper Information</h2>
<p><strong>Citation</strong>: Leon, M., Perezhohin, Y., Peres, F., Popovič, A., &amp; Castelli, M. (2024). Comparing SMILES and SELFIES tokenization for enhanced chemical language modeling. <em>Scientific Reports</em>, 14(1), 25016. <a href="https://doi.org/10.1038/s41598-024-76440-8">https://doi.org/10.1038/s41598-024-76440-8</a></p>
<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">@article</span>{leon2024comparing,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">title</span>=<span style="color:#e6db74">{Comparing SMILES and SELFIES tokenization for enhanced chemical language modeling}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">author</span>=<span style="color:#e6db74">{Leon, Miguelangel and Perezhohin, Yuriy and Peres, Fernando and Popovi{\v{c}}, Ale{\v{s}} and Castelli, Mauro}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">journal</span>=<span style="color:#e6db74">{Scientific Reports}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">volume</span>=<span style="color:#e6db74">{14}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">number</span>=<span style="color:#e6db74">{1}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">pages</span>=<span style="color:#e6db74">{25016}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">year</span>=<span style="color:#e6db74">{2024}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">publisher</span>=<span style="color:#e6db74">{Nature Publishing Group}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">doi</span>=<span style="color:#e6db74">{10.1038/s41598-024-76440-8}</span>
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div>]]></content:encoded></item><item><title>SMILES Transformer: Low-Data Molecular Fingerprints</title><link>https://hunterheidenreich.com/notes/chemistry/molecular-representations/encoders/smiles-transformer/</link><pubDate>Thu, 26 Mar 2026 00:00:00 +0000</pubDate><guid>https://hunterheidenreich.com/notes/chemistry/molecular-representations/encoders/smiles-transformer/</guid><description>SMILES Transformer uses unsupervised Transformer pre-training on SMILES strings to produce molecular fingerprints that excel in low-data drug discovery tasks.</description><content:encoded><![CDATA[<h2 id="a-transformer-approach-to-learned-molecular-fingerprints">A Transformer Approach to Learned Molecular Fingerprints</h2>
<p>This is a <strong>Method</strong> paper that introduces SMILES Transformer (ST), a Transformer-based sequence-to-sequence model pre-trained on unlabeled SMILES strings to produce continuous, data-driven molecular fingerprints. The primary contribution is demonstrating that unsupervised pre-training on chemical text representations yields fingerprints that generalize well under low-data conditions, outperforming both rule-based fingerprints (ECFP) and graph convolution models on several <a href="/notes/chemistry/molecular-design/property-prediction/moleculenet-benchmark-molecular-ml/">MoleculeNet</a> benchmarks. A secondary contribution is the Data Efficiency Metric (DEM), a scalar metric for evaluating model performance across varying training set sizes.</p>
<h2 id="the-low-data-problem-in-molecular-property-prediction">The Low-Data Problem in Molecular Property Prediction</h2>
<p>Machine learning for drug discovery depends on molecular representations, but labeled datasets of experimentally validated properties are typically small. Conventional approaches fall into two camps: rule-based fingerprints like ECFP that hash substructures into sparse binary vectors, and graph-based methods like GraphConv that learn representations end-to-end. Rule-based fingerprints perform poorly with shallow models or limited data, while graph-based methods are designed for large fully-labeled settings.</p>
<p>Pre-training on unlabeled data had shown strong results in NLP (ELMo, BERT, XLNet), and prior work in cheminformatics had explored RNN-based and VAE-based pre-training on SMILES (<a href="/notes/chemistry/molecular-representations/encoders/seq2seq-fingerprint-molecular-embedding/">Seq2Seq fingerprints</a>, <a href="/notes/chemistry/molecular-design/generation/latent-space/grammar-variational-autoencoder/">Grammar VAE</a>, heteroencoders). However, none of these studies systematically evaluated performance in small-data settings. Honda et al. fill this gap by applying Transformer-based pre-training to SMILES and measuring data efficiency explicitly.</p>
<h2 id="transformer-pre-training-on-smiles-with-pooled-fingerprint-extraction">Transformer Pre-training on SMILES with Pooled Fingerprint Extraction</h2>
<p>The core innovation is a Transformer encoder-decoder architecture pre-trained as an autoencoder on SMILES strings, with a specific fingerprint extraction strategy that pools the encoder outputs into a fixed-length vector.</p>
<h3 id="architecture">Architecture</h3>
<p>The model uses 4 Transformer blocks for both the encoder and decoder, each with 4-head attention and 256 embedding dimensions plus 2 linear layers. Input SMILES are tokenized at the symbol level (e.g., &lsquo;c&rsquo;, &lsquo;Br&rsquo;, &lsquo;=&rsquo;, &lsquo;(&rsquo;, &lsquo;2&rsquo;) and one-hot encoded. Following Vaswani et al. (2017), the input uses the sum of token encoding and positional encoding.</p>
<h3 id="pre-training">Pre-training</h3>
<p>The model is pre-trained on 861,000 unlabeled SMILES sampled from <a href="https://en.wikipedia.org/wiki/ChEMBL">ChEMBL24</a> to minimize cross-entropy between input and output SMILES (i.e., reconstruction). <a href="/notes/chemistry/molecular-representations/notations/randomized-smiles-generative-models/">SMILES enumeration</a> (Bjerrum, 2017) randomly generates non-canonical SMILES at each epoch to reduce representation bias. Training runs for 5 epochs with Adam optimization, reaching a perplexity of 1.0 (perfect decoding).</p>
<h3 id="fingerprint-extraction">Fingerprint Extraction</h3>
<p>Since the Transformer outputs symbol-level (atom-level) representations, a pooling strategy produces molecule-level fingerprints. Four vectors are concatenated:</p>
<ol>
<li>Mean-pooled output of the last encoder layer</li>
<li>Max-pooled output of the last encoder layer</li>
<li>First output token of the last encoder layer</li>
<li>First output token of the penultimate encoder layer</li>
</ol>
<p>This produces a 1024-dimensional fingerprint, matching the dimensionality of ECFP for fair comparison.</p>
<h3 id="data-efficiency-metric">Data Efficiency Metric</h3>
<p>The paper proposes DEM to measure how well a model performs across different training set sizes:</p>
<p>$$
M_{DE}(f, m) = \frac{1}{|I|} \sum_{i \in I} m(f_i, X_i, Y_i)
$$</p>
<p>where $f_i$ is the model trained on the fraction $i$ of training data, $m$ is the task metric, and $I = {0.0125, 0.025, 0.05, 0.1, 0.2, 0.4, 0.8}$ doubles the training percentage at each step. This captures average performance across a range of data availability, giving a single scalar that balances accuracy and data efficiency.</p>
<h2 id="benchmarking-across-moleculenet-with-data-efficiency-focus">Benchmarking Across MoleculeNet with Data Efficiency Focus</h2>
<h3 id="datasets">Datasets</h3>
<p>The evaluation uses 10 datasets from MoleculeNet spanning three categories:</p>
<table>
  <thead>
      <tr>
          <th>Category</th>
          <th>Dataset</th>
          <th>Tasks</th>
          <th>Type</th>
          <th>Molecules</th>
          <th>Metric</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>Physical chemistry</td>
          <td>ESOL</td>
          <td>1</td>
          <td>Regression</td>
          <td>1,128</td>
          <td>RMSE</td>
      </tr>
      <tr>
          <td>Physical chemistry</td>
          <td>FreeSolv</td>
          <td>1</td>
          <td>Regression</td>
          <td>643</td>
          <td>RMSE</td>
      </tr>
      <tr>
          <td>Physical chemistry</td>
          <td><a href="https://en.wikipedia.org/wiki/Lipophilicity">Lipophilicity</a></td>
          <td>1</td>
          <td>Regression</td>
          <td>4,200</td>
          <td>RMSE</td>
      </tr>
      <tr>
          <td>Biophysics</td>
          <td>MUV</td>
          <td>17</td>
          <td>Classification</td>
          <td>93,127</td>
          <td>PRC-AUC</td>
      </tr>
      <tr>
          <td>Biophysics</td>
          <td>HIV</td>
          <td>1</td>
          <td>Classification</td>
          <td>41,913</td>
          <td>ROC-AUC</td>
      </tr>
      <tr>
          <td>Biophysics</td>
          <td>BACE</td>
          <td>1</td>
          <td>Classification</td>
          <td>1,522</td>
          <td>ROC-AUC</td>
      </tr>
      <tr>
          <td>Physiology</td>
          <td>BBBP</td>
          <td>1</td>
          <td>Classification</td>
          <td>2,053</td>
          <td>ROC-AUC</td>
      </tr>
      <tr>
          <td>Physiology</td>
          <td>Tox21</td>
          <td>12</td>
          <td>Classification</td>
          <td>8,014</td>
          <td>ROC-AUC</td>
      </tr>
      <tr>
          <td>Physiology</td>
          <td>SIDER</td>
          <td>27</td>
          <td>Classification</td>
          <td>1,427</td>
          <td>ROC-AUC</td>
      </tr>
      <tr>
          <td>Physiology</td>
          <td>ClinTox</td>
          <td>2</td>
          <td>Classification</td>
          <td>1,491</td>
          <td>ROC-AUC</td>
      </tr>
  </tbody>
</table>
<h3 id="baselines">Baselines</h3>
<ul>
<li><strong>ECFP4</strong>: Rule-based extended-connectivity fingerprint with 1024 dimensions</li>
<li><strong>RNNS2S</strong>: RNN-based Seq2Seq pre-trained fingerprint (3-layer bidirectional GRU, same pre-training data as ST)</li>
<li><strong>GraphConv</strong>: Graph convolution network trained end-to-end on labeled data</li>
</ul>
<h3 id="experimental-setup">Experimental Setup</h3>
<p>All fingerprint methods use a simple MLP classifier/regressor from scikit-learn with default hyperparameters to isolate the fingerprint quality from model capacity. Datasets are randomly split (stratified for classification), and results are averaged over 20 trials. Note that random splits are used rather than scaffold splits for the DEM experiments.</p>
<h3 id="data-efficiency-results-dem">Data Efficiency Results (DEM)</h3>
<table>
  <thead>
      <tr>
          <th>Dataset</th>
          <th>ST+MLP</th>
          <th>ECFP+MLP</th>
          <th>RNNS2S+MLP</th>
          <th>GraphConv</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>ESOL (RMSE, lower is better)</td>
          <td><strong>1.144</strong></td>
          <td>1.741</td>
          <td>1.317</td>
          <td>1.673</td>
      </tr>
      <tr>
          <td>FreeSolv (RMSE, lower is better)</td>
          <td><strong>2.246</strong></td>
          <td>3.043</td>
          <td>2.987</td>
          <td>3.476</td>
      </tr>
      <tr>
          <td>Lipophilicity (RMSE, lower is better)</td>
          <td>1.169</td>
          <td><strong>1.090</strong></td>
          <td>1.219</td>
          <td><strong>1.062</strong></td>
      </tr>
      <tr>
          <td>MUV (PRC-AUC, higher is better)</td>
          <td>0.009</td>
          <td><strong>0.036</strong></td>
          <td>0.010</td>
          <td>0.004</td>
      </tr>
      <tr>
          <td>HIV (ROC-AUC, higher is better)</td>
          <td>0.683</td>
          <td>0.697</td>
          <td>0.682</td>
          <td><strong>0.723</strong></td>
      </tr>
      <tr>
          <td>BACE (ROC-AUC, higher is better)</td>
          <td>0.719</td>
          <td><strong>0.769</strong></td>
          <td>0.717</td>
          <td>0.744</td>
      </tr>
      <tr>
          <td>BBBP (ROC-AUC, higher is better)</td>
          <td><strong>0.900</strong></td>
          <td>0.760</td>
          <td>0.884</td>
          <td>0.795</td>
      </tr>
      <tr>
          <td>Tox21 (ROC-AUC, higher is better)</td>
          <td><strong>0.706</strong></td>
          <td>0.616</td>
          <td>0.702</td>
          <td>0.687</td>
      </tr>
      <tr>
          <td>SIDER (ROC-AUC, higher is better)</td>
          <td>0.559</td>
          <td><strong>0.588</strong></td>
          <td>0.558</td>
          <td>0.557</td>
      </tr>
      <tr>
          <td>ClinTox (ROC-AUC, higher is better)</td>
          <td><strong>0.963</strong></td>
          <td>0.515</td>
          <td>0.904</td>
          <td>0.936</td>
      </tr>
  </tbody>
</table>
<p>ST achieves the best DEM in 5 of 10 datasets (ESOL, FreeSolv, BBBP, Tox21, ClinTox), with particularly strong margins on ClinTox (+0.027 over GraphConv) and BBBP (+0.016 over RNNS2S).</p>
<h3 id="linear-model-experiments">Linear Model Experiments</h3>
<p>To further isolate fingerprint quality, the authors replace MLP with ridge/logistic regression with L2 penalty. On 8 datasets (excluding MUV and SIDER due to class imbalance issues), ST achieves best DEM in 5 of 8, confirming the fingerprint quality holds regardless of downstream model.</p>
<h3 id="stratified-analysis-by-molecule-size">Stratified Analysis by Molecule Size</h3>
<p>On BBBP stratified by SMILES length, ST&rsquo;s ROC-AUC increases with longer SMILES, similar to RNNS2S but unlike GraphConv which shows stable performance across lengths. This suggests text-based models extract richer information from longer sequences.</p>
<h3 id="comparison-with-record-scores-large-data">Comparison with Record Scores (Large Data)</h3>
<p>Under the large-data setting (80/10/10 train/val/test split with hyperparameter tuning via Optuna), ST achieves first place only in ClinTox (0.954) but performs comparably to ECFP and graph-based models on the other datasets. This confirms that ST&rsquo;s main advantage is in the low-data regime.</p>
<h2 id="strong-low-data-performance-with-caveats-on-scalability">Strong Low-Data Performance with Caveats on Scalability</h2>
<h3 id="key-findings">Key Findings</h3>
<ol>
<li>Transformer-based unsupervised pre-training on SMILES produces fingerprints that excel in low-data molecular property prediction, achieving best data efficiency on 5 of 10 MoleculeNet tasks.</li>
<li>The advantage is most pronounced on small datasets (ESOL with 1,128 molecules, FreeSolv with 643, BBBP with 2,053, ClinTox with 1,491) where pre-training enables good generalization.</li>
<li>With sufficient labeled data and hyperparameter tuning, ST fingerprints perform comparably to (but do not surpass) graph-based methods.</li>
<li>Longer SMILES provide richer information for text-based models, as shown by the stratified analysis on BBBP.</li>
</ol>
<h3 id="limitations">Limitations</h3>
<ul>
<li>Random splits are used for most DEM experiments rather than scaffold splits, which may inflate performance estimates for drug discovery applications where training and test molecules are structurally distinct.</li>
<li>The pre-training corpus (861K SMILES from ChEMBL24) is relatively small by modern standards.</li>
<li>MUV performance is poor across all methods (PRC-AUC near zero), suggesting the DEM framework may not be informative for extremely imbalanced or noisy datasets.</li>
<li>No comparison with BERT-style masked language model pre-training, which later work (<a href="/notes/chemistry/molecular-representations/encoders/chemberta/">ChemBERTa</a>) would show as a viable alternative.</li>
</ul>
<h3 id="future-directions">Future Directions</h3>
<p>The authors propose three directions: (1) replacing the Transformer with Transformer-XL to handle longer SMILES, (2) multi-task pre-training that jointly predicts molecular descriptors (e.g., molecular weight, <a href="https://en.wikipedia.org/wiki/Partition_coefficient">LogP</a>) alongside SMILES reconstruction, and (3) better exploitation of enumerated SMILES to constrain the latent space.</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>Pre-training</td>
          <td>ChEMBL24</td>
          <td>861,000 SMILES</td>
          <td>Unlabeled, randomly sampled</td>
      </tr>
      <tr>
          <td>Evaluation</td>
          <td>MoleculeNet (10 datasets)</td>
          <td>643 to 93,127 molecules</td>
          <td>See Table 1 for per-dataset details</td>
      </tr>
  </tbody>
</table>
<h3 id="algorithms">Algorithms</h3>
<ul>
<li>Transformer encoder-decoder: 4 blocks each, 4-head attention, 256 embedding dimensions</li>
<li>Pre-training: 5 epochs, Adam optimizer, cross-entropy loss, SMILES enumeration for augmentation</li>
<li>Fingerprint: 1024 dimensions from concatenated mean pool, max pool, and first-token outputs</li>
<li>Downstream: scikit-learn MLP (default hyperparameters) for DEM experiments; ridge/logistic regression for linear model experiments; Optuna for hyperparameter search in large-data comparison</li>
</ul>
<h3 id="models">Models</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/DSPsleeporg/smiles-transformer">smiles-transformer</a></td>
          <td>Code</td>
          <td>MIT</td>
          <td>Official implementation (Jupyter notebooks)</td>
      </tr>
  </tbody>
</table>
<h3 id="evaluation">Evaluation</h3>
<ul>
<li>DEM averaged over 7 training fractions (1.25% to 80%), 20 trials each</li>
<li>Random splits for DEM; scaffold splits for HIV, BACE, BBBP in large-data comparison</li>
<li>Metrics: RMSE (regression), ROC-AUC or PRC-AUC (classification) per MoleculeNet conventions</li>
</ul>
<h3 id="hardware">Hardware</h3>
<p>The paper does not specify GPU type or training time for the pre-training phase.</p>
<hr>
<h2 id="paper-information">Paper Information</h2>
<p><strong>Citation</strong>: Honda, S., Shi, S., &amp; Ueda, H. R. (2019). SMILES Transformer: Pre-trained Molecular Fingerprint for Low Data Drug Discovery. <em>arXiv preprint arXiv:1911.04738</em>.</p>
<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">@article</span>{honda2019smiles,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">title</span>=<span style="color:#e6db74">{SMILES Transformer: Pre-trained Molecular Fingerprint for Low Data Drug Discovery}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">author</span>=<span style="color:#e6db74">{Honda, Shion and Shi, Shoi and Ueda, Hiroki R.}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">journal</span>=<span style="color:#e6db74">{arXiv preprint arXiv:1911.04738}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">year</span>=<span style="color:#e6db74">{2019}</span>
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div>]]></content:encoded></item><item><title>SMI+AIS: Hybridizing SMILES with Environment Tokens</title><link>https://hunterheidenreich.com/notes/chemistry/molecular-representations/notations/smi-ais-hybrid-molecular-representation/</link><pubDate>Thu, 26 Mar 2026 00:00:00 +0000</pubDate><guid>https://hunterheidenreich.com/notes/chemistry/molecular-representations/notations/smi-ais-hybrid-molecular-representation/</guid><description>SMI+AIS hybridizes SMILES with Atom-In-SMILES tokens encoding local chemical environments, improving molecular generation binding affinity and synthesizability.</description><content:encoded><![CDATA[<h2 id="a-hybrid-molecular-representation-combining-smiles-and-chemical-environment-tokens">A Hybrid Molecular Representation Combining SMILES and Chemical-Environment Tokens</h2>
<p>This is a <strong>Method</strong> paper that introduces SMI+AIS(N), a hybrid molecular string representation combining standard <a href="/notes/chemistry/molecular-representations/notations/smiles/">SMILES</a> tokens with <a href="/notes/chemistry/molecular-representations/notations/atom-in-smiles-tokenization/">Atom-In-SMILES (AIS)</a> tokens. AIS tokens encode local chemical environment information (central atom, ring membership, and neighboring atoms) into a single token. The key contribution is a systematic hybridization strategy that selectively replaces the most frequent SMILES tokens with AIS equivalents, preserving SMILES grammar compatibility while enriching token diversity. The method is validated on molecular structure generation via latent space optimization for drug design.</p>
<h2 id="limitations-of-standard-smiles-for-machine-learning">Limitations of Standard SMILES for Machine Learning</h2>
<p>SMILES is the most widely adopted string-based molecular representation, used in major databases like ZINC and PubChem. Despite this ubiquity, SMILES has several well-known limitations for machine learning applications:</p>
<ol>
<li><strong>Non-unique representations</strong>: The same molecule can be encoded as multiple distinct SMILES strings.</li>
<li><strong>Invalid string generation</strong>: Generative models can produce syntactically invalid SMILES that do not correspond to any molecule.</li>
<li><strong>Limited token diversity</strong>: SMILES tokens map one-to-one to atoms or bonds, so the token vocabulary is restricted to the available atom and bond types.</li>
<li><strong>Insufficient chemical context</strong>: Individual SMILES tokens carry no information about the local chemical environment of an atom.</li>
</ol>
<p>Alternative representations like <a href="/notes/chemistry/molecular-representations/notations/selfies/">SELFIES</a> (guaranteeing validity) and <a href="/notes/chemistry/molecular-representations/notations/inchi-2013/">InChI</a> (guaranteeing uniqueness) address some of these issues but share the same fundamental limitation of low token diversity. The Atom-In-SMILES (AIS) representation (Ucak et al., 2023) enriches tokens with neighboring atom and ring information, but using AIS exclusively produces a large vocabulary with many infrequent tokens that can cause data sparsity problems. The authors aim to find a middle ground: adding chemical context to the most common tokens while keeping the vocabulary manageable.</p>
<h2 id="core-innovation-selective-token-hybridization-with-ais">Core Innovation: Selective Token Hybridization with AIS</h2>
<p>The SMI+AIS(N) representation hybridizes standard SMILES with AIS tokens through a frequency-based selection process:</p>
<h3 id="ais-token-structure">AIS Token Structure</h3>
<p>Each AIS token encodes three pieces of information about an atom, delimited by semicolons:</p>
<p>$$
\lbrack \text{central atom} ; \text{ring info} ; \text{neighbor atoms} \rbrack
$$</p>
<p>For example, the oxygen in a carboxyl group of benzoic acid is represented as <code>[O;!R;C]</code>, meaning: oxygen atom, not in a ring, bonded to carbon. In standard SMILES, this would simply be <code>O</code>.</p>
<h3 id="hybridization-procedure">Hybridization Procedure</h3>
<ol>
<li>Convert all SMILES strings in the <a href="/notes/chemistry/datasets/zinc-22/">ZINC database</a> to their full AIS representations.</li>
<li>Count the frequency of each AIS token across the database.</li>
<li>Select the top-N most frequent AIS tokens to form the hybrid vocabulary.</li>
<li>In the hybrid representation, atoms matching these top-N AIS tokens are written in AIS notation; all other atoms use standard SMILES notation.</li>
</ol>
<p>For benzoic acid, the hybridization produces:</p>
<p>$$
\text{SMI}: \texttt{O=C(O)c1ccccc1}
$$</p>
<p>$$
\text{SMI+AIS}: \texttt{\lbrack O;!R;C\rbrack=\lbrack C;!R;COO\rbrack(\lbrack OH;!R;C\rbrack)c1ccccc1}
$$</p>
<p>The parameter N controls vocabulary size. The authors test N = 50, 100, 150, and 200, finding that N = 100-150 provides the best balance for the ZINC database.</p>
<h3 id="token-frequency-rebalancing">Token Frequency Rebalancing</h3>
<p>A key benefit of hybridization is mitigating the severe token frequency imbalance in standard SMILES. Carbon (C), the most frequent element with ~184 million occurrences in ZINC, is represented by only 16 token types in SMILES. With SMI+AIS(200), carbon is distinguished into 145 token types based on chemical environment, with 74% of carbon occurrences represented by AIS tokens. Less common elements like halogens see minimal change (only 2% AIS representation), which avoids introducing unnecessarily rare tokens.</p>
<table>
  <thead>
      <tr>
          <th>Element</th>
          <th>Frequency</th>
          <th>SMILES Types</th>
          <th>SMI+AIS(100) Types (AIS %)</th>
          <th>SMI+AIS(200) Types (AIS %)</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>C</td>
          <td>183,860,954</td>
          <td>16</td>
          <td>78 (73%)</td>
          <td>145 (74%)</td>
      </tr>
      <tr>
          <td>O</td>
          <td>27,270,229</td>
          <td>8</td>
          <td>16 (11%)</td>
          <td>24 (11%)</td>
      </tr>
      <tr>
          <td>N</td>
          <td>26,022,928</td>
          <td>11</td>
          <td>32 (1%)</td>
          <td>46 (10%)</td>
      </tr>
      <tr>
          <td>X (halogens)</td>
          <td>6,137,030</td>
          <td>7</td>
          <td>10 (2%)</td>
          <td>11 (2%)</td>
      </tr>
      <tr>
          <td>S</td>
          <td>4,581,307</td>
          <td>12</td>
          <td>17 (2%)</td>
          <td>24 (2%)</td>
      </tr>
  </tbody>
</table>
<h2 id="latent-space-optimization-for-molecular-generation">Latent Space Optimization for Molecular Generation</h2>
<h3 id="model-architecture">Model Architecture</h3>
<p>The evaluation uses a <a href="/notes/chemistry/molecular-design/generation/latent-space/automatic-chemical-design-vae/">conditional variational autoencoder (CVAE)</a> with:</p>
<ul>
<li><strong>Encoder</strong>: BERT-style architecture with entity and positional embeddings, 4 multi-head attention layers (8 heads each), producing mean and standard deviation vectors in latent space.</li>
<li><strong>Decoder</strong>: 4 stacked gated recurrent unit (GRU) layers that transform sampled latent vectors (conditioned) back into token sequences.</li>
<li>Training: 20 epochs on 9 million compounds from the ZINC database (8:1:1 train/valid/test split) under identical conditions for all representations.</li>
</ul>
<h3 id="optimization-setup">Optimization Setup</h3>
<p><a href="https://en.wikipedia.org/wiki/Bayesian_optimization">Bayesian Optimization</a> (BO) via BoTorch is applied to the CVAE <a href="/notes/chemistry/molecular-design/generation/latent-space/">latent space</a>, maximizing a multi-objective function:</p>
<p>$$
\text{Obj} = -\text{BA} - 0.5 \times \text{SA}^2
$$</p>
<p>where BA is binding affinity (docking score from QuickVina 2, lower is stronger) and SA is synthetic accessibility score (from RDKit, lower is more synthesizable). Each BO iteration generates 800 candidate latent vectors. Invalid strings receive a penalty objective value of -100.</p>
<h3 id="protein-targets">Protein Targets</h3>
<p>Four diverse targets were used to assess generalizability:</p>
<ul>
<li><strong>PDK4</strong> (<a href="https://en.wikipedia.org/wiki/Pyruvate_dehydrogenase_kinase">Pyruvate Dehydrogenase Kinase</a> 4): narrow, deep binding pocket</li>
<li><strong>5-HT1B</strong> (<a href="https://en.wikipedia.org/wiki/5-HT1B_receptor">Serotonin Receptor 1B</a>): shallow, open <a href="https://en.wikipedia.org/wiki/G_protein-coupled_receptor">GPCR</a> conformation</li>
<li><strong>PARP1</strong> (<a href="https://en.wikipedia.org/wiki/PARP1">Poly ADP-ribose Polymerase 1</a>): small, flexible molecule binding site</li>
<li><strong>CK1d</strong> (<a href="https://en.wikipedia.org/wiki/Casein_kinase_1">Casein Kinase I</a> Delta): broad, accessible conformation</li>
</ul>
<p>Protein structures were obtained from the <a href="https://en.wikipedia.org/wiki/Protein_Data_Bank">Protein Data Bank</a> (PDB IDs: 4V26, 4IAQ, 6I8M, 4TN6). Each optimization was run 10 times independently from the same 5 initial compounds selected from BindingDB.</p>
<h3 id="key-results">Key Results</h3>
<p>SMI+AIS(100) consistently achieved the highest objective values across protein targets.</p>
<p><strong>PDK4 Optimization</strong> (Top-1 results over 10 independent runs):</p>
<ul>
<li>SMI+AIS(100) achieved approximately 12% improvement over standard SMILES and 28% improvement over SELFIES based on median Top-1 objective values.</li>
<li>Generated structures exhibited BA scores between -10 and -9 and SA scores between 2.0 and 2.3.</li>
<li>Molecular weights clustered around 400 amu, consistent with the CVAE conditioning.</li>
</ul>
<p><strong>Validity Ratios</strong>: Standard SMILES produced approximately 40% valid structures. SMI+AIS representations showed significant improvement as N increased, though SMI+AIS(200) showed slight saturation, likely from insufficiently trained infrequent tokens.</p>
<p><strong>SELFIES</strong>: Despite achieving the highest validity ratio, SELFIES failed to generate chemically meaningful structures with desirable BA and SA scores. The authors attribute this to SELFIES grammar where token meaning is highly context-dependent, causing minor latent space variations to produce large structural changes.</p>
<p><strong>Cross-target consistency</strong>: Improvements were observed across all four protein targets, with slight variation (5-HT1B showed smaller differences between SMI and SMI+AIS(100) for Top-1, while other targets showed significant improvements).</p>
<h2 id="improved-molecular-generation-through-chemical-context-enrichment">Improved Molecular Generation Through Chemical Context Enrichment</h2>
<p>The SMI+AIS(N) representation achieves consistent improvements in molecular generation quality compared to both standard SMILES and SELFIES. The core findings are:</p>
<ol>
<li><strong>Binding affinity improvement</strong>: Approximately 7% improvement over standard SMILES for the PDK4 target.</li>
<li><strong>Synthesizability improvement</strong>: Approximately 6% increase in synthetic accessibility scores.</li>
<li><strong>Target independence</strong>: Performance gains transfer across four structurally diverse protein targets.</li>
<li><strong>Preserved structural motifs</strong>: The generative model retains chemically meaningful fragments (e.g., acetamide and <a href="https://en.wikipedia.org/wiki/Piperidine">piperidine</a>) from initial compounds without explicit fragment constraints.</li>
</ol>
<h3 id="limitations">Limitations</h3>
<p>The authors acknowledge several limitations:</p>
<ul>
<li><strong>Stereochemistry</strong>: SMI+AIS inherits the limited stereochemistry handling of standard SMILES.</li>
<li><strong>Evaluation scope</strong>: Only molecular generation was tested; property prediction and other ML tasks remain unexplored.</li>
<li><strong>Compute constraints</strong>: The study was limited to molecular generation due to computing power and time.</li>
<li><strong>Single optimization strategy</strong>: Only latent space optimization with Bayesian optimization was evaluated; other generative approaches were not compared.</li>
</ul>
<h3 id="future-directions">Future Directions</h3>
<p>The authors suggest extending SMI+AIS to diverse benchmarking tests including molecular property prediction, experimental validation, and broader applications of chemical language models.</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>Training/Vocab</td>
          <td>ZINC Database</td>
          <td>9M compounds</td>
          <td>Canonicalized, deduplicated, split 8:1:1</td>
      </tr>
      <tr>
          <td>Binding targets</td>
          <td>BindingDB</td>
          <td>5 initial compounds per target</td>
          <td>Selected for each protein target</td>
      </tr>
      <tr>
          <td>Protein structures</td>
          <td>PDB</td>
          <td>4 structures</td>
          <td>IDs: 4V26, 4IAQ, 6I8M, 4TN6</td>
      </tr>
  </tbody>
</table>
<h3 id="algorithms">Algorithms</h3>
<ul>
<li><strong>Tokenization</strong>: AIS token frequency counting on full ZINC database, top-N selection</li>
<li><strong>Generative model</strong>: Conditional VAE with BERT encoder (4 layers, 8 heads) and GRU decoder (4 layers)</li>
<li><strong>Optimization</strong>: Bayesian Optimization via BoTorch (800 candidates per iteration)</li>
<li><strong>Docking</strong>: QuickVina 2 with 25 A pocket size, 10 docking simulations per ligand</li>
<li><strong>SA scoring</strong>: RDKit SA score</li>
<li>Training: 20 epochs for all representations under identical conditions</li>
</ul>
<h3 id="models">Models</h3>
<ul>
<li>CVAE architecture details in supplementary (Fig. S9, Tables S2, S4)</li>
<li>No pre-trained weights released</li>
</ul>
<h3 id="evaluation">Evaluation</h3>
<table>
  <thead>
      <tr>
          <th>Metric</th>
          <th>SMI+AIS(100) vs SMILES</th>
          <th>SMI+AIS(100) vs SELFIES</th>
          <th>Notes</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>Median Top-1 Obj. Value</td>
          <td>+12%</td>
          <td>+28%</td>
          <td>PDK4 target</td>
      </tr>
      <tr>
          <td>Validity Ratio</td>
          <td>Higher than ~40% (SMILES)</td>
          <td>Lower than SELFIES</td>
          <td>SMI+AIS improves with N</td>
      </tr>
      <tr>
          <td>BA (binding affinity)</td>
          <td>~7% improvement</td>
          <td>Substantial</td>
          <td>Lower (more negative) is better</td>
      </tr>
      <tr>
          <td>SA (synthesizability)</td>
          <td>~6% improvement</td>
          <td>Substantial</td>
          <td>Lower is more synthesizable</td>
      </tr>
  </tbody>
</table>
<h3 id="hardware">Hardware</h3>
<p>Hardware details are not specified in the main text. Optimization wall times are reported in supplementary Table S5.</p>
<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/herim-han/AIS-Drug-Opt">AIS-Drug-Opt</a></td>
          <td>Code</td>
          <td>Not specified</td>
          <td>Source code and datasets for reproduction</td>
      </tr>
  </tbody>
</table>
<p><strong>Reproducibility Status</strong>: Partially Reproducible. Code and processed data are publicly available on GitHub, but no pre-trained model weights are released, the license is unspecified, and hardware requirements are not documented in the main text.</p>
<hr>
<h2 id="paper-information">Paper Information</h2>
<p><strong>Citation</strong>: Han, H., Yeom, M. S., &amp; Choi, S. (2025). Hybridization of SMILES and chemical-environment-aware tokens to improve performance of molecular structure generation. <em>Scientific Reports</em>, 15, 16892. <a href="https://doi.org/10.1038/s41598-025-01890-7">https://doi.org/10.1038/s41598-025-01890-7</a></p>
<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">@article</span>{han2025hybridization,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">title</span>=<span style="color:#e6db74">{Hybridization of SMILES and chemical-environment-aware tokens to improve performance of molecular structure generation}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">author</span>=<span style="color:#e6db74">{Han, Herim and Yeom, Min Sun and Choi, Sunghwan}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">journal</span>=<span style="color:#e6db74">{Scientific Reports}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">volume</span>=<span style="color:#e6db74">{15}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">number</span>=<span style="color:#e6db74">{1}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">pages</span>=<span style="color:#e6db74">{16892}</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">publisher</span>=<span style="color:#e6db74">{Springer Nature}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">doi</span>=<span style="color:#e6db74">{10.1038/s41598-025-01890-7}</span>
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div>]]></content:encoded></item><item><title>SMI-TED: Encoder-Decoder Foundation Models for Chemistry</title><link>https://hunterheidenreich.com/notes/chemistry/molecular-representations/encoders/smi-ted-encoder-decoder-chemistry/</link><pubDate>Thu, 26 Mar 2026 00:00:00 +0000</pubDate><guid>https://hunterheidenreich.com/notes/chemistry/molecular-representations/encoders/smi-ted-encoder-decoder-chemistry/</guid><description>SMI-TED is a family of encoder-decoder transformer models pre-trained on 91M PubChem molecules for molecular property prediction and generation.</description><content:encoded><![CDATA[<h2 id="an-encoder-decoder-chemical-foundation-model-family">An Encoder-Decoder Chemical Foundation Model Family</h2>
<p>SMI-TED is a <strong>Method</strong> paper that introduces a family of encoder-decoder transformer-based foundation models for chemistry. The primary contribution is the SMI-TED289M architecture, a 289-million parameter model pre-trained on 91 million curated SMILES from PubChem, along with a Mixture-of-Experts variant (MoE-OSMI) that scales to 8x289M parameters. The models support molecular property prediction, molecule reconstruction, reaction yield prediction, and few-shot reasoning over molecular embeddings. All model weights and code are open-sourced under an Apache 2.0 license.</p>
<h2 id="bridging-encoding-and-decoding-for-molecular-representations">Bridging Encoding and Decoding for Molecular Representations</h2>
<p>Chemical language models based on <a href="/notes/chemistry/molecular-representations/notations/smiles/">SMILES</a> have gained traction for molecular property prediction and generation. Most existing models, such as <a href="/notes/chemistry/molecular-representations/encoders/molformer/">MoLFormer</a> and <a href="/notes/chemistry/molecular-representations/encoders/chemberta/">ChemBERTa</a>, are encoder-only architectures that produce molecular embeddings through mean pooling. While effective for downstream classification and regression, this encoder-only approach has a limitation: mean pooling has no natural inverse, meaning the model cannot reconstruct the input molecule from its latent representation. This restricts the model&rsquo;s utility for generative tasks and limits the interpretability of the learned latent space.</p>
<p>The authors argue that adding a decoder with a reconstruction objective forces the model to encode a more complete set of structural features. Prior work has shown that the quality of pre-training data matters more than the choice of SMILES vs. <a href="/notes/chemistry/molecular-representations/notations/selfies/">SELFIES</a>, and that large-scale pre-training can yield useful chemical representations. SMI-TED builds on these observations by combining an encoder-decoder architecture with a carefully curated 91-million molecule dataset from <a href="https://en.wikipedia.org/wiki/PubChem">PubChem</a>.</p>
<h2 id="invertible-pooling-and-two-phase-pre-training">Invertible Pooling and Two-Phase Pre-Training</h2>
<p>The core architectural innovation in SMI-TED is a learned pooling mechanism that replaces standard mean or max pooling with an invertible projection. Given token embeddings $\mathbf{x} \in \mathbb{R}^{D \times L}$ (where $D = 202$ is the maximum token count and $L = 768$ is the embedding dimension), the submersion into the latent space $\mathbf{z} \in \mathbb{R}^{L}$ is computed as:</p>
<p>$$
\mathbf{z} = \left(\text{LayerNorm}\left(\text{GELU}\left(\mathbf{W}_1^T \mathbf{x} + \mathbf{b}_1\right)\right)\right) \mathbf{W}_2
$$</p>
<p>where $\mathbf{W}_1 \in \mathbb{R}^{D \times L}$, $\mathbf{b}_1 \in \mathbb{R}^{L}$, and $\mathbf{W}_2 \in \mathbb{R}^{L \times L}$. The immersion (inverse mapping) back to the token space is:</p>
<p>$$
\tilde{\mathbf{x}}^T = \left(\text{LayerNorm}\left(\text{GELU}\left(\mathbf{z} \mathbf{W}_3 + \mathbf{b}_3\right)\right)\right) \mathbf{W}_4
$$</p>
<p>where $\mathbf{W}_3 \in \mathbb{R}^{L \times L}$, $\mathbf{b}_3 \in \mathbb{R}^{L}$, and $\mathbf{W}_4 \in \mathbb{R}^{L \times D}$. A decoder language model then predicts the next token from $\tilde{\mathbf{x}}$.</p>
<p>The encoder uses a modified RoFormer attention mechanism with rotary position embeddings:</p>
<p>$$
\text{Attention}_m(Q, K, V) = \frac{\sum_{n=1}^{N} \langle \varphi(R_m q_m), \varphi(R_n k_n) \rangle v_n}{\sum_{n=1}^{N} \langle \varphi(R_m q_m), \varphi(R_n k_n) \rangle}
$$</p>
<p>where $R_m$ are position-dependent rotation matrices and $\varphi$ is a random feature map.</p>
<p><strong>Two-phase pre-training strategy:</strong></p>
<ul>
<li><strong>Phase 1</strong>: The token encoder is pre-trained on 95% of the data using masked language modeling (15% token selection, of which 80% masked, 10% random, 10% unchanged). The remaining 5% trains the encoder-decoder layer, preventing convergence issues from unstable early embeddings.</li>
<li><strong>Phase 2</strong>: After the token embeddings converge, both the encoder and decoder train on 100% of the data jointly.</li>
</ul>
<p><strong><a href="https://en.wikipedia.org/wiki/Mixture_of_experts">Mixture-of-Experts</a> (MoE-OSMI):</strong> The MoE variant composes 8 fine-tuned SMI-TED289M expert models with a gating network. Given an input embedding $x$, the output is:</p>
<p>$$
y = \sum_{i=1}^{n} G(x)_i E_i(\hat{x})
$$</p>
<p>where $G(x) = \text{Softmax}(\text{TopK}(x \cdot W_g))$ selects the top $k = 2$ experts per input, setting all other gate values to zero.</p>
<h2 id="benchmarks-across-property-prediction-generation-and-reaction-yield">Benchmarks Across Property Prediction, Generation, and Reaction Yield</h2>
<h3 id="moleculenet-classification-6-datasets-roc-auc"><a href="/notes/chemistry/molecular-design/property-prediction/moleculenet-benchmark-molecular-ml/">MoleculeNet</a> classification (6 datasets, ROC-AUC)</h3>
<table>
  <thead>
      <tr>
          <th>Method</th>
          <th>BBBP</th>
          <th>ClinTox</th>
          <th>HIV</th>
          <th>BACE</th>
          <th>SIDER</th>
          <th>Tox21</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>MoLFormer</td>
          <td>73.6 +/- 0.8</td>
          <td>91.2 +/- 1.4</td>
          <td>80.5 +/- 1.65</td>
          <td>86.3 +/- 0.6</td>
          <td>65.5 +/- 0.2</td>
          <td>80.46 +/- 0.2</td>
      </tr>
      <tr>
          <td>Uni-Mol</td>
          <td>72.9 +/- 0.6</td>
          <td>91.9 +/- 1.8</td>
          <td>80.8 +/- 0.3</td>
          <td>85.7 +/- 0.2</td>
          <td>65.9 +/- 1.3</td>
          <td>79.6 +/- 0.5</td>
      </tr>
      <tr>
          <td>GEM</td>
          <td>72.4 +/- 0.4</td>
          <td>90.1 +/- 1.3</td>
          <td>80.6 +/- 0.9</td>
          <td>85.6 +/- 1.1</td>
          <td>67.2 +/- 0.4</td>
          <td>78.1 +/- 0.1</td>
      </tr>
      <tr>
          <td>SMI-TED289M (pre-trained)</td>
          <td>91.46 +/- 0.47</td>
          <td>93.49 +/- 0.85</td>
          <td>80.51 +/- 1.34</td>
          <td>85.58 +/- 0.92</td>
          <td>66.01 +/- 0.88</td>
          <td>81.53 +/- 0.45</td>
      </tr>
      <tr>
          <td>SMI-TED289M (fine-tuned)</td>
          <td><strong>92.26 +/- 0.57</strong></td>
          <td><strong>94.27 +/- 1.83</strong></td>
          <td>76.85 +/- 0.89</td>
          <td><strong>88.24 +/- 0.50</strong></td>
          <td>65.68 +/- 0.45</td>
          <td><strong>81.85 +/- 1.42</strong></td>
      </tr>
  </tbody>
</table>
<p>SMI-TED achieves the best results in 4 of 6 classification tasks. Notably, the pre-trained version (without fine-tuning) already matches or exceeds many baselines on BBBP, ClinTox, and Tox21.</p>
<h3 id="moleculenet-regression-5-datasets-mae-for-qm9qm8-rmse-for-esolfreesolvlipophilicity">MoleculeNet regression (5 datasets, MAE for QM9/QM8, RMSE for ESOL/FreeSolv/Lipophilicity)</h3>
<table>
  <thead>
      <tr>
          <th>Method</th>
          <th>QM9</th>
          <th>QM8</th>
          <th>ESOL</th>
          <th>FreeSolv</th>
          <th>Lipophilicity</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>MoLFormer</td>
          <td>1.5894</td>
          <td>0.0102</td>
          <td>0.880</td>
          <td>2.342</td>
          <td>0.700</td>
      </tr>
      <tr>
          <td>D-MPNN</td>
          <td>3.241</td>
          <td>0.0143</td>
          <td>0.98</td>
          <td>2.18</td>
          <td>0.65</td>
      </tr>
      <tr>
          <td>SMI-TED289M (fine-tuned)</td>
          <td><strong>1.3246</strong></td>
          <td><strong>0.0095</strong></td>
          <td><strong>0.6112</strong></td>
          <td><strong>1.2233</strong></td>
          <td><strong>0.5522</strong></td>
      </tr>
  </tbody>
</table>
<p>SMI-TED289M achieves the best results across all 5 regression tasks when fine-tuned. The improvements are substantial on ESOL (0.61 vs. 0.82 for next best) and FreeSolv (1.22 vs. 1.91 for next best).</p>
<h3 id="reaction-yield-prediction-buchwald-hartwig-c-n-cross-coupling">Reaction yield prediction (<a href="https://en.wikipedia.org/wiki/Buchwald%E2%80%93Hartwig_amination">Buchwald-Hartwig</a> C-N cross-coupling)</h3>
<p>The model was tested on Pd-catalyzed Buchwald-Hartwig reactions with 3,955 reactions across varying train/test splits. Selected $R^2$ results:</p>
<table>
  <thead>
      <tr>
          <th>Split</th>
          <th>Yield-BERT (Aug)</th>
          <th>DRFP</th>
          <th>SMI-TED289M</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>70/30</td>
          <td>0.97</td>
          <td>0.95</td>
          <td><strong>0.984</strong></td>
      </tr>
      <tr>
          <td>10/90</td>
          <td>0.81</td>
          <td>0.81</td>
          <td><strong>0.961</strong></td>
      </tr>
      <tr>
          <td>2.5/97.5</td>
          <td>0.61</td>
          <td>0.62</td>
          <td><strong>0.875</strong></td>
      </tr>
      <tr>
          <td>Test 1-4 avg</td>
          <td>0.58</td>
          <td>0.71</td>
          <td><strong>0.983</strong></td>
      </tr>
  </tbody>
</table>
<p>SMI-TED shows particularly strong performance in low-data regimes. With only 2.5% training data, it achieves $R^2 = 0.875$, compared to 0.61-0.62 for competing methods.</p>
<h3 id="moses-molecular-generation-benchmarks"><a href="/notes/chemistry/molecular-design/generation/evaluation/molecular-sets-moses/">MOSES</a> molecular generation benchmarks</h3>
<p>SMI-TED is competitive with baselines including CharRNN, SMILES VAE, JT-VAE, <a href="/notes/chemistry/molecular-design/generation/latent-space/limo-latent-inceptionism/">LIMO</a>, <a href="/notes/chemistry/molecular-design/generation/autoregressive/molgen-molecular-generation-chemical-feedback/">MolGen-7b</a>, and <a href="/notes/chemistry/molecular-design/generation/autoregressive/gp-molformer/">GP-MoLFormer</a> on standard metrics (validity, uniqueness, novelty, FCD, internal diversity). It achieves superior scaffold cosine similarity (Scaf) and nearest-neighbor similarity (SNN) scores.</p>
<h3 id="latent-space-compositionality">Latent space compositionality</h3>
<p>Using six families of carbon chains ($\mathcal{F} = {CC, CO, CN, CS, CF, CP}$), the authors test whether the embedding space respects hierarchical distance structures. A linear regression on SMI-TED embeddings yields $R^2 = 0.99$ and $MSE = 0.002$, compared to $R^2 = 0.55$ and $MSE = 0.237$ for MoLFormer. This indicates that the SMI-TED latent space captures compositional chemical relationships far more faithfully.</p>
<p>For structure-property analysis on QM9, nitrogen-containing molecules represent 9.10% of the dataset but account for 32.81% of the top 10% by HOMO energy. In the SMI-TED latent space, these molecules cluster distinctly (<a href="https://en.wikipedia.org/wiki/Davies%E2%80%93Bouldin_index">Davies-Bouldin index</a> of 2.82 vs. 4.28 for MoLFormer), suggesting the decoder objective encourages encoding of functional group information.</p>
<h2 id="strong-performance-with-a-compositional-latent-space">Strong Performance with a Compositional Latent Space</h2>
<p>SMI-TED289M demonstrates competitive or superior performance across molecular property prediction, reaction yield prediction, and molecular generation benchmarks. The key findings include:</p>
<ol>
<li><strong>Broad applicability</strong>: The single pre-trained model achieves strong results across classification (4/6 best), regression (5/5 best), reaction yield, and generation tasks.</li>
<li><strong>Low-data robustness</strong>: The pre-training on 91M molecules provides chemical knowledge that transfers well to small training sets, as shown by the reaction yield experiments where SMI-TED maintains high accuracy even at 2.5% training data.</li>
<li><strong>Compositional embeddings</strong>: The encoder-decoder architecture produces a latent space where molecular similarity follows chemical intuition, with near-perfect linear relationships between functional group families ($R^2 = 0.99$).</li>
<li><strong>Structure-property capture</strong>: The reconstruction objective appears to enforce encoding of chemically meaningful features like nitrogen substituent effects on <a href="https://en.wikipedia.org/wiki/HOMO_and_LUMO">HOMO</a> energy, outperforming encoder-only models in latent space organization.</li>
</ol>
<p><strong>Limitations</strong>: The paper evaluates on MoleculeNet benchmarks, which are well-studied but may not reflect performance on more diverse chemical tasks. The BBBP classification result (92.26) shows a large jump from prior methods (73.6 for MoLFormer), which is worth scrutinizing. The MoE variant is evaluated only in supplementary materials, and scaling behavior beyond 8 experts is not explored.</p>
<p><strong>Future directions</strong>: The authors note that compositionality of the learned representations suggests potential for reasoning applications, though they acknowledge that stronger claims require further studies following compositionality analysis methodologies from natural language processing. The model has been integrated into the dZiner agent for inverse molecular design.</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>Pre-training</td>
          <td>PubChem (curated)</td>
          <td>91M molecules, 4B tokens</td>
          <td>Deduplicated, canonicalized, validity-checked</td>
      </tr>
      <tr>
          <td>Classification</td>
          <td>MoleculeNet (BBBP, ClinTox, HIV, BACE, SIDER, Tox21)</td>
          <td>Varies</td>
          <td>Original benchmark splits</td>
      </tr>
      <tr>
          <td>Regression</td>
          <td>MoleculeNet (QM9, QM8, ESOL, FreeSolv, Lipophilicity)</td>
          <td>Varies</td>
          <td>Original benchmark splits</td>
      </tr>
      <tr>
          <td>Generation</td>
          <td>MOSES</td>
          <td>1.94M molecules</td>
          <td>Train/test/scaffold test splits</td>
      </tr>
      <tr>
          <td>Reaction yield</td>
          <td>Buchwald-Hartwig HTE</td>
          <td>3,955 reactions</td>
          <td>3x 1536-well plates</td>
      </tr>
  </tbody>
</table>
<h3 id="algorithms">Algorithms</h3>
<ul>
<li>Masked language modeling for token encoder (15% selection: 80% masked, 10% random, 10% unchanged)</li>
<li>Two-phase pre-training (95/5 split then 100% joint training)</li>
<li>RoFormer attention with rotary position embeddings</li>
<li>Vocabulary: 2,993 tokens (2,988 molecular + 5 special)</li>
<li>Maximum sequence length: 202 tokens (covers 99.4% of PubChem)</li>
<li>Learning rate: 1.6e-4, batch size: 288 molecules</li>
<li>40 epochs over the full PubChem corpus</li>
<li>10 random seeds per experiment for robustness</li>
</ul>
<h3 id="models">Models</h3>
<table>
  <thead>
      <tr>
          <th>Variant</th>
          <th>Parameters</th>
          <th>Encoder</th>
          <th>Decoder</th>
          <th>Description</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>SMI-TED289M base</td>
          <td>289M</td>
          <td>47M</td>
          <td>242M</td>
          <td>12 layers, 12 attention heads, hidden size 768, dropout 0.2</td>
      </tr>
      <tr>
          <td>MoE-OSMI</td>
          <td>8x289M</td>
          <td>-</td>
          <td>-</td>
          <td>8 experts, top-k=2 routing, gating network</td>
      </tr>
  </tbody>
</table>
<h3 id="evaluation">Evaluation</h3>
<ul>
<li>Classification: ROC-AUC</li>
<li>Regression: MAE (QM9, QM8), RMSE (ESOL, FreeSolv, Lipophilicity)</li>
<li>Reaction yield: $R^2$</li>
<li>Generation: Validity, uniqueness, novelty, FCD, IntDiv, Scaf, SNN (MOSES metrics)</li>
<li>Latent space: Linear regression $R^2$, MSE, Davies-Bouldin index, t-SNE visualization</li>
</ul>
<h3 id="hardware">Hardware</h3>
<ul>
<li>24 NVIDIA V100 GPUs (16GB)</li>
<li>4 nodes with DDP (Distributed Data Parallel)</li>
<li>Pre-training: 40 epochs on 91M molecules</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/IBM/materials/tree/main/models/smi_ted">IBM/materials (smi_ted)</a></td>
          <td>Code</td>
          <td>Apache-2.0</td>
          <td>Training, fine-tuning scripts, Jupyter notebooks</td>
      </tr>
      <tr>
          <td><a href="https://huggingface.co/ibm/materials.smi-ted">ibm/materials.smi-ted</a></td>
          <td>Model</td>
          <td>Apache-2.0</td>
          <td>Pre-trained model weights</td>
      </tr>
      <tr>
          <td><a href="https://doi.org/10.5281/zenodo.15603701">Zenodo archive</a></td>
          <td>Code + Data</td>
          <td>Apache-2.0</td>
          <td>Archival copy of scripts</td>
      </tr>
  </tbody>
</table>
<hr>
<h2 id="paper-information">Paper Information</h2>
<p><strong>Citation</strong>: Soares, E., Vital Brazil, E., Shirasuna, V., Zubarev, D., Cerqueira, R., &amp; Schmidt, K. (2025). An open-source family of large encoder-decoder foundation models for chemistry. <em>Communications Chemistry</em>, 8(1). <a href="https://doi.org/10.1038/s42004-025-01585-0">https://doi.org/10.1038/s42004-025-01585-0</a></p>
<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">@article</span>{soares2025smited,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">title</span>=<span style="color:#e6db74">{An open-source family of large encoder-decoder foundation models for chemistry}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">author</span>=<span style="color:#e6db74">{Soares, Eduardo and Vital Brazil, Emilio and Shirasuna, Victor and Zubarev, Dmitry and Cerqueira, Renato and Schmidt, Kristin}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">journal</span>=<span style="color:#e6db74">{Communications Chemistry}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">volume</span>=<span style="color:#e6db74">{8}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">number</span>=<span style="color:#e6db74">{1}</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">publisher</span>=<span style="color:#e6db74">{Nature Publishing Group}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">doi</span>=<span style="color:#e6db74">{10.1038/s42004-025-01585-0}</span>
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div>]]></content:encoded></item><item><title>Seq2seq Fingerprint: Unsupervised Molecular Embedding</title><link>https://hunterheidenreich.com/notes/chemistry/molecular-representations/encoders/seq2seq-fingerprint-molecular-embedding/</link><pubDate>Thu, 26 Mar 2026 00:00:00 +0000</pubDate><guid>https://hunterheidenreich.com/notes/chemistry/molecular-representations/encoders/seq2seq-fingerprint-molecular-embedding/</guid><description>Seq2seq fingerprint uses a GRU encoder-decoder trained on SMILES self-translation to produce unsupervised molecular embeddings for property prediction.</description><content:encoded><![CDATA[<h2 id="an-unsupervised-seq2seq-method-for-molecular-fingerprints">An Unsupervised Seq2seq Method for Molecular Fingerprints</h2>
<p>This is a <strong>Method</strong> paper that introduces seq2seq fingerprint, an unsupervised molecular embedding approach based on sequence-to-sequence learning. The core idea is to train a <a href="https://en.wikipedia.org/wiki/Gated_recurrent_unit">GRU</a> encoder-decoder network to translate <a href="/notes/chemistry/molecular-representations/notations/smiles/">SMILES</a> strings to themselves, then extract the intermediate fixed-length vector as a molecular fingerprint. These fingerprints are then used with standard supervised classifiers for downstream property prediction tasks such as solubility classification and promiscuity prediction.</p>
<h2 id="the-labeled-data-bottleneck-in-drug-discovery">The Labeled Data Bottleneck in Drug Discovery</h2>
<p>Machine learning approaches to molecular property prediction depend on fixed-length feature vectors as inputs. Traditional molecular fingerprints fall into two categories: hash-based methods like Extended-Connectivity Fingerprints (ECFP) that are fast but lossy and non-invertible, and biologist-guided local-feature fingerprints that require domain expertise and are task-specific. Supervised deep learning fingerprints (e.g., neural fingerprints) can learn representations from data but require large amounts of labeled data, which is expensive to obtain in drug discovery due to the cost of biological experiments.</p>
<p>The authors identify three limitations of existing approaches:</p>
<ol>
<li>Hash-based fingerprints discard information during the hashing process and cannot reconstruct the original molecule</li>
<li>Local-feature fingerprints require expert knowledge and generalize poorly across tasks</li>
<li>Supervised deep learning fingerprints are data-hungry and fail when labeled data is limited</li>
</ol>
<h2 id="self-translation-as-unsupervised-molecular-encoding">Self-Translation as Unsupervised Molecular Encoding</h2>
<p>The key insight is to adapt the <a href="https://en.wikipedia.org/wiki/Seq2seq">sequence-to-sequence</a> learning framework from machine translation (originally English-to-French) to molecular representation learning by setting both the input and output to the same SMILES string. Since the intermediate vector must contain enough information to reconstruct the original SMILES, it serves as a rich, task-agnostic molecular fingerprint.</p>
<p>The architecture consists of two components:</p>
<ul>
<li><strong>Perceiver network</strong>: A multi-layer GRU encoder that reads the SMILES string and compresses it into a fixed-length vector</li>
<li><strong>Interpreter network</strong>: A multi-layer GRU decoder that reconstructs the original SMILES from the fingerprint vector</li>
</ul>
<p>The GRU cell computes a sequence of outputs $(s_1, \ldots, s_T)$ from input sequences $(x_1, \ldots, x_T)$ by iterating:</p>
<p>$$
z_t = \sigma_g(W_z x_t + U_z s_{t-1} + b_z)
$$</p>
<p>$$
r_t = \sigma_r(W_r x_t + U_r s_{t-1} + b_r)
$$</p>
<p>$$
h_t = \tanh(U_h x_t + W_h(s_{t-1} \circ r_t))
$$</p>
<p>$$
s_t = (1 - z_t) \circ h_{t-1} + z_t \circ s_{t-1}
$$</p>
<p>where $z_t$ is the update gate, $r_t$ is the reset gate, $\circ$ denotes element-wise multiplication, and $W$, $U$, $b$ are trainable parameters.</p>
<p>Several adaptations to the original seq2seq framework make this work for molecular data:</p>
<ol>
<li><strong>GRU instead of LSTM</strong>: GRU provides comparable performance with faster training, which is important given the large training data pool</li>
<li><strong>Attention mechanism</strong>: Establishes a stronger connection between the perceiver and interpreter networks via soft alignment, addressing the challenge of passing information through hidden memory for long sequences (SMILES can be up to 250 characters)</li>
<li><strong>Dropout layers</strong>: Added to input and output gates (but not hidden memory transfer) following the approach of Zaremba et al. to combat overfitting when training on large datasets</li>
<li><strong>Fingerprint extraction layer</strong>: A fixed-unit fully connected layer combined with a GRU cell state concatenation layer is inserted between encoder and decoder to explicitly output the fingerprint vector</li>
<li><strong>Reverse target sequence</strong>: Following Sutskever et al., the target sequence is reversed to improve SGD optimization</li>
<li><strong>Bucket training</strong>: Sequences are distributed into buckets by length and padded to enable GPU parallelization</li>
</ol>
<h2 id="classification-experiments-on-logp-and-pm2-datasets">Classification Experiments on LogP and PM2 Datasets</h2>
<h3 id="training-setup">Training Setup</h3>
<p>The unsupervised training used 334,092 valid SMILES representations from combined LogP and PM2-full datasets obtained from the National Center for Advancing Translational Sciences (NCATS) at NIH. Three model variants were trained with fingerprint dimensions of 512, 768, and 1024, differing in the number of GRU layers (2, 3, and 4 respectively) while keeping the latent dimension at 256. Each model was trained for 24 hours on a workstation with an Intel i7-6700K CPU, 16 GB RAM, and an NVIDIA GTX 1080 GPU.</p>
<h3 id="reconstruction-performance">Reconstruction Performance</h3>
<p>The models were evaluated on their ability to reconstruct SMILES strings from their fingerprints:</p>
<table>
  <thead>
      <tr>
          <th>Model</th>
          <th>GRU Layers</th>
          <th>Latent Dim</th>
          <th>Perplexity</th>
          <th>Exact Match Accuracy</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>seq2seq-512</td>
          <td>2</td>
          <td>256</td>
          <td>1.00897</td>
          <td>94.24%</td>
      </tr>
      <tr>
          <td>seq2seq-768</td>
          <td>3</td>
          <td>256</td>
          <td>1.00949</td>
          <td>92.92%</td>
      </tr>
      <tr>
          <td>seq2seq-1024</td>
          <td>4</td>
          <td>256</td>
          <td>1.01472</td>
          <td>90.26%</td>
      </tr>
  </tbody>
</table>
<p>Deeper models showed lower reconstruction accuracy, possibly because larger fingerprint spaces introduce more null spaces and require longer training to converge.</p>
<h3 id="classification-results">Classification Results</h3>
<p>Two labeled datasets were used for downstream classification:</p>
<ul>
<li><strong>LogP</strong>: 10,850 samples with <a href="https://en.wikipedia.org/wiki/Partition_coefficient">water-octanol partition coefficient</a> values, binarized at a threshold of 1.88</li>
<li><strong>PM2-10k</strong>: 10,000 samples with binary promiscuity class labels</li>
</ul>
<p>The seq2seq fingerprints were evaluated with three ensemble classifiers (<a href="https://en.wikipedia.org/wiki/AdaBoost">AdaBoost</a>, <a href="https://en.wikipedia.org/wiki/Gradient_boosting">GradientBoost</a>, RandomForest) against circular fingerprints (ECFP) and neural fingerprints. Results are 100-run averages of 5-fold cross-validation accuracy.</p>
<p><strong>LogP classification accuracy:</strong></p>
<table>
  <thead>
      <tr>
          <th>Method</th>
          <th>Mean Accuracy</th>
          <th>Std Dev</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>Circular FP (ECFP)</td>
          <td>0.3674</td>
          <td>0.0074</td>
      </tr>
      <tr>
          <td>Neural FP</td>
          <td>0.6080</td>
          <td>0.0135</td>
      </tr>
      <tr>
          <td>Seq2seq-1024 + GradientBoost</td>
          <td><strong>0.7664</strong></td>
          <td>0.0043</td>
      </tr>
      <tr>
          <td>Seq2seq-1024 + AdaBoost</td>
          <td>0.7342</td>
          <td>0.0042</td>
      </tr>
      <tr>
          <td>Seq2seq-512 + GradientBoost</td>
          <td>0.7350</td>
          <td>0.0060</td>
      </tr>
  </tbody>
</table>
<p><strong>PM2-10k classification accuracy:</strong></p>
<table>
  <thead>
      <tr>
          <th>Method</th>
          <th>Mean Accuracy</th>
          <th>Std Dev</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>Circular FP (ECFP)</td>
          <td>0.3938</td>
          <td>0.0114</td>
      </tr>
      <tr>
          <td>Neural FP</td>
          <td>0.5227</td>
          <td>0.0112</td>
      </tr>
      <tr>
          <td>Seq2seq-1024 + GradientBoost</td>
          <td><strong>0.6206</strong></td>
          <td>0.0198</td>
      </tr>
      <tr>
          <td>Seq2seq-1024 + AdaBoost</td>
          <td>0.6036</td>
          <td>0.0147</td>
      </tr>
      <tr>
          <td>Seq2seq-512 + GradientBoost</td>
          <td>0.5741</td>
          <td>0.0086</td>
      </tr>
  </tbody>
</table>
<p>The seq2seq fingerprint outperformed both baselines across all configurations. Despite the seq2seq-1024 model having lower reconstruction accuracy, it provided the best classification performance, suggesting that the longer fingerprint captures more discriminative information for downstream tasks even if the reconstruction is less exact.</p>
<h2 id="unsupervised-transfer-learning-for-molecular-properties">Unsupervised Transfer Learning for Molecular Properties</h2>
<p>The results demonstrate that unsupervised pretraining on large unlabeled molecular datasets can produce fingerprints that transfer well to supervised property prediction with limited labels. The key advantages confirmed by the experiments are:</p>
<ol>
<li><strong>Label-free training</strong>: The unsupervised approach uses essentially unlimited SMILES data, avoiding the expensive label collection process</li>
<li><strong>Task-agnostic representations</strong>: The same fingerprints work across different classification tasks (solubility and promiscuity) without retraining</li>
<li><strong>Invertibility</strong>: The fingerprints contain enough information to reconstruct the original SMILES (up to 94.24% exact match), unlike hash-based methods</li>
</ol>
<p><strong>Limitations</strong> acknowledged by the authors include:</p>
<ul>
<li>Long training times (24 hours per model variant), motivating future work on distributed training</li>
<li>The relationship between fingerprint dimensionality and downstream performance is non-monotonic (768-dim underperforms 512-dim on some tasks), suggesting sensitivity to hyperparameter choices</li>
<li>Only classification tasks were evaluated; regression performance was not assessed</li>
<li>The comparison baselines are limited to ECFP and neural fingerprints from 2015</li>
</ul>
<p><strong>Future directions</strong> proposed include distributed training strategies, hyperparameter optimization methods, and semi-supervised extensions that incorporate label information into the fingerprint training.</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>Unsupervised training</td>
          <td>LogP + PM2-full (combined)</td>
          <td>334,092 SMILES</td>
          <td>Obtained from NCATS at NIH</td>
      </tr>
      <tr>
          <td>Classification</td>
          <td>LogP</td>
          <td>10,850 samples</td>
          <td>Binary labels at LogP threshold 1.88</td>
      </tr>
      <tr>
          <td>Classification</td>
          <td>PM2-10k</td>
          <td>10,000 samples</td>
          <td>Binary promiscuity labels</td>
      </tr>
  </tbody>
</table>
<h3 id="algorithms">Algorithms</h3>
<ul>
<li>Encoder-decoder: Multi-layer GRU with attention mechanism and dropout</li>
<li>Fingerprint dimensions: 512, 768, 1024 (with 2, 3, 4 GRU layers respectively)</li>
<li>Latent dimension: 256 for all variants</li>
<li>Downstream classifiers: AdaBoost, GradientBoost, RandomForest</li>
<li>Evaluation: 5-fold cross-validation, 100-run averages</li>
<li>Baselines: ECFP via RDKit, Neural Fingerprint from HIPS/neural-fingerprint</li>
</ul>
<h3 id="models">Models</h3>
<p>Three model variants trained for 24 hours each. The paper states code would become publicly available after acceptance, but no public repository has been confirmed.</p>
<h3 id="evaluation">Evaluation</h3>
<table>
  <thead>
      <tr>
          <th>Metric</th>
          <th>Best Value</th>
          <th>Task</th>
          <th>Configuration</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>Classification accuracy</td>
          <td>0.7664</td>
          <td>LogP</td>
          <td>seq2seq-1024 + GradientBoost</td>
      </tr>
      <tr>
          <td>Classification accuracy</td>
          <td>0.6206</td>
          <td>PM2-10k</td>
          <td>seq2seq-1024 + GradientBoost</td>
      </tr>
      <tr>
          <td>Exact match reconstruction</td>
          <td>94.24%</td>
          <td>SMILES recovery</td>
          <td>seq2seq-512</td>
      </tr>
      <tr>
          <td>Perplexity</td>
          <td>1.00897</td>
          <td>SMILES recovery</td>
          <td>seq2seq-512</td>
      </tr>
  </tbody>
</table>
<h3 id="hardware">Hardware</h3>
<ul>
<li>Training: Intel i7-6700K @ 4.00 GHz, 16 GB RAM, NVIDIA GTX 1080 GPU</li>
<li>Hyperparameter search and classifier training: TACC Lonestar 5 cluster</li>
<li>Training time: 24 hours per model variant</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/HIPS/neural-fingerprint">Neural Fingerprint (baseline)</a></td>
          <td>Code</td>
          <td>MIT</td>
          <td>Baseline comparison code</td>
      </tr>
  </tbody>
</table>
<p>The authors indicated the seq2seq fingerprint code would be released after acceptance, but no public repository has been found as of this writing. The datasets were sourced from NCATS/NIH.</p>
<hr>
<h2 id="paper-information">Paper Information</h2>
<p><strong>Citation</strong>: Xu, Z., Wang, S., Zhu, F., &amp; Huang, J. (2017). Seq2seq Fingerprint: An Unsupervised Deep Molecular Embedding for Drug Discovery. <em>Proceedings of the 8th ACM International Conference on Bioinformatics, Computational Biology, and Health Informatics (ACM-BCB &lsquo;17)</em>, 285-294. <a href="https://doi.org/10.1145/3107411.3107424">https://doi.org/10.1145/3107411.3107424</a></p>
<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>{xu2017seq2seq,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">title</span>=<span style="color:#e6db74">{Seq2seq Fingerprint: An Unsupervised Deep Molecular Embedding for Drug Discovery}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">author</span>=<span style="color:#e6db74">{Xu, Zheng and Wang, Sheng and Zhu, Feiyun and Huang, Junzhou}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">booktitle</span>=<span style="color:#e6db74">{Proceedings of the 8th ACM International Conference on Bioinformatics, Computational Biology, and Health Informatics}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">pages</span>=<span style="color:#e6db74">{285--294}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">year</span>=<span style="color:#e6db74">{2017}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">publisher</span>=<span style="color:#e6db74">{ACM}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">doi</span>=<span style="color:#e6db74">{10.1145/3107411.3107424}</span>
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div>]]></content:encoded></item><item><title>Randomized SMILES Improve Molecular Generative Models</title><link>https://hunterheidenreich.com/notes/chemistry/molecular-representations/notations/randomized-smiles-generative-models/</link><pubDate>Thu, 26 Mar 2026 00:00:00 +0000</pubDate><guid>https://hunterheidenreich.com/notes/chemistry/molecular-representations/notations/randomized-smiles-generative-models/</guid><description>Randomized SMILES improve RNN molecular generative models by increasing chemical space coverage, uniformity, and completeness versus canonical SMILES.</description><content:encoded><![CDATA[<h2 id="data-augmentation-through-smiles-randomization">Data Augmentation Through SMILES Randomization</h2>
<p>This is an <strong>Empirical</strong> paper that performs an extensive benchmark of RNN-based molecular generative models trained with different SMILES string variants. The primary contribution is demonstrating that randomized SMILES (non-unique molecular string representations obtained by randomizing atom orderings) substantially improve the quality of the generated chemical space compared to canonical SMILES, without requiring any changes to the model architecture.</p>
<p>The paper evaluates three properties of generated chemical spaces: uniformity (equal probability of sampling each molecule), completeness (coverage of the target space), and closedness (generating only molecules within the target space). These are measured using a new composite metric called UC-JSD.</p>
<h2 id="canonical-smiles-bias-in-generative-models">Canonical SMILES Bias in Generative Models</h2>
<p>Recurrent Neural Networks trained on SMILES strings have shown the capacity to create large chemical spaces of valid molecules. However, when trained with canonical SMILES (the unique string representation produced by a canonicalization algorithm), these models exhibit biases. Specifically, prior work by the same group showed that models trained on one million <a href="/notes/chemistry/datasets/gdb-13/">GDB-13</a> molecules could only recover 68% of GDB-13 when sampled two billion times, compared to the theoretical maximum of 87% from an ideal uniform sampler.</p>
<p>The canonical SMILES representation introduces two problems. First, the canonicalization algorithm constrains how the molecular graph is traversed (e.g., prioritizing sidechains over ring atoms), forcing the model to learn both valid SMILES syntax and the specific canonical ordering rules. Second, structurally similar molecules can have substantially different canonical SMILES, making some molecules harder to sample than others. Molecules with more ring systems and complex topologies are particularly underrepresented.</p>
<p>The authors also note that DeepSMILES, a recently proposed alternative syntax, had not been benchmarked against randomized SMILES, and that the data augmentation capabilities of randomized SMILES at different training set sizes were unexplored.</p>
<h2 id="randomized-smiles-as-non-canonical-representations">Randomized SMILES as Non-Canonical Representations</h2>
<p>The core insight is that by randomizing the atom ordering before SMILES generation, each molecule can be represented by multiple different but equally valid SMILES strings. This effectively provides data augmentation: a molecule with $n$ heavy atoms can theoretically yield up to $n$ different SMILES strings (though the actual number is typically lower due to molecular symmetry).</p>
<p>Two randomized SMILES variants are explored:</p>
<ul>
<li><strong>Restricted randomized SMILES</strong>: Atom ordering is randomized, but RDKit&rsquo;s built-in fixes are applied. These fixes prevent overly complicated traversals, such as prioritizing sidechains before completing ring atoms.</li>
<li><strong>Unrestricted randomized SMILES</strong>: Atom ordering is randomized without any RDKit restrictions, producing a superset of the restricted variant that includes more convoluted SMILES strings.</li>
</ul>
<p>For each training epoch, a new set of randomized SMILES is generated for the same molecules, so a model trained for 300 epochs on one million molecules sees approximately 300 million different SMILES strings (with some overlap due to sampling).</p>
<p>The model architecture is a standard RNN with an embedding layer, $l$ layers of LSTM or GRU cells of size $w$, optional dropout, and a linear output layer with softmax. The training objective minimizes the average negative log-likelihood (NLL):</p>
<p>$$
J(T) = -\ln P(X_{0} = x_{0}) - \sum_{t=1}^{T} \ln P(X_{t} = x_{t} \mid X_{t-1} = x_{t-1} \dots X_{1} = x_{1})
$$</p>
<p>The key metric is the Uniformity-Completeness JSD (UC-JSD), which extends the Jensen-Shannon Divergence to measure how uniform, complete, and closed the generated chemical space is:</p>
<p>$$
JSD = H\left(\sum_{d \in D} \alpha_{i} \cdot d_{i}\right) - \sum_{d \in D} \alpha_{i} H(d_{i})
$$</p>
<p>where $H(d)$ is the Shannon entropy of a probability distribution. The UC-JSD is computed over the NLL vectors of the validation, training, and sampled sets. The composite UCC score is defined as:</p>
<p>$$
UCC = \text{completeness} \times \text{uniformity} \times \text{closedness}
$$</p>
<p>where completeness measures coverage of GDB-13, uniformity measures how equal the sampling probabilities are, and closedness measures how few invalid (out-of-target-space) molecules are generated.</p>
<h2 id="benchmark-design-across-smiles-variants-training-sizes-and-architectures">Benchmark Design Across SMILES Variants, Training Sizes, and Architectures</h2>
<p>The benchmark covers a systematic grid of experimental conditions:</p>
<p><strong>SMILES variants</strong>: Canonical, restricted randomized, unrestricted randomized, and three DeepSMILES variants (branch syntax, ring syntax, both).</p>
<p><strong>Training set sizes from GDB-13</strong>: 1,000,000, 10,000, and 1,000 molecules with corresponding validation sets.</p>
<p><strong>Architecture choices</strong>: LSTM vs. GRU cells, with hyperparameter grids over number of layers ($l$), hidden size ($w$), dropout rate ($d$), and batch size ($b$).</p>
<table>
  <thead>
      <tr>
          <th>Model</th>
          <th>Layers ($l$)</th>
          <th>Hidden ($w$)</th>
          <th>Dropout ($d$)</th>
          <th>Batch ($b$)</th>
          <th>Cell</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>GDB-13 1M</td>
          <td>3</td>
          <td>512</td>
          <td>0, 25, 50</td>
          <td>64, 128, 256, 512</td>
          <td>GRU, LSTM</td>
      </tr>
      <tr>
          <td>GDB-13 10K</td>
          <td>2, 3, 4</td>
          <td>256, 384, 512</td>
          <td>0, 25, 50</td>
          <td>8, 16, 32</td>
          <td>LSTM</td>
      </tr>
      <tr>
          <td>GDB-13 1K</td>
          <td>2, 3, 4</td>
          <td>128, 192, 256</td>
          <td>0, 25, 50</td>
          <td>4, 8, 16</td>
          <td>LSTM</td>
      </tr>
      <tr>
          <td>ChEMBL</td>
          <td>3</td>
          <td>512</td>
          <td>0, 25, 50</td>
          <td>64, 128, 256, 512</td>
          <td>LSTM</td>
      </tr>
  </tbody>
</table>
<p>Each model&rsquo;s best epoch was selected using a smoothed UC-JSD curve, and the best epoch was then sampled with replacement $k = 2 \times 10^{9}$ times for GDB-13 benchmarks.</p>
<p>For ChEMBL experiments, models were trained on 1,483,943 molecules with a validation set of 78,102 molecules. Evaluation used validity, unique molecule count, and Frechet ChemNet Distance (FCD).</p>
<h2 id="randomized-smiles-produce-more-complete-and-uniform-chemical-spaces">Randomized SMILES Produce More Complete and Uniform Chemical Spaces</h2>
<h3 id="gdb-13-results-1m-training-set">GDB-13 results (1M training set)</h3>
<p>The restricted randomized SMILES model recovered 83.0% of GDB-13, compared to 72.8% for canonical SMILES and 68.4-72.1% for DeepSMILES variants. All three quality metrics improved substantially:</p>
<table>
  <thead>
      <tr>
          <th>SMILES Variant</th>
          <th>% GDB-13</th>
          <th>Uniformity</th>
          <th>Completeness</th>
          <th>Closedness</th>
          <th>UCC</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>Canonical</td>
          <td>72.8</td>
          <td>0.879</td>
          <td>0.836</td>
          <td>0.861</td>
          <td>0.633</td>
      </tr>
      <tr>
          <td>Rand. restricted</td>
          <td>83.0</td>
          <td>0.977</td>
          <td>0.953</td>
          <td>0.925</td>
          <td>0.860</td>
      </tr>
      <tr>
          <td>Rand. unrestricted</td>
          <td>80.9</td>
          <td>0.970</td>
          <td>0.929</td>
          <td>0.876</td>
          <td>0.790</td>
      </tr>
      <tr>
          <td>DeepSMILES (both)</td>
          <td>68.4</td>
          <td>0.851</td>
          <td>0.785</td>
          <td>0.796</td>
          <td>0.532</td>
      </tr>
  </tbody>
</table>
<p>The NLL distribution of GDB-13 molecules under the randomized SMILES model was centered near $NLL_{GDB13} = -\ln(1/|GDB13|) = 20.6$ with a narrow spread, indicating near-uniform sampling probability. The canonical model showed a much wider NLL distribution, meaning some molecules were orders of magnitude harder to sample.</p>
<p>Randomized SMILES without data augmentation (same SMILES each epoch) still outperformed canonical SMILES (UCC 0.712 vs. 0.633 for restricted), confirming that the non-canonical representation itself is beneficial beyond the augmentation effect.</p>
<h3 id="smaller-training-sets-amplify-the-advantage">Smaller training sets amplify the advantage</h3>
<p>With only 10,000 training molecules (0.001% of GDB-13), the randomized model generated 62.3% of GDB-13 vs. 38.8% for canonical. With 1,000 training molecules, the gap widened further: 34.1% vs. 14.5%. Validity also improved dramatically (81.2% vs. 50.4% for the 1K setting), suggesting randomized SMILES helps the model learn valid SMILES syntax more effectively from limited data.</p>
<h3 id="chembl-results">ChEMBL results</h3>
<p>On the drug-like ChEMBL dataset, the randomized SMILES model generated at least double the number of unique molecules compared to canonical (64.09% vs. 34.67% unique in a 2B sample), with comparable validity (98.33% vs. 98.26%). The canonical model showed a lower FCD (0.0712 vs. 0.1265), but the authors argue this reflects overfitting: the canonical model&rsquo;s NLL distributions for training and validation sets overlapped tightly, while the randomized model showed more uniform coverage. Physicochemical property distributions (molecular weight, logP, SA score, QED, NP score, internal diversity) were nearly identical across both models.</p>
<h3 id="architecture-findings">Architecture findings</h3>
<p>LSTM cells consistently outperformed GRU cells across all SMILES variants. Despite GRU&rsquo;s faster per-epoch training time, LSTM models converged in fewer epochs, making them faster overall. Dropout improved canonical SMILES models but was less beneficial (or detrimental) for randomized SMILES, suggesting that randomized SMILES themselves serve as a regularization mechanism. Larger batch sizes generally improved performance across all variants.</p>
<h3 id="uc-jsd-as-a-model-selection-metric">UC-JSD as a model selection metric</h3>
<p>The UC-JSD showed strong correlation with UCC ($R^{2} = 0.931$ for canonical, $R^{2} = 0.856$ for restricted randomized, $R^{2} = 0.885$ for unrestricted randomized), validating its use as a model selection criterion without requiring expensive sampling of every model.</p>
<p>The authors interpret randomized SMILES models as occupying a hybrid space between grammar-based and action-based generative models. The vocabulary serves as a fixed action space where atom tokens are &ldquo;add atom&rdquo; actions, bond tokens are &ldquo;add bond&rdquo; actions, and ring/branching tokens enable graph traversal. Canonical SMILES constrain this action space to a single deterministic path, while randomized SMILES allow the model to explore multiple valid traversals. This perspective also explains why DeepSMILES performed worse: its altered syntax creates a more complex action space without compensating benefits.</p>
<p>The authors encourage the use of randomized SMILES across different model architectures and tasks, including classification and property prediction, and suggest that finding optimal restricted variants of randomized SMILES is a promising research direction.</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>Training/Eval</td>
          <td>GDB-13 subsets</td>
          <td>1M / 10K / 1K molecules</td>
          <td>Randomly sampled from 975M GDB-13</td>
      </tr>
      <tr>
          <td>Training/Eval</td>
          <td>ChEMBL</td>
          <td>1,483,943 training / 78,102 validation</td>
          <td>Filtered subset of ChEMBL database</td>
      </tr>
  </tbody>
</table>
<p>GDB-13 is available from the <a href="http://gdb.unibe.ch/downloads">Reymond group website</a>. ChEMBL is publicly available.</p>
<h3 id="algorithms">Algorithms</h3>
<ul>
<li>Character-level tokenization with special handling for multi-character tokens (Cl, Br, bracketed atoms, %-prefixed ring numbers)</li>
<li>Teacher forcing during training with NLL loss</li>
<li>Gradient norm clipping to 1.0</li>
<li>Weight initialization from $\mathcal{U}(-\sqrt{1/w}, \sqrt{1/w})$</li>
<li>Adaptive learning rate decay based on UC-JSD</li>
<li>Best epoch selection via smoothed UC-JSD (window size 4)</li>
</ul>
<h3 id="models">Models</h3>
<p>Standard RNN architecture: embedding layer, stacked LSTM/GRU layers with optional dropout, linear output with softmax. Best models used 3 layers of 512-dimensional LSTM cells. Vocabulary sizes: 26 (GDB-13), 31 (ChEMBL).</p>
<h3 id="evaluation">Evaluation</h3>
<table>
  <thead>
      <tr>
          <th>Metric</th>
          <th>Best Randomized</th>
          <th>Best Canonical</th>
          <th>Notes</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>% GDB-13 (1M)</td>
          <td>83.0%</td>
          <td>72.8%</td>
          <td>2B sample with replacement</td>
      </tr>
      <tr>
          <td>UCC (1M)</td>
          <td>0.860</td>
          <td>0.633</td>
          <td>Composite score</td>
      </tr>
      <tr>
          <td>% GDB-13 (10K)</td>
          <td>62.3%</td>
          <td>38.8%</td>
          <td>2B sample with replacement</td>
      </tr>
      <tr>
          <td>% GDB-13 (1K)</td>
          <td>34.1%</td>
          <td>14.5%</td>
          <td>2B sample with replacement</td>
      </tr>
      <tr>
          <td>% Unique ChEMBL</td>
          <td>64.09%</td>
          <td>34.67%</td>
          <td>2B sample with replacement</td>
      </tr>
  </tbody>
</table>
<h3 id="hardware">Hardware</h3>
<p>Nvidia Tesla V100 (Volta) 16 GB VRAM with CUDA 9.1, driver 390.30. Training times ranged from 1 minute (1K canonical) to 131 hours (ChEMBL canonical). Randomized SMILES models required longer per-epoch training due to augmentation overhead but converged to better solutions.</p>
<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/undeadpixel/reinvent-randomized">reinvent-randomized</a></td>
          <td>Code</td>
          <td>MIT</td>
          <td>Training and benchmarking code</td>
      </tr>
      <tr>
          <td><a href="http://gdb.unibe.ch/downloads">GDB-13</a></td>
          <td>Dataset</td>
          <td>Academic use</td>
          <td>975 million fragment-like molecules</td>
      </tr>
      <tr>
          <td><a href="https://github.com/molecularsets/moses">MOSES benchmark</a></td>
          <td>Code</td>
          <td>MIT</td>
          <td>Used for FCD and property calculations</td>
      </tr>
  </tbody>
</table>
<hr>
<h2 id="paper-information">Paper Information</h2>
<p><strong>Citation</strong>: Arús-Pous, J., Johansson, S. V., Prykhodko, O., Bjerrum, E. J., Tyrchan, C., Reymond, J.-L., Chen, H., &amp; Engkvist, O. (2019). Randomized SMILES strings improve the quality of molecular generative models. <em>Journal of Cheminformatics</em>, 11(1), 71. <a href="https://doi.org/10.1186/s13321-019-0393-0">https://doi.org/10.1186/s13321-019-0393-0</a></p>
<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">@article</span>{aruspous2019randomized,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">title</span>=<span style="color:#e6db74">{Randomized SMILES strings improve the quality of molecular generative models}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">author</span>=<span style="color:#e6db74">{Ar{\&#39;u}s-Pous, Josep and Johansson, Simon Viet and Prykhodko, Oleksii and Bjerrum, Esben Jannik and Tyrchan, Christian and Reymond, Jean-Louis and Chen, Hongming and Engkvist, Ola}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">journal</span>=<span style="color:#e6db74">{Journal of Cheminformatics}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">volume</span>=<span style="color:#e6db74">{11}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">number</span>=<span style="color:#e6db74">{1}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">pages</span>=<span style="color:#e6db74">{71}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">year</span>=<span style="color:#e6db74">{2019}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">doi</span>=<span style="color:#e6db74">{10.1186/s13321-019-0393-0}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">publisher</span>=<span style="color:#e6db74">{Springer}</span>
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div>]]></content:encoded></item><item><title>Neural Machine Translation of Chemical Nomenclature</title><link>https://hunterheidenreich.com/notes/chemistry/molecular-representations/name-translation/nmt-chemical-nomenclature-en-zh/</link><pubDate>Thu, 26 Mar 2026 00:00:00 +0000</pubDate><guid>https://hunterheidenreich.com/notes/chemistry/molecular-representations/name-translation/nmt-chemical-nomenclature-en-zh/</guid><description>Xu et al. apply CNN and LSTM seq2seq models to translate chemical nomenclature between English and Chinese, outperforming rule-based tools.</description><content:encoded><![CDATA[<h2 id="a-method-for-neural-translation-of-chemical-names">A Method for Neural Translation of Chemical Names</h2>
<p>This is a <strong>Method</strong> paper that introduces deep learning approaches for translating chemical nomenclature between English and Chinese. The primary contribution is demonstrating that character-level sequence-to-sequence neural networks (both CNN-based and LSTM-based) can serve as viable alternatives to hand-crafted rule-based translation systems for chemical names. The work compares two neural architectures against an existing rule-based tool on bilingual chemical name datasets.</p>
<h2 id="bridging-the-english-chinese-chemical-nomenclature-gap">Bridging the English-Chinese Chemical Nomenclature Gap</h2>
<p>English and Chinese are the two most widely used languages for chemical nomenclature worldwide. Translation between them is important for chemical data processing, especially for converting Chinese chemical names extracted via named entity recognition into English names that existing name-to-structure tools can parse. Rule-based translation between these languages faces considerable challenges:</p>
<ol>
<li>Chinese chemical names lack word boundaries (no spaces), making segmentation difficult.</li>
<li>Word order is often reversed between English and Chinese chemical names (e.g., &ldquo;ethyl acetate&rdquo; maps to characters meaning &ldquo;acetate-ethyl&rdquo; in Chinese).</li>
<li>The same English morpheme can map to different Chinese characters depending on chemical context (e.g., &ldquo;ethyl&rdquo; translates differently in &ldquo;ethyl acetate&rdquo; vs. &ldquo;ethyl alcohol&rdquo;).</li>
<li>Trivial names, especially for natural products, follow irregular translation patterns or are transliterations.</li>
</ol>
<p>Building comprehensive rule sets requires a formally trained chemist fluent in both languages, making rule-based approaches expensive and fragile.</p>
<h2 id="character-level-sequence-to-sequence-translation">Character-Level Sequence-to-Sequence Translation</h2>
<p>The core idea is to treat chemical name translation as a character-level machine translation task, applying encoder-decoder architectures with attention mechanisms. Two architectures are proposed:</p>
<p><strong>CNN-based architecture</strong>: Three 1D convolutional layers encode the input character sequence. A decoder with three 1D convolutional layers processes the target sequence offset by one timestep, combined with attention mechanism layers that connect encoder and decoder outputs. Two additional 1D convolutional layers produce the final decoded output sequence.</p>
<p><strong>LSTM-based architecture</strong>: An LSTM encoder converts the input sequence into two state vectors. An LSTM decoder is trained with teacher forcing, using the encoder&rsquo;s state vectors as its initial state, and generating the target sequence offset by one timestep.</p>
<p>Both models operate at the character level. Input chemical name strings are transformed into embedding vectors, with the vocabulary size equal to the number of unique characters in the respective language (100 unique characters for English names, 2,056 unique characters for Chinese names).</p>
<h2 id="experimental-setup-and-comparison-with-rule-based-tool">Experimental Setup and Comparison with Rule-Based Tool</h2>
<h3 id="datasets">Datasets</h3>
<p>The authors built two directional datasets from a manually curated corpus of scientific literature maintained at their institution:</p>
<ul>
<li><strong>En2Ch (English to Chinese)</strong>: 30,394 name pairs after deduplication</li>
<li><strong>Ch2En (Chinese to English)</strong>: 37,207 name pairs after deduplication</li>
</ul>
<p>The datasets cover systematic compound names through trivial names. For names with multiple valid translations, the most commonly used translation was selected. Each dataset was split 80/20 for training and validation.</p>
<h3 id="model-configuration">Model Configuration</h3>
<p>Both neural network models used the following hyperparameters:</p>
<ul>
<li>Batch size: 64</li>
<li>Epochs: 100</li>
<li>Latent dimensionality: 256 (encoding and decoding space)</li>
<li>Implementation: Python 3.7 with Keras 2.3 and TensorFlow backend</li>
</ul>
<h3 id="evaluation-metrics">Evaluation Metrics</h3>
<p>The models were evaluated on five metrics across both translation directions:</p>
<ul>
<li><strong>Success Rate</strong>: Percentage of inputs that produced any output</li>
<li><strong>String Matching Accuracy</strong>: Exact match with the single target name</li>
<li><strong>Data Matching Accuracy</strong>: Exact match allowing any valid translation from the corpus</li>
<li><strong>Manual Spot Check</strong>: Blind evaluation of 100 random samples per approach</li>
<li><strong>Running Time</strong>: Wall-clock time on the same hardware</li>
</ul>
<h3 id="baseline">Baseline</h3>
<p>The rule-based comparison system operates in three steps: disassemble the input name into word fragments, translate each fragment, and reassemble into the target language. This tool had been deployed as an online service with over one million uses at the time of publication.</p>
<h2 id="key-findings-and-limitations">Key Findings and Limitations</h2>
<h3 id="main-results">Main Results</h3>
<table>
  <thead>
      <tr>
          <th>Metric</th>
          <th>CNN</th>
          <th>LSTM</th>
          <th>Rule-based</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>Success Rate En2Ch</td>
          <td>100%</td>
          <td>100%</td>
          <td>75.97%</td>
      </tr>
      <tr>
          <td>Success Rate Ch2En</td>
          <td>100%</td>
          <td>100%</td>
          <td>59.90%</td>
      </tr>
      <tr>
          <td>String Match En2Ch</td>
          <td>82.92%</td>
          <td>89.64%</td>
          <td>39.81%</td>
      </tr>
      <tr>
          <td>String Match Ch2En</td>
          <td>78.11%</td>
          <td>55.44%</td>
          <td>43.77%</td>
      </tr>
      <tr>
          <td>Data Match En2Ch</td>
          <td>84.44%</td>
          <td>90.82%</td>
          <td>45.15%</td>
      </tr>
      <tr>
          <td>Data Match Ch2En</td>
          <td>80.22%</td>
          <td>57.40%</td>
          <td>44.91%</td>
      </tr>
      <tr>
          <td>Manual Check En2Ch</td>
          <td>90.00%</td>
          <td>89.00%</td>
          <td>80.00%</td>
      </tr>
      <tr>
          <td>Manual Check Ch2En</td>
          <td>82.00%</td>
          <td>61.00%</td>
          <td>78.00%</td>
      </tr>
      <tr>
          <td>Time En2Ch (s)</td>
          <td>1423</td>
          <td>190</td>
          <td>288</td>
      </tr>
      <tr>
          <td>Time Ch2En (s)</td>
          <td>1876</td>
          <td>303</td>
          <td>322</td>
      </tr>
  </tbody>
</table>
<p>Both neural approaches achieved 100% success rate (always producing output), while the rule-based tool failed on 24% and 40% of inputs for En2Ch and Ch2En respectively. The rule-based tool&rsquo;s failures were concentrated on Chinese names lacking word boundaries and on trivial names of natural products.</p>
<p>For English-to-Chinese translation, LSTM performed best at 89.64% string matching accuracy (90.82% data matching), followed by CNN at 82.92%. For Chinese-to-English, CNN substantially outperformed LSTM (78.11% vs. 55.44% string matching), suggesting that LSTM had difficulty with long-term dependencies in Chinese character sequences. The authors observed that many LSTM errors appeared at the ends of chemical names.</p>
<h3 id="analysis-by-name-type">Analysis by Name Type</h3>
<p>The CNN-based approach outperformed LSTM on CAS names (80% vs. 52% in manual checks) and was more robust for longer names. The rule-based tool showed consistent performance regardless of name length, suggesting it was more suited to regular systematic names but struggled with the diversity of real-world chemical nomenclature.</p>
<h3 id="limitations">Limitations</h3>
<ul>
<li>Performance depends heavily on training data quality and quantity.</li>
<li>Neither neural approach was validated on an external test set outside the institution&rsquo;s corpus.</li>
<li>The CNN model was considerably slower (5-6x) than the other two approaches.</li>
<li>No comparison against modern transformer-based NMT architectures (the study predates widespread adoption of transformers for this task).</li>
<li>The dataset is relatively small by modern NMT standards (30-37K pairs).</li>
<li>The authors noted that some neural translations were actually better than the target labels, suggesting the evaluation metrics understate true performance.</li>
</ul>
<h3 id="future-directions">Future Directions</h3>
<p>The authors suggest that combining CNN and LSTM architectures could yield further improvements, and that the approach has practical applications in scientific publishing (Chinese journals requiring English abstracts) and chemical database interoperability.</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>Training/Validation (En2Ch)</td>
          <td>Curated bilingual corpus</td>
          <td>30,394 pairs</td>
          <td>80/20 split, from SIOC chemical data system</td>
      </tr>
      <tr>
          <td>Training/Validation (Ch2En)</td>
          <td>Curated bilingual corpus</td>
          <td>37,207 pairs</td>
          <td>80/20 split, from SIOC chemical data system</td>
      </tr>
      <tr>
          <td>Testing (En2Ch)</td>
          <td>Held-out validation split</td>
          <td>6,079 records</td>
          <td>Same source</td>
      </tr>
      <tr>
          <td>Testing (Ch2En)</td>
          <td>Held-out validation split</td>
          <td>7,441 records</td>
          <td>Same source</td>
      </tr>
  </tbody>
</table>
<p>Training data, Python code for both models, and result data are provided as supplementary files with the paper.</p>
<h3 id="algorithms">Algorithms</h3>
<ul>
<li>Character-level CNN encoder-decoder with attention (3+3+2 conv layers)</li>
<li>Character-level LSTM encoder-decoder with teacher forcing</li>
<li>Batch size: 64, epochs: 100, latent dim: 256</li>
</ul>
<h3 id="models">Models</h3>
<p>Both models implemented in Python 3.7 with Keras 2.3 / TensorFlow. No pre-trained weights are released separately, but the training code is provided as supplementary material.</p>
<h3 id="evaluation">Evaluation</h3>
<table>
  <thead>
      <tr>
          <th>Metric</th>
          <th>Best Value (En2Ch)</th>
          <th>Best Value (Ch2En)</th>
          <th>Notes</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>Success Rate</td>
          <td>100% (both DL)</td>
          <td>100% (both DL)</td>
          <td>Rule-based: 75.97% / 59.90%</td>
      </tr>
      <tr>
          <td>String Matching</td>
          <td>89.64% (LSTM)</td>
          <td>78.11% (CNN)</td>
          <td>Best neural model per direction</td>
      </tr>
      <tr>
          <td>Data Matching</td>
          <td>90.82% (LSTM)</td>
          <td>80.22% (CNN)</td>
          <td>Allows multiple valid translations</td>
      </tr>
      <tr>
          <td>Manual Spot Check</td>
          <td>90.00% (CNN)</td>
          <td>82.00% (CNN)</td>
          <td>Blind evaluation of 100 samples</td>
      </tr>
  </tbody>
</table>
<h3 id="hardware">Hardware</h3>
<p>Not specified in the paper. Running times reported but hardware details not provided.</p>
<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://doi.org/10.1186/s13321-020-00457-0">Supplementary files</a></td>
          <td>Code + Data</td>
          <td>CC-BY 4.0</td>
          <td>Training data, CNN/LSTM code, results (Additional files 1-6)</td>
      </tr>
      <tr>
          <td><a href="https://www.organchem.csdb.cn/translate">SIOC Translation Tool</a></td>
          <td>Other</td>
          <td>Not specified</td>
          <td>Rule-based baseline tool, online service</td>
      </tr>
  </tbody>
</table>
<hr>
<h2 id="paper-information">Paper Information</h2>
<p><strong>Citation</strong>: Xu, T., Chen, W., Zhou, J., Dai, J., Li, Y., &amp; Zhao, Y. (2020). Neural machine translation of chemical nomenclature between English and Chinese. <em>Journal of Cheminformatics</em>, 12, 50. <a href="https://doi.org/10.1186/s13321-020-00457-0">https://doi.org/10.1186/s13321-020-00457-0</a></p>
<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">@article</span>{xu2020neural,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">title</span>=<span style="color:#e6db74">{Neural machine translation of chemical nomenclature between English and Chinese}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">author</span>=<span style="color:#e6db74">{Xu, Tingjun and Chen, Weiming and Zhou, Junhong and Dai, Jingfang and Li, Yingyong and Zhao, Yingli}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">journal</span>=<span style="color:#e6db74">{Journal of Cheminformatics}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">volume</span>=<span style="color:#e6db74">{12}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">pages</span>=<span style="color:#e6db74">{50}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">year</span>=<span style="color:#e6db74">{2020}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">doi</span>=<span style="color:#e6db74">{10.1186/s13321-020-00457-0}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">publisher</span>=<span style="color:#e6db74">{Springer}</span>
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div>]]></content:encoded></item><item><title>nach0: A Multimodal Chemical and NLP Foundation Model</title><link>https://hunterheidenreich.com/notes/chemistry/molecular-representations/multimodal/nach0-multimodal-chemical-language-model/</link><pubDate>Thu, 26 Mar 2026 00:00:00 +0000</pubDate><guid>https://hunterheidenreich.com/notes/chemistry/molecular-representations/multimodal/nach0-multimodal-chemical-language-model/</guid><description>nach0 is a T5-based encoder-decoder model pre-trained on SMILES, scientific text, and patents, then instruction-tuned for chemical and NLP tasks.</description><content:encoded><![CDATA[<h2 id="a-multi-domain-encoder-decoder-for-chemistry-and-nlp">A Multi-Domain Encoder-Decoder for Chemistry and NLP</h2>
<p>nach0 is a <strong>Method</strong> paper that introduces a unified encoder-decoder foundation model capable of handling both natural language processing (NLP) tasks and chemistry tasks within a single architecture. The primary contribution is demonstrating that a T5-based model pre-trained on scientific text, patents, and <a href="/notes/chemistry/molecular-representations/notations/smiles/">SMILES</a> molecular strings can be instruction-tuned to perform molecular property prediction, reaction prediction, molecular generation, named entity recognition, question answering, and cross-domain translation (text-to-molecule and molecule-to-text) simultaneously. The model is available in base (250M parameters) and large (780M parameters) configurations.</p>
<h2 id="bridging-chemical-and-linguistic-representations">Bridging Chemical and Linguistic Representations</h2>
<p>Most existing biomedical language models (BioBERT, SciFive, BioMegatron) are trained exclusively on natural language text from sources like PubMed, omitting chemical structure information encoded in SMILES strings. Conversely, chemistry-specific models trained on SMILES data often lack the ability to process natural language instructions or perform NLP tasks. Models like <a href="/notes/chemistry/llm-applications/galactica-large-language-model-for-science/">Galactica</a> and MolT5 attempted to bridge this gap by training on both natural language and chemical data, but they were not fine-tuned on a diverse set of chemical tasks using instruction tuning in a multi-task fashion.</p>
<p>nach0 addresses this by creating a shared representation space for both modalities and fine-tuning across a comprehensive set of tasks spanning three domains: NLP-only tasks, chemistry-only tasks, and cross-domain tasks that require translating between natural language and molecular representations.</p>
<h2 id="unified-text-to-text-framework-with-smiles-tokenization">Unified Text-to-Text Framework with SMILES Tokenization</h2>
<p>The core innovation in nach0 is formulating all chemical and linguistic tasks as text-to-text problems within a single encoder-decoder transformer, combined with a specialized SMILES tokenization strategy.</p>
<h3 id="smiles-token-integration">SMILES Token Integration</h3>
<p>Rather than treating SMILES as plain text, nach0 extends the T5 vocabulary with dedicated SMILES tokens. Each SMILES token is annotated with special symbols in the format <code>&lt;sm_{token}&gt;</code>, creating a distinct vocabulary space for molecular representations while preserving the natural language vocabulary from FLAN-T5. The embedding matrix is initialized by reusing learned embeddings from the pre-trained model for original tokens, with new chemical tokens initialized from the first embeddings.</p>
<h3 id="architecture">Architecture</h3>
<p>Both model sizes use the standard <a href="/notes/natural-language-processing/language-models/t5-text-to-text-transfer-transformer/">T5</a> encoder-decoder architecture:</p>
<table>
  <thead>
      <tr>
          <th>Configuration</th>
          <th>Parameters</th>
          <th>Layers</th>
          <th>Hidden Size</th>
          <th>FFN Size</th>
          <th>Attention Heads</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>Base</td>
          <td>250M</td>
          <td>12</td>
          <td>768</td>
          <td>3072</td>
          <td>12</td>
      </tr>
      <tr>
          <td>Large</td>
          <td>780M</td>
          <td>24</td>
          <td>1024</td>
          <td>4096</td>
          <td>16</td>
      </tr>
  </tbody>
</table>
<h3 id="pre-training-data">Pre-training Data</h3>
<p>The model is pre-trained with a language modeling objective on three data sources:</p>
<table>
  <thead>
      <tr>
          <th>Source</th>
          <th>Documents</th>
          <th>Tokens</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>PubMed abstracts (chemistry-filtered)</td>
          <td>13M</td>
          <td>355M</td>
      </tr>
      <tr>
          <td>USPTO patent descriptions</td>
          <td>119K</td>
          <td>2.9B</td>
      </tr>
      <tr>
          <td><a href="/notes/chemistry/datasets/zinc-22/">ZINC</a> molecular database</td>
          <td>~100M</td>
          <td>4.7B</td>
      </tr>
  </tbody>
</table>
<h3 id="instruction-tuning">Instruction Tuning</h3>
<p>Following the approach of Raffel et al. and Chung et al., nach0 uses natural language prompts to formulate each task. For example, a retrosynthesis task might be phrased as &ldquo;What reactants could be used to synthesize [SMILES]?&rdquo; and a property prediction task as &ldquo;Can [SMILES] penetrate the <a href="https://en.wikipedia.org/wiki/Blood%E2%80%93brain_barrier">BBB</a>?&rdquo; This enables multi-task training across all domains with a single loss function and shared hyperparameters.</p>
<p>Training uses a batch size of 1024, learning rate of $1 \times 10^{-4}$, and weight decay of 0.01. Pre-training runs for one epoch, and fine-tuning for 10 epochs. Data mixing follows the examples-proportional mixing strategy from T5.</p>
<h2 id="multi-task-evaluation-across-nlp-and-chemistry-benchmarks">Multi-Task Evaluation Across NLP and Chemistry Benchmarks</h2>
<p>nach0 is evaluated on a comprehensive set of benchmarks spanning three task categories.</p>
<h3 id="task-categories">Task Categories</h3>
<p><strong>NLP tasks</strong>: Named entity recognition (BC5CDR-Chemical, BC5CDR-Disease, NCBI-Disease, BC2GM, JNLPBA), PICO extraction (EBM PICO), textual entailment (MedNLI, SciTail), relation extraction (ChemProt, DDI, GAD), sentence similarity (BIOSSES), document classification (HoC), and question answering (PubMedQA, BioASQ, MedMCQA, MMLU).</p>
<p><strong>Chemistry tasks</strong>: Molecular property prediction (ESOL, FreeSolv, Lipophilicity, BBBP, HIV, BACE from <a href="/notes/chemistry/molecular-design/property-prediction/moleculenet-benchmark-molecular-ml/">MoleculeNet</a>; QM9 from Mol-Instructions), molecular generation (<a href="/notes/chemistry/molecular-design/generation/evaluation/molecular-sets-moses/">MOSES</a>), forward reaction prediction, reagent prediction, and <a href="https://en.wikipedia.org/wiki/Retrosynthetic_analysis">retrosynthesis</a> (from Mol-Instructions/USPTO).</p>
<p><strong>Cross-domain tasks</strong>: Description-guided molecule design and molecular description generation (from Mol-Instructions).</p>
<h3 id="baselines">Baselines</h3>
<p>nach0 is compared against FLAN-T5 (250M), SciFive (220M), and MolT5 (220M), all trained in multi-task fashion.</p>
<h3 id="key-results">Key Results</h3>
<p>On chemistry and cross-domain tasks, nach0 base consistently outperforms all base-sized baselines. Selected highlights from Table 3:</p>
<table>
  <thead>
      <tr>
          <th>Task</th>
          <th>Metric</th>
          <th>MolT5</th>
          <th>SciFive</th>
          <th>FLAN</th>
          <th>nach0 Base</th>
          <th>nach0 Large</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>Forward reaction</td>
          <td>Acc@1</td>
          <td>27.0%</td>
          <td>60.0%</td>
          <td>59.0%</td>
          <td>88.0%</td>
          <td>89.9%</td>
      </tr>
      <tr>
          <td>Retrosynthesis</td>
          <td>Acc@1</td>
          <td>15.0%</td>
          <td>31.0%</td>
          <td>31.0%</td>
          <td>53.0%</td>
          <td>56.3%</td>
      </tr>
      <tr>
          <td>Reagent prediction</td>
          <td>Acc@1</td>
          <td>1.1%</td>
          <td>3.8%</td>
          <td>4.0%</td>
          <td>6.3%</td>
          <td>13.1%</td>
      </tr>
      <tr>
          <td>BACE</td>
          <td>BA</td>
          <td>0.58</td>
          <td>0.65</td>
          <td>0.65</td>
          <td>0.74</td>
          <td>0.71</td>
      </tr>
      <tr>
          <td>BBBP</td>
          <td>BA</td>
          <td>0.55</td>
          <td>0.66</td>
          <td>0.60</td>
          <td>0.67</td>
          <td>0.68</td>
      </tr>
      <tr>
          <td>HFE (FreeSolv)</td>
          <td>R2</td>
          <td>-0.36</td>
          <td>0.51</td>
          <td>0.55</td>
          <td>0.77</td>
          <td>0.78</td>
      </tr>
      <tr>
          <td>MOSES (FCD)</td>
          <td>FCD/Test</td>
          <td>0.521</td>
          <td>0.578</td>
          <td>0.529</td>
          <td>0.311</td>
          <td>0.304</td>
      </tr>
      <tr>
          <td>Description-guided mol. design</td>
          <td>BLEU-2</td>
          <td>30.3%</td>
          <td>44.2%</td>
          <td>43.6%</td>
          <td>49.0%</td>
          <td>48.8%</td>
      </tr>
      <tr>
          <td>Mol. description gen.</td>
          <td>BLEU-2</td>
          <td>35.6%</td>
          <td>39.6%</td>
          <td>38.6%</td>
          <td>43.9%</td>
          <td>41.7%</td>
      </tr>
  </tbody>
</table>
<p>On NLP tasks, nach0 base performs comparably to FLAN base, with the two models trading wins across different tasks. nach0 large improves substantially over nach0 base on most tasks.</p>
<h3 id="ablation-study">Ablation Study</h3>
<p>The ablation study (Table 4) examines the impact of multi-task training across chemical task groups. Key findings:</p>
<ul>
<li>nach0 trained on all chemical tasks jointly outperforms models trained on individual task groups (prediction-only, reaction-only, or generation-only) on the total set of metrics</li>
<li>The joint model shows lower novelty scores on MOSES compared to the generation-only model, but this reflects less overfitting to training data rather than worse performance</li>
<li>nach0 consistently outperforms MolT5 across all chemical task configurations, demonstrating the benefit of pre-training on both natural language and chemical data with specialized SMILES tokens</li>
</ul>
<h3 id="case-studies">Case Studies</h3>
<p>Two applied case studies demonstrate nach0 in drug discovery scenarios:</p>
<ol>
<li>
<p><strong>End-to-end drug discovery for <a href="https://en.wikipedia.org/wiki/Diabetes">diabetes mellitus</a></strong>: Using a sequence of prompts, nach0 identifies biological targets, analyzes mechanisms of action, generates molecular structures, proposes synthesis routes, and predicts molecular properties.</p>
</li>
<li>
<p><strong><a href="https://en.wikipedia.org/wiki/Janus_kinase_3">JAK3</a> inhibitor generation with Chemistry42</strong>: nach0 replaces 42 specialized generative models in Insilico Medicine&rsquo;s Chemistry42 platform. In 45 minutes, nach0 generates 8 molecules satisfying all 2D and 3D requirements (hinge binding, active site binding), compared to a 0.04% discovery rate from a combinatorial generator over 24 hours. Chemistry42&rsquo;s full pipeline (72 hours) still produces better structures since it uses reinforcement learning feedback and explicit structural constraints.</p>
</li>
</ol>
<h3 id="comparison-with-chatgpt">Comparison with ChatGPT</h3>
<p>On a subset evaluation, fine-tuned nach0 base outperforms GPT-3.5-turbo on all tested tasks: EBM PICO (F1: 67.6% vs. 64.4%), MedMCQA-Open (BLEU-2: 6.3% vs. 1.7%), and molecular description generation (BLEU-2: 42.8% vs. 2.2%).</p>
<h2 id="competitive-multi-task-performance-with-clear-limitations">Competitive Multi-Task Performance with Clear Limitations</h2>
<p>nach0 demonstrates that a single encoder-decoder model can achieve competitive results across both chemical and NLP tasks when pre-trained on mixed-modality data and fine-tuned with instruction tuning. The model&rsquo;s strongest advantages appear on chemistry tasks (reaction prediction, property prediction, molecular generation), where specialized SMILES tokenization and chemical pre-training provide clear benefits over general-purpose models of similar scale.</p>
<h3 id="limitations-acknowledged-by-the-authors">Limitations Acknowledged by the Authors</h3>
<ol>
<li>
<p><strong>Not at chemist expert level</strong>: Human evaluations indicate the model does not match domain expert performance. Key gaps include chemical reasoning, knowledge alignment with domain-specific knowledge graphs, and the ability to learn from expert feedback.</p>
</li>
<li>
<p><strong>SMILES-only molecular representation</strong>: The model lacks 3D geometric information. SMILES notation is not one-to-one with molecular structures, and the model does not incorporate molecular graphs or 3D coordinates. The authors suggest <a href="/notes/chemistry/molecular-representations/notations/selfies/">SELFIES</a> as a potential alternative representation.</p>
</li>
<li>
<p><strong>Prompt sensitivity</strong>: Performance depends on prompt quality and specificity. Over-reliance on domain-specific prompts may limit response diversity.</p>
</li>
<li>
<p><strong>Limited chemical diversity</strong>: Cross-domain datasets from Mol-Instructions primarily cover known drugs and chemical probes from <a href="https://en.wikipedia.org/wiki/PubChem">PubChem</a>, representing only a fraction of predicted chemical space.</p>
</li>
</ol>
<h3 id="future-directions">Future Directions</h3>
<p>The authors propose extending nach0 with protein sequence modalities (using <a href="/notes/chemistry/molecular-representations/notations/group-selfies-fragment-molecular-representation/">Group SELFIES</a>), expanding zero-shot evaluation capabilities, and integrating knowledge graph information through self-supervised approaches.</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>Pre-training (text)</td>
          <td>PubMed abstracts</td>
          <td>13M docs, 355M tokens</td>
          <td>Filtered for chemistry-related content</td>
      </tr>
      <tr>
          <td>Pre-training (text)</td>
          <td>USPTO patents</td>
          <td>119K docs, 2.9B tokens</td>
          <td>Patent descriptions</td>
      </tr>
      <tr>
          <td>Pre-training (chemical)</td>
          <td>ZINC</td>
          <td>~100M docs, 4.7B tokens</td>
          <td>Molecular SMILES strings</td>
      </tr>
      <tr>
          <td>Fine-tuning (NLP)</td>
          <td>17 NLP datasets</td>
          <td>Varies</td>
          <td>See Table 1 in paper</td>
      </tr>
      <tr>
          <td>Fine-tuning (chemistry)</td>
          <td>MoleculeNet, MOSES, Mol-Instructions</td>
          <td>Varies</td>
          <td>Predefined or random splits</td>
      </tr>
  </tbody>
</table>
<h3 id="algorithms">Algorithms</h3>
<ul>
<li>Architecture: T5 encoder-decoder (base: 250M, large: 780M parameters)</li>
<li>Pre-training objective: Language modeling (masked span prediction)</li>
<li>Fine-tuning: Multi-task instruction tuning with examples-proportional mixing</li>
<li>Hyperparameters: batch size 1024, learning rate $1 \times 10^{-4}$, weight decay 0.01</li>
<li>Pre-training: 1 epoch; fine-tuning: 10 epochs</li>
</ul>
<h3 id="models">Models</h3>
<table>
  <thead>
      <tr>
          <th>Artifact</th>
          <th>Type</th>
          <th>License</th>
          <th>Notes</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td><a href="https://huggingface.co/insilicomedicine/nach0_base">nach0 Base (HuggingFace)</a></td>
          <td>Model</td>
          <td>CC-BY-NC-4.0</td>
          <td>250M parameter encoder-decoder</td>
      </tr>
      <tr>
          <td><a href="https://huggingface.co/insilicomedicine/nach0_large">nach0 Large (HuggingFace)</a></td>
          <td>Model</td>
          <td>CC-BY-NC-4.0</td>
          <td>780M parameter encoder-decoder</td>
      </tr>
      <tr>
          <td><a href="https://github.com/insilicomedicine/nach0">nach0 GitHub Repository</a></td>
          <td>Code</td>
          <td>Not specified</td>
          <td>Training and inference code</td>
      </tr>
  </tbody>
</table>
<h3 id="evaluation">Evaluation</h3>
<p>Evaluation spans 17+ NLP benchmarks and 10+ chemistry benchmarks. Metrics include F1 (NER, RE, classification), accuracy (QA, entailment, reaction prediction), balanced accuracy (molecular property classification), R2/RMSE (regression), BLEU-2 (generation), and FCD/SNN/validity/novelty (molecular generation via MOSES).</p>
<h3 id="hardware">Hardware</h3>
<ul>
<li>Base models: NVIDIA A4000 and A5000 GPUs</li>
<li>Large models: NVIDIA DGX cloud platform</li>
<li>Training used tensor and pipeline parallelism via NeMo toolkit</li>
<li>Specific GPU counts and training times not reported</li>
</ul>
<hr>
<h2 id="paper-information">Paper Information</h2>
<p><strong>Citation</strong>: Livne, M., Miftahutdinov, Z., Tutubalina, E., Kuznetsov, M., Polykovskiy, D., Brundyn, A., Jhunjhunwala, A., Costa, A., Aliper, A., Aspuru-Guzik, A., &amp; Zhavoronkov, A. (2024). nach0: Multimodal Natural and Chemical Languages Foundation Model. <em>Chemical Science</em>, 15(22), 8380-8389. <a href="https://doi.org/10.1039/D4SC00966E">https://doi.org/10.1039/D4SC00966E</a></p>
<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">@article</span>{livne2024nach0,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">title</span>=<span style="color:#e6db74">{nach0: multimodal natural and chemical languages foundation model}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">author</span>=<span style="color:#e6db74">{Livne, Micha and Miftahutdinov, Zulfat and Tutubalina, Elena and Kuznetsov, Maksim and Polykovskiy, Daniil and Brundyn, Annika and Jhunjhunwala, Aastha and Costa, Anthony and Aliper, Alex and Aspuru-Guzik, Al{\&#39;a}n and Zhavoronkov, Alex}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">journal</span>=<span style="color:#e6db74">{Chemical Science}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">volume</span>=<span style="color:#e6db74">{15}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">number</span>=<span style="color:#e6db74">{22}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">pages</span>=<span style="color:#e6db74">{8380--8389}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">year</span>=<span style="color:#e6db74">{2024}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">publisher</span>=<span style="color:#e6db74">{Royal Society of Chemistry}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">doi</span>=<span style="color:#e6db74">{10.1039/D4SC00966E}</span>
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div>]]></content:encoded></item><item><title>MolBERT: Auxiliary Tasks for Molecular BERT Models</title><link>https://hunterheidenreich.com/notes/chemistry/molecular-representations/encoders/molbert-molecular-representations/</link><pubDate>Thu, 26 Mar 2026 00:00:00 +0000</pubDate><guid>https://hunterheidenreich.com/notes/chemistry/molecular-representations/encoders/molbert-molecular-representations/</guid><description>MolBERT applies BERT to SMILES with domain-relevant auxiliary tasks like physicochemical property prediction, improving virtual screening and QSAR.</description><content:encoded><![CDATA[<h2 id="bert-based-molecular-representations-with-auxiliary-pre-training-tasks">BERT-Based Molecular Representations with Auxiliary Pre-Training Tasks</h2>
<p>This is a <strong>Method</strong> paper that introduces MolBERT, a bidirectional Transformer (BERT) architecture applied to SMILES-based molecular representations for drug discovery. The primary contribution is a systematic study of how different domain-relevant self-supervised pre-training tasks affect the quality of learned molecular embeddings, paired with a model that achieves state-of-the-art performance on <a href="https://en.wikipedia.org/wiki/Virtual_screening">virtual screening</a> and <a href="https://en.wikipedia.org/wiki/Quantitative_structure%E2%80%93activity_relationship">quantitative structure-activity relationship (QSAR)</a> benchmarks.</p>
<h2 id="why-domain-relevant-pre-training-matters-for-molecular-language-models">Why Domain-Relevant Pre-Training Matters for Molecular Language Models</h2>
<p>Molecular representations are foundational for predictive, generative, and analytical tasks in drug discovery. Language models applied to text-based molecular representations like SMILES have demonstrated strong performance across property prediction, reaction prediction, and molecular generation. However, several open questions remained at the time of this work:</p>
<ol>
<li><strong>Task selection for pre-training</strong>: Prior work explored masked token prediction, input translation, and property concatenation, but there was no systematic comparison of how different self-supervised tasks affect downstream performance.</li>
<li><strong>SMILES ambiguity</strong>: The same molecule can be encoded as many different SMILES strings depending on how the molecular graph is traversed. Canonicalization algorithms address this but introduce their own artifacts that may distract the model.</li>
<li><strong>Domain knowledge integration</strong>: Standard NLP pre-training objectives (e.g., masked language modeling) do not explicitly encode chemical knowledge. It was unclear whether incorporating chemistry-specific supervision during pre-training could improve representation quality.</li>
</ol>
<p>MolBERT addresses these gaps by evaluating three pre-training tasks, including a novel physicochemical property prediction objective, and measuring their individual and combined effects on downstream drug discovery benchmarks.</p>
<h2 id="three-auxiliary-tasks-for-chemistry-aware-pre-training">Three Auxiliary Tasks for Chemistry-Aware Pre-Training</h2>
<p>MolBERT uses the BERT-Base architecture (12 attention heads, 12 layers, 768-dimensional hidden states, approximately 85M parameters) and explores three self-supervised pre-training tasks:</p>
<p><strong>Masked Language Modeling (MaskedLM)</strong>: The standard BERT objective where 15% of input tokens are masked and the model predicts their identity. The loss is cross-entropy between predicted and true tokens.</p>
<p><strong>SMILES Equivalence (SMILES-Eq)</strong>: A binary classification task where the model receives two SMILES strings and predicts whether they represent the same molecule. The second string is either a random permutation of the first (same molecule, different traversal) or a randomly sampled molecule. This is optimized with cross-entropy loss.</p>
<p><strong>Physicochemical Property Prediction (PhysChemPred)</strong>: Using <a href="https://en.wikipedia.org/wiki/RDKit">RDKit</a>, a set of 200 real-valued molecular descriptors are computed for each molecule. The model predicts these normalized descriptors from the SMILES input using mean squared error:</p>
<p>$$\mathcal{L}_{\text{PhysChemPred}} = \frac{1}{D} \sum_{d=1}^{D} (y_d - \hat{y}_d)^2$$</p>
<p>where $D = 200$ is the number of descriptors, $y_d$ is the true normalized descriptor value, and $\hat{y}_d$ is the model&rsquo;s prediction.</p>
<p>The final training loss is the arithmetic mean of all active task losses:</p>
<p>$$\mathcal{L}_{\text{total}} = \frac{1}{|\mathcal{T}|} \sum_{t \in \mathcal{T}} \mathcal{L}_t$$</p>
<p>where $\mathcal{T}$ is the set of active pre-training tasks.</p>
<p>Additionally, MolBERT supports SMILES permutation augmentation during training, where each input molecule is represented by a randomly sampled non-canonical SMILES string rather than the canonical form. The model uses a fixed vocabulary of 42 tokens, a sequence length of 128, and relative positional embeddings (from Transformer-XL) to support arbitrary-length SMILES at inference time.</p>
<h2 id="ablation-study-and-benchmark-evaluation">Ablation Study and Benchmark Evaluation</h2>
<h3 id="pre-training-setup">Pre-Training Setup</h3>
<p>All models were pre-trained on the <a href="/notes/chemistry/molecular-design/generation/evaluation/guacamol-benchmarking-de-novo-molecular-design/">GuacaMol benchmark dataset</a>, consisting of approximately 1.6M compounds curated from ChEMBL, using an 80%/5% train/validation split. Training used the Adam optimizer with a learning rate of $3 \times 10^{-5}$ for 20 epochs (ablation) or 100 epochs (final model).</p>
<h3 id="ablation-impact-of-task-combinations-on-virtual-screening">Ablation: Impact of Task Combinations on Virtual Screening</h3>
<p>The ablation study evaluated all seven possible task combinations on the RDKit virtual screening benchmark (69 datasets, 5 query molecules per target). Results measured by AUROC and BEDROC20 (an early enrichment metric with $\alpha = 20$):</p>
<table>
  <thead>
      <tr>
          <th style="text-align: center">MaskedLM</th>
          <th style="text-align: center">PhysChemPred</th>
          <th style="text-align: center">SMILES-Eq</th>
          <th style="text-align: center">AUROC (w/ perm)</th>
          <th style="text-align: center">BEDROC20 (w/ perm)</th>
          <th style="text-align: center">AUROC (w/o perm)</th>
          <th style="text-align: center">BEDROC20 (w/o perm)</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td style="text-align: center">Yes</td>
          <td style="text-align: center">Yes</td>
          <td style="text-align: center">Yes</td>
          <td style="text-align: center">0.685 +/- 0.069</td>
          <td style="text-align: center">0.246 +/- 0.041</td>
          <td style="text-align: center">0.707 +/- 0.059</td>
          <td style="text-align: center">0.280 +/- 0.042</td>
      </tr>
      <tr>
          <td style="text-align: center">Yes</td>
          <td style="text-align: center">Yes</td>
          <td style="text-align: center">No</td>
          <td style="text-align: center">0.738 +/- 0.060</td>
          <td style="text-align: center">0.323 +/- 0.071</td>
          <td style="text-align: center">0.740 +/- 0.066</td>
          <td style="text-align: center">0.322 +/- 0.065</td>
      </tr>
      <tr>
          <td style="text-align: center">Yes</td>
          <td style="text-align: center">No</td>
          <td style="text-align: center">Yes</td>
          <td style="text-align: center">0.483 +/- 0.092</td>
          <td style="text-align: center">0.092 +/- 0.069</td>
          <td style="text-align: center">0.493 +/- 0.068</td>
          <td style="text-align: center">0.108 +/- 0.070</td>
      </tr>
      <tr>
          <td style="text-align: center">No</td>
          <td style="text-align: center">Yes</td>
          <td style="text-align: center">Yes</td>
          <td style="text-align: center">0.476 +/- 0.077</td>
          <td style="text-align: center">0.064 +/- 0.034</td>
          <td style="text-align: center">0.514 +/- 0.165</td>
          <td style="text-align: center">0.084 +/- 0.014</td>
      </tr>
      <tr>
          <td style="text-align: center">Yes</td>
          <td style="text-align: center">No</td>
          <td style="text-align: center">No</td>
          <td style="text-align: center">0.696 +/- 0.058</td>
          <td style="text-align: center">0.283 +/- 0.077</td>
          <td style="text-align: center">0.676 +/- 0.060</td>
          <td style="text-align: center">0.250 +/- 0.073</td>
      </tr>
      <tr>
          <td style="text-align: center">No</td>
          <td style="text-align: center">Yes</td>
          <td style="text-align: center">No</td>
          <td style="text-align: center">0.719 +/- 0.057</td>
          <td style="text-align: center">0.293 +/- 0.071</td>
          <td style="text-align: center">0.716 +/- 0.061</td>
          <td style="text-align: center">0.290 +/- 0.076</td>
      </tr>
      <tr>
          <td style="text-align: center">No</td>
          <td style="text-align: center">No</td>
          <td style="text-align: center">Yes</td>
          <td style="text-align: center">0.129 +/- 0.067</td>
          <td style="text-align: center">0.005 +/- 0.037</td>
          <td style="text-align: center">0.508 +/- 0.068</td>
          <td style="text-align: center">0.048 +/- 0.035</td>
      </tr>
  </tbody>
</table>
<p>Key findings from the ablation:</p>
<ul>
<li>PhysChemPred had the highest individual impact (average BEDROC20 of 0.292 alone vs. 0.266 for MaskedLM alone).</li>
<li>Combining MaskedLM + PhysChemPred achieved the best performance (BEDROC20 of 0.323), though the additive gain from MaskedLM was modest (+0.031).</li>
<li>The SMILES-Eq task consistently decreased performance when added to other task combinations.</li>
</ul>
<p>A further sub-ablation on PhysChemPred descriptor groups showed that surface descriptors alone (49 of 200 descriptors) achieved nearly the same performance as the full set, suggesting molecular surface properties provide particularly informative supervision.</p>
<h3 id="virtual-screening-results">Virtual Screening Results</h3>
<p>Using the best task combination (MaskedLM + PhysChemPred) trained for 100 epochs:</p>
<table>
  <thead>
      <tr>
          <th>Method</th>
          <th>AUROC</th>
          <th>BEDROC20</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>MolBERT (100 epochs)</td>
          <td>0.743 +/- 0.062</td>
          <td>0.344 +/- 0.062</td>
      </tr>
      <tr>
          <td>CDDD</td>
          <td>0.725 +/- 0.057</td>
          <td>0.310 +/- 0.080</td>
      </tr>
      <tr>
          <td>RDKit descriptors</td>
          <td>0.633 +/- 0.027</td>
          <td>0.217 +/- 0.000</td>
      </tr>
      <tr>
          <td>ECFC4</td>
          <td>0.603 +/- 0.056</td>
          <td>0.170 +/- 0.079</td>
      </tr>
  </tbody>
</table>
<p>MolBERT outperformed all baselines including <a href="/notes/chemistry/molecular-representations/encoders/cddd-translation-molecular-descriptors/">CDDD</a> (the prior state of the art), RDKit calculated descriptors, and extended-connectivity fingerprints (ECFC4).</p>
<h3 id="qsar-results">QSAR Results</h3>
<p>On <a href="/notes/chemistry/molecular-design/property-prediction/moleculenet-benchmark-molecular-ml/">MoleculeNet</a> regression tasks (RMSE, lower is better):</p>
<table>
  <thead>
      <tr>
          <th>Dataset</th>
          <th style="text-align: center">RDKit (norm)</th>
          <th style="text-align: center">ECFC4</th>
          <th style="text-align: center">CDDD</th>
          <th style="text-align: center">MolBERT</th>
          <th style="text-align: center">MolBERT (finetune)</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>ESOL</td>
          <td style="text-align: center">0.687 +/- 0.08</td>
          <td style="text-align: center">0.902 +/- 0.06</td>
          <td style="text-align: center">0.567 +/- 0.06</td>
          <td style="text-align: center">0.552 +/- 0.07</td>
          <td style="text-align: center"><strong>0.531 +/- 0.04</strong></td>
      </tr>
      <tr>
          <td>FreeSolv</td>
          <td style="text-align: center">1.671 +/- 0.45</td>
          <td style="text-align: center">2.876 +/- 0.38</td>
          <td style="text-align: center">1.456 +/- 0.43</td>
          <td style="text-align: center">1.523 +/- 0.66</td>
          <td style="text-align: center"><strong>0.948 +/- 0.33</strong></td>
      </tr>
      <tr>
          <td>Lipophilicity</td>
          <td style="text-align: center">0.738 +/- 0.04</td>
          <td style="text-align: center">0.770 +/- 0.03</td>
          <td style="text-align: center">0.669 +/- 0.02</td>
          <td style="text-align: center">0.602 +/- 0.01</td>
          <td style="text-align: center"><strong>0.561 +/- 0.03</strong></td>
      </tr>
  </tbody>
</table>
<p>On MoleculeNet classification tasks (AUROC, higher is better):</p>
<table>
  <thead>
      <tr>
          <th>Dataset</th>
          <th style="text-align: center">RDKit (norm)</th>
          <th style="text-align: center">ECFC4</th>
          <th style="text-align: center">CDDD</th>
          <th style="text-align: center">MolBERT</th>
          <th style="text-align: center">MolBERT (finetune)</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>BACE</td>
          <td style="text-align: center">0.831</td>
          <td style="text-align: center">0.845</td>
          <td style="text-align: center">0.833</td>
          <td style="text-align: center">0.849</td>
          <td style="text-align: center"><strong>0.866</strong></td>
      </tr>
      <tr>
          <td>BBBP</td>
          <td style="text-align: center">0.696</td>
          <td style="text-align: center">0.678</td>
          <td style="text-align: center">0.761</td>
          <td style="text-align: center">0.750</td>
          <td style="text-align: center"><strong>0.762</strong></td>
      </tr>
      <tr>
          <td>HIV</td>
          <td style="text-align: center">0.708</td>
          <td style="text-align: center">0.714</td>
          <td style="text-align: center">0.753</td>
          <td style="text-align: center">0.747</td>
          <td style="text-align: center"><strong>0.783</strong></td>
      </tr>
  </tbody>
</table>
<p>Fine-tuned MolBERT achieved the best performance on all six QSAR datasets. When used as a fixed feature extractor with an SVM, MolBERT embeddings outperformed other representations on three of six tasks.</p>
<h2 id="key-findings-and-limitations">Key Findings and Limitations</h2>
<h3 id="key-findings">Key Findings</h3>
<ol>
<li><strong>Pre-training task selection matters significantly.</strong> The choice of auxiliary tasks during pre-training has a large effect on downstream performance. PhysChemPred provides the strongest individual signal.</li>
<li><strong>Domain-relevant auxiliary tasks improve representation quality.</strong> Predicting physicochemical properties during pre-training encodes chemical knowledge directly into the embeddings, outperforming purely linguistic objectives.</li>
<li><strong>The SMILES equivalence task hurts performance.</strong> Despite being chemically motivated, the SMILES-Eq task consistently degraded results, suggesting it may introduce conflicting learning signals.</li>
<li><strong>PhysChemPred organizes the embedding space.</strong> Analysis of pairwise cosine similarities showed that models trained with PhysChemPred assign high similarity to permutations of the same molecule and low similarity to different molecules, creating a more semantically meaningful representation space.</li>
</ol>
<h3 id="limitations">Limitations</h3>
<ul>
<li>The paper evaluates only SMILES-based representations, inheriting all limitations of string-based molecular encodings (inability to capture 3D structure, sensitivity to tokenization).</li>
<li>The virtual screening evaluation uses a fixed number of query molecules ($n = 5$), which may not reflect realistic screening scenarios.</li>
<li>Cross-validation splits from ChemBench were used for QSAR evaluation rather than scaffold splits, which may overestimate performance on structurally novel compounds.</li>
<li>The model&rsquo;s 128-token sequence length limit may truncate larger molecules, though relative positional embeddings partially address this at inference time.</li>
</ul>
<h3 id="future-directions">Future Directions</h3>
<p>The authors propose extending MolBERT to learn representations for other biological entities such as proteins, and developing more advanced pre-training strategies.</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>Pre-training</td>
          <td>GuacaMol (ChEMBL)</td>
          <td>~1.6M compounds</td>
          <td>80% train / 5% validation split</td>
      </tr>
      <tr>
          <td>Virtual Screening</td>
          <td>RDKit benchmark v1.2</td>
          <td>69 target datasets</td>
          <td>Filtered subset with active/decoy compounds</td>
      </tr>
      <tr>
          <td>QSAR (Regression)</td>
          <td>ESOL, FreeSolv, Lipophilicity</td>
          <td>Varies</td>
          <td>From MoleculeNet, ChemBench splits</td>
      </tr>
      <tr>
          <td>QSAR (Classification)</td>
          <td>BACE, BBBP, HIV</td>
          <td>Varies</td>
          <td>From MoleculeNet, ChemBench splits</td>
      </tr>
  </tbody>
</table>
<h3 id="algorithms">Algorithms</h3>
<ul>
<li>Architecture: BERT-Base (12 heads, 12 layers, 768-dim hidden, ~85M params)</li>
<li>Optimizer: Adam, learning rate $3 \times 10^{-5}$</li>
<li>Vocabulary: 42 tokens, sequence length 128</li>
<li>Masking: 15% of tokenized input</li>
<li>Positional encoding: relative positional embeddings (Transformer-XL)</li>
<li>Fine-tuning SVM: $C = 5.0$, RBF kernel (from Winter et al.)</li>
<li>Fine-tuning head: single linear layer on pooled output</li>
<li>Embeddings: pooled output (or average sequence output when only MaskedLM is used)</li>
</ul>
<h3 id="models">Models</h3>
<ul>
<li>BERT-Base with ~85M parameters</li>
<li>Pre-trained weights available at <a href="https://github.com/BenevolentAI/MolBERT">BenevolentAI/MolBERT</a></li>
</ul>
<h3 id="evaluation">Evaluation</h3>
<table>
  <thead>
      <tr>
          <th>Metric</th>
          <th>Task</th>
          <th>Notes</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>AUROC</td>
          <td>Virtual Screening, Classification QSAR</td>
          <td>Standard area under ROC curve</td>
      </tr>
      <tr>
          <td>BEDROC20</td>
          <td>Virtual Screening</td>
          <td>Early enrichment metric, $\alpha = 20$</td>
      </tr>
      <tr>
          <td>RMSE</td>
          <td>Regression QSAR</td>
          <td>Root mean squared error</td>
      </tr>
  </tbody>
</table>
<h3 id="hardware">Hardware</h3>
<ul>
<li>2 GPUs, 16 CPUs</li>
<li>Pre-training time: ~40 hours (20 epochs)</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/BenevolentAI/MolBERT">BenevolentAI/MolBERT</a></td>
          <td>Code + Model</td>
          <td>MIT</td>
          <td>Official implementation with pre-trained weights</td>
      </tr>
  </tbody>
</table>
<hr>
<h2 id="paper-information">Paper Information</h2>
<p><strong>Citation</strong>: Fabian, B., Edlich, T., Gaspar, H., Segler, M., Meyers, J., Fiscato, M., &amp; Ahmed, M. (2020). Molecular representation learning with language models and domain-relevant auxiliary tasks. <em>arXiv preprint arXiv:2011.13230</em>.</p>
<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">@article</span>{fabian2020molecular,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">title</span>=<span style="color:#e6db74">{Molecular representation learning with language models and domain-relevant auxiliary tasks}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">author</span>=<span style="color:#e6db74">{Fabian, Benedek and Edlich, Thomas and Gaspar, H{\&#39;e}l{\&#39;e}na and Segler, Marwin and Meyers, Joshua and Fiscato, Marco and Ahmed, Mohamed}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">journal</span>=<span style="color:#e6db74">{arXiv preprint arXiv:2011.13230}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">year</span>=<span style="color:#e6db74">{2020}</span>
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div>]]></content:encoded></item><item><title>Group SELFIES: Fragment-Based Molecular Strings</title><link>https://hunterheidenreich.com/notes/chemistry/molecular-representations/notations/group-selfies-fragment-molecular-representation/</link><pubDate>Thu, 26 Mar 2026 00:00:00 +0000</pubDate><guid>https://hunterheidenreich.com/notes/chemistry/molecular-representations/notations/group-selfies-fragment-molecular-representation/</guid><description>Group SELFIES extends SELFIES with fragment-based group tokens for chemically robust molecular string representations that improve distribution learning.</description><content:encoded><![CDATA[<h2 id="a-fragment-aware-extension-of-selfies">A Fragment-Aware Extension of SELFIES</h2>
<p>This is a <strong>Method</strong> paper that introduces Group SELFIES, a molecular string representation extending SELFIES by incorporating group tokens that represent functional groups or entire substructures. The primary contribution is a representation that maintains the 100% chemical validity guarantee of SELFIES while enabling fragment-level molecular encoding. Group SELFIES is shorter, more human-readable, and produces better distribution learning compared to both SMILES and standard SELFIES.</p>
<h2 id="from-atoms-to-fragments-in-molecular-strings">From Atoms to Fragments in Molecular Strings</h2>
<p>Molecular string representations underpin nearly all string-based molecular generation, from chemical language models and VAEs to genetic algorithms. SMILES, the dominant representation, suffers from validity issues: generated strings frequently contain syntax errors or violate valency constraints. SELFIES solved this by guaranteeing that every string decodes to a valid molecule, but both SMILES and SELFIES operate at the atomic level. Human chemists, by contrast, think about molecules in terms of functional groups and substructures.</p>
<p>Fragment-based generative models exploit this inductive bias by constructing custom representations amenable to fragment-based molecular design. However, these approaches are typically graph-based, losing the desirable properties of string representations: easy manipulation and direct input into established language models. Historical string representations like Wiswesser Line Notation (WLN), Hayward Notation, and SYBYL Line Notation (SLN) did use non-atomic tokens, but none provided chemical robustness guarantees.</p>
<p>The gap is clear: no existing string representation combines the chemical robustness of SELFIES with the fragment-level abstraction that captures meaningful chemical motifs.</p>
<h2 id="group-tokens-with-chemical-robustness-guarantees">Group Tokens with Chemical Robustness Guarantees</h2>
<p>The core innovation is the introduction of <strong>group tokens</strong> into the SELFIES framework. Each group token represents a predefined molecular fragment (such as a benzene ring, carboxyl group, or any user-specified substructure) and is treated as a single unit during encoding and decoding.</p>
<h3 id="group-definition">Group Definition</h3>
<p>Each group is defined as a set of atoms and bonds with labeled <strong>attachment points</strong> that specify how the group participates in bonding. Each attachment point has a specified maximum valency, allowing the decoder to continue tracking available valency during string construction. Group tokens take the form <code>[:S&lt;group-name&gt;]</code>, where <code>S</code> is the starting attachment index.</p>
<h3 id="encoding">Encoding</h3>
<p>To encode a molecule, the encoder first recognizes and replaces substructure matches from the group set. By default, the encoder processes larger groups first, but users can override this with priority values. The encoder then traverses the molecular graph similarly to standard SELFIES encoding, inserting tokens that track attachment indices for entering and exiting groups.</p>
<h3 id="decoding">Decoding</h3>
<p>When the decoder encounters a group token, it looks up the corresponding group in the group set dictionary, places all atoms of the group, and connects the main chain to the starting attachment point. Navigation between attachment points is handled by reading subsequent tokens as relative indices. If an attachment point is occupied, the next available one is used. If all attachment points are exhausted, the group is immediately popped from the stack.</p>
<h3 id="chemical-robustness">Chemical Robustness</h3>
<p>The key property preserved from SELFIES is that <strong>any arbitrary Group SELFIES string decodes to a molecule with valid valency</strong>. This is achieved by maintaining the same two SELFIES decoder features within the group framework:</p>
<ol>
<li>Token overloading: every token can be interpreted as a number when needed (for branch lengths, ring targets, or attachment indices).</li>
<li>Valency tracking: if adding a bond would exceed available valency, the decoder adjusts the bond order or skips the bond.</li>
</ol>
<p>The authors verified robustness by encoding and decoding 25 million molecules from the eMolecules database.</p>
<h3 id="chirality-handling">Chirality Handling</h3>
<p>Group SELFIES handles chirality differently from SMILES and SELFIES. Rather than using <code>@</code>-notation for tetrahedral chirality, all chiral centers must be specified as groups. An &ldquo;essential set&rdquo; of 23 groups covers all relevant chiral centers in the eMolecules database. This approach also supports extended chirality (axial, helical, planar) by abstracting the entire chiral substructure into a group token.</p>
<h3 id="fragment-selection">Fragment Selection</h3>
<p>The group set is a user-defined dictionary that maps group names to molecular fragments. Users can specify groups manually using SMILES-like syntax, extract them from fragment libraries, or use fragmentation algorithms such as matched molecular pair analysis. The authors tested several approaches, including a naive method that cleaves side chains from rings and methods based on cheminformatics fragmentation tools. A useful group set typically contains fragments that appear in many molecules and replace many atoms, with similar fragments merged to reduce redundancy.</p>
<h2 id="experiments-on-compactness-generation-and-distribution-learning">Experiments on Compactness, Generation, and Distribution Learning</h2>
<h3 id="compactness-section-41">Compactness (Section 4.1)</h3>
<p>Using 53 groups (30 extracted from ZINC-250k plus 23 from the essential set), Group SELFIES strings are shorter than their SMILES and SELFIES equivalents. Despite Group SELFIES having a larger alphabet, the compressed file size of the ZINC-250k dataset is smallest for Group SELFIES, indicating lower information-theoretic complexity.</p>
<h3 id="random-molecular-generation-section-42">Random Molecular Generation (Section 4.2)</h3>
<p>To isolate the effect of the representation from the generative model, the authors use a primitive generative model: sample a random string length from the dataset, draw tokens uniformly from a bag of all tokens, and concatenate. From 100,000 ZINC-250k molecules:</p>
<ul>
<li>Randomly sampled Group SELFIES strings produce molecules whose SAScore and QED distributions more closely overlap with the original ZINC dataset than molecules from randomly sampled SELFIES strings.</li>
<li>The Wasserstein distances to the ZINC distribution are consistently lower for Group SELFIES.</li>
<li>On a nonfullerene acceptor (NFA) dataset, Group SELFIES preserves aromatic rings while SELFIES rarely does.</li>
</ul>
<h3 id="distribution-learning-with-vaes-section-43">Distribution Learning with VAEs (Section 4.3)</h3>
<p>Using the MOSES benchmarking framework, VAEs were trained for 125 epochs on both Group SELFIES and SELFIES representations. The Group SELFIES VAE used 300 groups extracted from the MOSES training set. Results from 100,000 generated molecules:</p>
<table>
  <thead>
      <tr>
          <th>Metric</th>
          <th>Group-VAE-125</th>
          <th>SELFIES-VAE-125</th>
          <th>Train (Reference)</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>Valid</td>
          <td>1.0 (0)</td>
          <td>1.0 (0)</td>
          <td>1.0</td>
      </tr>
      <tr>
          <td>Unique@1k</td>
          <td>1.0 (0)</td>
          <td>0.9996 (5)</td>
          <td>1.0</td>
      </tr>
      <tr>
          <td>Unique@10k</td>
          <td>0.9985 (4)</td>
          <td>0.9986 (4)</td>
          <td>1.0</td>
      </tr>
      <tr>
          <td>FCD (Test)</td>
          <td>0.1787 (29)</td>
          <td>0.6351 (43)</td>
          <td>0.008</td>
      </tr>
      <tr>
          <td>FCD (TestSF)</td>
          <td>0.734 (109)</td>
          <td>1.3136 (128)</td>
          <td>0.4755</td>
      </tr>
      <tr>
          <td>SNN (Test)</td>
          <td>0.6051 (4)</td>
          <td>0.6014 (3)</td>
          <td>0.6419</td>
      </tr>
      <tr>
          <td>Frag (Test)</td>
          <td>0.9995 (0)</td>
          <td>0.9989 (0)</td>
          <td>1.0</td>
      </tr>
      <tr>
          <td>Scaf (Test)</td>
          <td>0.9649 (21)</td>
          <td>0.9588 (15)</td>
          <td>0.9907</td>
      </tr>
      <tr>
          <td>IntDiv</td>
          <td>0.8587 (1)</td>
          <td>0.8579 (1)</td>
          <td>0.8567</td>
      </tr>
      <tr>
          <td>Novelty</td>
          <td>0.9623 (7)</td>
          <td>0.96 (4)</td>
          <td>1.0</td>
      </tr>
  </tbody>
</table>
<p>The most notable improvement is in Frechet ChemNet Distance (FCD), where Group SELFIES achieves 0.1787 versus 0.6351 for SELFIES on the test set. FCD measures the difference between penultimate-layer activations of ChemNet, encoding a mixture of biological and chemical properties relevant to drug-likeness. Most other metrics are comparable, with Group SELFIES matching or slightly outperforming SELFIES across the board.</p>
<h2 id="advantages-limitations-and-future-directions">Advantages, Limitations, and Future Directions</h2>
<h3 id="key-findings">Key Findings</h3>
<p>Group SELFIES provides three main advantages over standard SELFIES:</p>
<ol>
<li><strong>Substructure control</strong>: Important scaffolds, chiral centers, and charged groups can be preserved during molecular optimization.</li>
<li><strong>Compactness</strong>: Group tokens represent multiple atoms, yielding shorter strings with lower information-theoretic complexity.</li>
<li><strong>Improved distribution learning</strong>: The FCD metric shows substantial improvement, indicating generated molecules better capture biological and chemical properties of the training set.</li>
</ol>
<p>Both SELFIES and Group SELFIES achieve 100% validity, eliminating the validity issues associated with SMILES-based generation.</p>
<h3 id="limitations">Limitations</h3>
<p>The authors acknowledge several limitations:</p>
<ul>
<li><strong>Computational speed</strong>: Encoding and decoding is slower than SELFIES due to RDKit overhead, particularly for the encoder which performs substructure matching for every group in the set.</li>
<li><strong>No group overlap</strong>: Groups cannot overlap in the current formulation, which limits expressiveness for polycyclic compounds.</li>
<li><strong>Group set design</strong>: Choosing an effective group set remains an open design choice that may require domain expertise or fragmentation algorithm tuning.</li>
<li><strong>Limited generative model evaluation</strong>: The paper focuses on random sampling and VAEs; evaluation with more sophisticated models (GANs, reinforcement learning, genetic algorithms) is left to future work.</li>
</ul>
<h3 id="future-directions">Future Directions</h3>
<p>The authors propose several extensions: flexible scaffold tokens that preserve topology while allowing atom-type variation, representations based on cellular complexes or hypergraphs to handle overlapping groups, and integration with genetic algorithms like JANUS for molecular optimization.</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>Compactness / Generation</td>
          <td>ZINC-250k</td>
          <td>250,000 molecules</td>
          <td>Random subset of 10,000 for fragment extraction; 100,000 for generation</td>
      </tr>
      <tr>
          <td>Distribution Learning</td>
          <td>MOSES benchmark</td>
          <td>~1.9M molecules</td>
          <td>Standard train/test split from MOSES framework</td>
      </tr>
      <tr>
          <td>Robustness Verification</td>
          <td>eMolecules</td>
          <td>25M molecules</td>
          <td>Full database encode-decode round trip</td>
      </tr>
      <tr>
          <td>NFA Generation</td>
          <td>NFA dataset</td>
          <td>Not specified</td>
          <td>Nonfullerene acceptors from Lopez et al. (2017)</td>
      </tr>
  </tbody>
</table>
<h3 id="algorithms">Algorithms</h3>
<ul>
<li><strong>Fragmentation</strong>: Naive ring-sidechain cleavage, matched molecular pair analysis, and diversity-based selection of 300 groups for VAE experiments.</li>
<li><strong>Essential set</strong>: 23 chiral groups covering all relevant chiral centers in eMolecules.</li>
<li><strong>Random generation</strong>: Bag-of-tokens sampling with length matched to dataset distribution.</li>
</ul>
<h3 id="models">Models</h3>
<ul>
<li><strong>VAE</strong>: Trained for 125 epochs on MOSES dataset using both SELFIES and Group SELFIES tokenizations.</li>
<li>Architecture details follow the MOSES benchmark VAE configuration.</li>
</ul>
<h3 id="evaluation">Evaluation</h3>
<table>
  <thead>
      <tr>
          <th>Metric</th>
          <th>Description</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>FCD</td>
          <td>Frechet ChemNet Distance (penultimate layer activations)</td>
      </tr>
      <tr>
          <td>SNN</td>
          <td>Average Tanimoto similarity to nearest neighbor in reference set</td>
      </tr>
      <tr>
          <td>Frag</td>
          <td>Cosine similarity of BRICS fragment distributions</td>
      </tr>
      <tr>
          <td>Scaf</td>
          <td>Cosine similarity of Bemis-Murcko scaffold distributions</td>
      </tr>
      <tr>
          <td>IntDiv</td>
          <td>Internal diversity via Tanimoto similarity</td>
      </tr>
      <tr>
          <td>Validity</td>
          <td>Percentage passing RDKit parsing</td>
      </tr>
      <tr>
          <td>Uniqueness</td>
          <td>Percentage of non-duplicate generated molecules</td>
      </tr>
      <tr>
          <td>Novelty</td>
          <td>Fraction of generated molecules not in training set</td>
      </tr>
  </tbody>
</table>
<h3 id="hardware">Hardware</h3>
<ul>
<li>Robustness verification performed on the Niagara supercomputer (SciNet HPC Consortium).</li>
<li>VAE training hardware not specified.</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/aspuru-guzik-group/group-selfies">group-selfies</a></td>
          <td>Code</td>
          <td>Apache-2.0</td>
          <td>Open-source Python implementation</td>
      </tr>
  </tbody>
</table>
<hr>
<h2 id="paper-information">Paper Information</h2>
<p><strong>Citation</strong>: Cheng, A. H., Cai, A., Miret, S., Malkomes, G., Phielipp, M., &amp; Aspuru-Guzik, A. (2023). Group SELFIES: A robust fragment-based molecular string representation. <em>Digital Discovery</em>, 2(3), 748-758. <a href="https://doi.org/10.1039/D3DD00012E">https://doi.org/10.1039/D3DD00012E</a></p>
<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">@article</span>{cheng2023group,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">title</span>=<span style="color:#e6db74">{Group SELFIES: A Robust Fragment-Based Molecular String Representation}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">author</span>=<span style="color:#e6db74">{Cheng, Austin H. and Cai, Andy and Miret, Santiago and Malkomes, Gustavo and Phielipp, Mariano and Aspuru-Guzik, Al{\&#39;a}n}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">journal</span>=<span style="color:#e6db74">{Digital Discovery}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">volume</span>=<span style="color:#e6db74">{2}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">number</span>=<span style="color:#e6db74">{3}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">pages</span>=<span style="color:#e6db74">{748--758}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">year</span>=<span style="color:#e6db74">{2023}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">publisher</span>=<span style="color:#e6db74">{Royal Society of Chemistry}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">doi</span>=<span style="color:#e6db74">{10.1039/D3DD00012E}</span>
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div>]]></content:encoded></item><item><title>DeepSMILES: Adapting SMILES Syntax for Machine Learning</title><link>https://hunterheidenreich.com/notes/chemistry/molecular-representations/notations/deepsmiles-adaptation-for-ml/</link><pubDate>Thu, 26 Mar 2026 00:00:00 +0000</pubDate><guid>https://hunterheidenreich.com/notes/chemistry/molecular-representations/notations/deepsmiles-adaptation-for-ml/</guid><description>DeepSMILES modifies SMILES syntax to eliminate unbalanced parentheses and unpaired ring closures, reducing invalid outputs from generative molecular models.</description><content:encoded><![CDATA[<h2 id="a-new-molecular-string-notation-for-generative-models">A New Molecular String Notation for Generative Models</h2>
<p>This is a <strong>Method</strong> paper that introduces DeepSMILES, a modified SMILES syntax designed to reduce the rate of syntactically invalid strings produced by machine-learning generative models. The primary contribution is a pair of string-level transformations (for ring closures and for branches) that can be applied independently and interconverted with standard SMILES without loss of information, including stereochemistry.</p>
<h2 id="the-problem-of-invalid-smiles-in-molecular-generation">The Problem of Invalid SMILES in Molecular Generation</h2>
<p>Deep neural networks for de novo molecular design commonly operate on <a href="/notes/chemistry/molecular-representations/notations/smiles/">SMILES</a> strings. <a href="/notes/machine-learning/generative-models/autoencoding-variational-bayes/">Variational autoencoders</a> (<a href="/notes/chemistry/molecular-design/generation/latent-space/automatic-chemical-design-vae/">Gomez-Bombarelli et al., 2018</a>), recurrent neural networks with LSTM (<a href="/notes/chemistry/molecular-design/generation/autoregressive/lstm-drug-like-molecule-generation/">Segler et al., 2018</a>; Olivecrona et al., 2017), and grammar-based approaches (<a href="/notes/chemistry/molecular-design/generation/latent-space/grammar-variational-autoencoder/">Kusner et al., 2017</a>) all generate molecules by sampling character sequences. A persistent problem is that many generated strings are syntactically invalid SMILES, with reported validity rates ranging from 7% to 80%.</p>
<p>Two structural features of SMILES syntax are responsible for most invalid strings:</p>
<ol>
<li><strong>Balanced parentheses</strong>: Branches require matched open/close parenthesis pairs. A generative model must track nesting state across long sequences to produce valid brackets.</li>
<li><strong>Paired ring closure symbols</strong>: Rings require two identical digit tokens at corresponding positions. The model must remember which digits are &ldquo;open&rdquo; and close them appropriately.</li>
</ol>
<p>Grammar-based approaches (e.g., <a href="/notes/chemistry/molecular-design/generation/latent-space/grammar-variational-autoencoder/">Grammar VAE</a>) can enforce balanced parentheses through a context-free grammar, but they cannot enforce the ring closure pairing constraint because that constraint is context-sensitive. Syntax-directed approaches (Dai et al., 2018) add explicit ring closure constraints but at the cost of significantly more complex decoder architectures.</p>
<h2 id="core-innovation-postfix-branch-notation-and-single-ring-closure-symbols">Core Innovation: Postfix Branch Notation and Single Ring Closure Symbols</h2>
<p>DeepSMILES addresses both syntax problems through two independent string transformations.</p>
<h3 id="ring-closure-transformation">Ring closure transformation</h3>
<p>Standard SMILES uses a pair of identical digits to mark ring openings and closings (e.g., <code>c1ccccc1</code> for benzene). DeepSMILES eliminates the ring-opening digit and replaces the ring-closing digit with the ring size, counting back along the tree path to the ring-opening atom. Benzene becomes <code>cccccc6</code>, where <code>6</code> means &ldquo;connect to the atom 6 positions back.&rdquo;</p>
<p>This transformation has three key properties:</p>
<ul>
<li>Every ring of a given size always uses the same digit, regardless of context. A phenyl ring is always <code>cccccc6</code> in DeepSMILES, whereas in SMILES it might be <code>c1ccccc1</code>, <code>c2ccccc2</code>, <code>c3ccccc3</code>, etc.</li>
<li>A single symbol cannot be &ldquo;unmatched&rdquo; since there is no corresponding opening symbol.</li>
<li>For double-digit ring sizes, the <code>%N</code> notation is used (and <code>%(N)</code> for sizes above 99).</li>
</ul>
<p>Bond stereochemistry is preserved by moving any explicit or stereo bond from the eliminated ring-opening symbol to the ring-closing symbol, with direction adjusted as needed.</p>
<h3 id="branch-parenthesis-transformation">Branch (parenthesis) transformation</h3>
<p>Standard SMILES uses matched open/close parenthesis pairs for branches (e.g., <code>C(OC)(SC)F</code>). DeepSMILES replaces this with a postfix notation inspired by Reverse Polish Notation (RPN). Only close parentheses are used, and the number of consecutive close parentheses indicates how far back on the current branch the next atom attaches.</p>
<p>For example, <code>C(OC)(SC)F</code> becomes <code>COC))SC))F</code>. The interpretation uses a stack: atoms are pushed onto the stack as they are read, each close parenthesis pops one atom from the stack, and the next atom connects to whatever is on top of the stack.</p>
<h3 id="stereochemistry-preservation">Stereochemistry preservation</h3>
<p>Tetrahedral stereochemistry is fully preserved through the transformations. When ring closure symbol reordering would change the stereo configuration, the <code>@</code>/<code>@@</code> annotation is inverted during encoding to compensate.</p>
<h3 id="independence-of-transformations">Independence of transformations</h3>
<p>The two transformations are independent and can be applied separately or together. Any application of DeepSMILES should specify which transformations were applied.</p>
<h2 id="roundtrip-validation-on-chembl-23">Roundtrip Validation on ChEMBL 23</h2>
<p>The authors validated DeepSMILES by roundtripping all entries in the ChEMBL 23 database through SMILES-to-DeepSMILES-to-SMILES conversion. Canonical SMILES (including stereochemistry) were generated by four independent cheminformatics toolkits: CDK, OEChem, Open Babel, and RDKit. Using multiple toolkits ensures coverage of different traversal orders and ring closure ordering conventions.</p>
<p>All SMILES strings roundtripped without error across all three configurations (branches only, rings only, both). The exact string representation may differ in ring closure digit assignment or digit ordering, sometimes with an associated stereo inversion at tetrahedral centers, but the canonical SMILES of the original and roundtripped molecules are identical.</p>
<h3 id="performance-characteristics">Performance characteristics</h3>
<p>The following table shows the effect of DeepSMILES conversion on string length and throughput, measured on canonical SMILES from Open Babel for ChEMBL 23:</p>
<table>
  <thead>
      <tr>
          <th>Transformation</th>
          <th>Mean % change in length</th>
          <th>Encoding (per sec)</th>
          <th>Decoding (per sec)</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>Branches only</td>
          <td>+8.2%</td>
          <td>32,000</td>
          <td>16,000</td>
      </tr>
      <tr>
          <td>Rings only</td>
          <td>-6.4%</td>
          <td>26,000</td>
          <td>24,000</td>
      </tr>
      <tr>
          <td>Both</td>
          <td>+1.9%</td>
          <td>26,000</td>
          <td>17,500</td>
      </tr>
  </tbody>
</table>
<p>The ring transformation slightly shortens strings (by removing one digit per ring), while the branch transformation slightly lengthens them (additional close parentheses). Combined, the net effect is a small increase of about 2%. Throughput is in the tens of thousands of conversions per second in pure Python.</p>
<h2 id="limitations-and-future-directions">Limitations and Future Directions</h2>
<p>DeepSMILES does not eliminate all invalid strings. Invalid DeepSMILES can still be generated, for example when there are more close parentheses than atoms on the stack, or when a ring size exceeds the number of available atoms. The reference implementation raises a <code>DecodeError</code> in these cases, though the authors note that a more tolerant decoder (ignoring extra parentheses or defaulting to the first atom for oversized rings) could be used during generation.</p>
<p>The paper assumes that input SMILES are generated by a standard cheminformatics toolkit as a depth-first traversal of the molecular graph. Non-standard SMILES (e.g., <code>CC(C1)CCCC1</code>) cannot be directly encoded.</p>
<p>The authors suggest several directions for future work:</p>
<ul>
<li>Investigating whether a preferred traversal order (e.g., shorter branches first) would make DeepSMILES even easier for models to learn.</li>
<li>Exploring notations where atoms in the organic subset explicitly list their hydrogen count, which would allow a fully parenthesis-free representation.</li>
<li>Using SMILES augmentation with random traversal orders (as explored by Bjerrum and Threlfall, 2017) in combination with DeepSMILES.</li>
<li>Designing entirely new line notations optimized for ML, where every string maps to a valid molecule, there are few duplicate representations, small string changes produce small structural changes, and string length correlates with pharmaceutical relevance.</li>
</ul>
<p>The fused ring case presents additional complexity: a bicyclic system has three cycles, and depending on traversal order, the ring size digit may not directly correspond to the ring size of any individual ring. This is an inherent limitation of depth-first traversal-based notations.</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>Validation</td>
          <td>ChEMBL 23</td>
          <td>~1.7M compounds</td>
          <td>Canonical SMILES from CDK, OEChem, Open Babel, RDKit</td>
      </tr>
  </tbody>
</table>
<h3 id="algorithms">Algorithms</h3>
<p>The DeepSMILES encoder and decoder are pure string-processing algorithms with no machine-learning components. The transformations operate on SMILES syntax tokens (atoms, bonds, parentheses, ring closure digits) without chemical interpretation.</p>
<h3 id="evaluation">Evaluation</h3>
<table>
  <thead>
      <tr>
          <th>Metric</th>
          <th>Value</th>
          <th>Notes</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>Roundtrip accuracy</td>
          <td>100%</td>
          <td>All ChEMBL 23 entries across 4 toolkits</td>
      </tr>
      <tr>
          <td>Encoding throughput</td>
          <td>26,000-32,000/s</td>
          <td>Pure Python, varies by transformation</td>
      </tr>
      <tr>
          <td>Decoding throughput</td>
          <td>16,000-24,000/s</td>
          <td>Pure Python, varies by transformation</td>
      </tr>
  </tbody>
</table>
<h3 id="hardware">Hardware</h3>
<p>No specific hardware requirements. The implementation is a pure Python module with no GPU dependencies.</p>
<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/nextmovesoftware/deepsmiles">deepsmiles</a></td>
          <td>Code</td>
          <td>MIT</td>
          <td>Pure Python encoder/decoder</td>
      </tr>
  </tbody>
</table>
<hr>
<h2 id="paper-information">Paper Information</h2>
<p><strong>Citation</strong>: O&rsquo;Boyle, N. M., &amp; Dalke, A. (2018). DeepSMILES: An Adaptation of SMILES for Use in Machine-Learning of Chemical Structures. <em>ChemRxiv</em>. <a href="https://doi.org/10.26434/chemrxiv.7097960.v1">https://doi.org/10.26434/chemrxiv.7097960.v1</a></p>
<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">@article</span>{oboyle2018deepsmiles,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">title</span>=<span style="color:#e6db74">{DeepSMILES: An Adaptation of SMILES for Use in Machine-Learning of Chemical Structures}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">author</span>=<span style="color:#e6db74">{O&#39;Boyle, Noel M. and Dalke, Andrew}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">journal</span>=<span style="color:#e6db74">{ChemRxiv}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">year</span>=<span style="color:#e6db74">{2018}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">doi</span>=<span style="color:#e6db74">{10.26434/chemrxiv.7097960.v1}</span>
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div>]]></content:encoded></item><item><title>CDDD: Learning Descriptors by Translating SMILES</title><link>https://hunterheidenreich.com/notes/chemistry/molecular-representations/encoders/cddd-translation-molecular-descriptors/</link><pubDate>Thu, 26 Mar 2026 00:00:00 +0000</pubDate><guid>https://hunterheidenreich.com/notes/chemistry/molecular-representations/encoders/cddd-translation-molecular-descriptors/</guid><description>CDDD learns continuous molecular descriptors by translating between SMILES and InChI representations, outperforming fingerprints in virtual screening.</description><content:encoded><![CDATA[<h2 id="a-translation-based-method-for-learned-molecular-descriptors">A Translation-Based Method for Learned Molecular Descriptors</h2>
<p>This is a <strong>Method</strong> paper that introduces Continuous and Data-Driven Descriptors (CDDD), a neural machine translation approach for learning fixed-size, continuous molecular representations. Rather than training an autoencoder to reconstruct <a href="/notes/chemistry/molecular-representations/notations/smiles/">SMILES</a> strings, Winter et al. train an encoder-decoder model to translate between semantically equivalent but syntactically different molecular representations (e.g., randomized SMILES to canonical SMILES, or <a href="/notes/chemistry/molecular-representations/notations/inchi-2013/">InChI</a> to canonical SMILES). The bottleneck latent vector serves as a general-purpose molecular descriptor. Pretrained on approximately 72 million compounds from <a href="/notes/chemistry/datasets/zinc-22/">ZINC15</a> and PubChem, CDDD produces 512-dimensional descriptors that achieve competitive QSAR performance and significantly outperform all tested molecular fingerprints in ligand-based virtual screening.</p>
<h2 id="why-translation-instead-of-reconstruction">Why Translation Instead of Reconstruction?</h2>
<p>Molecular descriptors are central to cheminformatics. Traditional approaches rely on human-engineered fingerprints like ECFPs, which encode structural features as fixed-length bit vectors. While effective, these representations are constrained by predefined feature extraction rules.</p>
<p>Recent work applied deep neural networks directly to molecular graphs or SMILES strings to learn task-specific representations. However, these end-to-end approaches must learn features from scratch for each new dataset, making them prone to overfitting on the small bioactivity datasets typical in drug discovery.</p>
<p>Unsupervised approaches based on autoencoders (notably <a href="/notes/chemistry/molecular-design/generation/latent-space/automatic-chemical-design-vae/">Gomez-Bombarelli et al.&rsquo;s VAE</a> and <a href="/notes/chemistry/molecular-representations/encoders/seq2seq-fingerprint-molecular-embedding/">Xu et al.&rsquo;s seq2seq model</a>) offered a path toward general-purpose learned descriptors. These models reconstruct SMILES strings through an information bottleneck, forcing the latent space to capture molecular information. The concern with reconstruction, however, is that the model may focus on syntactic patterns of the string representation rather than the underlying chemical semantics. A model that memorizes SMILES syntax shortcuts can achieve low reconstruction error without truly encoding chemical meaning.</p>
<p>Winter et al. address this by drawing on the analogy to neural machine translation: a translator must understand the meaning of a sentence to produce a correct translation in another language. By training the model to translate between different molecular representations (which share chemical semantics but differ in syntax), the latent space is forced to capture the chemical information common to both representations, rather than representation-specific syntactic artifacts.</p>
<h2 id="translation-as-semantic-compression">Translation as Semantic Compression</h2>
<p>The core insight is that translating between two syntactically different but semantically equivalent representations forces the encoder to capture only the chemical meaning shared by both. The model architecture follows the standard encoder-decoder framework from neural machine translation.</p>
<p>The encoder reads a source molecular string (e.g., a randomized SMILES or InChI) and compresses it into a fixed-size latent vector. The decoder takes this latent vector and generates the target molecular string (canonical SMILES). The model is trained to minimize character-level cross-entropy between the decoder output and the target sequence.</p>
<p>Four translation tasks were evaluated:</p>
<ol>
<li><strong>Randomized SMILES to canonical SMILES</strong> (best performing)</li>
<li><strong>InChI to canonical SMILES</strong></li>
<li><strong>Canonical SMILES to canonical SMILES</strong> (autoencoding baseline)</li>
<li><strong>Canonical SMILES to InChI</strong> (failed to learn)</li>
</ol>
<p>The final model uses an RNN encoder with 3 stacked GRU layers (512, 1024, and 2048 units). The concatenated cell states pass through a fully connected layer with tanh activation to produce a 512-dimensional latent vector. The decoder mirrors this architecture, initializing its GRU states from the latent vector via separate fully connected layers. Teacher forcing is used during training, and left-to-right beam search is used at inference.</p>
<p>An auxiliary property prediction network takes the latent vector as input and predicts nine molecular properties (logP, partial charges, valence electrons, H-bond donors/acceptors, Balaban&rsquo;s J, <a href="https://en.wikipedia.org/wiki/Molar_refractivity">molar refractivity</a>, TPSA). This multi-task signal encourages the latent space to encode physically meaningful information. The full training objective combines the translation cross-entropy loss with the property prediction mean squared error:</p>
<p>$$\mathcal{L} = \mathcal{L}_{\text{translation}} + \mathcal{L}_{\text{properties}}$$</p>
<p>To ensure invariance to input SMILES representation at inference time, the model uses randomized SMILES as input half the time and canonical SMILES the other half during training. Input dropout (15% at the character level) and Gaussian noise (standard deviation 0.05) are applied for regularization.</p>
<h2 id="qsar-benchmarks-virtual-screening-and-latent-space-exploration">QSAR Benchmarks, Virtual Screening, and Latent Space Exploration</h2>
<h3 id="pretraining">Pretraining</h3>
<p>The model was pretrained on approximately 72 million compounds from ZINC15 and PubChem (merged, deduplicated, filtered for organic molecules with MW 12-600, &gt;3 heavy atoms, logP between -7 and 5). All evaluation compounds were removed from the pretraining set.</p>
<h3 id="qsar-experiments">QSAR Experiments</h3>
<p>Ten QSAR datasets were used, spanning classification (<a href="https://en.wikipedia.org/wiki/Ames_test">Ames mutagenicity</a>, <a href="https://en.wikipedia.org/wiki/KCNH2">hERG inhibition</a>, <a href="https://en.wikipedia.org/wiki/Blood%E2%80%93brain_barrier">BBB penetration</a>, BACE inhibition, bee toxicity) and regression (EGFR inhibition, <a href="https://en.wikipedia.org/wiki/Plasmodium_falciparum">Plasmodium falciparum</a> inhibition, lipophilicity, aqueous solubility, melting point). Two datasets (Ames and lipophilicity) served as validation for architecture selection; the remaining eight were held out for final evaluation.</p>
<p>CDDD descriptors with an SVM were benchmarked against:</p>
<ul>
<li>Nine circular fingerprint variants (Morgan fingerprints, radius 1-3, folded to 512/1024/2048 bits) with RF, SVM, and GB</li>
<li>Graph convolution models (<a href="/notes/chemistry/molecular-design/property-prediction/moleculenet-benchmark-molecular-ml/">DeepChem</a>)</li>
</ul>
<p>Both random-split and cluster-split (K-means on MACCS fingerprints, K=5) cross-validation were performed.</p>
<table>
  <thead>
      <tr>
          <th>Task</th>
          <th>Split</th>
          <th>CDDD + SVM</th>
          <th>Best Fingerprint</th>
          <th>Graph Conv</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>Ames (ROC-AUC)</td>
          <td>Random</td>
          <td>0.89</td>
          <td>0.89 (ecfc2, RF)</td>
          <td>0.88</td>
      </tr>
      <tr>
          <td>hERG (ROC-AUC)</td>
          <td>Random</td>
          <td>0.86</td>
          <td>0.85 (ecfc4, RF)</td>
          <td>0.86</td>
      </tr>
      <tr>
          <td>BBBP (ROC-AUC)</td>
          <td>Random</td>
          <td>0.93</td>
          <td>0.93 (ecfc2, RF)</td>
          <td>0.92</td>
      </tr>
      <tr>
          <td>BACE (ROC-AUC)</td>
          <td>Random</td>
          <td>0.90</td>
          <td>0.91 (ecfc2, RF)</td>
          <td>0.91</td>
      </tr>
      <tr>
          <td>Bee toxicity (ROC-AUC)</td>
          <td>Random</td>
          <td>0.92</td>
          <td>0.91 (ecfc6, RF)</td>
          <td>0.89</td>
      </tr>
      <tr>
          <td>Lipophilicity ($r^2$)</td>
          <td>Random</td>
          <td>0.72</td>
          <td>0.69 (ecfc2, SVM)</td>
          <td>0.73</td>
      </tr>
      <tr>
          <td>ESOL ($r^2$)</td>
          <td>Random</td>
          <td>0.92</td>
          <td>0.58 (ecfc6, SVM)</td>
          <td>0.86</td>
      </tr>
      <tr>
          <td>Melting point ($r^2$)</td>
          <td>Random</td>
          <td>0.42</td>
          <td>0.38 (ecfc2, SVM)</td>
          <td>0.39</td>
      </tr>
  </tbody>
</table>
<p>CDDD descriptors showed competitive or better performance across all tasks. Notably, CDDD achieved substantially higher $r^2$ on aqueous solubility (0.92 vs. 0.58 for the best fingerprint). The authors emphasize that CDDD&rsquo;s feature extraction was fixed based on two validation tasks, while baseline methods selected the best fingerprint/model combination per task, making the comparison conservative for CDDD.</p>
<h3 id="virtual-screening">Virtual Screening</h3>
<p>Ligand-based virtual screening experiments followed the Riniker et al. benchmarking protocol on 40 DUD targets and 17 MUV targets. Five active compounds were randomly selected per target, and remaining compounds were ranked by similarity (cosine similarity for CDDD, <a href="https://en.wikipedia.org/wiki/Jaccard_index">Tanimoto</a> for fingerprints). This process was repeated 50 times per target.</p>
<table>
  <thead>
      <tr>
          <th>Database</th>
          <th>CDDD (ROC-AUC)</th>
          <th>Second Best</th>
          <th>p-value (Wilcoxon)</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>DUD</td>
          <td>0.949</td>
          <td>0.899 (laval)</td>
          <td>$5 \times 10^{-38}$</td>
      </tr>
      <tr>
          <td>MUV</td>
          <td>0.679</td>
          <td>0.677 (ap)</td>
          <td>0.04</td>
      </tr>
  </tbody>
</table>
<p>CDDD significantly outperformed all 14 baseline fingerprints on both databases. The DUD improvement was particularly large (+5.0 ROC-AUC points over the next best). On MUV, which is designed to be harder, the advantage was smaller but still statistically significant. Importantly, while the best baseline fingerprint varied between DUD and MUV (laval vs. ap), CDDD ranked first on both, demonstrating consistent performance.</p>
<h3 id="latent-space-exploration">Latent Space Exploration</h3>
<p>The continuous, reversible nature of CDDD enables chemical space navigation. Shifting a molecule&rsquo;s embedding along the first principal component of the pretraining data correlates with molecular size (Spearman $r = 0.947$, $p = 0.00048$), while the second principal component correlates with polarity/logP ($r = -0.916$, $p = 0.00015$).</p>
<p>When shifting 1000 compounds along 100 random directions, the model maintained high valid SMILES generation rates (&gt;97% for the top beam search output, &gt;99% when considering the top 3 outputs). Euclidean distance in the descriptor space correlated smoothly with Tanimoto distance in fingerprint space, confirming that the latent space supports meaningful interpolation.</p>
<h2 id="consistent-learned-descriptors-for-chemistry">Consistent Learned Descriptors for Chemistry</h2>
<p>CDDD demonstrated that translation between molecular representations produces more informative latent spaces than autoencoder reconstruction. The key findings are:</p>
<ol>
<li><strong>Translation outperforms reconstruction</strong>: Models trained on translating between different representations consistently produced better downstream descriptors than autoencoding models, despite autoencoding being an easier task.</li>
<li><strong>Auxiliary property prediction helps</strong>: The additional classification task for molecular properties improved descriptor quality, particularly for physicochemical endpoints correlated with the predicted properties.</li>
<li><strong>Consistent performance</strong>: Unlike baseline methods where the best fingerprint varies by task, CDDD showed consistent performance across all QSAR and VS experiments.</li>
<li><strong>Smooth latent space</strong>: The continuous descriptor space supports meaningful interpolation and chemical space exploration with high valid SMILES rates.</li>
</ol>
<p>The authors acknowledge several limitations. The InChI-to-SMILES translation worked but produced inferior descriptors compared to SMILES-to-SMILES, and SMILES-to-InChI translation failed entirely, likely due to InChI&rsquo;s complex syntax (counting, arithmetic). The approach was only tested with string-based representations; translation between conceptually different representations (e.g., 3D structures) remains future work. The QSAR evaluation, while extensive, used relatively standard datasets, and the method&rsquo;s advantage over graph convolution models was modest on tasks where end-to-end learning had sufficient data.</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>Pretraining</td>
          <td>ZINC15 + PubChem (merged)</td>
          <td>~72M compounds</td>
          <td>Filtered: organic, MW 12-600, &gt;3 heavy atoms, logP -7 to 5</td>
      </tr>
      <tr>
          <td>Validation</td>
          <td>Ames mutagenicity</td>
          <td>6,130</td>
          <td>Classification</td>
      </tr>
      <tr>
          <td>Validation</td>
          <td>Lipophilicity</td>
          <td>3,817</td>
          <td>Regression</td>
      </tr>
      <tr>
          <td>Test</td>
          <td>hERG, BBBP, BACE, bee toxicity</td>
          <td>188-3,440</td>
          <td>Classification</td>
      </tr>
      <tr>
          <td>Test</td>
          <td>EGFR, Plasmodium, ESOL, melting point</td>
          <td>184-4,451</td>
          <td>Regression</td>
      </tr>
      <tr>
          <td>VS</td>
          <td>DUD</td>
          <td>40 targets</td>
          <td>Ligand-based virtual screening</td>
      </tr>
      <tr>
          <td>VS</td>
          <td>MUV</td>
          <td>17 targets</td>
          <td>Maximum unbiased validation</td>
      </tr>
  </tbody>
</table>
<h3 id="algorithms">Algorithms</h3>
<ul>
<li>Encoder: 3 stacked GRU layers (512, 1024, 2048 units) with tanh bottleneck to 512-dim latent space</li>
<li>Decoder: Matching 3 stacked GRU layers, initialized from latent space</li>
<li>Auxiliary classifier: 3 FC layers (512, 128, 9) predicting molecular properties</li>
<li>Optimizer: Adam, initial LR $5 \times 10^{-4}$, decayed by 0.9 every 50,000 steps</li>
<li>Batch size: 64 with bucketing by sequence length</li>
<li>Input regularization: 15% character dropout + Gaussian noise (std 0.05)</li>
<li>Beam search for decoding at inference</li>
</ul>
<h3 id="models">Models</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/jrwnter/cddd">CDDD (GitHub)</a></td>
          <td>Code + Model</td>
          <td>MIT</td>
          <td>Pretrained model and extraction code</td>
      </tr>
  </tbody>
</table>
<h3 id="evaluation">Evaluation</h3>
<ul>
<li>QSAR: 5-fold random CV and 5-fold cluster CV (K-means on MACCS, K=5)</li>
<li>Classification metric: ROC-AUC</li>
<li>Regression metric: $r^2$</li>
<li>VS: ROC-AUC averaged over 50 random active set selections per target</li>
<li>Statistical test: <a href="https://en.wikipedia.org/wiki/Wilcoxon_signed-rank_test">Wilcoxon signed-rank test</a> for VS comparisons</li>
</ul>
<h3 id="hardware">Hardware</h3>
<ul>
<li>Framework: TensorFlow 1.4.1</li>
<li>Fingerprint extraction on GPU is comparable in speed to RDKit on CPU</li>
<li>SVM training on 512-dim CDDD descriptors takes seconds (vs. minutes for 2048-dim fingerprints)</li>
<li>Graph convolution training: ~30 minutes per task on GPU</li>
</ul>
<hr>
<h2 id="paper-information">Paper Information</h2>
<p><strong>Citation</strong>: Winter, R., Montanari, F., Noe, F., &amp; Clevert, D.-A. (2019). Learning continuous and data-driven molecular descriptors by translating equivalent chemical representations. <em>Chemical Science</em>, 10(6), 1692-1701. <a href="https://doi.org/10.1039/C8SC04175J">https://doi.org/10.1039/C8SC04175J</a></p>
<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">@article</span>{winter2019learning,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">title</span>=<span style="color:#e6db74">{Learning continuous and data-driven molecular descriptors by translating equivalent chemical representations}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">author</span>=<span style="color:#e6db74">{Winter, Robin and Montanari, Floriane and No{\&#39;e}, Frank and Clevert, Djork-Arn{\&#39;e}}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">journal</span>=<span style="color:#e6db74">{Chemical Science}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">volume</span>=<span style="color:#e6db74">{10}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">number</span>=<span style="color:#e6db74">{6}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">pages</span>=<span style="color:#e6db74">{1692--1701}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">year</span>=<span style="color:#e6db74">{2019}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">publisher</span>=<span style="color:#e6db74">{Royal Society of Chemistry}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">doi</span>=<span style="color:#e6db74">{10.1039/C8SC04175J}</span>
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div>]]></content:encoded></item><item><title>Atom-in-SMILES: Better Tokens for Chemical Models</title><link>https://hunterheidenreich.com/notes/chemistry/molecular-representations/notations/atom-in-smiles-tokenization/</link><pubDate>Thu, 26 Mar 2026 00:00:00 +0000</pubDate><guid>https://hunterheidenreich.com/notes/chemistry/molecular-representations/notations/atom-in-smiles-tokenization/</guid><description>Atom-in-SMILES replaces generic SMILES tokens with environment-aware atomic tokens, reducing token degeneration and improving chemical translation accuracy.</description><content:encoded><![CDATA[<h2 id="a-new-tokenization-method-for-chemical-language-models">A New Tokenization Method for Chemical Language Models</h2>
<p>This is a <strong>Method</strong> paper that introduces Atom-in-SMILES (AIS), a tokenization scheme for SMILES strings that replaces generic atomic tokens with environment-aware tokens encoding each atom&rsquo;s local chemical neighborhood. The primary contribution is demonstrating that tokenization quality has a significant impact on chemical language model outcomes across multiple tasks: SMILES canonicalization, <a href="/notes/chemistry/molecular-design/reaction-prediction/">single-step retrosynthesis</a>, and <a href="/notes/chemistry/molecular-design/property-prediction/">molecular property prediction</a>.</p>
<h2 id="why-standard-smiles-tokenization-falls-short">Why Standard SMILES Tokenization Falls Short</h2>
<p>Standard atom-wise SMILES tokenization treats all atoms of the same element identically. Every carbon is tokenized as &ldquo;C&rdquo; regardless of whether it is part of an aromatic ring, a carbonyl group, or a methyl chain. This creates a highly degenerate token space where chemically distinct atoms share the same representation.</p>
<p>The authors draw an analogy between natural language and chemical language. A typical SMILES sequence is about three times longer than a natural language sentence, yet the token vocabulary is roughly 1000 times smaller. This mismatch leads to extreme token repetition: the same tokens (C, c, N, O) appear many times within a single sequence. In natural language processing, token degeneration (where models repeatedly predict the same token) is a known failure mode of autoregressive decoders. The repetitive nature of SMILES tokens exacerbates this problem in chemical language models.</p>
<p>SMILES also lacks a one-to-one correspondence between tokens and chemical meaning. Two molecules that differ in only one atom substitution (e.g., swapping a carbon for a nitrogen in a ring) produce identical token sets under atom-wise tokenization, making it harder for models to distinguish structurally similar molecules.</p>
<h2 id="core-innovation-encoding-atom-environments-into-tokens">Core Innovation: Encoding Atom Environments into Tokens</h2>
<p>The key insight is to replace each atomic token with a richer token that encodes the atom&rsquo;s local chemical environment, inspired by the <a href="https://en.wikipedia.org/wiki/Atoms_in_molecules">atoms-in-molecules (AIM)</a> concept from quantum chemistry. For a given SMILES string, the AIS mapping function $f$ operates on the token space:</p>
<p>$$
f(X) = \begin{cases} AE|_{X_{\text{central}}} &amp; \text{if } X \text{ is an atom} \\ X &amp; \text{otherwise} \end{cases}
$$</p>
<p>where $AE|_{X_{\text{central}}}$ denotes the atomic environment centered on atom $X$. Non-atomic tokens (brackets, bond symbols, ring closures) pass through unchanged.</p>
<p>Each AIS token is formatted as <code>[Sym;Ring;Neighbors]</code> where:</p>
<ul>
<li><strong>Sym</strong> is the atomic symbol with chirality, aromaticity (lowercase for aromatic), hydrogen count, and formal charge</li>
<li><strong>Ring</strong> indicates whether the atom is in a ring (<code>R</code>) or not (<code>!R</code>)</li>
<li><strong>Neighbors</strong> lists the neighboring atoms interacting with the central atom</li>
</ul>
<p>This mapping is bijective: SMILES strings can be fully recovered from AIS strings via an inverse projection. The algorithm iterates over atoms in a molecule, computes their local environments using RDKit, and produces environment-aware token variants.</p>
<p>As a concrete example, in glycine the two carbons and two oxygens are indistinguishable under atom-wise tokenization. Under AIS, each receives a unique token reflecting its bonding environment (e.g., the carboxyl carbon is distinguished from the alpha carbon).</p>
<p>The AIS tokenization also exhibits a fingerprint-like property. Because each token encodes local structural information, the set of AIS tokens for a molecule functions similarly to circular fingerprints like ECFP2. The authors show that pairwise <a href="https://en.wikipedia.org/wiki/Jaccard_index">Tanimoto similarities</a> computed from AIS token sets have resolution comparable to ECFP2 and HashAP fingerprints, and better resolution than MACCS, Avalon, and RDKit fingerprints.</p>
<p>Token repetition can be quantified as:</p>
<p>$$
\text{rep-}l = \sum_{t=1}^{|s|} \mathbb{1}[s_t \in s_{t-w-1:t-1}]
$$</p>
<p>where $s$ is the predicted sequence, $|s|$ is the token count, and $w$ is the window size. AIS tokens exhibit consistently lower normalized repetition rates compared to SMILES, <a href="/notes/chemistry/molecular-representations/notations/selfies/">SELFIES</a>, and <a href="/notes/chemistry/molecular-representations/notations/deepsmiles-adaptation-for-ml/">DeepSMILES</a> across diverse molecular datasets (drugs, natural products, steroids, lipids, metal complexes, octane isomers).</p>
<h2 id="experimental-evaluation-across-three-chemical-tasks">Experimental Evaluation Across Three Chemical Tasks</h2>
<h3 id="input-output-equivalent-mapping-smiles-canonicalization">Input-Output Equivalent Mapping (SMILES Canonicalization)</h3>
<p>The first task tests whether a model can translate non-canonical SMILES enumerations into canonical form. The authors constructed deliberately challenging datasets from <a href="/notes/chemistry/datasets/gdb-13/">GDB-13</a> subsets with cumulative structural constraints (no cyclic heteroatom-heteroatom bonds, stable functional groups only, fragment-like, scaffold-like, etc.), generating training sets of 1M molecules augmented with 150K molecules from the most restrictive subset at 10x, 30x, and 50x augmentation levels.</p>
<table>
  <thead>
      <tr>
          <th>GDB-13 Subset</th>
          <th>Atom-wise (x10)</th>
          <th>Atom-wise (x50)</th>
          <th>AIS (x10)</th>
          <th>AIS (x50)</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>ab</td>
          <td>34.2%</td>
          <td>33.2%</td>
          <td>37.3%</td>
          <td>34.1%</td>
      </tr>
      <tr>
          <td>abc</td>
          <td>31.0%</td>
          <td>29.6%</td>
          <td>33.7%</td>
          <td>30.4%</td>
      </tr>
      <tr>
          <td>abcde</td>
          <td>48.7%</td>
          <td>45.5%</td>
          <td>53.6%</td>
          <td>47.0%</td>
      </tr>
      <tr>
          <td>abcdef</td>
          <td>41.8%</td>
          <td>39.1%</td>
          <td>52.5%</td>
          <td>46.9%</td>
      </tr>
      <tr>
          <td>abcdefg</td>
          <td>50.9%</td>
          <td>50.0%</td>
          <td>59.9%</td>
          <td>56.8%</td>
      </tr>
  </tbody>
</table>
<p>AIS outperformed atom-wise tokenization on all subsets and augmentation levels. The performance gap grew larger for more restrictive (more similar) subsets, reaching up to 10.7% on the abcdef subset. This demonstrates that AIS is particularly effective when molecules are structurally similar and harder to distinguish.</p>
<h3 id="single-step-retrosynthesis">Single-Step Retrosynthesis</h3>
<p>The second task uses the USPTO-50K benchmark for single-step <a href="https://en.wikipedia.org/wiki/Retrosynthetic_analysis">retrosynthetic prediction</a> via a template-free transformer encoder-decoder model. The model was trained for 200,000 steps with Adam optimizer, negative log-likelihood loss, and cyclic learning rate scheduling.</p>
<table>
  <thead>
      <tr>
          <th>Tokenization</th>
          <th>rep-|P - rep-|GT &gt;= 2</th>
          <th>String Exact (%)</th>
          <th>Tc Exact (%)</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>Atom-wise baseline</td>
          <td>&ndash;</td>
          <td>42.00</td>
          <td>&ndash;</td>
      </tr>
      <tr>
          <td>Atom-wise (reproduced)</td>
          <td>801</td>
          <td>42.05</td>
          <td>44.72</td>
      </tr>
      <tr>
          <td>SmilesPE</td>
          <td>821</td>
          <td>19.82</td>
          <td>22.74</td>
      </tr>
      <tr>
          <td>SELFIES</td>
          <td>886</td>
          <td>28.82</td>
          <td>30.76</td>
      </tr>
      <tr>
          <td>DeepSMILES</td>
          <td>902</td>
          <td>38.63</td>
          <td>41.20</td>
      </tr>
      <tr>
          <td><strong>Atom-in-SMILES</strong></td>
          <td><strong>727</strong></td>
          <td><strong>46.32</strong></td>
          <td><strong>47.62</strong></td>
      </tr>
  </tbody>
</table>
<p>AIS achieved 46.32% string exact accuracy (4.3% above the atom-wise baseline) and 47.62% Tanimoto exact accuracy (2.9% above baseline). AIS also had the fewest degenerate token repetitions (727 vs. 801 for atom-wise), representing approximately a 10% reduction. DeepSMILES had the highest repetition count (902) despite reasonable overall accuracy. SELFIES and <a href="/notes/chemistry/molecular-representations/notations/smiles-pair-encoding/">SmilesPE</a> both performed substantially worse than the atom-wise baseline on this task.</p>
<p>The authors identified six common token repetition patterns in retrosynthetic predictions: long head repetitions, long tail repetitions, repetitive rings, repetitive chains, and halogen repetitions on both aliphatic and aromatic carbons.</p>
<h3 id="molecular-property-prediction">Molecular Property Prediction</h3>
<p>The third task evaluates tokenization schemes on <a href="/notes/chemistry/molecular-design/property-prediction/moleculenet-benchmark-molecular-ml/">MoleculeNet</a> benchmarks using Random Forest models with 5-fold cross-validation. AIS tokens were converted to fingerprint-like feature vectors.</p>
<table>
  <thead>
      <tr>
          <th>Dataset</th>
          <th>SMILES</th>
          <th>DeepSMILES</th>
          <th>SELFIES</th>
          <th>SmilesPE</th>
          <th>AIS</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td><strong>Regression (RMSE, lower is better)</strong></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
      </tr>
      <tr>
          <td>ESOL</td>
          <td>0.628</td>
          <td>0.631</td>
          <td>0.675</td>
          <td>0.689</td>
          <td><strong>0.553</strong></td>
      </tr>
      <tr>
          <td>FreeSolv</td>
          <td>0.545</td>
          <td>0.544</td>
          <td>0.564</td>
          <td>0.761</td>
          <td><strong>0.441</strong></td>
      </tr>
      <tr>
          <td>Lipophilicity</td>
          <td>0.924</td>
          <td>0.895</td>
          <td>0.938</td>
          <td>0.800</td>
          <td><strong>0.683</strong></td>
      </tr>
      <tr>
          <td><strong>Classification (ROC-AUC, higher is better)</strong></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
      </tr>
      <tr>
          <td>BBBP</td>
          <td>0.758</td>
          <td>0.777</td>
          <td>0.799</td>
          <td>0.847</td>
          <td><strong>0.885</strong></td>
      </tr>
      <tr>
          <td>BACE</td>
          <td>0.740</td>
          <td>0.774</td>
          <td>0.746</td>
          <td>0.837</td>
          <td><strong>0.835</strong></td>
      </tr>
      <tr>
          <td>HIV</td>
          <td>0.649</td>
          <td>0.648</td>
          <td>0.653</td>
          <td>0.739</td>
          <td><strong>0.729</strong></td>
      </tr>
  </tbody>
</table>
<p>AIS achieved the best performance on all three regression datasets and two of three classification datasets. On ESOL, the RMSE improvement over standard SMILES was 12%. On lipophilicity, the improvement was 26%.</p>
<h2 id="key-findings-better-tokens-yield-better-chemical-models">Key Findings: Better Tokens Yield Better Chemical Models</h2>
<p>The main findings of this work are:</p>
<ol>
<li>
<p><strong>Tokenization significantly impacts chemical language model quality.</strong> The choice of tokenization scheme can change prediction accuracy by over 10 percentage points on equivalent mapping tasks.</p>
</li>
<li>
<p><strong>AIS reduces token degeneration by approximately 10%</strong> compared to atom-wise SMILES tokenization, with consistently lower normalized repetition rates across diverse molecular datasets.</p>
</li>
<li>
<p><strong>AIS outperforms all compared tokenization schemes</strong> (atom-wise SMILES, SmilesPE, SELFIES, DeepSMILES) on canonicalization, retrosynthesis, and property prediction.</p>
</li>
<li>
<p><strong>The fingerprint-like nature of AIS tokens</strong> enables direct use as molecular features for property prediction and provides resolution comparable to established circular fingerprints.</p>
</li>
<li>
<p><strong>The mapping is invertible</strong>, so AIS strings can always be converted back to valid SMILES. This is a practical advantage over approaches that may lose structural information.</p>
</li>
</ol>
<p><strong>Limitations</strong>: AIS cannot distinguish environmentally identical substructures or atoms related by a molecular symmetry plane, since it only considers nearest-neighbor environments. Performance on long-chain molecules (e.g., lipids) is similar across all tokenization schemes, suggesting that local environment encoding is less informative for repetitive linear structures.</p>
<p><strong>Future directions</strong>: The authors suggest AIS has potential for broader adoption in molecular generative models, chemical translation, and property prediction tasks across the cheminformatics community.</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>Canonicalization training</td>
          <td>GDB-13 subsets</td>
          <td>1M + 150K augmented</td>
          <td>Cumulative structural constraints a-h</td>
      </tr>
      <tr>
          <td>Canonicalization testing</td>
          <td>GDB-13 disjoint test sets</td>
          <td>20K per subset</td>
          <td>Various restriction levels</td>
      </tr>
      <tr>
          <td>Retrosynthesis</td>
          <td>USPTO-50K</td>
          <td>~50K reactions</td>
          <td>Sequences &gt; 150 tokens removed</td>
      </tr>
      <tr>
          <td>Property prediction</td>
          <td>MoleculeNet (ESOL, FreeSolv, Lipophilicity, BBBP, BACE, HIV)</td>
          <td>Varies</td>
          <td>Standard benchmark splits</td>
      </tr>
  </tbody>
</table>
<h3 id="algorithms">Algorithms</h3>
<ul>
<li>Transformer encoder-decoder architecture for canonicalization and retrosynthesis tasks</li>
<li>200,000 training steps with Adam optimizer, negative log-likelihood loss, cyclic learning rate scheduler</li>
<li>Random Forest with 5-fold cross-validation for property prediction</li>
<li>AIS tokenization implemented via RDKit for atom environment extraction</li>
</ul>
<h3 id="evaluation">Evaluation</h3>
<table>
  <thead>
      <tr>
          <th>Metric</th>
          <th>Task</th>
          <th>Notes</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>String exact match (%)</td>
          <td>Canonicalization, Retrosynthesis</td>
          <td>Exact SMILES match</td>
      </tr>
      <tr>
          <td>Tanimoto exactness (Tc)</td>
          <td>Retrosynthesis</td>
          <td>Morgan FP radius 3, 2048 bits</td>
      </tr>
      <tr>
          <td>RMSE</td>
          <td>Regression property prediction</td>
          <td>ESOL, FreeSolv, Lipophilicity</td>
      </tr>
      <tr>
          <td>ROC-AUC</td>
          <td>Classification property prediction</td>
          <td>BBBP, BACE, HIV</td>
      </tr>
      <tr>
          <td>rep-l</td>
          <td>Token degeneration</td>
          <td>Single-token repetition count</td>
      </tr>
  </tbody>
</table>
<h3 id="hardware">Hardware</h3>
<p>Not explicitly specified in the paper.</p>
<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/snu-lcbc/atom-in-SMILES">atom-in-SMILES</a></td>
          <td>Code</td>
          <td>CC-BY-NC-SA-4.0</td>
          <td>AIS tokenization implementation</td>
      </tr>
  </tbody>
</table>
<hr>
<h2 id="paper-information">Paper Information</h2>
<p><strong>Citation</strong>: Ucak, U. V., Ashyrmamatov, I., &amp; Lee, J. (2023). Improving the quality of chemical language model outcomes with atom-in-SMILES tokenization. <em>Journal of Cheminformatics</em>, 15, 55. <a href="https://doi.org/10.1186/s13321-023-00725-9">https://doi.org/10.1186/s13321-023-00725-9</a></p>
<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">@article</span>{ucak2023improving,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">title</span>=<span style="color:#e6db74">{Improving the quality of chemical language model outcomes with atom-in-SMILES tokenization}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">author</span>=<span style="color:#e6db74">{Ucak, Umit V. and Ashyrmamatov, Islambek and Lee, Juyong}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">journal</span>=<span style="color:#e6db74">{Journal of Cheminformatics}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">volume</span>=<span style="color:#e6db74">{15}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">number</span>=<span style="color:#e6db74">{1}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">pages</span>=<span style="color:#e6db74">{55}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">year</span>=<span style="color:#e6db74">{2023}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">publisher</span>=<span style="color:#e6db74">{Springer}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">doi</span>=<span style="color:#e6db74">{10.1186/s13321-023-00725-9}</span>
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div>]]></content:encoded></item><item><title>Review of Molecular Representation Learning Models</title><link>https://hunterheidenreich.com/notes/chemistry/molecular-representations/notations/molecular-representation-learning-foundation-models-review/</link><pubDate>Wed, 25 Mar 2026 00:00:00 +0000</pubDate><guid>https://hunterheidenreich.com/notes/chemistry/molecular-representations/notations/molecular-representation-learning-foundation-models-review/</guid><description>A systematic review of molecular representation learning foundation models for drug discovery, covering five modalities and four pretraining strategies.</description><content:encoded><![CDATA[<h2 id="a-systematization-of-molecular-representation-foundation-models">A Systematization of Molecular Representation Foundation Models</h2>
<p>This paper is a <strong>Systematization</strong> that provides the first comprehensive review of foundation models for molecular representation learning (MRL). The authors classify existing models by their input modality (unimodal vs. multimodal), analyze four mainstream pretraining strategies, survey five downstream application domains, and propose practical guidelines for model selection. The review covers over 35 representative models published between 2020 and 2024, with parameter counts ranging from 2 million to over 1 trillion.</p>
<h2 id="why-a-systematic-review-of-mrl-foundation-models-is-needed">Why a Systematic Review of MRL Foundation Models Is Needed</h2>
<p>Molecular representation learning transforms molecular structures and properties into numerical vectors that serve as inputs for machine learning models. The field has evolved rapidly from molecular fingerprints through SMILES-based sequence models to graph neural networks and 3D geometry-aware architectures. Foundation models, characterized by large-scale pretraining on unlabeled molecular data followed by fine-tuning on downstream tasks, have introduced new opportunities for generalizability and transfer learning in drug discovery.</p>
<p>Despite this rapid progress, the authors identify a gap: no prior work has systematically reviewed MRL foundation models across all input modalities and pretraining paradigms. Existing surveys tend to focus on specific representations (e.g., graph-based methods) or specific applications (e.g., property prediction) without providing the cross-cutting perspective needed to guide model selection. This review fills that gap by offering a unified taxonomy and practical guidelines.</p>
<h2 id="taxonomy-of-molecular-descriptors-and-model-architectures">Taxonomy of Molecular Descriptors and Model Architectures</h2>
<p>The core organizational framework classifies models along two axes: the molecular descriptor used as input and the backbone architecture.</p>
<h3 id="molecular-descriptors">Molecular Descriptors</h3>
<p>The review identifies five primary descriptor types:</p>
<ol>
<li><strong>Molecular fingerprints</strong>: Binary vectors encoding structural features (e.g., Morgan fingerprints). Rarely used in foundation models due to information loss and dimensional complexity.</li>
<li><strong>1D sequences</strong>: <a href="/notes/chemistry/molecular-representations/notations/smiles/">SMILES</a> and <a href="/notes/chemistry/molecular-representations/notations/selfies/">SELFIES</a> string representations. SMILES is compact and widely used but can produce invalid molecules. SELFIES guarantees valid molecular strings by construction.</li>
<li><strong>2D topological graphs</strong>: Atoms as nodes, bonds as edges. Can be derived from SMILES via <a href="https://en.wikipedia.org/wiki/RDKit">RDKit</a>, making graph datasets effectively interchangeable with SMILES datasets.</li>
<li><strong>3D geometry</strong>: Spatial coordinates capturing conformational information, energy states, and stereochemistry. Experimentally expensive to obtain, limiting dataset availability.</li>
<li><strong>Multimodal</strong>: Combinations of the above with text, IUPAC names, knowledge graphs, and molecular images.</li>
</ol>
<p>The paper also discusses mathematically abstract molecular representations. For example, the <a href="https://en.wikipedia.org/wiki/Wiener_index">Wiener index</a> quantifies structural complexity:</p>
<p>$$
W = \frac{1}{2} \sum_{i &lt; j} d_{ij}
$$</p>
<p>where $d_{ij}$ is the topological distance (shortest bonding path length) between atoms $i$ and $j$.</p>
<p>Degree centrality captures local connectivity:</p>
<p>$$
C_{D}(v_{i}) = \sum_{j=1}^{n} A_{ij}
$$</p>
<p>where $A \in \mathbb{R}^{n \times n}$ is the molecular graph adjacency matrix.</p>
<h3 id="model-architectures">Model Architectures</h3>
<p>Models are classified into two primary categories:</p>
<p><strong>Unimodal-based models:</strong></p>
<ul>
<li><strong>Sequence-based</strong>: Transformer models operating on SMILES/SELFIES (e.g., <a href="/notes/chemistry/molecular-representations/encoders/chemberta-2/">ChemBERTa-2</a>, <a href="/notes/chemistry/molecular-representations/encoders/molformer/">MoLFormer</a>, MolGEN, <a href="/notes/chemistry/llm-applications/llamsmol-instruction-tuning-chemistry/">LlaSMol</a>). These capture syntactic patterns but miss spatial and topological features.</li>
<li><strong>Topological graph-based</strong>: GNN variants (GIN, GCN, GAT) and Transformer-based graph models (Graphormer). GNNs capture local topology through message passing; Transformers overcome locality limitations through global self-attention.</li>
<li><strong>3D geometry-based</strong>: Models like Uni-Mol and 3D PGT that incorporate spatial coordinates. Uni-Mol uses distance-aware self-attention with an SE(3)-equivariant coordinate head for rotation/translation invariance.</li>
<li><strong>Image-based</strong>: CNN-based models (ImageMol) that process 2D molecular images using visual representation learning.</li>
</ul>
<p><strong>Multimodal-based models:</strong></p>
<ul>
<li><strong>Sequence + Graph</strong>: <a href="/notes/chemistry/molecular-representations/multimodal/dual-view-molecule-pretraining/">DVMP</a>, PanGu Drug Model. Combines the strengths of string and topological representations.</li>
<li><strong>Graph + 3D Geometry</strong>: GraphMVP, Transformer-M. Enriches topological features with spatial information.</li>
<li><strong>Text + Molecular Structure</strong>: KV-PLM, MolT5, MoleculeSTM, MolReGPT, Y-mol. Aligns molecular structural information with biomedical text through cross-modal learning.</li>
</ul>
<h2 id="four-pretraining-paradigms-for-mrl">Four Pretraining Paradigms for MRL</h2>
<p>The review systematically categorizes pretraining strategies into four paradigms:</p>
<h3 id="masked-language-modeling-mlm">Masked Language Modeling (MLM)</h3>
<p>The cornerstone strategy for sequence-based models. Randomly masks tokens in molecular sequences and trains the model to predict them. ChemBERTa pretrained on 77 million SMILES sequences from PubChem achieves 5-10% improvement in AUC-ROC on property prediction tasks compared to task-specific models. MLM captures local dependencies and global sequence patterns but cannot model spatial or topological features, making it best suited for unimodal sequence inputs.</p>
<h3 id="contrastive-learning-cl">Contrastive Learning (CL)</h3>
<p>The dominant strategy for multimodal models. Constructs positive-negative sample pairs to align features across modalities or views. In unimodal settings, CL generates negative samples by perturbing molecular graphs. In multimodal settings, it aligns features from different modalities. GraphMVP, which contrasts 2D topological features with 3D spatial features, reduces RMSE by 15% on QM9 energy prediction compared to unimodal models. Performance depends heavily on the quality of positive sample construction.</p>
<h3 id="reconstruction-based-pretraining-rbp">Reconstruction-Based Pretraining (RBP)</h3>
<p>Learns global molecular features by reconstructing original data from corrupted inputs. Tasks include node feature reconstruction, graph structure reconstruction, and coordinate/energy reconstruction. MGMAE masks more than 50% of nodes and edges in molecular graphs and trains the model to reconstruct them, achieving 94.2% AUC-ROC on BBBP. RBP captures global structural patterns but requires high model complexity and training cost.</p>
<h3 id="multimodal-alignment-pretraining-map">Multimodal Alignment Pretraining (MAP)</h3>
<p>Designed for multimodal inputs, aligning and fusing features from different modalities through cross-modal tasks. KV-PLM uses SMILES-to-text matching to align molecular structure and functional information. MAP fuses structural information (SMILES, graphs) with semantic information (text) but requires large-scale cross-modal labeled data, posing significant data acquisition challenges.</p>
<h2 id="downstream-applications-and-performance-benchmarks">Downstream Applications and Performance Benchmarks</h2>
<p>The review evaluates MRL foundation models across five application domains.</p>
<h3 id="molecular-property-prediction">Molecular Property Prediction</h3>
<p>The most common benchmark for MRL models. The review provides comprehensive ROC-AUC comparisons across eight <a href="/notes/chemistry/molecular-design/property-prediction/moleculenet-benchmark-molecular-ml/">MoleculeNet</a> classification datasets:</p>
<table>
  <thead>
      <tr>
          <th>Model</th>
          <th>Type</th>
          <th>BBBP</th>
          <th>BACE</th>
          <th>ClinTox</th>
          <th>Tox21</th>
          <th>SIDER</th>
          <th>HIV</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>MGMAE</td>
          <td>Graph</td>
          <td>94.2</td>
          <td>92.7</td>
          <td>96.7</td>
          <td>86.0</td>
          <td>66.4</td>
          <td>-</td>
      </tr>
      <tr>
          <td>MPG</td>
          <td>Graph</td>
          <td>92.2</td>
          <td>92.0</td>
          <td>96.3</td>
          <td>83.7</td>
          <td>66.1</td>
          <td>-</td>
      </tr>
      <tr>
          <td>GROVER</td>
          <td>Graph+Trans.</td>
          <td>94.0</td>
          <td>89.4</td>
          <td>94.4</td>
          <td>83.1</td>
          <td>65.8</td>
          <td>-</td>
      </tr>
      <tr>
          <td>MoLFormer</td>
          <td>Sequence</td>
          <td>93.7</td>
          <td>88.2</td>
          <td>94.8</td>
          <td>84.7</td>
          <td>69.0</td>
          <td>82.2</td>
      </tr>
      <tr>
          <td>MM-Deacon</td>
          <td>Seq.+IUPAC</td>
          <td>78.5</td>
          <td>-</td>
          <td>99.5</td>
          <td>-</td>
          <td>69.3</td>
          <td>80.1</td>
      </tr>
      <tr>
          <td>Uni-Mol</td>
          <td>3D</td>
          <td>72.9</td>
          <td>85.7</td>
          <td>91.9</td>
          <td>79.6</td>
          <td>65.9</td>
          <td>80.8</td>
      </tr>
      <tr>
          <td>DVMP</td>
          <td>Seq.+Graph</td>
          <td>77.8</td>
          <td>89.4</td>
          <td>95.6</td>
          <td>79.1</td>
          <td>69.8</td>
          <td>81.4</td>
      </tr>
      <tr>
          <td>TxD-T-LLM</td>
          <td>Seq.+Text</td>
          <td>-</td>
          <td>-</td>
          <td>86.3</td>
          <td>88.2</td>
          <td>-</td>
          <td>73.2</td>
      </tr>
  </tbody>
</table>
<p>The table shows that no single architecture dominates across all datasets. Transformer- and GIN-based architectures with graph inputs generally perform well. The review notes that model effectiveness depends heavily on the dataset, with Mole-BERT encountering negative transfer due to a small and unbalanced atomic vocabulary.</p>
<h3 id="molecular-generation">Molecular Generation</h3>
<p>MolGEN (SELFIES-based, 8B parameters) achieves 100% validity on synthetic molecules. MolT5 excels at text-to-molecule generation. Uni-Mol generates 3D conformations with 97.95% coverage on QM9.</p>
<h3 id="drug-drug-interaction-prediction"><a href="https://en.wikipedia.org/wiki/Drug_interaction">Drug-Drug Interaction</a> Prediction</h3>
<p>MPG achieves 96.6% AUC-ROC on BIOSNAP by combining unsupervised pretraining with supervised fine-tuning and multi-task learning.</p>
<h3 id="retrosynthesis-prediction"><a href="https://en.wikipedia.org/wiki/Retrosynthetic_analysis">Retrosynthesis</a> Prediction</h3>
<p>DVMP achieves 66.5% top-1 accuracy on USPTO-50K when reaction types are provided as priors (54.2% without).</p>
<h3 id="drug-synergy-prediction">Drug Synergy Prediction</h3>
<p>SynerGPT (GPT-based) achieves 77.7% AUC-ROC in few-shot settings for novel drug combinations, outperforming baselines through contextual learning.</p>
<h2 id="guidelines-limitations-and-future-directions">Guidelines, Limitations, and Future Directions</h2>
<h3 id="model-selection-guidelines">Model Selection Guidelines</h3>
<p>The authors provide structured guidelines for choosing MRL foundation models based on:</p>
<ol>
<li><strong>Task objective</strong>: Property prediction favors GNNs or large pretrained frameworks (ChemBERTa-2, Uni-Mol). Generation tasks favor GPT-style autoregressive models (MolGEN). Retrosynthesis benefits from multimodal architectures.</li>
<li><strong>Data characteristics</strong>: SMILES/graph representations suit generation tasks. Knowledge graph-enhanced models benefit interaction and synergy prediction. Transfer learning helps data-limited scenarios.</li>
<li><strong>Interpretability needs</strong>: Transformer architectures are preferred when interpretability is required, as attention matrices enable visualization of learned molecular features.</li>
<li><strong>Computational budget</strong>: GIN-based models have $\mathcal{O}(|V| + |E|)$ complexity, while Transformer-based models scale as $\mathcal{O}(n^2 \cdot d)$.</li>
</ol>
<h3 id="limitations-and-future-directions">Limitations and Future Directions</h3>
<p>The review identifies five key challenges:</p>
<ol>
<li><strong>Multimodal data integration</strong>: Each representation paradigm has distinct limitations (1D neglects spatial configuration, 2D omits conformational details, 3D faces rotational invariance challenges). The authors propose incorporating <a href="/notes/chemistry/molecular-simulation/">molecular dynamics</a> trajectories as a dynamic modality and using cross-modal data augmentation.</li>
<li><strong>Data scarcity</strong>: Semi-supervised learning can achieve more than 90% of fully supervised performance using only 10% labeled data on QM9. Cross-modal augmentation (e.g., 3D InfoMax) can generate plausible 3D conformers from 2D graphs.</li>
<li><strong>Interpretability</strong>: Current methods rely primarily on attention-based visualization, which is insufficient for multimodal models. The authors suggest assessing decision consistency across modalities and incorporating chemical knowledge graphs.</li>
<li><strong>Training efficiency</strong>: Large parameter counts demand distributed parallel training techniques, with data parallelism being the most common approach.</li>
<li><strong>Robustness and generalization</strong>: Strategies include data augmentation (multiple SMILES representations, 3D conformer generation), meta-learning for rapid adaptation, and sparse attention mechanisms to reduce sensitivity to irrelevant long-range interactions.</li>
</ol>
<hr>
<h2 id="reproducibility-details">Reproducibility Details</h2>
<p>This is a review paper, so standard reproducibility criteria for experimental papers do not directly apply. The review compiles results from the original publications of each surveyed model.</p>
<h3 id="data">Data</h3>
<p>The review catalogs 28 representative molecular datasets used by the surveyed foundation models:</p>
<table>
  <thead>
      <tr>
          <th>Dataset</th>
          <th>Size</th>
          <th>Descriptor</th>
          <th>Primary Use</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>PubChem</td>
          <td>~118M</td>
          <td>SMILES, 3D, Image, IUPAC</td>
          <td>Pretraining</td>
      </tr>
      <tr>
          <td>ZINC15</td>
          <td>~980M</td>
          <td>SMILES</td>
          <td>Pretraining</td>
      </tr>
      <tr>
          <td>ChEMBL</td>
          <td>~2.4M</td>
          <td>SMILES</td>
          <td>Pretraining</td>
      </tr>
      <tr>
          <td>QM9</td>
          <td>133,884</td>
          <td>SMILES</td>
          <td>Property prediction</td>
      </tr>
      <tr>
          <td><a href="/notes/chemistry/datasets/geom/">GEOM</a></td>
          <td>450,000</td>
          <td>3D coordinates</td>
          <td>Property prediction</td>
      </tr>
      <tr>
          <td>USPTO-full</td>
          <td>950,000</td>
          <td>SMILES</td>
          <td>Reaction prediction</td>
      </tr>
      <tr>
          <td>Molecule3D</td>
          <td>4M</td>
          <td>3D coordinates</td>
          <td>Property prediction</td>
      </tr>
  </tbody>
</table>
<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/Z-dot-max/MRL_Foundation_Review">Review Materials (GitHub)</a></td>
          <td>Code/Data</td>
          <td>Not specified</td>
          <td>Code and data tables for figures</td>
      </tr>
      <tr>
          <td><a href="https://pmc.ncbi.nlm.nih.gov/articles/PMC12784970/">Paper (PMC)</a></td>
          <td>Paper</td>
          <td>CC-BY</td>
          <td>Open access via PubMed Central</td>
      </tr>
  </tbody>
</table>
<h3 id="evaluation">Evaluation</h3>
<p>All performance metrics reported in the review are directly cited from the original studies. The evaluation protocols follow each model&rsquo;s original setup. The review covers:</p>
<ul>
<li>ROC-AUC for classification tasks (property prediction, DDI, synergy)</li>
<li>RMSE/MAE for regression tasks</li>
<li>Validity and novelty for molecular generation</li>
<li>Top-k accuracy for retrosynthesis</li>
<li>COV and MAT for conformation generation</li>
</ul>
<hr>
<h2 id="paper-information">Paper Information</h2>
<p><strong>Citation</strong>: Song, B., Zhang, J., Liu, Y., Liu, Y., Jiang, J., Yuan, S., Zhen, X., &amp; Liu, Y. (2025). A systematic review of molecular representation learning foundation models. <em>Briefings in Bioinformatics</em>, 27(1), bbaf703. <a href="https://doi.org/10.1093/bib/bbaf703">https://doi.org/10.1093/bib/bbaf703</a></p>
<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">@article</span>{song2025systematic,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">title</span>=<span style="color:#e6db74">{A systematic review of molecular representation learning foundation models}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">author</span>=<span style="color:#e6db74">{Song, Bosheng and Zhang, Jiayi and Liu, Ying and Liu, Yuansheng and Jiang, Jing and Yuan, Sisi and Zhen, Xia and Liu, Yiping}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">journal</span>=<span style="color:#e6db74">{Briefings in Bioinformatics}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">volume</span>=<span style="color:#e6db74">{27}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">number</span>=<span style="color:#e6db74">{1}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">pages</span>=<span style="color:#e6db74">{bbaf703}</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">publisher</span>=<span style="color:#e6db74">{Oxford University Press}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">doi</span>=<span style="color:#e6db74">{10.1093/bib/bbaf703}</span>
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div>]]></content:encoded></item><item><title>AMORE: Testing ChemLLM Robustness to SMILES Variants</title><link>https://hunterheidenreich.com/notes/chemistry/molecular-representations/encoders/amore-smiles-robustness-framework/</link><pubDate>Wed, 25 Mar 2026 00:00:00 +0000</pubDate><guid>https://hunterheidenreich.com/notes/chemistry/molecular-representations/encoders/amore-smiles-robustness-framework/</guid><description>AMORE is a zero-shot framework testing whether chemical language models recognize equivalent SMILES of the same molecule via embedding retrieval.</description><content:encoded><![CDATA[<h2 id="an-empirical-framework-for-probing-chemical-understanding">An Empirical Framework for Probing Chemical Understanding</h2>
<p>This is an <strong>Empirical</strong> paper that introduces Augmented Molecular Retrieval (AMORE), a zero-shot evaluation framework for chemical language models (ChemLMs). The primary contribution is a method to assess whether ChemLMs have learned genuine molecular semantics or simply memorize textual patterns. Rather than relying on traditional NLP metrics like BLEU and ROUGE, AMORE tests whether a model&rsquo;s embedding space treats chemically equivalent <a href="/notes/chemistry/molecular-representations/notations/smiles/">SMILES</a> representations as similar. The authors evaluate 12 models across multiple architectures (encoder-only, encoder-decoder, decoder-only) on two datasets and five augmentation types, and extend the analysis to downstream MoleculeNet tasks.</p>
<h2 id="why-standard-nlp-metrics-fail-for-chemical-evaluation">Why Standard NLP Metrics Fail for Chemical Evaluation</h2>
<p>Chemical language models are typically evaluated using text-based metrics from NLP (BLEU, ROUGE, METEOR) on tasks like molecule captioning. These metrics compare word overlap and sentence fluency but cannot detect whether a model truly understands molecular structure. A SMILES string like <code>C(=O)O</code> and its canonicalized or kekulized form represent the same molecule, yet text-based metrics would penalize valid reformulations. Embedding-based metrics like BERTScore are also insufficient because they were trained on general text, not chemical notation.</p>
<p>The core research question is direct: do evaluation metrics used on ChemLMs reflect actual chemical knowledge, or do the models simply imitate understanding by learning textual features? This question has practical consequences in pharmaceuticals and healthcare, where missteps in chemical reasoning carry serious risks.</p>
<h2 id="embedding-based-retrieval-as-a-chemical-litmus-test">Embedding-Based Retrieval as a Chemical Litmus Test</h2>
<p>AMORE exploits a fundamental property of molecular representations: a single molecule can be written as multiple valid SMILES strings that are chemically identical. These serve as &ldquo;total synonyms,&rdquo; a concept without a true analogue in natural language.</p>
<p>The framework works in four steps:</p>
<ol>
<li>Take a set $X = (x_1, x_2, \ldots, x_n)$ of $n$ molecular representations.</li>
<li>Apply a transformation $f$ to obtain augmented representations $X&rsquo; = (x&rsquo;_1, x&rsquo;_2, \ldots, x&rsquo;_n)$, where $x&rsquo;_i = f(x_i)$. The constraint is that $f$ must not change the underlying molecule.</li>
<li>Obtain vectorized embeddings $e(x_i)$ and $e(x&rsquo;_j)$ from the model for each original and augmented SMILES.</li>
<li>Evaluate in a retrieval task: given $e(x_i)$, retrieve $e(x&rsquo;_i)$ from the augmented set.</li>
</ol>
<p>The evaluation metrics are top-$k$ accuracy (whether the correct augmented SMILES ranks at position $\leq k$) and <a href="https://en.wikipedia.org/wiki/Mean_reciprocal_rank">Mean Reciprocal Rank</a> (MRR). Retrieval uses <a href="https://en.wikipedia.org/wiki/FAISS">FAISS</a> for efficient nearest-neighbor search. The key insight is that if a model truly understands molecular structure, it should embed different SMILES representations of the same molecule close together.</p>
<h3 id="five-smiles-augmentation-types">Five SMILES Augmentation Types</h3>
<p>The framework uses five identity-preserving augmentations, all executed through <a href="https://en.wikipedia.org/wiki/RDKit">RDKit</a>:</p>
<ol>
<li><strong>Canonicalization</strong>: Transform SMILES to the standardized RDKit canonical form.</li>
<li><strong>Hydrogen addition</strong>: Explicitly add hydrogen atoms that are normally implied (e.g., <code>C</code> becomes <code>[CH4]</code>). This dramatically increases string length.</li>
<li><strong>Kekulization</strong>: Convert aromatic ring notation to explicit alternating double bonds.</li>
<li><strong>Cycle renumbering</strong>: Replace ring-closure digit identifiers with random valid alternatives.</li>
<li><strong>Random atom order</strong>: Randomize the atom traversal order used to generate the SMILES string.</li>
</ol>
<h2 id="twelve-models-two-datasets-five-augmentations">Twelve Models, Two Datasets, Five Augmentations</h2>
<h3 id="models-evaluated">Models Evaluated</h3>
<p>The authors test 12 publicly available Transformer-based models spanning three architecture families:</p>
<table>
  <thead>
      <tr>
          <th>Model</th>
          <th>Domain</th>
          <th>Parameters</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>Text+Chem T5-standard</td>
          <td>Cross-modal</td>
          <td>220M</td>
      </tr>
      <tr>
          <td>Text+Chem T5-augm</td>
          <td>Cross-modal</td>
          <td>220M</td>
      </tr>
      <tr>
          <td>MolT5-base</td>
          <td>Cross-modal</td>
          <td>220M</td>
      </tr>
      <tr>
          <td>MolT5-large</td>
          <td>Cross-modal</td>
          <td>770M</td>
      </tr>
      <tr>
          <td>SciFive</td>
          <td>Text-only</td>
          <td>220M</td>
      </tr>
      <tr>
          <td>PubChemDeBERTa</td>
          <td>Chemical</td>
          <td>86M</td>
      </tr>
      <tr>
          <td>ChemBERT-ChEMBL</td>
          <td>Chemical</td>
          <td>6M</td>
      </tr>
      <tr>
          <td><a href="/notes/chemistry/molecular-representations/encoders/chemberta/">ChemBERTa</a></td>
          <td>Chemical</td>
          <td>125M</td>
      </tr>
      <tr>
          <td><a href="/notes/chemistry/molecular-representations/encoders/bartsmiles-molecular-representations/">BARTSmiles</a></td>
          <td>Chemical</td>
          <td>400M</td>
      </tr>
      <tr>
          <td>ZINC-RoBERTa</td>
          <td>Chemical</td>
          <td>102M</td>
      </tr>
      <tr>
          <td><a href="/notes/chemistry/molecular-representations/multimodal/nach0-multimodal-chemical-language-model/">nach0</a></td>
          <td>Chemical</td>
          <td>220M</td>
      </tr>
      <tr>
          <td>ZINC-GPT</td>
          <td>Chemical</td>
          <td>87M</td>
      </tr>
  </tbody>
</table>
<h3 id="datasets">Datasets</h3>
<ul>
<li><strong>ChEBI-20 test set</strong>: ~3,300 molecule-description pairs, used for both AMORE retrieval and molecule captioning comparisons.</li>
<li><strong>Isomers</strong> (QM9 subset): 918 molecules that are all isomers of C9H12N2O, making retrieval harder because all molecules share the same molecular formula.</li>
</ul>
<h3 id="key-results-on-chebi-20">Key Results on ChEBI-20</h3>
<p>On the ChEBI-20 dataset (Table 2 from the paper), top-1 accuracy varies enormously by augmentation type. Cycle renumbering is easiest (up to 98.48% Acc@1 for SciFive), while hydrogen addition is hardest (no model exceeds 5.97% Acc@1).</p>
<p>For the cross-modal Text+Chem T5-standard model:</p>
<table>
  <thead>
      <tr>
          <th>Augmentation</th>
          <th>Acc@1</th>
          <th>Acc@5</th>
          <th>MRR</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>Canonical</td>
          <td>63.03</td>
          <td>82.76</td>
          <td>72.4</td>
      </tr>
      <tr>
          <td>Hydrogen</td>
          <td>5.46</td>
          <td>10.85</td>
          <td>8.6</td>
      </tr>
      <tr>
          <td>Kekulization</td>
          <td>76.76</td>
          <td>92.03</td>
          <td>83.8</td>
      </tr>
      <tr>
          <td>Cycle</td>
          <td>96.70</td>
          <td>99.82</td>
          <td>98.2</td>
      </tr>
      <tr>
          <td>Random</td>
          <td>46.94</td>
          <td>74.18</td>
          <td>59.33</td>
      </tr>
  </tbody>
</table>
<h3 id="key-results-on-isomers">Key Results on Isomers</h3>
<p>Performance drops substantially on the Isomers dataset, where all molecules share the same formula. The best Acc@1 for hydrogen augmentation is just 1.53% (MolT5-large). Even for the relatively easy cycle augmentation, top scores drop from the high 90s to the low 90s for most models, and some models (BARTSmiles: 41.83%) struggle considerably.</p>
<h3 id="downstream-moleculenet-impact">Downstream MoleculeNet Impact</h3>
<p>The authors also fine-tuned models on original <a href="/notes/chemistry/molecular-design/property-prediction/moleculenet-benchmark-molecular-ml/">MoleculeNet</a> training data and tested on augmented test sets across 9 tasks (regression, binary classification, multilabel classification). Results confirm that augmentations degrade downstream performance. For example, on ESOL regression, RMSE increased from 0.87 to 7.93 with hydrogen addition. Rankings computed using the Vote&rsquo;n&rsquo;Rank framework (using the <a href="https://en.wikipedia.org/wiki/Copeland%27s_method">Copeland rule</a>) show that hydrogen augmentation is the only one that substantially reshuffles model rankings; other augmentations preserve the original ordering.</p>
<h3 id="correlation-between-amore-and-captioning-metrics">Correlation Between AMORE and Captioning Metrics</h3>
<p>The differences in ROUGE/METEOR between original and augmented SMILES correlate with AMORE retrieval accuracy (Spearman correlation &gt; 0.7 with p-value = 0.003 for Acc@1). This validates AMORE as a proxy for predicting how augmentations will affect generation quality, without requiring labeled captioning data.</p>
<h2 id="current-chemlms-learn-syntax-not-chemistry">Current ChemLMs Learn Syntax, Not Chemistry</h2>
<p>The central finding is that existing ChemLMs are not robust to identity-preserving SMILES augmentations. Several specific conclusions emerge:</p>
<ol>
<li>
<p><strong>Hydrogen augmentation is catastrophic</strong>: All models fail (&lt; 6% Acc@1 on ChEBI-20, &lt; 2% on Isomers). The authors attribute this to the near-complete absence of explicit hydrogen in pretraining data, creating a distribution shift.</p>
</li>
<li>
<p><strong>Cross-modal models outperform unimodal ones</strong>: Models trained on both text and SMILES (Text+Chem T5, MolT5) consistently achieve higher retrieval accuracy on four of five augmentations.</p>
</li>
<li>
<p><strong>Augmentation difficulty follows a consistent order</strong>: For all models, hydrogen is hardest, followed by canonicalization, random ordering, kekulization, and cycle renumbering (easiest).</p>
</li>
<li>
<p><strong>Layer-wise analysis reveals instability</strong>: Retrieval accuracy across Transformer layers is correlated across augmentation types, suggesting that representations degrade at the same layers regardless of augmentation.</p>
</li>
<li>
<p><strong><a href="https://en.wikipedia.org/wiki/Levenshtein_distance">Levenshtein distance</a> partially explains difficulty</strong>: Hydrogen augmentation produces strings ~2x longer than originals (Levenshtein ratio of 1.49), but the low correlation between Levenshtein ratio and downstream metrics (ROUGE1 correlation of -0.05 for hydrogen) suggests string length alone does not explain the failure.</p>
</li>
</ol>
<h3 id="limitations">Limitations</h3>
<p>The authors acknowledge several limitations. Only publicly available HuggingFace models were evaluated, excluding models like <a href="/notes/chemistry/molecular-design/generation/autoregressive/chemformer/">Chemformer</a> and <a href="/notes/chemistry/molecular-representations/encoders/molformer/">Molformer</a> that lack HF checkpoints. The study focuses exclusively on SMILES sequences, not 3D molecular structures or other formats like <a href="/notes/chemistry/molecular-representations/notations/selfies/">SELFIES</a>. The augmentation types, while representative, do not cover all possible identity transformations.</p>
<p>The authors suggest that AMORE could serve as a regularization tool during training, for example by using metric learning to encourage models to embed SMILES variants of the same molecule close together.</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>Retrieval evaluation</td>
          <td>ChEBI-20 test set</td>
          <td>3,300 molecules</td>
          <td>Standard benchmark for molecule captioning</td>
      </tr>
      <tr>
          <td>Retrieval evaluation</td>
          <td>Isomers (QM9 subset)</td>
          <td>918 molecules</td>
          <td>All isomers of C9H12N2O</td>
      </tr>
      <tr>
          <td>Downstream evaluation</td>
          <td>MoleculeNet (9 tasks)</td>
          <td>Varies</td>
          <td>ESOL, Lipophilicity, FreeSolv, HIV, BBBP, BACE, Tox21, ToxCast, SIDER</td>
      </tr>
  </tbody>
</table>
<h3 id="algorithms">Algorithms</h3>
<ul>
<li>SMILES augmentations via RDKit (canonicalization, hydrogen addition, kekulization, cycle renumbering, random atom ordering)</li>
<li>Nearest-neighbor retrieval using FAISS with L2, cosine, inner product, and HNSW metrics</li>
<li>Model ranking via Vote&rsquo;n&rsquo;Rank (Copeland rule) on MoleculeNet tasks</li>
</ul>
<h3 id="models">Models</h3>
<p>All 12 evaluated models are publicly available on HuggingFace. No custom model training was performed for the AMORE retrieval experiments. MoleculeNet experiments used standard fine-tuning on original training splits.</p>
<h3 id="evaluation">Evaluation</h3>
<table>
  <thead>
      <tr>
          <th>Metric</th>
          <th>Description</th>
          <th>Notes</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>Acc@1</td>
          <td>Top-1 retrieval accuracy</td>
          <td>Primary AMORE metric</td>
      </tr>
      <tr>
          <td>Acc@5</td>
          <td>Top-5 retrieval accuracy</td>
          <td>Secondary AMORE metric</td>
      </tr>
      <tr>
          <td>MRR</td>
          <td>Mean Reciprocal Rank</td>
          <td>Average rank of correct match</td>
      </tr>
      <tr>
          <td>ROUGE-2</td>
          <td>Bigram overlap for captioning</td>
          <td>Compared against AMORE</td>
      </tr>
      <tr>
          <td>METEOR</td>
          <td>MT evaluation metric for captioning</td>
          <td>Compared against AMORE</td>
      </tr>
  </tbody>
</table>
<h3 id="hardware">Hardware</h3>
<p>Computational resources from HPC facilities at HSE University. Specific GPU types and training times are not reported.</p>
<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/ChemistryLLMs/AMORE">AMORE GitHub</a></td>
          <td>Code</td>
          <td>Not specified</td>
          <td>Framework code and evaluation data</td>
      </tr>
  </tbody>
</table>
<hr>
<h2 id="paper-information">Paper Information</h2>
<p><strong>Citation</strong>: Ganeeva, V., Khrabrov, K., Kadurin, A., &amp; Tutubalina, E. (2025). Measuring Chemical LLM robustness to molecular representations: a SMILES variation-based framework. <em>Journal of Cheminformatics</em>, 17(1). <a href="https://doi.org/10.1186/s13321-025-01079-0">https://doi.org/10.1186/s13321-025-01079-0</a></p>
<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">@article</span>{ganeeva2025measuring,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">title</span>=<span style="color:#e6db74">{Measuring Chemical LLM robustness to molecular representations: a SMILES variation-based framework}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">author</span>=<span style="color:#e6db74">{Ganeeva, Veronika and Khrabrov, Kuzma and Kadurin, Artur and Tutubalina, Elena}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">journal</span>=<span style="color:#e6db74">{Journal of Cheminformatics}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">volume</span>=<span style="color:#e6db74">{17}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">number</span>=<span style="color:#e6db74">{1}</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">publisher</span>=<span style="color:#e6db74">{Springer}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">doi</span>=<span style="color:#e6db74">{10.1186/s13321-025-01079-0}</span>
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div>]]></content:encoded></item><item><title>Neural Scaling of Deep Chemical Models</title><link>https://hunterheidenreich.com/notes/chemistry/molecular-representations/encoders/neural-scaling-of-deep-chemical-models/</link><pubDate>Tue, 24 Mar 2026 00:00:00 +0000</pubDate><guid>https://hunterheidenreich.com/notes/chemistry/molecular-representations/encoders/neural-scaling-of-deep-chemical-models/</guid><description>Frey et al. discover neural scaling laws for chemical LLMs and GNN interatomic potentials, showing power-law loss improvements with scale.</description><content:encoded><![CDATA[<h2 id="what-kind-of-paper-is-this">What kind of paper is this?</h2>
<p>This is a <strong>discovery paper</strong> that identifies empirical neural scaling laws in two distinct domains of chemical deep learning: large language models (LLMs) for generative chemistry and graph neural networks (GNNs) for machine-learned interatomic potentials. The paper also introduces training performance estimation (TPE) as a practical tool for accelerating hyperparameter optimization in these domains.</p>
<h2 id="why-scaling-laws-matter-for-chemistry">Why scaling laws matter for chemistry</h2>
<p>Neural scaling laws, first characterized for NLP models by Kaplan et al. (2020), describe how model loss decreases as a power law with increasing model size, dataset size, or compute:</p>
<p>$$
L(R) = \alpha R^{-\beta}
$$</p>
<p>where $\alpha$ is a coefficient, $\beta$ is the scaling exponent, and $R$ is the resource being scaled (parameters, data, or compute). These relationships have guided resource allocation decisions in NLP and computer vision, but their applicability to scientific deep learning was unknown.</p>
<p>Chemical deep learning differs from standard NLP and vision tasks in several key ways. Physics-based priors (like symmetry constraints) may reduce the need for massive scale. The heterogeneity of chemical space and molecular tasks makes general pre-training more challenging. There are no established default architectures, datasets, or training recipes at large scale for chemistry.</p>
<p>This paper asks: do the same scaling behaviors hold for chemical models, and how do physical priors affect them?</p>
<h2 id="training-performance-estimation-for-efficient-scaling">Training performance estimation for efficient scaling</h2>
<p>Before running expensive scaling experiments, the authors needed a way to efficiently select hyperparameters. They introduced TPE, a generalization of training speed estimation (TSE) to new domains. TSE computes the cumulative training loss over the first $T$ epochs:</p>
<p>$$
\text{TSE} = \sum_{t=1}^{T} \left( \frac{1}{B} \sum_{i=1}^{B} \mathcal{L}\left(f_{\theta(t,i)}(\mathbf{X}_i), \mathbf{y}_i\right) \right)
$$</p>
<p>where $B$ is the number of training steps per epoch, $\mathcal{L}$ is the loss function, and $f_{\theta(t,i)}$ is the network at epoch $t$ and mini-batch $i$. A linear regression then predicts converged loss from early-training TSE:</p>
<p>$$
L = m \times \text{TSE} + b
$$</p>
<p>Using only 20% of the total training budget, TPE achieves $R^2 = 0.98$ and Spearman&rsquo;s $\rho = 1.0$ for ChemGPT on the MOSES dataset. For GNNs, it achieves $R^2 \geq 0.86$ and $\rho \geq 0.92$ across SchNet, PaiNN, and SpookyNet. This enables discarding suboptimal configurations early, saving up to 90% of compute.</p>
<h2 id="chemgpt-scaling-chemical-language-models">ChemGPT: scaling chemical language models</h2>
<p>ChemGPT is a GPT-3-style autoregressive transformer for molecular generation. It uses GPT-Neo as its backbone with a SELFIES tokenizer, factorizing the probability of a molecular sequence as:</p>
<p>$$
p(x) = \prod_{i=1}^{n} p\left(s_i \mid s_1, \dots, s_{i-1}\right)
$$</p>
<p>The authors trained ChemGPT models ranging from ~78K to over 1 billion non-embedding parameters on subsets of PubChem10M (up to ~10 million molecules, or ~300 million tokens). Key findings from the scaling experiments:</p>
<ul>
<li><strong>Pre-training loss monotonically improves</strong> with increasing dataset size up to nearly 10 million molecules, with no saturation observed.</li>
<li><strong>For a fixed data budget</strong>, increasing model size provides monotonic improvements until models reach ~1 billion parameters.</li>
<li><strong>The scaling exponent</strong> $\beta = 0.17 \pm 0.01$ for the largest dataset (after excluding the three largest models from the power-law fit), and $\beta = 0.30 \pm 0.01$ for the next largest dataset.</li>
<li><strong>Resolution-limited regimes</strong> appear where the power-law behavior breaks down, indicating either insufficient data for a given model size or vice versa. These regimes shift depending on the data budget.</li>
</ul>
<p>An interesting observation: for small datasets, large models ($10^7$ parameters and above) still provide notable loss improvements, suggesting that scaling up model size helps even when data is limited.</p>
<h2 id="neural-force-field-scaling-with-gnns">Neural force field scaling with GNNs</h2>
<p>For tasks requiring three-dimensional molecular geometry, the authors studied GNN-based neural force fields (NFFs). These models predict energies $\hat{E} = f_\theta(X)$ and derive forces by differentiation:</p>
<p>$$
\hat{F}_{ij} = -\frac{\partial \hat{E}}{\partial r_{ij}}
$$</p>
<p>Training uses an L1 loss over energies and forces:</p>
<p>$$
\mathcal{L} = \frac{1}{N} \sum_{i=1}^{N} \left[ \alpha_E | E_i - \hat{E}_i | + \alpha_F | \mathbf{F}_i - \hat{\mathbf{F}}_i | \right]
$$</p>
<p>Four NFF architectures were studied, spanning a range of physical priors:</p>
<table>
  <thead>
      <tr>
          <th>Model</th>
          <th>Type</th>
          <th>Key Characteristic</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>SchNet</td>
          <td>E(3) invariant</td>
          <td>Continuous filter convolutions</td>
      </tr>
      <tr>
          <td>PaiNN</td>
          <td>E(3) equivariant</td>
          <td>Equivariant message passing</td>
      </tr>
      <tr>
          <td>Allegro</td>
          <td>E(3) equivariant</td>
          <td>Local, learned many-body functions</td>
      </tr>
      <tr>
          <td>SpookyNet</td>
          <td>E(3) equivariant</td>
          <td>Non-local interactions, empirical corrections</td>
      </tr>
  </tbody>
</table>
<p>Model capacity is parameterized as $c = d \times w$ (depth times width). Models were trained on subsets of the ANI-1x dataset (up to 100,000 geometries, corresponding to ~4.5 million force labels).</p>
<p>Key GNN scaling findings:</p>
<ul>
<li><strong>PaiNN shows monotonic loss improvement</strong> with increasing dataset size and strong correlation between converged loss and model capacity (Spearman&rsquo;s $\rho \geq 0.88$).</li>
<li><strong>Equivariant GNNs (PaiNN, Allegro) show better scaling efficiency</strong> than invariant GNNs (SchNet), with larger $\beta$ values.</li>
<li><strong>The scaling exponent for equivariant GNNs</strong> is $\beta = 0.26$, indicating that physics-based equivariance priors provide greater sample efficiency that persists to much larger and more chemically diverse datasets than previously studied.</li>
<li><strong>A transition at $10^4$ datapoints</strong> shows nearly perfect rank correlation between model capacity and converged loss ($\rho \geq 0.93$), suggesting this may be a threshold where models move from memorization to generalization.</li>
</ul>
<h2 id="results-and-practical-implications">Results and practical implications</h2>
<p>The scaling results provide actionable guidance for resource allocation:</p>
<ul>
<li>For <strong>chemical LLMs with large data budgets</strong>, the greatest loss improvements come from scaling up small models (around $10^5$ parameters).</li>
<li>For <strong>small data budgets</strong>, rapid improvements come from scaling medium-sized models ($10^7$ parameters).</li>
<li>For <strong>NFFs</strong>, low-capacity models show diminishing returns with more data, while high-capacity models show rapid improvements with increasing dataset size.</li>
<li><strong>Neither model type has saturated</strong> with respect to model size, dataset size, or compute, suggesting substantial room for improvement with further scaling.</li>
</ul>
<p>The 300-million-parameter ChemGPT trained on 300 million tokens and the PaiNN model with capacity ~1,000 trained on $10^5$ frames achieved the minimum losses in their respective scaling plots, providing concrete targets for practitioners.</p>
<h2 id="reproducibility-details">Reproducibility Details</h2>
<p><strong>Data:</strong></p>
<ul>
<li>PubChem10M (10M SMILES strings, via DeepChem)</li>
<li>MOSES (2M molecules, for TPE validation)</li>
<li>ANI-1x (5M DFT calculations, via Figshare)</li>
<li>Revised MD-17 (10 small organic molecules, 10,000 frames for TPE)</li>
</ul>
<p><strong>Models:</strong></p>
<ul>
<li>ChemGPT: GPT-Neo backbone, 24 layers, widths from 16 to 2,048, sizes from ~78K to ~1.2B non-embedding parameters</li>
<li>SchNet, PaiNN, Allegro, SpookyNet: widths of 16, 64, 256; depths of 2, 3, 4; 5 Angstrom cutoff</li>
</ul>
<p><strong>Training:</strong></p>
<ul>
<li>ChemGPT: AdamW optimizer, learning rate $2 \times 10^{-5}$, batch size 8 per GPU, 10 epochs, cross-entropy loss</li>
<li>GNNs: Adam optimizer, learning rate scheduler (halved after 30 epochs without improvement), early stopping after 50 stagnant epochs, max 1,000 epochs, L1 loss (force-only training)</li>
</ul>
<p><strong>Hardware:</strong></p>
<ul>
<li>NVIDIA Volta V100 GPUs (32 GB), 2 GPUs per node</li>
<li>PyTorch with distributed data parallel (DDP), PyTorch Lightning, LitMatter</li>
</ul>
<p><strong>Code:</strong> <a href="https://github.com/ncfrey/litmatter">LitMatter repository</a></p>
<h2 id="paper-information">Paper Information</h2>
<p><strong>Citation:</strong> Frey, N.C., Soklaski, R., Axelrod, S. et al. Neural scaling of deep chemical models. <em>Nat Mach Intell</em> <strong>5</strong>, 1297-1305 (2023).</p>
<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">@article</span>{frey2023neural,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">title</span>=<span style="color:#e6db74">{Neural scaling of deep chemical models}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">author</span>=<span style="color:#e6db74">{Frey, Nathan C. and Soklaski, Ryan and Axelrod, Simon and Samsi, Siddharth and G{\&#39;o}mez-Bombarelli, Rafael and Coley, Connor W. and Gadepally, Vijay}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">journal</span>=<span style="color:#e6db74">{Nature Machine Intelligence}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">volume</span>=<span style="color:#e6db74">{5}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">number</span>=<span style="color:#e6db74">{11}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">pages</span>=<span style="color:#e6db74">{1297--1305}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">year</span>=<span style="color:#e6db74">{2023}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">publisher</span>=<span style="color:#e6db74">{Nature Publishing Group}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">doi</span>=<span style="color:#e6db74">{10.1038/s42256-023-00740-3}</span>
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div>]]></content:encoded></item><item><title>BARTSmiles: BART Pre-Training for Molecular SMILES</title><link>https://hunterheidenreich.com/notes/chemistry/molecular-representations/encoders/bartsmiles-molecular-representations/</link><pubDate>Sun, 22 Mar 2026 00:00:00 +0000</pubDate><guid>https://hunterheidenreich.com/notes/chemistry/molecular-representations/encoders/bartsmiles-molecular-representations/</guid><description>BARTSmiles applies BART-style denoising pre-training to 1.7B SMILES from ZINC20, achieving top results on 11 molecular property and reaction tasks.</description><content:encoded><![CDATA[<h2 id="a-bart-based-method-for-molecular-self-supervised-learning">A BART-Based Method for Molecular Self-Supervised Learning</h2>
<p>BARTSmiles is a <strong>Method</strong> paper. It introduces a self-supervised pre-training approach for molecular representations based on the BART (Bidirectional and Auto-Regressive Transformers) architecture from Lewis et al. (2019). The primary contribution is a pre-training strategy, discovered through systematic ablations, that trains a BART-large model on 1.7 billion deduplicated <a href="/notes/chemistry/molecular-representations/notations/smiles/">SMILES strings</a> from the <a href="/notes/chemistry/datasets/zinc-22/">ZINC20 dataset</a>. BARTSmiles achieves the best reported results on 11 tasks spanning molecular property classification, regression, and chemical reaction generation.</p>
<h2 id="scaling-self-supervised-molecular-representations-beyond-prior-work">Scaling Self-Supervised Molecular Representations Beyond Prior Work</h2>
<p>At the time of publication, large-scale self-supervised representation learning had produced significant improvements in NLP, computer vision, and speech, but molecular representation learning had not benefited from comparable scale. Previous SMILES-based pre-trained models such as <a href="/notes/chemistry/molecular-representations/encoders/chemberta/">ChemBERTa</a> (Chithrananda et al., 2020) and <a href="/notes/chemistry/molecular-design/generation/autoregressive/chemformer/">ChemFormer</a> (Irwin et al., 2022) used encoder-only or encoder-decoder architectures with substantially less compute. ChemFormer, the most closely related prior work, also trained a BART-like model but with a fraction of the compute and data.</p>
<p>The paper argues that three gaps needed to be addressed:</p>
<ol>
<li><strong>Scale</strong>: Prior molecular pre-training used orders of magnitude less compute than NLP pre-training.</li>
<li><strong>Architecture choice</strong>: Encoder-only models like ChemBERTa cannot perform generative fine-tuning (retrosynthesis, reaction prediction), limiting their applicability.</li>
<li><strong>Pre-training recipe</strong>: Standard BART hyperparameters (e.g., 30% mask token budget) were tuned for natural language and had not been validated for molecular SMILES strings.</li>
</ol>
<h2 id="core-innovation-ablation-driven-pre-training-recipe-for-smiles">Core Innovation: Ablation-Driven Pre-Training Recipe for SMILES</h2>
<p>The key insight of BARTSmiles is that the BART denoising objective, when carefully tuned for the molecular domain, learns representations that implicitly encode downstream task information. The authors discover this through a systematic three-stage ablation:</p>
<h3 id="tokenization">Tokenization</h3>
<p>Rather than using hand-crafted tokenization rules that separate individual atoms (C, N, H) and bond symbols (#, =), BARTSmiles uses a learned SentencePiece unigram tokenizer trained on 10 million random SMILES with a vocabulary size of 1,021. On matched compute budgets, learned tokenization achieves 0.801 average AUC-ROC vs. 0.779 for hand-crafted tokenization on the ablation benchmark (HIV, BBBP, ClinTox).</p>
<h3 id="masking-strategy">Masking Strategy</h3>
<p>The BART denoising objective has three main hyperparameters: the mask token budget (fraction of tokens masked), random mask probability, and the Poisson $\lambda$ controlling mask span length. The ablation results show:</p>
<ul>
<li><strong>Mask token budget</strong>: The standard BART value of 0.30 is suboptimal for molecules. A budget of 0.20 performs best (0.821 AUC-ROC), with performance degrading at both lower (0.10: 0.753) and higher (0.40: 0.701) budgets.</li>
<li><strong>Span masking</strong>: The choice of random mask probability and $\lambda$ has a minor effect once the budget is set to 0.20. Values of random mask = 0.10 and $\lambda$ = 2.5 or 3.5 all yield 0.821.</li>
<li><strong>Token randomization</strong>: Disabling the randomize-tokens noise (where some tokens are replaced with random tokens rather than masked) improves performance from 0.821 to 0.835.</li>
</ul>
<h3 id="scale">Scale</h3>
<p>Training on the full 1.7 billion molecule ZINC20 dataset (20 hours on 1,024 A100 GPUs, totaling 20,480 A100 GPU-hours) improves performance by 5 absolute AUC-ROC points over the same model trained on 100 million samples. The previous most compute-intensive molecular pre-training used 3,330 V100-hours (Ross et al., 2021).</p>
<h3 id="implicit-task-encoding">Implicit Task Encoding</h3>
<p>The paper provides a quantitative demonstration that frozen BARTSmiles representations encode task-specific information. Using L1-regularized logistic regression on frozen 1,024-dimensional mean-pooled representations, just 7 neurons are sufficient to achieve 0.987 AUC-ROC on ClinTox (within 2 percentage points of full fine-tuning). Even a single neuron achieves 0.77 AUC-ROC on ClinTox subtask 1.</p>
<h2 id="experimental-setup-moleculenet-toxicology-and-generative-benchmarks">Experimental Setup: MoleculeNet, Toxicology, and Generative Benchmarks</h2>
<h3 id="classification-tasks">Classification Tasks</h3>
<p>BARTSmiles is evaluated on 7 classification datasets from <a href="/notes/chemistry/molecular-design/property-prediction/moleculenet-benchmark-molecular-ml/">MoleculeNet</a> (SIDER, ClinTox, Tox21, ToxCast, HIV, BACE, BBBP) plus 2 toxicology datasets (<a href="https://en.wikipedia.org/wiki/Ames_test">Ames</a>, <a href="https://en.wikipedia.org/wiki/Micronucleus_test">Micronucleus Assay</a>). All classification tasks use AUC-ROC. Baselines include both supervised graph models (D-MPNN, Attentive FP, 3D InfoMax) and self-supervised methods (ChemBERTa, <a href="/notes/chemistry/molecular-representations/encoders/molformer/">MolFormer-XL</a>, GROVER-large, MolCLR, iMolCLR).</p>
<p>Selected classification results (AUC-ROC):</p>
<table>
  <thead>
      <tr>
          <th>Dataset</th>
          <th>BARTSmiles</th>
          <th>Previous Best</th>
          <th>Previous Best Model</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>ClinTox</td>
          <td><strong>0.997</strong></td>
          <td>0.954</td>
          <td>iMolCLR</td>
      </tr>
      <tr>
          <td>ToxCast</td>
          <td><strong>0.825</strong></td>
          <td>0.805</td>
          <td>Attentive FP</td>
      </tr>
      <tr>
          <td>SIDER</td>
          <td><strong>0.705</strong></td>
          <td>0.699</td>
          <td>iMolCLR</td>
      </tr>
      <tr>
          <td>Tox21</td>
          <td>0.851</td>
          <td>0.858</td>
          <td>Attentive FP</td>
      </tr>
  </tbody>
</table>
<p>The authors note that three scaffold-split datasets (HIV, BACE, BBBP) are highly sensitive to the specific split used, and they suspect some baseline results use different or random splits. These results are marked with caveats in the paper.</p>
<h3 id="regression-tasks">Regression Tasks</h3>
<p>All three MoleculeNet regression tasks (ESOL, FreeSolv, Lipophilicity) are evaluated using RMSE:</p>
<table>
  <thead>
      <tr>
          <th>Dataset</th>
          <th>BARTSmiles</th>
          <th>Previous Best</th>
          <th>Previous Best Model</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>ESOL</td>
          <td><strong>0.095</strong></td>
          <td>0.279</td>
          <td>MoLFormer-XL</td>
      </tr>
      <tr>
          <td>FreeSolv</td>
          <td><strong>0.114</strong></td>
          <td>0.231</td>
          <td>MoLFormer-XL</td>
      </tr>
      <tr>
          <td>Lipophilicity</td>
          <td><strong>0.292</strong></td>
          <td>0.529</td>
          <td>MoLFormer-XL</td>
      </tr>
  </tbody>
</table>
<p>BARTSmiles achieves substantial improvements on all three regression tasks.</p>
<h3 id="generative-tasks">Generative Tasks</h3>
<p><strong><a href="https://en.wikipedia.org/wiki/Retrosynthetic_analysis">Retrosynthesis</a></strong> (USPTO-50k): BARTSmiles achieves 55.6% Top-1 accuracy using a sample-128 + perplexity re-ranking strategy, compared to 55.3% for Dual-TF and 54.3% for ChemFormer. Top-5 and Top-10 results are 74.2% and 80.9% respectively.</p>
<p><strong>Chemical Reaction Prediction</strong> (USPTO MIT/LEF/STEREO): BARTSmiles with beam search outperforms the <a href="/notes/chemistry/molecular-design/reaction-prediction/molecular-transformer/">Molecular Transformer</a> baseline across all six evaluation settings. On USPTO-MIT (split), BARTSmiles achieves 91.8% vs. 90.4% for the Transformer baseline.</p>
<h3 id="fine-tuning-recipe">Fine-Tuning Recipe</h3>
<p>The fine-tuning approach is designed to minimize hyperparameter tuning:</p>
<ul>
<li>Batch size 16, 10 epochs, polynomial decay learning rate schedule with warmup at 16% of training</li>
<li>Grid search over dropout (0.1, 0.2, 0.3) and learning rate ($5 \times 10^{-6}$, $1 \times 10^{-5}$, $3 \times 10^{-5}$)</li>
<li>Stochastic Weight Averaging (SWA) over three sets of four checkpoints</li>
<li>For generative tasks: R3F regularization (Aghajanyan et al., 2020a) and full fp32 precision</li>
<li>For generation: beam search (beam size 10) or sample 128 sequences with perplexity re-ranking</li>
</ul>
<h2 id="key-findings-and-limitations">Key Findings and Limitations</h2>
<h3 id="key-findings">Key Findings</h3>
<ol>
<li><strong>Scale matters for molecular pre-training</strong>: Training on 1.7B molecules with 20,480 A100 GPU-hours yields 5 absolute points of AUC-ROC improvement over training on 100M molecules.</li>
<li><strong>Domain-specific ablation is necessary</strong>: The optimal BART masking configuration for molecules (20% budget, no token randomization) differs from the standard NLP configuration (30% budget, with randomization).</li>
<li><strong>Frozen representations capture task structure</strong>: A small number of neurons from the frozen model can nearly match full fine-tuning performance on certain tasks, suggesting the pre-training objective implicitly encodes molecular properties.</li>
<li><strong>Interpretability aligns with domain knowledge</strong>: Integrated Gradients attribution on fine-tuned BARTSmiles highlights known structural alerts (e.g., <a href="https://en.wikipedia.org/wiki/Nitro_compound">nitro groups</a> in mutagenic compounds, hydroxyl groups in soluble compounds).</li>
</ol>
<h3 id="limitations">Limitations</h3>
<ul>
<li><strong>Scaffold split sensitivity</strong>: Results on HIV, BACE, and BBBP are sensitive to the specific scaffold split, making direct comparison with baselines difficult.</li>
<li><strong>Pre-training data distribution</strong>: The <a href="https://en.wikipedia.org/wiki/Fr%C3%A9chet_distance">Frechet distance</a> analysis shows that some downstream datasets (BBBP, SIDER) are far from ZINC20 in representation space, which may explain weaker performance on those tasks.</li>
<li><strong>Fingerprints carry complementary information</strong>: On the Ames and Micronucleus Assay datasets, BARTSmiles alone does not beat fingerprint-based baselines. Combining BARTSmiles with ECFP4 fingerprints closes the gap, implying that SMILES-based pre-training does not fully capture all structural information.</li>
<li><strong>Compute requirements</strong>: Pre-training requires 1,024 A100 GPUs, which limits accessibility.</li>
</ul>
<h3 id="future-directions">Future Directions</h3>
<p>The authors suggest investigating the impact of pre-training data composition, noting that ZINC20 contains over a billion molecules but its distribution may be irrelevant for many downstream tasks. They also propose further collaboration between ML and chemistry experts to discover new molecular substructure-property relationships.</p>
<hr>
<h2 id="reproducibility-details">Reproducibility Details</h2>
<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/YerevaNN/BARTSmiles">BARTSmiles (GitHub)</a></td>
          <td>Code + Model</td>
          <td>MIT</td>
          <td>Pre-training, fine-tuning, and evaluation scripts with pre-trained weights</td>
      </tr>
  </tbody>
</table>
<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>Pre-training</td>
          <td>ZINC20 (deduplicated)</td>
          <td>~1.7B molecules</td>
          <td>Canonicalized SMILES, 10K validation holdout</td>
      </tr>
      <tr>
          <td>Classification</td>
          <td>MoleculeNet (7 datasets)</td>
          <td>1,427-41,127 compounds</td>
          <td>AUC-ROC metric</td>
      </tr>
      <tr>
          <td>Regression</td>
          <td>MoleculeNet (3 datasets)</td>
          <td>642-4,200 compounds</td>
          <td>RMSE metric</td>
      </tr>
      <tr>
          <td>Toxicology</td>
          <td>Ames, MN Assay</td>
          <td>6,512 / 641 compounds</td>
          <td>Cross-validation for Ames; external test for MN</td>
      </tr>
      <tr>
          <td>Retrosynthesis</td>
          <td>USPTO-50k</td>
          <td>Standard split</td>
          <td>Top-K accuracy</td>
      </tr>
      <tr>
          <td>Reaction prediction</td>
          <td>USPTO (MIT/LEF/STEREO)</td>
          <td>Standard splits</td>
          <td>Top-1 accuracy</td>
      </tr>
  </tbody>
</table>
<h3 id="algorithms">Algorithms</h3>
<ul>
<li>Architecture: BART-Large (pre-layer norm Transformer encoder-decoder)</li>
<li>Tokenizer: SentencePiece unigram, vocabulary size 1,021, max sequence length 128</li>
<li>Pre-training objective: BART denoising (mask token budget 0.20, Poisson span masking with $\lambda$ = 2.5, no token randomization)</li>
<li>Fine-tuning: polynomial decay LR, SWA, grid search over dropout and LR</li>
<li>Generative fine-tuning: R3F regularization, fp32 precision, Adam initialized from pre-training moving averages</li>
</ul>
<h3 id="models">Models</h3>
<ul>
<li>BART-Large architecture (exact parameter count not specified in paper)</li>
<li>Pre-trained checkpoint released on GitHub</li>
<li>Maximum sequence length: 128 tokens</li>
</ul>
<h3 id="evaluation">Evaluation</h3>
<table>
  <thead>
      <tr>
          <th>Task</th>
          <th>Metric</th>
          <th>BARTSmiles</th>
          <th>Notes</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>ClinTox</td>
          <td>AUC-ROC</td>
          <td>0.997</td>
          <td>New SOTA</td>
      </tr>
      <tr>
          <td>ToxCast</td>
          <td>AUC-ROC</td>
          <td>0.825</td>
          <td>New SOTA</td>
      </tr>
      <tr>
          <td>ESOL</td>
          <td>RMSE</td>
          <td>0.095</td>
          <td>New SOTA</td>
      </tr>
      <tr>
          <td>FreeSolv</td>
          <td>RMSE</td>
          <td>0.114</td>
          <td>New SOTA</td>
      </tr>
      <tr>
          <td>Lipophilicity</td>
          <td>RMSE</td>
          <td>0.292</td>
          <td>New SOTA</td>
      </tr>
      <tr>
          <td>USPTO-50k Retro (Top-1)</td>
          <td>Accuracy</td>
          <td>55.6%</td>
          <td>New SOTA (sample + re-rank)</td>
      </tr>
      <tr>
          <td>USPTO-MIT Rxn (Split)</td>
          <td>Accuracy</td>
          <td>91.8%</td>
          <td>New SOTA (beam-10)</td>
      </tr>
  </tbody>
</table>
<h3 id="hardware">Hardware</h3>
<ul>
<li>Pre-training: 1,024 NVIDIA A100 GPUs for 20 hours (20,480 A100 GPU-hours)</li>
<li>Ablation runs: 128 A100 GPUs per run</li>
<li>Framework: FairSeq with FairScale (fully sharded data parallel), automatic mixed precision</li>
<li>Experiment tracking: Aim</li>
</ul>
<hr>
<h2 id="paper-information">Paper Information</h2>
<p><strong>Citation</strong>: Chilingaryan, G., Tamoyan, H., Tevosyan, A., Babayan, N., Khondkaryan, L., Hambardzumyan, K., Navoyan, Z., Khachatrian, H., &amp; Aghajanyan, A. (2024). BARTSmiles: Generative Masked Language Models for Molecular Representations. <em>Journal of Chemical Information and Modeling</em>, 64(15), 5832-5843. <a href="https://doi.org/10.1021/acs.jcim.4c00512">https://doi.org/10.1021/acs.jcim.4c00512</a></p>
<p><strong>Publication</strong>: Journal of Chemical Information and Modeling, 2024 (preprint: arXiv 2022)</p>
<p><strong>Additional Resources</strong>:</p>
<ul>
<li><a href="https://github.com/YerevaNN/BARTSmiles">BARTSmiles GitHub Repository (MIT License)</a></li>
</ul>
<h2 id="citation">Citation</h2>
<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">@article</span>{chilingaryan2024bartsmiles,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">title</span>=<span style="color:#e6db74">{BARTSmiles: Generative Masked Language Models for Molecular Representations}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">author</span>=<span style="color:#e6db74">{Chilingaryan, Gayane and Tamoyan, Hovhannes and Tevosyan, Ani and Babayan, Nelly and Khondkaryan, Lusine and Hambardzumyan, Karen and Navoyan, Zaven and Khachatrian, Hrant and Aghajanyan, Armen}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">journal</span>=<span style="color:#e6db74">{Journal of Chemical Information and Modeling}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">volume</span>=<span style="color:#e6db74">{64}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">number</span>=<span style="color:#e6db74">{15}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">pages</span>=<span style="color:#e6db74">{5832--5843}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">doi</span>=<span style="color:#e6db74">{10.1021/acs.jcim.4c00512}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">year</span>=<span style="color:#e6db74">{2024}</span>
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div>]]></content:encoded></item><item><title>SELFormer: A SELFIES-Based Molecular Language Model</title><link>https://hunterheidenreich.com/notes/chemistry/molecular-representations/encoders/selformer/</link><pubDate>Mon, 16 Mar 2026 00:00:00 +0000</pubDate><guid>https://hunterheidenreich.com/notes/chemistry/molecular-representations/encoders/selformer/</guid><description>A SELFIES-based RoBERTa model pretrained on 2M ChEMBL molecules for molecular property prediction on MoleculeNet benchmarks.</description><content:encoded><![CDATA[<h2 id="a-selfies-based-chemical-language-model">A SELFIES-Based Chemical Language Model</h2>
<p>This is primarily a <strong>Method</strong> paper ($\Psi_{\text{Method}}$) with a secondary <strong>Resource</strong> component ($\Psi_{\text{Resource}}$).</p>
<p>SELFormer applies the RoBERTa transformer architecture to <a href="/notes/chemistry/molecular-representations/notations/selfies-original-paper/">SELFIES</a> molecular string representations instead of the <a href="/notes/chemistry/molecular-representations/notations/smiles/">SMILES</a> notation used by prior chemical language models. The model is pretrained via masked language modeling (MLM) on 2M drug-like compounds from <a href="https://en.wikipedia.org/wiki/ChEMBL">ChEMBL</a> and fine-tuned for molecular property prediction tasks on <a href="/notes/chemistry/molecular-design/property-prediction/moleculenet-benchmark-molecular-ml/">MoleculeNet</a> benchmarks. The authors release pretrained models, fine-tuning code, and datasets as open-source resources.</p>
<h2 id="why-selfies-over-smiles-for-pretraining">Why SELFIES Over SMILES for Pretraining?</h2>
<p>Existing chemical language models, including <a href="/notes/chemistry/molecular-representations/encoders/chemberta/">ChemBERTa</a>, <a href="/notes/chemistry/molecular-representations/encoders/chemberta-2/">ChemBERTa-2</a>, <a href="/notes/chemistry/molecular-representations/encoders/molbert-molecular-representations/">MolBERT</a>, and <a href="/notes/chemistry/molecular-representations/encoders/molformer/">MolFormer</a>, all use SMILES as their input representation. SMILES has well-documented validity and robustness issues: arbitrary perturbations to a SMILES string frequently produce syntactically invalid outputs. This means a pretrained model must spend capacity learning SMILES grammar rules rather than chemical semantics.</p>
<p><a href="/notes/chemistry/molecular-representations/notations/selfies-original-paper/">SELFIES</a> addresses this by construction: every possible SELFIES string decodes to a valid molecule. Despite this theoretical advantage and SELFIES&rsquo; growing adoption in generative chemistry, no prior work had systematically evaluated SELFIES as input for large-scale transformer pretraining. SELFormer fills this gap by providing a direct comparison between SELFIES-based and SMILES-based chemical language models on standard benchmarks.</p>
<h2 id="masked-language-modeling-on-guaranteed-valid-molecular-strings">Masked Language Modeling on Guaranteed-Valid Molecular Strings</h2>
<p>SELFormer uses byte-level Byte-Pair Encoding (BPE) to tokenize SELFIES strings, then pretrains a RoBERTa encoder using the standard MLM objective. 15% of input tokens are masked, and the model minimizes the cross-entropy loss over the masked positions:</p>
<p>$$
\mathcal{L}_{\text{MLM}} = -\frac{1}{|\mathcal{M}|} \sum_{i \in \mathcal{M}} \log P(x_i \mid x_{\setminus \mathcal{M}}; \theta)
$$</p>
<p>where $\mathcal{M}$ is the set of masked token indices, $x_i$ is the true token at position $i$, $x_{\setminus \mathcal{M}}$ is the corrupted input context, and $\theta$ are the model parameters.</p>
<p>The key insight is that because SELFIES guarantees 100% validity, every masked token prediction corresponds to a valid molecular fragment. The model never wastes capacity predicting invalid chemistry. For fine-tuning, a two-layer classification or regression head is added on top of the encoder&rsquo;s output embedding.</p>
<p>Two model sizes were trained. Notably, the larger SELFormer uses fewer attention heads (4) but more hidden layers (12) than SELFormer-Lite (12 heads, 8 layers). This counterintuitive configuration emerged from the authors&rsquo; hyperparameter search over ~100 models, where deeper architectures with fewer heads outperformed wider, shallower ones:</p>
<table>
  <thead>
      <tr>
          <th>Configuration</th>
          <th>SELFormer-Lite</th>
          <th>SELFormer</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>Attention Heads</td>
          <td>12</td>
          <td>4</td>
      </tr>
      <tr>
          <td>Hidden Layers</td>
          <td>8</td>
          <td>12</td>
      </tr>
      <tr>
          <td>Batch Size</td>
          <td>16</td>
          <td>16</td>
      </tr>
      <tr>
          <td>Learning Rate</td>
          <td>5e-5</td>
          <td>5e-5</td>
      </tr>
      <tr>
          <td>Weight Decay</td>
          <td>0.01</td>
          <td>0.01</td>
      </tr>
      <tr>
          <td>Pretraining Epochs</td>
          <td>100</td>
          <td>100</td>
      </tr>
      <tr>
          <td>Parameters</td>
          <td>58.3M</td>
          <td>86.7M</td>
      </tr>
  </tbody>
</table>
<h2 id="benchmarking-against-smiles-transformers-and-graph-models">Benchmarking Against SMILES Transformers and Graph Models</h2>
<p>SELFormer was pretrained on 2.08M drug-like compounds from ChEMBL v30 (converted from SMILES to SELFIES), then fine-tuned on nine MoleculeNet tasks. All evaluations use scaffold splitting via the Chemprop library.</p>
<p><strong>Classification tasks</strong> (ROC-AUC, scaffold split):</p>
<table>
  <thead>
      <tr>
          <th>Model</th>
          <th>BACE</th>
          <th>BBBP</th>
          <th>HIV</th>
          <th>Tox21</th>
          <th>SIDER</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>SELFormer</td>
          <td>0.832</td>
          <td><strong>0.902</strong></td>
          <td>0.681</td>
          <td>0.653</td>
          <td><strong>0.745</strong></td>
      </tr>
      <tr>
          <td>ChemBERTa-2</td>
          <td>0.799</td>
          <td>0.728</td>
          <td>0.622</td>
          <td>-</td>
          <td>-</td>
      </tr>
      <tr>
          <td>MolBERT</td>
          <td><strong>0.866</strong></td>
          <td>0.762</td>
          <td><strong>0.783</strong></td>
          <td>-</td>
          <td>-</td>
      </tr>
      <tr>
          <td>D-MPNN</td>
          <td>0.809</td>
          <td>0.710</td>
          <td>0.771</td>
          <td>0.759</td>
          <td>0.570</td>
      </tr>
      <tr>
          <td>MolCLR</td>
          <td><strong>0.890</strong></td>
          <td>0.736</td>
          <td><strong>0.806</strong></td>
          <td><strong>0.787</strong></td>
          <td>0.652</td>
      </tr>
      <tr>
          <td>GEM</td>
          <td>0.856</td>
          <td>0.724</td>
          <td><strong>0.806</strong></td>
          <td>0.781</td>
          <td>0.672</td>
      </tr>
      <tr>
          <td>KPGT</td>
          <td>0.855</td>
          <td><strong>0.908</strong></td>
          <td>-</td>
          <td><strong>0.848</strong></td>
          <td>0.649</td>
      </tr>
  </tbody>
</table>
<p><strong>Regression tasks</strong> (RMSE, scaffold split, lower is better):</p>
<table>
  <thead>
      <tr>
          <th>Model</th>
          <th>ESOL</th>
          <th>FreeSolv</th>
          <th>Lipophilicity</th>
          <th>PDBbind</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>SELFormer</td>
          <td><strong>0.682</strong></td>
          <td>2.797</td>
          <td>0.735</td>
          <td>1.488</td>
      </tr>
      <tr>
          <td>ChemBERTa-2</td>
          <td>-</td>
          <td>-</td>
          <td>0.986</td>
          <td>-</td>
      </tr>
      <tr>
          <td>D-MPNN</td>
          <td>1.050</td>
          <td><strong>2.082</strong></td>
          <td><strong>0.683</strong></td>
          <td><strong>1.397</strong></td>
      </tr>
      <tr>
          <td>GEM</td>
          <td>0.798</td>
          <td><strong>1.877</strong></td>
          <td>0.660</td>
          <td>-</td>
      </tr>
      <tr>
          <td>KPGT</td>
          <td>0.803</td>
          <td>2.121</td>
          <td><strong>0.600</strong></td>
          <td>-</td>
      </tr>
  </tbody>
</table>
<p>The ablation study compared SELFormer vs. SELFormer-Lite across pretrained-only, 25-epoch, and 50-epoch fine-tuning configurations on randomly split datasets. SELFormer consistently outperformed SELFormer-Lite, confirming the benefit of the deeper (12-layer) architecture.</p>
<h2 id="strong-classification-performance-with-compact-pretraining">Strong Classification Performance with Compact Pretraining</h2>
<p>SELFormer&rsquo;s strongest results come on classification tasks where molecular substructure matters:</p>
<ul>
<li><strong>SIDER</strong>: Best overall ROC-AUC (0.745), outperforming the next best method (MolCLR at 0.652) by 9.3 percentage points. The authors attribute this to SELFIES&rsquo; ability to capture subtle structural differences relevant to drug side effects.</li>
<li><strong>BBBP</strong>: Second best (0.902), behind only KPGT (0.908). SELFormer scored 17.4 percentage points above ChemBERTa-2 (0.728) on this task.</li>
<li><strong>BACE/HIV vs. ChemBERTa-2</strong>: SELFormer outperformed ChemBERTa-2 by 3.3 points on BACE (0.832 vs 0.799), 17.4 on BBBP, and 5.9 on HIV (0.681 vs 0.622). Since both models use similar RoBERTa architectures, this comparison is suggestive of a SELFIES advantage, though differences in pretraining corpus (ChEMBL vs PubChem), corpus size, and training procedure confound a clean attribution to the input representation alone.</li>
<li><strong>ESOL regression</strong>: Best RMSE (0.682) vs GEM (0.798), a 14.5% relative improvement.</li>
</ul>
<p>Limitations are also apparent:</p>
<ul>
<li><strong>HIV and Tox21</strong>: SELFormer underperforms graph-based methods (MolCLR, GEM, KPGT) on these larger datasets. The authors attribute this to insufficient hyperparameter search given computational constraints.</li>
<li><strong>FreeSolv and Lipophilicity regression</strong>: D-MPNN and graph-based methods maintain an edge, suggesting that explicit 2D/3D structural inductive biases remain valuable for certain property types.</li>
<li><strong>Small pretraining corpus</strong>: At 2M molecules, SELFormer&rsquo;s corpus is orders of magnitude smaller than MolFormer&rsquo;s 1.1B. Despite this, SELFormer outperforms MolFormer on SIDER (0.745 vs 0.690), highlighting SELFIES&rsquo; representational advantage.</li>
<li><strong>Single-task ablation scope</strong>: Some architectural claims rest on limited task coverage, and broader benchmarking would strengthen the conclusions.</li>
</ul>
<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>Pretraining</td>
          <td>ChEMBL v30</td>
          <td>2,084,725 compounds (2,084,472 after SELFIES conversion)</td>
          <td>Drug-like bioactive small molecules</td>
      </tr>
      <tr>
          <td>Classification</td>
          <td>BACE</td>
          <td>1,513</td>
          <td><a href="https://en.wikipedia.org/wiki/Beta-secretase_1">Beta-secretase 1</a> inhibitor binding</td>
      </tr>
      <tr>
          <td>Classification</td>
          <td>BBBP</td>
          <td>2,039</td>
          <td><a href="https://en.wikipedia.org/wiki/Blood%E2%80%93brain_barrier">Blood-brain barrier</a> permeability</td>
      </tr>
      <tr>
          <td>Classification</td>
          <td>HIV</td>
          <td>41,127</td>
          <td>HIV replication inhibition</td>
      </tr>
      <tr>
          <td>Classification</td>
          <td>SIDER</td>
          <td>1,427</td>
          <td>Drug side effects (27 classes)</td>
      </tr>
      <tr>
          <td>Classification</td>
          <td>Tox21</td>
          <td>7,831</td>
          <td>Toxicity (12 targets)</td>
      </tr>
      <tr>
          <td>Regression</td>
          <td>ESOL</td>
          <td>1,128</td>
          <td>Aqueous solubility</td>
      </tr>
      <tr>
          <td>Regression</td>
          <td>FreeSolv</td>
          <td>642</td>
          <td>Hydration free energy</td>
      </tr>
      <tr>
          <td>Regression</td>
          <td>Lipophilicity</td>
          <td>4,200</td>
          <td>Octanol/water distribution coefficient</td>
      </tr>
      <tr>
          <td>Regression</td>
          <td>PDBbind</td>
          <td>11,908</td>
          <td>Binding affinity</td>
      </tr>
  </tbody>
</table>
<h3 id="algorithms">Algorithms</h3>
<ul>
<li><strong>Pretraining objective</strong>: Masked language modeling (MLM), 15% token masking</li>
<li><strong>Tokenization</strong>: Byte-level Byte-Pair Encoding (BPE) on SELFIES strings</li>
<li><strong>SMILES to SELFIES conversion</strong>: SELFIES API with Pandaral.lel for parallelization</li>
<li><strong>Splitting</strong>: Scaffold splitting via Chemprop library (80/10/10 train/validation/test)</li>
<li><strong>Fine-tuning</strong>: Two-layer classification/regression head on encoder output; up to 200 epochs with hyperparameter search</li>
</ul>
<h3 id="models">Models</h3>
<ul>
<li><strong>Architecture</strong>: RoBERTa (HuggingFace Transformers)</li>
<li><strong>SELFormer</strong>: 12 hidden layers, 4 attention heads, 86.7M parameters</li>
<li><strong>SELFormer-Lite</strong>: 8 hidden layers, 12 attention heads, 58.3M parameters</li>
<li><strong>Hyperparameter search</strong>: Sequential search over ~100 configurations on 100K molecule subset</li>
</ul>
<h3 id="evaluation">Evaluation</h3>
<table>
  <thead>
      <tr>
          <th>Metric</th>
          <th>Task Type</th>
          <th>Details</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>ROC-AUC</td>
          <td>Classification</td>
          <td>Area under receiver operating characteristic curve</td>
      </tr>
      <tr>
          <td>PRC-AUC</td>
          <td>Classification</td>
          <td>Area under precision-recall curve (reported for random splits)</td>
      </tr>
      <tr>
          <td>RMSE</td>
          <td>Regression</td>
          <td>Root mean squared error</td>
      </tr>
  </tbody>
</table>
<p>Results reported on scaffold split and random split datasets.</p>
<h3 id="hardware">Hardware</h3>
<ul>
<li><strong>Compute</strong>: 2x NVIDIA A5000 GPUs</li>
<li><strong>Hyperparameter optimization time</strong>: ~11 days</li>
<li><strong>Full pretraining</strong>: 100 epochs on 2.08M molecules</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/HUBioDataLab/SELFormer">SELFormer GitHub</a></td>
          <td>Code</td>
          <td>GPL-3.0</td>
          <td>Pretraining, fine-tuning, and evaluation scripts</td>
      </tr>
      <tr>
          <td><a href="https://huggingface.co/HUBioDataLab/SELFormer">SELFormer on HuggingFace</a></td>
          <td>Model</td>
          <td>GPL-3.0</td>
          <td>Pretrained SELFormer weights</td>
      </tr>
      <tr>
          <td><a href="https://www.ebi.ac.uk/chembl/">ChEMBL v30</a></td>
          <td>Dataset</td>
          <td>CC BY-SA 3.0</td>
          <td>Source pretraining data</td>
      </tr>
      <tr>
          <td><a href="https://moleculenet.org/">MoleculeNet</a></td>
          <td>Benchmark</td>
          <td>Unknown</td>
          <td>Downstream evaluation tasks</td>
      </tr>
  </tbody>
</table>
<hr>
<h2 id="paper-information">Paper Information</h2>
<p><strong>Citation</strong>: Yüksel, A., Ulusoy, E., Ünlü, A., &amp; Doğan, T. (2023). SELFormer: Molecular Representation Learning via SELFIES Language Models. <em>Machine Learning: Science and Technology</em>, 4(2), 025035. <a href="https://doi.org/10.1088/2632-2153/acdb30">https://doi.org/10.1088/2632-2153/acdb30</a></p>
<p><strong>Publication</strong>: Machine Learning: Science and Technology 2023</p>
<p><strong>Additional Resources</strong>:</p>
<ul>
<li><a href="https://github.com/HUBioDataLab/SELFormer">GitHub Repository (SELFormer)</a></li>
<li><a href="https://huggingface.co/HUBioDataLab/SELFormer">HuggingFace Model Hub (SELFormer)</a></li>
</ul>
<h2 id="citation">Citation</h2>
<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">@article</span>{yuksel2023selformer,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">title</span>=<span style="color:#e6db74">{{SELFormer}: Molecular Representation Learning via {SELFIES} Language Models}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">author</span>=<span style="color:#e6db74">{Y{\&#34;u}ksel, Atakan and Ulusoy, Erva and {\&#34;U}nl{\&#34;u}, Atabey and Do{\u{g}}an, Tunca}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">journal</span>=<span style="color:#e6db74">{Machine Learning: Science and Technology}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">volume</span>=<span style="color:#e6db74">{4}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">number</span>=<span style="color:#e6db74">{2}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">pages</span>=<span style="color:#e6db74">{025035}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">year</span>=<span style="color:#e6db74">{2023}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">publisher</span>=<span style="color:#e6db74">{IOP Publishing}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">doi</span>=<span style="color:#e6db74">{10.1088/2632-2153/acdb30}</span>
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div>]]></content:encoded></item><item><title>MoLFormer: Large-Scale Chemical Language Representations</title><link>https://hunterheidenreich.com/notes/chemistry/molecular-representations/encoders/molformer/</link><pubDate>Mon, 16 Mar 2026 00:00:00 +0000</pubDate><guid>https://hunterheidenreich.com/notes/chemistry/molecular-representations/encoders/molformer/</guid><description>A linear-attention transformer pretrained on 1.1B SMILES from PubChem and ZINC for molecular property prediction across MoleculeNet benchmarks.</description><content:encoded><![CDATA[<h2 id="a-billion-scale-chemical-language-model">A Billion-Scale Chemical Language Model</h2>
<p>This is primarily a <strong>Method</strong> paper ($\Psi_{\text{Method}}$).</p>
<p>MoLFormer is a transformer encoder pretrained via masked language modeling on 1.1 billion <a href="/notes/chemistry/molecular-representations/notations/smiles/">SMILES</a> strings from <a href="https://en.wikipedia.org/wiki/PubChem">PubChem</a> and <a href="https://en.wikipedia.org/wiki/ZINC_database">ZINC</a>. The key architectural choices are linear attention (for $O(N)$ complexity instead of $O(N^2)$) and rotary positional embeddings (RoPE). The resulting model, MoLFormer-XL, produces molecular embeddings that outperform or match GNN baselines across a wide range of <a href="/notes/chemistry/molecular-design/property-prediction/moleculenet-benchmark-molecular-ml/">MoleculeNet</a> classification and regression tasks, including quantum-chemical property prediction from SMILES alone.</p>
<h2 id="bridging-the-gap-between-molecular-languages-and-graph-neural-networks">Bridging the Gap Between Molecular Languages and Graph Neural Networks</h2>
<p>Prior chemical language models like <a href="/notes/chemistry/molecular-representations/encoders/chemberta/">ChemBERTa</a> were pretrained on relatively small datasets (10M-77M molecules) and generally underperformed GNNs on molecular property prediction. The core question: does a transformer trained on a sufficiently large SMILES corpus learn enough chemical structure to compete with graph-based methods that have explicit topological inductive biases?</p>
<p>Two specific challenges motivated this work:</p>
<ul>
<li><strong>Scale</strong>: The chemical space spans $10^{60}$ to $10^{100}$ plausible molecules, yet labeled property data is scarce. Self-supervised pretraining on the ~1.1B unlabeled molecules available in public databases could provide a general-purpose representation.</li>
<li><strong>Efficiency</strong>: Standard transformer attention is $O(N^2)$ in sequence length, making billion-scale pretraining impractical without architectural modifications.</li>
</ul>
<h2 id="linear-attention-with-rotary-positional-embeddings">Linear Attention with Rotary Positional Embeddings</h2>
<p>MoLFormer&rsquo;s two key architectural choices are its attention mechanism and positional encoding scheme.</p>
<p><strong>Standard attention</strong> computes:</p>
<p>$$
\text{Attention}_m(Q, K, V) = \frac{\sum_{n=1}^{N} \exp(\langle q_m, k_n \rangle) v_n}{\sum_{n=1}^{N} \exp(\langle q_m, k_n \rangle)}
$$</p>
<p>MoLFormer replaces this with <strong>linear attention</strong> using a generalized feature map $\varphi$, combined with <strong>rotary positional embeddings</strong> $R_m$ applied before the feature map:</p>
<p>$$
\text{Attention}_m(Q, K, V) = \frac{\sum_{n=1}^{N} \langle \varphi(R_m q_m), \varphi(R_n k_n) \rangle v_n}{\sum_{n=1}^{N} \langle \varphi(R_m q_m), \varphi(R_n k_n) \rangle}
$$</p>
<p>This differs from the original RoFormer formulation, which applies the rotation after the feature map. The authors found that rotating the raw queries and keys before projection led to faster convergence and lower validation loss. The combination of linear attention and adaptive sequence-length bucketing reduces GPU requirements from ~1000 to 16 for training on the full 1.1B corpus.</p>
<p>The model uses masked language modeling (15% token masking, following BERT conventions) with a vocabulary of 2,362 SMILES tokens. Sequence length is capped at 202 tokens, covering 99.4% of all molecules.</p>
<h2 id="broad-moleculenet-benchmarking-with-scaling-ablations">Broad MoleculeNet Benchmarking with Scaling Ablations</h2>
<p>MoLFormer-XL was evaluated on 11 MoleculeNet tasks against supervised GNNs, self-supervised GNNs, and prior language models.</p>
<p><strong>Classification tasks</strong> (ROC-AUC, scaffold split; values reported as percentages in the original paper, converted to proportions here for consistency):</p>
<table>
  <thead>
      <tr>
          <th>Model</th>
          <th>BBBP</th>
          <th>Tox21</th>
          <th>ClinTox</th>
          <th>HIV</th>
          <th>BACE</th>
          <th>SIDER</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>MoLFormer-XL</td>
          <td><strong>0.937</strong></td>
          <td><strong>0.847</strong></td>
          <td><strong>0.948</strong></td>
          <td>0.822</td>
          <td>0.882</td>
          <td><strong>0.690</strong></td>
      </tr>
      <tr>
          <td>N-Gram</td>
          <td>0.912</td>
          <td>0.769</td>
          <td>0.855</td>
          <td>0.830</td>
          <td>0.876</td>
          <td>0.632</td>
      </tr>
      <tr>
          <td>MolCLR</td>
          <td>0.736</td>
          <td>0.798</td>
          <td>0.932</td>
          <td>0.806</td>
          <td><strong>0.890</strong></td>
          <td>0.680</td>
      </tr>
      <tr>
          <td>GEM</td>
          <td>0.724</td>
          <td>0.781</td>
          <td>0.901</td>
          <td>0.806</td>
          <td>0.856</td>
          <td>0.672</td>
      </tr>
      <tr>
          <td>Hu et al.</td>
          <td>0.708</td>
          <td>0.787</td>
          <td>0.789</td>
          <td>0.802</td>
          <td>0.859</td>
          <td>0.652</td>
      </tr>
      <tr>
          <td>GeomGCL</td>
          <td>-</td>
          <td>0.850</td>
          <td>0.919</td>
          <td>-</td>
          <td>-</td>
          <td>0.648</td>
      </tr>
      <tr>
          <td>ChemBERTa</td>
          <td>0.643</td>
          <td>-</td>
          <td>0.906</td>
          <td>0.622</td>
          <td>-</td>
          <td>-</td>
      </tr>
  </tbody>
</table>
<p><strong>Regression tasks</strong> (RMSE for ESOL/FreeSolv/Lipophilicity, avg MAE for QM9/QM8):</p>
<table>
  <thead>
      <tr>
          <th>Model</th>
          <th>QM9</th>
          <th>QM8</th>
          <th>ESOL</th>
          <th>FreeSolv</th>
          <th>Lipophilicity</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>MoLFormer-XL</td>
          <td><strong>1.5894</strong></td>
          <td><strong>0.0102</strong></td>
          <td><strong>0.2787</strong></td>
          <td><strong>0.2308</strong></td>
          <td><strong>0.5289</strong></td>
      </tr>
      <tr>
          <td>A-FP</td>
          <td>2.6355</td>
          <td>0.0282</td>
          <td>0.5030</td>
          <td>0.736</td>
          <td>0.578</td>
      </tr>
      <tr>
          <td>MPNN</td>
          <td>3.1898</td>
          <td>0.0143</td>
          <td>0.58</td>
          <td>1.150</td>
          <td>0.7190</td>
      </tr>
      <tr>
          <td>GC</td>
          <td>4.3536</td>
          <td>0.0148</td>
          <td>0.970</td>
          <td>1.40</td>
          <td>0.655</td>
      </tr>
  </tbody>
</table>
<p>MoLFormer-XL also outperforms geometry-aware GNNs (DimeNet, GeomGCL, GEM) on ESOL (0.279 vs 0.575), FreeSolv (0.231 vs 0.866), and Lipophilicity (0.529 vs 0.541).</p>
<p><strong>Key ablation findings</strong>:</p>
<ul>
<li><strong>Data scale matters</strong>: Performance improves monotonically from 10% subsets through the full 1.1B corpus. Training on 100% ZINC alone performed worst, likely due to its smaller vocabulary and less diverse molecule lengths.</li>
<li><strong>Model depth matters</strong>: MoLFormer-Base (6 layers) underperforms MoLFormer-XL (12 layers) on most tasks.</li>
<li><strong>Fine-tuning &raquo; frozen</strong>: Fine-tuning the full encoder consistently outperforms using frozen embeddings with a downstream classifier.</li>
<li><strong>Rotary &gt; absolute at scale</strong>: Rotary embeddings underperform absolute embeddings on smaller pretraining sets but overtake them once the corpus exceeds 1B molecules.</li>
</ul>
<h2 id="smiles-transformers-learn-molecular-geometry">SMILES Transformers Learn Molecular Geometry</h2>
<p>The most striking finding is that MoLFormer&rsquo;s attention patterns correlate with 3D interatomic distances, despite training only on 1D SMILES strings.</p>
<p>Using QM9 molecules with known 3D geometries, the authors computed cosine similarity between attention maps and spatial distance matrices across three distance categories:</p>
<table>
  <thead>
      <tr>
          <th>Distance Category</th>
          <th>Range</th>
          <th>Linear Attention (Rotary)</th>
          <th>Full Attention (Rotary)</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>Short</td>
          <td>$\leq$ 2 Å</td>
          <td>0.594-0.602</td>
          <td>0.598-0.615</td>
      </tr>
      <tr>
          <td>Medium</td>
          <td>2-4 Å</td>
          <td>0.724-0.730</td>
          <td>0.716-0.727</td>
      </tr>
      <tr>
          <td>Long</td>
          <td>4-10 Å</td>
          <td>0.209-0.211</td>
          <td>0.204-0.210</td>
      </tr>
  </tbody>
</table>
<p>The strong correlation in the short and medium categories indicates the model captures covalent bond connectivity and near-neighbor spatial relationships. Linear attention shows marginally higher cosine similarity than full attention on medium-range distances (0.724-0.730 vs 0.716-0.727), though the differences are small.</p>
<p>MoLFormer-XL embeddings also correlate more strongly with molecular fingerprint similarity (0.64 vs 0.48 for ChemBERTa) and maximum common subgraph size (-0.60 vs -0.44), confirming that the representations encode structural information.</p>
<p><strong>Limitations</strong>:</p>
<ul>
<li><strong>Quantum-chemical energies</strong>: SchNet and DimeNet (which encode explicit 3D geometry) outperform MoLFormer-XL on QM9 atomization energy tasks, with DimeNet achieving roughly 10x lower MAE on U0_atom (0.008 vs 0.083 eV). 3D information remains important for these properties.</li>
<li><strong>Sequence length cap</strong>: The 202-token limit excludes 0.6% of molecules, potentially limiting applicability to larger structures.</li>
<li><strong>SMILES canonicalization</strong>: The model depends on <a href="https://en.wikipedia.org/wiki/RDKit">RDKit</a> canonical SMILES; sensitivity to non-canonical forms is not evaluated.</li>
</ul>
<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>Pretraining</td>
          <td>PubChem</td>
          <td>111M molecules</td>
          <td>Canonical SMILES via RDKit</td>
      </tr>
      <tr>
          <td>Pretraining</td>
          <td>ZINC</td>
          <td>~1B molecules</td>
          <td>Canonical SMILES via RDKit</td>
      </tr>
      <tr>
          <td>Pretraining (combined)</td>
          <td>PubChem + ZINC</td>
          <td>~1.1B molecules</td>
          <td>MoLFormer-XL training set</td>
      </tr>
      <tr>
          <td>Classification</td>
          <td>BBBP, Tox21, ClinTox, HIV, BACE, SIDER</td>
          <td>1,427-41,127</td>
          <td>MoleculeNet scaffold splits</td>
      </tr>
      <tr>
          <td>Regression</td>
          <td>QM9, QM8, ESOL, FreeSolv, Lipophilicity</td>
          <td>642-133,885</td>
          <td>MoleculeNet random splits (QM9/QM8), scaffold (others)</td>
      </tr>
  </tbody>
</table>
<h3 id="algorithms">Algorithms</h3>
<ul>
<li><strong>Pretraining objective</strong>: Masked language modeling (15% selection: 80% masked, 10% random, 10% unchanged)</li>
<li><strong>Tokenization</strong>: SMILES tokenizer from Schwaller et al., vocabulary of 2,362 tokens</li>
<li><strong>Sequence length</strong>: 1-202 tokens (99.4% coverage)</li>
<li><strong>Optimizer</strong>: Fused LAMB (via APEX), chosen for stability with large batch sizes and no need for learning rate warm-up</li>
<li><strong>Adaptive bucketing</strong>: Sequences grouped by length into buckets to minimize padding waste</li>
</ul>
<h3 id="models">Models</h3>
<ul>
<li><strong>Architecture</strong>: Transformer encoder with linear attention and rotary positional embeddings</li>
<li><strong>MoLFormer-XL</strong>: 12 layers, 12 attention heads, hidden size 768</li>
<li><strong>MoLFormer-Base</strong>: 6 layers (ablation only)</li>
<li><strong>Feature map size</strong>: 32 (generalized feature map for linear attention)</li>
<li><strong>Frozen head</strong>: Fully connected model with hyperparameter sweep (learning rate, batch size, hidden dim, number of layers)</li>
</ul>
<h3 id="evaluation">Evaluation</h3>
<table>
  <thead>
      <tr>
          <th>Metric</th>
          <th>Task Type</th>
          <th>Details</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>ROC-AUC</td>
          <td>Classification</td>
          <td>Scaffold splits per MoleculeNet</td>
      </tr>
      <tr>
          <td>RMSE</td>
          <td>Regression (ESOL, FreeSolv, Lipophilicity)</td>
          <td>Scaffold splits</td>
      </tr>
      <tr>
          <td>Avg MAE</td>
          <td>Regression (QM9, QM8)</td>
          <td>Random splits per MoleculeNet</td>
      </tr>
  </tbody>
</table>
<p>QM9 results also reported with 5-fold cross-validation for robustness.</p>
<h3 id="hardware">Hardware</h3>
<ul>
<li><strong>Compute</strong>: GPU cluster with nodes containing either 8 NVIDIA Tesla V100 (32GB) or 8 Ampere A100 (40GB) GPUs connected via NVLink and InfiniBand</li>
<li><strong>GPU reduction</strong>: Linear attention + bucketing reduced GPU requirements from ~1000 to 16</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/IBM/molformer">IBM/molformer</a></td>
          <td>Code</td>
          <td>Apache-2.0</td>
          <td>Pretraining, fine-tuning, and attention visualization</td>
      </tr>
      <tr>
          <td><a href="https://huggingface.co/ibm/MoLFormer-XL-both-10pct">MoLFormer-XL (HuggingFace)</a></td>
          <td>Model</td>
          <td>Apache-2.0</td>
          <td>Pretrained weights (46.8M parameters)</td>
      </tr>
      <tr>
          <td><a href="https://pubchem.ncbi.nlm.nih.gov/">PubChem</a></td>
          <td>Dataset</td>
          <td>Public domain</td>
          <td>111M molecules</td>
      </tr>
      <tr>
          <td><a href="https://zinc.docking.org/">ZINC</a></td>
          <td>Dataset</td>
          <td>See ZINC terms</td>
          <td>~1B molecules</td>
      </tr>
  </tbody>
</table>
<hr>
<h2 id="paper-information">Paper Information</h2>
<p><strong>Citation</strong>: Ross, J., Belgodere, B., Chenthamarakshan, V., Padhi, I., Mroueh, Y., &amp; Das, P. (2022). Large-Scale Chemical Language Representations Capture Molecular Structure and Properties. <em>Nature Machine Intelligence</em>, 4, 1256-1264. <a href="https://doi.org/10.1038/s42256-022-00580-7">https://doi.org/10.1038/s42256-022-00580-7</a></p>
<p><strong>Publication</strong>: Nature Machine Intelligence 2022</p>
<p><strong>Additional Resources</strong>:</p>
<ul>
<li><a href="https://github.com/IBM/molformer">GitHub Repository (MoLFormer)</a></li>
<li><a href="https://huggingface.co/ibm/MoLFormer-XL-both-10pct">HuggingFace Models</a></li>
</ul>
<h2 id="citation">Citation</h2>
<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">@article</span>{ross2022molformer,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">title</span>=<span style="color:#e6db74">{Large-Scale Chemical Language Representations Capture Molecular Structure and Properties}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">author</span>=<span style="color:#e6db74">{Ross, Jerret and Belgodere, Brian and Chenthamarakshan, Vijil and Padhi, Inkit and Mroueh, Youssef and Das, Payel}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">journal</span>=<span style="color:#e6db74">{Nature Machine Intelligence}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">volume</span>=<span style="color:#e6db74">{4}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">number</span>=<span style="color:#e6db74">{12}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">pages</span>=<span style="color:#e6db74">{1256--1264}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">year</span>=<span style="color:#e6db74">{2022}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">publisher</span>=<span style="color:#e6db74">{Nature Publishing Group}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">doi</span>=<span style="color:#e6db74">{10.1038/s42256-022-00580-7}</span>
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div>]]></content:encoded></item><item><title>ChemBERTa-3: Open Source Chemical Foundation Models</title><link>https://hunterheidenreich.com/notes/chemistry/molecular-representations/encoders/chemberta-3/</link><pubDate>Fri, 26 Dec 2025 00:00:00 +0000</pubDate><guid>https://hunterheidenreich.com/notes/chemistry/molecular-representations/encoders/chemberta-3/</guid><description>An open-source framework integrating DeepChem and Ray for training and benchmarking chemical foundation models like MoLFormer and GROVER at scale.</description><content:encoded><![CDATA[<h2 id="core-contribution-an-open-source-framework">Core Contribution: An Open-Source Framework</h2>
<p>This is primarily a <strong>Resource ($\Psi_{\text{Resource}}$)</strong> paper, with secondary <strong>Method ($\Psi_{\text{Method}}$)</strong> contributions.</p>
<ul>
<li><strong>Resource Basis</strong>: The core contribution is &ldquo;ChemBERTa-3,&rdquo; an open-source framework integrated into DeepChem that standardizes the pretraining and benchmarking of chemical foundation models. The authors focus heavily on infrastructure (AWS/Ray integration) and correcting benchmarking inconsistencies in the field.</li>
<li><strong>Method Basis</strong>: It trains models like &ldquo;c3-MoLFormer&rdquo; to reproduce and validate the infrastructure.</li>
</ul>
<h2 id="the-pretraining-scalability-challenge">The Pretraining Scalability Challenge</h2>
<ul>
<li><strong>Scalability Challenges</strong>: Building robust molecular models is difficult due to the vast size of chemical space and the computational intensity of pretraining on large datasets.</li>
<li><strong>Proprietary Barriers</strong>: Many high-performing chemical foundation models (e.g., the full <a href="/notes/chemistry/molecular-representations/encoders/molformer/">MoLFormer-XL</a>) are partially closed-source or difficult to reproduce.</li>
<li><strong>Benchmarking Inconsistencies</strong>: There is a lack of systematic comparison between architectures (e.g., Graph vs. Transformer) using unified protocols. Specifically, previous comparisons relied on reported results that used differing scaffold splitting algorithms, making them inaccurate.</li>
</ul>
<h2 id="unified-infrastructure--standardized-benchmarking">Unified Infrastructure &amp; Standardized Benchmarking</h2>
<ul>
<li><strong>Unified Infrastructure</strong>: Integration of DeepChem with Ray for distributed, scalable pretraining and fine-tuning of both graph and transformer models.</li>
<li><strong>Standardized Benchmarking</strong>: Identification that MoLFormer&rsquo;s scaffold splitting algorithm differs from the standard DeepChem/<a href="/notes/chemistry/molecular-design/property-prediction/moleculenet-benchmark-molecular-ml/">MoleculeNet</a> splitter, and the subsequent standardization of these benchmarks for fair comparison.</li>
<li><strong>New DeepChem Tools</strong>: Introduction of the <code>ModularTorchModel</code> class for flexible loss computation and <code>HuggingFaceModel</code> wrappers to bridge ecosystems.</li>
</ul>
<h2 id="benchmarking-transformers-vs-graph-models">Benchmarking Transformers vs. Graph Models</h2>
<ul>
<li><strong>Architecture Comparison</strong>: Benchmarked Transformers (<a href="/notes/chemistry/molecular-representations/encoders/chemberta/">ChemBERTa</a>, <a href="/notes/chemistry/molecular-representations/encoders/molformer/">MoLFormer</a>) against Graph models (GROVER, InfoGraph, InfoMax3D, DMPNN, GCN) and baselines (Random Forest).</li>
<li><strong>Pretraining Scale Disparity</strong>:
<ul>
<li>Transformers were pretrained on ZINC20 subsets ranging from 10M to 1.1B molecules (combining ZINC and PubChem).</li>
<li>Graph models were limited to 250K molecule subsets due to memory and computational overhead of message passing on large graphs. While this highlights the superior scalability of Transformer architectures, comparing a 1.1B-trained Transformer to a 250K-trained Graph model provides an unbalanced evaluation of architectural capacity.</li>
</ul>
</li>
<li><strong>Reproducibility Validation</strong>: Trained &ldquo;c3-MoLFormer&rdquo; (a reproduction of MoLFormer) on 1.1B molecules using two distinct hardware setups: AWS spot instances (Ray) and a local HPC cluster.</li>
<li><strong>Scaffold Split Analysis</strong>: Compared performance metrics using &ldquo;DeepChem scaffold splits&rdquo; vs. &ldquo;MoLFormer scaffold splits&rdquo; to quantify the impact of data leakage/overlap.</li>
</ul>
<h2 id="overcoming-scaffold-splitting-inconsistencies">Overcoming Scaffold Splitting Inconsistencies</h2>
<ul>
<li><strong>Scaling Transformers vs. Graphs</strong>: Transformer-based models are significantly easier to scale to large datasets than current graph-based approaches, though performance is comparable at small scales.</li>
<li><strong>Benchmarking sensitivity</strong>: MoLFormer&rsquo;s reported superiority over baselines was partly inflated by its specific scaffold splitting method, which had higher structural overlap between train and test sets (yielding a lower <a href="https://en.wikipedia.org/wiki/Jaccard_index">Tanimoto distance</a>, generally quantified via $1 - \frac{|A \cap B|}{|A \cup B|}$) than DeepChem splits. When standardized, baselines like DMPNN perform more competitively.</li>
<li><strong>Infrastructure Viability</strong>: The framework successfully replicated large-scale training (MoLFormer-1.1B) on both cloud and on-premise HPC, confirming reproducibility.</li>
<li><strong>Open Source Release</strong>: All code, configurations, and the c3-MoLFormer-1.1B model weights are released to facilitate future research.</li>
</ul>
<hr>
<h2 id="reproducibility-details">Reproducibility Details</h2>
<h3 id="data">Data</h3>
<ul>
<li><strong>Pretraining</strong>:
<ul>
<li><strong>Source</strong>: <a href="/notes/chemistry/datasets/zinc-22/">ZINC20</a> (1.4B compounds) and PubChem.</li>
<li><strong>Scale</strong>: Subsets of 10M, 100M, and 1.1B (100% ZINC20 + 100% PubChem) were used for Transformers. Graph models used a 250K subset.</li>
</ul>
</li>
<li><strong>Fine-tuning</strong>:
<ul>
<li><strong>Suite</strong>: MoleculeNet.</li>
<li><strong>Tasks</strong>: Classification (BACE, BBBP, Tox21, HIV, SIDER, ClinTox) and Regression (ESOL, FreeSolv, Lipophilicity, QM9).</li>
<li><strong>Splits</strong>: Critical distinction made between &ldquo;DeepChem scaffold splits&rdquo; (80/10/10) and &ldquo;MoLFormer scaffold splits&rdquo; (which can be downloaded from <a href="https://ibm.ent.box.com/v/MoLFormer-data"><code>https://ibm.ent.box.com/v/MoLFormer-data</code></a>). The paper notes these algorithms differ.</li>
</ul>
</li>
</ul>
<h3 id="algorithms">Algorithms</h3>
<ul>
<li><strong>Framework</strong>: DeepChem integrated with Ray for distributed training. To recreate the environment, the repository relies on a nightly version of DeepChem (<code>pip install --pre deepchem</code>) and specific dependencies found within the <code>requirements.txt</code>. Pretraining scripts are available in the <code>chemberta3_benchmarking/pretraining</code> directory of the repository.</li>
<li><strong>Data Preparation</strong>: Featurization workflows (e.g., <code>CircularFingerprint</code>, <code>RDKitConformer</code>) are documented under <code>chemberta3_benchmarking/data/data_preprocessing/</code> in the codebase.</li>
<li><strong>Modular Training</strong>: Uses <code>ModularTorchModel</code> to allow loss computation from intermediate values and flexible component connection.</li>
<li><strong>Training Brittleness</strong>:
<ul>
<li><strong>Optimizer</strong>: Linear learning rate scheduler with warmup.</li>
<li><strong>Instability Handling</strong>: The authors observed significant loss spikes during warmup. Their primary mitigation strategy involved checkpointing frequently and restarting from the last stable state upon a spike, highlighting a persistent brittleness in optimizing these large chemical foundation models.</li>
<li><strong>Numerical Issues</strong>: Addressed NaN values by pretraining on a small dataset with low LR before scaling up.</li>
</ul>
</li>
</ul>
<h3 id="models">Models</h3>
<ul>
<li><strong><a href="/notes/chemistry/molecular-representations/encoders/chemberta/">ChemBERTa</a></strong>: RoBERTa-based architecture trained with Masked Language Modeling (MLM) and Multitask Regression (MTR). Specific model identifiers (e.g., <a href="https://huggingface.co/DeepChem/ChemBERTa-100M-MLM"><code>DeepChem/ChemBERTa-100M-MLM</code></a>) are hosted on Hugging Face so researchers can pull them directly via the <code>transformers</code> library. The core pretraining objective minimized the standard MLM loss:
$$ \mathcal{L}_{\text{MLM}} = - \frac{1}{|\mathcal{M}|} \sum_{i \in \mathcal{M}} \log \hat{y}_{i} $$
where $\mathcal{M}$ represents the set of masked SMILES token indices, and $\hat{y}_{i}$ is the model&rsquo;s predicted probability for the correct token given the corrupted sequence context.</li>
<li><strong>MoLFormer (c3-MoLFormer)</strong>: Re-implementation of the MoLFormer architecture (Rotary embeddings, linear attention). Specific model identifiers (e.g., <a href="https://huggingface.co/DeepChem/MoLFormer-c3-1.1B"><code>DeepChem/MoLFormer-c3-1.1B</code></a>) are similarly available on Hugging Face.
<ul>
<li>Tokenizer: <code>ibm/MoLFormer-XL-both-10pct</code> tokenizer.</li>
</ul>
</li>
<li><strong>Graph Models</strong>:
<ul>
<li><strong>GROVER</strong>: Graph Transformer with node/edge/graph level self-supervision.</li>
<li><strong>InfoGraph</strong>: Maximizes mutual information between graph-level and substructure representations.</li>
<li><strong>InfoMax3D</strong>: Incorporates 3D conformer data (via <a href="https://en.wikipedia.org/wiki/RDKit">RDKit</a> ETKDGv2) into contrastive pretraining.</li>
<li><strong>DMPNN</strong>: Directed Message Passing Neural Network (Chemprop variant).</li>
</ul>
</li>
</ul>
<h3 id="evaluation">Evaluation</h3>
<ul>
<li><strong>Metrics</strong>: <a href="https://en.wikipedia.org/wiki/Receiver_operating_characteristic">ROC-AUC</a> for classification; RMSE for regression (MAE for QM9).</li>
<li><strong>Baselines</strong>: Random Forest, GCN, DMPNN trained on fine-tuning splits only.</li>
<li><strong>Protocol</strong>: Three independent runs per configuration to report mean and range (not a confidence interval), with the exception of the compute-heavy QM9 dataset, which only received a single run. Benchmarking execution scripts (e.g., GCN, RF, DMPNN, ChemBERTa) are stored in the repo under <code>chemberta3_benchmarking/models_benchmarking/</code> and contain the specific fine-tuning hyperparameters and optimizer configurations used for each downstream task.</li>
<li><strong>Key Results</strong>:
<ul>
<li><em>c3-MoLFormer-1.1B</em> achieved ~0.848 ROC-AUC on BACE and ~0.900 on BBBP (using MoLFormer splits). This closely matches the original IBM MoLFormer metrics, validating the reproducibility of the open-source framework.</li>
<li>When constrained to the equivalent 250K subset, Graph models (InfoGraph, GROVER) performed comparably to Transformers, indicating that Transformer superiority in chemistry is largely driven by data scalability rather than an inherent architectural advantage at small scales.</li>
</ul>
</li>
</ul>
<h3 id="hardware">Hardware</h3>
<ul>
<li><strong>Cloud (AWS)</strong>:
<ul>
<li><strong>Compute</strong>: 40 NVIDIA T4 GPUs (<code>g4dn.12xlarge</code> spot instances for pretraining, <code>g4dn.2xlarge</code> for benchmarking).</li>
<li><strong>Cost</strong>: ~$4000 for MoLFormer 1.1B pretraining.</li>
<li><strong>Time</strong>: ~10 days (260 hours) for 1.1B model pretraining.</li>
<li><strong>Setup</strong>: Setup scripts for single-node and multi-node spot EC2 clusters are provided in the GitHub repository&rsquo;s <code>infra/</code> and <code>spot/</code> folders.</li>
</ul>
</li>
<li><strong>On-Premise HPC</strong>:
<ul>
<li><strong>Compute</strong>: 16 nodes (AMD EPYC), each with 4 AMD MI300A APUs.</li>
<li><strong>Environment</strong>: Ray multi-node multi-GPU framework.</li>
</ul>
</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/deepforestsci/chemberta3">ChemBERTa-3 GitHub Repository</a></td>
          <td>Code</td>
          <td>Unknown</td>
          <td>Training, fine-tuning, and benchmarking framework</td>
      </tr>
      <tr>
          <td><a href="https://huggingface.co/DeepChem/MoLFormer-c3-1.1B">DeepChem/MoLFormer-c3-1.1B</a></td>
          <td>Model</td>
          <td>Unknown</td>
          <td>MoLFormer re-implementation pretrained on 1.1B molecules</td>
      </tr>
      <tr>
          <td><a href="https://huggingface.co/DeepChem/ChemBERTa-100M-MLM">DeepChem/ChemBERTa-100M-MLM</a></td>
          <td>Model</td>
          <td>Unknown</td>
          <td>ChemBERTa pretrained on 100M ZINC molecules</td>
      </tr>
      <tr>
          <td><a href="https://huggingface.co/DeepChem/MoLFormer-c3-100M">DeepChem/MoLFormer-c3-100M</a></td>
          <td>Model</td>
          <td>Unknown</td>
          <td>MoLFormer pretrained on 100M molecules</td>
      </tr>
      <tr>
          <td><a href="https://huggingface.co/DeepChem/MoLFormer-c3-550M">DeepChem/MoLFormer-c3-550M</a></td>
          <td>Model</td>
          <td>Unknown</td>
          <td>MoLFormer pretrained on 550M molecules</td>
      </tr>
  </tbody>
</table>
<h2 id="paper-information">Paper Information</h2>
<p><strong>Citation</strong>: Singh, R. et al. (2026). ChemBERTa-3: an open source training framework for chemical foundation models. <em>Digital Discovery</em>, 5, 662-685. <a href="https://doi.org/10.1039/D5DD00348B">https://doi.org/10.1039/D5DD00348B</a></p>
<p><strong>Publication</strong>: Digital Discovery 2026</p>
<p><strong>Additional Resources</strong>:</p>
<ul>
<li><a href="https://github.com/deepforestsci/chemberta3">ChemBERTa-3 GitHub Repository</a></li>
<li><a href="https://deepchem.io/">DeepChem Project</a></li>
<li><a href="https://huggingface.co/DeepChem">DeepChem Hugging Face Models</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">@article</span>{singhChemBERTa3OpenSource2026,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">author</span> = <span style="color:#e6db74">{Singh, Riya and Barsainyan, Aryan Amit and Irfan, Rida and Amorin, Connor Joseph and He, Stewart and Davis, Tony and Thiagarajan, Arun and Sankaran, Shiva and Chithrananda, Seyone and Ahmad, Walid and Jones, Derek and McLoughlin, Kevin and Kim, Hyojin and Bhutani, Anoushka and Sathyanarayana, Shreyas Vinaya and Viswanathan, Venkat and Allen, Jonathan E. and Ramsundar, Bharath}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">title</span> = <span style="color:#e6db74">{{{ChemBERTa-3}}: an open source training framework for chemical foundation models}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">journal</span> = <span style="color:#e6db74">{Digital Discovery}</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">volume</span> = <span style="color:#e6db74">{5}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">pages</span> = <span style="color:#e6db74">{662-685}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">publisher</span> = <span style="color:#e6db74">{The Royal Society of Chemistry}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">doi</span> = <span style="color:#e6db74">{10.1039/D5DD00348B}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">url</span> = <span style="color:#e6db74">{https://doi.org/10.1039/D5DD00348B}</span>
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div>]]></content:encoded></item><item><title>ChemBERTa-2: Scaling Molecular Transformers to 77M</title><link>https://hunterheidenreich.com/notes/chemistry/molecular-representations/encoders/chemberta-2/</link><pubDate>Thu, 25 Dec 2025 00:00:00 +0000</pubDate><guid>https://hunterheidenreich.com/notes/chemistry/molecular-representations/encoders/chemberta-2/</guid><description>Optimizing transformer pretraining for molecules using MLM vs MTR objectives, scaling to 77M compounds from PubChem for improved property prediction.</description><content:encoded><![CDATA[<h2 id="classifying-chemberta-2s-methodological-contributions">Classifying ChemBERTa-2&rsquo;s Methodological Contributions</h2>
<p>This is primarily a <strong>Methodological</strong> paper with a secondary <strong>Resource</strong> contribution.</p>
<p>It fits the Method classification because it focuses on optimizing the architecture and pretraining pipeline for molecular transformers. The authors perform extensive ablation studies (varying dataset size from 5M to 77M, comparing MLM vs. MTR objectives) to determine &ldquo;how well&rdquo; these strategies work compared to baselines. The secondary Resource classification applies because they open-source the trained models and establish a benchmark on a massive 77M compound dataset.</p>
<p><strong>Key methodological indicators</strong>:</p>
<ul>
<li><strong>Baseline comparison</strong>: The paper explicitly compares ChemBERTa-2 against standard baselines (D-MPNN, Random Forest, GCN) and its predecessor (<a href="/notes/chemistry/molecular-representations/encoders/chemberta/">ChemBERTa-1</a>) with prominent benchmark tables</li>
<li><strong>Ablation studies</strong>: Extensive experiments comparing multi-task and self-supervised pretraining by varying hyperparameters and pretraining dataset size</li>
<li><strong>Scaling analysis</strong>: Systematic investigation of whether larger datasets (up to 77M compounds) yield better performance</li>
</ul>
<h2 id="motivations-for-scaling-molecular-transformers">Motivations for Scaling Molecular Transformers</h2>
<p>The authors aim to bridge the gap between NLP success stories (like GPT-3) and molecular machine learning by developing a &ldquo;chemical foundation model&rdquo;.</p>
<p><strong>Key motivations</strong>:</p>
<ul>
<li><strong>Label scarcity</strong>: Experimental labels for molecular properties are rare and expensive, but unlabeled SMILES strings are abundant</li>
<li><strong>Scaling hypothesis</strong>: Testing if scaling pretraining data (up to 77M compounds) yields consistent downstream improvements, similar to scaling laws in NLP</li>
<li><strong>Efficiency</strong>: Optimizing the pretraining process introduced in the original ChemBERTa by comparing self-supervised (MLM) and weakly supervised (MTR, using <a href="https://en.wikipedia.org/wiki/RDKit">RDKit</a> computed properties as labels) approaches</li>
</ul>
<h2 id="novelty-in-multi-task-regression-objectives">Novelty in Multi-Task Regression Objectives</h2>
<p><strong>Scale</strong>: Training on 77M unique SMILES from PubChem, which is one of the largest molecular pretraining datasets used to date (compared to 10M for ChemBERTa-1 or 18.7M for <a href="/notes/chemistry/molecular-representations/encoders/smiles-bert/">SMILES-BERT</a>).</p>
<p><strong>Pipeline optimization</strong>: A direct, controlled comparison of <strong>Masked Language Modeling (MLM)</strong> vs. <strong>Multi-Task Regression (MTR)</strong> pretraining objectives on identical datasets.</p>
<p><strong>Proxy selection</strong>: The finding that MLM loss correlates well with MTR loss, allowing the cheaper MLM task to be used for hyperparameter tuning before running the expensive MTR pretraining.</p>
<h2 id="experimental-pretraining-setup-on-77m-compounds">Experimental Pretraining Setup on 77M Compounds</h2>
<h3 id="pretraining-setup">Pretraining Setup</h3>
<p><strong>Datasets</strong>: Subsets of <a href="https://en.wikipedia.org/wiki/PubChem">PubChem</a> containing 5M, 10M, and 77M unique SMILES.</p>
<p><strong>Tasks</strong>:</p>
<ul>
<li><strong>MLM</strong>: Masking 15% of tokens (following RoBERTa procedure). The model is optimized by minimizing the cross-entropy loss over the predicted masked tokens:
$$ \mathcal{L}_{MLM} = -\sum_{i \in \mathcal{M}} \log P(x_i \mid \mathbf{x}_{\setminus \mathcal{M}}) $$
where $\mathcal{M}$ represents the set of masked token indices.</li>
<li><strong>MTR</strong>: Predicting 200 calculated molecular properties (via RDKit) simultaneously using a mean squared error objective:
$$ \mathcal{L}_{MTR} = \frac{1}{200} \sum_{j=1}^{200} \frac{1}{N} \sum_{i=1}^{N} \left( \hat{y}_{ij} - y_{ij} \right)^2 $$
Continuous target labels $y_{ij}$ are mean-normalized prior to training to equilibrate the disparate scales of different chemical properties.</li>
</ul>
<p><strong>Hyperparameter search</strong>: Ran 50 random configurations on the 5M dataset; selected the top 5 to scale up to 10M and 77M.</p>
<h3 id="downstream-validation">Downstream Validation</h3>
<p><strong>Finetuning</strong>: Evaluated on 8 tasks from <strong><a href="/notes/chemistry/molecular-design/property-prediction/moleculenet-benchmark-molecular-ml/">MoleculeNet</a></strong> (BACE, BBBP, ClinTox, Delaney, etc.) using scaffold splits (80/10/10).</p>
<p><strong>Analysis</strong>: Used UMAP to visualize embeddings from MLM, MTR, and ECFP to check for clustering by label without finetuning.</p>
<h2 id="key-performance-outcomes-and-scaling-realities">Key Performance Outcomes and Scaling Realities</h2>
<p><strong>Highly competitive performance</strong>: ChemBERTa-2 outperforms the D-MPNN baseline (chemprop) on 6 out of 8 MoleculeNet tasks, though the margins demonstrate that task-specific baselines remain notably robust.</p>
<p><strong>MTR superiority</strong>: Models pretrained on Multi-Task Regression (MTR) consistently perform better on downstream tasks than those pretrained on MLM on every finetuning task evaluated. MTR is substantially slower than MLM due to the larger input size from the 200-element label vector, but MLM loss serves as a reliable proxy for MTR loss, enabling cheaper architecture search before committing to full MTR pretraining.</p>
<p><strong>Scaling laws versus downstream utility</strong>: Pretraining loss improved by 25-35% when increasing the dataset from 5M to 77M compounds. However, this improvement in pretraining loss does not uniformly transfer to downstream tasks. For MTR models, SR-p53 ROC-AUC decreases monotonically from 0.834 (5M) to 0.827 (10M) to 0.817 (77M), and Lipophilicity RMSE is worse at 77M (0.798) than at 5M (0.758), despite a dip at 10M (0.744). This variability in transfer challenges the assumption that pretraining improvements always yield downstream gains.</p>
<p><strong>Transfer learning</strong>: The correlation between pretraining loss and downstream performance is task-dependent; it is strong for Lipophilicity but weaker for BACE classification.</p>
<h2 id="reproducibility-details">Reproducibility Details</h2>
<h3 id="data">Data</h3>
<p>The pretraining corpus is derived from <strong>PubChem</strong>.</p>
<table>
  <thead>
      <tr>
          <th>Purpose</th>
          <th>Dataset</th>
          <th>Size</th>
          <th>Notes</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td><strong>Pretraining</strong></td>
          <td>PubChem</td>
          <td>77M SMILES</td>
          <td>Canonicalized and globally shuffled. Subsets of 5M and 10M used. <strong>Note: Exact splits and datasets are not published.</strong></td>
      </tr>
      <tr>
          <td><strong>Validation</strong></td>
          <td>PubChem</td>
          <td>100k SMILES</td>
          <td>A fixed set held out from the 77M corpus. <strong>Note: Exact 100k subset is not published.</strong></td>
      </tr>
      <tr>
          <td><strong>MTR Labels</strong></td>
          <td>RDKit</td>
          <td>200 props</td>
          <td>200 molecular properties calculated from SMILES using RDKit. Labels are mean-normalized. <strong>Note: Calculated labels are not published and must be re-computed.</strong></td>
      </tr>
      <tr>
          <td><strong>Finetuning</strong></td>
          <td>MoleculeNet</td>
          <td>1.5k - 8k</td>
          <td>Tasks: BACE, Clearance, Delaney, Lipophilicity, BBBP, ClinTox, HIV, Tox21. Split 80/10/10 via scaffold splitter.</td>
      </tr>
  </tbody>
</table>
<h3 id="algorithms">Algorithms</h3>
<p><strong>Pretraining Objectives:</strong></p>
<ol>
<li><strong>Masked Language Modeling (MLM)</strong>: Follows RoBERTa procedure. Masks 15% of tokens. Max sequence length 512.</li>
<li><strong>Multi-Task Regression (MTR)</strong>: Predicting 200 RDKit properties. Labels are mean-normalized.</li>
</ol>
<p><strong>Tokenizer:</strong></p>
<ul>
<li>Dictionary of common SMILES characters</li>
<li>Maximum vocabulary size: <strong>591 tokens</strong></li>
</ul>
<p><strong>Optimization:</strong></p>
<ul>
<li><strong>Patience</strong>: Early stopping set to one pass through the dataset to ensure full coverage</li>
<li><strong>Hyperparameter search</strong>: Random search (50 configs) varying hidden size, attention heads, dropout, intermediate size, hidden layers, and learning rate. <strong>Note: The precise configuration of the winning models that were scaled to 77M is absent from the paper.</strong></li>
</ul>
<h3 id="models">Models</h3>
<ul>
<li><strong>Architecture</strong>: Based on <strong>RoBERTa</strong> (HuggingFace implementation)</li>
<li><strong>Parameter scale</strong>: Models ranged between <strong>5M and 46M parameters</strong></li>
<li><strong>Selection</strong>: Top 5 configurations from the 5M-dataset random search were trained on the full 77M dataset</li>
<li><strong>Checkpoints</strong>: Pre-trained weights are hosted by DeepChem on <a href="https://huggingface.co/DeepChem">Hugging Face</a>. Direct links include <a href="https://huggingface.co/DeepChem/ChemBERTa-77M-MTR">DeepChem/ChemBERTa-77M-MTR</a> and <a href="https://huggingface.co/DeepChem/ChemBERTa-77M-MLM">DeepChem/ChemBERTa-77M-MLM</a> (Note: Model cards are currently empty).</li>
<li><strong>Code Reference</strong>: While the <a href="https://github.com/deepchem/deepchem">DeepChem</a> repository is referenced for code, isolated training scripts tailored to recreate ChemBERTa-2&rsquo;s exact pipeline are not separated from the generalized deepchem library tooling.</li>
</ul>
<h3 id="evaluation">Evaluation</h3>
<p>Benchmarks were performed on <strong>MoleculeNet</strong> using DeepChem.</p>
<table>
  <thead>
      <tr>
          <th>Metric</th>
          <th>Tasks</th>
          <th>Baseline</th>
          <th>Notes</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td><strong>RMSE</strong> ($\downarrow$)</td>
          <td>Delaney, Lipo, BACE (Reg), Clearance</td>
          <td>D-MPNN</td>
          <td>ChemBERTa-2 outperformed D-MPNN on Delaney (0.889 vs 1.105) and Clearance (48.5 vs 49.8).</td>
      </tr>
      <tr>
          <td><strong>ROC-AUC</strong> ($\uparrow$)</td>
          <td>BBBP, ClinTox, HIV, Tox21, BACE (Cls)</td>
          <td>D-MPNN</td>
          <td>ChemBERTa-2 generally competitive; MTR-77M achieved 0.728 on BBBP vs D-MPNN 0.697.</td>
      </tr>
  </tbody>
</table>
<h3 id="hardware">Hardware</h3>
<ul>
<li><strong>Compute</strong>: AWS EC2 instances with <strong>Nvidia T4 GPUs</strong></li>
<li><strong>Strategy</strong>: AWS Spot instances were used to reduce cost; implemented frequent checkpointing to handle interruptions.</li>
<li><strong>Note</strong>: For MTR, they wrote a custom data loader wrapper around HuggingFace&rsquo;s text loader to handle CSV parsing efficiency, as the default CSV loader was a major bottleneck for the 200-element target vectors.</li>
</ul>
<h2 id="paper-information">Paper Information</h2>
<p><strong>Citation</strong>: Ahmad, W., Simon, E., Chithrananda, S., Grand, G., &amp; Ramsundar, B. (2022). ChemBERTa-2: Towards Chemical Foundation Models. <em>arXiv preprint arXiv:2209.01712</em>. <a href="https://doi.org/10.48550/arXiv.2209.01712">https://doi.org/10.48550/arXiv.2209.01712</a></p>
<p><strong>Publication</strong>: arXiv 2022 (Presented at 2021 ELLIS ML for Molecule Discovery Workshop)</p>
<p><strong>Additional Resources</strong>:</p>
<ul>
<li><a href="/notes/chemistry/molecular-representations/encoders/chemberta/">ChemBERTa-1 Paper</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>{ahmadChemBERTa2ChemicalFoundation2022,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">title</span> = <span style="color:#e6db74">{{{ChemBERTa-2}}: {{Towards Chemical Foundation Models}}}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">shorttitle</span> = <span style="color:#e6db74">{{{ChemBERTa-2}}}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">author</span> = <span style="color:#e6db74">{Ahmad, Walid and Simon, Elana and Chithrananda, Seyone and Grand, Gabriel and Ramsundar, Bharath}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">year</span> = <span style="color:#ae81ff">2022</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">month</span> = sep,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">number</span> = <span style="color:#e6db74">{arXiv:2209.01712}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">eprint</span> = <span style="color:#e6db74">{2209.01712}</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.2209.01712}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">urldate</span> = <span style="color:#e6db74">{2025-12-25}</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><item><title>ChemBERTa: Molecular Property Prediction via Transformers</title><link>https://hunterheidenreich.com/notes/chemistry/molecular-representations/encoders/chemberta/</link><pubDate>Tue, 23 Dec 2025 00:00:00 +0000</pubDate><guid>https://hunterheidenreich.com/notes/chemistry/molecular-representations/encoders/chemberta/</guid><description>A systematic evaluation of RoBERTa transformers pretrained on 77M PubChem SMILES for molecular property prediction tasks.</description><content:encoded><![CDATA[<h2 id="taxonomy-and-paper-contributions">Taxonomy and Paper Contributions</h2>
<p>This is primarily a <strong>Method</strong> paper ($\Psi_{\text{Method}}$), with a significant <strong>Resource</strong> component ($\Psi_{\text{Resource}}$).</p>
<p>It is a methodological investigation because it systematically evaluates a specific architecture (Transformers/RoBERTa) against established State-of-the-Art (SOTA) baselines like directed Message Passing Neural Networks (D-MPNNs) to determine &ldquo;how well does this work?&rdquo; in the chemical domain. It ablates dataset size, tokenization, and input representation.</p>
<p>It is also a resource paper as it introduces &ldquo;PubChem-77M,&rdquo; a curated dataset of 77 million SMILES strings designed to facilitate large-scale self-supervised pretraining for the community.</p>
<h2 id="overcoming-data-scarcity-in-property-prediction">Overcoming Data Scarcity in Property Prediction</h2>
<p>The primary motivation is <strong>data scarcity</strong> in molecular property prediction. Graph Neural Networks (GNNs) achieve strong performance on property prediction tasks when provided with sufficient labeled data. Generating these labels requires costly and time-consuming laboratory testing, leading to severe data scarcity in specialized chemical domains.</p>
<p>Massive quantities of <strong>unlabeled chemical structure data</strong> exist in the form of <a href="/notes/chemistry/molecular-representations/notations/smiles/">SMILES</a> strings. Inspired by the success of Transformers in NLP, where self-supervised pretraining on large corpora yields strong transfer learning, the authors aim to use these unlabeled datasets to learn effective molecular representations. Additionally, Transformers benefit from a mature software ecosystem (HuggingFace) that offers efficiency advantages over GNNs.</p>
<h2 id="pretraining-scaling-laws-and-novelty">Pretraining Scaling Laws and Novelty</h2>
<p>Previous works applied Transformers to SMILES strings. This paper advances the field by systematically evaluating scaling laws and architectural components for this domain. Specifically:</p>
<ul>
<li><strong>Scaling Analysis</strong>: It explicitly tests how pretraining dataset size (100K to 10M) impacts downstream performance.</li>
<li><strong>Tokenizer Comparison</strong>: It compares standard NLP <a href="https://en.wikipedia.org/wiki/Byte-pair_encoding">Byte-Pair Encoding (BPE)</a> against a chemically-aware &ldquo;SmilesTokenizer&rdquo;.</li>
<li><strong>Representation Comparison</strong>: It evaluates if the robust <a href="/notes/chemistry/molecular-representations/notations/selfies/">SELFIES</a> string representation offers advantages over standard SMILES in a Transformer context.</li>
</ul>
<h2 id="experimental-setup-pretraining-and-finetuning">Experimental Setup: Pretraining and Finetuning</h2>
<p>The authors trained <strong>ChemBERTa</strong> (based on RoBERTa) using Masked Language Modeling (MLM) on subsets of the <a href="https://en.wikipedia.org/wiki/PubChem">PubChem</a> dataset. The core training objective minimizes the cross-entropy loss over a corrupted input where a subset of basic tokens, denoted by $\mathcal{M}$, are masked:</p>
<p>$$
\mathcal{L}_{\text{MLM}} = - \frac{1}{|\mathcal{M}|} \sum_{i \in \mathcal{M}} \log P(x_i \mid x_{\setminus \mathcal{M}}; \theta)
$$</p>
<p>where $x_i$ is the exact masked token, $x_{\setminus \mathcal{M}}$ is the corrupted SMILES context string, and $\theta$ represents the network parameters.</p>
<ul>
<li><strong>Pretraining</strong>: Models were pretrained on dataset sizes of 100K, 250K, 1M, and 10M compounds.</li>
<li><strong>Baselines</strong>: Performance was compared against D-MPNN (Graph Neural Network), Random Forest (RF), and SVM using 2048-bit Morgan Fingerprints.</li>
<li><strong>Downstream Tasks</strong>: Finetuning was performed individually on small <a href="/notes/chemistry/molecular-design/property-prediction/moleculenet-benchmark-molecular-ml/">MoleculeNet</a> classification tasks: BBBP (<a href="https://en.wikipedia.org/wiki/Blood%E2%80%93brain_barrier">blood-brain barrier</a>), ClinTox (clinical toxicity), HIV, and Tox21 (p53 stress-response). This poses a transfer learning challenge, as the model must adapt from pretraining on 10 million molecules to classifying datasets ranging from ~1.5K to ~41K examples.</li>
<li><strong>Ablations</strong>:
<ul>
<li><strong>Tokenization</strong>: BPE vs. SmilesTokenizer on the 1M dataset, evaluated on Tox21.</li>
<li><strong>Input</strong>: SMILES vs. SELFIES strings on the Tox21 task.</li>
</ul>
</li>
</ul>
<h2 id="results-vs-graph-neural-network-baselines">Results vs. Graph Neural Network Baselines</h2>
<p>The main comparison between ChemBERTa (pretrained on 10M compounds) and Chemprop baselines on MoleculeNet tasks is summarized below (Table 1 from the paper):</p>
<table>
  <thead>
      <tr>
          <th>Model</th>
          <th>BBBP ROC</th>
          <th>BBBP PRC</th>
          <th>ClinTox ROC</th>
          <th>ClinTox PRC</th>
          <th>HIV ROC</th>
          <th>HIV PRC</th>
          <th>Tox21 ROC</th>
          <th>Tox21 PRC</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>ChemBERTa 10M</td>
          <td>0.643</td>
          <td>0.620</td>
          <td>0.733</td>
          <td>0.975</td>
          <td>0.622</td>
          <td>0.119</td>
          <td>0.728</td>
          <td>0.207</td>
      </tr>
      <tr>
          <td>D-MPNN</td>
          <td>0.708</td>
          <td>0.697</td>
          <td>0.906</td>
          <td>0.993</td>
          <td>0.752</td>
          <td>0.152</td>
          <td>0.688</td>
          <td>0.429</td>
      </tr>
      <tr>
          <td>RF</td>
          <td>0.681</td>
          <td>0.692</td>
          <td>0.693</td>
          <td>0.968</td>
          <td>0.780</td>
          <td>0.383</td>
          <td>0.724</td>
          <td>0.335</td>
      </tr>
      <tr>
          <td>SVM</td>
          <td>0.702</td>
          <td>0.724</td>
          <td>0.833</td>
          <td>0.986</td>
          <td>0.763</td>
          <td>0.364</td>
          <td>0.708</td>
          <td>0.345</td>
      </tr>
  </tbody>
</table>
<ul>
<li><strong>Scaling Improvements &amp; Training Dynamics</strong>: Performance scales predictably with pretraining data size. Increasing data from 100K to 10M improved ROC-AUC by +0.110 and PRC-AUC by +0.059 on average across BBBP, ClinTox, and Tox21 (HIV was omitted due to resource constraints). Notably, researchers had to halt pretraining on the 10M subset after just 3 epochs due to overfitting, suggesting that simple 15% token masking might not provide a sufficiently difficult learning curvature for large-scale chemical representation.</li>
<li><strong>Performance Limits vs. GNNs</strong>: ChemBERTa generally performs below the D-MPNN baseline. On the Tox21 dataset, ChemBERTa-10M achieved a higher ROC-AUC (0.728) than D-MPNN (0.688); nonetheless, it recorded a substantially lower PRC-AUC (0.207 vs 0.429). This gap indicates that current Transformer iterations lack the explicit inductive biases of graph algorithms and struggle with the severe class imbalances typical of chemical datasets.</li>
<li><strong>Ablation Limitations (Tokenization &amp; SELFIES)</strong>: The authors&rsquo; ablation studies for tokenization (SmilesTokenizer narrowly beating BPE) and input representation (SELFIES performing comparably to SMILES) were evaluated exclusively on the single Tox21 task. Deriving broad architectural conclusions regarding &ldquo;semantically-aware tokenization&rdquo; or string robustness from an $N=1$ empirical evaluation is a significant limitation of the study. Broader benchmarking is required to validate these findings.</li>
<li><strong>Interpretability</strong>: Attention heads organically learn to track chemically relevant substructures (like specific functional groups and aromatic rings), mimicking the inductive biases of graph convolutions.</li>
</ul>
<hr>
<h2 id="reproducibility-details">Reproducibility Details</h2>
<h3 id="data">Data</h3>
<p>The authors curated a massive dataset for pretraining and utilized standard benchmarks for evaluation.</p>
<ul>
<li><strong>Pretraining Data</strong>: <strong>PubChem-77M</strong>.
<ul>
<li>Source: 77 million unique SMILES from PubChem.</li>
<li>Preprocessing: Canonicalized and globally shuffled.</li>
<li>Subsets used: 100K, 250K, 1M, and 10M subsets.</li>
<li><em>Availability Note</em>: The authors provided a direct link to the <a href="https://deepchemdata.s3-us-west-1.amazonaws.com/datasets/pubchem_10m.txt.zip">canonicalized 10M compound subset</a> used for their largest experiments. Full reproducibility of the smaller (100K, 250K, 1M) or full 77M sets may require re-extracting from PubChem.</li>
</ul>
</li>
<li><strong>Evaluation Data</strong>: <strong>MoleculeNet</strong>.
<ul>
<li>Tasks: BBBP (2,039), ClinTox (1,478), HIV (41,127), Tox21 (7,831).</li>
<li>Splitting: 80/10/10 train/valid/test split using a <strong>scaffold splitter</strong> to ensure chemical diversity between splits.</li>
</ul>
</li>
</ul>
<h3 id="algorithms">Algorithms</h3>
<p>The core training methodology mirrors standard BERT/RoBERTa procedures adapted for chemical strings.</p>
<ul>
<li><strong>Objective</strong>: Masked Language Modeling (MLM) with <strong>15% token masking</strong>.</li>
<li><strong>Tokenization</strong>:
<ul>
<li><strong>BPE</strong>: Byte-Pair Encoder (vocab size 52K).</li>
<li><strong>SmilesTokenizer</strong>: Regex-based custom tokenizer available in DeepChem (documented <a href="https://deepchem.readthedocs.io/en/latest/tokenizers.html#smilestokenizer">here</a>).</li>
</ul>
</li>
<li><strong>Sequence Length</strong>: Maximum sequence length of <strong>512 tokens</strong>.</li>
<li><strong>Finetuning</strong>: Appended a linear classification layer; backpropagated through the base model for up to 25 epochs with early stopping on ROC-AUC.</li>
</ul>
<h3 id="models">Models</h3>
<ul>
<li><strong>Architecture</strong>: <strong>RoBERTa</strong> (via HuggingFace).
<ul>
<li>Layers: 6</li>
<li>Attention Heads: 12 (72 distinct mechanisms total).</li>
<li><em>Implementation Note</em>: The original training notebooks and scripts are maintained in the authors&rsquo; <a href="https://github.com/seyonechithrananda/bert-loves-chemistry">bert-loves-chemistry repository</a>, alongside the primary downstream tasks integrated into DeepChem. A <a href="https://github.com/deepchem/deepchem/blob/master/examples/tutorials/Transfer_Learning_With_ChemBERTa_Transformers.ipynb">full Tox21 transfer learning tutorial</a> has been incorporated into the DeepChem repository.</li>
</ul>
</li>
<li><strong>Baselines</strong> (via Chemprop library):
<ul>
<li><strong>D-MPNN</strong>: Directed Message Passing Neural Network with default hyperparameters.</li>
<li><strong>RF/SVM</strong>: Scikit-learn Random Forest and SVM using 2048-bit Morgan fingerprints (<a href="https://en.wikipedia.org/wiki/RDKit">RDKit</a>).</li>
</ul>
</li>
</ul>
<h3 id="evaluation">Evaluation</h3>
<p>Performance is measured using dual metrics to account for class imbalance common in toxicity datasets.</p>
<table>
  <thead>
      <tr>
          <th>Metric</th>
          <th>Details</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td><strong>ROC-AUC</strong></td>
          <td>Area Under Receiver Operating Characteristic Curve</td>
      </tr>
      <tr>
          <td><strong>PRC-AUC</strong></td>
          <td>Area Under Precision-Recall Curve (vital for imbalanced data)</td>
      </tr>
  </tbody>
</table>
<h3 id="hardware">Hardware</h3>
<ul>
<li><strong>Compute</strong>: Single <strong>NVIDIA V100 GPU</strong>.</li>
<li><strong>Training Time</strong>: Approximately <strong>48 hours</strong> for the 10M compound subset.</li>
<li><strong>Carbon Footprint</strong>: Estimated 17.1 kg $\text{CO}_2\text{eq}$ (offset by Google Cloud).</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/seyonechithrananda/bert-loves-chemistry">bert-loves-chemistry</a></td>
          <td>Code</td>
          <td>MIT</td>
          <td>Training notebooks and finetuning scripts</td>
      </tr>
      <tr>
          <td><a href="https://github.com/deepchem/deepchem">DeepChem</a></td>
          <td>Code</td>
          <td>MIT</td>
          <td>Integration of ChemBERTa and SmilesTokenizer</td>
      </tr>
      <tr>
          <td><a href="https://huggingface.co/seyonec/ChemBERTa-zinc-base-v1">ChemBERTa-zinc-base-v1</a></td>
          <td>Model</td>
          <td>Unknown</td>
          <td>Pre-trained RoBERTa on 100K ZINC SMILES</td>
      </tr>
      <tr>
          <td><a href="https://deepchemdata.s3-us-west-1.amazonaws.com/datasets/pubchem_10m.txt.zip">PubChem-10M subset</a></td>
          <td>Dataset</td>
          <td>Unknown</td>
          <td>Canonicalized 10M compound subset used for largest experiments</td>
      </tr>
  </tbody>
</table>
<p><strong>Reproducibility status</strong>: Partially Reproducible. Code and pre-trained models are available, and the 10M pretraining subset is downloadable. However, smaller subsets (100K, 250K, 1M) may need re-extraction from PubChem, and exact hyperparameter details for finetuning (learning rate, batch size) are not fully specified in the paper.</p>
<hr>
<h2 id="paper-information">Paper Information</h2>
<p><strong>Citation</strong>: Chithrananda, S., Grand, G., &amp; Ramsundar, B. (2020). ChemBERTa: Large-Scale Self-Supervised Pretraining for Molecular Property Prediction. <em>arXiv preprint arXiv:2010.09885</em>. <a href="https://doi.org/10.48550/arXiv.2010.09885">https://doi.org/10.48550/arXiv.2010.09885</a></p>
<p><strong>Publication</strong>: arXiv 2020 (Preprint)</p>
<p><strong>Additional Resources</strong>:</p>
<ul>
<li><a href="https://huggingface.co/seyonec/ChemBERTa-zinc-base-v1">HuggingFace Model Hub (ChemBERTa-zinc-base-v1)</a> - <em>Additional pre-trained variations on PubChem &amp; ZINC datasets are available on the author&rsquo;s <a href="https://huggingface.co/seyonec">seyonec</a> HF profile.</em></li>
<li><a href="https://github.com/seyonechithrananda/bert-loves-chemistry">bert-loves-chemistry GitHub Repository</a> - <em>Notebooks and scripts used for MLM pretraining and finetuning evaluations.</em></li>
</ul>
<h3 id="bibtex">BibTeX</h3>
<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>{chithranandaChemBERTaLargeScaleSelfSupervised2020,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">title</span> = <span style="color:#e6db74">{{{ChemBERTa}}: {{Large-Scale Self-Supervised Pretraining}} for {{Molecular Property Prediction}}}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">shorttitle</span> = <span style="color:#e6db74">{{{ChemBERTa}}}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">author</span> = <span style="color:#e6db74">{Chithrananda, Seyone and Grand, Gabriel and Ramsundar, Bharath}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">year</span> = <span style="color:#ae81ff">2020</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">month</span> = oct,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">number</span> = <span style="color:#e6db74">{arXiv:2010.09885}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">eprint</span> = <span style="color:#e6db74">{2010.09885}</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.2010.09885}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">urldate</span> = <span style="color:#e6db74">{2025-12-24}</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><item><title>Translating InChI to IUPAC Names with Transformers</title><link>https://hunterheidenreich.com/notes/chemistry/molecular-representations/name-translation/handsel-inchi-iupac-2021/</link><pubDate>Sat, 20 Dec 2025 00:00:00 +0000</pubDate><guid>https://hunterheidenreich.com/notes/chemistry/molecular-representations/name-translation/handsel-inchi-iupac-2021/</guid><description>Sequence-to-sequence Transformer translating InChI identifiers to IUPAC names with 91% accuracy on organic compounds.</description><content:encoded><![CDATA[<h2 id="primary-contribution-a-transformer-based-method">Primary Contribution: A Transformer-Based Method</h2>
<p>This is primarily a <strong>Method</strong> paper. It adapts a specific architecture (Transformer) to a specific task (InChI-to-IUPAC translation) and evaluates its performance against both machine learning and commercial baselines. It also has a secondary <strong>Resource</strong> contribution, as the trained model and scripts are released as open-source software.</p>
<h2 id="motivation-the-bottleneck-in-algorithmic-iupac-nomenclature">Motivation: The Bottleneck in Algorithmic IUPAC Nomenclature</h2>
<p>Generating correct IUPAC names is difficult due to the comprehensive but complex rules defined by the International Union of Pure and Applied Chemistry. Commercial software generates names from structures but remains closed-source with opaque methodologies and frequent inter-package disagreements. Open identifiers like InChI and SMILES lack direct human readability. This creates a need for an open, automated method to generate informative IUPAC names from standard identifiers like InChI, which are ubiquitous in online chemical databases.</p>
<h2 id="novelty-treating-chemical-translation-as-a-character-level-sequence">Novelty: Treating Chemical Translation as a Character-Level Sequence</h2>
<p>The key novelty is treating chemical nomenclature translation as a character-level sequence-to-sequence problem using a Transformer architecture, specifically using <a href="/notes/chemistry/molecular-representations/notations/inchi-2013/">InChI</a> as the source language.</p>
<ul>
<li>Standard Neural Machine Translation (NMT) uses sub-word tokenization. This model processes InChI and predicts IUPAC names character-by-character.</li>
<li>It demonstrates that character-level tokenization outperforms byte-pair encoding or unigram models for this specific chemical task.</li>
<li>It uses InChI&rsquo;s standardization to avoid the canonicalization issues inherent in SMILES-based approaches.</li>
<li>The attention mechanism allows the decoder to align specific parts of the generated IUPAC name with corresponding structural features in the source InChI string, operating via the standard scaled dot-product attention:
$$ \text{Attention}(Q, K, V) = \text{softmax}\left(\frac{QK^T}{\sqrt{d_k}}\right)V $$</li>
</ul>
<h2 id="methodology--experimental-validation">Methodology &amp; Experimental Validation</h2>
<ul>
<li><strong>Training:</strong> The model was trained on 10 million InChI/IUPAC pairs sampled from PubChem using a character-level objective. The model is supervised using categorical cross-entropy loss across the vocabulary of characters:
$$ \mathcal{L} = -\sum_{i=1}^{N} y_i \log(\hat{y}_i) $$</li>
<li><strong>Ablation Studies:</strong> The authors experimentally validated architecture choices, finding that LSTM models and sub-word tokenization (BPE) performed worse than the Transformer with character tokenization. They also optimized dropout rates.</li>
<li><strong>Performance Benchmarking:</strong> The model was evaluated on a held-out test set of 200,000 samples. Performance was quantified primarily by Whole-Name Accuracy and Normalized Edit Distance (based on the Damerau-Levenshtein distance, scaled by the maximum string length).</li>
<li><strong>Commercial Comparison:</strong> The authors compared their model against four major commercial packages (ACD/I-Labs, ChemAxon, Mestrelab, and PubChem&rsquo;s Lexichem). However, this evaluation used a highly limited test set of only 100 molecules, restricting the statistical confidence of the external baseline.</li>
<li><strong>Error Analysis:</strong> They analyzed performance across different chemical classes (organics, charged species, macrocycles, inorganics) and visualized attention coefficients to interpret model focus.</li>
</ul>
<h2 id="key-results-and-the-inorganic-challenge">Key Results and the Inorganic Challenge</h2>
<ul>
<li><strong>High Accuracy on Organics:</strong> The model achieved 91% whole-name accuracy on the test set, performing particularly well on organic compounds.</li>
<li><strong>Comparable to Commercial Tools:</strong> On the limited 100-molecule benchmark, the edit distance between the model&rsquo;s predictions and commercial packages (15-23%) was similar to the variation found <em>between</em> the commercial packages themselves (16-21%).</li>
<li><strong>Limitations on Inorganics:</strong> The model performed poorly on inorganic (14% accuracy) and organometallic compounds (20% accuracy). This is attributed to inherent data limitations in the standard InChI format (which deliberately disconnects metal atoms from their ligands) and low training data coverage for those classes.</li>
<li><strong>Character-Level Superiority:</strong> Character-level tokenization was found to be essential; byte-pair encoding reduced accuracy significantly.</li>
</ul>
<hr>
<h2 id="reproducibility-details">Reproducibility Details</h2>
<h3 id="data">Data</h3>
<p>The dataset was derived from <a href="https://ftp.ncbi.nlm.nih.gov/pubchem/Compound/Extras/">PubChem&rsquo;s public FTP server</a> (<code>CID-SMILES.gz</code> and <code>CID-IUPAC.gz</code>).</p>
<table>
  <thead>
      <tr>
          <th>Purpose</th>
          <th>Dataset</th>
          <th>Size</th>
          <th>Notes</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td><strong>Raw</strong></td>
          <td>PubChem</td>
          <td>100M pairs</td>
          <td>Filtered for length (InChI &lt; 200 chars, IUPAC &lt; 150 chars). 132k unparseable SMILES dropped.</td>
      </tr>
      <tr>
          <td><strong>Training</strong></td>
          <td>Subsampled</td>
          <td>10M pairs</td>
          <td>Random sample from the filtered set.</td>
      </tr>
      <tr>
          <td><strong>Validation</strong></td>
          <td>Held-out</td>
          <td>10,000 samples</td>
          <td>Limited to InChI length &gt; 50 chars.</td>
      </tr>
      <tr>
          <td><strong>Test</strong></td>
          <td>Held-out</td>
          <td>200,000 samples</td>
          <td>Limited to InChI length &gt; 50 chars.</td>
      </tr>
      <tr>
          <td><strong>Tokenization</strong></td>
          <td>Vocab</td>
          <td>InChI: 66 chars<br>IUPAC: 70 chars</td>
          <td>Character-level tokenization. Spaces treated as tokens.</td>
      </tr>
  </tbody>
</table>
<h3 id="algorithms">Algorithms</h3>
<ul>
<li><strong>Framework</strong>: OpenNMT-py 2.0.0 (using PyTorch). Training scripts and vocabularies are available as supplementary files to the original publication. Pre-trained model weights are hosted on <a href="https://doi.org/10.5281/zenodo.5081159">Zenodo</a>.</li>
<li><strong>Architecture Type</strong>: Transformer Encoder-Decoder.</li>
<li><strong>Optimization</strong>: ADAM optimizer ($\beta_1=0.9, \beta_2=0.998$).</li>
<li><strong>Learning Rate</strong>: Linear warmup over 8000 steps to 0.0005, then decayed by inverse square root of iteration.</li>
<li><strong>Regularization</strong>:
<ul>
<li>Dropout: 0.1 (applied to dense and attentional layers).</li>
<li>Label Smoothing: Magnitude 0.1.</li>
</ul>
</li>
<li><strong>Training Strategy</strong>: Teacher forcing used for both training and validation.</li>
<li><strong>Gradient Accumulation</strong>: Gradients accumulated over 4 batches before updating parameters.</li>
<li><strong>Inference</strong>: Beam search with width 10 and length penalty 1.0.</li>
</ul>
<h3 id="models">Models</h3>
<ul>
<li><strong>Structure</strong>: 6 layers in encoder, 6 layers in decoder.</li>
<li><strong>Attention</strong>: 8 heads per attention sub-layer.</li>
<li><strong>Dimensions</strong>:
<ul>
<li>Feed-forward hidden state size: 2048.</li>
<li>Embedding vector length: 512.</li>
</ul>
</li>
<li><strong>Initialization</strong>: Glorot&rsquo;s method.</li>
<li><strong>Position</strong>: Positional encoding added to word vectors.</li>
</ul>
<h3 id="evaluation">Evaluation</h3>
<p>Metrics reported include <strong>Whole-Name Accuracy</strong> (percentage of exact matches) and <strong>Normalized Edit Distance</strong> (Damerau-Levenshtein, scale 0-1).</p>
<table>
  <thead>
      <tr>
          <th>Metric</th>
          <th>Value</th>
          <th>Baseline</th>
          <th>Notes</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>Accuracy (All)</td>
          <td>91%</td>
          <td>N/A</td>
          <td>Test set of 200k samples.</td>
      </tr>
      <tr>
          <td>Accuracy (Inorganic)</td>
          <td>14%</td>
          <td>N/A</td>
          <td>Limited by InChI format and data.</td>
      </tr>
      <tr>
          <td>Accuracy (Organometallic)</td>
          <td>20%</td>
          <td>N/A</td>
          <td>Limited by InChI format and data.</td>
      </tr>
      <tr>
          <td>Accuracy (Charged)</td>
          <td>79%</td>
          <td>N/A</td>
          <td>Test set subset.</td>
      </tr>
      <tr>
          <td>Accuracy (Rajan)</td>
          <td>72%</td>
          <td>N/A</td>
          <td>Comparative ML model (STOUT).</td>
      </tr>
      <tr>
          <td>Edit Dist (Organic)</td>
          <td>$0.02 \pm 0.03$</td>
          <td>N/A</td>
          <td>Very high similarity for organics.</td>
      </tr>
      <tr>
          <td>Edit Dist (Inorganic)</td>
          <td>$0.32 \pm 0.20$</td>
          <td>N/A</td>
          <td>Poor performance on inorganics.</td>
      </tr>
      <tr>
          <td>Edit Dist (Organometallic)</td>
          <td>$0.37 \pm 0.24$</td>
          <td>N/A</td>
          <td>Poor performance on organometallics.</td>
      </tr>
  </tbody>
</table>
<h3 id="hardware">Hardware</h3>
<ul>
<li><strong>GPU</strong>: Tesla K80.</li>
<li><strong>Training Time</strong>: 7 days.</li>
<li><strong>Throughput</strong>: ~6000 tokens/sec (InChI) and ~3800 tokens/sec (IUPAC).</li>
<li><strong>Batch Size</strong>: 4096 tokens (approx. 30 compounds).</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://doi.org/10.5281/zenodo.5081159">InChI to IUPAC model</a></td>
          <td>Model</td>
          <td>CC BY 4.0</td>
          <td>Pre-trained Transformer weights (551 MB), requires OpenNMT-py 2.0.0</td>
      </tr>
      <tr>
          <td><a href="https://ftp.ncbi.nlm.nih.gov/pubchem/Compound/Extras/">PubChem FTP</a></td>
          <td>Dataset</td>
          <td>Public Domain</td>
          <td>Source data: CID-SMILES.gz and CID-IUPAC.gz</td>
      </tr>
      <tr>
          <td>Training scripts &amp; vocabularies</td>
          <td>Code</td>
          <td>Unknown</td>
          <td>Included as supplementary files with the publication</td>
      </tr>
  </tbody>
</table>
<hr>
<h2 id="paper-information">Paper Information</h2>
<p><strong>Citation</strong>: Handsel, J., Matthews, B., Knight, N. J., &amp; Coles, S. J. (2021). Translating the InChI: Adapting Neural Machine Translation to Predict IUPAC Names from a Chemical Identifier. <em>Journal of Cheminformatics</em>, 13(1), 79. <a href="https://doi.org/10.1186/s13321-021-00535-x">https://doi.org/10.1186/s13321-021-00535-x</a></p>
<p><strong>Publication</strong>: Journal of Cheminformatics 2021</p>
<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">@article</span>{handselTranslatingInChIAdapting2021a,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">title</span> = <span style="color:#e6db74">{Translating the {{InChI}}: Adapting Neural Machine Translation to Predict {{IUPAC}} Names from a Chemical Identifier}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">shorttitle</span> = <span style="color:#e6db74">{Translating the {{InChI}}}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">author</span> = <span style="color:#e6db74">{Handsel, Jennifer and Matthews, Brian and Knight, Nicola J. and Coles, Simon J.}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">year</span> = <span style="color:#ae81ff">2021</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">month</span> = oct,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">journal</span> = <span style="color:#e6db74">{Journal of Cheminformatics}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">volume</span> = <span style="color:#e6db74">{13}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">number</span> = <span style="color:#e6db74">{1}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">pages</span> = <span style="color:#e6db74">{79}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">issn</span> = <span style="color:#e6db74">{1758-2946}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">doi</span> = <span style="color:#e6db74">{10.1186/s13321-021-00535-x}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">urldate</span> = <span style="color:#e6db74">{2025-12-20}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">abstract</span> = <span style="color:#e6db74">{We present a sequence-to-sequence machine learning model for predicting the IUPAC name of a chemical from its standard International Chemical Identifier (InChI). The model uses two stacks of transformers in an encoder-decoder architecture, a setup similar to the neural networks used in state-of-the-art machine translation. Unlike neural machine translation, which usually tokenizes input and output into words or sub-words, our model processes the InChI and predicts the IUPAC name character by character. The model was trained on a dataset of 10 million InChI/IUPAC name pairs freely downloaded from the National Library of Medicine&#39;s online PubChem service. Training took seven days on a Tesla K80 GPU, and the model achieved a test set accuracy of 91\%. The model performed particularly well on organics, with the exception of macrocycles, and was comparable to commercial IUPAC name generation software. The predictions were less accurate for inorganic and organometallic compounds. This can be explained by inherent limitations of standard InChI for representing inorganics, as well as low coverage in the training data.}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">langid</span> = <span style="color:#e6db74">{english}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">keywords</span> = <span style="color:#e6db74">{Attention,GPU,InChI,IUPAC,seq2seq,Transformer}</span>
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div>]]></content:encoded></item><item><title>Struct2IUPAC: Translating SMILES to IUPAC via Transformers</title><link>https://hunterheidenreich.com/notes/chemistry/molecular-representations/name-translation/struct2iupac-2021/</link><pubDate>Sat, 20 Dec 2025 00:00:00 +0000</pubDate><guid>https://hunterheidenreich.com/notes/chemistry/molecular-representations/name-translation/struct2iupac-2021/</guid><description>A Transformer-based model for translating between SMILES strings and IUPAC names, trained on 47M PubChem examples, achieving 98.9% accuracy with verification.</description><content:encoded><![CDATA[<h2 id="struct2iupac-as-a-methodological-shift">Struct2IUPAC as a Methodological Shift</h2>
<p>This is primarily a <strong>Method</strong> paper with significant elements of <strong>Position</strong>.</p>
<ul>
<li><strong>Method</strong>: The authors propose a specific neural architecture (Transformer with custom tokenization) and a verification pipeline (round-trip check) to solve the SMILES $\leftrightarrow$ IUPAC translation task. They rigorously benchmark this against rule-based baselines (OPSIN).</li>
<li><strong>Position</strong>: The authors explicitly argue for a paradigm shift, suggesting that &ldquo;heavy&rdquo; neural architectures should replace complex, costly rule-based legacy systems even for &ldquo;exact&rdquo; algorithmic tasks.</li>
</ul>
<h2 id="the-cost-of-rule-based-chemical-naming">The Cost of Rule-Based Chemical Naming</h2>
<ul>
<li><strong>Complexity of Naming</strong>: Generating IUPAC names manually is error-prone and requires deep algorithmic knowledge.</li>
<li><strong>Lack of Open Source Tools</strong>: While open-source tools exist for Name-to-Structure (e.g., OPSIN), there were no open-source tools for the inverse &ldquo;Structure-to-Name&rdquo; conversion at the time of writing.</li>
<li><strong>Cost of Development</strong>: Developing rule-based converters &ldquo;from scratch&rdquo; is prohibitively expensive and time-consuming compared to training a neural model on existing data.</li>
</ul>
<h2 id="struct2iupac-core-innovation">Struct2IUPAC Core Innovation</h2>
<ul>
<li><strong>Struct2IUPAC</strong>: The first effective open-source neural model for <a href="/notes/chemistry/molecular-representations/name-translation/stout-v2/">converting SMILES to IUPAC names</a>, treating chemical translation as a Neural Machine Translation (NMT) problem.</li>
<li><strong>Verification Loop</strong>: A novel inference pipeline that generates multiple candidates via beam search and validates them using a reverse converter (OPSIN) to ensure the generated name maps back to the original structure.</li>
<li><strong>Custom Tokenization</strong>: A manually curated rule-based tokenizer for IUPAC names that handles specific chemical suffixes, prefixes, and stereochemical markers.</li>
</ul>
<h2 id="experimental-setup-and-stress-testing">Experimental Setup and Stress Testing</h2>
<ul>
<li><strong>Accuracy Benchmarking</strong>: The models were tested on a held-out subset of 100,000 molecules from PubChem. The authors measured accuracy across different beam sizes (1, 3, 5).</li>
<li><strong>Comparison to Rules</strong>: The neural IUPAC2Struct model was compared directly against the rule-based OPSIN tool.</li>
<li><strong>Stress Testing</strong>:
<ul>
<li><strong>Sequence Length</strong>: Evaluated performance across varying token lengths, identifying a &ldquo;sweet spot&rdquo; (10-60 tokens) and failure modes for very short (e.g., methane) or long molecules.</li>
<li><strong>Stereochemistry</strong>: Tested on &ldquo;stereo-dense&rdquo; compounds. The authors define a &ldquo;stereo-density&rdquo; index ($I$) as the ratio of stereocenters ($S$) to total tokens ($N$):
$$I = \frac{S}{N}$$
They observed a performance drop for these dense molecules, though the model still handled many stereocenters robustly.</li>
<li><strong>Tautomers</strong>: Verified the model&rsquo;s ability to handle different tautomeric forms (e.g., Guanine and Uracil variants).</li>
</ul>
</li>
<li><strong>Latency Analysis</strong>: Benchmarked inference speeds on CPU vs. GPU relative to output sequence length.</li>
</ul>
<h2 id="benchmarks-and-outcomes">Benchmarks and Outcomes</h2>
<ul>
<li><strong>High Accuracy</strong>: The Struct2IUPAC model achieved <strong>98.9% accuracy</strong> (Beam 5 with verification). The reverse model (IUPAC2Struct) achieved <strong>99.1%</strong>, comparable to OPSIN&rsquo;s 99.4%.</li>
<li><strong>Distribution Modeling vs. Intuition</strong>: The authors claim the model infers &ldquo;chemical logic,&rdquo; because it correctly generates multiple valid IUPAC names for single molecules where naming ambiguity exists (e.g., parent group selection). However, this more likely reflects the Transformer successfully modeling the high-frequency conditional probability distribution of synonymous names present in the PubChem training data, rather than learning intrinsic chemical rules.</li>
<li><strong>Production Readiness</strong>: Inference on GPU takes less than 0.5 seconds even for long names, making it viable for production use.</li>
<li><strong>Paradigm Shift</strong>: The authors conclude that neural networks are a viable, cost-effective alternative to developing rule-based algorithms for legacy notation conversion.</li>
</ul>
<hr>
<h2 id="reproducibility-details">Reproducibility Details</h2>
<h3 id="data">Data</h3>
<p>The study utilized the PubChem database.</p>
<table>
  <thead>
      <tr>
          <th>Purpose</th>
          <th>Dataset</th>
          <th>Size</th>
          <th>Notes</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td><strong>Total</strong></td>
          <td>PubChem</td>
          <td>~95M</td>
          <td>Filtered for RDKit compatibility</td>
      </tr>
      <tr>
          <td><strong>Training</strong></td>
          <td>Split A</td>
          <td>47,312,235</td>
          <td>Random 50% split</td>
      </tr>
      <tr>
          <td><strong>Testing</strong></td>
          <td>Split B</td>
          <td>47,413,850</td>
          <td>Random 50% split</td>
      </tr>
  </tbody>
</table>
<ul>
<li><strong>Cleaning</strong>: Molecules that could not be processed by RDKit were removed. Molecules containing tokens not in the tokenizer (e.g., aromatic selenium) were excluded.</li>
<li><strong>Availability</strong>: A subset of 100,000 test molecules is available on GitHub (<code>data/test_100000.csv</code>) and Zenodo. The full train/test splits are not explicitly provided.</li>
</ul>
<h3 id="algorithms">Algorithms</h3>
<ul>
<li><strong>Tokenization</strong>:
<ul>
<li><strong>SMILES</strong>: Character-based tokenization.</li>
<li><strong>IUPAC</strong>: Custom rule-based tokenizer splitting suffixes (<code>-one</code>, <code>-al</code>), prefixes (<code>-oxy</code>, <code>-di</code>), and special symbols (<code>(</code>, <code>)</code>, <code>R(S)</code>).</li>
</ul>
</li>
<li><strong>Verification Step</strong>:
<ol>
<li>Generate $N$ names using Beam Search ($N=5$).</li>
<li>Reverse translate the candidate name using OPSIN.</li>
<li>Check if the OPSIN structure matches the original input SMILES.</li>
<li>Display the first verified match; otherwise, report failure.</li>
</ol>
</li>
</ul>
<h3 id="models">Models</h3>
<ul>
<li><strong>Architecture</strong>: Standard Transformer with 6 encoder layers and 6 decoder layers.</li>
<li><strong>Hyperparameters</strong>:
<ul>
<li>Attention Heads: 8</li>
<li>Attention Dimension ($d_{\text{model}}$): 512</li>
<li>Feed-Forward Dimension ($d_{\text{ff}}$): 2048</li>
</ul>
</li>
<li><strong>Training Objective</strong>: The models were trained using standard autoregressive cross-entropy loss over the target token sequence $y$ given the input string $x$:
$$\mathcal{L} = - \sum_{t=1}^{T} \log P(y_t \mid y_{&lt;t}, x)$$</li>
<li><strong>Training</strong>: Two separate models were trained: <code>Struct2IUPAC</code> (SMILES $\to$ IUPAC) and <code>IUPAC2Struct</code> (IUPAC $\to$ SMILES).</li>
<li><strong>Availability</strong>: Code for model architecture is provided in the GitHub repository. Pre-trained weights for the IUPAC2Struct model are available, but the Struct2IUPAC model weights are not publicly released, meaning researchers would need to retrain that model on their own PubChem data to reproduce those results.</li>
</ul>
<h3 id="evaluation">Evaluation</h3>
<p>Evaluation was performed on a random subset of 100,000 molecules from the test set.</p>
<table>
  <thead>
      <tr>
          <th>Metric</th>
          <th>Task</th>
          <th>Beam Size</th>
          <th>Accuracy</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td><strong>Exact Match</strong></td>
          <td>Struct2IUPAC</td>
          <td>1</td>
          <td>96.1%</td>
      </tr>
      <tr>
          <td><strong>Exact Match</strong></td>
          <td>Struct2IUPAC</td>
          <td>5</td>
          <td>98.9%</td>
      </tr>
      <tr>
          <td><strong>Exact Match</strong></td>
          <td>IUPAC2Struct</td>
          <td>1</td>
          <td>96.6%</td>
      </tr>
      <tr>
          <td><strong>Exact Match</strong></td>
          <td>IUPAC2Struct</td>
          <td>5</td>
          <td>99.1%</td>
      </tr>
  </tbody>
</table>
<ul>
<li><strong>Robustness</strong>: Accuracy drops significantly for augmented (non-canonical) SMILES (37.16%) and stereo-enriched compounds (66.52%).</li>
</ul>
<h3 id="hardware">Hardware</h3>
<ul>
<li><strong>Training Infrastructure</strong>: 4 $\times$ Tesla V100 GPUs and 36 CPUs.</li>
<li><strong>Training Time</strong>: Approximately 10 days under full load.</li>
<li><strong>Inference Speed</strong>: &lt;0.5s per molecule on GPU; scale is linear with output token length.</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/sergsb/IUPAC2Struct">IUPAC2Struct (GitHub)</a></td>
          <td>Code</td>
          <td>MIT</td>
          <td>Transformer code and pre-trained IUPAC2Struct model</td>
      </tr>
      <tr>
          <td><a href="https://doi.org/10.5281/zenodo.4280814">Test data (Zenodo)</a></td>
          <td>Dataset</td>
          <td>Unknown</td>
          <td>100k test molecules, OPSIN failure cases, model failure cases</td>
      </tr>
      <tr>
          <td><a href="https://app.syntelly.com/smiles2iupac">Struct2IUPAC web demo</a></td>
          <td>Other</td>
          <td>N/A</td>
          <td>Online interface for SMILES to IUPAC conversion</td>
      </tr>
  </tbody>
</table>
<hr>
<h2 id="paper-information">Paper Information</h2>
<p><strong>Citation</strong>: Krasnov, L., Khokhlov, I., Fedorov, M. V., &amp; Sosnin, S. (2021). Transformer-based artificial neural networks for the conversion between chemical notations. <em>Scientific Reports</em>, 11(1), 14798. <a href="https://doi.org/10.1038/s41598-021-94082-y">https://doi.org/10.1038/s41598-021-94082-y</a></p>
<p><strong>Publication</strong>: Scientific Reports 2021</p>
<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">@article</span>{krasnovTransformerbasedArtificialNeural2021a,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">title</span> = <span style="color:#e6db74">{Transformer-Based Artificial Neural Networks for the Conversion between Chemical Notations}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">author</span> = <span style="color:#e6db74">{Krasnov, Lev and Khokhlov, Ivan and Fedorov, Maxim V. and Sosnin, Sergey}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">year</span> = <span style="color:#ae81ff">2021</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">month</span> = jul,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">journal</span> = <span style="color:#e6db74">{Scientific Reports}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">volume</span> = <span style="color:#e6db74">{11}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">number</span> = <span style="color:#e6db74">{1}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">pages</span> = <span style="color:#e6db74">{14798}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">publisher</span> = <span style="color:#e6db74">{Nature Publishing Group}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">doi</span> = <span style="color:#e6db74">{10.1038/s41598-021-94082-y}</span>
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div><p><strong>Additional Resources</strong>:</p>
<ul>
<li><a href="https://github.com/sergsb/IUPAC2Struct">GitHub Repository</a></li>
<li><a href="https://app.syntelly.com/smiles2iupac">Web Demo</a></li>
</ul>
]]></content:encoded></item><item><title>STOUT: SMILES to IUPAC Names via Neural Machine Translation</title><link>https://hunterheidenreich.com/notes/chemistry/molecular-representations/name-translation/stout/</link><pubDate>Sat, 20 Dec 2025 00:00:00 +0000</pubDate><guid>https://hunterheidenreich.com/notes/chemistry/molecular-representations/name-translation/stout/</guid><description>A deep-learning neural machine translation approach to translate between SMILES strings and IUPAC names using the STOUT model.</description><content:encoded><![CDATA[<h2 id="contribution-translating-chemistry-as-a-language">Contribution: Translating Chemistry as a Language</h2>
<p>This is primarily a <strong>Method</strong> paper, with a strong secondary contribution as a <strong>Resource</strong> paper.</p>
<ul>
<li><strong>Method</strong>: It proposes a neural machine translation (NMT) architecture to approximate the complex, rule-based algorithm of IUPAC naming, treating it as a language translation task.</li>
<li><strong>Resource</strong>: It provides an open-source tool and trained models to the community, addressing a gap where such functionality was previously limited to proprietary software.</li>
</ul>
<h2 id="motivation-democratizing-iupac-nomenclature">Motivation: Democratizing IUPAC Nomenclature</h2>
<p>The International Union of Pure and Applied Chemistry (IUPAC) naming scheme is universally accepted but algorithmically complex. Generating these names correctly is challenging for humans, and automated generation is largely missing from major open-source toolkits like CDK, RDKit, or Open Babel. While reliable commercial tools exist (e.g., ChemAxon&rsquo;s <code>molconvert</code>), there was a lack of open-source alternatives for the scientific community. STOUT aims to fill this gap using a data-driven approach.</p>
<h2 id="core-innovation-sequence-to-sequence-naming">Core Innovation: Sequence-to-Sequence Naming</h2>
<ul>
<li><strong>Language Translation Approach</strong>: The authors treat chemical representations (<a href="/notes/chemistry/molecular-representations/notations/smiles/">SMILES</a>/<a href="/notes/chemistry/molecular-representations/notations/selfies/">SELFIES</a>) and IUPAC names as two different languages, applying Neural Machine Translation (NMT) to translate between them.</li>
<li><strong>Use of SELFIES</strong>: The work establishes SELFIES (Self-Referencing Embedded Strings) as a robust choice over SMILES for deep learning tokenization in this specific task, capitalizing on its syntactic robustness.</li>
<li><strong>Hardware Acceleration</strong>: The paper benchmarks GPU versus TPU training and highlights the practical necessity of Tensor Processing Units (TPUs) for training large-scale chemical language models, reducing training time by an order of magnitude.</li>
</ul>
<h2 id="methodology--translation-validation">Methodology &amp; Translation Validation</h2>
<ul>
<li><strong>Data Scale</strong>: The model was trained on datasets of 30 million and 60 million molecules derived from PubChem.</li>
<li><strong>Hardware Benchmarking</strong>: Training efficiency was compared between an nVidia Tesla V100 GPU and Google TPU v3-8/v3-32 units.</li>
<li><strong>Bidirectional Translation</strong>: The system was tested on two distinct tasks:
<ol>
<li><strong>Forward</strong>: SELFIES → IUPAC names</li>
<li><strong>Reverse</strong>: IUPAC names → SELFIES</li>
</ol>
</li>
<li><strong>Validation</strong>: Performance was evaluated on a held-out test set of 2.2 million molecules.</li>
</ul>
<h2 id="translation-accuracy--hardware-scaling">Translation Accuracy &amp; Hardware Scaling</h2>
<ul>
<li><strong>High Accuracy</strong>: The model achieved an average BLEU score of ~90% and a Tanimoto similarity index &gt; 0.9 for both translation directions.</li>
<li><strong>Generalization</strong>: Even when predictions were textually mismatched (low BLEU score), the underlying chemical structures often remained highly similar (high Tanimoto similarity), suggesting the system captures fundamental chemical semantics rather than merely memorizing strings.</li>
<li><strong>Impact of Data Size</strong>: Expanding training from 30 million to 60 million molecules yielded consistent performance gains without saturating.</li>
<li><strong>Hardware Necessity</strong>: Training on TPUs proved up to 54 times faster than a standard GPU baseline (Tesla V100), making scaling highly computationally tractable.</li>
</ul>
<hr>
<h2 id="reproducibility">Reproducibility</h2>
<table>
  <thead>
      <tr>
          <th style="text-align: left">Artifact</th>
          <th style="text-align: left">Type</th>
          <th style="text-align: left">License</th>
          <th style="text-align: left">Notes</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td style="text-align: left"><a href="https://github.com/egonw/Smiles-TO-iUpac-Translator">STOUT (GitHub)</a></td>
          <td style="text-align: left">Code</td>
          <td style="text-align: left">MIT</td>
          <td style="text-align: left">Current repo hosts STOUT V2.0 transformer models; V1 RNN code available in earlier commits</td>
      </tr>
      <tr>
          <td style="text-align: left"><a href="https://pubchem.ncbi.nlm.nih.gov/">PubChem</a></td>
          <td style="text-align: left">Dataset</td>
          <td style="text-align: left">Public Domain</td>
          <td style="text-align: left">Source of 111M molecules; 30M/60M training subsets not directly provided</td>
      </tr>
  </tbody>
</table>
<h3 id="data">Data</h3>
<p>The dataset was curated from PubChem (111 million molecules). Note that the specific 30M and 60M subsets are not directly linked in the publication repository, which means a user would have to reconstruct the filtering process.</p>
<p><strong>Preprocessing &amp; Filtering</strong>:</p>
<ul>
<li>Explicit hydrogens removed; converted to canonical SMILES.</li>
<li><strong>Filtering Rules</strong>: MW &lt; 1500 Da, no counter ions, limited element set (C, H, O, N, P, S, F, Cl, Br, I, Se, B), no hydrogen isotopes, 3-40 bonds, no charged groups.</li>
<li><strong>Ground Truth Generation</strong>: ChemAxon&rsquo;s <code>molconvert</code> (Marvin Suite 20.15) was used to generate target IUPAC names for training.</li>
<li><strong>Representation</strong>: All SMILES were converted to SELFIES for training.</li>
</ul>
<table>
  <thead>
      <tr>
          <th style="text-align: left">Purpose</th>
          <th style="text-align: left">Dataset</th>
          <th style="text-align: left">Size</th>
          <th style="text-align: left">Notes</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td style="text-align: left"><strong>Training</strong></td>
          <td style="text-align: left">PubChem Filtered</td>
          <td style="text-align: left">30M &amp; 60M</td>
          <td style="text-align: left">Two distinct training sets created.</td>
      </tr>
      <tr>
          <td style="text-align: left"><strong>Testing</strong></td>
          <td style="text-align: left">PubChem Held-out</td>
          <td style="text-align: left">2.2M</td>
          <td style="text-align: left">Molecules not present in training sets; uniform token frequency.</td>
      </tr>
  </tbody>
</table>
<h3 id="algorithms">Algorithms</h3>
<ul>
<li><strong>Tokenization</strong>:
<ul>
<li><strong>SELFIES</strong>: Split iteratively by brackets <code>[</code> and <code>]</code>.</li>
<li><strong>IUPAC</strong>: Split via punctuation (<code>(</code>, <code>)</code>, <code>{</code>, <code>}</code>, <code>[</code>, <code>]</code>, <code>-</code>, <code>.</code>, <code>,</code>) and a discrete set of sub-word chemical morphemes (e.g., <code>methyl</code>, <code>benzene</code>, <code>fluoro</code>).</li>
<li><strong>Padding</strong>: SELFIES padded to 48 tokens; IUPAC padded to 78 tokens. &ldquo;Start&rdquo; and &ldquo;End&rdquo; sequence markers append each chain.</li>
</ul>
</li>
<li><strong>Optimization</strong>: Adam optimizer instantiated with a learning rate of $0.0005$.</li>
<li><strong>Objective Function</strong>: Sparse categorical cross-entropy, assessing prediction probabilities for token $i$ over vocabulary $V$:
$$ \mathcal{L} = -\sum_{i=1}^{V} y_i \log(\hat{y}_i) $$</li>
</ul>
<h3 id="models">Models</h3>
<ul>
<li><strong>Architecture</strong>: Encoder-Decoder sequence-to-sequence network with Bahdanau attention mechanism context weighting.</li>
<li><strong>Components</strong>:
<ul>
<li><strong>Encoder/Decoder</strong>: Recurrent Neural Networks (RNN) constructed using Gated Recurrent Units (GRU).</li>
<li><strong>Attention</strong>: Bahdanau (additive) soft attention, which calculates alignment scores to softly weight encoder hidden states natively:
$$ e_{tj} = v_a^\top \tanh(W_a s_{t-1} + U_a h_j) $$</li>
<li><strong>Embedding</strong>: Decoder output passes through a continuous embedding layer before concatenating with the attention context vector.</li>
</ul>
</li>
<li><strong>Implementation</strong>: Python 3 backend using TensorFlow 2.3.0. <em>Note: The linked GitHub repository currently defaults to the STOUT V2.0 transformer models, so researchers aiming to reproduce this specific V1 RNN paper should reference the older tag/commit history.</em></li>
</ul>
<h3 id="evaluation">Evaluation</h3>
<p>Metrics heavily emphasize both linguistic accuracy and cheminformatic structural correctness:</p>
<table>
  <thead>
      <tr>
          <th style="text-align: left">Metric</th>
          <th style="text-align: left">Details</th>
          <th style="text-align: left">Result (60M Model)</th>
          <th style="text-align: left">Notes</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td style="text-align: left"><strong>BLEU Score</strong></td>
          <td style="text-align: left">NLTK sentence BLEU (unigram to 4-gram)</td>
          <td style="text-align: left">0.94 (IUPAC $\to$ SELFIES)</td>
          <td style="text-align: left">Exact text overlap. Serves as a strictly syntactic proxy.</td>
      </tr>
      <tr>
          <td style="text-align: left"><strong>Tanimoto Similarity</strong></td>
          <td style="text-align: left">PubChem fingerprints via CDK</td>
          <td style="text-align: left">0.98 (Valid IUPAC names)</td>
          <td style="text-align: left">Evaluates substructure alignment over bit vectors, $T(A, B) = \frac{\vert A \cap B \vert}{\vert A \cup B \vert}$.</td>
      </tr>
  </tbody>
</table>
<h3 id="hardware">Hardware</h3>
<p>Comparison of hardware efficiency for training large chemical language models:</p>
<table>
  <thead>
      <tr>
          <th style="text-align: left">Hardware</th>
          <th style="text-align: left">Batch Size</th>
          <th style="text-align: left">Time per Epoch (15M subset)</th>
          <th style="text-align: left">Speedup Factor</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td style="text-align: left"><strong>GPU (Tesla V100)</strong></td>
          <td style="text-align: left">256</td>
          <td style="text-align: left">~27 hours</td>
          <td style="text-align: left">1x</td>
      </tr>
      <tr>
          <td style="text-align: left"><strong>TPU v3-8</strong></td>
          <td style="text-align: left">1024 (Global)</td>
          <td style="text-align: left">~2 hours</td>
          <td style="text-align: left">13x</td>
      </tr>
      <tr>
          <td style="text-align: left"><strong>TPU v3-32</strong></td>
          <td style="text-align: left">1024 (Global)</td>
          <td style="text-align: left">~0.5 hours</td>
          <td style="text-align: left">54x</td>
      </tr>
  </tbody>
</table>
<hr>
<h2 id="paper-information">Paper Information</h2>
<p><strong>Citation</strong>: Rajan, K., Zielesny, A., &amp; Steinbeck, C. (2021). STOUT: SMILES to IUPAC names using neural machine translation. <em>Journal of Cheminformatics</em>, 13(1), 34. <a href="https://doi.org/10.1186/s13321-021-00512-4">https://doi.org/10.1186/s13321-021-00512-4</a></p>
<p><strong>Publication</strong>: Journal of Cheminformatics 2021</p>
<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">@article</span>{rajanSTOUTSMILESIUPAC2021,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">title</span> = <span style="color:#e6db74">{STOUT: SMILES to IUPAC Names Using Neural Machine Translation}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">shorttitle</span> = <span style="color:#e6db74">{STOUT}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">author</span> = <span style="color:#e6db74">{Rajan, Kohulan and Zielesny, Achim and Steinbeck, Christoph}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">year</span> = <span style="color:#e6db74">{2021}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">month</span> = apr,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">journal</span> = <span style="color:#e6db74">{Journal of Cheminformatics}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">volume</span> = <span style="color:#e6db74">{13}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">number</span> = <span style="color:#e6db74">{1}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">pages</span> = <span style="color:#e6db74">{34}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">issn</span> = <span style="color:#e6db74">{1758-2946}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">doi</span> = <span style="color:#e6db74">{10.1186/s13321-021-00512-4}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">urldate</span> = <span style="color:#e6db74">{2025-09-22}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">abstract</span> = <span style="color:#e6db74">{Chemical compounds can be identified through a graphical depiction, a suitable string representation, or a chemical name. A universally accepted naming scheme for chemistry was established by the International Union of Pure and Applied Chemistry (IUPAC) based on a set of rules. Due to the complexity of this ruleset a correct chemical name assignment remains challenging for human beings and there are only a few rule-based cheminformatics toolkits available that support this task in an automated manner. Here we present STOUT (SMILES-TO-IUPAC-name translator), a deep-learning neural machine translation approach to generate the IUPAC name for a given molecule from its SMILES string as well as the reverse translation, i.e. predicting the SMILES string from the IUPAC name. In both cases, the system is able to predict with an average BLEU score of about 90% and a Tanimoto similarity index of more than 0.9. Also incorrect predictions show a remarkable similarity between true and predicted compounds.}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">langid</span> = <span style="color:#e6db74">{english}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">keywords</span> = <span style="color:#e6db74">{Attention mechanism,Chemical language,Deep neural network,DeepSMILES,IUPAC names,Neural machine translation,Recurrent neural network,SELFIES,SMILES}</span>
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div><p><strong>Additional Resources</strong>:</p>
<ul>
<li><a href="https://github.com/egonw/Smiles-TO-iUpac-Translator">GitHub Repository</a></li>
<li><a href="/notes/chemistry/molecular-representations/name-translation/stout-v2/">STOUT V2.0 Note</a></li>
<li><a href="/notes/chemistry/molecular-representations/name-translation/struct2iupac-2021/">Struct2IUPAC Note</a></li>
<li><a href="/notes/chemistry/molecular-representations/name-translation/handsel-inchi-iupac-2021/">HandSEL Note (InChI to IUPAC)</a></li>
</ul>
]]></content:encoded></item><item><title>STOUT V2.0: Transformer-Based SMILES to IUPAC Translation</title><link>https://hunterheidenreich.com/notes/chemistry/molecular-representations/name-translation/stout-v2/</link><pubDate>Sat, 20 Dec 2025 00:00:00 +0000</pubDate><guid>https://hunterheidenreich.com/notes/chemistry/molecular-representations/name-translation/stout-v2/</guid><description>A Transformer-based model for translating SMILES to IUPAC names, trained on ~1 billion molecules, achieving ~0.99 BLEU score on benchmarks.</description><content:encoded><![CDATA[<h2 id="paper-contribution--methodological-scope">Paper Contribution &amp; Methodological Scope</h2>
<p><strong>Method (Primary) / Resource (Secondary)</strong></p>
<p>This paper presents a <strong>Methodological</strong> contribution by developing and validating a Transformer-based neural machine translation model (STOUT V2) for bidirectional chemical nomenclature (<a href="/notes/chemistry/molecular-representations/notations/smiles/">SMILES</a> $\leftrightarrow$ IUPAC). It systematically compares this new architecture against previous RNN-based baselines (<a href="/notes/chemistry/molecular-representations/name-translation/stout/">STOUT V1</a>) and performs ablation studies on tokenization strategies.</p>
<p>It also serves as a significant <strong>Resource</strong> contribution by generating a massive training dataset of nearly 1 billion SMILES-IUPAC pairs (curated via commercial Lexichem software) and releasing the resulting models and code as open-source tools for chemical naming.</p>
<h2 id="the-need-for-robust-open-source-iupac-nomenclature-rules">The Need for Robust Open-Source IUPAC Nomenclature Rules</h2>
<p>Assigning systematic IUPAC names to chemical structures requires adherence to complex rules, challenging human consistency. Deterministic, rule-based software options like OpenEye Lexichem and ChemAxon are reliable commercial solutions. Existing open-source tools like OPSIN focus on parsing names to structures.</p>
<p>The previous version of STOUT (V1), based on RNNs/GRUs, achieved ~90% BLEU accuracy, with known limitations in capturing long-distance dependencies required for stereochemistry handling. This work uses the sequence-learning capabilities of Transformers combined with large-scale datasets to create a competitive open-source IUPAC naming tool.</p>
<h2 id="architectural-shift-and-billion-scale-training">Architectural Shift and Billion-Scale Training</h2>
<p>The primary advancements over previous iterations address both architecture and dataset scale:</p>
<ol>
<li><strong>Architecture Shift</strong>: Moving from an RNN-based Seq2Seq model to a <strong>Transformer-based architecture</strong> (4 layers, 8 heads), which captures intricate chemical patterns better than GRUs.</li>
<li><strong>Billion-Scale Training</strong>: Training on a dataset of nearly <strong>1 billion molecules</strong> (combining PubChem and ZINC15), significantly larger than the 60 million used for STOUT V1.</li>
<li><strong>Tokenization Strategy</strong>: Determining that <strong>character-wise tokenization</strong> for IUPAC names is superior to word-wise tokenization in terms of both accuracy and training efficiency (15% faster).</li>
</ol>
<h2 id="experimental-validation-and-scaling-limits">Experimental Validation and Scaling Limits</h2>
<p>The authors conducted three primary experiments to validate bidirectional translation (SMILES $\rightarrow$ IUPAC and IUPAC $\rightarrow$ SMILES):</p>
<ul>
<li><strong>Experiment 1 (Optimization)</strong>: Assessed the impact of dataset size (1M vs 10M vs 50M) and tokenization strategy on SMILES-to-IUPAC performance.</li>
<li><strong>Experiment 2 (Scaling)</strong>: Trained models on 110 million PubChem molecules for <strong>both</strong> forward and reverse translation tasks to test performance on longer sequences.</li>
<li><strong>Experiment 3 (Generalization)</strong>: Trained on the full ~1 billion dataset (PubChem + ZINC15) for both translation directions.</li>
<li><strong>External Validation</strong>: Benchmarked against an external dataset from ChEBI (1,485 molecules) and ChEMBL34 to test generalization to unseen data.</li>
</ul>
<p><strong>Evaluation Metrics</strong>:</p>
<ul>
<li><strong>Textual Accuracy</strong>: BLEU scores (1-4) and Exact String Match.</li>
<li><strong>Chemical Validity</strong>: Retranslation of generated names back to SMILES using OPSIN, followed by Tanimoto similarity checks (PubChem fingerprints) against the original input.</li>
</ul>
<h2 id="translation-accuracy-and-structural-validity">Translation Accuracy and Structural Validity</h2>
<ul>
<li><strong>Superior Performance</strong>: STOUT V2 achieved an average BLEU score of <strong>0.99</strong> (vs 0.94 for V1). While exact string matches varied by experiment (83-89%), the model notably achieved a perfect BLEU score (1.0) on <strong>97.49%</strong> of a specific test set where STOUT V1 only reached 66.65%.</li>
<li><strong>Structural Validity (&ldquo;Near Misses&rdquo;)</strong>: When the generated name differed from the ground truth string, the re-generated structure often remained chemically valid. The model maintained an average Tanimoto similarity $T(A,B)$ of <strong>0.68</strong> for these divergent names between bit-vector fingerprints $A$ and $B$, roughly defined as:
$$ T(A,B) = \frac{\sum (A \cap B)}{\sum (A \cup B)} $$
<em>Critique</em>: Note that an average Tanimoto coefficient of 0.68 typically suggests moderate structural similarity/drift, not an almost-identical &ldquo;near miss&rdquo; (which would be $&gt;0.85$). This implies the model constructs chemically related but structurally distinct outputs when it fails exact string matching.</li>
<li><strong>Tokenization</strong>: Character-level splitting for IUPAC names outperformed word-level splitting and was more computationally efficient.</li>
<li><strong>Data Imbalance &amp; Generalization</strong>: The model&rsquo;s drop in performance for sequences &gt;600 characters highlights a systemic issue in open chemical databases: long, highly complex SMILES strings are significantly underrepresented. Even billion-scale training datasets are still bound by the chemical diversity of their source material.</li>
<li><strong>Limitations</strong>:
<ul>
<li><strong>Preferred Names (PINs)</strong>: The model mimics Lexichem&rsquo;s naming conventions, generating valid IUPAC names distinct from strict <em>Preferred IUPAC Names</em> (PINs).</li>
<li><strong>Sequence Length</strong>: Performance degrades for very long SMILES (&gt;600 characters) due to scarcity in the training data.</li>
<li><strong>Algorithmic Distillation Bottleneck</strong>: Because the 1 billion training pairs were generated entirely by OpenEye&rsquo;s Lexichem, STOUT V2 acts as a knowledge distillation of that specific commercial algorithm. The model learns Lexichem’s heuristic mapping, specific dialects, and potential systematic errors, rather than deriving true nomenclature rules from first principles.</li>
</ul>
</li>
</ul>
<hr>
<h2 id="reproducibility-details">Reproducibility Details</h2>
<h3 id="data">Data</h3>
<p>The training data was derived from PubChem and ZINC15. Ground truth IUPAC names were generated using OpenEye Lexichem TK 2.8.1 to ensure consistency.</p>
<table>
  <thead>
      <tr>
          <th>Purpose</th>
          <th>Dataset</th>
          <th>Size</th>
          <th>Notes</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td><strong>Training (Exp 1)</strong></td>
          <td>PubChem Subset</td>
          <td>1M, 10M, 50M</td>
          <td>Selected via MaxMin algorithm for diversity</td>
      </tr>
      <tr>
          <td><strong>Training (Exp 2)</strong></td>
          <td>PubChem</td>
          <td>110M</td>
          <td>Filtered for SMILES length &lt; 600</td>
      </tr>
      <tr>
          <td><strong>Training (Exp 3)</strong></td>
          <td>PubChem + ZINC15</td>
          <td>~1 Billion</td>
          <td>999,637,326 molecules total</td>
      </tr>
      <tr>
          <td><strong>Evaluation</strong></td>
          <td>ChEBI</td>
          <td>1,485</td>
          <td>External validation set, non-overlapping with training</td>
      </tr>
  </tbody>
</table>
<p><strong>Preprocessing</strong>:</p>
<ul>
<li><strong>SMILES</strong>: Canonicalized, isomeric, and kekulized using RDKit (v2023.03.1).</li>
<li><strong>Formatting</strong>: Converted to TFRecord format in 100 MB chunks for TPU efficiency.</li>
</ul>
<h3 id="algorithms">Algorithms</h3>
<ul>
<li><strong>SMILES Tokenization</strong>: Regex-based splitting. Atoms (e.g., &ldquo;Cl&rdquo;, &ldquo;Au&rdquo;), bonds, brackets, and digits are separate tokens.</li>
<li><strong>IUPAC Tokenization</strong>: <strong>Character-wise split</strong> was selected as the optimal strategy (treating every character as a token).</li>
<li><strong>Optimization</strong>: Adam optimizer with a custom learning rate scheduler based on model dimensions.</li>
<li><strong>Loss Function</strong>: Trained to minimize the Sparse Categorical Cross-Entropy $L$, masking padding tokens. For a correctly predicted target class $t$ alongside probabilities $p_i$, the masked loss is represented mathematically as:
$$ L = - \sum_{i=1}^{m} m_i y_{i} \log(p_{i}) $$
where $m_i$ masks padded positions.</li>
<li><strong>Code Availability</strong>: The <a href="https://github.com/egonw/Smiles-TO-iUpac-Translator">main STOUT V2 repository</a> contains the inference package. The training pipeline/instructions (originally linked to a separate repo that is currently a 404) can still be found within the <a href="https://doi.org/10.5281/zenodo.6559438">Zenodo archive release</a>.</li>
</ul>
<h3 id="models">Models</h3>
<p>The model follows the standard Transformer architecture from &ldquo;Attention is All You Need&rdquo; (Vaswani et al.).</p>
<ul>
<li><strong>Architecture</strong>: 4 Transformer layers (encoder/decoder stack).</li>
<li><strong>Attention</strong>: Multi-head attention with <strong>8 heads</strong>.</li>
<li><strong>Dimensions</strong>: Embedding size ($d_{model}$) = 512; Feed-forward dimension ($d_{ff}$) = 2048.</li>
<li><strong>Regularization</strong>: Dropout rate of 0.1.</li>
<li><strong>Context Window</strong>: Max input length (SMILES) = 600; Max output length (IUPAC) = 700-1000.</li>
<li><strong>Weights</strong>: Model weights for forward and reverse architectures are <a href="https://doi.org/10.5281/zenodo.13318286">available via Zenodo (v3)</a>.</li>
</ul>
<h3 id="evaluation">Evaluation</h3>
<p>Evaluation focused on both string similarity and chemical structural integrity.</p>
<table>
  <thead>
      <tr>
          <th>Metric</th>
          <th>Scope</th>
          <th>Method</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td><strong>BLEU Score</strong></td>
          <td>N-gram overlap</td>
          <td>Compared predicted IUPAC string to Ground Truth.</td>
      </tr>
      <tr>
          <td><strong>Exact Match</strong></td>
          <td>Accuracy</td>
          <td>Binary 1/0 check for identical strings.</td>
      </tr>
      <tr>
          <td><strong>Tanimoto</strong></td>
          <td>Structural Similarity</td>
          <td>Predicted Name $\rightarrow$ OPSIN $\rightarrow$ SMILES $\rightarrow$ Fingerprint comparison to input.</td>
      </tr>
  </tbody>
</table>
<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/egonw/Smiles-TO-iUpac-Translator">STOUT V2 GitHub</a></td>
          <td>Code</td>
          <td>MIT</td>
          <td>Inference package (PyPI: STOUT-pypi)</td>
      </tr>
      <tr>
          <td><a href="https://doi.org/10.5281/zenodo.13318286">Model Weights (Zenodo v3)</a></td>
          <td>Model</td>
          <td>Unknown</td>
          <td>Forward and reverse translation weights</td>
      </tr>
      <tr>
          <td><a href="https://zenodo.org/records/6559438">Code Snapshot (Zenodo)</a></td>
          <td>Code</td>
          <td>Unknown</td>
          <td>Training pipeline archive</td>
      </tr>
      <tr>
          <td><a href="https://stout.decimer.ai">Web Application</a></td>
          <td>Other</td>
          <td>Unknown</td>
          <td>Demo with Ketcher, bulk submission, DECIMER integration</td>
      </tr>
  </tbody>
</table>
<h3 id="hardware">Hardware</h3>
<p>Training was conducted entirely on Google Cloud Platform (GCP) TPUs.</p>
<ul>
<li><strong>STOUT V1</strong>: Trained on TPU v3-8.</li>
<li><strong>STOUT V2</strong>: Trained on <strong>TPU v4-128 pod slices</strong> (128 nodes).</li>
<li><strong>Large Scale (Exp 3)</strong>: Trained on <strong>TPU v4-256 pod slice</strong> (256 nodes).</li>
<li><strong>Training Time</strong>: Average of <strong>15 hours and 2 minutes per epoch</strong> for the 1 billion dataset.</li>
<li><strong>Framework</strong>: TensorFlow 2.15.0-pjrt with Keras.</li>
</ul>
<hr>
<h2 id="paper-information">Paper Information</h2>
<p><strong>Citation</strong>: Rajan, K., Zielesny, A., &amp; Steinbeck, C. (2024). STOUT V2.0: SMILES to IUPAC name conversion using transformer models. <em>Journal of Cheminformatics</em>, 16(146). <a href="https://doi.org/10.1186/s13321-024-00941-x">https://doi.org/10.1186/s13321-024-00941-x</a></p>
<p><strong>Publication</strong>: Journal of Cheminformatics 2024</p>
<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">@article</span>{rajanSTOUTV20SMILES2024,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">title</span> = <span style="color:#e6db74">{{{STOUT V2}}.0: {{SMILES}} to {{IUPAC}} Name Conversion Using Transformer Models}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">shorttitle</span> = <span style="color:#e6db74">{{{STOUT V2}}.0}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">author</span> = <span style="color:#e6db74">{Rajan, Kohulan and Zielesny, Achim and Steinbeck, Christoph}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">year</span> = <span style="color:#ae81ff">2024</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">month</span> = dec,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">journal</span> = <span style="color:#e6db74">{Journal of Cheminformatics}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">volume</span> = <span style="color:#e6db74">{16}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">number</span> = <span style="color:#e6db74">{1}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">pages</span> = <span style="color:#e6db74">{146}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">issn</span> = <span style="color:#e6db74">{1758-2946}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">doi</span> = <span style="color:#e6db74">{10.1186/s13321-024-00941-x}</span>
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div><p><strong>Additional Resources</strong>:</p>
<ul>
<li><a href="https://stout.decimer.ai">Web Application</a> (Includes Ketcher drawing, bulk submission, and DECIMER integration)</li>
<li><a href="https://decimer.ai">DECIMER Project</a></li>
<li><a href="/notes/chemistry/molecular-representations/name-translation/stout/">STOUT V1 Note</a></li>
<li><a href="https://zenodo.org/records/6559438">Zenodo Archive (Code Snapshot)</a></li>
</ul>
]]></content:encoded></item><item><title>SELFIES and the Future of Molecular String Representations</title><link>https://hunterheidenreich.com/notes/chemistry/molecular-representations/notations/selfies-2022/</link><pubDate>Tue, 02 Dec 2025 00:00:00 +0000</pubDate><guid>https://hunterheidenreich.com/notes/chemistry/molecular-representations/notations/selfies-2022/</guid><description>Perspective on SELFIES as a 100% robust SMILES alternative, with 16 future research directions for molecular AI.</description><content:encoded><![CDATA[<h2 id="position-a-roadmap-for-robust-chemical-languages">Position: A Roadmap for Robust Chemical Languages</h2>
<p>This is a <strong>Position</strong> paper (perspective) that proposes a research agenda for molecular representations in AI. It reviews the evolution of chemical notation over 250 years and argues for extending SELFIES-style robust representations beyond traditional organic chemistry into polymers, crystals, reactions, and other complex chemical systems.</p>
<h2 id="the-generative-bottleneck-in-traditional-representations">The Generative Bottleneck in Traditional Representations</h2>
<p>While SMILES has been the standard molecular representation since 1988, its fundamental weakness for machine learning is well-established: randomly generated SMILES strings are often invalid. The motivation is twofold:</p>
<ol>
<li><strong>Current problem</strong>: Traditional representations (SMILES, <a href="/notes/chemistry/molecular-representations/notations/inchi-2013/">InChI</a>, DeepSMILES) lack 100% robustness; random mutations or generations can produce invalid strings, limiting their use in generative AI models.</li>
<li><strong>Future opportunity</strong>: SELFIES solved this for small organic molecules, but many important chemical domains (polymers, crystals, reactions) still lack robust representations, creating a bottleneck for AI-driven discovery in these areas.</li>
</ol>
<h2 id="16-concrete-research-directions-for-selfies">16 Concrete Research Directions for SELFIES</h2>
<p>The novelty is in the comprehensive research roadmap. The authors propose 16 concrete research projects organized around key themes:</p>
<ul>
<li><strong>Domain extension</strong>: Includes metaSELFIES for learning graph rules directly from data, BigSELFIES for stochastic polymers, and crystal structures via labeled quotient graphs.</li>
<li><strong>Chemical reactions</strong>: Robust reaction representations that enforce conservation laws.</li>
<li><strong>Programming perspective</strong>: Treating molecular representations as programming languages, potentially achieving Turing-completeness.</li>
<li><strong>Benchmarking</strong>: Systematic comparisons across representation formats.</li>
<li><strong>Interpretability</strong>: Understanding how humans and machines actually learn from different representations.</li>
</ul>
<h2 id="evidence-from-generative-case-studies">Evidence from Generative Case Studies</h2>
<p>This perspective paper includes case studies:</p>
<ol>
<li>
<p><strong>Pasithea (Deep Molecular Dreaming)</strong>: A generative model that first learns to predict a chemical property from a one-hot encoded SELFIES, then freezes the network weights and uses gradient descent on the one-hot input encoding to optimize molecular properties (logP). The target property increases or decreases nearly monotonically, demonstrating that the model has learned meaningful structure-property relationships from the SELFIES representation.</p>
</li>
<li>
<p><strong>DECIMER and STOUT</strong>: DECIMER (Deep lEarning for Chemical ImagE Recognition) is an image-to-structure tool, and STOUT (SMILES-TO-IUPAC-name Translator) translates between IUPAC names and molecular string representations. Both show improved performance when using SELFIES as an intermediate representation. STOUT internally converts SMILES to SELFIES before processing and decodes predicted SELFIES back to SMILES. These results suggest SELFIES provides a more learnable internal representation for sequence-to-sequence models.</p>
</li>
</ol>
<h2 id="strategic-outcomes-and-future-vision">Strategic Outcomes and Future Vision</h2>
<p>The paper establishes robust representations as a fundamental bottleneck in computational chemistry and proposes a clear path forward:</p>
<p><strong>Key outcomes</strong>:</p>
<ul>
<li>Identification of 16 concrete research projects spanning domain extension, benchmarking, and interpretability</li>
<li>Evidence that SELFIES enables capabilities (like smooth property optimization) impossible with traditional formats</li>
<li>Framework for thinking about molecular representations as programming languages</li>
</ul>
<p><strong>Strategic impact</strong>: The proposed extensions could enable new applications across drug discovery (efficient exploration beyond small molecules), materials design (systematic crystal structure discovery), synthesis planning (better reaction representations), and fundamental research (new ways to understand chemical behavior).</p>
<p><strong>Future vision</strong>: The authors emphasize that robust representations could become a bridge for bidirectional learning between humans and machines, enabling humans to learn new chemical concepts from AI systems.</p>
<h2 id="the-mechanism-of-robustness">The Mechanism of Robustness</h2>
<p>The key difference between SELFIES and other representations lies in how they handle syntax:</p>
<ul>
<li><strong>SMILES/DeepSMILES</strong>: Rely on non-local markers (opening/closing parentheses or ring numbers) that must be balanced. A mutation or random generation can easily break this balance, producing invalid strings.</li>
<li><strong>SELFIES</strong>: Uses a formal grammar (automaton) where derivation rules are entirely local. The critical innovation is <strong>overloading</strong>: a state-modifying symbol like <code>[Branch1]</code> starts a branch and changes the interpretation of the <em>next</em> symbol to represent a numerical parameter (the branch length).</li>
</ul>
<p>This overloading mechanism ensures that any arbitrary sequence of SELFIES tokens can be parsed into a valid molecular graph. The derivation can never fail because every symbol either adds an atom or modifies how subsequent symbols are interpreted.</p>
<h2 id="the-16-research-projects-technical-details">The 16 Research Projects: Technical Details</h2>
<p>This section provides technical details on the proposed research directions:</p>
<h3 id="extending-to-new-domains">Extending to New Domains</h3>
<p><strong>metaSELFIES (Project 1)</strong>: The authors propose learning graph construction rules automatically from data. This could enable robust representations for any graph-based system, from quantum optics to biological networks, without needing domain-specific expertise.</p>
<p><strong>Token Optimization (Project 2)</strong>: SELFIES uses &ldquo;overloading&rdquo; where a symbol&rsquo;s meaning changes based on context. This project would investigate how this affects machine learning performance and whether the approach can be optimized.</p>
<h3 id="handling-complex-molecular-systems">Handling Complex Molecular Systems</h3>
<p><strong>BigSELFIES (Project 3)</strong>: Current representations struggle with large, often random structures like polymers and biomolecules. BigSELFIES would combine hierarchical notation with stochastic building blocks to handle these complex systems where traditional small-molecule representations break down.</p>
<p><strong>Crystal Structures (Projects 4-5)</strong>: Crystals present unique challenges due to their infinite, periodic arrangements. An infinite net cannot be represented by a finite string directly. The proposed approach uses <strong>labeled quotient graphs (LQGs)</strong>, which are finite graphs that uniquely determine a periodic net. However, current SELFIES cannot represent LQGs because they lack symbols for edge directions and edge labels (vector shifts encoding periodicity). Extending SELFIES to handle these structures could enable AI-driven materials design without relying on predefined crystal structures, opening up systematic exploration of theoretical materials space.</p>
<p><strong>Beyond Organic Chemistry (Project 6)</strong>: Transition metals and main-group compounds feature complex bonding that breaks the simple two-center, two-electron model. The solution: use machine learning on large structural databases to automatically learn these complex bonding rules.</p>
<h3 id="chemical-reactions-and-programming-concepts">Chemical Reactions and Programming Concepts</h3>
<p><strong>Reaction Representations (Project 7)</strong>: Moving beyond static molecules to represent chemical transformations. A robust reaction format would enforce conservation laws and could learn reactivity patterns from large reaction datasets, improving synthesis planning.</p>
<h3 id="developing-a-100-robust-programming-language">Developing a 100% Robust Programming Language</h3>
<p><strong>Programming Language Perspective (Projects 8-9)</strong>: An intriguing reframing views molecular representations as programming languages executed by chemical parsers. This opens possibilities for adding loops, logic, and other programming concepts to efficiently describe complex structures. The ambitious goal is a Turing-complete programming language that is also 100% robust. While fascinating, it is worth critically noting that enforcing 100% syntactical robustness inherently restricts grammar flexibility. Can a purely robust string representation realistically describe highly fuzzy, delocalized electron bonds (like in Project 6) without becoming impractically long or collapsing into specialized sub-languages?</p>
<p><strong>Empirical Comparisons (Projects 10-11)</strong>: With multiple representation options (strings, matrices, images), we need systematic comparisons. The proposed benchmarks would go beyond simple validity metrics to focus on real-world design objectives in drug discovery, catalysis, and materials science.</p>
<p><strong>Human Readability (Project 12)</strong>: While SMILES is often called &ldquo;human-readable,&rdquo; this claim lacks scientific validation. The proposed study would test how well humans actually understand different molecular representations.</p>
<p><strong>Machine Learning Perspectives (Projects 13-16)</strong>: These projects explore how machines interpret molecular representations:</p>
<ul>
<li>Training networks to translate between formats to find universal representations</li>
<li>Comparing learning efficiency across different formats</li>
<li>Investigating latent space smoothness in generative models</li>
<li>Visualizing what models actually learn about molecular structure</li>
</ul>
<h2 id="reproducibility-details">Reproducibility Details</h2>
<p>Since this is a position paper outlining future research directions, standard empirical reproducibility metrics do not apply. However, the foundational tools required to pursue the proposed roadmap are open-source.</p>
<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/aspuru-guzik-group/selfies">aspuru-guzik-group/selfies</a></td>
          <td>Code</td>
          <td>Apache-2.0</td>
          <td>Core SELFIES Python library, installable via <code>pip install selfies</code></td>
      </tr>
      <tr>
          <td><a href="https://arxiv.org/abs/2204.00056">arXiv:2204.00056</a></td>
          <td>Paper</td>
          <td>N/A</td>
          <td>Open-access preprint of the published Patterns article</td>
      </tr>
  </tbody>
</table>
<h2 id="paper-information">Paper Information</h2>
<p><strong>Citation</strong>: Krenn, M., Ai, Q., Barthel, S., Carson, N., Frei, A., Frey, N. C., Friederich, P., Gaudin, T., Gayle, A. A., Jablonka, K. M., Lameiro, R. F., Lemm, D., Lo, A., Moosavi, S. M., Nápoles-Duarte, J. M., Nigam, A., Pollice, R., Rajan, K., Schatzschneider, U., &hellip; Aspuru-Guzik, A. (2022). SELFIES and the future of molecular string representations. <em>Patterns</em>, <em>3</em>(10). <a href="https://doi.org/10.1016/j.patter.2022.100588">https://doi.org/10.1016/j.patter.2022.100588</a></p>
<p><strong>Publication</strong>: Patterns 2022</p>
<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">@article</span>{Krenn2022,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">title</span> = <span style="color:#e6db74">{SELFIES and the future of molecular string representations}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">volume</span> = <span style="color:#e6db74">{3}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">ISSN</span> = <span style="color:#e6db74">{2666-3899}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">url</span> = <span style="color:#e6db74">{http://dx.doi.org/10.1016/j.patter.2022.100588}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">DOI</span> = <span style="color:#e6db74">{10.1016/j.patter.2022.100588}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">number</span> = <span style="color:#e6db74">{10}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">journal</span> = <span style="color:#e6db74">{Patterns}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">publisher</span> = <span style="color:#e6db74">{Elsevier BV}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">author</span> = <span style="color:#e6db74">{Krenn, Mario and Ai, Qianxiang and Barthel, Senja and Carson, Nessa and Frei, Angelo and Frey, Nathan C. and Friederich, Pascal and Gaudin, Théophile and Gayle, Alberto Alexander and Jablonka, Kevin Maik and Lameiro, Rafael F. and Lemm, Dominik and Lo, Alston and Moosavi, Seyed Mohamad and Nápoles-Duarte, José Manuel and Nigam, AkshatKumar and Pollice, Robert and Rajan, Kohulan and Schatzschneider, Ulrich and Schwaller, Philippe and Skreta, Marta and Smit, Berend and Strieth-Kalthoff, Felix and Sun, Chong and Tom, Gary and von Rudorff, Guido Falk and Wang, Andrew and White, Andrew and Young, Adamo and Yu, Rose and Aspuru-Guzik, Alán}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">year</span> = <span style="color:#e6db74">{2022}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">month</span> = oct,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">pages</span> = <span style="color:#e6db74">{100588}</span>
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div><p><strong>Additional Resources</strong>:</p>
<ul>
<li><a href="/notes/chemistry/molecular-representations/notations/selfies-original-paper/">Original SELFIES Paper</a></li>
<li><a href="/notes/chemistry/molecular-representations/notations/selfies/">SELFIES Overview</a></li>
</ul>
]]></content:encoded></item><item><title>Invalid SMILES Benefit Chemical Language Models: A Study</title><link>https://hunterheidenreich.com/notes/chemistry/molecular-representations/notations/invalid-smiles-help/</link><pubDate>Tue, 02 Dec 2025 00:00:00 +0000</pubDate><guid>https://hunterheidenreich.com/notes/chemistry/molecular-representations/notations/invalid-smiles-help/</guid><description>Skinnider (2024) shows that generating invalid SMILES actually improves chemical language model performance through quality filtering.</description><content:encoded><![CDATA[<h2 id="core-contribution-repurposing-invalid-smiles">Core Contribution: Repurposing Invalid SMILES</h2>
<p>This is an <strong>Empirical</strong> paper that challenges a fundamental assumption in the field of chemical language models. Skinnider provides both empirical evidence and mechanistic explanations for why the ability to generate &ldquo;invalid&rdquo; SMILES strings is beneficial for model performance.</p>
<h2 id="the-problem-with-absolute-validity-in-chemical-lms">The Problem with Absolute Validity in Chemical LMs</h2>
<p>Prior research attempted to eliminate invalid generations using constrained representations like SELFIES. This paper demonstrates that invalid outputs serve as low-likelihood samples whose removal acts as an implicit quality filter, improving distribution learning.</p>
<h2 id="invalid-generation-as-an-implicit-quality-filter">Invalid Generation as an Implicit Quality Filter</h2>
<p>The central insight is counterintuitive: <strong>invalid SMILES generation acts as a built-in quality control mechanism</strong>. The key contributions are:</p>
<ol>
<li>
<p><strong>Empirical Evidence</strong>: Direct comparisons showing that SMILES-based models consistently outperform SELFIES-based models across multiple metrics, with performance gains strongly correlated with the proportion of invalid outputs generated.</p>
</li>
<li>
<p><strong>Mechanistic Explanation</strong>: Invalid SMILES are demonstrated to be low-likelihood samples from the model&rsquo;s probability distribution. When these are filtered out, it&rsquo;s equivalent to removing the model&rsquo;s least confident predictions, a form of automatic quality control.</p>
</li>
<li>
<p><strong>Causal Evidence</strong>: By modifying SELFIES to allow invalid generation (through relaxed constraints), the author shows that performance improves when models can generate and discard invalid outputs, directly proving the causal relationship.</p>
</li>
<li>
<p><strong>Bias Analysis</strong>: SELFIES models are shown to introduce systematic structural biases (fewer aromatic rings, more aliphatic rings) due to their validity constraints, limiting their ability to explore chemical space naturally.</p>
</li>
</ol>
<h2 id="experimental-design-and-causal-interventions">Experimental Design and Causal Interventions</h2>
<p>The paper uses a multi-pronged approach to establish both correlation and causation:</p>
<p><strong>Performance Comparisons</strong>: SMILES and SELFIES models were trained on identical datasets and evaluated using distribution-learning metrics like Fréchet ChemNet distance. The comparison was robust across different architectures, training set sizes, and chemical databases.</p>
<p><strong>Loss Analysis</strong>: The relationship between SMILES validity and model confidence was examined by analyzing the sequence loss. For a given SMILES string $S$ composed of tokens $t_1, t_2, &hellip;, t_N$, the negative log-likelihood acts as a proxy for the model&rsquo;s uncertainty:</p>
<p>$$ \text{NLL}(S) = -\sum_{i=1}^N \log P(t_i | t_1, &hellip;, t_{i-1}) $$</p>
<p>Invalid SMILES strings consistently register higher $\text{NLL}$ scores, meaning they represent the model&rsquo;s least confident predictions. Filtering them effectively acts as automatic quality control, providing the mechanistic explanation for why invalid filtering improves performance.</p>
<p><strong>Causal Intervention</strong>: A key experiment involved modifying the SELFIES valency constraints at two levels: first allowing pentavalent carbons (&ldquo;Texas SELFIES&rdquo;), then removing all constraints entirely (&ldquo;unconstrained SELFIES&rdquo;). This allowed direct testing of whether the ability to generate invalid outputs (which are then discarded) causally improves performance.</p>
<p><strong>Structural Bias Analysis</strong>: Generated molecules were analyzed for chemical features like ring types and bond patterns to quantify how validity constraints systematically distort the model&rsquo;s exploration of chemical space.</p>
<p><strong>Generalization Testing</strong>: Models were trained on subsets of chemical databases and tested on their ability to reproduce the broader chemical space, measuring how validity constraints affect generalization.</p>
<p><strong>Practical Application</strong>: The approach was tested on structure elucidation, using models to identify unknown molecules from minimal experimental data like mass spectrometry.</p>
<h2 id="key-findings-on-validity-constraints-and-bias">Key Findings on Validity Constraints and Bias</h2>
<p><strong>Superior Performance Across the Board</strong>: SMILES-based models consistently outperformed SELFIES models on distribution-learning tasks. Using metrics like Fréchet ChemNet distance, SMILES models generated molecules that more closely matched the statistical properties of their training data. This performance advantage was directly correlated with the proportion of invalid SMILES generated. Models that produced more invalid outputs performed better after filtering.</p>
<p><strong>Invalid SMILES Are Low-Confidence Predictions</strong>: The analysis revealed that invalid SMILES consistently have higher loss values than valid ones, meaning they represent the model&rsquo;s least confident predictions. This suggests that validity checking acts as an automatic confidence filter, removing low-quality samples without requiring explicit uncertainty estimation.</p>
<p><strong>Causal Evidence Through Unconstrained SELFIES</strong>: Direct causal evidence came from modifying SELFIES to allow invalid generation. When &ldquo;unconstrained SELFIES&rdquo; models could generate and discard invalid molecules, their performance improved, approaching that of SMILES models. This provides direct causal evidence that the ability to generate invalid outputs is what drives the performance gains.</p>
<p><strong>Validity Constraints Introduce Systematic Bias</strong>: SELFIES models showed clear structural biases compared to both training data and SMILES outputs. They generated fewer aromatic rings and more aliphatic structures, systematic distortions caused by the valency constraints used to ensure validity. These biases limit the model&rsquo;s ability to faithfully represent chemical space.</p>
<p><strong>Reduced Generalization</strong>: When trained on subsets of chemical databases, SMILES models could reproduce a larger portion of the complete chemical space compared to SELFIES models. Although SELFIES generated more valid molecules in absolute terms, their structural biases constrained exploration and limited generalization beyond the training set.</p>
<p><strong>Real-World Application Benefits</strong>: In structure elucidation tasks, identifying unknown molecules from experimental data like mass spectrometry, SMILES-based models significantly outperformed SELFIES models. This demonstrates that the benefits extend beyond academic benchmarks to practical applications.</p>
<p><strong>CASMI 2022 Benchmark</strong>: The language model trained on the LOTUS database was benchmarked against 19 submissions to the CASMI 2022 competition for structure elucidation of unknown compounds. Using only accurate mass as input (no MS/MS data), the model achieved competitive performance, highlighting the practical utility of the sampling-frequency-based approach for de novo structure elucidation.</p>
<p><strong>Computational Efficiency</strong>: Filtering invalid SMILES is computationally trivial. Parsing ten million SMILES strings with RDKit takes approximately 7.5 minutes on a single CPU, making the post-processing overhead negligible compared to model training and inference costs.</p>
<h2 id="reproducibility-details">Reproducibility Details</h2>
<h3 id="models">Models</h3>
<p><strong>Primary Architecture (LSTM):</strong> The main results rely on a Recurrent Neural Network (RNN) using Long Short-Term Memory (LSTM) units.</p>
<ul>
<li><strong>Structure:</strong> Three-layer LSTM with a hidden layer size of 1,024 dimensions</li>
<li><strong>Embedding:</strong> An embedding layer of 128 dimensions</li>
<li><strong>Decoder:</strong> A linear decoder layer outputs token probabilities</li>
</ul>
<p><strong>Secondary Architecture (Transformer/GPT):</strong> To confirm robustness across architectures, the author also used a Generative Pretrained Transformer (GPT) architecture adapted from MolGPT.</p>
<ul>
<li><strong>Structure:</strong> Eight transformer blocks</li>
<li><strong>Internals:</strong> Each block contains eight masked self-attention heads and a feed-forward network (1,024 dimensions) using GELU activation</li>
<li><strong>Embedding:</strong> 256 dimensions, concatenated with learned positional encodings</li>
</ul>
<h3 id="algorithms">Algorithms</h3>
<p><strong>Optimizer:</strong> Adam optimizer for both architectures with $\beta_1=0.9$ and $\beta_2=0.999$.</p>
<p><strong>Learning Rate:</strong></p>
<ul>
<li>LSTM: 0.001</li>
<li>Transformer: 0.0005</li>
</ul>
<p><strong>Batch Size:</strong> 64</p>
<p><strong>Loss Function:</strong> Cross-entropy loss of next-token prediction.</p>
<p><strong>Stopping Criteria:</strong> Early stopping using a validation set (10% of training data) with patience of 50,000 minibatches.</p>
<h3 id="data">Data</h3>
<p><strong>Primary Source:</strong> ChEMBL database (version 28).</p>
<p><strong>Preprocessing Pipeline:</strong></p>
<ul>
<li><strong>Cleaning:</strong> Removal of duplicate SMILES, salts, and solvents (retaining heavy fragments with $\geq 3$ heavy atoms)</li>
<li><strong>Filtering:</strong> Molecules with atoms other than {Br, C, Cl, F, H, I, N, O, P, S} were removed</li>
<li><strong>Normalization:</strong> Charged molecules were neutralized and converted to canonical SMILES</li>
</ul>
<p><strong>Training Subsets:</strong> Models were trained on random samples of 30,000, 100,000, and 300,000 molecules to test scalability.</p>
<p><strong>Generalization Data:</strong> To test generalization, models were also trained on the <a href="/notes/chemistry/datasets/gdb-13/">GDB-13</a> database (enumerating drug-like molecules up to 13 heavy atoms).</p>
<p><strong>Structure Elucidation Data:</strong> For practical application tasks, models were trained on natural products (LOTUS, COCONUT), food compounds (FooDB), and environmental contaminants (NORMAN).</p>
<h3 id="evaluation">Evaluation</h3>
<p><strong>Primary Metric:</strong> Fréchet ChemNet Distance (FCD), measuring chemical similarity between generated molecules and the training set (lower is better).</p>
<p><strong>Secondary Metrics:</strong></p>
<ul>
<li><strong>Validity:</strong> Percentage of outputs parseable by RDKit</li>
<li><strong>Scaffold Similarity:</strong> Jensen-Shannon distances between Murcko scaffold compositions</li>
<li><strong>Physical Properties:</strong> Comparisons of molecular weight, LogP, topological polar surface area (TPSA), and ring counts (aromatic vs. aliphatic)</li>
<li><strong>Structure Elucidation:</strong> &ldquo;Top-k accuracy,&rdquo; the proportion of held-out molecules where the correct structure appeared in the model&rsquo;s top $k$ ranked outputs</li>
</ul>
<h3 id="hardware">Hardware</h3>
<ul>
<li><strong>Compute Nodes:</strong> Dell EMC C4140 GPU compute nodes</li>
<li><strong>GPUs:</strong> NVIDIA Tesla V100</li>
<li><strong>Compute Time:</strong> Parsing 10 million SMILES took ~7.5 minutes on a single CPU; SELFIES models required an average of 0.6 hours longer to train than SMILES models</li>
</ul>
<h3 id="replicability">Replicability</h3>
<p><strong>Code Availability:</strong> Source code and intermediate data are available via <a href="https://doi.org/10.5281/zenodo.10680855">Zenodo</a>. Pre-trained model weights are not provided in the archive, requiring researchers to train models from scratch using the included scripts to fully replicate the study.</p>
<p><strong>Data Availability:</strong> Training datasets and generated molecule samples (10 million from ChEMBL/GDB-13 models, 100 million from LOTUS/COCONUT/FooDB/NORMAN cross-validation folds) are available via <a href="https://doi.org/10.5281/zenodo.8321735">Zenodo</a>.</p>
<p><strong>Software Libraries:</strong></p>
<ul>
<li><strong>PyTorch:</strong> LSTM and Transformer implementations</li>
<li><strong>RDKit:</strong> SMILES parsing, validity checking, and property calculation</li>
<li><strong>SELFIES:</strong> Version 2.1.1 for conversion</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://doi.org/10.5281/zenodo.10680855">Source code (Zenodo)</a></td>
          <td>Code</td>
          <td>Unknown</td>
          <td>Training scripts, analysis code, and intermediate data</td>
      </tr>
      <tr>
          <td><a href="https://doi.org/10.5281/zenodo.8321735">Training and generated molecules (Zenodo)</a></td>
          <td>Dataset</td>
          <td>Unknown</td>
          <td>Preprocessed training sets and sampled molecules</td>
      </tr>
  </tbody>
</table>
<h2 id="implications-and-takeaways">Implications and Takeaways</h2>
<p>This work reframes how we think about &ldquo;errors&rdquo; in generative models. The key insight is that model outputs appearing incorrect often represent low-likelihood samples whose removal improves overall performance.</p>
<p>The findings suggest that the field&rsquo;s drive toward guaranteed validity leads to systematic biases. Letting models fail informatively and using those failures as quality signals can yield better distribution learning. This is relevant as the field moves toward larger, more capable models where such self-correction mechanisms become increasingly valuable.</p>
<p>For practitioners, the takeaway is to consider the role of invalid outputs before eliminating them. Filtering low-confidence generations provides automatic quality control that improves final results.</p>
<h2 id="paper-information">Paper Information</h2>
<p><strong>Citation</strong>: Skinnider, M. A. (2024). Invalid SMILES are beneficial rather than detrimental to chemical language models. Nature Machine Intelligence, 6(4), 437-448. <a href="https://doi.org/10.1038/s42256-024-00821-x">https://doi.org/10.1038/s42256-024-00821-x</a></p>
<p><strong>Publication</strong>: Nature Machine Intelligence (2024)</p>
<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">@article</span>{skinnider2024invalid,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">title</span>=<span style="color:#e6db74">{Invalid SMILES are beneficial rather than detrimental to chemical language models}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">author</span>=<span style="color:#e6db74">{Skinnider, Michael A}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">journal</span>=<span style="color:#e6db74">{Nature Machine Intelligence}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">volume</span>=<span style="color:#e6db74">{6}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">number</span>=<span style="color:#e6db74">{4}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">pages</span>=<span style="color:#e6db74">{437--448}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">year</span>=<span style="color:#e6db74">{2024}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">publisher</span>=<span style="color:#e6db74">{Nature Publishing Group UK London}</span>
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div>]]></content:encoded></item><item><title>SMILES Notation: The Original Paper by Weininger (1988)</title><link>https://hunterheidenreich.com/notes/chemistry/molecular-representations/notations/smiles-original-paper/</link><pubDate>Sun, 12 Oct 2025 00:00:00 +0000</pubDate><guid>https://hunterheidenreich.com/notes/chemistry/molecular-representations/notations/smiles-original-paper/</guid><description>Weininger's 1988 paper introducing SMILES notation, a string-based molecular representation that became a standard in computational chemistry.</description><content:encoded><![CDATA[<h2 id="paper-information">Paper Information</h2>
<p><strong>Citation</strong>: Weininger, D. (1988). SMILES, a chemical language and information system. 1. Introduction to methodology and encoding rules. <em>Journal of Chemical Information and Computer Sciences</em>, 28(1), 31-36. <a href="https://doi.org/10.1021/ci00057a005">https://doi.org/10.1021/ci00057a005</a></p>
<p><strong>Publication</strong>: Journal of Chemical Information and Computer Sciences, 1988</p>
<p><strong>Additional Resources</strong>:</p>
<ul>
<li><a href="/notes/chemistry/molecular-representations/notations/smiles/">SMILES notation overview</a> - Modern usage summary</li>
<li><a href="/posts/visualizing-smiles-and-selfies-strings/">Converting SMILES to 2D images</a> - Practical visualization tutorial</li>
</ul>
<h2 id="core-contribution-a-string-based-molecular-notation">Core Contribution: A String-Based Molecular Notation</h2>
<p>This is a <strong>Method</strong> paper that introduces a novel notation system for representing chemical structures as text strings. It establishes the encoding rules and input conventions for SMILES (Simplified Molecular Input Line Entry System), while explicitly deferring the canonicalization algorithm to subsequent papers in the series.</p>
<h2 id="the-computational-complexity-of-chemical-information-in-the-1980s">The Computational Complexity of Chemical Information in the 1980s</h2>
<p>As computers became central to chemical information processing in the 1980s, the field faced a fundamental problem: existing line notations were either too complex for chemists to use practically or too limited for computational applications. Previous systems required extensive training to write correctly and were prone to errors.</p>
<p>The goal was ambitious: create a system that could represent any molecule as a simple text string, making it both human-readable and machine-efficient. This would enable compact database storage, fast processing, and easy exchange between software systems.</p>
<h2 id="separating-input-rules-from-canonicalization">Separating Input Rules from Canonicalization</h2>
<p>Weininger&rsquo;s key insight was to separate the problem into two parts: create simple, flexible rules that chemists could easily learn for input, while deferring to the computer the complex task of generating a unique, canonical representation. This division of labor made SMILES both practical and powerful.</p>
<p>The specific innovations include:</p>
<ol>
<li><strong>Simple input rules</strong> - Chemists could write molecules intuitively (e.g., <code>CCO</code> or <code>OCC</code> for ethanol)</li>
<li><strong>Ring closure notation</strong> - Breaking one bond and marking ends with matching digits</li>
<li><strong>Implicit hydrogens</strong> - Automatic calculation based on standard valences keeps strings compact</li>
<li><strong>Algorithmic aromaticity detection</strong> - Automatic recognition of aromatic systems from Kekulé structures</li>
<li><strong>Human-readable output</strong> - Unlike binary formats, SMILES strings are readable and debuggable</li>
</ol>
<p><strong>Important scope note</strong>: This first paper in the series establishes the input syntax and encoding rules. The canonicalization algorithm (how to generate unique SMILES) is explicitly stated as the subject of following papers: &ldquo;specification of isomerisms, substructures, and unique SMILES generation are the subjects of following papers.&rdquo;</p>
<h2 id="demonstrating-notation-rules-across-molecular-classes">Demonstrating Notation Rules Across Molecular Classes</h2>
<p>The paper is primarily a specification document establishing notation rules. The methodology is demonstrated through worked examples showing how to encode various molecular structures:</p>
<ul>
<li><strong>Basic molecules</strong>: Ethane (<code>CC</code>), ethylene (<code>C=C</code>), acetylene (<code>C#C</code>)</li>
<li><strong>Branches</strong>: Isobutyric acid (<code>CC(C)C(=O)O</code>)</li>
<li><strong>Rings</strong>: Cyclohexane (<code>C1CCCCC1</code>), benzene (<code>c1ccccc1</code>)</li>
<li><strong>Aromatic systems</strong>: Tropone (<code>O=c1cccccc1</code>), quinone (showing exocyclic bond effects)</li>
<li><strong>Complex structures</strong>: Morphine (40 characters vs 1000-2000 for connection tables)</li>
<li><strong>Edge cases</strong>: Salts, isotopes, charged species, tautomers</li>
</ul>
<p>Performance comparisons are mentioned qualitatively: SMILES processing was approximately 100 times faster than traditional connection table methods on the hardware of the era (1988), with dramatic reductions in storage space.</p>
<h2 id="performance-and-practical-viability">Performance and Practical Viability</h2>
<p>The paper successfully establishes SMILES as a practical notation system with several key outcomes:</p>
<p><strong>Practical benefits</strong>:</p>
<ul>
<li><strong>Compactness</strong>: 40 characters for morphine vs 1000-2000 for connection tables</li>
<li><strong>Speed</strong>: ~100x faster processing than traditional methods</li>
<li><strong>Accessibility</strong>: Simple enough for chemists to learn without extensive training</li>
<li><strong>Machine-friendly</strong>: Efficient parsing and string-based operations</li>
</ul>
<p><strong>Design principles validated</strong>:</p>
<ul>
<li>Separating user input from canonical representation makes the system both usable and rigorous</li>
<li>Implicit hydrogens reduce string length without loss of information</li>
<li>Ring closure notation with digit markers is more intuitive than complex graph syntax</li>
<li>Automatic aromaticity detection handles most cases correctly</li>
</ul>
<p><strong>Acknowledged limitations</strong>:</p>
<ul>
<li>Canonicalization algorithm not included in this paper</li>
<li>Stereochemistry handling deferred to subsequent papers</li>
<li>Some edge cases (like unusual valence states) require explicit specification</li>
</ul>
<p>The paper concludes by positioning SMILES as a foundation for database storage, substructure searching, and chemical informatics applications - a vision that proved accurate as SMILES became one of the most widely used molecular representations in computational chemistry.</p>
<h2 id="reproducibility-details">Reproducibility Details</h2>
<p>To implement the method described in this paper, the following look-up tables and algorithms are required. <strong>Note</strong>: These details are critical for replication but are often glossed over in high-level summaries.</p>
<h3 id="1-the-valence-look-up-table">1. The Valence Look-Up Table</h3>
<p>To calculate implicit hydrogens, the system assumes the &ldquo;lowest normal valence&rdquo; greater than or equal to the explicit bond count. The paper explicitly defines these valences:</p>
<table>
  <thead>
      <tr>
          <th>Element</th>
          <th>Allowed Valences</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>B</td>
          <td>3</td>
      </tr>
      <tr>
          <td>C</td>
          <td>4</td>
      </tr>
      <tr>
          <td>N</td>
          <td>3, 5</td>
      </tr>
      <tr>
          <td>O</td>
          <td>2</td>
      </tr>
      <tr>
          <td>P</td>
          <td>3, 5</td>
      </tr>
      <tr>
          <td>S (aliphatic)</td>
          <td>2, 4, 6</td>
      </tr>
      <tr>
          <td>S (aromatic)</td>
          <td>3, 5</td>
      </tr>
      <tr>
          <td>F, Cl, Br, I</td>
          <td>1</td>
      </tr>
  </tbody>
</table>
<p><strong>Example</strong>: For sulfur in $\text{H}_2\text{SO}_4$ written as <code>OS(=O)(=O)O</code>, the explicit bond count is 6 (two single bonds + two double bonds to four oxygens), so the system uses valence 6 with zero implicit hydrogens. Without knowing S allows valence 6, the algorithm would fail.</p>
<h3 id="2-explicit-hydrogen-requirements">2. Explicit Hydrogen Requirements</h3>
<p>The paper lists exactly three cases where hydrogen atoms are retained (not suppressed):</p>
<ol>
<li><strong>Hydrogen connected to other hydrogen</strong> (molecular hydrogen, $\text{H}_2$, written as <code>[H][H]</code>)</li>
<li><strong>Hydrogen connected to zero or more than one other atom</strong> (bridging hydrogens, isolated protons)</li>
<li><strong>Isotopic hydrogen specifications</strong> in isomeric SMILES (deuterium <code>[2H]</code>, tritium <code>[3H]</code>)</li>
</ol>
<p>For all other cases, hydrogens are implicit and calculated from the valence table.</p>
<h3 id="3-ring-closure-notation">3. Ring Closure Notation</h3>
<p>Standard SMILES supports single digits <code>1-9</code> for ring closures. For rings numbered 10 and higher, the notation requires a <strong>percent sign prefix</strong>:</p>
<ul>
<li>Ring closures 1-9: <code>C1CCCCC1</code></li>
<li>Ring closures 10+: <code>C%10CCCCC%10</code>, <code>C2%13%24</code> (ring 2, ring 13, ring 24)</li>
</ul>
<p>Without this rule, a parser would fail on large polycyclic structures.</p>
<h3 id="4-aromaticity-detection-algorithm">4. Aromaticity Detection Algorithm</h3>
<p>The system uses an extended version of Hückel&rsquo;s Rule ($4N+2$ π-electrons). The &ldquo;excess electron&rdquo; count for the aromatic system is determined by these rules:</p>
<p><strong>Carbon contribution</strong>:</p>
<ul>
<li><strong>C in aromatic ring</strong>: Contributes 1 electron</li>
<li><strong>C double-bonded to exocyclic electronegative atom</strong> (e.g., $\text{C}=\text{O}$ in quinone): Contributes 0 electrons (the carbon &ldquo;loses&rdquo; its electron to the oxygen)</li>
</ul>
<p><strong>Heteroatom contribution</strong>:</p>
<ul>
<li><strong>O, S in ring</strong>: Contributes 2 electrons (lone pair)</li>
<li><strong>N in ring</strong>: Contributes 1 electron (pyridine-like) or 2 electrons (pyrrole-like, must have explicit hydrogen <code>[nH]</code>)</li>
</ul>
<p><strong>Charge effects</strong>:</p>
<ul>
<li><strong>Positive charge</strong>: Reduces electron count by 1</li>
<li><strong>Negative charge</strong>: Increases electron count by 1</li>
</ul>
<p><strong>Critical example - Quinone</strong>:</p>
<pre tabindex="0"><code>O=C1C=CC(=O)C=C1
</code></pre><p>Quinone has 6 carbons in the ring, but the two carbons bonded to exocyclic oxygens contribute 0 electrons each. The four remaining carbons contribute 4 electrons total (not 6), so quinone is <strong>not aromatic</strong> by this algorithm. This exocyclic bond rule is essential for correct aromaticity detection.</p>
<p><strong>Aromatic ring test</strong>:</p>
<ol>
<li>All atoms must be sp² hybridized</li>
<li>Count excess electrons using the rules above</li>
<li>Calculate whether the system complies with Hückel&rsquo;s parity rule constraint:
$$ \text{Excess Electrons} \equiv 2 \pmod 4 \iff \text{Excess Electrons} = 4N + 2 $$
If the electron count satisfies this property for some integer $N$, the ring is determined to be aromatic.</li>
</ol>
<h2 id="encoding-rules-reference">Encoding Rules Reference</h2>
<p>The following sections provide a detailed reference for the six fundamental SMILES encoding rules. These are the rules a user would apply when writing SMILES strings.</p>
<h3 id="1-atoms">1. Atoms</h3>
<p>Atoms use their standard chemical symbols. Elements in the &ldquo;organic subset&rdquo; (B, C, N, O, P, S, F, Cl, Br, I) can be written directly when they have their most common valence - so <code>C</code> automatically means a carbon with enough implicit hydrogens to satisfy its valence.</p>
<p>Everything else goes in square brackets: <code>[Au]</code> for gold, <code>[NH4+]</code> for ammonium ion, or <code>[13C]</code> for carbon-13. Aromatic atoms get lowercase letters: <code>c</code> for aromatic carbon in benzene.</p>
<h3 id="2-bonds">2. Bonds</h3>
<p>Bond notation is straightforward:</p>
<ul>
<li><code>-</code> for single bonds (usually omitted)</li>
<li><code>=</code> for double bonds</li>
<li><code>#</code> for triple bonds</li>
<li><code>:</code> for aromatic bonds (also usually omitted)</li>
</ul>
<p>So <code>CC</code> and <code>C-C</code> both represent ethane, while <code>C=C</code> is ethylene.</p>
<h3 id="3-branches">3. Branches</h3>
<p>Branches use parentheses, just like in mathematical expressions. Isobutyric acid becomes <code>CC(C)C(=O)O</code> - the main chain is <code>CC C(=O)O</code> with a methyl <code>(C)</code> branch.</p>
<h3 id="4-rings">4. Rings</h3>
<p>This is where SMILES gets clever. You break one bond and mark both ends with the same digit. Cyclohexane becomes <code>C1CCCCC1</code> - the <code>1</code> connects the first and last carbon, closing the ring.</p>
<p>You can reuse digits for different rings in the same molecule, making complex structures manageable.</p>
<h3 id="5-disconnected-parts">5. Disconnected Parts</h3>
<p>Salts and other disconnected structures use periods. Sodium phenoxide: <code>[Na+].[O-]c1ccccc1</code>. The order doesn&rsquo;t matter - you&rsquo;re just listing the separate components.</p>
<h3 id="6-aromaticity">6. Aromaticity</h3>
<p>Aromatic rings can be written directly with lowercase letters. Benzoic acid becomes <code>c1ccccc1C(=O)O</code>. The system can also detect aromaticity automatically from Kekulé structures, so <code>C1=CC=CC=C1C(=O)O</code> works just as well.</p>
<h3 id="simplified-subset-for-organic-chemistry">Simplified Subset for Organic Chemistry</h3>
<p>Weininger recognized that most chemists work primarily with organic compounds, so he defined a simplified subset that covers the vast majority of cases. For organic molecules, you only need four rules:</p>
<ol>
<li><strong>Atoms</strong>: Use standard symbols (C, N, O, etc.)</li>
<li><strong>Multiple bonds</strong>: Use <code>=</code> and <code>#</code> for double and triple bonds</li>
<li><strong>Branches</strong>: Use parentheses <code>()</code></li>
<li><strong>Rings</strong>: Use matching digits</li>
</ol>
<p>This &ldquo;basic SMILES&rdquo; covers the vast majority of organic compounds, making the system immediately accessible without having to learn all the edge cases.</p>
<h2 id="design-decisions-and-edge-cases">Design Decisions and Edge Cases</h2>
<p>Beyond the basic rules, the paper established several important conventions for handling ambiguous cases:</p>
<h3 id="hydrogen-handling">Hydrogen Handling</h3>
<p>Hydrogens are usually implicit - the system calculates how many each atom needs based on standard valences. So <code>C</code> represents CH₄, <code>N</code> represents NH₃, and so on. This keeps strings compact and readable.</p>
<p>Explicit hydrogens only appear in special cases: when hydrogen connects to multiple atoms, when you need to specify an exact count, or in isotopic specifications like <code>[2H]</code> for deuterium.</p>
<h3 id="bond-representation">Bond Representation</h3>
<p>The paper made an important choice about how to represent bonds in ambiguous cases. For example, nitromethane could be written as charge-separated <code>C[N+](=O)[O-]</code> or with covalent double bonds <code>CN(=O)=O</code>. Weininger chose to prefer the covalent form when possible, because it preserves the correct topological symmetry.</p>
<p>However, when covalent representation would require unusual valences, charge separation is preferred. Diazomethane becomes <code>C=[N+]=[N-]</code> to avoid forcing carbon into an unrealistic valence state.</p>
<h3 id="tautomers">Tautomers</h3>
<p>SMILES doesn&rsquo;t try to be too clever about tautomers - it represents exactly what you specify. So 2-pyridone can be written as either the enol form <code>Oc1ncccc1</code> or the keto form <code>O=c1[nH]cccc1</code>. The system won&rsquo;t automatically convert between them.</p>
<p>This explicit approach means you need to decide which tautomeric form to represent, but it also means the notation precisely captures what you intend.</p>
<h3 id="aromaticity-detection">Aromaticity Detection</h3>
<p>One of the most sophisticated parts of the original system was automatic aromaticity detection. The algorithm uses an extended Hückel rule: a ring is aromatic if all atoms are sp² hybridized and it contains 4N+2 π-electrons.</p>
<p>This means you can input benzene as the Kekulé structure <code>C1=CC=CC=C1</code> and the system will automatically recognize it as aromatic and convert it to <code>c1ccccc1</code>. The algorithm handles complex cases like tropone (<code>O=c1cccccc1</code>) and correctly identifies them as aromatic.</p>
<h3 id="aromatic-nitrogen">Aromatic Nitrogen</h3>
<p>The system makes an important distinction for nitrogen in aromatic rings. Pyridine-type nitrogen (like in pyridine itself) is written as <code>n</code> and has no attached hydrogens. Pyrrole-type nitrogen has an attached hydrogen that must be specified explicitly: <code>[nH]1cccc1</code> for pyrrole.</p>
<p>This distinction captures the fundamental difference in electron contribution between these two nitrogen types in aromatic systems.</p>
<h2 id="impact-and-legacy">Impact and Legacy</h2>
<p>Nearly four decades later, SMILES remains one of the most widely used molecular notations in computational chemistry. The notation became the foundation for:</p>
<ul>
<li><strong>Database storage</strong> - Compact, searchable molecular representations</li>
<li><strong>Substructure searching</strong> - Pattern matching in chemical databases</li>
<li><strong>Property prediction</strong> - Input format for QSAR models</li>
<li><strong>Chemical informatics</strong> - Standard exchange format between software</li>
<li><strong>Modern ML</strong> - Text-based representation for neural networks</li>
</ul>
<p>While newer approaches like <a href="/notes/chemistry/molecular-representations/notations/selfies/">SELFIES</a> have addressed some limitations (like the possibility of invalid strings), SMILES&rsquo; combination of simplicity and power has made it enduringly useful.</p>
<p>The paper established both a notation system and a design philosophy: chemical informatics tools should be powerful enough for computers while remaining accessible to working chemists. That balance remains relevant today as we develop new molecular representations for machine learning and AI applications.</p>
]]></content:encoded></item><item><title>SELFIES: The Original Paper on Robust Molecular Strings</title><link>https://hunterheidenreich.com/notes/chemistry/molecular-representations/notations/selfies-original-paper/</link><pubDate>Sun, 12 Oct 2025 00:00:00 +0000</pubDate><guid>https://hunterheidenreich.com/notes/chemistry/molecular-representations/notations/selfies-original-paper/</guid><description>The 2020 paper introducing SELFIES, the 100% robust molecular representation that solves SMILES validity problems in ML applications.</description><content:encoded><![CDATA[<h2 id="contribution-a-100-robust-representation-for-ml">Contribution: A 100% Robust Representation for ML</h2>
<p>This is a <strong>Method</strong> paper that introduces a new molecular string representation designed specifically for machine learning applications.</p>
<h2 id="motivation-the-invalidity-bottleneck">Motivation: The Invalidity Bottleneck</h2>
<p>When neural networks generate molecules using <a href="/notes/chemistry/molecular-representations/notations/smiles/">SMILES notation</a>, a huge fraction of output strings are invalid: either syntax errors or chemically impossible structures. This was a fundamental bottleneck: if your generative model produces a large fraction of invalid molecules, you are wasting computational effort and severely limiting chemical space exploration.</p>
<h2 id="novelty-a-formal-grammar-approach">Novelty: A Formal Grammar Approach</h2>
<p>The authors&rsquo; key insight was using a <strong>formal grammar approach</strong> (specifically, a Chomsky type-2, context-free grammar with self-referencing functions) where each symbol is interpreted based on chemical context. The &ldquo;state of the derivation&rdquo; tracks available valence bonds, preventing impossible structures like a carbon with five single bonds.</p>
<p>For example, generating 2-Fluoroethenimine (<code>FC=C=N</code>) follows a state derivation where each step restricts the available valency for the next element:</p>
<p>$$
\mathbf{X}_0 \xrightarrow{[F]} \text{F } \mathbf{X}_1 \xrightarrow{[=C]} \text{FC } \mathbf{X}_3 \xrightarrow{[=C]} \text{FC=C } \mathbf{X}_2 \xrightarrow{[\#N]} \text{FC=C=N}
$$</p>
<p>This approach guarantees 100% validity: every SELFIES string corresponds to a valid molecule, and every valid molecule can be represented.</p>
<h2 id="methodology--experiments-validating-robustness">Methodology &amp; Experiments: Validating Robustness</h2>
<p>The authors ran several experiments to demonstrate SELFIES&rsquo; robustness:</p>
<h3 id="random-mutation-test">Random Mutation Test</h3>
<p>They took the SELFIES and <a href="/notes/chemistry/molecular-representations/notations/smiles/">SMILES</a> representations of MDMA and introduced random changes:</p>
<ul>
<li><strong>SMILES</strong>: After just one random mutation, only 9.9% of strings remained valid (dropping to 1.1% after three mutations).</li>
<li><strong>SELFIES</strong>: 100% of mutated strings still represented valid molecules (though different from the original).</li>
</ul>
<p>This empirical difference demonstrates why SELFIES is well suited for evolutionary algorithms and genetic programming approaches to molecular design, where random mutations of strings are a core operation.</p>
<h3 id="generative-model-performance">Generative Model Performance</h3>
<p>The real test came with actual machine learning models. The authors trained Variational Autoencoders (VAEs) and Generative Adversarial Networks (GANs) on both representations:</p>
<p><strong>VAE Results:</strong></p>
<ul>
<li>SMILES-based VAE: Large invalid regions scattered throughout the latent space</li>
<li>SELFIES-based VAE: Every point in the continuous latent space mapped to a valid molecule</li>
<li>The SELFIES model encoded <strong>over 100 times more diverse molecules</strong></li>
</ul>
<p><strong>GAN Results:</strong></p>
<ul>
<li>Best SMILES GAN: 18.6% diverse, valid molecules</li>
<li>Best SELFIES GAN: 78.9% diverse, valid molecules</li>
</ul>
<p><strong>Evaluation Metrics:</strong></p>
<ul>
<li><strong>Validity</strong>: Percentage of generated strings representing valid molecular structures</li>
<li><strong>Diversity</strong>: Number of unique valid molecules produced</li>
<li><strong>Reconstruction Accuracy</strong>: How well the autoencoder reproduced input molecules</li>
</ul>
<h3 id="scalability-test">Scalability Test</h3>
<p>The authors showed SELFIES works beyond toy molecules by successfully encoding and decoding all <strong>72 million molecules</strong> from the PubChem database (with fewer than 500 SMILES characters per molecule), demonstrating practical applicability to real chemical databases.</p>
<h2 id="results--conclusions-chemical-space-exploration">Results &amp; Conclusions: Chemical Space Exploration</h2>
<p><strong>Key Findings:</strong></p>
<ul>
<li>SELFIES achieves 100% validity guarantee: every string represents a valid molecule</li>
<li>SELFIES-based VAEs encode over 100x more diverse molecules than SMILES-based models</li>
<li>SELFIES-based GANs produce 78.9% diverse valid molecules vs. 18.6% for SMILES GANs</li>
<li>Successfully validated on all 72 million PubChem molecules</li>
</ul>
<p><strong>Limitations Acknowledged:</strong></p>
<ul>
<li>No standardization or canonicalization method at time of publication</li>
<li>The initial grammar covered only small biomolecules; extensions for stereochemistry, ions, polyvalency, and full periodic table coverage were planned</li>
<li>Requires community testing and adoption</li>
</ul>
<p><strong>Impact:</strong></p>
<p>This work demonstrated that designing ML-native molecular representations could enable new approaches in drug discovery and materials science. SELFIES was subsequently evaluated as an alternative input representation to SMILES in <a href="/notes/chemistry/molecular-representations/encoders/chemberta/">ChemBERTa</a>, a transformer pretrained on molecular strings for property prediction, where it performed comparably to SMILES on the Tox21 benchmark, though the comparison was limited to a single task.</p>
<h2 id="reproducibility-details">Reproducibility Details</h2>
<h3 id="data">Data</h3>
<p>The machine learning experiments used two distinct datasets:</p>
<ul>
<li><strong>QM9</strong> (134k molecules): Primary training dataset for VAE and GAN models</li>
<li><strong>PubChem</strong> (72M molecules): Used only to test representation coverage and scalability; not used for model training</li>
</ul>
<h3 id="models">Models</h3>
<p>The VAE implementation included:</p>
<ul>
<li><strong>Latent space</strong>: 241-dimensional with Gaussian distributions</li>
<li><strong>Input encoding</strong>: One-hot encoding of SELFIES/SMILES strings</li>
<li>Full architectural details (encoder/decoder structures, layer types) provided in Supplementary Information</li>
</ul>
<h3 id="algorithms">Algorithms</h3>
<p>The authors found GAN performance was highly sensitive to hyperparameter selection:</p>
<ul>
<li>Searched <strong>200 different hyperparameter configurations</strong> to achieve the reported 78.9% diversity</li>
<li>Specific optimizers, learning rates, and training duration detailed in Supplementary Information</li>
<li>Full rule generation algorithm provided in Table 2</li>
</ul>
<h3 id="evaluation">Evaluation</h3>
<p>All models evaluated on:</p>
<ul>
<li><strong>Validity rate</strong>: Percentage of syntactically and chemically valid outputs</li>
<li><strong>Diversity</strong>: Count of unique valid molecules generated</li>
<li><strong>Reconstruction accuracy</strong>: Fidelity of autoencoder reconstruction (VAEs only)</li>
</ul>
<h3 id="hardware">Hardware</h3>
<ul>
<li>Training performed on the SciNet supercomputing infrastructure.</li>
<li>The paper does not specify GPU types or training times.</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/aspuru-guzik-group/selfies">SELFIES GitHub Repository</a></td>
          <td>Code</td>
          <td>Apache-2.0</td>
          <td>Official implementation; has evolved significantly since the original paper</td>
      </tr>
  </tbody>
</table>
<h3 id="replication-resources">Replication Resources</h3>
<p>Complete technical replication is highly accessible due to the paper being published open-access in <em>Machine Learning: Science and Technology</em>. It primarily requires:</p>
<ul>
<li>The full rule generation algorithm (Table 2 in paper)</li>
<li>Code: <a href="https://github.com/aspuru-guzik-group/selfies">https://github.com/aspuru-guzik-group/selfies</a></li>
<li>Supplementary Information for complete architectural and hyperparameter specifications</li>
</ul>
<p><strong>Note</strong>: The <a href="/notes/chemistry/molecular-representations/notations/selfies/">modern SELFIES library</a> has evolved significantly since this foundational paper, addressing many of the implementation challenges identified by the authors.</p>
<h2 id="paper-information">Paper Information</h2>
<p><strong>Citation</strong>: Krenn, M., Häse, F., Nigam, A., Friederich, P., &amp; Aspuru-Guzik, A. (2020). Self-referencing embedded strings (SELFIES): A 100% robust molecular string representation. <em>Machine Learning: Science and Technology</em>, <em>1</em>(4), 045024. <a href="https://doi.org/10.1088/2632-2153/aba947">https://doi.org/10.1088/2632-2153/aba947</a></p>
<p><strong>Publication</strong>: Machine Learning: Science and Technology, 2020</p>
<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">@article</span>{Krenn_2020,
</span></span><span style="display:flex;"><span>	<span style="color:#a6e22e">doi</span> = <span style="color:#e6db74">{10.1088/2632-2153/aba947}</span>,
</span></span><span style="display:flex;"><span>	<span style="color:#a6e22e">url</span> = <span style="color:#e6db74">{https://doi.org/10.1088%2F2632-2153%2Faba947}</span>,
</span></span><span style="display:flex;"><span>	<span style="color:#a6e22e">year</span> = <span style="color:#ae81ff">2020</span>,
</span></span><span style="display:flex;"><span>	<span style="color:#a6e22e">month</span> = <span style="color:#e6db74">{aug}</span>,
</span></span><span style="display:flex;"><span>	<span style="color:#a6e22e">publisher</span> = <span style="color:#e6db74">{{IOP} Publishing}</span>,
</span></span><span style="display:flex;"><span>	<span style="color:#a6e22e">volume</span> = <span style="color:#e6db74">{1}</span>,
</span></span><span style="display:flex;"><span>	<span style="color:#a6e22e">number</span> = <span style="color:#e6db74">{4}</span>,
</span></span><span style="display:flex;"><span>	<span style="color:#a6e22e">pages</span> = <span style="color:#e6db74">{045024}</span>,
</span></span><span style="display:flex;"><span>	<span style="color:#a6e22e">author</span> = <span style="color:#e6db74">{Mario Krenn and Florian H{\&#34;{a}}se and AkshatKumar Nigam and Pascal Friederich and Alan Aspuru-Guzik}</span>,
</span></span><span style="display:flex;"><span>	<span style="color:#a6e22e">title</span> = <span style="color:#e6db74">{Self-referencing embedded strings ({SELFIES}): A 100{\%} robust molecular string representation}</span>,
</span></span><span style="display:flex;"><span>	<span style="color:#a6e22e">journal</span> = <span style="color:#e6db74">{Machine Learning: Science and Technology}</span>
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div><p><strong>Additional Resources</strong>:</p>
<ul>
<li><a href="https://github.com/aspuru-guzik-group/selfies">GitHub Repository</a></li>
<li><a href="/notes/chemistry/molecular-representations/notations/selfies/">Modern SELFIES Documentation</a></li>
</ul>
]]></content:encoded></item><item><title>RInChI: The Reaction International Chemical Identifier</title><link>https://hunterheidenreich.com/notes/chemistry/molecular-representations/notations/rinchi/</link><pubDate>Sun, 12 Oct 2025 00:00:00 +0000</pubDate><guid>https://hunterheidenreich.com/notes/chemistry/molecular-representations/notations/rinchi/</guid><description>RInChI extends InChI to create unique, machine-readable identifiers for chemical reactions and database searching.</description><content:encoded><![CDATA[<h2 id="paper-classification-and-scope">Paper Classification and Scope</h2>
<p>This is an <strong>infrastructure/resource paper</strong> combined with a <strong>methods paper</strong>. It establishes a standard format, releases an open-source software library, and enables large-scale database operations. The methods component details the specific algorithmic rules for constructing identifiers through hashing, sorting, and layering.</p>
<h2 id="the-need-for-standardized-reaction-identifiers">The Need for Standardized Reaction Identifiers</h2>
<p>While we have excellent standards for identifying individual molecules (like <a href="/notes/chemistry/molecular-representations/notations/smiles/">SMILES</a> and <a href="/notes/chemistry/molecular-representations/notations/inchi-2013/">InChI</a>), there was no equivalent for chemical reactions. This creates real problems:</p>
<ul>
<li>Different researchers working on the same reaction might describe it completely differently</li>
<li>Searching large reaction databases becomes nearly impossible</li>
<li>No way to check if two apparently different reaction descriptions are actually the same process</li>
<li>Chemical databases can&rsquo;t easily link related reactions or identify duplicates</li>
</ul>
<p>If a reaction converts &ldquo;starting material A + reagent B to product C,&rdquo; it is difficult to determine if that is identical to another researcher&rsquo;s description of the same transformation using different names or graphical representations. A working group was established in 2008 to address this, producing prototype versions at the University of Cambridge starting in 2011. The first official release (RInChI V1.00) was funded by the InChI Trust.</p>
<h2 id="core-innovation-standardizing-reaction-strings">Core Innovation: Standardizing Reaction Strings</h2>
<p>RInChI solves this by creating a standardized, machine-readable label for any chemical reaction. The key insight is to focus on the essential chemistry while ignoring experimental details that can vary between labs.</p>
<h3 id="core-principles">Core Principles</h3>
<p>RInChI captures three fundamental pieces of information:</p>
<ol>
<li><strong>Starting materials</strong>: What molecules you begin with</li>
<li><strong>Products</strong>: What molecules you end up with</li>
<li><strong>Agents</strong>: Substances present at both the beginning and end (catalysts, solvents, etc.)</li>
</ol>
<p>Importantly, RInChI intentionally excludes experimental conditions like temperature, pressure, yield, or reaction time. These details can vary significantly even for identical chemical transformations, so including them would make it nearly impossible for different researchers to generate the same identifier.</p>
<h3 id="how-rinchi-works">How RInChI Works</h3>
<h4 id="the-rinchi-string-structure">The RInChI String Structure</h4>
<p>A RInChI string has six distinct layers. Crucially, <strong>Layers 2 and 3 are assigned alphabetically</strong>. This is essential for generating consistent identifiers.</p>
<p><strong>Layer 1: Version</strong></p>
<ul>
<li>Standard header defining the RInChI version (e.g., <code>RInChI=1.00.1S</code>)</li>
</ul>
<p><strong>Layers 2 &amp; 3: Component Molecules</strong></p>
<ul>
<li>These layers contain the InChI strings of reaction participants (reactants and products)</li>
<li><strong>Sorting Rule</strong>: The distinct groups (Reactant Group vs. Product Group) are sorted alphabetically as aggregate strings. The group that comes first alphabetically becomes <strong>Layer 2</strong>; the other becomes <strong>Layer 3</strong></li>
<li>This means if a product&rsquo;s InChI is alphabetically &ldquo;earlier&rdquo; than the reactant&rsquo;s, the product goes in Layer 2</li>
<li><strong>Formatting</strong>: Molecules within a layer are separated by <code>!</code>. The two layers are separated by <code>&lt;&gt;</code></li>
</ul>
<p><strong>Layer 4: Agents</strong></p>
<ul>
<li>Contains catalysts, solvents, and any molecule found in <em>both</em> the reactant and product input lists</li>
<li><strong>Algorithmic rule</strong>: Anything appearing in both the reactant list and product list must be removed from both and added to Layer 4</li>
</ul>
<p><strong>Layer 5: Direction (The Decoder)</strong></p>
<ul>
<li>This layer determines which component layer represents the starting material:
<ul>
<li><code>/d+</code>: Layer 2 is the Starting Material (forward direction)</li>
<li><code>/d-</code>: Layer 3 is the Starting Material (reverse direction)</li>
<li><code>/d=</code>: Equilibrium reaction</li>
</ul>
</li>
<li>Without this layer, you cannot determine reactants from products</li>
</ul>
<p><strong>Layer 6: No-Structure Data</strong></p>
<ul>
<li>Format: <code>/uA-B-C</code> where the numbers indicate the count of structureless materials in Layer 2, Layer 3, and Layer 4 respectively</li>
<li>Used when substances lack defined structures and cannot be represented by InChI</li>
</ul>
<h3 id="separator-syntax">Separator Syntax</h3>
<p>For parsing or generating RInChI strings, the separator characters are:</p>
<table>
  <thead>
      <tr>
          <th>Separator</th>
          <th>Purpose</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td><code>/</code></td>
          <td>Separates layers</td>
      </tr>
      <tr>
          <td><code>!</code></td>
          <td>Separates molecules within a layer</td>
      </tr>
      <tr>
          <td><code>&lt;&gt;</code></td>
          <td>Separates reactant/product groups</td>
      </tr>
  </tbody>
</table>
<h3 id="example-structure">Example Structure</h3>
<pre><code>RInChI=1.00.1S/[Layer2 InChIs]&lt;&gt;[Layer3 InChIs]&lt;&gt;[Agent InChIs]/d+/u0-0-0
</code></pre>
<p>This systematic approach ensures that any researcher starting with the same reaction will generate an identical RInChI string.</p>
<h3 id="rinchikeys-shorter-identifiers-for-practical-use">RInChIKeys: Shorter Identifiers for Practical Use</h3>
<p>Since full RInChI strings can become extremely long, the standard includes three types of shorter, hashed keys for different applications:</p>
<h4 id="long-rinchikey">Long-RInChIKey</h4>
<ul>
<li>Contains complete InChIKeys for every molecule in the reaction</li>
<li>Variable length, but allows searching for reactions containing specific compounds</li>
<li>Useful for substructure searches: &ldquo;Show me all reactions involving compound X&rdquo;</li>
</ul>
<h4 id="short-rinchikey">Short-RInChIKey</h4>
<ul>
<li>Fixed length (63 characters): 55 letters plus eight hyphens</li>
<li>Generated by separately hashing the major InChI layers (molecular formula and connectivity) of layers two, three, and four into ten-character strings, then hashing the minor layers (stereochemistry) and protonation states into five-character groups</li>
<li>Suitable for exact matching, database indexing, and linking identical reactions across different databases</li>
</ul>
<h4 id="web-rinchikey">Web-RInChIKey</h4>
<ul>
<li>Shortest format (47 characters)</li>
<li>Generated by combining all InChIs from every layer, removing duplicates, sorting alphabetically, then hashing the major layers into a seventeen-character block and the minor layers into a twelve-character block, with a protonation indicator</li>
<li>Ignores molecular roles (reactant vs. product), making it useful for finding related reactions where a molecule&rsquo;s role might differ between studies</li>
<li>Good for discovering &ldquo;reverse&rdquo; reactions, comparing databases with different drawing models, or finding alternative synthetic routes</li>
</ul>
<h2 id="experimental-validation-and-software-implementation">Experimental Validation and Software Implementation</h2>
<p>This infrastructure paper focuses on developing and validating the RInChI standard. The validation approach includes:</p>
<ul>
<li><strong>Software implementation</strong>: Development of the official RInChI software library capable of parsing reaction files and generating identifiers</li>
<li><strong>Format testing</strong>: Validation that the system correctly handles standard reaction file formats (<code>.RXN</code>, <code>.RD</code>)</li>
<li><strong>Consistency verification</strong>: Ensuring identical reactions produce identical RInChI strings regardless of input variations</li>
<li><strong>Key generation</strong>: Testing all three RInChIKey variants (Long, Short, Web) for different use cases</li>
<li><strong>Database integration</strong>: Demonstrating practical application in reaction database management. A database of over one million RInChIs was assembled using data that NextMove Software extracted from the patent literature, available at www-rinchi.ch.cam.ac.uk</li>
</ul>
<h2 id="impact-on-chemical-database-analytics">Impact on Chemical Database Analytics</h2>
<h3 id="practical-applications">Practical Applications</h3>
<p>RInChI enables systematic organization and analysis of chemical reactions:</p>
<h4 id="database-management">Database Management</h4>
<p>RInChI enables systematic organization of reaction databases. You can:</p>
<ul>
<li>Automatically identify and merge duplicate reaction entries</li>
<li>Find all variations of a particular transformation</li>
<li>Link related reactions across different data sources</li>
</ul>
<h4 id="reaction-analysis">Reaction Analysis</h4>
<p>With standardized identifiers, you can perform large-scale analysis:</p>
<ul>
<li>Identify the most commonly used reagents or catalysts</li>
<li>Find cases where identical starting materials yield different products</li>
<li>Analyze reaction trends and patterns across entire databases</li>
</ul>
<h4 id="multi-step-synthesis-representation">Multi-Step Synthesis Representation</h4>
<p>RInChI can represent complex, multi-step syntheses as single combined identifiers, making it easier to analyze and compare different synthetic routes.</p>
<h4 id="research-integration">Research Integration</h4>
<p>The standard enables better collaboration by ensuring different research groups can generate identical identifiers for the same chemical processes, facilitating data sharing and literature analysis.</p>
<h3 id="limitations-and-considerations">Limitations and Considerations</h3>
<h4 id="what-gets-lost">What Gets Lost</h4>
<p>Since RInChI builds on the Standard InChI for individual molecules, it inherits certain limitations:</p>
<ul>
<li><strong>Tautomers</strong>: Different tautomeric forms are treated as identical</li>
<li><strong>Stereochemistry</strong>: Relative stereochemical relationships aren&rsquo;t captured</li>
<li><strong>Experimental conditions</strong>: Temperature, pressure, yield, and reaction time are intentionally excluded</li>
</ul>
<h4 id="the-trade-off">The Trade-off</h4>
<p>This is an intentional feature. By focusing on core chemical identity, RInChI achieves its primary goal: ensuring that different researchers working on the same fundamental transformation generate the same identifier.</p>
<h3 id="implementation-and-tools">Implementation and Tools</h3>
<h4 id="official-software">Official Software</h4>
<p>The RInChI software, available from the InChI Trust, handles the practical details:</p>
<ul>
<li>Accepts standard reaction file formats (<code>.RXN</code>, <code>.RD</code>)</li>
<li>Generates RInChI strings, all three RInChIKey variants, and auxiliary information</li>
<li>Automates the complex process of creating consistent identifiers</li>
</ul>
<h4 id="rauxinfo-preserving-visual-information">RAuxInfo: Preserving Visual Information</h4>
<p>While RInChI discards graphical information (atom coordinates, drawing layout), the software can generate supplementary &ldquo;RAuxInfo&rdquo; strings that preserve this data. This allows reconstruction of the original visual representation when needed.</p>
<h3 id="future-directions">Future Directions</h3>
<p>RInChI development continues to evolve:</p>
<ul>
<li><strong>Integration</strong>: Plans for compatibility with other emerging standards like <a href="/notes/chemistry/molecular-representations/notations/mixfile-minchi/">MInChI for chemical mixtures</a></li>
<li><strong>Extended applications</strong>: Work on representing complex, multi-component reaction systems</li>
<li><strong>Software development</strong>: Tools for generating graphical representations directly from RInChI without auxiliary information</li>
</ul>
<h3 id="key-takeaways">Key Takeaways</h3>
<ol>
<li>
<p><strong>Filling a critical gap</strong>: RInChI provides the first standardized way to uniquely identify chemical reactions, solving a fundamental problem in chemical informatics.</p>
</li>
<li>
<p><strong>Focus on essential chemistry</strong>: By excluding experimental variables, RInChI achieves consistent identification of core chemical transformations.</p>
</li>
<li>
<p><strong>Flexible searching</strong>: Multiple RInChIKey formats enable different types of database queries, from exact matching to similarity searching.</p>
</li>
<li>
<p><strong>Practical implementation</strong>: Official software tools make RInChI generation accessible to working chemists and database managers.</p>
</li>
<li>
<p><strong>Foundation for analysis</strong>: Standardized reaction identifiers enable large-scale analysis of chemical databases and systematic study of reaction patterns.</p>
</li>
</ol>
<p>RInChI brings to reaction data the same kind of standardization and machine-readability that SMILES and InChI provide for individual molecules.</p>
<h2 id="reproducibility">Reproducibility</h2>
<p>The RInChI software is available for download from the InChI Trust website (<a href="http://www.inchi-trust.org/downloads/)">http://www.inchi-trust.org/downloads/)</a>. It is also available as an Oracle cartridge and as a Pipeline Pilot component from StructurePendium. A database of over one million RInChIs is hosted at www-rinchi.ch.cam.ac.uk.</p>
<table>
  <thead>
      <tr>
          <th>Artifact</th>
          <th>Type</th>
          <th>License</th>
          <th>Notes</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td><a href="http://www.inchi-trust.org/downloads/">RInChI Software (InChI Trust)</a></td>
          <td>Code</td>
          <td>Unknown</td>
          <td>Official RInChI V1.00 implementation</td>
      </tr>
      <tr>
          <td><a href="https://www-rinchi.ch.cam.ac.uk">RInChI Database</a></td>
          <td>Dataset</td>
          <td>Unknown</td>
          <td>Over 1M reactions from patent literature</td>
      </tr>
  </tbody>
</table>
<h2 id="paper-information">Paper Information</h2>
<p><strong>Citation</strong>: Grethe, G., Blanke, G., Kraut, H., &amp; Goodman, J. M. (2018). International chemical identifier for reactions (RInChI). <em>Journal of Cheminformatics</em>, <em>10</em>(1), 22. <a href="https://doi.org/10.1186/s13321-018-0277-8">https://doi.org/10.1186/s13321-018-0277-8</a></p>
<p><strong>Publication</strong>: Journal of Cheminformatics (2018)</p>
<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">@article</span>{Grethe2018,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">title</span>=<span style="color:#e6db74">{International chemical identifier for reactions (RInChI)}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">author</span>=<span style="color:#e6db74">{Grethe, Guenter and Blanke, Gerd and Kraut, Hans and Goodman, Jonathan M}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">journal</span>=<span style="color:#e6db74">{Journal of Cheminformatics}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">volume</span>=<span style="color:#e6db74">{10}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">number</span>=<span style="color:#e6db74">{1}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">pages</span>=<span style="color:#e6db74">{22}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">year</span>=<span style="color:#e6db74">{2018}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">publisher</span>=<span style="color:#e6db74">{Springer}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">doi</span>=<span style="color:#e6db74">{10.1186/s13321-018-0277-8}</span>
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div>]]></content:encoded></item><item><title>Recent Advances in the SELFIES Library: 2023 Update</title><link>https://hunterheidenreich.com/notes/chemistry/molecular-representations/notations/selfies-2023/</link><pubDate>Sun, 12 Oct 2025 00:00:00 +0000</pubDate><guid>https://hunterheidenreich.com/notes/chemistry/molecular-representations/notations/selfies-2023/</guid><description>Major updates to the SELFIES library, improved performance, expanded chemistry support, and new customization features.</description><content:encoded><![CDATA[<h2 id="overview">Overview</h2>
<p>This software update paper documents major improvements to the SELFIES Python library (version 2.1.1), covering its history, underlying algorithms, design, and performance.</p>
<h2 id="limitations-in-the-original-selfies-implementation">Limitations in the Original SELFIES Implementation</h2>
<p>While the <a href="/notes/chemistry/molecular-representations/notations/selfies-original-paper/">original SELFIES concept</a> was promising, the initial 2019 implementation had critical limitations that prevented widespread adoption:</p>
<ol>
<li><strong>Performance</strong>: Too slow for production ML workflows</li>
<li><strong>Limited chemistry</strong>: Couldn&rsquo;t represent aromatic molecules, stereochemistry, or many other important chemical features</li>
<li><strong>Poor usability</strong>: Lacked user-friendly APIs for common tasks</li>
</ol>
<p>These barriers meant that despite SELFIES&rsquo; theoretical advantages (100% validity guarantee), researchers couldn&rsquo;t practically use it for real-world applications like drug discovery or materials science.</p>
<h2 id="architectural-refactoring-and-new-ml-integrations">Architectural Refactoring and New ML Integrations</h2>
<p>The 2023 update refactors the underlying SELFIES engine with improvements to design, efficiency, and supported features. The key updates include:</p>
<ol>
<li>
<p><strong>Streamlined Grammar</strong>: The underlying context-free grammar has been generalized and streamlined, improving execution speed and extensibility while maintaining the 100% validity guarantee.</p>
</li>
<li>
<p><strong>Expanded Chemical Support</strong>: Adds support for aromatic systems (via internal kekulization), stereochemistry (chirality, cis/trans), charged species, and isotopic data, covering nearly all features supported by SMILES while preserving the validity guarantee.</p>
</li>
<li>
<p><strong>Semantic Constraint API</strong>: Introduces the <code>set_semantic_constraints()</code> function, allowing specification of custom valence definitions useful for theoretical studies or hypervalent states.</p>
</li>
<li>
<p><strong>ML Utility Functions</strong>: Provides tokenization (<code>split_selfies</code>), length estimation (<code>len_selfies</code>), label/one-hot encoding (<code>selfies_to_encoding</code>), vocabulary extraction, and attribution tracking for integration with neural network pipelines.</p>
</li>
</ol>
<h2 id="performance-benchmarks--validity-testing">Performance Benchmarks &amp; Validity Testing</h2>
<p>The authors validated the library through several benchmarks:</p>
<p><strong>Performance testing</strong>: Roundtrip conversion (SMILES to SELFIES to SMILES) on the DTP open compound collection (slightly over 300K molecules) completed in 252 seconds total (136s encoding, 116s decoding), using pure Python with no external dependencies.</p>
<p><strong>Random SELFIES generation</strong>: Demonstrated that random SELFIES strings of varying lengths always decode to valid molecules, with the size distribution of generated molecules controllable by filtering the sampling alphabet (e.g., removing multi-bond and low-valence atom symbols shifts the distribution toward larger molecules).</p>
<p><strong>Validity guarantee</strong>: By construction, every SELFIES string decodes to a valid molecule. The grammar&rsquo;s bond demotion and deferred ring closure mechanisms make it impossible to generate chemically invalid structures.</p>
<p><strong>Attribution system</strong>: Showed both encoder and decoder can track which input symbols produce which output symbols, useful for property alignment.</p>
<h2 id="future-trajectories-for-general-chemical-representations">Future Trajectories for General Chemical Representations</h2>
<p>The 2023 update successfully addresses the main adoption barriers:</p>
<ol>
<li><strong>Fast enough</strong> for large-scale ML applications (300K molecules in ~4 minutes)</li>
<li><strong>Chemically comprehensive</strong> enough for drug discovery and materials science</li>
<li><strong>User-friendly</strong> enough for straightforward integration into existing workflows</li>
</ol>
<p>The validity guarantee, SELFIES&rsquo; core advantage, is now practically accessible for real-world research. The roadmap includes future extensions for polymers, crystals, chemical reactions, and non-covalent interactions, which would expand SELFIES&rsquo; applicability beyond small-molecule chemistry.</p>
<p><strong>Limitations acknowledged</strong>: The paper focuses on implementation improvements. Some advanced chemical systems (polymers, crystals) still need future work.</p>
<h2 id="reproducibility-details">Reproducibility Details</h2>
<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/aspuru-guzik-group/selfies">selfies</a></td>
          <td>Code</td>
          <td>Apache 2.0</td>
          <td>Official Python library, installable via <code>pip install selfies</code></td>
      </tr>
  </tbody>
</table>
<h3 id="code">Code</h3>
<p>The <code>selfies</code> library is completely open-source and written in pure Python. It requires no extra dependencies and is available on GitHub, installable via <code>pip install selfies</code>. The repository includes testing suites (<code>tox</code>) and example benchmarking scripts to reproduce the translation speeds reported in the paper.</p>
<h3 id="hardware">Hardware</h3>
<p>Performance benchmarks (e.g., the 252-second roundtrip conversion on 300K molecules) were executed on Google Colaboratory using two 2.20GHz Intel Xeon CPUs.</p>
<h3 id="algorithms">Algorithms</h3>
<h4 id="technical-specification-the-grammar">Technical Specification: The Grammar</h4>
<p>The core innovation of SELFIES is a <strong>Context-Free Grammar (CFG) augmented with state-machine logic</strong> to ensure that every derived string represents a valid molecule. While the software features are important, understanding the underlying derivation rules is essential for replication or extension of the system.</p>
<p><strong>1. Derivation Rules: The Atom State Machine</strong></p>
<p>The fundamental mechanism that guarantees validity is a <strong>state machine</strong> that tracks the remaining valence of the most recently added atom:</p>
<ul>
<li><strong>State Tracking</strong>: The derivation maintains a non-terminal state $X_l$, where $l$ represents the current atom&rsquo;s remaining valence (number of bonds it can still form)</li>
<li><strong>Standard Derivation</strong>: An atom symbol $[\beta \alpha]$ (bond order + atom type) transitions the state from $S$ (start) to $X_l$, where $l$ is calculated from the atom&rsquo;s standard valence minus the incoming bond order</li>
<li><strong>Bond Demotion (The Key Rule)</strong>: When deriving atom symbol $[\beta \alpha]$ in state $X_i$, the actual bond order used is $d_0 = \min(\ell, i, d(\beta))$, where $\ell$ is the new atom&rsquo;s valence, $i$ is the previous atom&rsquo;s remaining capacity, and $d(\beta)$ is the requested bond order. This automatic downward adjustment is the mathematical core of the validity guarantee.</li>
</ul>
<p>This state machine ensures that no atom ever exceeds its allowed valence, making it impossible to generate chemically invalid structures.</p>
<p><strong>2. Control Symbols: Branches and Rings</strong></p>
<p>Branch length calculation: SELFIES uses a <strong>hexadecimal encoding</strong> to determine branch lengths. A branch symbol <code>[Branch l]</code> consumes the next $\ell$ symbols from the queue and converts them to integer indices $c_1, \dots, c_\ell$ via a fixed mapping (Table III in the paper). The number of symbols $N$ to include in the branch is then:</p>
<p>$$
N = 1 + \sum_{k=1}^{\ell} 16^{\ell - k} , c_k
$$</p>
<p>This formula interprets the indices as hexadecimal digits, allowing compact specification of branches up to hundreds of symbols long.</p>
<p>Ring closure queue system: Ring formation uses a <strong>deferred evaluation</strong> strategy to maintain validity. Ring symbols don&rsquo;t create bonds immediately; instead, they push closure candidates into a queue $R$. These candidates are resolved after the main derivation completes. A ring closure candidate is <strong>rejected</strong> if either ring atom has no remaining valence ($m_1 = 0$ or $m_2 = 0$), or if the left and right ring atoms are not distinct (to avoid self-loops). If a prior bond already exists between the two atoms, the bond order is incremented rather than duplicated. This deferred validation prevents invalid ring structures while keeping the grammar context-free during the main derivation.</p>
<p><strong>3. Symbol Structure and Standardization</strong></p>
<p>SELFIES enforces a strict, standardized format for atom symbols to eliminate ambiguity:</p>
<ul>
<li><strong>Canonical Format</strong>: Atom symbols follow the structure <code>[Bond, Isotope, Element, Chirality, H-count, Charge]</code></li>
<li><strong>No Variation</strong>: There is only one way to write each symbol (e.g., <code>[Fe++]</code> and <code>[Fe+2]</code> are standardized to a single form)</li>
<li><strong>Order Matters</strong>: The components must appear in the specified order</li>
</ul>
<p><strong>4. Default Semantic Constraints</strong></p>
<p>By default, the library enforces standard organic chemistry valence rules:</p>
<ul>
<li><strong>Charge-Dependent Valences</strong>: Default constraints specify maximum bonds per charge state (e.g., C: 4/5/3 for neutral/+1/-1; S: 6/7/5). Unlisted atom types default to 8 maximum bonds as a catch-all.</li>
<li><strong>Preset Options</strong>: Three preset constraint sets are available: <code>default</code>, <code>octet_rule</code>, and <code>hypervalent</code>.</li>
<li><strong>Customizable</strong>: Constraints can be modified via <code>set_semantic_constraints()</code> for specialized applications (hypervalent compounds, theoretical studies, etc.)</li>
</ul>
<p>The combination of these grammar rules with the state machine ensures that <strong>every valid SELFIES string decodes to a chemically valid molecule</strong>, regardless of how the string was generated (random, ML model output, manual construction, etc.).</p>
<h3 id="data">Data</h3>
<p><strong>Benchmark dataset</strong>: DTP (Developmental Therapeutics Program) open compound collection with slightly over 300K SMILES strings, a set of molecules tested experimentally for potential treatment against cancer and AIDS.</p>
<p><strong>Random generation testing</strong>: Random SELFIES strings of varying lengths (10, 100, 250 symbols) generated from both basic and filtered alphabets to test decoding validity and molecule size distributions.</p>
<h3 id="evaluation">Evaluation</h3>
<p><strong>Performance metric</strong>: Roundtrip conversion time (SMILES to SELFIES to SMILES) is 252 seconds for 300K+ molecules (136s encoding, 116s decoding). Times averaged over 3 replicate trials on Google Colaboratory.</p>
<p><strong>Validity testing</strong>: Random SELFIES strings of lengths 10, 100, and 250 all decode to valid molecules. Decoding 1000 random strings of length 250 from the basic alphabet takes 0.341s; from the filtered alphabet, 1.633s.</p>
<p><strong>Attribution system</strong>: Both <code>encoder()</code> and <code>decoder()</code> support an <code>attribute</code> flag that returns <code>AttributionMap</code> objects, tracing which input symbols produce which output symbols for property alignment.</p>
<h2 id="paper-information">Paper Information</h2>
<p><strong>Citation</strong>: Lo, A., Pollice, R., Nigam, A., White, A. D., Krenn, M., &amp; Aspuru-Guzik, A. (2023). Recent advances in the self-referencing embedded strings (SELFIES) library. <em>Digital Discovery</em>, <em>2</em>(4), 897-908. <a href="https://doi.org/10.1039/D3DD00044C">https://doi.org/10.1039/D3DD00044C</a></p>
<p><strong>Publication</strong>: Digital Discovery 2023</p>
<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">@article</span>{lo2023recent,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">title</span>=<span style="color:#e6db74">{Recent advances in the self-referencing embedded strings (SELFIES) library}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">author</span>=<span style="color:#e6db74">{Lo, Alston and Pollice, Robert and Nigam, AkshatKumar and White, Andrew D and Krenn, Mario and Aspuru-Guzik, Al{\&#39;a}n}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">journal</span>=<span style="color:#e6db74">{Digital Discovery}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">volume</span>=<span style="color:#e6db74">{2}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">number</span>=<span style="color:#e6db74">{4}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">pages</span>=<span style="color:#e6db74">{897--908}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">year</span>=<span style="color:#e6db74">{2023}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">publisher</span>=<span style="color:#e6db74">{Royal Society of Chemistry}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">doi</span>=<span style="color:#e6db74">{10.1039/D3DD00044C}</span>
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div><p><strong>Additional Resources</strong>:</p>
<ul>
<li><a href="https://github.com/aspuru-guzik-group/selfies">SELFIES GitHub Repository</a></li>
<li><a href="/notes/chemistry/molecular-representations/notations/selfies-original-paper/">Original SELFIES Paper (2020)</a></li>
<li><a href="/notes/chemistry/molecular-representations/notations/selfies/">SELFIES Format Overview</a></li>
</ul>
]]></content:encoded></item><item><title>NInChI: Toward a Chemical Identifier for Nanomaterials</title><link>https://hunterheidenreich.com/notes/chemistry/molecular-representations/notations/ninchi-alpha/</link><pubDate>Sun, 12 Oct 2025 00:00:00 +0000</pubDate><guid>https://hunterheidenreich.com/notes/chemistry/molecular-representations/notations/ninchi-alpha/</guid><description>NInChI (Nanomaterials InChI) extends chemical identifiers to represent complex, multi-component nanomaterials.</description><content:encoded><![CDATA[<h2 id="a-new-standard-for-nanoinformatics">A New Standard for Nanoinformatics</h2>
<p>This is a <strong>Systematization paper</strong> that proposes a new standard: the NInChI. It addresses a fundamental limitation in nanoinformatics. The result of a collaborative workshop organized by the H2020 research infrastructure NanoCommons and the nanoinformatics project NanoSolveIT, this work uses <strong>six detailed case studies</strong> to systematically develop a <strong>hierarchical, machine-readable notation</strong> for complex nanomaterials that could work across experimental research, regulatory frameworks, and computational modeling.</p>
<h2 id="the-breakdown-of-traditional-chemical-identifiers">The Breakdown of Traditional Chemical Identifiers</h2>
<p>Chemoinformatics has fantastic tools for representing small molecules: SMILES strings, InChI identifiers, and standardized databases that make molecular data searchable and shareable. But when you step into nanotechnology, everything breaks down.</p>
<p>Consider trying to describe a gold nanoparticle with a silica shell and organic surface ligands. How do you capture:</p>
<ul>
<li>The gold core composition and size</li>
<li>The silica shell thickness and interface</li>
<li>The surface chemistry and ligand density</li>
<li>The overall shape and morphology</li>
</ul>
<p>There&rsquo;s simply no standardized way to represent this complexity in a machine-readable format. This creates massive problems for:</p>
<ul>
<li><strong>Data sharing</strong> between research groups</li>
<li><strong>Regulatory assessment</strong> where precise identification matters</li>
<li><strong>Computational modeling</strong> that needs structured input</li>
<li><strong>Database development</strong> and search capabilities</li>
</ul>
<p>Without a standard notation, nanomaterials research suffers from the same data fragmentation that plagued small molecule chemistry before SMILES existed.</p>
<h2 id="the-five-tier-nanomaterial-description-hierarchy">The Five-Tier Nanomaterial Description Hierarchy</h2>
<p>The authors propose NInChI (Nanomaterials InChI), a layered extension to the existing InChI system. The core insight is organizing nanomaterial description from the inside out, following the OECD&rsquo;s framework for risk assessment, with a five-tier hierarchy:</p>
<ol>
<li><strong>Tier 1: Chemical Composition</strong>: What is the core made of? This differentiates uniform compositions (Tier 1.1), randomly mixed (Tier 1.2), ordered core-shell materials (Tier 1.3), and onion-like multi-shell morphologies (Tier 1.4).</li>
<li><strong>Tier 2: Morphology</strong>: What shape, size, and dimensionality? This encodes dimension (0D-3D), size and size distribution, and shape information.</li>
<li><strong>Tier 3: Surface Properties</strong>: Physical and chemical surface parameters such as charge, roughness, and hydrophobicity. Many of these depend on external conditions (pH, solvent, temperature).</li>
<li><strong>Tier 4: Surface Functionalization</strong>: How are coatings attached to the core? This includes functionalization density, orientation, and binding type (covalent vs. non-covalent).</li>
<li><strong>Tier 5: Surface Ligands</strong>: What molecules are on the surface, their density, orientation, and distribution?</li>
</ol>
<p>This hierarchy captures the essential information needed to distinguish between different nanomaterials while building on familiar chemical concepts.</p>
<h2 id="testing-the-standard-six-case-studies">Testing the Standard: Six Case Studies</h2>
<p>The authors tested their concept against six real-world case studies to identify what actually matters in practice.</p>
<p><strong>Case Study 1: Gold Nanoparticles</strong></p>
<p>Gold NPs provided a relatively simple test case: an inert metallic core with various surface functionalizations. Key insights: core composition and size are essential, surface chemistry (what molecules are attached) matters critically, shape affects properties, and dynamic properties like protein corona formation belong outside the intrinsic NInChI representation. This established the boundary: NInChI should capture intrinsic, stable properties.</p>
<p><strong>Case Study 2: Graphene-Family NMs</strong></p>
<p>Carbon nanotubes and graphene introduced additional complexity: dimensionality (1D tubes vs 2D sheets vs 0D fullerenes), chirality (the (n,m) vector that defines a nanotube&rsquo;s structure), defects and impurities that can alter properties, and number of layers (for nanotubes, single-wall vs multi-wall). This case showed that the notation needed to handle both topological complexity and chemical composition.</p>
<p><strong>Case Study 3: Complex Engineered (Doped and Multi-Metallic) NMs</strong></p>
<p>Doped materials, alloys, and core-shell structures revealed key requirements: need to distinguish true alloys (homogeneous mixing) and core-shell structures with the same overall composition, crystal structure information becomes crucial, and component ratios must be precisely specified. The case study assessed whether the MInChI extension could represent these solid solutions.</p>
<p><strong>Case Study 4: Database Applications</strong></p>
<p>The FAIR (Findable, Accessible, Interoperable, Reusable) principles guided this analysis. NInChI addresses real database problems: it provides greater specificity than CAS numbers (which lack nanoform distinction), offers a systematic alternative to ad-hoc naming schemes, and enables machine-searchability.</p>
<p><strong>Case Study 5: Computational Modeling</strong></p>
<p>This explored several applications: automated descriptor generation from NInChI structure, read-across predictions for untested materials, and model input preparation from standardized notation. The layered structure provides structured input that computational tools need for both physics-based and data-driven nanoinformatics approaches.</p>
<p><strong>Case Study 6: Regulatory Applications</strong></p>
<p>Under frameworks like REACH, regulators need to distinguish between different &ldquo;nanoforms&rdquo;, which are materials with the same chemical composition but different sizes, shapes, or surface treatments. NInChI directly addresses this by encoding the specific properties that define regulatory categories, providing precision sufficient for legal definitions and risk assessment frameworks.</p>
<h2 id="the-ninchi-alpha-specification-in-practice">The NInChI Alpha Specification in Practice</h2>
<p>Synthesizing insights from all six case studies, the authors propose the <strong>NInChI alpha specification</strong> (version 0.00.1A), a three-layer structure. Importantly, the paper distinguishes the five-tier NM description hierarchy (Section 1.2 above) from the three-layer NInChI notation hierarchy. NM properties from the five tiers are encoded into these three notation layers:</p>
<p><strong>Layer 1 (Version Number)</strong>: Standard header indicating the NInChI version, denoted as <code>0.00.1A</code> for the alpha version. This follows the convention of all <a href="/notes/chemistry/molecular-representations/notations/inchi-2013/">InChI</a>-based notations.</p>
<p><strong>Layer 2 (Composition)</strong>: Each component (core, shell, ligands, impurities, dopants, linkers) gets described using standard InChI (or PInChI/MInChI) for chemical composition, with additional sublayers for morphology (prefix <code>m</code>, e.g., <code>sp</code> for sphere, <code>sh</code> for shell, <code>tu</code> for tube), size (prefix <code>s</code>, in scientific notation in meters), crystal structure (prefix <code>k</code>), and chirality (prefix <code>w</code> for carbon nanotubes). Components are separated by <code>!</code>.</p>
<p><strong>Layer 3 (Arrangement)</strong>: Specified with prefix <code>y</code>, this layer describes how the components from Layer 2 are combined, proceeding from inside out. A core-shell material is written as <code>y2&amp;1</code> where the numbers reference components in Layer 2. Covalent bonding between components is indicated with parentheses, e.g., <code>(1&amp;2&amp;3)</code> for a nano core with a covalently bound ligand coating.</p>
<p>The paper provides concrete worked examples from the case studies:</p>
<ul>
<li><strong>Silica with gold coating</strong> (20 nm silica, 2 nm gold shell):
<code>NInChI=0.00.1A/Au/msh/s2t10r1-9;12r2-9!/O2Si/c1-3-2/msp/s20d-9/k000/y2&amp;1</code></li>
<li><strong>CTAB-capped gold nanoparticle</strong> (20 nm diameter):
<code>NinChI=0.00.1A/Au/msp/s20d-9!C19H42N.BrH/c1-5-6-7.../y1&amp;2</code></li>
<li><strong>Chiral single-wall nanotube</strong> of the (3,1) type with 0.4 nm diameter:
<code>NInChI=0.00.1A/C/mtu/s4d-10/w(3,1)/y1</code></li>
</ul>
<p><strong>Property Prioritization</strong>: The case studies produced a prioritization of NM properties into four categories (Table 3 in the paper):</p>
<table>
  <thead>
      <tr>
          <th>Category 1: Must Have</th>
          <th>Category 2a: Nice to Have</th>
          <th>Category 2b: Extrinsic</th>
          <th>Category 3: Out of Scope</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>Chemical composition</td>
          <td>Structural defects</td>
          <td>Surface charge</td>
          <td>Optical properties</td>
      </tr>
      <tr>
          <td>Size/size distribution</td>
          <td>Density</td>
          <td>Corona</td>
          <td>Magnetic properties</td>
      </tr>
      <tr>
          <td>Shape</td>
          <td>Surface composition</td>
          <td>Agglomeration state</td>
          <td>Chemical/oxidation state</td>
      </tr>
      <tr>
          <td>Crystal structure</td>
          <td></td>
          <td>Dispersion</td>
          <td></td>
      </tr>
      <tr>
          <td>Chirality</td>
          <td></td>
          <td></td>
          <td></td>
      </tr>
      <tr>
          <td>Ligand and ligand binding</td>
          <td></td>
          <td></td>
          <td></td>
      </tr>
  </tbody>
</table>
<p><strong>Implementation</strong>: The authors built a prototype NInChI generation tool using the ZK framework with a Java backend, available through the <a href="http://enaloscloud.novamechanics.com/nanocommons/NInChI/">Enalos Cloud Platform</a>. The tool lets users specify core composition, morphology, size, crystal structure, and chirality, then build outward by adding shells or clusters. InChIs for shell components are retrieved via the NCI/CADD chemical structure REST API.</p>
<p><strong>Limitations</strong>: The alpha version acknowledges areas for future development: nanocomposite and nanostructured materials, inverse NMs (nano holes in bulk material), and nanoporous materials are beyond current scope. Dynamic properties such as dissolution, agglomeration, and protein corona formation are excluded. The stochastic nature of NMs (e.g., broad size distributions) is not yet fully addressed. Covalent bonding between components needs further refinement.</p>
<p><strong>Impact</strong>: For researchers, NInChI enables precise structural queries for nanomaterials data sharing. For regulators, it provides systematic identification for risk assessment and nanoform classification under frameworks like REACH. For computational modelers, it enables automated descriptor generation and read-across predictions.</p>
<p><strong>Key Conclusions</strong>: The 8-month collaborative process demonstrates that creating systematic notation for nanomaterials is feasible. The hierarchical, inside-out organization provides an approach that satisfies experimentalists, modelers, database owners, and regulators. Testing against six case studies identified the essential features that must be captured. By extending InChI and reusing conventions from MInChI, RInChI, and PInChI, the work builds on existing infrastructure. The proposed NInChI alpha is intended to stimulate further analysis and refinement with the broader community and the InChI Trust.</p>
<h2 id="reproducibility-details">Reproducibility Details</h2>
<ul>
<li><strong>Paper Accessibility</strong>: The paper is fully open-access under the CC BY 4.0 license, allowing for straightforward reading and analysis.</li>
<li><strong>Tools &amp; Code</strong>: The authors provided a prototype NInChI generation tool available through the <a href="http://enaloscloud.novamechanics.com/nanocommons/NInChI/">Enalos Cloud Platform</a>, built using the ZK framework with a Java backend. The underlying backend code was not released as an open-source library.</li>
<li><strong>Documentation</strong>: The paper serves as the first alpha specification for community discussion and refinement. No formal algorithmic pseudocode for automated string parsing or generation from structured nanomaterials files (like <code>.cif</code>) is provided.</li>
</ul>
<table>
  <thead>
      <tr>
          <th>Artifact</th>
          <th>Type</th>
          <th>License</th>
          <th>Notes</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td><a href="http://enaloscloud.novamechanics.com/nanocommons/NInChI/">NInChI Generator (Enalos Cloud)</a></td>
          <td>Other</td>
          <td>Unknown</td>
          <td>Prototype web tool for generating NInChI strings; backend not open-source</td>
      </tr>
      <tr>
          <td><a href="https://www.mdpi.com/2079-4991/10/12/2493">Paper (MDPI)</a></td>
          <td>Other</td>
          <td>CC BY 4.0</td>
          <td>Open-access alpha specification</td>
      </tr>
  </tbody>
</table>
<h2 id="paper-information">Paper Information</h2>
<p><strong>Citation</strong>: Lynch, I., Afantitis, A., Exner, T., Himly, M., Lobaskin, V., Doganis, P., &hellip; &amp; Melagraki, G. (2020). Can an InChI for Nano Address the Need for a Simplified Representation of Complex Nanomaterials across Experimental and Nanoinformatics Studies? <em>Nanomaterials</em>, <em>10</em>(12), 2493. <a href="https://doi.org/10.3390/nano10122493">https://doi.org/10.3390/nano10122493</a></p>
<p><strong>Publication</strong>: Nanomaterials (2020)</p>
<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">@article</span>{lynch2020inchi,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">title</span>=<span style="color:#e6db74">{Can an InChI for Nano Address the Need for a Simplified Representation of Complex Nanomaterials across Experimental and Nanoinformatics Studies?}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">author</span>=<span style="color:#e6db74">{Lynch, Iseult and Afantitis, Antreas and Exner, Thomas and others}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">journal</span>=<span style="color:#e6db74">{Nanomaterials}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">volume</span>=<span style="color:#e6db74">{10}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">number</span>=<span style="color:#e6db74">{12}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">pages</span>=<span style="color:#e6db74">{2493}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">year</span>=<span style="color:#e6db74">{2020}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">publisher</span>=<span style="color:#e6db74">{MDPI}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">doi</span>=<span style="color:#e6db74">{10.3390/nano10122493}</span>
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div>]]></content:encoded></item><item><title>Mixfile &amp; MInChI: Machine-Readable Mixture Formats</title><link>https://hunterheidenreich.com/notes/chemistry/molecular-representations/notations/mixfile-minchi/</link><pubDate>Sun, 12 Oct 2025 00:00:00 +0000</pubDate><guid>https://hunterheidenreich.com/notes/chemistry/molecular-representations/notations/mixfile-minchi/</guid><description>Mixfile and MInChI provide the first standardized, machine-readable formats for representing chemical mixtures.</description><content:encoded><![CDATA[<h2 id="a-standardized-resource-for-chemical-mixtures">A Standardized Resource for Chemical Mixtures</h2>
<p>This is a <strong>Resource</strong> paper that introduces two complementary standards for representing chemical mixtures: the detailed <strong>Mixfile</strong> format for comprehensive mixture descriptions and the compact <strong>MInChI</strong> (Mixtures InChI) specification for canonical mixture identifiers.</p>
<h2 id="the-missing-format-for-complex-formulations">The Missing Format for Complex Formulations</h2>
<p>There is a fundamental gap in chemical informatics: current standards excel at representing pure individual molecules (SMILES, InChI, Molfile), but a corresponding standard for multi-component mixtures remains an open challenge. This is a major problem because real-world chemistry predominantly involves complex mixtures.</p>
<p>Everyday chemical work frequently involves:</p>
<ul>
<li>Reagents with specified purity (e.g., &ldquo;$\geq$ 97% pure&rdquo;)</li>
<li>Solutions and formulations</li>
<li>Complex mixtures like &ldquo;hexanes&rdquo; (which contains multiple isomers)</li>
<li>Drug formulations with active ingredients and excipients</li>
</ul>
<p>Without a machine-readable standard, chemists are forced to describe these mixtures in plain text that software cannot parse or analyze systematically. This creates barriers for automated safety analysis, inventory management, and data sharing.</p>
<h2 id="dual-design-comprehensive-mixfiles-and-canonical-minchis">Dual Design: Comprehensive Mixfiles and Canonical MInChIs</h2>
<p>The authors propose a two-part solution:</p>
<ol>
<li><strong>Mixfile</strong>: A detailed, hierarchical JSON format that captures the complete composition of a mixture</li>
<li><strong>MInChI</strong>: A compact, canonical string identifier derived from Mixfile data</li>
</ol>
<p>This dual approach provides both comprehensive description (Mixfile) and simple identification (MInChI), similar to having both a detailed recipe and a short name for a dish.</p>
<h3 id="what-makes-a-good-mixture-format">What Makes a Good Mixture Format?</h3>
<p>The authors identify three essential properties any mixture format must capture:</p>
<ol>
<li><strong>Compound</strong>: What molecules are present?</li>
<li><strong>Quantity</strong>: How much of each component?</li>
<li><strong>Hierarchy</strong>: How are components organized (e.g., mixtures-of-mixtures)?</li>
</ol>
<p>The hierarchical aspect is crucial. Consider &ldquo;hexanes&rdquo;: it is a named mixture containing specific proportions of n-hexane, 2-methylpentane, 3-methylpentane, etc. A mixture format needs to represent both the individual isomers and the fact that they are grouped under the umbrella term &ldquo;hexanes.&rdquo;</p>
<h3 id="mixfile-format-details">Mixfile Format Details</h3>
<p>Mixfile uses JSON as its foundation, making it both human-readable and easy to parse in modern programming languages. The core structure is a hierarchical tree where each component can contain:</p>
<ul>
<li><strong>name</strong>: Component identifier</li>
<li><strong>molfile/smiles/inchi/formula</strong>: Molecular structure (molfile is the primary source of truth)</li>
<li><strong>quantity/units/relation/ratio</strong>: Concentration data with optional relation operators</li>
<li><strong>contents</strong>: Array of sub-components for hierarchical mixtures</li>
<li><strong>identifiers</strong>: Database IDs or URLs for additional information</li>
</ul>
<h4 id="simple-example">Simple Example</h4>
<p>A basic Mixfile might look like:</p>
<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-json" data-lang="json"><span style="display:flex;"><span>{
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">&#34;mixfileVersion&#34;</span>: <span style="color:#ae81ff">0.01</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">&#34;name&#34;</span>: <span style="color:#e6db74">&#34;Acetone, ≥99%&#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">&#34;contents&#34;</span>: [
</span></span><span style="display:flex;"><span>    {
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">&#34;name&#34;</span>: <span style="color:#e6db74">&#34;acetone&#34;</span>,
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">&#34;smiles&#34;</span>: <span style="color:#e6db74">&#34;CC(=O)C&#34;</span>,
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">&#34;quantity&#34;</span>: <span style="color:#ae81ff">99</span>,
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">&#34;units&#34;</span>: <span style="color:#e6db74">&#34;%&#34;</span>,
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">&#34;relation&#34;</span>: <span style="color:#e6db74">&#34;&gt;=&#34;</span>
</span></span><span style="display:flex;"><span>    }
</span></span><span style="display:flex;"><span>  ]
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div><p>Note that the paper specifies distinct fields for molecular structures: <code>molfile</code> (the primary source of truth), <code>smiles</code>, <code>inchi</code>, and <code>formula</code>. Concentration data uses separate <code>quantity</code>, <code>units</code>, and <code>relation</code> fields.</p>
<h4 id="complex-example-mixture-of-mixtures">Complex Example: Mixture-of-Mixtures</h4>
<p>For something like &ldquo;ethyl acetate dissolved in hexanes,&rdquo; the structure would be:</p>
<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-json" data-lang="json"><span style="display:flex;"><span>{
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">&#34;mixfileVersion&#34;</span>: <span style="color:#ae81ff">0.01</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">&#34;name&#34;</span>: <span style="color:#e6db74">&#34;Ethyl acetate in hexanes&#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">&#34;contents&#34;</span>: [
</span></span><span style="display:flex;"><span>    {
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">&#34;name&#34;</span>: <span style="color:#e6db74">&#34;ethyl acetate&#34;</span>,
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">&#34;smiles&#34;</span>: <span style="color:#e6db74">&#34;CCOC(=O)C&#34;</span>,
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">&#34;quantity&#34;</span>: <span style="color:#ae81ff">10</span>,
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">&#34;units&#34;</span>: <span style="color:#e6db74">&#34;%&#34;</span>
</span></span><span style="display:flex;"><span>    },
</span></span><span style="display:flex;"><span>    {
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">&#34;name&#34;</span>: <span style="color:#e6db74">&#34;hexanes&#34;</span>,
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">&#34;contents&#34;</span>: [
</span></span><span style="display:flex;"><span>        {
</span></span><span style="display:flex;"><span>          <span style="color:#f92672">&#34;name&#34;</span>: <span style="color:#e6db74">&#34;n-hexane&#34;</span>,
</span></span><span style="display:flex;"><span>          <span style="color:#f92672">&#34;smiles&#34;</span>: <span style="color:#e6db74">&#34;CCCCCC&#34;</span>,
</span></span><span style="display:flex;"><span>          <span style="color:#f92672">&#34;quantity&#34;</span>: <span style="color:#ae81ff">60</span>,
</span></span><span style="display:flex;"><span>          <span style="color:#f92672">&#34;units&#34;</span>: <span style="color:#e6db74">&#34;%&#34;</span>
</span></span><span style="display:flex;"><span>        },
</span></span><span style="display:flex;"><span>        {
</span></span><span style="display:flex;"><span>          <span style="color:#f92672">&#34;name&#34;</span>: <span style="color:#e6db74">&#34;2-methylpentane&#34;</span>,
</span></span><span style="display:flex;"><span>          <span style="color:#f92672">&#34;smiles&#34;</span>: <span style="color:#e6db74">&#34;CC(C)CCC&#34;</span>,
</span></span><span style="display:flex;"><span>          <span style="color:#f92672">&#34;quantity&#34;</span>: <span style="color:#ae81ff">25</span>,
</span></span><span style="display:flex;"><span>          <span style="color:#f92672">&#34;units&#34;</span>: <span style="color:#e6db74">&#34;%&#34;</span>
</span></span><span style="display:flex;"><span>        }
</span></span><span style="display:flex;"><span>      ]
</span></span><span style="display:flex;"><span>    }
</span></span><span style="display:flex;"><span>  ]
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div><p>This hierarchical structure captures the &ldquo;recipe&rdquo; of complex mixtures while remaining machine-readable.</p>
<h3 id="minchi-canonical-mixture-identifiers">MInChI: Canonical Mixture Identifiers</h3>
<p>While Mixfiles provide comprehensive descriptions, simple identifiers are also needed for database storage and searching. This is where MInChI comes in.</p>
<p>A MInChI string is structured as:</p>
<pre><code>MInChI=0.00.1S/&lt;components&gt;/n&lt;indexing&gt;/g&lt;concentration&gt;
</code></pre>
<ul>
<li><strong>Header</strong>: Version information (<code>0.00.1S</code> in the paper&rsquo;s specification)</li>
<li><strong>Components</strong>: Standard InChI for each unique molecule, sorted alphabetically <em>by the InChI strings themselves</em>, then concatenated with <code>&amp;</code></li>
<li><strong>Indexing</strong> (prefixed with <code>/n</code>): Hierarchical structure using curly braces <code>{}</code> for branches and <code>&amp;</code> for adjacent nodes; uses 1-based integer indices referring to the sorted InChI list</li>
<li><strong>Concentration</strong> (prefixed with <code>/g</code>): Quantitative information for each component, with units converted to canonical codes</li>
</ul>
<h4 id="why-this-matters">Why This Matters</h4>
<p>MInChI strings enable simple database searches:</p>
<ul>
<li>Check if a specific component appears in any mixture</li>
<li>Compare different formulations of the same product</li>
<li>Identify similar mixtures based on string similarity</li>
</ul>
<h2 id="validating-the-standard-through-practical-tooling">Validating the Standard Through Practical Tooling</h2>
<p>The paper demonstrates the format&rsquo;s capabilities through several practical applications and a proof-of-concept implementation:</p>
<h3 id="text-extraction-algorithm">Text Extraction Algorithm</h3>
<p>The authors demonstrate a proof-of-concept algorithm that uses regular expressions and chemical name recognition to parse plain-text mixture descriptions into structured Mixfile data. The algorithm:</p>
<ol>
<li>Applies regex rules to remove filler words and extract concentrations</li>
<li>Looks up cleaned names against a custom chemical database</li>
<li>Falls back to OPSIN for SMILES generation from chemical names</li>
<li>Generates 2D coordinates for molecular structures</li>
</ol>
<h3 id="graphical-editor">Graphical Editor</h3>
<p>An open-source editor provides:</p>
<ul>
<li>Tree-based interface for building and editing hierarchical structures</li>
<li>Chemical structure sketching and editing</li>
<li>Database lookup (e.g., PubChem integration)</li>
<li>Automatic MInChI generation</li>
<li>Import/export capabilities</li>
</ul>
<h3 id="example-use-cases">Example Use Cases</h3>
<p>The paper validates the format through real-world applications:</p>
<ul>
<li><strong>Safety compliance</strong>: Automated hazard assessment based on concentration-dependent properties (e.g., solid osmium tetroxide vs. 1% aqueous solution)</li>
<li><strong>Inventory management</strong>: Precise, searchable laboratory records</li>
<li><strong>Data extraction</strong>: Parsing vendor catalogs and safety data sheets</li>
</ul>
<h2 id="outcomes-and-future-extensibility">Outcomes and Future Extensibility</h2>
<p>The work successfully establishes the first standardized, machine-readable formats for chemical mixtures. Key achievements:</p>
<ul>
<li><strong>Comprehensive representation</strong>: Mixfile captures component identity, quantity, and hierarchy</li>
<li><strong>Canonical identification</strong>: MInChI provides compact, searchable identifiers</li>
<li><strong>Practical tooling</strong>: Open-source editor and text extraction demonstrate feasibility</li>
<li><strong>Real-world validation</strong>: Format handles diverse use cases from safety to inventory</li>
</ul>
<h3 id="limitations-and-future-directions">Limitations and Future Directions</h3>
<p>The authors acknowledge areas for improvement:</p>
<ul>
<li><strong>Machine learning improvements</strong>: Better text extraction using modern NLP techniques</li>
<li><strong>Extended coverage</strong>: Support for polymers, complex formulations, analytical results</li>
<li><strong>Community adoption</strong>: Integration with existing chemical databases and software</li>
</ul>
<p>The hierarchical design makes Mixfile suitable for both &ldquo;recipe&rdquo; descriptions (how to make something) and analytical results (what was found). This flexibility should help drive adoption across different use cases in chemistry and materials science.</p>
<h2 id="reproducibility-details">Reproducibility Details</h2>
<h3 id="open-source-tooling--data">Open Source Tooling &amp; Data</h3>
<p>While the central repository focusing on validating and establishing the MInChI standard is <a href="https://github.com/IUPAC/MInChI">github.com/IUPAC/MInChI</a>, the tools and datasets actually used to develop the paper&rsquo;s proofs-of-concept are hosted elsewhere:</p>
<ul>
<li><strong>Graphical Editor &amp; App codebase</strong>: The Electron application and Mixfile handling codebase (<code>console.js</code>) can be found at <a href="https://github.com/cdd/mixtures">github.com/cdd/mixtures</a>.</li>
<li><strong>Text Extraction Data</strong>: The several thousand extracted mixture records generated through the text extraction method can be accessed inside the <code>cdd/mixtures</code> repository under <a href="https://github.com/cdd/mixtures/tree/master/reference"><code>reference/gathering.zip</code></a>.</li>
</ul>
<h3 id="artifacts">Artifacts</h3>
<table>
  <thead>
      <tr>
          <th style="text-align: left">Artifact</th>
          <th style="text-align: left">Type</th>
          <th style="text-align: left">License</th>
          <th style="text-align: left">Notes</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td style="text-align: left"><a href="https://github.com/IUPAC/MInChI">IUPAC/MInChI</a></td>
          <td style="text-align: left">Code / Data</td>
          <td style="text-align: left">Unknown</td>
          <td style="text-align: left">Validation test suite with ~150 mixture JSON files</td>
      </tr>
      <tr>
          <td style="text-align: left"><a href="https://github.com/cdd/mixtures">cdd/mixtures</a></td>
          <td style="text-align: left">Code / Data</td>
          <td style="text-align: left">GPL-3.0</td>
          <td style="text-align: left">Electron-based Mixfile editor, CLI tools, and reference mixture corpus</td>
      </tr>
  </tbody>
</table>
<p>The paper was funded by NIH Grant 1R43TR002528-01. No specific hardware requirements are needed, as this is a format specification with lightweight tooling.</p>
<h3 id="algorithms">Algorithms</h3>
<p>This section provides the specific algorithmic logic, schema definitions, and standardization rules needed to replicate the Mixfile parser or MInChI generator.</p>
<h4 id="the-strict-mixfile-json-schema">The Strict Mixfile JSON Schema</h4>
<p>To implement the format, a parser must recognize these specific fields:</p>
<p><strong>Root Structure</strong>:</p>
<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-json" data-lang="json"><span style="display:flex;"><span>{
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">&#34;mixfileVersion&#34;</span>: <span style="color:#ae81ff">0.01</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">&#34;header&#34;</span>: {},
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">&#34;contents&#34;</span>: []
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div><p><strong>Component Fields</strong>:</p>
<ul>
<li><code>name</code>: string (required if no structure is provided)</li>
<li><code>molfile</code>: string (the primary source of truth for molecular structure)</li>
<li><code>smiles</code>, <code>inchi</code>, <code>formula</code>: derived/transient fields for convenience</li>
<li><code>quantity</code>: number OR <code>[min, max]</code> array for ranges</li>
<li><code>units</code>: string (must map to supported ontology)</li>
<li><code>relation</code>: string (e.g., <code>&quot;&gt;&quot;</code>, <code>&quot;~&quot;</code>, <code>&quot;&gt;=&quot;</code>)</li>
<li><code>ratio</code>: array of two numbers <code>[numerator, denominator]</code></li>
<li><code>identifiers</code>: database assignments (e.g., CASRN, PubChem)</li>
<li><code>links</code>: URLs relevant to the component</li>
<li><code>contents</code>: recursive array for hierarchical mixtures</li>
</ul>
<h4 id="minchi-generation-algorithm">MInChI Generation Algorithm</h4>
<p>To generate <code>MInChI=0.00.1S/...</code>, the software must follow these steps:</p>
<ol>
<li>
<p><strong>Component Layer</strong>:</p>
<ul>
<li>Calculate standard <a href="/notes/chemistry/molecular-representations/notations/inchi-2013/">InChI</a> for all structures in the mixture</li>
<li>Sort distinct InChIs alphabetically by the InChI string itself</li>
<li>Join with <code>&amp;</code> to form the structure layer</li>
</ul>
</li>
<li>
<p><strong>Hierarchy &amp; Concentration Layers</strong>:</p>
<ul>
<li>Traverse the Mixfile tree recursively</li>
<li><strong>Indexing</strong>: Use integer indices (1-based) referring to the sorted InChI list</li>
<li><strong>Grouping</strong>: Use <code>{}</code> to denote hierarchy branches and <code>&amp;</code> to separate nodes at the same level</li>
<li><strong>Concentration</strong>: Convert all quantities to canonical unit codes and apply scaling factors</li>
</ul>
</li>
</ol>
<h4 id="unit-standardization-table">Unit Standardization Table</h4>
<p>Replication requires mapping input units to canonical MInChI codes. The full table from the paper (Table 1) includes:</p>
<table>
  <thead>
      <tr>
          <th style="text-align: left">Input Unit</th>
          <th style="text-align: left">MInChI Code</th>
          <th style="text-align: left">Scale Factor</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td style="text-align: left">%</td>
          <td style="text-align: left">pp</td>
          <td style="text-align: left">1</td>
      </tr>
      <tr>
          <td style="text-align: left">w/v%</td>
          <td style="text-align: left">wv</td>
          <td style="text-align: left">0.01</td>
      </tr>
      <tr>
          <td style="text-align: left">w/w%</td>
          <td style="text-align: left">wf</td>
          <td style="text-align: left">0.01</td>
      </tr>
      <tr>
          <td style="text-align: left">v/v%</td>
          <td style="text-align: left">vf</td>
          <td style="text-align: left">0.01</td>
      </tr>
      <tr>
          <td style="text-align: left">mol/mol%</td>
          <td style="text-align: left">mf</td>
          <td style="text-align: left">0.01</td>
      </tr>
      <tr>
          <td style="text-align: left">mol/L (M)</td>
          <td style="text-align: left">mr</td>
          <td style="text-align: left">1</td>
      </tr>
      <tr>
          <td style="text-align: left">mmol/L</td>
          <td style="text-align: left">mr</td>
          <td style="text-align: left">$10^{-3}$</td>
      </tr>
      <tr>
          <td style="text-align: left">g/L</td>
          <td style="text-align: left">wv</td>
          <td style="text-align: left">$10^{-3}$</td>
      </tr>
      <tr>
          <td style="text-align: left">mol/kg</td>
          <td style="text-align: left">mb</td>
          <td style="text-align: left">1</td>
      </tr>
      <tr>
          <td style="text-align: left">ratio</td>
          <td style="text-align: left">vp</td>
          <td style="text-align: left">1</td>
      </tr>
  </tbody>
</table>
<h4 id="text-extraction-logic">Text Extraction Logic</h4>
<p>The paper defines a recursive procedure for parsing plain-text mixture descriptions:</p>
<ol>
<li><strong>Input</strong>: Raw text string (e.g., &ldquo;2 M acetone in water&rdquo;)</li>
<li><strong>Rule Application</strong>: Apply RegEx rules in order:
<ul>
<li><em>Remove</em>: Delete common filler words (&ldquo;solution&rdquo;, &ldquo;in&rdquo;)</li>
<li><em>Replace</em>: Substitute known variations</li>
<li><em>Concentration</em>: Extract quantities like &ldquo;2 M&rdquo;, &ldquo;97%&rdquo;</li>
<li><em>Branch</em>: Split phrases like &ldquo;A in B&rdquo; into sub-nodes</li>
</ul>
</li>
<li><strong>Lookup</strong>: Check cleaned name against a custom table (handles cases like &ldquo;xylenes&rdquo; or specific structures)</li>
<li><strong>OPSIN</strong>: If no lookup match, send to the OPSIN tool to generate SMILES from the chemical name</li>
<li><strong>Embed</strong>: If structure found, generate 2D coordinates (Molfile) via RDKit</li>
</ol>
<h2 id="paper-information">Paper Information</h2>
<p><strong>Citation</strong>: Clark, A. M., McEwen, L. R., Gedeck, P., &amp; Bunin, B. A. (2019). Capturing mixture composition: an open machine-readable format for representing mixed substances. <em>Journal of Cheminformatics</em>, <em>11</em>(1), 33. <a href="https://doi.org/10.1186/s13321-019-0357-4">https://doi.org/10.1186/s13321-019-0357-4</a></p>
<p><strong>Publication</strong>: Journal of Cheminformatics (2019)</p>
<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">@article</span>{clark2019capturing,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">title</span>=<span style="color:#e6db74">{Capturing mixture composition: an open machine-readable format for representing mixed substances}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">author</span>=<span style="color:#e6db74">{Clark, Alex M and McEwen, Leah R and Gedeck, Peter and Bunin, Barry A}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">journal</span>=<span style="color:#e6db74">{Journal of cheminformatics}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">volume</span>=<span style="color:#e6db74">{11}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">number</span>=<span style="color:#e6db74">{1}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">pages</span>=<span style="color:#e6db74">{33}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">year</span>=<span style="color:#e6db74">{2019}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">publisher</span>=<span style="color:#e6db74">{BioMed Central}</span>
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div><p><strong>Additional Resources</strong>:</p>
<ul>
<li><a href="https://github.com/IUPAC/MInChI">Official MInChI GitHub repository</a></li>
</ul>
]]></content:encoded></item><item><title>Making InChI FAIR and Sustainable for Inorganic Chemistry</title><link>https://hunterheidenreich.com/notes/chemistry/molecular-representations/notations/inchi-2025/</link><pubDate>Sun, 12 Oct 2025 00:00:00 +0000</pubDate><guid>https://hunterheidenreich.com/notes/chemistry/molecular-representations/notations/inchi-2025/</guid><description>InChI v1.07 modernizes chemical identifiers for FAIR data principles and adds comprehensive support for inorganic compounds.</description><content:encoded><![CDATA[<h2 id="paper-contribution-modernizing-chemical-identifiers">Paper Contribution: Modernizing Chemical Identifiers</h2>
<p>This is a <strong>Resource</strong> paper that describes the development and maintenance of InChI (International Chemical Identifier), a fundamental infrastructure component for chemical databases. While it includes methodological improvements to the canonicalization algorithm for inorganic compounds, its primary contribution is ensuring the sustainability and accessibility of a critical chemical informatics resource.</p>
<h2 id="motivation-the-inorganic-chemistry-problem">Motivation: The Inorganic Chemistry Problem</h2>
<p>The International Chemical Identifier (InChI) is prevalent in chemistry databases, with over a billion structures using it. The original system was designed specifically for organic chemistry and systematically fails to parse organometallic structures accurately. The original implementation had significant limitations:</p>
<ul>
<li><strong>FAIR principles gap</strong>: Development was closed-source, documentation was inadequate, and the codebase was difficult to maintain</li>
<li><strong>Inorganic chemistry failure</strong>: Metal-ligand bonds were automatically disconnected, destroying stereochemical information for coordination complexes</li>
<li><strong>Technical debt</strong>: More than 3000 bugs and security vulnerabilities, nearly 60 Google OSS-Fuzz issues, and an unmaintainable codebase</li>
</ul>
<p>If you&rsquo;ve ever tried to search for a metal complex in a chemical database and gotten nonsense results, this is why. This paper describes the fix.</p>
<h2 id="core-innovation-smart-metal-ligand-handling">Core Innovation: Smart Metal-Ligand Handling</h2>
<p>The key innovations are:</p>
<ol>
<li>
<p><strong>Smart metal-ligand bond handling</strong>: A decision tree algorithm that uses coordination number and electronegativity to determine which bonds to keep and which to disconnect, preserving stereochemistry for coordination complexes</p>
</li>
<li>
<p><strong>Modernized development infrastructure</strong>: Migration to GitHub with open development, comprehensive testing, and maintainable documentation</p>
</li>
<li>
<p><strong>Backward compatibility</strong>: The core canonicalization algorithm remained unchanged, preserving over a billion existing InChIs for organic compounds</p>
</li>
</ol>
<p>The preprocessing step applies a two-pass iterative process for every metal in a structure:</p>
<ol>
<li><strong>Terminal metals</strong> (connected to only one other atom): check the electronegativity lookup table and disconnect if $\Delta EN \geq 1.7$</li>
<li><strong>Non-terminal metals</strong>: if coordination number exceeds the element&rsquo;s standard valence threshold, keep all bonds; otherwise, apply the same electronegativity check per bond (if at least one bond is kept, all are retained)</li>
<li>Hardcoded exceptions exist for Grignard reagents and organolithium compounds</li>
</ol>
<p>For example, $\text{FeCl}_2$ is treated as ionic and disconnected into $\text{Fe}^{2+}$ and $2\ \text{Cl}^-$, while $[\text{FeCl}_4]^{2-}$ remains connected as a coordination complex.</p>
<h2 id="validation-methods--experiments">Validation Methods &amp; Experiments</h2>
<p>The paper focuses on software engineering validation:</p>
<ul>
<li><strong>Bug fixing</strong>: Fixed more than 3000 bugs and security issues, plus nearly 60 Google OSS-Fuzz issues from the legacy codebase</li>
<li><strong>Backward compatibility testing</strong>: Verified that existing organic molecule InChIs remained unchanged</li>
<li><strong>Inorganic compound validation</strong>: Tested the new decision tree algorithm on coordination complexes, organometallic compounds, and ionic salts</li>
<li><strong>Documentation overhaul</strong>: Split technical documentation into Chemical Manual (for chemists) and Technical Manual (for developers)</li>
<li><strong>Web Demo</strong>: Created a browser-based <a href="https://iupac-inchi.github.io/InChI-Web-Demo/">InChI Web Demo</a> that calculates InChI, InChIKey, and AuxInfo from drawn structures or Molfiles, with all computation performed client-side</li>
</ul>
<p>The validation approach emphasizes maintaining the &ldquo;same molecule, same identifier&rdquo; principle while extending coverage to inorganic chemistry.</p>
<h2 id="key-outcomes-and-future-work">Key Outcomes and Future Work</h2>
<p>The v1.07 release successfully:</p>
<ul>
<li><strong>Modernizes infrastructure</strong>: Open development on GitHub with maintainable codebase</li>
<li><strong>Extends to inorganic chemistry</strong>: Proper handling of coordination complexes and organometallic compounds</li>
<li><strong>Maintains backward compatibility</strong>: No breaking changes for existing organic compound InChIs</li>
<li><strong>Improves database search</strong>: Metal complexes now searchable with correct stereochemistry preserved</li>
<li><strong>IUPAC approval</strong>: Version 1.07 has been approved by IUPAC&rsquo;s Committee on Publications and Cheminformatics Data Standards (CPCDS)</li>
</ul>
<p><strong>Acknowledged limitations</strong> for future work:</p>
<ul>
<li>Stereochemistry for inorganic and organometallic compounds still needs improvement, including atropisomers and MDL enhanced stereochemistry</li>
<li>Mixtures (MInChI) and nanomaterials (NInChI) remain unsolved problems</li>
<li>Chemical identifiers work best for discrete molecules and struggle with variable-composition materials</li>
</ul>
<p><strong>Impact</strong>: This update improves searchability of inorganic and organometallic compounds in major chemical databases by preserving coordination bond information that was previously discarded.</p>
<h2 id="reproducibility-details">Reproducibility Details</h2>
<h3 id="software--data-availability">Software &amp; Data Availability</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/IUPAC-InChI/InChI">IUPAC-InChI/InChI</a></td>
          <td>Code</td>
          <td>Open source (IUPAC/InChI Trust)</td>
          <td>Official C/C++ implementation of InChI v1.07</td>
      </tr>
      <tr>
          <td><a href="https://iupac-inchi.github.io/InChI-Web-Demo/">InChI Web Demo</a></td>
          <td>Other</td>
          <td>Open source</td>
          <td>Browser-based InChI/InChIKey generator for testing</td>
      </tr>
  </tbody>
</table>
<p>The InChI v1.07 codebase, primarily written in C/C++, is openly available on GitHub at <a href="https://github.com/IUPAC-InChI/InChI">IUPAC-InChI/InChI</a>. The repository includes the core canonicalization engine and the new inorganic preprocessing logic. Both the Technical Manual (for structural integration) and the Chemical Manual are maintained alongside the codebase. Compiled binaries are available for Windows, Linux, and macOS.</p>
<p><strong>Benchmarking Data</strong>: Validation of the new decision tree logic is managed through rigorous unit testing built directly into the repository&rsquo;s continuous integration pipelines. Standard tests with existing organic compounds confirm backward compatibility, while newly integrated suites of coordination complexes and organometallic compounds ensure the 1.07 processing triggers as expected.</p>
<h3 id="algorithms">Algorithms</h3>
<h4 id="the-metal-problem">The Metal Problem</h4>
<p>InChI&rsquo;s original algorithm assumed that bonds to metals were ionic and automatically disconnected them. This makes sense for something like sodium chloride (NaCl), where you have separate $\text{Na}^+$ and $\text{Cl}^-$ ions.</p>
<p>It fails for:</p>
<ul>
<li><strong>Coordination complexes</strong>: Where ligands are bonded to the metal center</li>
<li><strong>Organometallic compounds</strong>: Where carbon-metal bonds are covalent</li>
<li><strong>Sandwich compounds</strong>: Like ferrocene, where the bonding has both ionic and covalent character</li>
</ul>
<p>The result: loss of stereochemical information and identical InChIs for structurally different compounds.</p>
<h4 id="the-solution-smart-preprocessing">The Solution: Smart Preprocessing</h4>
<p>The new system uses a decision tree to figure out which metal-ligand bonds to keep and which to disconnect. The process is <strong>iterative</strong>: it runs for every metal in the structure, then checks every bond to that metal. In the C/C++ repository, this preprocessing logic acts as a filter applied <em>before</em> the traditional organic canonicalization engine (from v1.06) runs, dynamically determining whether coordination bonds are retained for downstream layer generation.</p>
<h5 id="decision-tree-logic">Decision Tree Logic</h5>
<p>The algorithm handles metals in two passes. First, <strong>terminal metals</strong> (bonded to only one atom) are checked against the electronegativity lookup table and disconnected if $\Delta EN \geq 1.7$. This preserves all metal-metal bonds.</p>
<p>Second, <strong>non-terminal metals</strong> are examined. For a metal $m$ bonded to ligand $l$:</p>
<p>$$
\begin{aligned}
B(m, l) &amp;=
\begin{cases}
\text{Connected (all bonds)} &amp; \text{if } CN(m) &gt; V(m) \\
\text{Connected} &amp; \text{if } |EN(m) - EN(l)| &lt; 1.7 \\
\text{Disconnected} &amp; \text{if } |EN(m) - EN(l)| \geq 1.7
\end{cases}
\end{aligned}
$$</p>
<p>A key rule: if at least one metal-ligand bond is kept for a given metal, all other bonds to that metal are also retained (no disconnection is carried out).</p>
<p><em>(Note: Explicit overrides exist for specific classes like Grignard reagents).</em></p>
<h5 id="hardcoded-chemical-exceptions">Hardcoded Chemical Exceptions</h5>
<p>The algorithm includes specific overrides based on well-established chemistry:</p>
<ul>
<li><strong>Grignard reagents (RMgX)</strong>: Explicitly configured to <strong>keep</strong> the Mg-C bond but <strong>disconnect</strong> the Mg-halide bond</li>
<li><strong>Organolithium compounds (RLi)</strong>: Explicitly configured to keep the structure intact</li>
</ul>
<p>These exceptions exist because the general electronegativity rules would give incorrect results for these compound classes.</p>
<h5 id="practical-example">Practical Example</h5>
<p>For example, $\text{FeCl}_2$ is treated as ionic and disconnected into $\text{Fe}^{2+}$ and $2\ \text{Cl}^-$, while $[\text{FeCl}_4]^{2-}$ remains connected because its coordination number exceeds the threshold.</p>
<h4 id="how-inchi-generation-works">How InChI Generation Works</h4>
<p>The process has six main steps:</p>
<ol>
<li><strong>Parse input</strong>: Read the structure from a file (Molfile, SDF, etc.)</li>
<li><strong>Convert to internal format</strong>: Transform into the software&rsquo;s data structures</li>
<li><strong>Normalize</strong>: Standardize tautomers, resolve ambiguities (where the new metal rules apply)</li>
<li><strong>Canonicalize</strong>: Create a unique representation independent of atom numbering</li>
<li><strong>Generate InChI string</strong>: Build the layered text identifier</li>
<li><strong>Create InChIKey</strong>: Hash the full string into a 27-character key for databases</li>
</ol>
<p>The InChI itself has separate layers for formula, connectivity, hydrogens, stereochemistry, isotopes, and charge. The InChIKey is what actually gets stored in databases for fast searching.</p>
<h5 id="inchikey-version-flag">InChIKey Version Flag</h5>
<p>Character 25 of the InChIKey indicates the version status:</p>
<ul>
<li><strong>&ldquo;S&rdquo;</strong>: Standard InChI</li>
<li><strong>&ldquo;N&rdquo;</strong>: Non-standard InChI</li>
<li><strong>&ldquo;B&rdquo;</strong>: Beta (experimental features)</li>
</ul>
<p>This flag is important for anyone parsing InChIKeys programmatically, as it tells you whether the identifier was generated using stable or experimental algorithms.</p>
<h2 id="additional-context">Additional Context</h2>
<h3 id="what-inchi-actually-does">What InChI Actually Does</h3>
<p>InChI creates a unique text string for any chemical structure. SMILES has multiple vendor implementations and can represent the same molecule in different ways. InChI provides a single, standardized format controlled by IUPAC. The goal is simple: same molecule, same identifier, every time.</p>
<p>This matters for FAIR data principles:</p>
<ul>
<li><strong>Findable</strong>: You can search for a specific compound across databases</li>
<li><strong>Accessible</strong>: The standard is open and free</li>
<li><strong>Interoperable</strong>: Different systems can connect chemical knowledge</li>
<li><strong>Reusable</strong>: The identifiers work consistently across platforms</li>
</ul>
<h3 id="better-documentation">Better Documentation</h3>
<p>The technical manual is being split into two documents:</p>
<ul>
<li><strong>Chemical Manual</strong>: For chemists who need to understand what InChIs mean</li>
<li><strong>Technical Manual</strong>: For developers who need to implement the algorithms</li>
</ul>
<p>This addresses the problem of current documentation serving both audiences poorly.</p>
<h3 id="the-bigger-picture">The Bigger Picture</h3>
<p>InChI&rsquo;s evolution reflects chemistry&rsquo;s expansion beyond its organic roots. The fact that it took this long to properly handle inorganic compounds shows how much computational chemistry has historically focused on carbon-based molecules.</p>
<p>As the field moves into catalysis, materials science, and coordination chemistry applications, having proper chemical identifiers becomes essential. You can&rsquo;t build FAIR chemical databases if half of chemistry is represented incorrectly.</p>
<h2 id="paper-information">Paper Information</h2>
<p><strong>Citation</strong>: Blanke, G., Brammer, J., Baljozovic, D., Khan, N. U., Lange, F., Bänsch, F., Tovee, C. A., Schatzschneider, U., Hartshorn, R. M., &amp; Herres-Pawlis, S. (2025). Making the InChI FAIR and sustainable while moving to inorganics. <em>Faraday Discussions</em>, 256, 503-519. <a href="https://doi.org/10.1039/D4FD00145A">https://doi.org/10.1039/D4FD00145A</a></p>
<p><strong>Publication</strong>: Faraday Discussions, 2025</p>
<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">@article</span>{blanke2025making,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">title</span>=<span style="color:#e6db74">{Making the InChI FAIR and sustainable while moving to inorganics}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">author</span>=<span style="color:#e6db74">{Blanke, G. and Brammer, J. and Baljozovic, D. and Khan, N. U. and Lange, F. and B{\&#34;a}nsch, F. and Tovee, C. A. and Schatzschneider, U. and Hartshorn, R. M. and Herres-Pawlis, S.}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">journal</span>=<span style="color:#e6db74">{Faraday Discussions}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">volume</span>=<span style="color:#e6db74">{256}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">pages</span>=<span style="color:#e6db74">{503--519}</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">publisher</span>=<span style="color:#e6db74">{Royal Society of Chemistry}</span>
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div>]]></content:encoded></item><item><title>InChI: The Worldwide Chemical Structure Identifier Standard</title><link>https://hunterheidenreich.com/notes/chemistry/molecular-representations/notations/inchi-2013/</link><pubDate>Sun, 12 Oct 2025 00:00:00 +0000</pubDate><guid>https://hunterheidenreich.com/notes/chemistry/molecular-representations/notations/inchi-2013/</guid><description>Heller et al. (2013) explain how IUPAC's InChI became the global standard for representing chemical structures, its governance, and current limitations.</description><content:encoded><![CDATA[<h2 id="inchi-as-a-resource-and-systematization-standard">InChI as a Resource and Systematization Standard</h2>
<p>This is a <strong>Resource &amp; Systematization Paper</strong> that reviews the history, technical architecture, governance structure, and implementation status of the InChI standard. It documents both the institutional development of an open chemical identifier and the technical specification that enables it.</p>
<h2 id="the-motivation-interoperability-in-chemical-databases">The Motivation: Interoperability in Chemical Databases</h2>
<p>Before InChI, the chemistry community faced a fundamental interoperability problem. Chemical databases used proprietary systems like CAS Registry Numbers, or format-dependent representations like <a href="/notes/chemistry/molecular-representations/notations/smiles/">SMILES</a> strings. These were expensive, restricted, and relied on &ldquo;in-house&rdquo; databases.</p>
<p>The authors argue the Internet and Open Source software acted as a <strong>&ldquo;black swan&rdquo; event</strong> that disrupted this status quo. The Internet created a need to link diverse, free and fee-based resources without a central gatekeeper. InChI was designed as the solution: a non-proprietary, open-source identifier enabling linking of distinct data compilations.</p>
<h2 id="technical-and-institutional-innovations-of-inchi">Technical and Institutional Innovations of InChI</h2>
<p>InChI&rsquo;s innovation is both technical and institutional:</p>
<p><strong>Technical novelty</strong>: A hierarchical &ldquo;layered&rdquo; canonicalization system where structure representations build from basic connectivity to full stereochemistry. This allows flexible matching: a molecule with unknown stereochemistry produces an InChI that&rsquo;s a subset of the same molecule with known stereochemistry.</p>
<p><strong>Institutional novelty</strong>: Creating an open standard governed by a charitable trust (the InChI Trust) that convinced commercial competitors (publishers, databases) to adopt it as a &ldquo;pre-competitive&rdquo; necessity. This solved the political problem of maintaining an open standard in a competitive industry.</p>
<h3 id="technical-architecture-layers-and-hashing">Technical Architecture: Layers and Hashing</h3>
<h4 id="the-inchi-string">The InChI String</h4>
<p>InChI is a <strong>canonicalized structure representation</strong> derived from IUPAC conventions. It uses a hierarchical &ldquo;layered&rdquo; format where specific layers add detail. The exact technical specification includes these string segments:</p>
<ol>
<li><strong>Main Layer</strong>: Chemical Formula</li>
<li><strong>Connectivity Layer (<code>/c</code>)</strong>: Atoms and bonds (excluding bond orders)</li>
<li><strong>Hydrogen Layer (<code>/h</code>)</strong>: Tautomeric and immobile H atoms</li>
<li><strong>Charge (<code>/q</code>) &amp; Proton Balance (<code>/p</code>)</strong>: Accounting for ionization</li>
<li><strong>Stereochemistry</strong>:
<ul>
<li>Double bond (<code>/b</code>) and Tetrahedral (<code>/t</code>) parity</li>
<li>Parity inversion (<code>/m</code>)</li>
<li>Stereo type (<code>/s</code>): absolute, relative, or racemic</li>
</ul>
</li>
<li><strong>Fixed-H Layer (<code>/f</code>)</strong>: Distinguishes specific tautomers if needed</li>
</ol>
<p>This layered approach means that a molecule with unknown stereochemistry will have an InChI that&rsquo;s a subset of the same molecule with known stereochemistry. This allows for flexible matching at the connectivity level even without complete stereochemical information.</p>
<h4 id="the-inchikey">The InChIKey</h4>
<p>Because InChI strings can be too long for search engines (which break at ~30 characters or at symbols like <code>/</code> and <code>+</code>), the InChIKey was created.</p>
<p><strong>Mechanism</strong>: A 27-character string generated via a <strong>SHA-256 hash</strong> of the InChI string. This can be represented as:</p>
<p>$$ \text{InChIKey} = f_{\text{SHA-256}}(\text{InChI}) $$</p>
<p><strong>Structure</strong>:</p>
<ul>
<li><strong>Block 1 (14 characters)</strong>: Encodes the molecular skeleton (connectivity)</li>
<li><strong>Block 2 (10 characters)</strong>: Eight letters encoding stereochemistry and isotopes, plus a flag indicating standard InChI (S) and an InChI version indicator (A for version 1)</li>
<li><strong>Block 3 (1 character)</strong>: Protonation flag (e.g., &lsquo;N&rsquo; for neutral)</li>
</ul>
<p>Because the InChIKey is a hash, it cannot be converted back to a structure (irreversible) and has a theoretical risk of collision. It is important to distinguish between <strong>InChI collisions</strong> (which are due to flaws/bugs and are very rare) and <strong>InChIKey collisions</strong> (which are mathematically inevitable due to hashing).</p>
<h2 id="what-experiments-were-performed">What experiments were performed?</h2>
<p>This is a systematization paper documenting an existing standard. However, the authors provide:</p>
<p><strong>Validation evidence</strong>:</p>
<ul>
<li><strong>Certification Suite</strong>: A test suite that software vendors must pass to display the &ldquo;InChI Certified&rdquo; logo, preventing fragmentation</li>
<li><strong>Round-trip conversion testing</strong>: Demonstrated &gt;99% success rate converting InChI back to structure (100% with AuxInfo layer)</li>
<li><strong>Real-world adoption metrics</strong>: Documented integration across major chemical databases and publishers</li>
</ul>
<p><strong>Known limitations identified</strong>:</p>
<ul>
<li>Tautomer representation issues in Version 1 (different drawings of same tautomer can generate different InChIs)</li>
<li>Edge cases in stereochemistry representation</li>
</ul>
<h3 id="institutional-history--governance">Institutional History &amp; Governance</h3>
<p><strong>Origin</strong>: The project was initiated at a March 2000 IUPAC meeting in Washington, DC. It was originally called the <strong>IUPAC Chemical Identifier Project (IChIP)</strong>.</p>
<p><strong>Development</strong>: Technical work was done by NIST (Stein, Heller, Tchekhovskoi), overseen by the IUPAC <strong>CCINS</strong> committee, which later became the <strong>InChI Subcommittee</strong> of Division VIII.</p>
<p><strong>The InChI Trust</strong>: To ensure the algorithm survived beyond a volunteer organization, the <strong>InChI Trust</strong> was formed in 2009. It is a UK charity supported by publishers and databases (e.g., Nature, RSC) to maintain the standard pre-competitively. This was a critical innovation: getting commercial publishers and software vendors to agree that a non-proprietary standard would benefit everyone.</p>
<h2 id="real-world-impact-and-future-directions">Real-World Impact and Future Directions</h2>
<h3 id="key-findings">Key Findings</h3>
<p><strong>Success through &ldquo;un-coerced adoption&rdquo;</strong>: InChI succeeded because commercial competitors viewed it as a &ldquo;pre-competitive&rdquo; necessity for the Internet age. The open governance model proved durable.</p>
<p><strong>Technical achievements</strong>:</p>
<ul>
<li>Reversible representation (&gt;99% without AuxInfo, 100% with it)</li>
<li>Hierarchical structure enables flexible matching at different levels of detail</li>
<li>InChIKey enables web search despite being a hash (with inherent collision risk)</li>
</ul>
<h3 id="limitations-acknowledged-as-of-2013">Limitations Acknowledged (as of 2013)</h3>
<ul>
<li><strong>Tautomerism Issues</strong>: Different drawings of the same tautomer (e.g., 1,4-oxime vs nitroso) can generate different InChIs in Version 1, which is targeted for Version 2</li>
<li><strong>Hash collision risk</strong>: InChIKey collisions are mathematically inevitable due to SHA-256 hashing, though InChI collisions (actual bugs) are very rare</li>
<li><strong>Certification required</strong>: To prevent fragmentation, software must pass the InChI Certification Suite</li>
</ul>
<h3 id="future-directions">Future Directions</h3>
<p>The authors note that while this paper documents the state as of 2013, InChI continues to evolve. Tautomer handling and edge cases in stereochemistry representation were priorities for future versions. The governance model through the InChI Trust was designed to ensure long-term maintenance beyond the original volunteer contributors.</p>
<h2 id="reproducibility-details">Reproducibility Details</h2>
<p>This systematization paper documents an existing standard. Key implementation resources are openly maintained by the InChI Trust.</p>
<h3 id="code--software">Code &amp; Software</h3>
<ul>
<li><strong>Official Open Source Implementation</strong>: The C source code and pre-compiled binaries for the InChI algorithm are freely available via the <a href="https://www.inchi-trust.org/downloads/">InChI Trust Downloads Page</a> and their <a href="https://github.com/IUPAC-InChI/InChI">official GitHub repository</a>.</li>
<li><strong>Canonicalization algorithm</strong>: Open-source implementation of IUPAC-based rules for generating unique representations from multiple possible drawings of the same molecule.</li>
</ul>
<h3 id="data--validation">Data &amp; Validation</h3>
<ul>
<li><strong>InChI Certification Suite</strong>: A test suite of chemical structures provided by the InChI Trust used to validate that third-party software implementations generate correct InChIs.</li>
<li><strong>Version 1 specification</strong>: Complete technical documentation of the layered format.</li>
</ul>
<h3 id="evaluation">Evaluation</h3>
<ul>
<li><strong>Round-trip conversion</strong>: &gt;99% success rate (100% with AuxInfo) as validated by NIST and IUPAC.</li>
<li><strong>Certification testing</strong>: Pass/fail validation for software claiming InChI compliance.</li>
</ul>
<h2 id="paper-information">Paper Information</h2>
<p><strong>Citation</strong>: Heller, S., McNaught, A., Stein, S., Tchekhovskoi, D., &amp; Pletnev, I. (2013). InChI - the worldwide chemical structure identifier standard. <em>Journal of Cheminformatics</em>, <em>5</em>(1), 7. <a href="https://doi.org/10.1186/1758-2946-5-7">https://doi.org/10.1186/1758-2946-5-7</a></p>
<p><strong>Publication</strong>: Journal of Cheminformatics, 2013</p>
<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">@article</span>{heller2013inchi,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">title</span>=<span style="color:#e6db74">{{InChI} - the worldwide chemical structure identifier standard}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">author</span>=<span style="color:#e6db74">{Heller, Stephen and McNaught, Alan and Stein, Stephen and Tchekhovskoi, Dmitrii and Pletnev, Igor}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">journal</span>=<span style="color:#e6db74">{Journal of Cheminformatics}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">volume</span>=<span style="color:#e6db74">{5}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">number</span>=<span style="color:#e6db74">{1}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">pages</span>=<span style="color:#e6db74">{7}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">year</span>=<span style="color:#e6db74">{2013}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">publisher</span>=<span style="color:#e6db74">{Springer}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">doi</span>=<span style="color:#e6db74">{10.1186/1758-2946-5-7}</span>
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div>]]></content:encoded></item><item><title>InChI and Tautomerism: Toward Comprehensive Treatment</title><link>https://hunterheidenreich.com/notes/chemistry/molecular-representations/notations/inchi-and-tautomers/</link><pubDate>Sun, 12 Oct 2025 00:00:00 +0000</pubDate><guid>https://hunterheidenreich.com/notes/chemistry/molecular-representations/notations/inchi-and-tautomers/</guid><description>Dhaked et al. compile 86 tautomeric rules and validate them across 400M+ structures, revealing that current InChI misses half of tautomeric relationships.</description><content:encoded><![CDATA[<h2 id="paper-contribution-a-systematized-tautomer-database-resource">Paper Contribution: A Systematized Tautomer Database Resource</h2>
<p>This is a <strong>Resource</strong> paper with strong <strong>Systematization</strong> elements. It provides a comprehensive catalog of 86 tautomeric transformation rules (20 pre-existing CACTVS defaults plus 66 new rules derived from experimental literature), designed to serve as a foundational resource for chemical database systems and the InChI V2 identifier standard. The systematic validation across 400+ million structures also makes it a benchmarking study for evaluating current chemoinformatics tools.</p>
<h2 id="the-tautomerism-problem-in-chemical-databases">The Tautomerism Problem in Chemical Databases</h2>
<p>Chemical databases face a fundamental problem: the same molecule can appear multiple times under different identifiers simply because it exists in different tautomeric forms. For example, glucose&rsquo;s ring-closed and open-chain forms are the same molecule; however, current chemical identifiers (including InChI) often treat them as distinct compounds.</p>















<figure class="post-figure center ">
    <img src="/img/notes/Glucose-tautomerism.webp"
         alt="D-glucose open-chain aldehyde form converting to beta-D-glucopyranose ring form, illustrating ring-chain tautomerism"
         title="D-glucose open-chain aldehyde form converting to beta-D-glucopyranose ring form, illustrating ring-chain tautomerism"
         
         
         loading="lazy"
         class="post-image">
    
    <figcaption class="post-caption">Ring-chain tautomerism in glucose: the open-chain aldehyde form (left) and the cyclic pyranose form (right) are the same molecule in different tautomeric states.</figcaption>
    
</figure>

<p>This creates three critical problems:</p>
<ol>
<li><strong>Database redundancy</strong>: Millions of duplicate entries for the same chemical entities</li>
<li><strong>Search failures</strong>: Researchers miss relevant compounds during structure searches</li>
<li><strong>ML training issues</strong>: Machine learning models learn to treat tautomers as different molecules</li>
</ol>
<p>The motivation for this work is to provide a comprehensive, experimentally-grounded rule set that enables InChI V2 to properly recognize tautomeric relationships, eliminating these problems at the identifier level.</p>
<h2 id="86-comprehensive-tautomeric-transformation-rules">86 Comprehensive Tautomeric Transformation Rules</h2>
<p>The key contributions are:</p>
<ol>
<li>
<p><strong>Comprehensive Rule Set</strong>: Compilation of <strong>86 tautomeric transformation rules</strong> (20 pre-existing CACTVS defaults plus 66 new rules derived from experimental literature), categorized into:</p>
<ul>
<li>54 Prototropic rules (classic H-movement tautomerism)</li>
<li>21 Ring-Chain rules (cyclic/open-chain transformations)</li>
<li>11 Valence rules (structural rearrangements with valence changes)</li>
</ul>
</li>
<li>
<p><strong>Massive-Scale Validation</strong>: Testing these rules against <strong>nine major chemical databases</strong> totaling over 400 million structures to identify coverage gaps in current InChI implementations</p>
</li>
<li>
<p><strong>Quantitative Assessment</strong>: Systematic measurement showing that current InChI (even with Nonstandard 15T + KET settings) only achieves ~50% success in recognizing tautomeric relationships, with some new rules showing &lt;2% success rates</p>
</li>
<li>
<p><strong>Practical Tools</strong>: Creation of the <strong>Tautomerizer</strong> web tool for public use, demonstrating practical application of the rule set</p>
</li>
</ol>
<p>The novelty lies in the systematic compilation and validation of transformation rules at a scale that reveals critical gaps in current chemical identification systems.</p>
<h2 id="massive-scale-validation-across-400m-structures">Massive-Scale Validation Across 400M+ Structures</h2>
<h3 id="database-analysis">Database Analysis</h3>
<p>The researchers analyzed <strong>9 chemical databases</strong> totaling 400+ million structures:</p>
<ul>
<li><strong>Public databases</strong>: PubChem (largest), ChEMBL, DrugBank, PDB Ligands, SureChEMBL, AMS, ChemNavigator</li>
<li><strong>Private databases</strong>: CSD (Cambridge Structural Database), CSDB (NCI internal)</li>
</ul>
<h3 id="methodology">Methodology</h3>
<p><strong>Software</strong>: CACTVS Chemoinformatics Toolkit (versions 3.4.6.33 and 3.4.8.6)</p>
<p><strong>Tautomer Generation Protocol</strong>:</p>
<ul>
<li><strong>Algorithm</strong>: Single-step generation (apply transforms to input structure only, avoiding recursion)</li>
<li><strong>Constraints</strong>: Max 10 tautomers per structure, 30-second CPU timeout per transform</li>
<li><strong>Format</strong>: All rules expressed as SMIRKS strings</li>
<li><strong>Stereochemistry</strong>: Stereocenters involved in tautomerism were flattened during transformation</li>
</ul>
<p><strong>Success Metrics</strong> (tested against InChI V.1.05):</p>
<ul>
<li><strong>Complete InChI match</strong>: All tautomers share identical InChI</li>
<li><strong>Partial InChI match</strong>: At least two tautomers share an InChI</li>
<li>Tested against two InChI configurations: Standard InChI and Nonstandard InChI (with 15T and KET options enabled)</li>
</ul>
<h3 id="rule-coverage-analysis">Rule Coverage Analysis</h3>
<p>For each of the 86 rules, the researchers:</p>
<ol>
<li>Applied the transformation to all molecules in each database</li>
<li>Generated tautomers using the SMIRKS patterns</li>
<li>Computed InChI identifiers for each tautomer</li>
<li>Measured success rates (percentage of cases where InChI recognized the relationship)</li>
</ol>
<h3 id="key-findings-from-experiments">Key Findings from Experiments</h3>
<p><strong>Rule Frequency</strong>: The most common rule <code>PT_06_00</code> (1,3-heteroatom H-shift, covering keto-enol tautomerism) affects <strong>&gt;70% of molecules</strong> across databases.</p>
<p><strong>InChI Performance</strong>:</p>
<ul>
<li>Standard InChI: ~37% success rate</li>
<li>Nonstandard InChI (15T + KET): ~50% success rate</li>
<li>Many newly defined rules: &lt;2% success rate</li>
</ul>
<p><strong>Scale Impact</strong>: Implementing the full 86-rule set would approximately <strong>triple</strong> the number of compounds recognized as having tautomeric relationships relative to Standard InChI.</p>
<h2 id="outcomes-inchi-v2-requirements-and-coverage-gaps">Outcomes: InChI V2 Requirements and Coverage Gaps</h2>
<h3 id="main-findings">Main Findings</h3>
<ol>
<li>
<p><strong>Current Systems Are Inadequate</strong>: Even with the Nonstandard 15T + KET settings, InChI only achieves ~50% success in recognizing tautomeric relationships, with Standard InChI at ~37%</p>
</li>
<li>
<p><strong>Massive Coverage Gap</strong>: The new rule set reveals millions of tautomeric relationships that current InChI completely misses, particularly for ring-chain and valence tautomerism</p>
</li>
<li>
<p><strong>Implementation Requirement</strong>: InChI V2 will require a major redesign to handle the comprehensive rule set</p>
</li>
<li>
<p><strong>Rule Validation</strong>: The 86-rule set provides a validated foundation for next-generation chemical identifiers, with the new rules further confirmed against an independent ChEMBL 24.1 tautomer extraction</p>
</li>
</ol>
<h3 id="implications">Implications</h3>
<p><strong>For Chemical Databases</strong>:</p>
<ul>
<li>Reduced redundancy through proper tautomer recognition</li>
<li>Improved data quality and consistency</li>
<li>More comprehensive structure search results</li>
</ul>
<p><strong>For Machine Learning</strong>:</p>
<ul>
<li>More accurate training data (tautomers properly grouped)</li>
<li>Better molecular property prediction models</li>
<li>Reduced dataset bias from tautomeric duplicates</li>
</ul>
<p><strong>For Chemoinformatics Tools</strong>:</p>
<ul>
<li>Blueprint for InChI V2 development</li>
<li>Standardized rule set for tautomer generation</li>
<li>Public tool (Tautomerizer) for practical use</li>
</ul>
<h3 id="limitations-acknowledged">Limitations Acknowledged</h3>
<ul>
<li>Single-step generation only (omits recursive enumeration of all possible tautomers)</li>
<li>30-second timeout may miss complex transformations</li>
<li>Some tautomeric preferences are context-dependent (pH, solvent) and require more than static rules for capture</li>
</ul>
<h3 id="additional-validation">Additional Validation</h3>
<p>The authors validated their rule set against 4,158 tautomeric systems independently extracted from ChEMBL 24.1 via a SMILES-based tautomer hash (provided by Noel O&rsquo;Boyle and Roger Sayle). Their rules covered essentially all tautomeric systems in that set, with practically all cases handled by the standard CACTVS rules PT_02_00 through PT_21_00.</p>
<h3 id="companion-resource-tautomer-database">Companion Resource: Tautomer Database</h3>
<p>A companion paper describes the creation of a publicly available Tautomer Database (Tauto DB) containing over 2,800 tautomeric tuples extracted from experimental literature, available at <a href="https://cactus.nci.nih.gov/download/tautomer/">https://cactus.nci.nih.gov/download/tautomer/</a>. Data from this database informed the generation of new rules in this work.</p>
<h3 id="future-directions">Future Directions</h3>
<p>The paper lays groundwork for InChI V2 development, emphasizing that the comprehensive rule set necessitates algorithmic redesign.</p>
<h2 id="reproducibility-details">Reproducibility Details</h2>
<h3 id="data">Data</h3>
<p><strong>Datasets Analyzed</strong> (400M+ total structures):</p>
<p><strong>Public Databases</strong> (Enable partial reproduction):</p>
<ul>
<li><strong>PubChem</strong>: Largest public chemical database</li>
<li><strong>ChEMBL</strong>: Bioactive molecules with drug-like properties</li>
<li><strong>DrugBank</strong>: FDA-approved and experimental drugs</li>
<li><strong>PDB Ligands</strong>: Small molecules from protein structures</li>
<li><strong>SureChEMBL</strong>: Chemical structures from patents</li>
<li><strong>AMS</strong>: Screening samples</li>
<li><strong>ChemNavigator</strong>: Commercial chemical database</li>
</ul>
<p><strong>Private/Proprietary Databases</strong> (Prevent 100% full-scale reproduction):</p>
<ul>
<li><strong>CSD</strong>: Cambridge Structural Database (requires commercial/academic license)</li>
<li><strong>CSDB</strong>: NCI internal database (private)</li>
</ul>
<h3 id="algorithms">Algorithms</h3>
<p><strong>Tautomer Generation</strong>:</p>
<ul>
<li><strong>Method</strong>: Single-step SMIRKS-based transformations</li>
<li><strong>Constraints</strong>:
<ul>
<li>Maximum 10 tautomers per input structure</li>
<li>30-second CPU timeout per transformation</li>
<li>Stereochemistry flattening for affected centers</li>
</ul>
</li>
<li><strong>Toolkit Dependency</strong>: The authors used the CACTVS Chemoinformatics Toolkit. Researchers attempting to reproduce this with fully open-source tools (like RDKit) may encounter differing behavior due to proprietary chemical perception logic and licensing differences.</li>
</ul>
<p><strong>Rule Categories</strong>:</p>
<ul>
<li><strong>Prototropic (PT)</strong>: 54 rules for hydrogen movement
<ul>
<li>Most common: <code>PT_06_00</code> (1,3-heteroatom H-shift, &gt;70% coverage)</li>
</ul>
</li>
<li><strong>Ring-Chain (RC)</strong>: 21 rules for cyclic/open-chain transformations
<ul>
<li>Examples: <code>RC_03_00</code> (pentose sugars), <code>RC_04_01</code> (hexose sugars)</li>
</ul>
</li>
<li><strong>Valence (VT)</strong>: 11 rules for valence changes
<ul>
<li>Notable: <code>VT_02_00</code> (tetrazole/azide, ~2.8M hits)</li>
</ul>
</li>
</ul>
<p><strong>InChI Comparison</strong>:</p>
<ul>
<li>Standard InChI (default settings)</li>
<li>Nonstandard InChI with <code>15T</code> and <code>KET</code> options (mobile H and keto-enol)</li>
</ul>
<h3 id="evaluation">Evaluation</h3>
<p><strong>Success Metrics</strong>:</p>
<p>Let $\mathcal{T}(m)$ be the set of generated tautomers for molecule $m$.</p>
<ul>
<li><strong>Complete Match</strong>: Occurs iff $\forall t_i, t_j \in \mathcal{T}(m), \text{InChI}(t_i) = \text{InChI}(t_j)$.</li>
<li><strong>Partial Match</strong>: At least 2 tautomers share the same InChI.</li>
<li><strong>Fail</strong>: All tautomers have different InChIs.</li>
</ul>
<p><strong>Benchmark Results</strong>:</p>
<ul>
<li>Standard InChI: ~37% success rate across all rules</li>
<li>Nonstandard (15T + KET): ~50% success rate</li>
<li>New rules: Many show &lt;2% recognition by current InChI</li>
</ul>
<h3 id="hardware">Hardware</h3>
<p><strong>Software Environment</strong>:</p>
<ul>
<li><strong>Toolkit</strong>: CACTVS Chemoinformatics Toolkit v3.4.6.33 and v3.4.8.6</li>
<li><strong>Hash Functions</strong>:
<ul>
<li><code>E_TAUTO_HASH</code> (tautomer-invariant identifier)</li>
<li><code>E_ISOTOPE_STEREO_HASH128</code> (tautomer-sensitive identifier)</li>
</ul>
</li>
</ul>
<p><strong>Note</strong>: The paper omits computational hardware specifications but acknowledges using the NIH HPC Biowulf cluster. Evaluating 400M+ structures necessitates high-throughput cluster computing, making it computationally expensive for an individual to replicate the full analysis from scratch.</p>
<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://cactus.nci.nih.gov/tautomerizer/">Tautomerizer Web Tool</a></td>
          <td>Other</td>
          <td>Unknown</td>
          <td>Public web tool for applying tautomeric rules to user molecules</td>
      </tr>
      <tr>
          <td><a href="https://cactus.nci.nih.gov/download/tautomer/">Tautomer Database</a></td>
          <td>Dataset</td>
          <td>Unknown</td>
          <td>2800+ experimental tautomeric tuples (companion resource)</td>
      </tr>
      <tr>
          <td><a href="https://pubs.acs.org/doi/10.1021/acs.jcim.9b01080">SMIRKS and Scripts (SI)</a></td>
          <td>Code</td>
          <td>Unknown</td>
          <td>CACTVS Tcl scripts and SMIRKS provided as Supporting Information</td>
      </tr>
  </tbody>
</table>
<h2 id="paper-information">Paper Information</h2>
<p><strong>Citation</strong>: Dhaked, D. K., Ihlenfeldt, W.-D., Patel, H., Delannée, V., &amp; Nicklaus, M. C. (2020). Toward a Comprehensive Treatment of Tautomerism in Chemoinformatics Including in InChI V2. <em>Journal of Chemical Information and Modeling</em>, <em>60</em>(3), 1253-1275. <a href="https://doi.org/10.1021/acs.jcim.9b01080">https://doi.org/10.1021/acs.jcim.9b01080</a></p>
<p><strong>Publication</strong>: Journal of Chemical Information and Modeling, 2020</p>
<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">@article</span>{dhaked2020toward,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">title</span>=<span style="color:#e6db74">{Toward a Comprehensive Treatment of Tautomerism in Chemoinformatics Including in InChI V2}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">author</span>=<span style="color:#e6db74">{Dhaked, Devendra K and Ihlenfeldt, Wolf-Dietrich and Patel, Hitesh and Delann{\&#39;e}e, Victorien and Nicklaus, Marc C}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">journal</span>=<span style="color:#e6db74">{Journal of Chemical Information and Modeling}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">volume</span>=<span style="color:#e6db74">{60}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">number</span>=<span style="color:#e6db74">{3}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">pages</span>=<span style="color:#e6db74">{1253--1275}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">year</span>=<span style="color:#e6db74">{2020}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">publisher</span>=<span style="color:#e6db74">{ACS Publications}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">doi</span>=<span style="color:#e6db74">{10.1021/acs.jcim.9b01080}</span>
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div><p><strong>Additional Resources</strong>:</p>
<ul>
<li><a href="https://cactus.nci.nih.gov/tautomerizer/">Tautomerizer Tool</a> - Public web tool for testing tautomeric transformations</li>
</ul>
]]></content:encoded></item><item><title>SELFIES: A Robust Molecular String Representation</title><link>https://hunterheidenreich.com/notes/chemistry/molecular-representations/notations/selfies/</link><pubDate>Fri, 12 Sep 2025 00:00:00 +0000</pubDate><guid>https://hunterheidenreich.com/notes/chemistry/molecular-representations/notations/selfies/</guid><description>SELFIES is a robust molecular string representation for ML where every string decodes to a valid molecule, implemented in the selfies Python library.</description><content:encoded><![CDATA[<h2 id="overview">Overview</h2>
<p><strong>SELFIES (SELF-referencIng Embedded Strings)</strong> is a string-based molecular representation where every possible string, even one generated randomly, corresponds to a syntactically and semantically valid molecule. This property addresses a major limitation of <a href="/notes/chemistry/molecular-representations/notations/smiles/">SMILES</a>, where a large fraction of strings produced by machine learning models represent invalid chemical structures.</p>
<p>The format is implemented in an open-source Python library called <code>selfies</code>. Since the <a href="/notes/chemistry/molecular-representations/notations/selfies-original-paper/">original publication</a>, the library has undergone significant architectural changes, most notably replacing the original string-manipulation engine with a graph-based internal representation that improved both performance and extensibility (see <a href="#recent-developments">Recent Developments</a>).</p>
<h3 id="key-characteristics">Key Characteristics</h3>
<ul>
<li><strong>Guaranteed Validity</strong>: Every possible SELFIES string can be decoded into a valid molecular graph that obeys chemical valence rules. This is its fundamental advantage over SMILES.</li>
<li><strong>Machine Learning Friendly</strong>: Can be used directly in any machine learning model (like VAEs or GANs) without adaptation, guaranteeing that all generated outputs are valid molecules.</li>
<li><strong>Customizable Constraints</strong>: The underlying chemical rules, such as maximum valence for different atoms, can be customized by the user. The library provides presets (e.g., for hypervalent species) and allows users to define their own rule sets.</li>
<li><strong>Human-readable</strong>: With some familiarity, SELFIES strings are human-readable, allowing interpretation of functional groups and connectivity.</li>
<li><strong>Local Operations</strong>: SELFIES encodes branch length and ring size as adjacent symbols in the string (rather than requiring matched delimiters or repeated digits at distant positions, as SMILES does), preventing common syntactical errors like unmatched parentheses or mismatched ring-closure digits.</li>
<li><strong>Broad Support</strong>: The current <code>selfies</code> library supports aromatic molecules (via kekulization), isotopes, charges, radicals, and stereochemistry. It also includes a dot symbol (<code>.</code>) for representing disconnected molecular fragments.</li>
</ul>
<h2 id="basic-syntax">Basic Syntax</h2>
<p>SELFIES uses symbols enclosed in square brackets (e.g., <code>[C]</code>, <code>[O]</code>, <code>[#N]</code>). The interpretation of each symbol depends on the current <strong>state of the derivation</strong> (described below), which ensures chemical valence rules are strictly obeyed. The syntax is formally defined by a Chomsky type-2 context-free grammar.</p>
<h3 id="derivation-rules">Derivation Rules</h3>
<p>SELFIES are constructed using a table of derivation rules. The process starts in an initial state (e.g., $X_0$) and reads the SELFIES string symbol by symbol. Each symbol, combined with the current state, determines the resulting atom/bond and the next state. The derivation state $X_n$ intuitively tracks that the previously added atom can form a maximum of $n$ additional bonds.</p>
<p>For example, the string <code>[F][=C][=C][#N]</code> is derived as follows, where $X_n$ indicates the atom can form up to $n$ additional bonds. Notice how bond demotion occurs: the first <code>[=C]</code> requests a double bond, but only a single bond is formed because state $X_1$ limits the connection to one bond.</p>
<p>$$
\begin{aligned}
\text{State } X_0 + \text{[F]} &amp;\rightarrow \text{F} + \text{State } X_1 \\
\text{State } X_1 + \text{[=C]} &amp;\rightarrow \text{F-C} + \text{State } X_3 \\
\text{State } X_3 + \text{[=C]} &amp;\rightarrow \text{F-C=C} + \text{State } X_2 \\
\text{State } X_2 + [\#\text{N}] &amp;\rightarrow \text{F-C=C=N} + \text{Final}
\end{aligned}
$$</p>
<h3 id="structural-features">Structural Features</h3>
<ul>
<li><strong>Branches</strong>: Represented by a <code>[Branch]</code> symbol. The symbols immediately following it are interpreted as an index that specifies the number of SELFIES symbols belonging to that branch. This structure prevents errors like unmatched parentheses in SMILES.</li>
<li><strong>Rings</strong>: Represented by a <code>[Ring]</code> symbol. Similar to branches, subsequent symbols specify an index that indicates which previous atom to connect to, forming a ring closure. To avoid violating valence constraints, ring bond creation is postponed to a final post-processing step, where it is only completed if the target atom has available bonds.</li>
</ul>
<h2 id="examples">Examples</h2>
<p>To see how these derivation rules work in practice, here are SELFIES representations for common molecules of increasing complexity:</p>















<figure class="post-figure center ">
    <img src="/img/selfies/ethanol.webp"
         alt="Ethanol molecule from SELFIES"
         title="Ethanol molecule from SELFIES"
         
         
         loading="lazy"
         class="post-image">
    
    <figcaption class="post-caption">Ethanol: <code>[C][C][O]</code></figcaption>
    
</figure>
















<figure class="post-figure center ">
    <img src="/img/selfies/benzene.webp"
         alt="Benzene molecule from SELFIES"
         title="Benzene molecule from SELFIES"
         
         
         loading="lazy"
         class="post-image">
    
    <figcaption class="post-caption">Benzene: <code>[C][=C][C][=C][C][=C][Ring1][=Branch1]</code></figcaption>
    
</figure>
















<figure class="post-figure center ">
    <img src="/img/selfies/aspirin.webp"
         alt="Aspirin molecule from SELFIES"
         title="Aspirin molecule from SELFIES"
         
         
         loading="lazy"
         class="post-image">
    
    <figcaption class="post-caption">Aspirin: <code>[C][C][Branch1][C][=O][O][C][=C][C][=C][C][=C][Ring1][=Branch1][C][Branch1][C][=O][O]</code></figcaption>
    
</figure>

<h2 id="the-selfies-python-library">The <code>selfies</code> Python Library</h2>
<p>The <code>selfies</code> library provides a dependency-free Python implementation. Here are the core operations:</p>
<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-python" data-lang="python"><span style="display:flex;"><span><span style="color:#f92672">import</span> selfies <span style="color:#66d9ef">as</span> sf
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># SMILES -&gt; SELFIES</span>
</span></span><span style="display:flex;"><span>smiles <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;c1ccc(C(=O)O)cc1&#34;</span>  <span style="color:#75715e"># benzoic acid</span>
</span></span><span style="display:flex;"><span>encoded <span style="color:#f92672">=</span> sf<span style="color:#f92672">.</span>encoder(smiles)
</span></span><span style="display:flex;"><span>print(encoded)
</span></span><span style="display:flex;"><span><span style="color:#75715e"># -&gt; [C][=C][C][=C][C][Branch1][C][=O][O][=C][Ring1][=Branch1]</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># SELFIES -&gt; SMILES</span>
</span></span><span style="display:flex;"><span>decoded <span style="color:#f92672">=</span> sf<span style="color:#f92672">.</span>decoder(encoded)
</span></span><span style="display:flex;"><span>print(decoded)
</span></span><span style="display:flex;"><span><span style="color:#75715e"># -&gt; C1=CC=CC(=C1)C(=O)O</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># Robustness: random strings always decode to valid molecules</span>
</span></span><span style="display:flex;"><span>random_selfies <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;[C][F][Ring1][O][=N][Branch1][C][S]&#34;</span>
</span></span><span style="display:flex;"><span>print(sf<span style="color:#f92672">.</span>decoder(random_selfies))
</span></span><span style="display:flex;"><span><span style="color:#75715e"># -&gt; always returns a valid molecule</span>
</span></span></code></pre></div><h3 id="tokenization-and-encoding">Tokenization and Encoding</h3>
<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-python" data-lang="python"><span style="display:flex;"><span><span style="color:#f92672">import</span> selfies <span style="color:#66d9ef">as</span> sf
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>selfies_str <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;[C][=C][C][=C][C][Branch1][C][=O][O][=C][Ring1][=Branch1]&#34;</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># Tokenize into individual symbols</span>
</span></span><span style="display:flex;"><span>tokens <span style="color:#f92672">=</span> list(sf<span style="color:#f92672">.</span>split_selfies(selfies_str))
</span></span><span style="display:flex;"><span>print(tokens)
</span></span><span style="display:flex;"><span><span style="color:#75715e"># -&gt; [&#39;[C]&#39;, &#39;[=C]&#39;, &#39;[C]&#39;, &#39;[=C]&#39;, &#39;[C]&#39;, &#39;[Branch1]&#39;, &#39;[C]&#39;,</span>
</span></span><span style="display:flex;"><span><span style="color:#75715e">#     &#39;[=O]&#39;, &#39;[O]&#39;, &#39;[=C]&#39;, &#39;[Ring1]&#39;, &#39;[=Branch1]&#39;]</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># Get the alphabet (unique token set) from a dataset</span>
</span></span><span style="display:flex;"><span>dataset <span style="color:#f92672">=</span> [<span style="color:#e6db74">&#34;[C][C][O]&#34;</span>, <span style="color:#e6db74">&#34;[C][=C][C][=C][C][=C][Ring1][=Branch1]&#34;</span>]
</span></span><span style="display:flex;"><span>alphabet <span style="color:#f92672">=</span> sf<span style="color:#f92672">.</span>get_alphabet_from_selfies(dataset)
</span></span><span style="display:flex;"><span>print(sorted(alphabet))
</span></span><span style="display:flex;"><span><span style="color:#75715e"># -&gt; [&#39;[=Branch1]&#39;, &#39;[=C]&#39;, &#39;[C]&#39;, &#39;[O]&#39;, &#39;[Ring1]&#39;]</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># Convert to integer encoding for ML pipelines</span>
</span></span><span style="display:flex;"><span>encoding, _ <span style="color:#f92672">=</span> sf<span style="color:#f92672">.</span>selfies_to_encoding(
</span></span><span style="display:flex;"><span>    selfies<span style="color:#f92672">=</span>selfies_str,
</span></span><span style="display:flex;"><span>    vocab_stoi<span style="color:#f92672">=</span>{s: i <span style="color:#66d9ef">for</span> i, s <span style="color:#f92672">in</span> enumerate(sorted(alphabet))},
</span></span><span style="display:flex;"><span>    pad_to_len<span style="color:#f92672">=</span><span style="color:#ae81ff">20</span>,
</span></span><span style="display:flex;"><span>    enc_type<span style="color:#f92672">=</span><span style="color:#e6db74">&#34;label&#34;</span>,
</span></span><span style="display:flex;"><span>)
</span></span></code></pre></div><h3 id="customizing-valence-constraints">Customizing Valence Constraints</h3>
<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-python" data-lang="python"><span style="display:flex;"><span><span style="color:#f92672">import</span> selfies <span style="color:#66d9ef">as</span> sf
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># View current constraints</span>
</span></span><span style="display:flex;"><span>print(sf<span style="color:#f92672">.</span>get_semantic_constraints())
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># Allow hypervalent sulfur (e.g., SF6)</span>
</span></span><span style="display:flex;"><span>sf<span style="color:#f92672">.</span>set_semantic_constraints(<span style="color:#e6db74">&#34;hypervalent&#34;</span>)
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># Or define custom constraints</span>
</span></span><span style="display:flex;"><span>sf<span style="color:#f92672">.</span>set_semantic_constraints({
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;S&#34;</span>: <span style="color:#ae81ff">6</span>,  <span style="color:#75715e"># allow hexavalent sulfur</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;P&#34;</span>: <span style="color:#ae81ff">5</span>,  <span style="color:#75715e"># allow pentavalent phosphorus</span>
</span></span><span style="display:flex;"><span>})
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># Reset to defaults</span>
</span></span><span style="display:flex;"><span>sf<span style="color:#f92672">.</span>set_semantic_constraints(<span style="color:#e6db74">&#34;default&#34;</span>)
</span></span></code></pre></div><h2 id="selfies-in-machine-learning">SELFIES in Machine Learning</h2>
<h3 id="molecular-generation">Molecular Generation</h3>
<p>SELFIES is particularly advantageous for generative models in computational chemistry. When used in a VAE, the entire continuous latent space decodes to valid molecules, unlike SMILES where large regions of the latent space are invalid. The <a href="/notes/chemistry/molecular-representations/notations/selfies-original-paper/">original SELFIES paper</a> demonstrated this concretely: a VAE trained with SELFIES stored two orders of magnitude more diverse molecules than a SMILES-based VAE, and a GAN produced 78.9% diverse valid molecules compared to 18.6% for SMILES (Krenn et al., 2020).</p>
<p>Several generation approaches build directly on SELFIES:</p>
<ul>
<li><strong>Latent space optimization</strong>: <a href="/notes/chemistry/molecular-design/generation/latent-space/limo-latent-inceptionism/">LIMO</a> uses a SELFIES-based VAE with gradient-based optimization to generate molecules with nanomolar binding affinities, achieving 6-8x speedup over RL baselines (Eckmann et al., 2022).</li>
<li><strong>Training-free generation</strong>: <a href="/notes/chemistry/molecular-design/generation/search-based/stoned-selfies-chemical-space-exploration/">STONED</a> demonstrates that simple character-level mutations in SELFIES (replacement, deletion, insertion) produce valid molecules by construction, eliminating the need for neural networks entirely. STONED achieved a GuacaMol score of 14.70, competitive with deep generative models (Nigam et al., 2021).</li>
<li><strong>Gradient-based dreaming</strong>: <a href="/notes/chemistry/molecular-design/generation/latent-space/deep-molecular-dreaming-pasithea/">PASITHEA</a> computes gradients with respect to one-hot encoded SELFIES inputs to steer molecules toward target property values. Because SELFIES&rsquo; surjective mapping guarantees every intermediate representation is a valid molecule, this continuous optimization over the input space is feasible. PASITHEA generated molecules with properties outside the training data range (logP up to 4.24 vs. a training max of 3.08), with 97.2% novelty (Shen et al., 2021).</li>
<li><strong>Large-scale pre-training</strong>: <a href="/notes/chemistry/molecular-design/generation/autoregressive/molgen-molecular-generation-chemical-feedback/">MolGen</a> is a BART-based model pre-trained on 100M+ SELFIES molecules. It achieves 100% validity and an FCD of 0.0015 on MOSES (vs. 0.0061 for Chemformer), and introduces chemical feedback to align outputs with preference rankings (Fang et al., 2024).</li>
</ul>
<p>In benchmarks, SELFIES performs well for optimization-oriented tasks. In the <a href="/notes/chemistry/molecular-design/generation/evaluation/pmo-sample-efficient-molecular-optimization/">PMO benchmark</a> of 25 methods, SELFIES-REINVENT ranked 3rd and STONED ranked 5th. SELFIES-based genetic algorithms outperformed SMILES-based GAs, likely because SELFIES provides more intuitive mutation operations (Gao et al., 2022). The <a href="/notes/chemistry/molecular-design/generation/evaluation/tartarus-inverse-molecular-design/">Tartarus benchmark</a> corroborates this across more diverse real-world objectives (organic emitters, protein ligands, reaction substrates): SELFIES-VAE consistently outperforms SMILES-VAE, and the representation matters most where validity is a bottleneck (Nigam et al., 2022).</p>
<p>SELFIES mutations provide a simple but effective way to explore chemical space:</p>
<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-python" data-lang="python"><span style="display:flex;"><span><span style="color:#f92672">import</span> selfies <span style="color:#66d9ef">as</span> sf
</span></span><span style="display:flex;"><span><span style="color:#f92672">import</span> random
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">def</span> <span style="color:#a6e22e">mutate_selfies</span>(selfies_str, mutation_type<span style="color:#f92672">=</span><span style="color:#e6db74">&#34;replace&#34;</span>):
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;&#34;&#34;Mutate a SELFIES string. Every output is a valid molecule.&#34;&#34;&#34;</span>
</span></span><span style="display:flex;"><span>    tokens <span style="color:#f92672">=</span> list(sf<span style="color:#f92672">.</span>split_selfies(selfies_str))
</span></span><span style="display:flex;"><span>    alphabet <span style="color:#f92672">=</span> list(sf<span style="color:#f92672">.</span>get_semantic_robust_alphabet())
</span></span><span style="display:flex;"><span>    idx <span style="color:#f92672">=</span> random<span style="color:#f92672">.</span>randint(<span style="color:#ae81ff">0</span>, len(tokens) <span style="color:#f92672">-</span> <span style="color:#ae81ff">1</span>)
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">if</span> mutation_type <span style="color:#f92672">==</span> <span style="color:#e6db74">&#34;replace&#34;</span>:
</span></span><span style="display:flex;"><span>        tokens[idx] <span style="color:#f92672">=</span> random<span style="color:#f92672">.</span>choice(alphabet)
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">elif</span> mutation_type <span style="color:#f92672">==</span> <span style="color:#e6db74">&#34;insert&#34;</span>:
</span></span><span style="display:flex;"><span>        tokens<span style="color:#f92672">.</span>insert(idx, random<span style="color:#f92672">.</span>choice(alphabet))
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">elif</span> mutation_type <span style="color:#f92672">==</span> <span style="color:#e6db74">&#34;delete&#34;</span> <span style="color:#f92672">and</span> len(tokens) <span style="color:#f92672">&gt;</span> <span style="color:#ae81ff">1</span>:
</span></span><span style="display:flex;"><span>        tokens<span style="color:#f92672">.</span>pop(idx)
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">return</span> <span style="color:#e6db74">&#34;&#34;</span><span style="color:#f92672">.</span>join(tokens)
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># Every mutation produces a valid molecule</span>
</span></span><span style="display:flex;"><span>original <span style="color:#f92672">=</span> sf<span style="color:#f92672">.</span>encoder(<span style="color:#e6db74">&#34;c1ccccc1&#34;</span>)  <span style="color:#75715e"># benzene</span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">for</span> _ <span style="color:#f92672">in</span> range(<span style="color:#ae81ff">5</span>):
</span></span><span style="display:flex;"><span>    mutant <span style="color:#f92672">=</span> mutate_selfies(original)
</span></span><span style="display:flex;"><span>    print(sf<span style="color:#f92672">.</span>decoder(mutant))  <span style="color:#75715e"># always valid</span>
</span></span></code></pre></div><h3 id="property-prediction-and-pretraining">Property Prediction and Pretraining</h3>
<p><a href="/notes/chemistry/molecular-representations/encoders/selformer/">SELFormer</a> is a RoBERTa-based chemical language model pretrained on 2M ChEMBL compounds using SELFIES as input. Because every masked token prediction corresponds to a valid molecular fragment, the model never wastes capacity learning invalid chemistry. SELFormer outperformed <a href="/notes/chemistry/molecular-representations/encoders/chemberta-2/">ChemBERTa-2</a> by approximately 12% on average across BACE, BBBP, and HIV classification benchmarks (Yüksel et al., 2023). <a href="/notes/chemistry/molecular-representations/encoders/chemberta/">ChemBERTa</a> also evaluated SELFIES as an input representation, finding comparable performance to SMILES on the Tox21 task (Chithrananda et al., 2020).</p>
<p>The <a href="/notes/chemistry/molecular-design/property-prediction/regression-transformer/">Regression Transformer</a> demonstrated that SELFIES achieves ~100% validity vs. ~40% for SMILES in conditional molecular generation, while performing comparably for property prediction. This dual prediction-generation capability is enabled by interleaving numerical property tokens with SELFIES molecular tokens in a single sequence (Born &amp; Manica, 2023).</p>
<p>At larger scales, <a href="/notes/chemistry/molecular-representations/encoders/neural-scaling-of-deep-chemical-models/">ChemGPT</a> (up to 1B parameters) uses a GPT-Neo backbone with SELFIES tokenization for autoregressive molecular generation, demonstrating that SELFIES follows the same power-law neural scaling behavior observed in NLP (Frey et al., 2023).</p>
<h3 id="optical-chemical-structure-recognition">Optical Chemical Structure Recognition</h3>
<p>In image-to-text chemical structure recognition, <a href="/notes/chemistry/optical-structure-recognition/benchmarks/rajan-string-representations-2022/">Rajan et al. (2022)</a> compared SMILES, DeepSMILES, SELFIES, and InChI as output formats using the same transformer architecture. SELFIES achieved 100% structural validity (every prediction could be decoded), while SMILES predictions occasionally contained syntax errors. The trade-off: SMILES achieved higher exact match accuracy (88.62%) partly because SELFIES strings are longer, producing more tokens for the decoder to predict.</p>
<h3 id="chemical-name-translation">Chemical Name Translation</h3>
<p><a href="/notes/chemistry/molecular-representations/name-translation/stout/">STOUT</a> uses SELFIES as its internal representation for translating between chemical line notations and IUPAC names. All SMILES are converted to SELFIES before processing, and the model achieves a BLEU score of 0.94 for IUPAC-to-SELFIES translation and 0.98 Tanimoto similarity on valid outputs. The authors found SELFIES&rsquo; syntactic robustness particularly valuable for this sequence-to-sequence task, where the decoder must produce a chemically valid output string (Rajan et al., 2021).</p>
<h3 id="tokenization">Tokenization</h3>
<p>Converting SELFIES strings into tokens for neural models is more straightforward than SMILES tokenization. Each bracket-enclosed symbol (<code>[C]</code>, <code>[=C]</code>, <code>[Branch1]</code>) is a natural token boundary. <a href="/notes/chemistry/molecular-representations/notations/smiles-selfies-tokenization-chemical-lm/">Atom Pair Encoding (APE)</a> extends byte pair encoding with chemistry-aware constraints for both SMILES and SELFIES. For SELFIES specifically, APE preserves atomic identity during subword merging, and SELFIES models showed strong inter-tokenizer agreement: all true positives from SELFIES-BPE were captured by SELFIES-APE (Leon et al., 2024).</p>
<h2 id="limitations-and-trade-offs">Limitations and Trade-offs</h2>
<h3 id="validity-constraints-can-introduce-bias">Validity Constraints Can Introduce Bias</h3>
<p>The guarantee that every string decodes to a valid molecule is SELFIES&rsquo; core advantage, but recent work has shown this comes with trade-offs. <a href="/notes/chemistry/molecular-representations/notations/invalid-smiles-help/">Skinnider (2024)</a> demonstrated that SMILES-based models consistently outperform SELFIES-based models on distribution-learning tasks. The mechanism: invalid SMILES represent a model&rsquo;s least confident predictions, and filtering them out acts as implicit quality control. SELFIES models, by construction, cannot discard low-confidence outputs this way. Furthermore, SELFIES validity constraints introduce systematic structural biases, generating fewer aromatic rings and more aliphatic structures compared to training data. When SELFIES constraints were relaxed to allow invalid generation (&ldquo;unconstrained SELFIES&rdquo;), performance improved, providing causal evidence that the ability to generate and discard invalid outputs benefits distribution learning.</p>
<p>This finding reframes the SMILES vs. SELFIES choice as context-dependent. As Grisoni (2023) summarizes in a <a href="/notes/chemistry/molecular-design/generation/evaluation/clms-de-novo-drug-design-review/">review of chemical language models</a>: &ldquo;SMILES offer a richer, more interpretable language with well-studied augmentation strategies, while SELFIES guarantee validity at the cost of chemical realism and edit interpretability.&rdquo;</p>
<p>The <a href="/notes/chemistry/molecular-design/generation/evaluation/pmo-sample-efficient-molecular-optimization/">PMO benchmark</a> provides further nuance: SELFIES-based variants of language model methods (REINVENT, LSTM HC, VAE) generally do not outperform their SMILES counterparts, because modern language models learn SMILES grammar well enough that syntactic invalidity is no longer a practical bottleneck. The exception is genetic algorithms, where SELFIES mutations are naturally well-suited.</p>
<p>A study on <a href="/notes/chemistry/molecular-design/property-prediction/lm-complex-molecular-distributions/">complex molecular distributions</a> paints a consistent picture: SELFIES-trained RNNs achieve better standard metrics (validity, uniqueness, novelty), while SMILES-trained RNNs achieve better distributional fidelity as measured by Wasserstein distance (Flam-Shepherd et al., 2022). Taken together, these findings suggest that SELFIES and SMILES have genuinely complementary strengths, and the best choice depends on whether the task prioritizes validity/novelty or distributional faithfulness.</p>
<h3 id="degenerate-outputs">Degenerate Outputs</h3>
<p>Although every SELFIES string decodes to a valid molecule, the decoded molecule may not always be chemically meaningful in context. The <a href="/notes/chemistry/molecular-design/property-prediction/regression-transformer/">Regression Transformer</a> reported ~1.9% defective generations where the output molecule had fewer than 50% of the seed molecule&rsquo;s atoms (Born &amp; Manica, 2023). This highlights a distinction between syntactic validity (which SELFIES guarantees) and semantic appropriateness (which it does not).</p>
<h3 id="other-limitations">Other Limitations</h3>
<ul>
<li><strong>Indirect Canonicalization</strong>: A canonical SELFIES string is currently generated by first creating a canonical SMILES string and then converting it to SELFIES. Direct canonicalization is a goal for future development.</li>
<li><strong>String Length</strong>: SELFIES strings are generally longer than their corresponding SMILES strings, which can impact storage, processing times, and sequence modeling difficulty for very large datasets.</li>
<li><strong>Ongoing Standardization</strong>: While the library now supports most major features found in SMILES, work is ongoing to extend the format to more complex systems like polymers, crystals, and reactions.</li>
</ul>
<h2 id="variants-and-extensions">Variants and Extensions</h2>
<h3 id="group-selfies">Group SELFIES</h3>
<p><a href="/notes/chemistry/molecular-representations/notations/group-selfies-fragment-molecular-representation/">Group SELFIES</a> extends the representation with group tokens that represent functional groups or entire substructures (e.g., a benzene ring or carboxyl group) as single units. Each group token has labeled attachment points with specified valency, allowing the decoder to continue tracking available bonds. Group SELFIES maintains the validity guarantee while producing shorter, more human-readable strings. On MOSES VAE benchmarks, Group SELFIES achieved an FCD of 0.1787 versus 0.6351 for standard SELFIES, indicating substantially better distribution learning (Cheng et al., 2023).</p>
<h3 id="stoned-algorithms">STONED Algorithms</h3>
<p><a href="/notes/chemistry/molecular-design/generation/search-based/stoned-selfies-chemical-space-exploration/">STONED</a> (Superfast Traversal, Optimization, Novelty, Exploration and Discovery) is a suite of algorithms that exploit SELFIES&rsquo; validity guarantee for training-free molecular design through point mutations, interpolation, and optimization (Nigam et al., 2021). See <a href="#molecular-generation">Molecular Generation</a> above for benchmark results.</p>
<h2 id="recent-developments">Recent Developments</h2>
<p>The <a href="/notes/chemistry/molecular-representations/notations/selfies-2023/">2023 library update</a> replaced the original string-manipulation engine with a graph-based internal representation. This change resolved several long-standing limitations: the original approach could not handle aromatics (requiring kekulization), stereochemistry, or charged species. The graph-based engine now supports all of these, and processes 300K+ molecules in approximately 4 minutes in pure Python. The library has been validated on all 72 million molecules from PubChem.</p>
<p>Looking forward, researchers have outlined <a href="/notes/chemistry/molecular-representations/notations/selfies-2022/">16 future research directions</a> for extending robust representations to complex systems like polymers, crystals, and chemical reactions.</p>
<h2 id="further-reading">Further Reading</h2>
<ul>
<li><a href="/posts/visualizing-smiles-and-selfies-strings/"><strong>Converting SELFIES Strings to 2D Molecular Images</strong></a>: Hands-on tutorial demonstrating SELFIES robustness and building visualization tools</li>
</ul>
<h2 id="references">References</h2>
<ul>
<li>Krenn, M., Häse, F., Nigam, A., Friederich, P., &amp; Aspuru-Guzik, A. (2020). Self-referencing embedded strings (SELFIES): A 100% robust molecular string representation. <a href="https://doi.org/10.1088/2632-2153/aba947"><em>Machine Learning: Science and Technology</em>, <em>1</em>(4), 045024.</a></li>
<li>Krenn, M., Ai, Q., Barthel, S., Carson, N., Frei, A., Frey, N. C., &hellip; &amp; Aspuru-Guzik, A. (2022). SELFIES and the future of molecular string representations. <a href="https://doi.org/10.1016/j.patter.2022.100588"><em>Patterns</em>, <em>3</em>(10), 100588.</a></li>
<li>Lo, A., Pollice, R., Nigam, A., White, A. D., Krenn, M., &amp; Aspuru-Guzik, A. (2023). Recent advances in the self-referencing embedded strings (SELFIES) library. <a href="https://doi.org/10.1039/d3dd00044c"><em>Digital Discovery</em>, <em>2</em>, 897-908.</a></li>
<li>Skinnider, M. A. (2024). Invalid SMILES are beneficial rather than detrimental to chemical language models. <a href="https://doi.org/10.1038/s42256-024-00821-x"><em>Nature Machine Intelligence</em>, <em>6</em>, 437-448.</a></li>
<li>Shen, C., Krenn, M., Eppel, S., &amp; Aspuru-Guzik, A. (2021). Deep molecular dreaming: inverse machine learning for de-novo molecular design and interpretability with surjective representations. <a href="https://doi.org/10.1088/2632-2153/ac09d6"><em>Machine Learning: Science and Technology</em>, <em>2</em>(3), 03LT02.</a></li>
<li>Fang, Y., et al. (2024). Domain-agnostic molecular generation with chemical feedback. <a href="https://openreview.net/forum?id=9rnerQyXlh"><em>ICLR 2024</em>.</a></li>
<li>Born, J., &amp; Manica, M. (2023). Regression Transformer enables concurrent sequence regression and generation for molecular language modelling. <a href="https://doi.org/10.1038/s42256-023-00639-z"><em>Nature Machine Intelligence</em>, <em>5</em>, 432-444.</a></li>
<li>Frey, N. C., Soklaski, R., Axelrod, S., Samsi, S., Gómez-Bombarelli, R., Coley, C. W., &amp; Gadepally, V. (2023). Neural scaling of deep chemical models. <a href="https://doi.org/10.1038/s42256-023-00740-3"><em>Nature Machine Intelligence</em>, <em>5</em>, 1297-1305.</a></li>
<li>Rajan, K., Zielesny, A., &amp; Steinbeck, C. (2021). STOUT: SMILES to IUPAC names using neural machine translation. <a href="https://doi.org/10.1186/s13321-021-00512-4"><em>Journal of Cheminformatics</em>, <em>13</em>, 34.</a></li>
<li>Nigam, A., Pollice, R., &amp; Aspuru-Guzik, A. (2022). Tartarus: A benchmarking platform for realistic and practical inverse molecular design. <a href="https://openreview.net/forum?id=sLFDE2MHzHO"><em>NeurIPS 2022 Datasets and Benchmarks</em>.</a></li>
<li><a href="https://github.com/aspuru-guzik-group/selfies">SELFIES GitHub Repository</a></li>
</ul>
]]></content:encoded></item><item><title>The Number of Isomeric Hydrocarbons of the Methane Series</title><link>https://hunterheidenreich.com/notes/chemistry/molecular-representations/notations/number-of-isomeric-hydrocarbons/</link><pubDate>Mon, 08 Sep 2025 00:00:00 +0000</pubDate><guid>https://hunterheidenreich.com/notes/chemistry/molecular-representations/notations/number-of-isomeric-hydrocarbons/</guid><description>Henze and Blair's 1931 JACS paper deriving exact recursive formulas for counting constitutional alkane isomers.</description><content:encoded><![CDATA[<h2 id="a-theoretical-foundation-for-mathematical-chemistry">A Theoretical Foundation for Mathematical Chemistry</h2>
<p>This is a foundational <strong>theoretical paper</strong> in mathematical chemistry and chemical graph theory. It derives <strong>exact mathematical laws</strong> governing molecular topology. The paper also serves as a <strong>benchmark resource</strong>, establishing the first systematic isomer counts that corrected historical errors and whose recursive method remains the basis for modern molecular enumeration.</p>
<h2 id="historical-motivation-and-the-failure-of-centric-trees">Historical Motivation and the Failure of Centric Trees</h2>
<p>The primary motivation was the lack of a rigorous mathematical relationship between carbon content ($N$) and isomer count.</p>
<ul>
<li><strong>Previous failures</strong>: Earlier attempts by <a href="https://doi.org/10.1002/cber.187500801227">Cayley (1875)</a> (as cited by Henze and Blair, referring to the Berichte der deutschen chemischen Gesellschaft summary) and <a href="https://doi.org/10.1002/cber.187500802191">Schiff (1875)</a> used &ldquo;centric&rdquo; and &ldquo;bicentric&rdquo; symmetry tree methods that broke down as carbon content increased, producing incorrect counts as early as $N = 12$. Subsequent efforts by Tiemann (1893), Delannoy (1894), Losanitsch (1897), Goldberg (1898), and Trautz (1924), as cited in the paper, each improved on specific aspects but none achieved general accuracy beyond moderate carbon content.</li>
<li><strong>The theoretical gap</strong>: All prior formulas depended on exhaustively identifying centers of symmetry, meaning they required additional correction terms for each increase in $N$ and could not reliably predict counts for larger molecules like $C_{40}$.</li>
</ul>
<p>This work aimed to develop a theoretically sound, generalizable method that could be extended to any number of carbons.</p>
<h2 id="core-innovation-recursive-enumeration-of-graphs">Core Innovation: Recursive Enumeration of Graphs</h2>
<p>The core novelty is the proof that the count of hydrocarbons is a recursive function of the count of alkyl radicals (alcohols) of size $N/2$ or smaller. The authors rely on a preliminary calculation of the total number of isomeric alcohols (the methanol series) to make this hydrocarbon enumeration possible. By defining $T_k$ as the exact number of possible isomeric alkyl radicals strictly containing $k$ carbon atoms, graph enumeration transforms into a mathematical recurrence.</p>
<p>To rigorously prevent double-counting when functionally identical branches connect to a central carbon, Henze and Blair applied combinations with substitution. Because the chemical branches are unordered topologically, connecting $x$ branches of identical structural size $k$ results in combinations with repetition:</p>
<p>$$ \binom{T_k + x - 1}{x} $$</p>
<p>For example, if a Group B central carbon is bonded to three identical sub-branches of length $k$, the combinatoric volume for that precise topological partition resolves to:</p>
<p>$$ \frac{T_k (T_k + 1)(T_k + 2)}{6} $$</p>
<p>Summing these constrained combinatorial partitions across all valid branch sizes (governed by the Even/Odd bisection rules) yields the exact isomer count for $N$ without overestimating due to symmetric permutations.</p>
<p><strong>The Symmetry Constraints</strong>: The paper rigorously divides the problem space to prevent double-counting:</p>
<ul>
<li><strong>Group A (Centrosymmetric)</strong>: Hydrocarbons that can be bisected into two smaller alkyl radicals.
<ul>
<li><em>Even $N$</em>: Split into two radicals of size $N/2$.</li>
<li><em>Odd $N$</em>: Split into sizes $(N+1)/2$ and $(N-1)/2$.</li>
</ul>
</li>
<li><strong>Group B (Asymmetric)</strong>: Hydrocarbons whose graphic formula cannot be symmetrically bisected. They contain exactly one central carbon atom attached to 3 or 4 branches. To prevent double-counting, Henze and Blair established strict maximum branch sizes:
<ul>
<li><em>Even $N$</em>: No branch can be larger than $(N/2 - 1)$ carbons.</li>
<li><em>Odd $N$</em>: No branch can be larger than $(N-3)/2$ carbons.</li>
<li><em>The Combinatorial Partitioning</em>: They further subdivided these 3-branch and 4-branch molecules into distinct mathematical cases based on whether the branches were structurally identical or unique, applying distinct combinatorial formulas to each scenario.</li>
</ul>
</li>
</ul>















<figure class="post-figure center ">
    <img src="/img/notes/hexane-and-its-six-isomers-by-even-and-odd-decomposition.webp"
         alt="The five structural isomers of hexane classified into Group A and Group B based on their decomposition"
         title="The five structural isomers of hexane classified into Group A and Group B based on their decomposition"
         
         
         loading="lazy"
         class="post-image">
    
    <figcaption class="post-caption">The five isomers of hexane ($C_6$) classified by Henze and Blair&rsquo;s symmetry scheme. Group A molecules (top row) can be bisected along a bond (highlighted in red) into two $C_3$ alkyl radicals. Group B molecules (bottom row) have a central carbon atom (red circle) with 3-4 branches, preventing symmetric bisection.</figcaption>
    
</figure>

<p>This classification is the key insight that enables the recursive formulas. By exhaustively partitioning hydrocarbons into these mutually exclusive groups, the authors could derive separate combinatorial expressions for each and sum them without double-counting.</p>
<p>For each structural class, combinatorial formulas are derived that depend on the number of isomeric alcohols ($T_k$) where $k &lt; N$. This transforms the problem of counting large molecular graphs into a recurrence relation based on the counts of smaller, simpler sub-graphs.</p>
<h2 id="validation-via-exhaustive-hand-enumeration">Validation via Exhaustive Hand-Enumeration</h2>
<p>The experiments were computational and enumerative:</p>
<ol>
<li><strong>Derivation of the recursion formulas</strong>: The main effort was the mathematical derivation of the set of equations for each structural class of hydrocarbon.</li>
<li><strong>Calculation</strong>: They applied their formulas to calculate the number of isomers for alkanes up to $N=40$, reaching over $6.2 \times 10^{13}$ isomers. This was far beyond what was previously possible.</li>
<li><strong>Validation by exhaustive enumeration</strong>: To prove the correctness of their theory, the authors manually drew and counted all possible structural formulas for the undecanes ($C_{11}$), dodecanes ($C_{12}$), tridecanes ($C_{13}$), and tetradecanes ($C_{14}$). This brute-force check confirmed their calculated numbers and corrected long-standing errors in the literature.
<ul>
<li><em>Key correction</em>: The manual enumeration proved that the count for tetradecane ($C_{14}$) is <strong>1,858</strong>, correcting erroneous values previously published by <a href="https://doi.org/10.1002/cber.189703002144" title="Die Isomerie-Arten bei den Homologen der Paraffin-Reihe">Losanitsch (1897)</a>, whose results for $C_{12}$ and $C_{14}$ the paper identifies as incorrect.</li>
</ul>
</li>
</ol>
<h2 id="benchmark-outcomes-and-scaling-limits">Benchmark Outcomes and Scaling Limits</h2>
<ul>
<li><strong>The Constitutional Limit</strong>: The paper establishes the mathematical ground truth for organic molecular graphs by strictly counting <em>constitutional</em> (structural) isomers. The derivation completely excludes 3D stereoisomerism (enantiomers and diastereomers). For modern geometric deep learning applications (e.g., generating 3D conformers), Henze and Blair&rsquo;s scaling sequence serves as a lower bound, representing a severe underestimation of the true number of spatial configurations feasible within chemical space.</li>
<li><strong>Theoretical outcome</strong>: The paper proves that the problem&rsquo;s inherent complexity requires a recursive approach.</li>
<li><strong>Benchmark resource</strong>: The authors published a table of isomer counts up to $C_{40}$ (Table II), correcting historical errors and establishing the first systematic enumeration across this range. Later computational verification revealed that the paper&rsquo;s hand-calculated values are exact through at least $C_{14}$ (confirmed by exhaustive enumeration) but accumulate minor arithmetic errors beyond that range (e.g., at $C_{40}$). The recursive method itself is exact and remains the basis for the accepted values in <a href="https://oeis.org/A000602">OEIS A000602</a>.</li>
</ul>















<figure class="post-figure center ">
    <img src="/img/notes/number-of-isomeric-hydrocarbons-of-the-methane-series.webp"
         alt="Log-scale plot showing exponential growth of alkane isomer counts from C1 to C40"
         title="Log-scale plot showing exponential growth of alkane isomer counts from C1 to C40"
         
         
         loading="lazy"
         class="post-image">
    
    <figcaption class="post-caption">The number of structural isomers grows super-exponentially with carbon content, reaching over 62 trillion for C₄₀. This plot, derived from Henze and Blair&rsquo;s Table II, illustrates the combinatorial explosion that makes direct enumeration intractable for larger molecules.</figcaption>
    
</figure>

<p>The plot above illustrates the staggering growth rate. Methane ($C_1$) through propane ($C_3$) each have exactly one isomer. Beyond this, the count accelerates rapidly: 75 isomers at $C_{10}$, nearly 37 million at $C_{25}$, and over 4 billion at $C_{30}$. By $C_{40}$, the count exceeds $6.2 \times 10^{13}$ (the paper&rsquo;s hand-calculated Table II reports 62,491,178,805,831, while the modern OEIS-verified value is 62,481,801,147,341). This super-exponential scaling demonstrates why brute-force enumeration becomes impossible and why the recursive approach was essential.</p>
<ul>
<li><strong>Foundational impact</strong>: This work established the mathematical framework that would later evolve into modern chemical graph theory and computational chemistry approaches for molecular enumeration. In the context of AI for molecular generation, this is an early form of <strong>expressivity analysis</strong>, defining the size of the chemical space that generative models must learn to cover.</li>
</ul>
<h2 id="reproducibility-details">Reproducibility Details</h2>
<ul>
<li>
<p><strong>Algorithms</strong>: The exact mathematical recursive formulas and combinatorial partitioning logic are fully provided in the text, allowing for programmatic implementation.</p>
</li>
<li>
<p><strong>Evaluation</strong>: The authors scientifically validated their recursive formulas through exhaustive manual hand-enumeration (brute-force drawing of structural formulas) up to $C_{14}$ to establish absolute correctness.</p>
</li>
<li>
<p><strong>Data</strong>: The paper&rsquo;s Table II provides isomer counts up to $C_{40}$. These hand-calculated values are exact through at least $C_{14}$ (validated by exhaustive enumeration) but accumulate minor arithmetic errors beyond that range. The corrected integer sequence is maintained in the On-Line Encyclopedia of Integer Sequences (OEIS) as <a href="https://oeis.org/A000602">A000602</a>.</p>
</li>
<li>
<p><strong>Code</strong>: The OEIS page provides Mathematica and Maple implementations. The following pure Python implementation uses the OEIS generating functions (which formalize Henze and Blair&rsquo;s recursive method) to compute the corrected isomer counts up to any arbitrary $N$:</p>
<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-python" data-lang="python"><span style="display:flex;"><span><span style="color:#66d9ef">def</span> <span style="color:#a6e22e">compute_alkane_isomers</span>(max_n: int) <span style="color:#f92672">-&gt;</span> list[int]:
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;&#34;&#34;
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">    Computes the number of alkane structural isomers C_nH_{2n+2}
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">    up to max_n using the generating functions from OEIS A000602.
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">    &#34;&#34;&#34;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">if</span> max_n <span style="color:#f92672">==</span> <span style="color:#ae81ff">0</span>: <span style="color:#66d9ef">return</span> [<span style="color:#ae81ff">1</span>]
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    <span style="color:#75715e"># Helper: multiply two polynomials (cap at degree max_n)</span>
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">def</span> <span style="color:#a6e22e">poly_mul</span>(a: list[int], b: list[int]) <span style="color:#f92672">-&gt;</span> list[int]:
</span></span><span style="display:flex;"><span>        res <span style="color:#f92672">=</span> [<span style="color:#ae81ff">0</span>] <span style="color:#f92672">*</span> (max_n <span style="color:#f92672">+</span> <span style="color:#ae81ff">1</span>)
</span></span><span style="display:flex;"><span>        <span style="color:#66d9ef">for</span> i, v_a <span style="color:#f92672">in</span> enumerate(a):
</span></span><span style="display:flex;"><span>            <span style="color:#66d9ef">for</span> j, v_b <span style="color:#f92672">in</span> enumerate(b):
</span></span><span style="display:flex;"><span>                <span style="color:#66d9ef">if</span> i <span style="color:#f92672">+</span> j <span style="color:#f92672">&lt;=</span> max_n: res[i <span style="color:#f92672">+</span> j] <span style="color:#f92672">+=</span> v_a <span style="color:#f92672">*</span> v_b
</span></span><span style="display:flex;"><span>                <span style="color:#66d9ef">else</span>: <span style="color:#66d9ef">break</span>
</span></span><span style="display:flex;"><span>        <span style="color:#66d9ef">return</span> res
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    <span style="color:#75715e"># Helper: evaluate P(x^k) by spacing out terms</span>
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">def</span> <span style="color:#a6e22e">poly_pow</span>(a: list[int], k: int) <span style="color:#f92672">-&gt;</span> list[int]:
</span></span><span style="display:flex;"><span>        res <span style="color:#f92672">=</span> [<span style="color:#ae81ff">0</span>] <span style="color:#f92672">*</span> (max_n <span style="color:#f92672">+</span> <span style="color:#ae81ff">1</span>)
</span></span><span style="display:flex;"><span>        <span style="color:#66d9ef">for</span> i, v <span style="color:#f92672">in</span> enumerate(a):
</span></span><span style="display:flex;"><span>            <span style="color:#66d9ef">if</span> i <span style="color:#f92672">*</span> k <span style="color:#f92672">&lt;=</span> max_n: res[i <span style="color:#f92672">*</span> k] <span style="color:#f92672">=</span> v
</span></span><span style="display:flex;"><span>            <span style="color:#66d9ef">else</span>: <span style="color:#66d9ef">break</span>
</span></span><span style="display:flex;"><span>        <span style="color:#66d9ef">return</span> res
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    <span style="color:#75715e"># T represents the alkyl radicals (OEIS A000598), T[0] = 1</span>
</span></span><span style="display:flex;"><span>    T <span style="color:#f92672">=</span> [<span style="color:#ae81ff">0</span>] <span style="color:#f92672">*</span> (max_n <span style="color:#f92672">+</span> <span style="color:#ae81ff">1</span>)
</span></span><span style="display:flex;"><span>    T[<span style="color:#ae81ff">0</span>] <span style="color:#f92672">=</span> <span style="color:#ae81ff">1</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    <span style="color:#75715e"># Iteratively build coefficients of T</span>
</span></span><span style="display:flex;"><span>    <span style="color:#75715e"># We only need to compute the (n-1)-th degree terms at step n</span>
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">for</span> n <span style="color:#f92672">in</span> range(<span style="color:#ae81ff">1</span>, max_n <span style="color:#f92672">+</span> <span style="color:#ae81ff">1</span>):
</span></span><span style="display:flex;"><span>        <span style="color:#75715e"># Extract previously calculated slices</span>
</span></span><span style="display:flex;"><span>        t_prev <span style="color:#f92672">=</span> T[:n]
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>        <span style="color:#75715e"># T(x^2) and T(x^3) terms up to n-1</span>
</span></span><span style="display:flex;"><span>        t2_term <span style="color:#f92672">=</span> T[(n <span style="color:#f92672">-</span> <span style="color:#ae81ff">1</span>) <span style="color:#f92672">//</span> <span style="color:#ae81ff">2</span>] <span style="color:#66d9ef">if</span> (n <span style="color:#f92672">-</span> <span style="color:#ae81ff">1</span>) <span style="color:#f92672">%</span> <span style="color:#ae81ff">2</span> <span style="color:#f92672">==</span> <span style="color:#ae81ff">0</span> <span style="color:#66d9ef">else</span> <span style="color:#ae81ff">0</span>
</span></span><span style="display:flex;"><span>        t3_term <span style="color:#f92672">=</span> T[(n <span style="color:#f92672">-</span> <span style="color:#ae81ff">1</span>) <span style="color:#f92672">//</span> <span style="color:#ae81ff">3</span>] <span style="color:#66d9ef">if</span> (n <span style="color:#f92672">-</span> <span style="color:#ae81ff">1</span>) <span style="color:#f92672">%</span> <span style="color:#ae81ff">3</span> <span style="color:#f92672">==</span> <span style="color:#ae81ff">0</span> <span style="color:#66d9ef">else</span> <span style="color:#ae81ff">0</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>        <span style="color:#75715e"># T(x)^2 and T(x)^3 terms up to n-1</span>
</span></span><span style="display:flex;"><span>        t_squared_n_1 <span style="color:#f92672">=</span> sum(t_prev[i] <span style="color:#f92672">*</span> t_prev[n <span style="color:#f92672">-</span> <span style="color:#ae81ff">1</span> <span style="color:#f92672">-</span> i] <span style="color:#66d9ef">for</span> i <span style="color:#f92672">in</span> range(n))
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>        t_cubed_n_1 <span style="color:#f92672">=</span> sum(
</span></span><span style="display:flex;"><span>            T[i] <span style="color:#f92672">*</span> T[j] <span style="color:#f92672">*</span> T[n <span style="color:#f92672">-</span> <span style="color:#ae81ff">1</span> <span style="color:#f92672">-</span> i <span style="color:#f92672">-</span> j]
</span></span><span style="display:flex;"><span>            <span style="color:#66d9ef">for</span> i <span style="color:#f92672">in</span> range(n)
</span></span><span style="display:flex;"><span>            <span style="color:#66d9ef">for</span> j <span style="color:#f92672">in</span> range(n <span style="color:#f92672">-</span> i)
</span></span><span style="display:flex;"><span>        )
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>        <span style="color:#75715e"># T(x) * T(x^2) term up to n-1</span>
</span></span><span style="display:flex;"><span>        t_t2_n_1 <span style="color:#f92672">=</span> sum(
</span></span><span style="display:flex;"><span>            T[i] <span style="color:#f92672">*</span> T[j]
</span></span><span style="display:flex;"><span>            <span style="color:#66d9ef">for</span> i <span style="color:#f92672">in</span> range(n)
</span></span><span style="display:flex;"><span>            <span style="color:#66d9ef">for</span> j <span style="color:#f92672">in</span> range((n <span style="color:#f92672">-</span> <span style="color:#ae81ff">1</span> <span style="color:#f92672">-</span> i) <span style="color:#f92672">//</span> <span style="color:#ae81ff">2</span> <span style="color:#f92672">+</span> <span style="color:#ae81ff">1</span>)
</span></span><span style="display:flex;"><span>            <span style="color:#66d9ef">if</span> i <span style="color:#f92672">+</span> <span style="color:#ae81ff">2</span><span style="color:#f92672">*</span>j <span style="color:#f92672">==</span> n <span style="color:#f92672">-</span> <span style="color:#ae81ff">1</span>
</span></span><span style="display:flex;"><span>        )
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>        T[n] <span style="color:#f92672">=</span> (t_cubed_n_1 <span style="color:#f92672">+</span> <span style="color:#ae81ff">3</span> <span style="color:#f92672">*</span> t_t2_n_1 <span style="color:#f92672">+</span> <span style="color:#ae81ff">2</span> <span style="color:#f92672">*</span> t3_term) <span style="color:#f92672">//</span> <span style="color:#ae81ff">6</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    <span style="color:#75715e"># Calculate Alkanes (OEIS A000602) from fully populated T</span>
</span></span><span style="display:flex;"><span>    T2 <span style="color:#f92672">=</span> poly_pow(T, <span style="color:#ae81ff">2</span>)
</span></span><span style="display:flex;"><span>    T3 <span style="color:#f92672">=</span> poly_pow(T, <span style="color:#ae81ff">3</span>)
</span></span><span style="display:flex;"><span>    T4 <span style="color:#f92672">=</span> poly_pow(T, <span style="color:#ae81ff">4</span>)
</span></span><span style="display:flex;"><span>    T_squared <span style="color:#f92672">=</span> poly_mul(T, T)
</span></span><span style="display:flex;"><span>    T_cubed <span style="color:#f92672">=</span> poly_mul(T_squared, T)
</span></span><span style="display:flex;"><span>    T_fourth <span style="color:#f92672">=</span> poly_mul(T_cubed, T)
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    term2 <span style="color:#f92672">=</span> [(T_squared[i] <span style="color:#f92672">-</span> T2[i]) <span style="color:#f92672">//</span> <span style="color:#ae81ff">2</span> <span style="color:#66d9ef">for</span> i <span style="color:#f92672">in</span> range(max_n <span style="color:#f92672">+</span> <span style="color:#ae81ff">1</span>)]
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    term3_inner <span style="color:#f92672">=</span> [
</span></span><span style="display:flex;"><span>        T_fourth[i]
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">+</span> <span style="color:#ae81ff">6</span> <span style="color:#f92672">*</span> poly_mul(T_squared, T2)[i]
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">+</span> <span style="color:#ae81ff">8</span> <span style="color:#f92672">*</span> poly_mul(T, T3)[i]
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">+</span> <span style="color:#ae81ff">3</span> <span style="color:#f92672">*</span> poly_mul(T2, T2)[i]
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">+</span> <span style="color:#ae81ff">6</span> <span style="color:#f92672">*</span> T4[i]
</span></span><span style="display:flex;"><span>        <span style="color:#66d9ef">for</span> i <span style="color:#f92672">in</span> range(max_n <span style="color:#f92672">+</span> <span style="color:#ae81ff">1</span>)
</span></span><span style="display:flex;"><span>    ]
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    alkanes <span style="color:#f92672">=</span> [<span style="color:#ae81ff">1</span>] <span style="color:#f92672">+</span> [<span style="color:#ae81ff">0</span>] <span style="color:#f92672">*</span> max_n
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">for</span> n <span style="color:#f92672">in</span> range(<span style="color:#ae81ff">1</span>, max_n <span style="color:#f92672">+</span> <span style="color:#ae81ff">1</span>):
</span></span><span style="display:flex;"><span>        alkanes[n] <span style="color:#f92672">=</span> T[n] <span style="color:#f92672">-</span> term2[n] <span style="color:#f92672">+</span> term3_inner[n <span style="color:#f92672">-</span> <span style="color:#ae81ff">1</span>] <span style="color:#f92672">//</span> <span style="color:#ae81ff">24</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">return</span> alkanes
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># Calculate and verify</span>
</span></span><span style="display:flex;"><span>isomers <span style="color:#f92672">=</span> compute_alkane_isomers(<span style="color:#ae81ff">40</span>)
</span></span><span style="display:flex;"><span>print(<span style="color:#e6db74">f</span><span style="color:#e6db74">&#34;C_14 isomers: </span><span style="color:#e6db74">{</span>isomers[<span style="color:#ae81ff">14</span>]<span style="color:#e6db74">}</span><span style="color:#e6db74">&#34;</span>)   <span style="color:#75715e"># Output: 1858</span>
</span></span><span style="display:flex;"><span>print(<span style="color:#e6db74">f</span><span style="color:#e6db74">&#34;C_40 isomers: </span><span style="color:#e6db74">{</span>isomers[<span style="color:#ae81ff">40</span>]<span style="color:#e6db74">}</span><span style="color:#e6db74">&#34;</span>)   <span style="color:#75715e"># Output: 62481801147341</span>
</span></span></code></pre></div></li>
<li>
<p><strong>Hardware</strong>: Derived analytically and enumerated manually by the authors in 1931 without computational hardware.</p>
</li>
</ul>
<h2 id="paper-information">Paper Information</h2>
<p><strong>Citation</strong>: Henze, H. R., &amp; Blair, C. M. (1931). The number of isomeric hydrocarbons of the methane series. <em>Journal of the American Chemical Society</em>, 53(8), 3077-3085. <a href="https://doi.org/10.1021/ja01359a034">https://doi.org/10.1021/ja01359a034</a></p>
<p><strong>Publication</strong>: Journal of the American Chemical Society (JACS) 1931</p>
<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">@article</span>{henze1931number,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">title</span>=<span style="color:#e6db74">{The number of isomeric hydrocarbons of the methane series}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">author</span>=<span style="color:#e6db74">{Henze, Henry R and Blair, Charles M}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">journal</span>=<span style="color:#e6db74">{Journal of the American Chemical Society}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">volume</span>=<span style="color:#e6db74">{53}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">number</span>=<span style="color:#e6db74">{8}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">pages</span>=<span style="color:#e6db74">{3077--3085}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">year</span>=<span style="color:#e6db74">{1931}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">publisher</span>=<span style="color:#e6db74">{ACS Publications}</span>
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div>]]></content:encoded></item><item><title>SMILES: A Compact Notation for Chemical Structures</title><link>https://hunterheidenreich.com/notes/chemistry/molecular-representations/notations/smiles/</link><pubDate>Mon, 08 Sep 2025 00:00:00 +0000</pubDate><guid>https://hunterheidenreich.com/notes/chemistry/molecular-representations/notations/smiles/</guid><description>SMILES (Simplified Molecular Input Line Entry System) represents chemical structures using compact ASCII strings.</description><content:encoded><![CDATA[<h2 id="overview">Overview</h2>
<p>SMILES (Simplified Molecular Input Line Entry System), originally developed by David Weininger in the late 1980s, is a one-dimensional string format for representing chemical molecular structures. It linearizes 3D molecular structures by performing a depth-first traversal of the molecular graph, recording the atoms and bonds along the way.</p>
<p>For example, the simple molecule ethanol ($\text{C}_2\text{H}_6\text{O}$) can be represented as <code>CCO</code>, while the more complex caffeine molecule becomes <code>CN1C=NC2=C1C(=O)N(C(=O)N2C)C</code>.</p>
<h3 id="key-characteristics">Key Characteristics</h3>
<ul>
<li><strong>Human-readable</strong>: Designed primarily for human readability. Compare with <a href="/notes/chemistry/molecular-representations/notations/inchi/">InChI</a>, a hierarchical representation optimized for machine parsing.</li>
<li><strong>Compact</strong>: More compact than other representations (3D coordinates, connectivity tables)</li>
<li><strong>Simple syntax</strong>: A language with simple syntax and structure, making it relatively easy to learn and use for chemists and researchers</li>
<li><strong>Flexible</strong>: Both linear and cyclic structures can be represented in many different valid ways</li>
</ul>
<p>For a hands-on tutorial on visualizing SMILES strings as 2D molecular images, see <a href="/posts/visualizing-smiles-and-selfies-strings/">Converting SMILES Strings to 2D Molecular Images</a>.</p>
<h2 id="basic-syntax">Basic Syntax</h2>
<h3 id="atomic-symbols">Atomic Symbols</h3>
<p>SMILES uses standard atomic symbols with implied hydrogen atoms:</p>
<ul>
<li><code>C</code> (methane, $\text{CH}_4$)</li>
<li><code>N</code> (ammonia, $\text{NH}_3$)</li>
<li><code>O</code> (water, $\text{H}_2\text{O}$)</li>
<li><code>P</code> (phosphine, $\text{PH}_3$)</li>
<li><code>S</code> (hydrogen sulfide, $\text{H}_2\text{S}$)</li>
<li><code>Cl</code> (hydrogen chloride, $\text{HCl}$)</li>
</ul>
<p><strong>Bracket notation</strong>: Elements outside the organic subset must be shown in brackets, e.g., <code>[Pt]</code> for elemental platinum. The organic subset (<code>B</code>, <code>C</code>, <code>N</code>, <code>O</code>, <code>P</code>, <code>S</code>, <code>F</code>, <code>Cl</code>, <code>Br</code>, and <code>I</code>) can omit brackets.</p>
<h3 id="bond-representation">Bond Representation</h3>
<p>Bonds are represented by symbols:</p>
<ul>
<li><strong>Single bond</strong>: <code>-</code> (usually omitted)</li>
</ul>















<figure class="post-figure center ">
    <img src="/img/smiles2img/ethane.webp"
         alt="Ethane"
         title="Ethane"
         
         
         loading="lazy"
         class="post-image">
    
    <figcaption class="post-caption">Ethane ($\text{C}_2\text{H}_6$), SMILES: <code>CC</code></figcaption>
    
</figure>

<ul>
<li><strong>Double bond</strong>: <code>=</code></li>
</ul>















<figure class="post-figure center ">
    <img src="/img/smiles2img/methyl_isocyanate.webp"
         alt="Methyl Isocyanate"
         title="Methyl Isocyanate"
         
         
         loading="lazy"
         class="post-image">
    
    <figcaption class="post-caption">Methyl Isocyanate ($\text{C}_2\text{H}_3\text{NO}$), SMILES: <code>CN=C=O</code></figcaption>
    
</figure>

<ul>
<li><strong>Triple bond</strong>: <code>#</code></li>
</ul>















<figure class="post-figure center ">
    <img src="/img/smiles2img/hydrogen_cyanide.webp"
         alt="Hydrogen Cyanide"
         title="Hydrogen Cyanide"
         
         
         loading="lazy"
         class="post-image">
    
    <figcaption class="post-caption">Hydrogen Cyanide (HCN), SMILES: <code>C#N</code></figcaption>
    
</figure>

<ul>
<li><strong>Aromatic bond</strong>: <code>:</code> (usually omitted when lowercase atom symbols indicate aromaticity)</li>
</ul>















<figure class="post-figure center ">
    <img src="/img/smiles2img/vanillin.webp"
         alt="Vanillin"
         title="Vanillin"
         
         
         loading="lazy"
         class="post-image">
    
    <figcaption class="post-caption">Vanillin ($\text{C}_8\text{H}_8\text{O}_3$), SMILES: <code>O=Cc1ccc(O)c(OC)c1</code></figcaption>
    
</figure>

<ul>
<li><strong>Disconnected structures</strong>: <code>.</code> (separates disconnected components such as salts and ionic compounds)</li>
</ul>















<figure class="post-figure center ">
    <img src="/img/smiles2img/copper_II_sulfate.webp"
         alt="Copper(II) Sulfate"
         title="Copper(II) Sulfate"
         
         
         loading="lazy"
         class="post-image">
    
    <figcaption class="post-caption">Copper(II) Sulfate ($\text{CuSO}_4$), SMILES: <code>[Cu+2].[O-]S(=O)(=O)[O-]</code></figcaption>
    
</figure>

<h3 id="structural-features">Structural Features</h3>
<ul>
<li><strong>Branches</strong>: Enclosed in parentheses and can be nested. For example, <code>CC(C)C(=O)O</code> represents isobutyric acid, where <code>(C)</code> and <code>(=O)</code> are branches off the main chain.</li>
</ul>















<figure class="post-figure center ">
    <img src="/img/smiles2img/3-propyl-4-isopropyl-1-heptene.webp"
         alt="3-Propyl-4-isopropyl-1-heptene"
         title="3-Propyl-4-isopropyl-1-heptene"
         
         
         loading="lazy"
         class="post-image">
    
    <figcaption class="post-caption">3-Propyl-4-isopropyl-1-heptene ($\text{C}\<em>{12}\text{H}\</em>{22}$), SMILES: <code>C=CC(CCC)C(C(C)C)CCC</code></figcaption>
    
</figure>

<ul>
<li><strong>Cyclic structures</strong>: Written by breaking bonds and using numbers to indicate bond connections. For example, <code>C1CCCCC1</code> represents cyclohexane (the <code>1</code> connects the first and last carbon).</li>
<li><strong>Aromaticity</strong>: Lower case letters are used for atoms in aromatic rings. For example, benzene is written as <code>c1ccccc1</code>.</li>
<li><strong>Formal charges</strong>: Indicated by placing the charge in brackets after the atom symbol, e.g., <code>[C+]</code>, <code>[C-]</code>, or <code>[C-2]</code></li>
</ul>
<h2 id="stereochemistry-and-isomers">Stereochemistry and Isomers</h2>
<h3 id="isotope-notation">Isotope Notation</h3>
<p>Isotope notation specifies the exact isotope of an element and comes before the element within square brackets, e.g., <code>[13C]</code> for carbon-13.</p>
<h3 id="double-bond-stereochemistry">Double Bond Stereochemistry</h3>
<p>Directional bonds can be specified using <code>\</code> and <code>/</code> symbols to indicate the stereochemistry of double bonds:</p>
<ul>
<li><code>C/C=C\C</code> represents (E)-2-butene (trans configuration)</li>
<li><code>C/C=C/C</code> represents (Z)-2-butene (cis configuration)</li>
</ul>
<p>The direction of the slashes indicates which side of the double bond each substituent is on.</p>
<h3 id="tetrahedral-chirality">Tetrahedral Chirality</h3>
<p>Chirality around tetrahedral centers uses <code>@</code> and <code>@@</code> symbols:</p>
<ul>
<li><code>N[C@](C)(F)C(=O)O</code> vs <code>N[C@@](F)(C)C(=O)O</code></li>
<li>Anti-clockwise counting vs clockwise counting</li>
<li><code>@</code> and <code>@@</code> are shorthand for <code>@TH1</code> and <code>@TH2</code>, respectively</li>
</ul>















<figure class="post-figure center ">
    <img src="/img/smiles2img/glucose.webp"
         alt="Glucose"
         title="Glucose"
         
         
         loading="lazy"
         class="post-image">
    
    <figcaption class="post-caption">Glucose ($\text{C}\<em>6\text{H}\</em>{12}\text{O}\_6$), SMILES: <code>OC[C@@H](O1)[C@@H](O)[C@H](O)[C@@H](O)[C@H](O)1</code></figcaption>
    
</figure>

<h3 id="advanced-stereochemistry">Advanced Stereochemistry</h3>
<p>More general notation for other stereocenters:</p>
<ul>
<li><code>@AL1</code>, <code>@AL2</code> for allene-type stereocenters</li>
<li><code>@SP1</code>, <code>@SP2</code>, <code>@SP3</code> for square-planar stereocenters</li>
<li><code>@TB1</code>&hellip;<code>@TB20</code> for trigonal bipyramidal stereocenters</li>
<li><code>@OH1</code>&hellip;<code>@OH30</code> for octahedral stereocenters</li>
</ul>
<p>SMILES allows partial specification since it relies on local chirality.</p>
<h2 id="smiles-in-machine-learning">SMILES in Machine Learning</h2>
<p>Beyond its original role as a compact notation, SMILES has become the dominant molecular input format for deep learning in chemistry. Its adoption has revealed both strengths and challenges specific to neural architectures.</p>
<h3 id="canonical-vs-randomized-smiles">Canonical vs. Randomized SMILES</h3>
<p>Canonical SMILES algorithms produce a single unique string per molecule, which is valuable for database deduplication. In generative modeling, however, canonical representations introduce training bias: the canonicalization algorithm constrains how the molecular graph is traversed (e.g., prioritizing sidechains over ring atoms), forcing models to learn both valid SMILES syntax and the specific ordering rules. Structurally similar molecules can have substantially different canonical strings, making complex topologies harder to sample.</p>
<p><a href="/notes/chemistry/molecular-representations/notations/randomized-smiles-generative-models/">Randomized SMILES</a> address this by generating non-unique representations through random atom orderings. Training RNN-based generative models on randomized SMILES acts as data augmentation, improving chemical space coverage, sampling uniformity, and completeness compared to canonical SMILES (Arus-Pous et al., 2019). In one benchmark, randomized SMILES recovered significantly more of <a href="/notes/chemistry/datasets/gdb-13/">GDB-13</a> chemical space than canonical SMILES across all training set sizes.</p>
<p>RDKit makes it straightforward to enumerate randomized SMILES for a given molecule:</p>
<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-python" data-lang="python"><span style="display:flex;"><span><span style="color:#f92672">from</span> rdkit <span style="color:#f92672">import</span> Chem
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>mol <span style="color:#f92672">=</span> Chem<span style="color:#f92672">.</span>MolFromSmiles(<span style="color:#e6db74">&#34;c1ccc(C(=O)O)cc1&#34;</span>)  <span style="color:#75715e"># benzoic acid</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># Canonical form (deterministic)</span>
</span></span><span style="display:flex;"><span>print(Chem<span style="color:#f92672">.</span>MolToSmiles(mol))
</span></span><span style="display:flex;"><span><span style="color:#75715e"># -&gt; O=C(O)c1ccccc1</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># Randomized forms (different each call)</span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">for</span> _ <span style="color:#f92672">in</span> range(<span style="color:#ae81ff">5</span>):
</span></span><span style="display:flex;"><span>    print(Chem<span style="color:#f92672">.</span>MolToSmiles(mol, doRandom<span style="color:#f92672">=</span><span style="color:#66d9ef">True</span>))
</span></span><span style="display:flex;"><span><span style="color:#75715e"># -&gt; OC(=O)c1ccccc1</span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># -&gt; O=C(c1ccccc1)O</span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># -&gt; OC(c1ccccc1)=O</span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># -&gt; C(O)(c1ccccc1)=O</span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># -&gt; c1c(C(=O)O)cccc1</span>
</span></span></code></pre></div><p>Each of these strings encodes the same molecule but presents a different traversal of the molecular graph, giving a generative model more diverse training signal per molecule.</p>
<h3 id="validity-and-the-role-of-invalid-smiles">Validity and the Role of Invalid SMILES</h3>
<p>A large fraction of SMILES strings generated by neural models are syntactically or semantically invalid. Early efforts aimed to eliminate invalid outputs entirely, either through constrained representations like <a href="/notes/chemistry/molecular-representations/notations/selfies/">SELFIES</a> (which guarantee 100% validity) or modified syntax like <a href="/notes/chemistry/molecular-representations/notations/deepsmiles-adaptation-for-ml/">DeepSMILES</a> (which removes paired syntax; see <a href="#deepsmiles">Variants</a> below for syntax details).</p>
<p>More recent work has complicated this picture. <a href="/notes/chemistry/molecular-representations/notations/invalid-smiles-help/">Skinnider (2024)</a> demonstrated that invalid SMILES generation actually benefits chemical language models. Invalid strings tend to be low-likelihood samples from the model&rsquo;s probability distribution. Filtering them out is equivalent to removing the model&rsquo;s least confident predictions, acting as implicit quality control. Meanwhile, enforcing absolute validity (as SELFIES does) can introduce systematic structural biases that impair distribution learning. This reframes SMILES&rsquo; non-robustness as potentially advantageous in certain ML contexts.</p>
<h3 id="tokenization-challenges">Tokenization Challenges</h3>
<p>Converting SMILES strings into token sequences for neural models is non-trivial. The two baseline approaches illustrate the problem using chloramphenicol (<code>O=C(NC([C@@H](O)c1ccc([N+](=O)[O-])cc1)CO)C(Cl)Cl</code>):</p>
<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-python" data-lang="python"><span style="display:flex;"><span><span style="color:#f92672">import</span> re
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>smiles <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;O=C(NC([C@@H](O)c1ccc([N+](=O)[O-])cc1)CO)C(Cl)Cl&#34;</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># Character-level: splits every character individually</span>
</span></span><span style="display:flex;"><span>char_tokens <span style="color:#f92672">=</span> list(smiles)
</span></span><span style="display:flex;"><span><span style="color:#75715e"># [&#39;O&#39;, &#39;=&#39;, &#39;C&#39;, &#39;(&#39;, &#39;N&#39;, &#39;C&#39;, &#39;(&#39;, &#39;[&#39;, &#39;C&#39;, &#39;@&#39;, &#39;@&#39;, &#39;H&#39;, &#39;]&#39;,</span>
</span></span><span style="display:flex;"><span><span style="color:#75715e">#  &#39;(&#39;, &#39;O&#39;, &#39;)&#39;, &#39;c&#39;, &#39;1&#39;, &#39;c&#39;, &#39;c&#39;, &#39;c&#39;, &#39;(&#39;, &#39;[&#39;, &#39;N&#39;, &#39;+&#39;, &#39;]&#39;,</span>
</span></span><span style="display:flex;"><span><span style="color:#75715e">#  &#39;(&#39;, &#39;=&#39;, &#39;O&#39;, &#39;)&#39;, &#39;[&#39;, &#39;O&#39;, &#39;-&#39;, &#39;]&#39;, &#39;)&#39;, &#39;c&#39;, &#39;c&#39;, &#39;1&#39;, &#39;)&#39;,</span>
</span></span><span style="display:flex;"><span><span style="color:#75715e">#  &#39;C&#39;, &#39;O&#39;, &#39;)&#39;, &#39;C&#39;, &#39;(&#39;, &#39;C&#39;, &#39;l&#39;, &#39;)&#39;, &#39;C&#39;, &#39;l&#39;]</span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># -&gt; 49 tokens</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># Atom-level: regex groups brackets, two-char elements, and bond symbols</span>
</span></span><span style="display:flex;"><span>atom_pattern <span style="color:#f92672">=</span> (
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">r</span><span style="color:#e6db74">&#34;(\[[^\]]+\]|Br?|Cl?|N|O|S|P|F|I|&#34;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">r</span><span style="color:#e6db74">&#34;b|c|n|o|s|p|\(|\)|\.|=|#|-|\+|&#34;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">r</span><span style="color:#e6db74">&#34;</span><span style="color:#ae81ff">\\</span><span style="color:#e6db74">|\/|:|~|@|\?|&gt;&gt;?|\*|%[0-9]</span><span style="color:#e6db74">{2}</span><span style="color:#e6db74">|[0-9])&#34;</span>
</span></span><span style="display:flex;"><span>)
</span></span><span style="display:flex;"><span>atom_tokens <span style="color:#f92672">=</span> re<span style="color:#f92672">.</span>findall(atom_pattern, smiles)
</span></span><span style="display:flex;"><span><span style="color:#75715e"># [&#39;O&#39;, &#39;=&#39;, &#39;C&#39;, &#39;(&#39;, &#39;N&#39;, &#39;C&#39;, &#39;(&#39;, &#39;[C@@H]&#39;, &#39;(&#39;, &#39;O&#39;, &#39;)&#39;, &#39;c&#39;,</span>
</span></span><span style="display:flex;"><span><span style="color:#75715e">#  &#39;1&#39;, &#39;c&#39;, &#39;c&#39;, &#39;c&#39;, &#39;(&#39;, &#39;[N+]&#39;, &#39;(&#39;, &#39;=&#39;, &#39;O&#39;, &#39;)&#39;, &#39;[O-]&#39;, &#39;)&#39;,</span>
</span></span><span style="display:flex;"><span><span style="color:#75715e">#  &#39;c&#39;, &#39;c&#39;, &#39;1&#39;, &#39;)&#39;, &#39;C&#39;, &#39;O&#39;, &#39;)&#39;, &#39;C&#39;, &#39;(&#39;, &#39;Cl&#39;, &#39;)&#39;, &#39;Cl&#39;]</span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># -&gt; 36 tokens</span>
</span></span></code></pre></div><p>Character-level tokenization splits <code>Cl</code> (chlorine) into <code>C</code> + <code>l</code>, making the chlorine indistinguishable from carbon. It also fragments <code>[C@@H]</code> (a chiral carbon) into six meaningless tokens: <code>[</code>, <code>C</code>, <code>@</code>, <code>@</code>, <code>H</code>, <code>]</code>. Atom-level tokenization preserves these as single tokens but still produces long sequences (~40 tokens per molecule on average in ChEMBL).</p>
<p>Several chemistry-aware tokenizers go further:</p>
<ul>
<li><a href="/notes/chemistry/molecular-representations/notations/smiles-pair-encoding/">SMILES Pair Encoding (SPE)</a> adapts byte pair encoding to learn high-frequency SMILES substrings from large chemical datasets, compressing average sequence length from ~40 to ~6 tokens while preserving chemically meaningful substructures.</li>
<li><a href="/notes/chemistry/molecular-representations/notations/smiles-selfies-tokenization-chemical-lm/">Atom Pair Encoding (APE)</a> preserves atomic identity during subword merging, preventing chemically meaningless token splits.</li>
<li><a href="/notes/chemistry/molecular-representations/notations/atom-in-smiles-tokenization/">Atom-in-SMILES (AIS)</a> encodes each atom&rsquo;s local chemical environment into the token itself (e.g., distinguishing a carbonyl carbon from a methyl carbon), reducing token degeneration and improving translation accuracy.</li>
<li><a href="/notes/chemistry/molecular-representations/notations/smirk-tokenization-molecular-models/">Smirk</a> achieves full OpenSMILES coverage with only 165 tokens by decomposing bracketed atoms into glyphs.</li>
</ul>
<h3 id="smiles-based-foundation-models">SMILES-Based Foundation Models</h3>
<p>SMILES serves as the primary input format for molecular encoder models, including <a href="/notes/chemistry/molecular-representations/encoders/smiles-bert/">SMILES-BERT</a>, <a href="/notes/chemistry/molecular-representations/encoders/smiles-transformer/">SMILES-Transformer</a>, <a href="/notes/chemistry/molecular-representations/encoders/bartsmiles-molecular-representations/">BARTSmiles</a>, <a href="/notes/chemistry/molecular-representations/encoders/smi-ted-encoder-decoder-chemistry/">SMI-TED</a>, and <a href="/notes/chemistry/molecular-representations/encoders/molbert-molecular-representations/">MolBERT</a>. These models learn molecular representations from large SMILES corpora through pre-training objectives like masked language modeling.</p>
<p>A key open challenge is robustness to SMILES variants. The <a href="/notes/chemistry/molecular-representations/encoders/amore-smiles-robustness-framework/">AMORE framework</a> revealed that current chemical language models struggle to recognize chemically equivalent SMILES representations (such as hydrogen-explicit vs. implicit forms, or different atom orderings) as encoding the same molecule.</p>
<h3 id="molecular-generation">Molecular Generation</h3>
<p>SMILES is the dominant representation for de novo molecular generation. The typical pipeline trains a language model on SMILES corpora, then steers sampling toward molecules with desired properties. Major architecture families include:</p>
<ul>
<li><strong>Variational autoencoders</strong>: The <a href="/notes/chemistry/molecular-design/generation/latent-space/automatic-chemical-design-vae/">Automatic Chemical Design VAE</a> (Gomez-Bombarelli et al., 2018) encodes SMILES into a continuous latent space, enabling gradient-based optimization toward target properties.</li>
<li><strong>RL-tuned generators</strong>: <a href="/notes/chemistry/molecular-design/generation/rl-tuned/reinvent-deep-rl-molecular-design/">REINVENT</a> and its successors fine-tune a pre-trained SMILES language model using reinforcement learning, rewarding molecules that satisfy multi-objective scoring functions. <a href="/notes/chemistry/molecular-design/generation/rl-tuned/drugex-v2-pareto-multi-objective-rl/">DrugEx</a> extends this with Pareto-based multi-objective optimization.</li>
<li><strong>Adversarial approaches</strong>: <a href="/notes/chemistry/molecular-design/generation/rl-tuned/organ-objective-reinforced-gan/">ORGAN</a> and <a href="/notes/chemistry/molecular-design/generation/latent-space/latentgan-de-novo-molecular-generation/">LatentGAN</a> apply GAN-based training to SMILES generation, using domain-specific rewards alongside the discriminator signal.</li>
</ul>
<p>The challenges of <a href="#canonical-vs-randomized-smiles">canonical vs. randomized SMILES</a> and <a href="#validity-and-the-role-of-invalid-smiles">invalid outputs</a> discussed above are particularly relevant in this generation context.</p>
<h3 id="property-prediction">Property Prediction</h3>
<p>SMILES strings serve as the primary input for quantitative structure-activity relationship (QSAR) models. <a href="/notes/chemistry/molecular-design/property-prediction/smiles2vec-interpretable-property-prediction/">SMILES2Vec</a> learns fixed-length molecular embeddings directly from SMILES for property regression and classification. <a href="/notes/chemistry/molecular-design/property-prediction/maxsmi-smiles-augmentation-property-prediction/">MaxSMI</a> demonstrates that SMILES augmentation (training on multiple randomized SMILES per molecule) improves property prediction accuracy, connecting the <a href="#canonical-vs-randomized-smiles">data augmentation benefits</a> observed in generative settings to discriminative tasks.</p>
<h3 id="optical-chemical-structure-recognition">Optical Chemical Structure Recognition</h3>
<p>SMILES is also the standard output format for <a href="/posts/what-is-ocsr/">optical chemical structure recognition (OCSR)</a> systems, which extract molecular structures from images in scientific literature. Deep learning approaches like <a href="/notes/chemistry/optical-structure-recognition/image-to-sequence/decimer/">DECIMER</a> and <a href="/notes/chemistry/optical-structure-recognition/image-to-sequence/image2smiles/">Image2SMILES</a> frame this as an image-to-SMILES translation problem, using encoder-decoder architectures to generate SMILES strings directly from molecular diagrams. For a taxonomy of OCSR approaches, see the <a href="/notes/chemistry/optical-structure-recognition/benchmarks/ocsr-methods/">OCSR methods overview</a>.</p>
<h2 id="limitations">Limitations</h2>
<h3 id="classical-limitations">Classical Limitations</h3>
<ul>
<li><strong>Non-uniqueness</strong>: Different SMILES strings can represent the same molecule (e.g., ethanol can be written as <code>CCO</code> or <code>OCC</code>). Canonical SMILES algorithms address this by producing a single unique representation.</li>
<li><strong>Non-robustness</strong>: SMILES strings can be written that do not correspond to any valid molecular structure.
<ul>
<li>Strings that cannot represent a molecular structure.</li>
<li>Strings that violate basic rules (more bonds than is physically possible).</li>
</ul>
</li>
<li><strong>Information loss</strong>: If 3D structural information exists, a SMILES string cannot encode it.</li>
</ul>
<h3 id="machine-learning-limitations">Machine Learning Limitations</h3>
<p>The challenges described above (canonical ordering bias motivating <a href="#canonical-vs-randomized-smiles">randomized SMILES</a>, validity constraints motivating <a href="#deepsmiles">DeepSMILES</a> and <a href="/notes/chemistry/molecular-representations/notations/selfies/">SELFIES</a>, and tokenization ambiguity motivating <a href="#tokenization-challenges">chemistry-aware tokenizers</a>) remain active areas of research. See the linked sections for details on each.</p>
<h2 id="variants-and-standards">Variants and Standards</h2>
<h3 id="canonical-smiles">Canonical SMILES</h3>
<p>For how canonical vs. randomized SMILES affects generative modeling, see <a href="#canonical-vs-randomized-smiles">Canonical vs. Randomized SMILES</a> above.</p>
<p>Canonical SMILES algorithms produce a single unique string per molecule by assigning a deterministic rank to each atom and then traversing the molecular graph in that rank order. Most implementations build on the Morgan algorithm (extended connectivity): each atom starts with an initial invariant based on its properties (atomic number, degree, charge, hydrogen count), then iteratively updates its invariant by incorporating its neighbors&rsquo; invariants until the ranking stabilizes. The final atom ranks determine the traversal order, which determines the canonical string.</p>
<p>In practice, the Morgan algorithm alone does not fully resolve all ties. Implementations must also make choices about tie-breaking heuristics, aromaticity perception (Kekulé vs. aromatic form), and stereochemistry encoding. Because these choices differ across toolkits (RDKit, OpenBabel, Daylight, ChemAxon), the same molecule can produce different &ldquo;canonical&rdquo; SMILES depending on the software. A canonical SMILES is only guaranteed unique within a single implementation, not across implementations.</p>
<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-python" data-lang="python"><span style="display:flex;"><span><span style="color:#f92672">from</span> rdkit <span style="color:#f92672">import</span> Chem
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># RDKit&#39;s canonical SMILES for caffeine</span>
</span></span><span style="display:flex;"><span>mol <span style="color:#f92672">=</span> Chem<span style="color:#f92672">.</span>MolFromSmiles(<span style="color:#e6db74">&#34;CN1C=NC2=C1C(=O)N(C(=O)N2C)C&#34;</span>)
</span></span><span style="display:flex;"><span>print(Chem<span style="color:#f92672">.</span>MolToSmiles(mol))
</span></span><span style="display:flex;"><span><span style="color:#75715e"># -&gt; Cn1c(=O)c2c(ncn2C)n(C)c1=O</span>
</span></span></code></pre></div><h3 id="isomeric-smiles">Isomeric SMILES</h3>
<p>Isomeric SMILES incorporates isotopes and stereochemistry information, providing more detailed molecular representations than generic SMILES. Non-isomeric SMILES strip this information, collapsing stereoisomers and isotopologues into the same string:</p>
<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-python" data-lang="python"><span style="display:flex;"><span><span style="color:#f92672">from</span> rdkit <span style="color:#f92672">import</span> Chem
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># L-alanine (chiral center)</span>
</span></span><span style="display:flex;"><span>mol <span style="color:#f92672">=</span> Chem<span style="color:#f92672">.</span>MolFromSmiles(<span style="color:#e6db74">&#34;N[C@@H](C)C(=O)O&#34;</span>)
</span></span><span style="display:flex;"><span>print(Chem<span style="color:#f92672">.</span>MolToSmiles(mol, isomericSmiles<span style="color:#f92672">=</span><span style="color:#66d9ef">True</span>))
</span></span><span style="display:flex;"><span><span style="color:#75715e"># -&gt; C[C@H](N)C(=O)O    (preserves chirality)</span>
</span></span><span style="display:flex;"><span>print(Chem<span style="color:#f92672">.</span>MolToSmiles(mol, isomericSmiles<span style="color:#f92672">=</span><span style="color:#66d9ef">False</span>))
</span></span><span style="display:flex;"><span><span style="color:#75715e"># -&gt; CC(N)C(=O)O         (chirality lost)</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># Deuterated water (isotope labels)</span>
</span></span><span style="display:flex;"><span>mol2 <span style="color:#f92672">=</span> Chem<span style="color:#f92672">.</span>MolFromSmiles(<span style="color:#e6db74">&#34;[2H]O[2H]&#34;</span>)
</span></span><span style="display:flex;"><span>print(Chem<span style="color:#f92672">.</span>MolToSmiles(mol2, isomericSmiles<span style="color:#f92672">=</span><span style="color:#66d9ef">True</span>))
</span></span><span style="display:flex;"><span><span style="color:#75715e"># -&gt; [2H]O[2H]           (preserves isotopes)</span>
</span></span><span style="display:flex;"><span>print(Chem<span style="color:#f92672">.</span>MolToSmiles(mol2, isomericSmiles<span style="color:#f92672">=</span><span style="color:#66d9ef">False</span>))
</span></span><span style="display:flex;"><span><span style="color:#75715e"># -&gt; [H]O[H]             (isotope info lost)</span>
</span></span></code></pre></div><h3 id="opensmiles-vs-proprietary">OpenSMILES vs. Proprietary</h3>
<ul>
<li><strong>Proprietary</strong>: The original SMILES specification was proprietary (Daylight Chemical Information Systems), which led to compatibility issues between different implementations.</li>
<li><strong>OpenSMILES</strong>: An open-source alternative standardization effort to address compatibility concerns and provide a freely available specification.</li>
</ul>
<h2 id="extensions-and-related-notations">Extensions and Related Notations</h2>
<h3 id="deepsmiles">DeepSMILES</h3>
<p><a href="/notes/chemistry/molecular-representations/notations/deepsmiles-adaptation-for-ml/">DeepSMILES</a> modifies two aspects of SMILES syntax that cause most invalid strings in generative models, while remaining interconvertible with standard SMILES without information loss.</p>
<p><strong>Ring closures</strong>: Standard SMILES uses paired digits (<code>c1ccccc1</code> for benzene). A model must remember which digits are &ldquo;open&rdquo; and close them correctly. DeepSMILES replaces this with a single ring-size indicator at the closing position: <code>cccccc6</code> means &ldquo;connect to the atom 6 positions back.&rdquo;</p>
<p><strong>Branches</strong>: Standard SMILES uses matched parentheses (<code>C(OC)(SC)F</code>). DeepSMILES uses a postfix notation with only closing parentheses, where consecutive <code>)</code> symbols indicate how far to pop back on the atom stack: <code>COC))SC))F</code>.</p>
<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-text" data-lang="text"><span style="display:flex;"><span>SMILES:       c1ccccc1          C(OC)(SC)F
</span></span><span style="display:flex;"><span>DeepSMILES:   cccccc6           COC))SC))F
</span></span><span style="display:flex;"><span>              ↑                 ↑
</span></span><span style="display:flex;"><span>              single digit =    no opening parens,
</span></span><span style="display:flex;"><span>              ring size         )) pops back to C
</span></span></code></pre></div><p>A single unpaired symbol cannot be &ldquo;unmatched,&rdquo; eliminating the two main sources of syntactically invalid strings from generative models.</p>
<h3 id="reaction-smiles">Reaction SMILES</h3>
<p>Reaction SMILES extends the notation to represent chemical reactions by separating reactants, reagents, and products with <code>&gt;</code> symbols. The general format is <code>reactants&gt;reagents&gt;products</code>, where each group can contain multiple molecules separated by <code>.</code>:</p>
<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-text" data-lang="text"><span style="display:flex;"><span>CC(=O)O.CCO&gt;&gt;CC(=O)OCC.O
</span></span><span style="display:flex;"><span>│         │ │            │
</span></span><span style="display:flex;"><span>│         │ │            └─ water
</span></span><span style="display:flex;"><span>│         │ └─ ethyl acetate
</span></span><span style="display:flex;"><span>│         └─ ethanol
</span></span><span style="display:flex;"><span>└─ acetic acid
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>(Fischer esterification: acetic acid + ethanol → ethyl acetate + water)
</span></span></code></pre></div><p>The <a href="/notes/chemistry/molecular-design/reaction-prediction/molecular-transformer/">Molecular Transformer</a> treats this as a machine translation problem, translating reactant SMILES to product SMILES with a Transformer encoder-decoder architecture.</p>
<h3 id="smarts-and-smirks">SMARTS and SMIRKS</h3>
<p><strong>SMARTS</strong> (SMILES Arbitrary Target Specification) is a pattern language built on SMILES syntax for substructure searching. It extends SMILES with query primitives like atom environments (<code>[CX3]</code> for a carbon with three connections) and logical operators, enabling precise structural pattern matching:</p>
<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-python" data-lang="python"><span style="display:flex;"><span><span style="color:#f92672">from</span> rdkit <span style="color:#f92672">import</span> Chem
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># SMARTS pattern for a carboxylic acid group: C(=O)OH</span>
</span></span><span style="display:flex;"><span>pattern <span style="color:#f92672">=</span> Chem<span style="color:#f92672">.</span>MolFromSmarts(<span style="color:#e6db74">&#34;[CX3](=O)[OX2H1]&#34;</span>)
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">for</span> name, smi <span style="color:#f92672">in</span> [(<span style="color:#e6db74">&#34;acetic acid&#34;</span>, <span style="color:#e6db74">&#34;CC(=O)O&#34;</span>),
</span></span><span style="display:flex;"><span>                  (<span style="color:#e6db74">&#34;benzoic acid&#34;</span>, <span style="color:#e6db74">&#34;c1ccc(C(=O)O)cc1&#34;</span>),
</span></span><span style="display:flex;"><span>                  (<span style="color:#e6db74">&#34;ethanol&#34;</span>, <span style="color:#e6db74">&#34;CCO&#34;</span>),
</span></span><span style="display:flex;"><span>                  (<span style="color:#e6db74">&#34;acetone&#34;</span>, <span style="color:#e6db74">&#34;CC(=O)C&#34;</span>)]:
</span></span><span style="display:flex;"><span>    mol <span style="color:#f92672">=</span> Chem<span style="color:#f92672">.</span>MolFromSmiles(smi)
</span></span><span style="display:flex;"><span>    print(<span style="color:#e6db74">f</span><span style="color:#e6db74">&#34;  </span><span style="color:#e6db74">{</span>name<span style="color:#e6db74">:</span><span style="color:#e6db74">15s</span><span style="color:#e6db74">}</span><span style="color:#e6db74"> -&gt; </span><span style="color:#e6db74">{</span><span style="color:#e6db74">&#39;match&#39;</span> <span style="color:#66d9ef">if</span> mol<span style="color:#f92672">.</span>HasSubstructMatch(pattern) <span style="color:#66d9ef">else</span> <span style="color:#e6db74">&#39;no match&#39;</span><span style="color:#e6db74">}</span><span style="color:#e6db74">&#34;</span>)
</span></span><span style="display:flex;"><span><span style="color:#75715e"># -&gt; acetic acid      -&gt; match</span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># -&gt; benzoic acid     -&gt; match</span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># -&gt; ethanol          -&gt; no match</span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># -&gt; acetone          -&gt; no match</span>
</span></span></code></pre></div><p><strong>SMIRKS</strong> extends SMARTS to describe reaction transforms, using atom maps (<code>:1</code>, <code>:2</code>, &hellip;) to track which atoms in the reactants correspond to which atoms in the products:</p>
<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-python" data-lang="python"><span style="display:flex;"><span><span style="color:#f92672">from</span> rdkit.Chem <span style="color:#f92672">import</span> AllChem, MolFromSmiles, MolToSmiles
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># SMIRKS for ester hydrolysis: break the C-O ester bond</span>
</span></span><span style="display:flex;"><span>smirks <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;[C:1](=[O:2])[O:3][C:4]&gt;&gt;[C:1](=[O:2])[OH:3].[C:4][OH]&#34;</span>
</span></span><span style="display:flex;"><span>rxn <span style="color:#f92672">=</span> AllChem<span style="color:#f92672">.</span>ReactionFromSmarts(smirks)
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>reactant <span style="color:#f92672">=</span> MolFromSmiles(<span style="color:#e6db74">&#34;CC(=O)OCC&#34;</span>)  <span style="color:#75715e"># ethyl acetate</span>
</span></span><span style="display:flex;"><span>products <span style="color:#f92672">=</span> rxn<span style="color:#f92672">.</span>RunReactants((reactant,))
</span></span><span style="display:flex;"><span>print(<span style="color:#e6db74">&#34; + &#34;</span><span style="color:#f92672">.</span>join(MolToSmiles(p) <span style="color:#66d9ef">for</span> p <span style="color:#f92672">in</span> products[<span style="color:#ae81ff">0</span>]))
</span></span><span style="display:flex;"><span><span style="color:#75715e"># -&gt; CC(=O)O + CCO    (acetic acid + ethanol)</span>
</span></span></code></pre></div><p>See the <a href="/notes/chemistry/molecular-representations/notations/smirk-tokenization-molecular-models/">Smirk tokenizer</a> for a recent approach to tokenizing these extensions for molecular foundation models.</p>
<h3 id="t-smiles">t-SMILES</h3>
<p><a href="/notes/chemistry/molecular-representations/notations/t-smiles-fragment-molecular-representation/">t-SMILES</a> encodes molecules as fragment-based strings by decomposing a molecule into chemically meaningful substructures, arranging them into a full binary tree, and traversing it breadth-first. This dramatically reduces nesting depth compared to standard SMILES (99.3% of tokens at depth 0-2 vs. 68.0% for SMILES on ChEMBL).</p>
<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-text" data-lang="text"><span style="display:flex;"><span>Standard SMILES (depth-first, atom-level):
</span></span><span style="display:flex;"><span>  CC(=O)Oc1ccccc1C(=O)O                     (aspirin)
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>t-SMILES pipeline:
</span></span><span style="display:flex;"><span>  1. Fragment:     [CC(=O)O*]  [*c1ccccc1*]  [*C(=O)O]
</span></span><span style="display:flex;"><span>  2. Binary tree:
</span></span><span style="display:flex;"><span>                   [*c1ccccc1*]
</span></span><span style="display:flex;"><span>                  /             \
</span></span><span style="display:flex;"><span>         [CC(=O)O*]          [*C(=O)O]
</span></span><span style="display:flex;"><span>  3. BFS string:   [*c1ccccc1*] ^ [CC(=O)O*] ^ [*C(=O)O]
</span></span></code></pre></div><p>The framework introduces two symbols beyond standard SMILES: <code>^</code> separates adjacent fragments (analogous to spaces between words), and <code>&amp;</code> marks empty tree nodes. Only single closure symbols are needed per fragment, eliminating the deep nesting that makes standard SMILES difficult for generative models on small datasets.</p>
<h2 id="further-reading">Further Reading</h2>
<p>For a more robust alternative that guarantees 100% valid molecules, see <a href="/notes/chemistry/molecular-representations/notations/selfies/">SELFIES (Self-Referencing Embedded Strings)</a>. For the historical context and design philosophy behind SMILES, see <a href="/notes/chemistry/molecular-representations/notations/smiles-original-paper/">SMILES: The Original Paper (Weininger 1988)</a>.</p>
<h2 id="references">References</h2>
<ul>
<li><a href="https://19january2021snapshot.epa.gov/sites/static/files/2015-05/documents/appendf.pdf">Sustainable Futures / P2 Framework Manual 2012 EPA-748-B12-001: Appendix F. SMILES Notation Tutorial</a></li>
<li><a href="https://www.daylight.com/dayhtml/doc/theory/theory.smiles.html">Daylight Chemical Information Systems, Inc. SMILES</a></li>
<li><a href="http://opensmiles.org/opensmiles.html">OpenSMILES</a></li>
<li><a href="https://arxiv.org/abs/2402.01439">From Words to Molecules: A Survey of Large Language Models in Chemistry</a></li>
</ul>
]]></content:encoded></item></channel></rss>