Is This Compound Already Known? A Library-Size-Invariant Cross-Spectrum Consistency Test

When chemists isolate a molecule from a plant, coral or microbe, they measure it several ways: a mass spectrum (how it breaks into fragments) and a nuclear magnetic resonance (NMR) spectrum (how its hydrogen and carbon atoms respond in a magnetic field). They then ask whether any structure in a reference library explains all the measurements at once. The expensive mistake is to settle on the closest library match when the molecule is actually a new carbon skeleton. Such a molecule should instead be sent to de novo structure search and quantum-chemical confirmation. Current tools handle this badly. Matching against larger libraries makes retrieval worse, because more near-miss decoys appear. Neural models that produce structures from spectra score 0% exact match on genuinely new scaffolds. And no tool reports a calibrated signal saying "none of your candidates is consistent with both spectra."

Cosmologists faced the same statistical problem when asking whether two surveys, such as the Planck satellite's cosmic microwave background data and the Dark Energy Survey, agree under a shared model. Their answer carries over directly. The naive agreement score, the Bayesian evidence ratio, grows with the width of the prior, so broad priors hide real disagreement. A corrected statistic called Suspiciousness removes that effect. We propose to treat each spectroscopic measurement as a separate "probe" and the candidate library as the "prior." Suspiciousness then becomes a consistency score between the mass spectrum and the NMR spectrum that does not depend on library size. We calibrate it by simulation with a neural classifier, and use it to decide, per sample, whether a compound is known, is a mixture, or is a new scaffold that needs de novo elucidation.

Core Claim

The "dataset dilution paradox" in spectral matching is the discrete version of the prior-volume effect in cosmology, and the cosmological fix removes it. The paradox is the finding that retrieval accuracy falls as libraries grow, reported in Structure characterization with NMR molecular networking. Concretely, let $m$ range over the candidate molecular graphs in a library of size $N$ with prior weight $\pi(m)$. Let $D_A$ be the tandem mass spectrum, $D_B$ the NMR spectrum, and $L_A(m), L_B(m)$ their likelihoods under forward spectrum simulators. Each modality's evidence is then $Z_A=\sum_m \pi(m)L_A(m)$, with $Z_B$ and the joint $Z_{AB}=\sum_m \pi(m)L_A(m)L_B(m)$ defined the same way. The evidence ratio is

$$R=\frac{Z_{AB}}{Z_A Z_B}, \qquad \log S=\log R-\left(\mathcal{D}_A+\mathcal{D}_B-\mathcal{D}_{AB}\right),$$

where each $\mathcal{D}$ is the Kullback–Leibler divergence from prior to posterior for that data subset. Take a uniform prior and one dominant candidate. Then $R\approx N$, so apparent agreement grows with library size whether or not the spectra truly agree. Each $\mathcal{D}\approx\log N$, so the bracket is also $\approx\log N$ and cancels that growth. $S$ therefore measures only whether the two spectra point at the same structure.

This mirrors the argument of Quantifying tensions in cosmological parameters: Interpreting the DES evidence ratio, which showed that the Dark Energy Survey Year 1 versus Planck ratio $R=2.8$ was a prior artifact and that Suspiciousness revealed moderate tension ($p\approx1$–$3\%$). That paper assumed near-Gaussian continuous posteriors. Our contribution is the discrete, combinatorial case. We further claim that a low calibrated $S$, meaning the spectra disagree about every library candidate, is a usable flag for "outside the library." That flag is exactly the signal a discovery pipeline needs before spending effort on de novo search.

Relation to Prior Work

Three molecular-side papers motivate the gap. MM-Spectrum fuses NMR, infrared and mass spectra with a sparse mixture-of-experts model, a network that routes each input to a small subset of specialist sub-networks. It reaches 76.04% top-1 accuracy, compared with 44.29% for a dense model that simply concatenates the spectra. But it decides agreement between modalities implicitly through learned routing and emits no statement of disagreement. FOAM evolves candidate graphs with a genetic algorithm scored by the ICEBERG forward mass-spectrum simulator. It raises DiffMS top-10 exact match on MassSpecGym from 4.25% to 10.28%. Its authors list the lack of calibrated uncertainty and the risk of simulator errors as open limitations. MassSpecGym supplies the constraint that shapes our evaluation. Under a split that clusters molecules by structural similarity (the Maximum Common Edge Subgraph, or MCES, split), de novo models reach 0% exact match on unseen scaffolds. Deciding when a sample is novel is therefore the practical question, not an academic one. We do not propose a better generator. We propose the test that decides when retrieval should be trusted and when it should be abandoned.

The cosmology side supplies the method and two cautions. TENSIONNET uses neural ratio estimation, which trains a classifier to tell matched data pairs from shuffled ones. From that classifier it learns the distribution the evidence ratio takes when data truly agree, and turns an observed ratio into a calibrated tension score $T$. We reuse this design with (mass spectrum, NMR spectrum) pairs from the same versus different molecules. This matters because learning the reference distribution absorbs some of the forward-simulator error that FOAM identifies. The first caution is TENSIONNET's own finding that it degrades in extreme tension. Out-of-library samples are extreme tension by construction, so we treat that regime as a primary evaluation target rather than a footnote. The second caution comes from When tension is just a fluctuation, which shows the evidence ratio has order-one scatter from noise ($\Delta\ln R\sim1$) and that this scatter widens under tension. We therefore report the full sampling distribution of $S$ under spectral noise, not a point value. The dispute this paper has with Handley and Lemos, over whether a tension is a prior artifact or a fluctuation, becomes testable here: in simulation we know the ground truth.

Research Program

We will build three components. The first is a likelihood layer that gives per-candidate likelihoods for each modality. For mass spectra it uses the ICEBERG simulator from FOAM. For NMR it uses the Modified Hungarian distance on simulated HSQC spectra (a two-dimensional NMR map of which hydrogens sit on which carbons) from Structure characterization with NMR molecular networking, converted into a likelihood with a learned temperature parameter. The second is an evidence-and-information calculator over discrete candidate sets. The prior is either uniform over a library or weighted by a generative model's proposals, which makes it an explicit, auditable object. The third is a TENSIONNET-style ratio estimator trained on simulated concordant and discordant pairs, which converts raw $\log S$ into a calibrated tension probability. Training pairs cover three categories. Concordant pairs are both spectra from one molecule. Mixture pairs combine spectra from two molecules, one of which dominates each modality. Novel-scaffold pairs are both spectra from one molecule whose MCES cluster is absent from the library. The output is a three-way decision (known, mixture, novel), plus a routing rule that sends novel calls to FOAM-style de novo search.

Baselines

The naive reference point is the current default: take the top-1 library match from joint spectral similarity and never abstain. Its retrieval quality on MassSpecGym is known. MIST achieves Hit@1 of 14.6% on the retrieval task (MassSpecGym). By construction it cannot flag novelty, so its novel-scaffold recall is zero.

The strongest existing multimodal system is MM-Spectrum, at 76.04% top-1 on its multimodal benchmark (MM-Spectrum). We will retrain it on the same simulated multimodal data (MMST, about 6 million samples) under our MCES split, with the same compute and the same hyperparameter search budget as our estimator. We use its maximum softmax confidence and its expert-routing entropy as novelty scores. For de novo search, the strongest baseline is DiffMS plus FOAM at 10.28% top-10 exact match on MassSpecGym (FOAM). We will rerun it with an identical number of simulator calls.

For novelty detection itself there is no reported result on Lacuna for out-of-library flagging, or for abstention accuracy, on MassSpecGym or the multimodal benchmark. We will establish these numbers ourselves.

Three ablations isolate the key ingredient. The first uses the raw evidence ratio $R$ in place of $S$, which tests whether the prior-volume correction matters. The second uses uncalibrated $S$ in place of ratio-estimator-calibrated $S$, which tests whether simulation calibration matters. The third uses a single-modality evidence $Z_A$ or $Z_B$, which tests whether cross-modal disagreement carries information beyond poor fit in one modality.

Beating the baselines means two things. The first is higher area under the ROC curve (AUROC) for flagging MCES-novel samples than both the confidence-threshold baselines, with the gap stable across library sizes. The second is, when used as a router, a top-10 exact match above 10.28% at matched simulator budget.

Why not just…?

Why not just threshold the best-match similarity score? This is the most serious threat. If novel scaffolds simply fit every candidate poorly, a similarity threshold catches them. The dilution paradox predicts it will not hold up: as $N$ grows, decoys raise the best score for novel samples too, so any fixed threshold drifts. Our first decisive experiment measures this drift directly. If thresholding stays competitive across a thousandfold growth in library size, the prior-volume argument has no practical force and we will say so.

Why not just train a supervised in-library/out-of-library classifier? This works if the training distribution of "novel" resembles the novel samples met at test time. In real discovery the novelty is the unanticipated rearrangement, such as the icetexane skeletons of Two New Icetexane Diterpenoids from Salvia przewalskii. Our concordance estimator is trained only on whether two spectra share a molecule, a label available for any molecule, and never on novelty labels. We will train the supervised classifier on the same data and evaluate both on held-out MCES clusters whose scaffold families differ from those used for any training. If the supervised classifier matches us there, the Bayesian machinery is unnecessary.

Why not just use MM-Spectrum's confidence or a deep ensemble? Softmax confidence is known to be overconfident off-distribution, but that is a general concern, not evidence on this task. More concretely, a single fused model cannot distinguish "the spectra disagree" (a mixture) from "the spectra agree about a structure I don't know" (a new scaffold), because both merely lower confidence. The synthetic-mixture experiment tests exactly this three-way separation, and ensembles are included at equal compute.

Proposed Experiments

We first validate the implementation by reproducing TENSIONNET's reported concordance between the Sloan Digital Sky Survey (SDSS) and Dark Energy Spectroscopic Instrument (DESI) baryon acoustic oscillation measurements, $T=1.22\pm0.20$ (TENSIONNET). The main experiments then run on MMST-simulated mass-spectrum and NMR pairs under an MCES split, with the real-spectrum SDBS database as a transfer test.

The first decisive check is library-size invariance. We subsample COCONUT/LOTUS-derived libraries from $10^3$ to $10^6$ entries and plot $R$, $S$ and top-1 retrieval against $N$. The prediction is that $\log R$ rises roughly as $\log N$ while $S$ stays flat.

The second check is novelty AUROC on held-out MCES clusters against all baselines, with the spread of $S$ under repeated noise draws reported alongside it. We expect the spread to widen for novel samples, as the fluctuation paper predicts. If it widens enough to destroy separation, that is a negative result worth publishing.

The third check is three-way accuracy on synthetic two-component mixtures.

The fourth check is end-to-end discovery. We route flagged samples to DiffMS plus FOAM, keep the total simulator budget fixed, and compare top-10 exact match against running FOAM on everything. A final small real-world probe applies the test to the published spectra of donghaecyclinones A–C (Donghaecyclinones A–C) and przewalskins C and D, all rearranged skeletons, using libraries that exclude them. It asks whether each is flagged as novel rather than force-matched to its closest known relative.