Which chemical features are captured by ChemBERTa's attention?
Seyed Hassan Alavi, Fatameh Zare-Mirakabad, Sajjad Gharaghani
Department of Mathematics and Computer Science, Computational Biology Research Center (CBRC), Amirkabir University of Technology, Tehran, Iran. · Department of Mathematics and Computer Science, Computational Biology Research Center (CBRC), Amirkabir University of Technology, Tehran, Iran. f.zare@aut.ac.ir.
Key points
From the paper's conclusion- Together, these findings provide new insights into how molecular transformers organize chemical information and offer a pathway toward more interpretable and task-informed molecular representations.
Abstract
Transformer-based models such as ChemBERTa have demonstrated strong performance across a wide range of molecular prediction tasks by learning contextual representations from SMILES strings. Despite this success, the internal organization of the chemical and structural information learned by these models remains poorly understood. In this work, we investigate which chemical concepts, functional groups, and structural features are captured by ChemBERTa's attention mechanisms across layers and heads. To address this question, we formulate the Attention Matrix Pattern Capture (AMPC) problem and introduce two complementary algorithms: AMPC-Chem-FG, which assesses whether attention patterns reflect predefined chemical concepts and functional groups, and AMPC-Struct, which evaluates the alignment between attention patterns and three-dimensional molecular structure represented by Coulomb matrices. Using a curated dataset derived from the ZINC database, our framework identifies specialized layer-head pairs that consistently emerge as statistical outliers and exhibit strong associations with chemically meaningful features. The results reveal specialized attention patterns related to ring structures, bond types, chirality, and functional groups. Furthermore, a layer-head pair achieves approximately 65% similarity to Coulomb-matrix representations, suggesting that ChemBERTa can capture information related to three-dimensional molecular organization despite being trained solely on SMILES strings. Finally, we demonstrate that embeddings constructed from AMPC-identified attention heads can improve downstream prediction performance compared with randomly selected heads and conventional ChemBERTa representations, highlighting the practical utility of the discovered specialization. Together, these findings provide new insights into how molecular transformers organize chemical information and offer a pathway toward more interpretable and task-informed molecular representations.
Read the paper
Discussion
Science Skim's AI key points, plus readers' public thoughts
Readers' thoughts
No reader thoughts yet.
Related papers
- Ceci n ’ est pas le benzène : The Treachery of Chemical Representations in Machine Learning for Drug DiscoveryJournal of Chemical Information and Modeling · 2026
- Beyond a Single Best Representation: Target-Specific Benchmarking of Frozen Molecular Embeddings and Fingerprints for Bioactivity Prediction.ChemMedChem · 2026
- Functional-Group Knowledge Is Structured in Language Models Before It Is SpokenarXiv · 2026
- Classical structural priors improve neural molecular representations in molecule language modelsarXiv · 2026
- Weighted Views Representation with Multi-Head Coulomb Attention for Molecular Property Prediction.ACS omega · 2026
- Same molecule, Different Knowledge: Cross-Identifier Binding Failures in LLMs For chemistryarXiv · 2026