Abstract
While Transformer models have achieved state-of-the-art performance across natural language processing tasks, they remain largely "black boxes." This paper introduces ATTATTR (Self-Attention Attribution), a novel interpretability method that utilizes Integrated Gradients to quantify the contribution of individual self-attention interactions to a model's final prediction. By moving beyond raw attention weights, ATTATTR reveals the hierarchical information flow within models like BERT, enables more effective model pruning, and identifies potent adversarial triggers that exploit spurious patterns in training data.
Introduction
The success of Transformers has sparked a surge in research aimed at understanding their internal mechanics. Previous interpretability efforts typically focus on either raw attention visualizations or feature attribution (identifying important input tokens). However, a significant gap remains: raw attention weights do not necessarily correlate with feature importance, and token-level attribution fails to explain how the model composes these tokens into higher-level semantic concepts across layers.
ATTATTR addresses this by focusing on interactions. It seeks to explain the "reasoning" path a model takes, visualizing how information is aggregated from raw text into the final classification decision.
The ATTATTR Method
ATTATTR applies the Integrated Gradients algorithm specifically to the self-attention matrices ($A$) in each layer of the Transformer.
Instead of merely observing the attention weight $A_{i,j}$ (the degree to which token $i$ attends to token $j$), ATTATTR calculates the gradient of the model's output with respect to that specific connection. By integrating these gradients along a path from a "zero attention" baseline to the actual state, the method produces an attribution score. This score represents the actual contribution of a specific interaction to the final prediction.
To make these interactions human-interpretable, the authors introduce a top-down greedy heuristic to extract the most salient interactions, organizing them into "attribution trees." These trees start at the [CLS] token—the final decision point—and branch downward to show the hierarchical aggregation of phrases and words.
Insights: Attention vs. Attribution
A primary finding of this work is that Attention $ eq$ Importance. Raw attention maps are frequently dense and noisy, containing many connections that have little to no impact on the final output. In contrast, attribution maps are significantly sparser and more directly aligned with the model's decision-making logic.
Through these visualizations, the authors observed that BERT typically performs local encoding in early layers (grouping adjacent words) and transitions to matching broader semantic patterns in deeper layers. Furthermore, the most "important" heads (those with high attribution) are consistent across similar tasks—such as Natural Language Inference (NLI) and Entailment—but vary significantly for unrelated tasks like sentiment analysis.
Experimental Results
Effective Model Pruning
The practical utility of attribution scores was demonstrated through model pruning experiments on the MNLI dataset. By ranking attention heads based on their attribution scores, the researchers could prune the model more aggressively while maintaining performance. Keeping only the top two heads per layer based on attribution allowed the model to retain approximately 97% of its original accuracy. Pruning based on raw attention scores resulted in a much more rapid decline in performance, confirming that attribution scores are a superior metric for identifying essential model components.
Adversarial Vulnerabilities
ATTATTR also revealed an over-reliance on spurious patterns. By extracting "interaction triggers"—word pairs with disproportionately high attribution scores—the authors could easily manipulate model predictions. For instance, adding the trigger "floods-ice" to a premise in the MNLI dataset caused the model's accuracy on the 'entailment' class to plummet from 82.87% to just 0.8%. This suggests that the model often "cheats" by relying on specific word interactions rather than a holistic understanding of the context.
Limitations and Future Work
While powerful, ATTATTR is a "white-box" method, requiring access to model gradients, which limits its use on proprietary APIs. Additionally, the construction of attribution trees relies on a greedy heuristic that may not capture every possible information path. Finally, calculating Integrated Gradients is computationally more expensive than simple attention visualization, requiring multiple forward and backward passes.
Future research may leverage these attribution scores to "debug" training datasets or develop more robust training objectives that discourage the model from relying on the anomalous adversarial patterns identified by ATTATTR.
Summary updated