MBGen: De Novo Molecular Generation from Mass Spectra via Many-Body Enhanced Diffusion

November 12, 2025 ยท View on GitHub

This repository contains the official implementation of MBGen, proposed in our AAAI-26 paper "De Novo Molecular Generation from Mass Spectra via Many-Body Enhanced Diffusion".
MBGen introduces a many-body enhanced diffusion framework for generating molecular structures directly from mass spectra.


๐Ÿงฉ Environment Installation

We recommend using conda for environment management.

conda create -y -c conda-forge -n mbgen rdkit=2024.09.4 python=3.9
conda activate mbgen
pip install torch==2.3.1 --index-url https://download.pytorch.org/whl/cu118
pip install -e .

๐Ÿ“ฆ Dataset Download and Processing

MBGen supports pretraining on molecular graph data and fine-tuning on mass spectrum datasets. Please run the scripts in the following order to download and preprocess the datasets:

bash data_processing/00_download_fp2mol_data.sh
bash data_processing/01_download_canopus_data.sh
bash data_processing/02_download_msg_data.sh
bash data_processing/03_preprocess_fp2mol.sh

๐Ÿš€ Training and Evaluation


๐Ÿ”ง Decoder Pretraining

Run the following command to pretrain the molecular decoder:

python fp2mol_main.py

๐ŸŽฏ Finetuning on Mass Spectrum Data

Run the following command to fine-tune the model for molecule generation from MS data:

python spec2mol_main.py