[Paper Review] One Transformer Can Understand Both 2D & 3D Molecular Data
This paper proposes Transformer-M, a unified Transformer-based model that jointly encodes 2D molecular graphs and 3D geometric structures using separate but shared attention channels. By dynamically activating 2D or 3D structural encodings as bias terms in self-attention mechanisms, the model achieves strong performance on both 2D and 3D molecular property prediction tasks, demonstrating generalization across modalities without architectural retraining.
Unlike vision and language data which usually has a unique format, molecules can naturally be characterized using different chemical formulations. One can view a molecule as a 2D graph or define it as a collection of atoms located in a 3D space. For molecular representation learning, most previous works designed neural networks only for a particular data format, making the learned models likely to fail for other data formats. We believe a general-purpose neural network model for chemistry should be able to handle molecular tasks across data modalities. To achieve this goal, in this work, we develop a novel Transformer-based Molecular model called Transformer-M, which can take molecular data of 2D or 3D formats as input and generate meaningful semantic representations. Using the standard Transformer as the backbone architecture, Transformer-M develops two separated channels to encode 2D and 3D structural information and incorporate them with the atom features in the network modules. When the input data is in a particular format, the corresponding channel will be activated, and the other will be disabled. By training on 2D and 3D molecular data with properly designed supervised signals, Transformer-M automatically learns to leverage knowledge from different data modalities and correctly capture the representations. We conducted extensive experiments for Transformer-M. All empirical results show that Transformer-M can simultaneously achieve strong performance on 2D and 3D tasks, suggesting its broad applicability. The code and models will be made publicly available at https://github.com/lsj2408/Transformer-M.
Motivation & Objective
- To develop a general-purpose deep learning model capable of handling both 2D molecular graphs and 3D geometric structures without architectural specialization.
- To address the limitation of existing models that are trained exclusively for one molecular data format, leading to poor zero-shot transfer across modalities.
- To enable joint learning from 2D and 3D data by designing a single model with modality-adaptive attention mechanisms.
- To demonstrate that a single neural network can effectively learn and generalize across molecular data modalities using shared parameters and modality-specific structural encodings.
Proposed method
- The model uses a standard Transformer backbone with two parallel, modality-specific channels for 2D and 3D structural encoding.
- The 2D channel employs degree encoding, shortest path distance encoding, and edge encoding as input biases to capture topological and bond features.
- The 3D channel uses Gaussian kernel-based distance encoding of 3D Euclidean distances between atoms as attention bias terms.
- During inference, only the active channel (2D or 3D) is used based on input modality, while shared attention and feed-forward layers are used across both.
- A joint training strategy enables the model to learn from 2D, 3D, or both data types in a single batch, with modality-specific channels disabled when inactive.
- The model is pre-trained on the PCQM4Mv2 dataset using a 3D position denoising objective and fine-tuned on downstream 2D and 3D datasets.
Experimental results
Research questions
- RQ1Can a single neural network architecture effectively learn meaningful representations from both 2D molecular graphs and 3D geometric structures?
- RQ2How does modality-specific structural encoding in attention mechanisms affect model generalization across molecular data formats?
- RQ3To what extent does joint pre-training on 2D and 3D data improve downstream performance on diverse molecular property prediction tasks?
- RQ4Does the use of shared parameters across modalities lead to better generalization than modality-specific models?
Key findings
- Transformer-M achieves a Pearson correlation coefficient (R) of 0.830 on the PDBBind core set, outperforming the best baseline (SIGN) and the pre-trained Graphormer model.
- On the QM9 dataset, the 2D-3D joint pre-training strategy reduces MAE by up to 30% compared to training from scratch, with improvements across all six molecular targets.
- Using DFT-generated 3D conformers leads to significant performance gains (e.g., R increase from 0.804 to 0.830), while RDKit-generated conformers yield only minor improvements.
- The model demonstrates consistent downstream performance gains when pre-trained with 3D position denoising, indicating the effectiveness of the pre-training objective for 3D molecular representation learning.
- The model maintains strong performance on 2D tasks even when trained on 3D data, showing robust cross-modal transferability.
- The ablation study confirms that modality-specific structural encodings are essential, as disabling either channel degrades performance on the corresponding modality.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.