[Paper Review] Attention Meets Post-hoc Interpretability: A Mathematical Perspective
This paper provides a mathematical analysis comparing attention-based explanations with post-hoc interpretability methods (like LIME and gradients) in a single-layer multi-head attention model. It shows that while attention weights are intuitive, they fail to capture model behavior accurately—post-hoc methods reveal more reliable, non-intuitive insights by accounting for final-layer transformations and sign-sensitive contributions.
Attention-based architectures, in particular transformers, are at the heart of a technological revolution. Interestingly, in addition to helping obtain state-of-the-art results on a wide range of applications, the attention mechanism intrinsically provides meaningful insights on the internal behavior of the model. Can these insights be used as explanations? Debate rages on. In this paper, we mathematically study a simple attention-based architecture and pinpoint the differences between post-hoc and attention-based explanations. We show that they provide quite different results, and that, despite their limitations, post-hoc methods are capable of capturing more useful insights than merely examining the attention weights.
Motivation & Objective
- To resolve the debate on whether attention weights can serve as reliable model explanations by providing a theoretical foundation.
- To mathematically compare attention-based explanations with established post-hoc methods such as LIME and gradient-based approaches.
- To demonstrate that post-hoc methods capture more meaningful and accurate insights than attention weights alone, especially in capturing negative contributions and final-layer transformations.
- To derive explicit, parameter-dependent expressions for post-hoc explanations in a simplified attention model, enabling direct comparison with attention mechanisms.
- To challenge the assumption that attention weights alone are sufficient for interpretability, advocating for post-hoc methods in practice.
Proposed method
- Analyzes a single-layer, multi-head attention model with binary classification, using scaled dot-product attention and learnable query/key/value projections.
- Derives exact mathematical expressions for gradient-based explanations (Theorem 4.1), showing they depend on attention weights and value vectors.
- Derives an approximate analytical expression for LIME explanations (Theorem 5.1), showing they are affine transformations of attention-weighted values and sensitive to final-layer weights.
- Uses asymptotic analysis for large sequence lengths to approximate LIME behavior, assuming bounded norms and positive lower bounds on attention and value terms.
- Validates theoretical approximations empirically, showing strong alignment between theoretical predictions and LIME outputs on real examples.
- Introduces a theoretical framework that explicitly links post-hoc explanation methods to model parameters and input tokens, enabling direct comparison with attention mechanisms.
Experimental results
Research questions
- RQ1How do post-hoc explanation methods like LIME and gradients mathematically relate to attention weights in a single-layer attention model?
- RQ2To what extent do attention weights alone provide accurate or misleading explanations compared to post-hoc methods?
- RQ3Why do post-hoc methods such as LIME and gradients capture more meaningful insights than attention weights, and what structural aspects of the model do they reveal?
- RQ4What is the mathematical relationship between LIME explanations and the model’s parameters, particularly the final-layer weights and attention-value interactions?
- RQ5How do the theoretical approximations of post-hoc explanations compare to empirical results, and under what conditions do they hold?
Key findings
- Post-hoc methods like LIME and gradients provide fundamentally different explanations than attention weights, as shown by explicit mathematical expressions derived from model parameters.
- LIME explanations (Theorem 5.1) are approximately an affine transformation of the attention-weighted values, with a leading term proportional to αₜWₗvₜ, but also depend on the final-layer weights Wₗ.
- Unlike attention weights, which are always positive, post-hoc methods can assign negative contributions—capturing cases where attention scores are high but the model suppresses the token’s influence via final-layer weights.
- When attention-weighted values for a token and the [UNK] token are similar (αₜvₜ ≈ αₕ,ₜvₕ,ₜ), LIME explanations tend toward zero, indicating low salience, which aligns with intuitive expectations.
- Theoretical approximations for LIME are empirically validated even for moderate-length sequences (tens of tokens), suggesting practical relevance beyond asymptotic assumptions.
- The analysis reveals that attention weights alone are insufficient for accurate interpretation because they ignore the final transformation layer, which can invert or suppress the influence of high-attention tokens.
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.