DOI: 10.1021/acs.analchem.6c03195 ISSN: 0003-2700

SpecRoFormer: Relative Position-Aware Representation Learning for Small-Molecule MS/MS Spectra

Guoqing Zhu, Shiting Lai, Xinyi Cao, Keyu Hu, Luojun Lin, Yuanlong Yu

Abstract

Spectrum retrieval in tandem mass spectrometry (MS/MS) relies on learning representations that accurately reflect molecular structural similarity. However, fragmentation variability across experimental conditions and instrument biases introduces significant distribution shifts in spectral data, making it difficult to learn representations that can generalize to different instruments. In this study, we propose SpecRoFormer, a Transformer-based framework that learns generalizable MS/MS representations through relative spectral modeling and fragmentation-aware augmentation. The approach captures structure-relevant relationships between peaks while improving robustness to fragmentation variability and distribution shifts. We train SpecRoFormer on the GNPS dataset and evaluate its generalization across multiple external benchmarks, including MoNA, MassBank, and MassSpecGym. Across these datasets, SpecRoFormer achieves the best overall retrieval performance against strong baselines such as MSBERT, DreaMS, and SpecEmbedding. Furthermore, evaluations on the large-scale simulated dataset SimMS-9M further verify the robustness of SpecRoFormer under broader distribution shifts, consistently outperforming competing methods. These results demonstrate that modeling relative spectral relationships together with fragmentation-aware robustness is critical for learning generalizable MS/MS representations, enabling reliable cross-instrument spectrum retrieval.

More from our Archive