Direct molecular formula prediction from tandem mass spectra with a multi-task-trained encoder and deterministic stoichiometric correction
Molecular formula assignment is the first step of metabolite identification from tandem mass spectra, yet deep-learning methods have repeatedly underperformed classical enumeration, reaching usable accuracy only through candidate generation and learned reranking. Here we present MStoic, a mass spectrum encoder that predicts molecular formulas directly and finalizes them with a deterministic, zero-parameter stoichiometric correction that selects a mass-consistent formula against the precursor mass (20 ppm; falling back to the closest-mass candidate when none qualifies). Every peak is embedded by soft Gaussian binning of log(m/z), Fourier features, pairwise-difference embeddings and an intensity embedding, and the encoder is trained with chemically grounded auxiliary tasks, including fragment-level supervision from computational fragmentation trees. On the multi-source Spectraverse benchmark (48,622 held-out spectra) MStoic achieves 77.8% top-1 exact-match accuracy, and 79.6% on the CASMI-2022 challenge, matching or exceeding specialized deep-learning, candidate-ranking, and rule-based baselines on every benchmark evaluated. Applying the same correction to a competing model shows that mass-based correction is a portable physical prior that amplifies rather than substitutes model capability. Factorial ablation shows that the hybrid encoding is selectively beneficial for rare-element-bearing formulas with information-dense spectra. And imposing mass conservation as a soft training loss reduces direct accuracy more than seven-fold, indicating that physical constraints in discrete chemical spaces belong in hard post-processing rather than in the training objective.
Authors
- Zhenlin Dong
- Ming Yu Gao (ORCID: https://orcid.org/0000-0002-8502-1155)
- Shang Zhang (ORCID: https://orcid.org/0009-0000-8177-2886)
Institutions
- Dongbei University of Finance and Economics (CN)
- Dalian University of Technology (CN)
- Shanghai Customs College (CN)
Publication Details
- Journal
- ChemRxiv
- Published
- 2026-10-27
- DOI
- https://doi.org/10.26434/chemrxiv.15011102/v1
- Primary Topic
- Metabolomics and Mass Spectrometry Studies
- Type
- preprint