Attention Meets Post-hoc Interpretability: A Mathematical Perspective
Gianluigi Lopardo, Frederic Precioso, Damien Garreau
TL;DR
The paper tackles whether attention weights in Transformer-like architectures provide faithful explanations or if post-hoc explainers offer better insight. It analyzes a simple single-layer, multi-head attention classifier for binary sentiment classification and derives explicit forms for $\nabla_{e_t} f(x)$ and $\beta^\infty_j$ that relate to the attention weights $\alpha_t^{(i)}$ and to the linear layers $W_\ell^{(i)}, W_v^{(i)}, W_k^{(i)}$. The main finding is that gradient-based and LIME explanations encode substantial information from the forward path beyond what attention weights reveal, with LIME producing an affine-like transformation of attention under certain conditions. The results clarify limitations of attention as explanations, emphasize the value of post-hoc methods, and outline future work to extend the analysis to deeper architectures and other domains.
Abstract
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.
