NIMIS: A Structure-Agnostic, Chemically Informed Slot-Attention Framework for Demixing 1D H-NMR Mixture Spectra
Organizations: Yusuf Hamied Department of Chemistry, Lensfield Road, Cambridge CB2 1EW
Abstract
The products of chemical reactions are usually complex mixtures that must be separated into their components before interpretable H-NMR spectra can be obtained. Direct analysis of the spectra of crude mixtures would accelerate reaction analysis and facilitate the exploration of new chemical space. We present NIMIS, a structure-agnostic, attention-based deep learning framework that groups the peaks of a 1D H-NMR mixture spectrum according to the component from which they originate. J-coupling information is introduced directly into the attention mechanism of a multi-head Transformer encoder, and the resulting contextualised peak embeddings are separated into components by slot attention. NIMIS was trained on 158,005 synthetic mixtures constructed from experimental spectra in the NMRexp database, covering molecules of up to 20 heavy atoms composed of C, H, N, O, S, F, Cl, Br and I. On held-out molecules it reaches a peak-to-component assignment accuracy of 82.28% for noise-free input and 77.34% with 10% integral noise, with a mean NIMIS score of 0.83 for correct assignments. NIMIS outperforms a conventional Transformer and simple baselines, and its performance carries over to a scaffold-disjoint evaluation. By grouping peaks into component-level sets, NIMIS provides a foundation for more robust mixture analysis methods, including methods capable of handling overlapping signals.
Figures & tables
| Added integral | Both chemical | J-coupling matching | Integral-ratio matrix | Vanilla |
|---|---|---|---|---|
| noise (%) | priors | matrix only | only | Transformer |
| 0 | 81.89 | 82.28 | 81.92 | 79.54 |
| 5 | 80.55 | 81.16 | 80.65 | 78.58 |
| 10 | 76.57 | 77.34 | 76.44 | 74.61 |
| 15 | 71.71 | 72.44 | 71.31 | 69.99 |
| Component | Number | Both chemical | J-coupling matching | Integral-ratio matrix | Vanilla |
|---|---|---|---|---|---|
| fraction (%) | of peaks | priors | matrix only | only | Transformer |
| 1–5 | 44,443 | 86.70 | 86.55 | 87.18 | 84.97 |
| 5–10 | 49,739 | 75.66 | 76.52 | 76.07 | 73.60 |
| 10–15 | 43,635 | 69.35 | 69.86 | 68.65 | 66.77 |
| 15–20 | 37,985 | 66.82 | 67.41 | 65.84 | 63.36 |
| 20 | 212,844 | 77.88 | 78.91 | 77.78 | 76.30 |
| NIMIS | Vanilla Transformer | |||
|---|---|---|---|---|
| Uniform bias | Integrals | J-couplings | Integrals + J-couplings | Integrals |
| None | 77.30 | 77.30 | 77.30 | 74.69 |
| 74.29 | 77.42 | 74.36 | 72.30 | |
| 75.81 | 77.41 | 75.90 | 73.58 | |
| 76.87 | 77.40 | 76.97 | 74.39 | |
| 77.05 | 77.18 | 76.87 | 74.46 | |
| Tolerance (Hz) | Accuracy (%) | Peaks matched (%) |
|---|---|---|
| 0.00 | 77.24 | 22.04 |
| 0.10 | 77.40 | 26.68 |
| 0.20 | 77.42 | 31.70 |
| 0.30 | 77.42 | 33.64 |
| 0.50 | 77.31 | 37.37 |
| 1.00 | 77.02 | 39.73 |
| Match type | Tolerance (Hz) | Mean attention |
|---|---|---|
| True match | 0.1 | 0.0891 |
| False match | 0.1 | 0.0387 |
| True match | 1.0 | 0.0749 |
| False match | 1.0 | 0.0395 |
| Unmatched (same component) | – | 0.0450 |
| Unmatched (different components) | – | 0.0259 |
| Approach | Accuracy (%) |
|---|---|
| NIMIS | 77.34 |
| Vanilla Transformer | 74.61 |
| Random assignment | 43.79 |
| J-coupling matching only | 24.20 |
| J-coupling with random completion | 46.28 |
| Integral matching alone | 58.55 |
Appendix figures & tables7 assets
Supplementary material from the paper’s appendix.
Appendix
| Layer | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
|---|---|---|---|---|---|---|---|---|
| 2.86 | 2.24 | 0.19 | 1.51 |
| Component | Setting |
|---|---|
| Model width | 128 |
| Peak input features (Fourier (peak position) + log-integral) | 33 |
| Embedding MLP (hidden widths) | |
| Fourier periods | 16 to 0.01 ppm, 16 geometric steps |
| Encoder depth | 8 |
| Attention heads / head width | 8 / 64 (inner width 512) |
| Optimiser | Adam, initial learning rate |
|---|---|
| LR schedule | ReduceLROnPlateau on epoch training loss (factor 0.5, patience 8, min ) |
| Gradient clipping | global norm 1.0 |
| Batch size | 128 per GPU (data-parallel via PyTorch DDP when several GPUs are used) |
| Epochs | 300 (validation every 5 epochs, best-validation-loss checkpoint kept) |
| Integral augmentation | , per peak, redrawn every batch |
| Test-time integral noise | 0, 5, 10, 15 % |
| Noise (%) | 2 | 3 | 4 | 5 | All | Mean NIMIS score | |
|---|---|---|---|---|---|---|---|
| comp. | comp. | comp. | comp. | correct | incorrect | ||
| Molecule-disjoint test set (16,000 mixtures, 388,646 peaks) | |||||||
| 0 | 93.75 | 87.62 | 81.71 | 74.89 | 82.28 | 0.832 | 0.571 |
| 5 | 93.37 | 86.62 | 80.50 | 73.48 | 81.16 | 0.830 | 0.573 |
| 10 | 91.47 | 83.28 | 76.12 | 69.04 | 77.34 | 0.828 | 0.590 |
| 15 | 88.42 | 78.63 | 70.63 | 63.72 | 72.44 | 0.828 | 0.618 |
| Component | Peak position (ppm) | Integral | NIMIS score |
|---|---|---|---|
| 1 | 4.76 | 2.08 | 0.6296 |
| 7.12 | 0.79 | 0.5711 | |
| 7.19 | 0.99 | 0.6060 | |
| 7.55 | 1.91 | 0.6058 | |
| 7.64 | 2.04 | 0.5419 | |
| 8.28 | 0.87 | 0.5819 |
| Matches removed (%) | Peaks matched (%) | All | 2 comp. | 3 comp. | 4 comp. | 5 comp. |
|---|---|---|---|---|---|---|
| 0 | 26.68 | 77.33 0.03 | 91.42 0.10 | 83.25 0.04 | 76.22 0.11 | 68.98 0.04 |
| 10 | 25.06 | 77.21 0.06 | 91.36 0.09 | 83.14 0.09 | 76.06 0.13 | 68.87 0.06 |
| 25 | 22.41 | 77.00 0.04 | 91.22 0.09 | 82.99 0.06 | 75.85 0.10 | 68.58 0.07 |
| 50 | 17.08 | 76.62 0.03 | 91.06 0.04 | 82.57 0.05 | 75.41 0.13 | 68.18 0.07 |
| 75 | 9.99 | 76.21 0.05 | 90.89 0.08 | 82.24 0.04 | 74.93 0.15 | 67.68 0.09 |
| 100 | 0.00 | 75.74 0.04 | 90.67 0.08 | 81.85 0.04 | 74.43 0.08 | 67.10 0.07 |
| Peak position (ppm) | Multiplicity | J (Hz) | Report (H) | Integral used |
| Binary mixture: 4-methoxybenzaldehyde and 4-nitroaniline (main-text Figure 7) | ||||
| 9.89 | s | – | 1 | 1.00 |
| 8.06 | d | 9.0 | 1 | 0.69 |
| 7.85 | d | 8.8 | 2 | 2.28 |
| 7.02 | d | 8.8 | 2 | 2.27 |
| 6.63 | d | 9.0 | 1 | 0.67 |