Double-head transformer neural network for molecular property prediction

Yuanbing Song, Jinghua Chen, Wenju Wang, Gang Chen, Zhichong MaJournal of Cheminformatics 2023 · DOI

TL;DR

Researchers have developed the Double-Head Transformer Neural Network (DHTNN), a new deep learning architecture that significantly improves the accuracy of molecular property predictions. By introducing a custom activation function called "Beaf" and a specialized transformer block, the model better captures the complex, nonlinear relationships within chemical structures, outperforming current state-of-the-art methods on major benchmarks.

What Problem Does This Paper Address?

Predicting how a molecule will behave—its toxicity, solubility, or binding affinity—is the "holy grail" of drug discovery and materials science. Traditionally, scientists used QSAR (Quantitative Structure-Activity Relationship) models, which rely on handcrafted chemical descriptors. While deep learning has automated this feature extraction, existing models often struggle with two things:

  1. Generalization of Nonlinear Features: Standard activation functions like ReLU "kill" neurons that receive negative input values, while Tanh saturates (flattens out) too quickly. This loses critical information during the training process.
  2. Feature Weighting: Molecules have intricate, multi-scale structures. Standard networks often fail to prioritize the most important "detail features" over less relevant global data.

Methods

The DHTNN framework consists of three distinct stages designed to handle molecular data more gracefully:

  • The "Beaf" Activation Function: The authors designed a new activation function, Beaf ($f(x) = x \cdot \tanh(\text{SoftPlus}(x)) - c$). Unlike ReLU, which is zero for all negative values, Beaf allows for a smooth, trainable mapping of negative values. This prevents "neuron death" and allows the model to capture subtler nonlinear patterns in molecular features.
  • Molecular Residual Encoding: The model uses a Directed Message Passing Neural Network (DMPNN) to turn molecular graphs into matrices. They integrated residual connections (skipping layers) to prevent "gradient explosion," a common problem in deep networks where errors become too large or too small to allow for effective learning.
  • Double-Head Transformer: Most transformers use "multi-head" attention. Here, the authors specifically used a double-head approach to extract features along the length and width of the molecular graph matrix separately. This allows the model to focus on intrinsic details and assign weights to features more rationally before the final prediction.

Datasets

The model was evaluated using the MoleculeNet benchmark, a gold standard in the field. The authors selected six diverse datasets covering physiology, physical chemistry, and biophysics:

  • Regression Tasks: Lipophilicity (solubility) and PDBbind (protein-ligand binding).
  • Classification Tasks: PCBA (biological activity), BACE (enzyme inhibitors), Tox21 (toxicity), and SIDER (drug side effects).

The data was split using both random splitting and scaffold splitting (a tougher test where the model must generalize to entirely new chemical families).

Key Insights and Ideas

  • Negative Values Matter: One of the most interesting "aha moments" is the realization that negative values in molecular feature vectors are not just noise—they contain signal. By using the Beaf function, which doesn't zero out negative inputs, the model retained more information, leading to a 5.8% improvement over the popular DMPNN model on lipophilicity tasks.
  • Attention is All You Need (for Chemistry): The double-head attention mechanism proved particularly powerful for large datasets. It allows the model to learn "atom-to-atom" interrelationships globally, rather than just looking at immediate neighbors in a chemical bond.
  • Stability through Residuals: The inclusion of residual blocks wasn't just a performance tweak; it was essential for convergence. It ensured that as the network grew deeper to capture more complexity, it remained mathematically stable.

Key Results

The DHTNN consistently outperformed state-of-the-art (SOTA) models like MolNet, Random Forest, and DMPNN:

  • Massive Gains on PCBA: On the PCBA dataset (the largest tested with over 400,000 samples), DHTNN improved performance by 61.4% compared to standard Feed-Forward Networks (FFN) on RDKit descriptors.
  • Regression Accuracy: For Lipophilicity, the model achieved an RMSE (Root Mean Square Error) of 0.577, lower than all other compared methods.
  • Robustness: Even under the more difficult "scaffold splitting" protocol, the model remained superior in five out of the six datasets, proving it isn't just memorizing patterns but actually learning chemical principles.

Limitations and Future Work

While the DHTNN is a significant step forward, the authors noted a few areas for improvement:

  • Tox21 Performance: Under scaffold splitting, the results on the Tox21 dataset were slightly worse than some existing models. This suggests that for certain types of toxicity data, the current attention mechanism might need further refinement.
  • 3D Information: The paper notes that many current models (including some they compared against) struggle when 3D spatial information is included. While DHTNN performs well on 2D graph representations, incorporating explicit 3D atomic coordinates could be a logical next step.
  • Computational Cost: While the transformer improves accuracy, attention mechanisms are generally more computationally expensive than simple message passing. Future work might look at optimizing the "double-head" structure for even faster inference.

Summary updated

Abstract

Existing molecular property prediction methods based on deep learning ignore the generalization ability of the nonlinear representation of molecular features and the reasonable assignment of weights of molecular features, making it difficult to further improve the accuracy of molecular property prediction. To solve the above problems, an end-to-end double-head transformer neural network (DHTNN) is proposed in this paper for high-precision molecular property prediction. For the data distribution characteristics of the molecular dataset, DHTNN specially designs a new activation function, beaf, which can greatly improve the generalization ability of the nonlinear representation of molecular features. A residual network is introduced in the molecular encoding part to solve the gradient explosion problem and ensure that the model can converge quickly. The transformer based on double-head attention is used to extract molecular intrinsic detail features, and the weights are reasonably assigned for predicting molecular properties with high accuracy. Our model, which was tested on the MoleculeNet [1] benchmark dataset, showed significant performance improvements over other state-of-the-art methods.
BibTeX
@article{song2023double,
  author = {Yuanbing Song and Jinghua Chen and Wenju Wang and Gang Chen and Zhichong Ma},
  title = {{Double-head transformer neural network for molecular property prediction}},
  journal = {Journal of Cheminformatics},
  year = {2023},
  doi = {10.1186/s13321-023-00700-4},
}
Figure