Self-Attention Attribution: Interpreting Information Interactions Inside Transformer
Yaru Hao, Li Dong, Furu Wei, Ke Xu
TL;DR
The paper introduces AttAttr, a self-attention attribution method based on integrated gradients to interpret information interactions inside Transformer models. It identifies important attention connections, constructs attribution trees to visualize information flow, and demonstrates practical uses in attention head pruning and adversarial trigger discovery on BERT. The approach reveals that attention weights do not always align with predictive contributions, enables robust head selection across homogeneous tasks, and uncovers vulnerabilities through adversarial patterns. Together, these contributions advance interpretability, model debugging, and robustness assessment for Transformer-based systems.
Abstract
The great success of Transformer-based models benefits from the powerful multi-head self-attention mechanism, which learns token dependencies and encodes contextual information from the input. Prior work strives to attribute model decisions to individual input features with different saliency measures, but they fail to explain how these input features interact with each other to reach predictions. In this paper, we propose a self-attention attribution method to interpret the information interactions inside Transformer. We take BERT as an example to conduct extensive studies. Firstly, we apply self-attention attribution to identify the important attention heads, while others can be pruned with marginal performance degradation. Furthermore, we extract the most salient dependencies in each layer to construct an attribution tree, which reveals the hierarchical interactions inside Transformer. Finally, we show that the attribution results can be used as adversarial patterns to implement non-targeted attacks towards BERT.
