[Paper Review] XAI for Transformers: Better Explanations through Conservative Propagation
The paper extends Layer-wise Relevance Propagation (LRP) to Transformers by introducing conservative propagation rules for attention heads and LayerNorm, addressing conservation failures of gradient-based methods, and achieving state-of-the-art explanation performance across NLP, vision, and graph domains.
Transformers have become an important workhorse of machine learning, with numerous applications. This necessitates the development of reliable methods for increasing their transparency. Multiple interpretability methods, often based on gradient information, have been proposed. We show that the gradient in a Transformer reflects the function only locally, and thus fails to reliably identify the contribution of input features to the prediction. We identify Attention Heads and LayerNorm as main reasons for such unreliable explanations and propose a more stable way for propagation through these layers. Our proposal, which can be seen as a proper extension of the well-established LRP method to Transformers, is shown both theoretically and empirically to overcome the deficiency of a simple gradient-based approach, and achieves state-of-the-art explanation performance on a broad range of Transformer models and datasets.
Motivation & Objective
- Motivate the need for explainable AI in Transformer models due to their complexity and potential fairness concerns.
- Analyze the conservation property of gradient-based explanations when applied to Transformers.
- Develop theoretically grounded, conservatively propagating LRP rules for attention heads and LayerNorm.
- Empirically validate the proposed method across NLP, vision, and graph tasks against strong baselines.
Proposed method
- Frame Gradient × Input (GI) explanations within the Layer-wise Relevance Propagation (LRP) formalism to assess conservation across Transformer modules.
- Identify Attention Heads and LayerNorm as key sources of conservation breaks in GI propagation.
- Derive conservative LRP rules for Attention Heads (AH-rule) and LayerNorm (LN-rule) by treating gating/rescaling terms as constants (detach) and applying the linear-layer LRP rule.
- Provide an easy implementation trick: compute explanations by y_j = sum_i x_i [p_ij].detach() and y_i = (x_i - E[x]) / [sqrt(epsilon+Var[x])] .detach(), then run GI to obtain explanations.
- Show that these AH and LN rules preserve conservation and yield better empirical explanations than GI across multiple datasets.
Experimental results
Research questions
- RQ1Can gradient-based explanations be made conservative in Transformer architectures to faithfully attribute predictions?
- RQ2Which Transformer components disrupt conservation for GI, and how can we modify propagation rules to address them?
- RQ3Do conservative LRP rules for attention heads and LayerNorm improve qualitative and quantitative explanation quality across NLP, vision, and graph tasks?
- RQ4How does the proposed method compare with state-of-the-art Transformer explainability approaches on standard benchmarks?
Key findings
- Conservation of GI is violated in Transformers, especially due to attention heads and LayerNorm.
- LRP with AH-rule and LN-rule maintains conservation and yields more faithful attributions than GI in experiments.
- LRP (AH+LN) consistently achieves the best AUAC (activation) and AU-MSE (pruning) across NLP and graph datasets, outperforming GI and several baselines.
- Qualitative explanations from LRP (AH) and LRP (AH+LN) focus on salient tokens or superpixels and reduce spurious emphasis on entities.
- The method scales with Transformer and Graphormer models and remains computationally efficient compared to some perturbation-based or attention-only methods.
- The approach enables bias analysis in Sentiment models (e.g., DistilBERT on SST-2) by attributing relevance to gendered names and entities without generating counterfactuals.
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.