TL;DR
When we ask a Vision Transformer why it made a decision using Layer-Wise Relevance Propagation (LRP), we want the "relevance" (credit) to flow backward from the output to the input pixels without disappearing. Existing methods either lose a huge chunk of this relevance inside the attention mechanism or fail to explain the query and key at all. This paper introduces two simple mathematical fixes—Softmax-IG and Bias-to-V—that plug the leaks, conserving nearly 100% of the relevance while keeping the math numerically stable.
What Problem Does This Paper Address?
Explainable AI helps us verify that models aren't cheating by using spurious "shortcuts" (like a hospital watermark on an X-ray). Layer-Wise Relevance Propagation (LRP) is a popular way to do this: it takes a model's prediction score and propagates it backward, layer by layer, like tracing a river back to its tributaries. Ideally, the total relevance at the input should equal the relevance at the output—a property called conservation.
In Transformers, however, the attention mechanism ($\text{softmax}(QK^\top)V$) has been a notorious headache for LRP. Earlier methods either:
- Conserved relevance and distributed it to queries ($Q$) and keys ($K$), but blew up numerically.
- Stayed stable by passing relevance only to the values ($V$), leaving $Q$ and $K$ completely unexplained.
- Used AttnLRP (Attention-Aware LRP), which is stable and explains $Q$ and $K$, but leaks 82–91% of the relevance inside attention.
Where does that relevance go? Prior work hypothesized two culprits in AttnLRP's softmax rule: linearization error (approximating the curved softmax function with a flat, first-order Taylor expansion) and structural bias (softmax outputs a non-zero value even when all input logits are zero, and AttnLRP drops the relevance assigned to this bias).
Methods
Building on AttnLRP, the authors introduce two new propagation rules to plug each leak:
- Softmax-IG (eliminates linearization error): Instead of taking the gradient of softmax only at the observed logits, Softmax-IG integrates the gradient along a straight-line path from zero to the input logits—a technique known as Integrated Gradients (IG). In practice, they approximate this integral with an $M$-point right Riemann sum. Conveniently, setting $M=1$ recovers the original AttnLRP rule, and as $M$ grows, the linearization error shrinks toward zero.
- Bias-to-V (eliminates structural bias): In AttnLRP, the relevance assigned to softmax's zero-logit bias ($\mathbf{b} = \text{softmax}(\mathbf{0} + C)$) is simply lost. Bias-to-V splits the attention output $YV$ into $(Y - \mathbf{b})V + \mathbf{b}V$ and routes all the relevance of $\mathbf{b}V$ directly to the value $V$, without altering the relevance reaching $Q$ or $K$.
Together, AttnLRP + Softmax-IG + Bias-to-V is proved to be numerically stable, distributes relevance to $Q$ and $K$, and conserves total relevance in Transformers.
Datasets
- ImageNet-Segmentation (4,276 images) for evaluating DeiT models on the segmentation test.
- ImageNet-S validation images (where an object covers at least 5% of the image) for evaluating seven other Vision Transformers (SigLIP, EVA2-S, DeiT3-H, ViT-L, CLIP-H, FlexiViT-L, and BEiT2-L).
- ImageNet validation set: 5,000 images for the perturbation test, 200 images for measuring relevance loss, and 50 images for timing. (Note: Appendix C also reports similar experiments on nine LLMs, though the main text focuses on the 10 ViTs.)
Key Insights and Ideas
- Plugging the leaks doesn't automatically mean "better" explanations: While combining both rules reduces attention relevance loss to 0.1–0.2%, it doesn't always beat AttnLRP on standard explanation tests.
- Softmax-IG helps most models: Fixing linearization error alone improved explanation performance on 8 out of 10 ViTs. Interestingly, the gains on DeiT-Tiny and DeiT-Small came mostly from attention rows with moderate concentration (maximum attention weight between 0.3 and 0.5), whereas highly concentrated rows ($\ge 0.9$) tended to degrade.
- Bias-to-V spreads relevance to the background: Routing the structural bias to $V$ gives equal weight ($1/n$) to all value tokens regardless of how much they actually contribute. On DeiT, this boosted background relevance by 1.86–2.52× (raising the background's share from 44–51% to 48–58%), which hurt segmentation scores on 6 of 10 ViTs.
- Maybe the test is flawed, not the explanation: The authors point out that humans look over the whole image to confirm no other object is present before making a decision. Some background relevance might reflect genuine model behavior, which the segmentation test unfairly penalizes.
Key Results
- Conservation: On DeiT (Tiny, Small, Base), attention relevance loss drops from 82.3–90.6% (AttnLRP) to 47.5–54.3% (+ Softmax-IG, $M=128$), 32.2–41.3% (+ Bias-to-V), and 0.1–0.2% (both rules combined).
- Convergence & Speed: Linearization error decreases as $O(1/M)$ (from 33–44% at $M=1$ to 0.14–0.20% at $M=128$). Segmentation scores nearly saturate by $M=16$. At $M=128$, runtime is 0.41–0.58 s per image (1.4–1.6× slower than AttnLRP's 0.26–0.42 s).
- Explanation Performance: On 10 ViTs, Softmax-IG ($M=128$) improves segmentation scores on 8/10 models, Bias-to-V degrades them on 6/10, and combining both improves 5/10 and degrades 5/10.
Limitations and Future Work
- Evaluation metrics: Standard segmentation tests treat background relevance as an error, which may mischaracterize how models actually confirm their predictions. Better evaluation metrics are needed.
- Alternative conservative rules: This work builds specifically on AttnLRP; other numerically stable ways to distribute relevance while conserving it in attention may exist and warrant comparison.
- Faster integration: Using higher-order numerical integration (like the trapezoidal rule or Gaussian quadrature) could achieve the same low linearization error with fewer steps $M$ and lower compute cost.
Summary updated