MultiModalSpectralTransformer is a transformer-based architecture that integrates various spectroscopic modalities (NMR, HSQC, COSY, IR) for automated molecular structure prediction, complete with a data generation pipeline and user-friendly HTML interface.
Implementation of the following publication:
Advancing Structure Elucidation with a Flexible Multi-Spectral AI Model
Publication:
- Preprint: ChemRxiv
- Data Repository part 1: Zenodo
- Data Repository part 2: Zenodo
- Data Repository part 3: Zenodo
This project requires significant computational resources:
- GPU: A high-performance GPU is necessary. We recommend using an NVIDIA GPU with CUDA 11.1 support (e.g., NVIDIA V100 or K80).
- Memory: At least 16GB RAM to handle datasets and model training.
- Storage: At least 50GB storage space for datasets, model checkpoints, and results.
- Python: Python 3.7.x is required (tested with Python 3.7.12).
Please ensure your system meets these requirements before proceeding with the installation and usage of MultiModalSpectralTransformer.
Detailed instructions on how to use the software, including the full improvement cycle workflow and the HTML GUI interface, are provided in the Electronic Supplementary Information (ESI) of the paper. Please refer to Section 3 of the ESI for a comprehensive user manual.
The ESI contains:
- Step-by-step guide for data preparation
- Instructions for model training and fine-tuning
- Tutorial on using the improvement cycle
- Guide for interpreting model outputs and explanations
- Troubleshooting tips and best practices
Before using this software, you need to download the necessary data and pre-trained models from our Zenodo repository: https://doi.org/10.5281/zenodo.14712886
You'll need to download the following files:
- Models (Required): Download
models.zipand extract its contents into themodelsdirectory of this repository - Data (Required): Download
data.zipand extract its contents into thedatadirectory of this repository - Experiment Data (Required for Reproducibility): Download experiment data and place it in the
experimentdirectory to reproduce the figures and results from the paper - Extra Assets (Optional): Additional resources for extended functionality
After cloning the repository and adding the required data and models, your folder structure should look like this:
MultiModalSpectralTransformer
│
├── 📁 AI_docs # Documentation related to the AI model
├── 📁 chemprop-IR # IR spectrum prediction model
├── 📁 data # All datasets (download from Zenodo)
│ ├── 📁 IBM_dataset
│ ├── 📁 PubChem_dataset
│ ├── 📁 test_data
│ ├── 📁 ZINC_4000
│ └── 📁 ZINC_dataset
├── 📁 deep-molecular-optimization # Molecule optimization code
├── 📁 dump # Temporary files and outputs
├── 📁 experiments # General experiment outputs
├── 📁 HSQC_results # Results specific to HSQC experiments
├── 📁 MMT_website # Web interface files
├── 📁 models # Pre-trained models (download from Zenodo)
│ ├── 📁 chemprop-ir
│ ├── 📁 mmst
│ ├── 📁 mol2mol
│ ├── 📁 sgnn
├── 📁 nmr_sgnn_norm
├── 📁 past_experiments / ChemXriv # Notebooks and data to reproduce paper experiments
│ ├── 📁 0.0_Experiment_Training_Strategy
│ ├── 📁 1.0_Experiment_Trainings_Experiments
│ └── 📁 ... (and other experiment folders)
├── 📁 scripts # Utility scripts
├── 📁 utils_MMT # Core utilities and functions
└── [Various notebooks] # Jupyter notebooks for different tasks
Ensure all downloaded files are placed in their respective directories as shown above.
The project includes several Jupyter notebooks for different purposes:
-
1.0_Experiment_Notebook.ipynb
- This notebook is used to reproduce the experiments.
-
2.0_NMR_Data_Generation.ipynb
- This notebook is used to generate simulated NMR data using the SGNN network.
- Link to SGNN paper
-
3.0_Chemprop_IR_Data_Generation.ipynb
- This notebook is used to produce simulated IR data using the Chemprop-IR network.
- Link to Chemprop-IR paper
-
4.0_Explainability_plot.ipynb
- Visualizes molecules with color-coded atoms showing probabilities
- Creates SVGs, labels, and SMILES string visualizations
- Supports colored and non-colored molecule rendering from pickle files
Please refer to these notebooks for detailed procedures on data generation and experiment reproduction.
- Conda: Ensure you have Conda installed on your system.
- CUDA: CUDA 11.1 is required for the GPU acceleration (required for PyTorch).
-
Clone the Repository:
git clone https://github.com/your-username/MultiModalSpectralTransformer.git cd MultiModalSpectralTransformer -
Download Required Data and Models: Download the necessary files from our Zenodo repository:
- https://doi.org/10.5281/zenodo.16076914
- https://doi.org/10.5281/zenodo.16257786
- https://doi.org/10.5281/zenodo.16283829
# Create directories if they don't exist mkdir -p data models past_experiments # Extract data files (after downloading all data.tar.xz.part* files) cat data.tar.xz.part* > data.tar.xz tar -xJf data.tar.xz -C data/ rm data.tar.xz # Extract model files (after downloading all models.tar.xz.part* files) cat models.tar.xz.part* > models.tar.xz tar -xJf models.tar.xz -C models/ rm models.tar.xz # Extract past experiments files (after downloading all past_experiments.tar.xz.part* files) cat past_experiments.tar.xz.part* > past_experiments.tar.xz tar -xJf past_experiments.tar.xz -C past_experiments/ rm past_experiments.tar.xz
-
Environment Setup: We provide an installation script that sets up all the necessary dependencies:
# Create a new conda environment conda create -y -c conda-forge -n NMR_Structure_Elucidator python=3.7.12 # Activate the environment conda activate NMR_Structure_Elucidator # Run the installation script bash installs.sh
The
installs.shscript will install all required packages including PyTorch, RDKit, and other dependencies needed for the project. -
Verify Installation: Test that the environment is properly set up by running one of the simpler notebooks:
jupyter lab
Then open one of the notebooks to verify functionality.
-
Start the Web Application:
cd MMT_website python app.py -
Access the Application: Open your web browser and navigate to
http://127.0.0.1:5000/.
We provide several Jupyter notebooks for different aspects of the workflow:
-
Run Jupyter Lab:
jupyter lab
-
Select a Notebook:
1.0_Experiment_Notebook.ipynb- For running experiments and evaluating results2.0_Automatic_NMR_Data_Generation.ipynb- For generating synthetic NMR data3.0_Chemprop_IR_Data_Generation_.ipynb- For generating IR spectral data4.0_Explainability_plot.ipynb- For visualizing model interpretations
-
CUDA/GPU Issues:
- Error:
CUDA error: no kernel image is available for execution on the device - Solution: Ensure your CUDA version matches the requirements (CUDA 11.1) and that your GPU drivers are up to date.
- Error:
-
Missing Data Files:
- Error:
FileNotFoundError: [Errno 2] No such file or directory: 'data/...' - Solution: Make sure you've downloaded and extracted all required data files from Zenodo to the correct locations.
- Error:
-
Python Environment Issues:
- Error:
ModuleNotFoundError: No module named 'xxx' - Solution: Double-check that all dependencies are installed in your conda environment. Run
pip listto verify.
- Error:
-
Model Loading Errors:
- Error:
torch.nn.modules.module.ModuleAttributeError: 'xxx' object has no attribute 'xxx' - Solution: Ensure you're using the correct model files from Zenodo and that they match the expected format.
- Error:
-
Accessing Web Interface on Remote Servers:
- Issue: When running the application on a remote or virtual node, you can't access the web interface via browser.
- Solution: Set up SSH port forwarding to tunnel the application port from the remote server to your local machine:
This command forwards port 5000 on the remote server to port 5000 on your local machine, allowing you to access the web interface by visiting
ssh -L 5000:localhost:5000 <username>@<node>
http://localhost:5000in your browser. - Note: Make sure your SSH connection remains active while using the web interface. For persistent connections, consider using tools like
tmuxorscreenon the remote server.
If you encounter persistent issues, please check the GitHub repository for updated troubleshooting guidance or open an issue with detailed information about your problem.
We welcome contributions to improve the MultiModalSpectralTransformer. Please fork the repository and submit a pull request.
This project is licensed under the Creative Commons Attribution-NonCommercial (CC BY-NC) License. For more details, see the LICENSE file.
