Abstract
Recent advancements in computational chemistry utilize transformer-based models pre-trained on Simplified Molecular Input Line Entry System (SMILES) sequences to predict molecular properties. To improve upon existing methods, we propose MLM-FG, a molecular language model with a novel pre-training strategy that randomly masks subsequences corresponding to chemically significant functional groups. This technique compels the model to better infer molecular structures and properties by learning the context of these key units. Extensive evaluations across 11 benchmark tasks demonstrate the superiority of MLM-FG, outperforming existing SMILES- and graph-based models in 9 of the 11 tasks. Remarkably, MLM-FG surpasses even some 3D-graph-based models, highlighting its exceptional capacity for representation learning without explicit 3D structural information. These results indicate that MLM-FG effectively learns to interpret molecular properties from SMILES, offering a powerful new tool for computational chemistry and related disciplines.
Introduction
The field of computational chemistry has seen a paradigm shift with the adoption of Transformer-based architectures. By representing molecules as sequences in the Simplified Molecular Input Line Entry System (SMILES) format, researchers can leverage powerful natural language processing techniques to predict complex molecular properties. However, standard pre-training objectives often fail to account for the inherent chemical structure of these sequences.
The Challenge of Chemical Semantics
Traditional masked language modeling (MLM) randomly hides individual tokens or characters. In the context of SMILES, this approach can inadvertently split functional groups—clusters of atoms that determine a molecule's chemical behavior—into meaningless fragments. This lack of "topology awareness" prevents models from capturing the critical structural "grammar" that defines molecular activity and toxicity. The authors argue that chemistry is not random; a molecule’s behavior is often dictated by specific clusters of atoms like carboxylic acids or esters. If a random mask splits one of these groups, the model fails to learn the group's holistic chemical significance.
Methodology: The MLM-FG Framework
To address these limitations, we introduce MLM-FG (Molecular Language Model with Functional Group masking). This framework enhances standard Transformer architectures, such as RoBERTa and MoLFormer, with a chemistry-aware pre-training strategy.
The MLM-FG process consists of three primary stages:
- Functional Group Identification: Utilizing RDKit and SMARTS patterns, the model parses SMILES strings to identify chemically significant subsequences and key atom clusters.
- Adaptive Masking: Instead of random token selection, the model specifically targets these identified functional groups. The masking ratio is adaptive: if a molecule contains fewer than 10 groups, one is masked; otherwise, 10% of the groups are hidden. If no groups are found, it defaults to standard atom masking.
- Contextual Reconstruction: The model is tasked with predicting the entire masked functional group based on the remaining molecular context, forcing it to encode the relationship between the "scaffold" of the molecule and its active chemical units.
Experimental Results
MLM-FG was pre-trained on up to 100 million unlabeled SMILES strings sampled from the PubChem database and evaluated across 11 benchmark tasks from MoleculeNet, including classification (e.g., ClinTox, Tox21) and regression (e.g., ESOL, Lipo) tasks.
Performance Benchmarks
The model demonstrated broad superiority, outperforming existing SMILES-based and 2D graph-based models in 9 out of 11 tasks. Notably, MLM-FG achieved an AUC-ROC of 0.9606 on the ClinTox benchmark, significantly higher than the 0.9451 achieved by the original MoLFormer. In the ESOL regression task (solubility), the model reduced the Root Mean Square Error (RMSE) to 0.3432, representing a 41% improvement over the next best baseline.
Surpassing 3D Models
Remarkably, MLM-FG outperformed GEM, a state-of-the-art model that utilizes explicit 3D structural information during its pre-training phase. This suggests that the functional group masking strategy allows the 1D language model to implicitly capture complex spatial relationships without requiring explicit 3D coordinates.
Key Insights
- Chemistry-Awareness vs. Data Volume: MLM-FG trained on 100 million molecules often outperformed the original MoLFormer trained on 1.1 billion molecules. This suggests that the quality and relevance of the masking strategy are more critical than raw data volume.
- Implicit Geometry: Analysis of the model's attention mechanisms revealed a high correlation with physical 3D distances between atoms, confirming that the model effectively "learns" molecular geometry from textual representations.
- Pharmacophoric Understanding: The exceptional performance on toxicity tasks is attributed to the model's explicit training on functional groups, which often serve as the primary drivers of biological activity (pharmacophores).
Conclusion and Future Work
MLM-FG represents a significant step forward in molecular representation learning. By aligning the pre-training objective with chemical principles, the model achieves state-of-the-art performance with greater data efficiency. While currently limited by sequence length truncation for very large polymers, future research will explore extending this framework to chemical reaction prediction and de novo molecular design, further bridging the gap between natural language processing and computational chemistry.
Summary updated