TL;DR
Finding which input tokens caused a language model's generation typically requires expensive token-ablation passes or memory-heavy gradient computations. Attribution with Attention ($\text{AT}^2$) bridges the gap between speed and accuracy by treating individual attention heads as features and learning head-importance weights offline. Once trained, $\text{AT}^2$ delivers attribution quality on par with hundreds of inference-time ablations while executing faster than a single model forward pass.
What Problem Does This Paper Address?
When a language model generates an answer, we often want to know which context snippets or reasoning steps prompted specific statements—a process known as token attribution. Knowing this enables automatic citation generation, hallucination debugging, and faithfulness checks.
Existing attribution approaches face a steep trade-off:
- Ablation-based surrogate modeling directly measures influence by masking input tokens, but requires 32 to 256 forward passes per example.
- Gradient-based methods require memory- and compute-heavy backward passes.
- Raw attention mechanisms provide zero-cost artifacts during generation, but standard heuristics—like averaging attention across all layers and heads—are notoriously unfaithful explanations of model behavior.
The paper asks: Can we learn to predict the effects of ablating prior tokens directly from attention weights, amortizing the cost across all future queries?
Methods
Rather than fitting a separate linear surrogate model from scratch for every query, $\text{AT}^2$ parameterizes token influence across queries:
- Attention as Features: For $L$ layers and $H$ heads, let $\text{Attn}(X, Y, s_i)_{\ell h}$ be the average attention paid by the generated span $Y$ to source tokens $s_i$ in head $(\ell, h)$.
-
Global Linear Combination: The attribution score for source $s_i$ is defined as a weighted sum over heads: $$w_\theta(X, S, Y)_i = \sum_{\ell=1}^L \sum_{h=1}^H \theta_{\ell h} \text{Attn}(X, Y, s_i)_{\ell h}$$ where $\theta \in \mathbb{R}^{L \times H}$ are global, learnable coefficients.
-
Offline Training: The authors sample random subset ablations across 2,000 training examples (32 ablations each, totaling ~64k forward passes once per model). They optimize $\theta$ to maximize the correlation between the linear surrogate predictions and the actual logit-transformed probability drops under ablation.
- Instant Inference: At test time, attributing a new sequence requires no extra ablations—only a dot product between the stored head coefficients and extracted attention weights.
Datasets
The authors evaluate two attribution regimes across token and sentence levels:
- Context Attribution: Identifying which parts of a reference document drove the response.
- Evaluation Datasets: CNN DailyMail (summarization), HotpotQA (multi-hop QA), Natural Questions (long-context QA), and MS MARCO.
- Generic Training Set: Databricks Dolly 15k.
- Thought Attribution: A task introduced by the authors to trace a reasoning model's final response back to its generated "chain-of-thought" steps.
- Evaluation Datasets: DROP (numerical reasoning) and Global Opinions QA.
- Generic Training Set: AGIEval.
Models evaluated include Llama-3.1-8B-Instruct, Phi-3.5-mini-instruct, and DeepSeek-R1-Distill-Qwen-7B.
Key Insights and Ideas
- Attention heads have specialized attribution utility: Simply averaging attention weights dilutes useful signals. In models like Phi-3.5-mini, naive attention averaging fails completely, while $\text{AT}^2$ isolates specific middle-layer heads that track factual attribution and suppresses irrelevant heads.
- Strong out-of-distribution transfer: Coefficients learned on a generic task (e.g., Dolly 15k or AGIEval) perform nearly identically to coefficients trained on task-specific data.
- Granularity transfer: Training $\text{AT}^2$ exclusively on token-level ablations transfers smoothly to attributing sentence- or paragraph-level sources.
- Downstream context pruning: Attribution is fast enough to act as an active inference filter. Using $\text{AT}^2$ to prune distractor paragraphs in HotpotQA improved response accuracy more effectively than 32-sample ablation modeling, at a fraction of the compute.
Key Results
- Attribution Quality: On the Linear Datamodeling Score (LDS) and Top-5 log-probability drop metrics, $\text{AT}^2$ consistently outperformed both gradient $\ell_1$-norm baselines and naive attention averaging. It achieved fidelity comparable to example-specific surrogate modeling (ESM) that used 128 to 256 ablations per sample.
- Runtime Efficiency: On an NVIDIA A100 GPU running Llama-3.1-8B:
- $\text{AT}^2$ with cached attention weights ran in 0.013s.
- Recomputing attention from saved hidden states (for FlashAttention workflows) took 0.048s.
- By comparison, a single forward pass took 0.138s, a backward pass took 0.403s, and ablation baselines required $\ge 32$ forward passes ($> 4.4\text{s}$).
- Context Pruning Gains: On HotpotQA, pruning down to the top $k=2$ passages identified by $\text{AT}^2$ increased Llama-3.1-8B's F1 score by +2.3 and Phi-3.5-mini's F1 score by +3.8 over unpruned baselines.
Limitations and Future Work
- First-Order Approximation: Attention weights only capture direct token relationships and ignore non-linear interactions between multiple input sources.
- Distributional Focus vs. Sampled Output: Attention weights contribute to the full next-token output distribution rather than the specific token chosen during greedy or stochastic decoding.
- FlashAttention Overhead: Systems using FlashAttention do not materialize the attention matrix by default; obtaining weights requires recomputing query-key dot products from cached hidden states.
- Model Scope: The approach relies strictly on transformer attention mechanisms and does not directly extend to non-attention architectures (e.g., state-space models).
Summary updated