[Paper Review] BERTology Meets Biology: Interpreting Attention in Protein Language Models
This paper introduces interpretability methods to analyze attention mechanisms in protein language models, demonstrating that attention captures key biological features such as 3D protein structure, functional binding sites, and biophysical properties across layers. Across BERT, ALBERT, and XLNet models on two datasets, attention aligns significantly with contact maps (p < 0.00001), binding sites, and post-translational modifications, revealing that attention learns meaningful biological inferences from self-supervised pre-training.
Transformer architectures have proven to learn useful representations for protein classification and generation tasks. However, these representations present challenges in interpretability. In this work, we demonstrate a set of methods for analyzing protein Transformer models through the lens of attention. We show that attention: (1) captures the folding structure of proteins, connecting amino acids that are far apart in the underlying sequence, but spatially close in the three-dimensional structure, (2) targets binding sites, a key functional component of proteins, and (3) focuses on progressively more complex biophysical properties with increasing layer depth. We find this behavior to be consistent across three Transformer architectures (BERT, ALBERT, XLNet) and two distinct protein datasets. We also present a three-dimensional visualization of the interaction between attention and protein structure. Code for visualization and analysis is available at https://github.com/salesforce/provis.
Motivation & Objective
- To interpret attention mechanisms in protein-specific Transformer models (e.g., BERT, ALBERT, XLNet) to understand how they encode biological knowledge.
- To investigate whether attention in these models captures structural and functional features of proteins, such as 3D spatial proximity and binding sites.
- To compare attention-based interpretability with hidden-state representations and evaluate its consistency across multiple architectures and datasets.
- To enable scientific discovery by linking model attention to known biological features like contact maps, substitution matrices, and post-translational modifications.
- To provide open-source tools for visualizing attention in 3D protein structures to support biological insight.
Proposed method
- The authors analyze attention weights from pre-trained protein Transformers (TapeBert, ProtBERT, ProtALBERT, ProtXLNet) across multiple layers and heads.
- They quantify attention alignment with ground-truth biological annotations: contact maps (spatial proximity), binding sites, post-translational modifications (PTMs), and amino acid frequencies.
- Statistical significance is assessed using 95% confidence intervals and Bonferroni-corrected hypothesis tests against background frequencies.
- A 3D visualization tool is developed using the NGL Viewer to overlay attention weights on protein structures, enabling spatial interpretation.
- Null models (randomized attention heads) are used to establish baselines and confirm that observed attention patterns are not due to chance.
- The study compares attention patterns to the BLOSUM substitution matrix to assess similarity in amino acid preference.
Experimental results
Research questions
- RQ1Do attention heads in protein language models align with spatial proximity in 3D protein structure, as measured by contact maps?
- RQ2Do specific attention heads target known functional regions such as binding sites in enzymes like HIV-1 protease?
- RQ3Does attention progressively encode higher-level biophysical or functional properties as it deepens through network layers?
- RQ4How does attention distribution compare to known biological priors such as the BLOSUM substitution matrix?
- RQ5Are attention patterns consistent across different Transformer architectures (BERT, ALBERT, XLNet) and protein datasets?
Key findings
- Attention heads in protein Transformers show significant alignment with 3D contact maps (p < 0.00001), with top heads focusing on amino acid pairs that are distant in sequence but close in 3D space.
- Specific attention heads target known functional binding sites—e.g., head 7-1 in ProtXLNet focuses on residue 27G in HIV-1 protease, a known drug-binding site.
- Attention patterns correlate strongly with the BLOSUM substitution matrix, indicating that attention learns biologically meaningful amino acid relationships.
- The proportion of attention focused on PTMs is significantly higher than background frequency (p < 0.00001), with some heads attending to PTM sites at rates over 70%.
- Amino acid-specific attention is highly non-uniform: for example, glycine and proline receive up to 98.3% and 98.1% of attention in certain heads, respectively, far exceeding their background frequency.
- The top attention heads in standard models consistently outperform their randomized counterparts (e.g., 25.5% vs. 12.1% for alanine in TapeBert), confirming non-random, biologically relevant attention.
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.