Abstract
<title>Abstract</title> <p> Tandem mass spectrometry (MS/MS) is widely used for small-molecule structural annotation, but translating sparse fragment-ion patterns into molecular structures remains challenging because experimental spectral libraries cover only a limited portion of chemical space. Computationally predicted spectra can broaden this coverage, but searches against large-scale <italic>in silico</italic> spectral libraries can yield noisy or weakly related matches. Here we introduce SiTGen, a retrieval-augmented framework that treats predicted spectra as a searchable library of reference structures. SiTGen searches an <italic>in silico</italic> library containing 862,963 structures, reranks the retrieved candidates using spectrum- and formula-derived features, and conditions a Transformer on the query spectrum, molecular formula and prioritized references to generate candidate structures. On the MassSpecGym benchmark, SiTGen achieved exact-structure accuracies of 9.48% at top-1 and 18.74% at top-10, exceeding the reported baselines evaluated on the same split. External validation on a PFAS dataset with minimal training-set overlap and on experimentally acquired Orbitrap PRM spectra further demonstrated generalization beyond the benchmark. Together, these results indicate that combining retrieval-augmented generation with large-scale in silico spectral libraries can expand the available reference space and support more reliable use of predicted spectral information. </p>