TL;DR
SHIMBO automates "shimming"—the finicky process of tuning magnetic fields in Nuclear Magnetic Resonance (NMR) spectrometers—using Bayesian Optimisation with Variational Bayesian Last Layer (VBLL) neural networks. Tested live on a 60-MHz bench-top NMR machine, it matches human experts on static samples in under an hour and, crucially, adapts on the fly to drifting lab conditions and changing samples in continuous-flow experiments.
What Problem Does This Paper Address?
NMR spectroscopy is one of chemistry's most powerful tools for figuring out molecular structures and monitoring reactions. But there is a catch: to get a clean, readable spectrum, the magnetic field hitting the sample must be extraordinarily uniform. Achieving this requires shimming—iteratively adjusting dozens of small corrective magnetic coils to cancel out field inhomogeneities.
In modern self-driving laboratories (SDLs), compact bench-top NMRs are popular because they are cheap and small. However, their permanent magnets are far more sensitive to temperature swings and vibrations than superconducting high-field magnets. Worse, their 64 shim coils are physically crammed together, meaning their effects are correlated and cannot be tuned one by one.
In flow NMR, where a reacting mixture continuously moves through the spectrometer, the sample's magnetic susceptibility and the lab environment are both constantly shifting. Static shimming presets quickly go stale, creating a major bottleneck for fully autonomous chemical discovery.
Methods
The authors frame shimming as a black-box optimisation problem over a 64-dimensional discrete space ([-2^15, 2^15 - 1]^64) and introduce SHIMBO:
- VBLL Surrogates: Instead of standard Gaussian Processes (GPs), SHIMBO uses Variational Bayesian Last Layer (VBLL) neural networks with Multi-Layer Perceptron (MLP) backbones. These naturally learn the physical correlations between the 64 shim coils.
- Batched Exploration & Trust Regions: To search the 64D space efficiently, SHIMBO uses batched
qLogEIacquisition (via BoTorch) alongside multiple trust regions to encourage diverse sampling. - Hardware Constraints: Not every 64-coil setting can be physically supplied by the spectrometer's digital-to-analogue converter. Because this validity region has no closed-form equation, SHIMBO uses an offline-trained binary classifier
p(c|x)to steer the acquisition function away from infeasible settings. - Continual Flow Adaptation: For flow NMR, SHIMBO uses a sliding data window (500 minutes) to phase out stale observations as the sample or environment drifts.
- Spectral Objectives: Depending on the sample, SHIMBO maximises either inverse full-width half-max (
1/FWHM) or negative spectral entropy.
Datasets
No simulated or pre-existing benchmark datasets were used—every experiment was run live on a single 60-MHz bench-top NMR spectrometer:
- Static samples: Pure water (
H2O), aDMSO/H2Omixture, and aqueous caffeine. - Flow NMR: A 40-hour run on fully dissolved caffeine (with deliberate perturbations to test recovery) and a 65-hour run with active caffeine dissolution (using
tBuOHas an internal standard).
Key Insights and Ideas
- You have to tune all 64 coils together: Ablations on water show that optimising any subset of the 64 shims consistently underperforms joint optimisation.
- Batching and multiple trust regions are essential: Unbatched (
q = 1) optimisation and single trust regions perform significantly worse than batched (q = 8, 16, 32) and multi-region (m = 4, 8, 16) setups. - VBLLs beat GPs on CPU: While ensemble surrogates perform best overall, they require GPUs. Among CPU-practical models, a single VBLL consistently outperforms a GP in both sample and time efficiency.
- Forgetting is a feature in flow NMR: Keeping the full observation history slows recovery after perturbations. A 500-minute sliding window lets SHIMBO adapt quickly to non-stationary samples.
Key Results
- Static Shimming: Within a practical 1-hour wall-clock budget, SHIMBO sharpens every peak from a stale initial shim—matching an experienced experimentalist on water and successfully shimming multi-peak
DMSO/H2Oand caffeine spectra.
- Surrogate Comparison: Across water,
DMSO/H2O, and caffeine, VBLL outperforms GP, while the VBLL ensemble achieves the highest overall objective values.
- Flow NMR: In the 65-hour active dissolution run, sliding-window SHIMBO accurately tracks the per-proton integral ratio of two closely spaced caffeine peaks (
3.208and3.376 ppm) relative totBuOH. In contrast, a fixed initial shim underestimates the dissolution rate throughout the entire experiment.
Limitations and Future Work
- Compute vs. Performance Trade-off: Ensemble surrogates (VBLL ensemble and MLP ensemble) deliver the strongest performance, but they are impractical to run without GPU resources, leaving the single VBLL as the best CPU-only option.
- Hardware Scope: All experimental validation was performed on a single 60-MHz bench-top NMR spectrometer; broader testing across other spectrometer architectures is not discussed in the paper.
Summary updated