Test-Time Tuned Language Models Enable End-to-end De Novo Molecular Structure Generation from MS/MS Spectra
Laura Mismetti, Marvin Alberts, Andreas Krause, Mara Graziani
TL;DR
The paper addresses end-to-end de novo molecular structure generation from MS/MS spectra, bypassing intermediate fragment prediction and database matching. It introduces test-time tuning of a pre-trained transformer that ingests MS/MS spectra and chemical formula as input and predicts SMILES, guided by an auxiliary fingerprint predictor and formula-constrained generation. The approach achieves state-of-the-art performance on NPLIB1 and MassSpecGym, with large relative gains and strong chemical plausibility even when exact structures are not recovered. Combined with simulated data pre-training and adaptive use of experimental spectra, the method offers a robust, scalable workflow to accelerate structure elucidation in metabolomics and related fields.
Abstract
Tandem Mass Spectrometry enables the identification of unknown compounds in crucial fields such as metabolomics, natural product discovery and environmental analysis. However, current methods rely on database matching from previously observed molecules, or on multi-step pipelines that require intermediate fragment or fingerprint prediction. This makes finding the correct molecule highly challenging, particularly for compounds absent from reference databases. We introduce a framework that, by leveraging test-time tuning, enhances the learning of a pre-trained transformer model to address this gap, enabling end-to-end de novo molecular structure generation directly from the tandem mass spectra and molecular formulae, bypassing manual annotations and intermediate steps. We surpass the de-facto state-of-the-art approach DiffMS on two popular benchmarks NPLIB1 and MassSpecGym by 100% and 20%, respectively. Test-time tuning on experimental spectra allows the model to dynamically adapt to novel spectra, and the relative performance gain over conventional fine-tuning is of 62% on MassSpecGym. When predictions deviate from the ground truth, the generated molecular candidates remain structurally accurate, providing valuable guidance for human interpretation and more reliable identification.
