NMIRacle: Multi-modal Generative Molecular Elucidation from IR and NMR Spectra

Federico Ottomano, Yingzhen Li, Alex M Ganose

TL;DR

NMIRacle is a two-stage deep learning framework that reconstructs 2D molecular structures directly from raw, unparsed infrared (IR) and nuclear magnetic resonance ($^1\text{H}$- and $^{13}\text{C}$-NMR) spectra. By pre-training a generator with count-aware chemical fragment representations and conditioning it via a hierarchical multi-spectral encoder, NMIRacle accurately generates complex, unseen small molecules without requiring chemical formulas, scaffolds, or manual peak picking.

What Problem Does This Paper Address?

Determining a molecule's structure from spectroscopic data—known as molecular structure elucidation—is a cornerstone of organic chemistry, metabolomics, and drug discovery. Traditionally, this process relies on human experts or searching reference databases, which breaks down when encountering completely novel compounds.

While recent machine learning models have attempted de novo generation from spectra, most suffer from major limitations:

  1. Single-modality focus: Relying only on IR or NMR ignores the complementary structural information offered by combining techniques.
  2. Heavy pre-processing: Many models require expert-engineered peak picking, integration, or multiplet assignment rather than operating on raw signals.
  3. Unrealistic priors: Existing benchmarks often assume known chemical formulas, pre-identified core scaffolds, or are limited to small molecules ($\le 20$ heavy atoms with only C, N, and O).

NMIRacle tackles the direct, end-to-end generation of SMILES strings from raw spectral intensity arrays across molecules with up to 35 heavy atoms and 9 distinct chemical elements, making minimal assumptions about prior knowledge.

Methods

NMIRacle decomposes structure elucidation into a two-stage conditional generative process:

Stage 1: [Count-Aware Fragments] ---> [Transformer Encoder-Decoder] ---> Molecular SMILES
                                                 ▲ (Transfer weights)
Stage 2: [Raw IR, 1H, 13C Spectra] ---> [Multi-Spectra Encoder]
                                                 ▼
                                        Joint Multi-Task Loss:
                             (SMILES Generation + Fragment Count Prediction)
  1. Stage 1 (Fragments-to-Molecule Pre-training): Instead of using binary presence/absence flags, NMIRacle represents molecules using a count-aware fragment vector across a curated vocabulary of 991 SMARTS patterns. Independent embeddings for fragment identities and their discrete integer occurrences are summed and passed to a Transformer encoder-decoder that learns a molecular prior $p_\phi(\mathbf{y} \mid \mathbf{c})$ via autoregressive SMILES generation.

  2. Stage 2 (Spectra-to-Molecule Fine-Tuning): The pre-trained generator is conditioned on latent representations from a hierarchical multi-spectral encoder:

  3. Continuous Spectra (IR, $^1\text{H}$-NMR): Processed via 1D convolutions, learnable linear projections, and learnable positional encodings.

  4. Discrete Chemical Shifts ($^{13}\text{C}$-NMR): Detected peaks are binned into 80 chemical shift intervals (0–220 ppm) and mapped via learnable embeddings.
  5. Intra- and Inter-modal Attention: Modality-specific Transformers capture local dependencies within each spectrum before an inter-spectral Transformer fuses all modalities.
  6. Multi-Task Objective: In Stage 2, the model simultaneously optimizes autoregressive SMILES reconstruction and an auxiliary fragment count prediction loss, forcing the spectral latent space to encode concrete functional group counts.

Datasets

  • Stage 1 (Molecular Pre-training): An augmented dataset of $\sim 3.7\text{M}$ molecules combining $\sim 3\text{M}$ sampled structures from GDB-17, $\sim 140\text{k}$ entries from SpectraBase, and $\sim 670\text{k}$ molecules from the Alberts et al. (2024) multimodal dataset. This expanded diversity to 9 chemical elements (C, N, O, F, S, Cl, Br, I, P) and up to 35 heavy atoms.
  • Stage 2 (Fine-Tuning & Evaluation): The simulated multimodal benchmark by Alberts et al. (2024), comprising $\sim 790\text{k}$ molecule–spectra pairs (IR, $^1\text{H}$-NMR, $^{13}\text{C}$-NMR) split 8:1:1. The test set was strictly disjoint from both the pre-training and fine-tuning datasets to evaluate generalization to entirely unseen chemical space.

Key Insights and Ideas

  • Count-awareness matters: Specifying how many copies of a functional group exist (e.g., chain lengths or aromatic rings) provides quantitative assembly constraints, boosting Stage 1 Top-1 accuracy from 0.63 (binary baseline) to 0.70.
  • Chemically grounded priors beat continuous SMILES embeddings: SMILES autoencoding models like Spec2Mol perform well during Stage 1 reconstruction (0.96 Top-1) but collapse during spectra conditioning (0.00 Top-1). Aligning continuous spectra to a latent SMILES code is far harder than grounding them in discrete chemical fragments.
  • Enantiomer-aware metrics reflect physical reality: Standard 1D NMR and IR cannot differentiate absolute stereochemistry (mirror images). Evaluating predictions with an enantiomer-aware matching protocol avoids penalizing models for physically indistinguishable enantiomers.

Key Results

  • Generation Accuracy: When conditioned on all three modalities (IR + $^1\text{H}$-NMR + $^{13}\text{C}$-NMR), NMIRacle achieves 0.48 Top-1 and 0.66 Top-15 accuracy, outperforming the previous state-of-the-art baseline NMR2Struct (0.41 / 0.58) and standard SMILES Transformers (0.28 / 0.42).
  • Relaxed Constraints: Under constitutional matching (ignoring stereochemical chirality), Top-15 accuracy climbs to 0.69.
  • Structural Similarity: NMIRacle obtains an average Morgan Tanimoto similarity of 0.88 and an edit distance (MCES) of 1.82 (vs. 2.39 for NMR2Struct).
  • Robustness to Complexity: Evaluating across a composite Molecular Complexity metric (accounting for heavy atom count, unique elements, and rings), NMIRacle maintains superior Tanimoto similarity across all complexity tiers.

Limitations and Future Work

  • Simulated vs. Experimental Data: All evaluations used simulated spectra without real-world artifacts like instrument noise, solvent shifts, or baseline distortions.
  • 2D Connectivity Only: The framework outputs 2D connectivity graphs (SMILES) and does not predict 3D molecular conformations.
  • Deterministic Point Estimates: Mapping spectra deterministically to latent fragments ignores intrinsic spectral degeneracies (where different molecules produce near-identical spectra). Probabilistic or variational approaches could improve handling of ambiguous inputs.
  • Rare Fragment Imbalance: While micro-averaged fragment F1 reaches 0.87, macro-averaged F1 is 0.43, indicating difficulty with rare functional groups.

Summary updated

BibTeX
@inproceedings{ottomano2026nmiracle,
  author = {Federico Ottomano and Yingzhen Li and Alex M Ganose},
  title = {{NMIRacle: Multi-modal Generative Molecular Elucidation from IR and NMR Spectra}},
  booktitle = {AI4Mat @ ICLR},
  year = {2026},
  url = {https://openreview.net/forum?id=ur5XwprSyO},
}
Figure