Contrastive Domain Generalization for Cross-Instrument Molecular Identification in Mass Spectrometry
Seunghyun Yoo, Sanghong Kim, Namkyung Yoon, Hwangnam Kim
TL;DR
This work tackles cross-instrument generalization in MS-based molecular identification by reframing spectral matching as cross-modal semantic alignment between MS spectra and a pretrained molecular-structure embedding space. It introduces a dual-encoder framework with a mass-spectral encoder that preserves fine-grained mass features via mass-domain transformation, intensity normalization, Gaussian Fourier projection, and orthogonal fusion, paired with a ChemBERTa-based molecular encoder and LoRA adaptation. Through InfoNCE-based cross-modal contrastive learning, the model achieves strong zero-shot performance (Hit@1 ≈ 42.2% in fixed 256-way retrieval) and robust few-shot accuracy (1-shot ≈ 88.0%, 5-shot ≈ 95.4%), along with meaningful Global retrieval capability (Hit@1 ≈ 3.6%, Hit@10 ≈ 17.6% for ~26k candidates). Findings indicate that integrating physical spectral resolution with chemically meaningful structure embeddings narrows the semantic gap and yields domain-invariant representations, enabling reliable molecular identification across heterogeneous MS instruments and unseen scaffolds. Significance lies in advancing generalization in MS-based identification, offering scalable, architecture-driven mitigation of instrument-induced distribution shifts and providing a foundation for extending cross-modal, cross-instrument frameworks to other sensing modalities.
Abstract
Identifying molecules from mass spectrometry (MS) data remains a fundamental challenge due to the semantic gap between physical spectral peaks and underlying chemical structures. Existing deep learning approaches often treat spectral matching as a closed-set recognition task, limiting their ability to generalize to unseen molecular scaffolds. To overcome this limitation, we propose a cross-modal alignment framework that directly maps mass spectra into the chemically meaningful molecular structure embedding space of a pretrained chemical language model. On a strict scaffold-disjoint benchmark, our model achieves a Top-1 accuracy of 42.2% in fixed 256-way zero-shot retrieval and demonstrates strong generalization under a global retrieval setting. Moreover, the learned embedding space demonstrates strong chemical coherence, reaching 95.4% accuracy in 5-way 5-shot molecular re-identification. These results suggest that explicitly integrating physical spectral resolution with molecular structure embedding is key to solving the generalization bottleneck in molecular identification from MS data.
