Quantifying Attention Flow in Transformers
Paper · 2020 · Samira Abnar and Willem Zuidema
Summary
A diagram of attention can seem to explain a prediction: the system gave a word a large weight, so that word must have mattered. In a deep Transformer, however, this interpretation overlooks what happens between layers. A hidden representation at a particular position no longer contains information only about the word that originally occupied that position. It has gathered information from elsewhere in the sentence. Attention directed toward that representation therefore cannot automatically be read as attention toward the original word. Samira Abnar and Willem Zuidema study this gap between attending to intermediate representations and attributing a decision to the input.
Their paper proposes attention rollout and attention flow, two ways to follow attention through the network rather than inspect a layer in isolation. Both describe the network as a graph connecting input positions and hidden representations. They also account for residual connections, which let a representation carry information forward without passing through the attention operation. Rollout treats attention weights as proportions and combines them along every route connecting a hidden representation to the input. Flow instead treats those weights as limits on how much can pass through each connection and applies a maximum-flow algorithm. The resulting scores offer different approximations of which original tokens could have contributed to a representation.
The principal experiment concerns grammatical number. An encoder receives a sentence prefix and predicts whether the following verb should be singular or plural. The task makes some attribution judgments relatively concrete: in a phrase containing a singular subject and a competing plural noun, the subject supplies the relevant agreement information. The authors train an encoder with 6 layers, 8 attention heads, and a hidden size of 128; its agreement accuracy is 0.96. They compare attention-based rankings of input words with rankings obtained by replacing words with an unknown-token marker, and with rankings derived from input gradients. Over 2000 test examples, the proposed methods agree much better with these reference measures in the deeper layers. For the final layer, correlation with the replacement-based measure is 0.29 for raw attention, 0.71 for rollout, and 0.70 for flow.
The evidence supports a useful diagnostic instead of a complete account of computation. Flow frequently agrees more closely with the reference measures, while rollout tends to concentrate its scores more narrowly. A sentiment experiment using DistillBERT gives much smaller correlations for every method, and the BERT pronoun examples provide qualitative support rather than a broad evaluation. The authors also warn that their experiments concern encoders without causal masking. Applying the methods to a left-to-right decoder would require correcting the positional advantage of earlier tokens. Their central contribution is thus a more careful way to inspect attention, accompanied by reasons to resist treating even the improved scores as definitive explanations.
Interesting ideas
Trace evidence across layers. An intermediate representation carries the history of earlier computation. A connection into that representation cannot reliably identify the original source of its contents. Rollout makes this history explicit by composing attention across the layers below the point being inspected. The reusable idea is to match an explanation to the level of the question: a question about input words requires following dependencies back to input words. This is useful wherever a system repeatedly mixes information and a visualization otherwise labels intermediate positions as though their contents had remained unchanged.
Include bypass connections. Attention is only part of the route through a Transformer block. Residual connections also preserve information at corresponding positions, so a graph built solely from attention weights omits an available path. Adding an identity contribution gives the attribution calculation a representation of that route. The broader engineering lesson is to include structural bypasses when constructing an explanation graph. A visually prominent operation may be convenient to inspect, but the surrounding architecture determines whether its weights describe all the relevant connections.
Compare strict and permissive accounts. Rollout interprets an edge weight as the proportion that must propagate through it. Flow interprets the same weight as a capacity that an attribution can use. These assumptions produce different pictures: rollout is frequently sharper, whereas flow can keep several candidate tokens prominent. Neither appearance establishes correctness. Comparing both can reveal whether a conclusion depends on a restrictive propagation assumption. This is especially useful when a diagnostic must distinguish a concentrated signal from a broader set of plausible contributors without pretending that either view proves causation.
Check explanations against interventions. A heat map can be coherent to a reader while disagreeing with the system’s response to a changed input. The authors therefore compare attention-based rankings with word replacement and with gradients. The reusable practice is to give an explanation method an independent behavioral check. In another learned component, an engineer could ask whether highly ranked inputs are also the inputs whose alteration most affects the relevant prediction. Agreement would support the diagnostic under that test; disagreement would identify a reason to investigate it.
Choose tasks with identifiable competitors. Subject–verb agreement supplies both a likely source of useful evidence and a tempting source of error. A noun with the wrong number can compete with the true subject. This makes an explanation more testable than a vague claim that a system attended to an important-looking word. Similar evaluations can be designed around a relevant input and a plausible distractor, provided their roles are established by the task. The advantage is a clearer question about what the system used, rather than a judgment based only on the attractiveness of a visualization.
Correct for structural opportunity. Earlier tokens in a causally masked network can be reached from more later positions. Their accumulated attribution can therefore reflect access permitted by the architecture as well as relevance to a particular prediction. The authors identify receptive-field normalization as necessary before transferring their methods to decoders. The general lesson is to separate importance from opportunity: when some inputs have more possible routes into a computation, an attribution scheme needs to consider whether that asymmetry alone can inflate their scores.
Deep dive: Quantifying Attention Flow in Transformers
Attention rollout and attention flow trace Transformer decisions to input words: how the methods work, what their tests show, and their limits. · about 34 minutes to read
How Mova uses it
For Mova, the small transparent language system implemented in Rust, this paper supplies a set of possible diagnostics and tests. The concrete applications concern its parsing, learning, token analysis, and generation stages. These are proposals for how Mova could use the work; there is no established implementation or measured Mova result in the account given here. The useful commitment is methodological: an explanation attached to a learned decision should be inspectable and should survive checks against the decision’s behavior.
In the tree stage, the clearest application concerns gparse. A diagnostic for an attachment could report which input words receive attribution when the parser selects a head or a dependency label. If the relevant learned component exposes self-attention, rollout could trace its attention through preceding layers before assigning scores to the original sentence. That would help answer a concrete dependency parsing question: which words appear to have contributed to this attachment decision? It could make the GPU parser easier to inspect alongside the perceptron parser.
That proposal requires care about the target being explained. The paper studies attribution from a classification representation, not from a dependency parser’s head-selection or label-selection computation. Mova would need to identify the representation associated with each decision and establish that the available attention graph connects it meaningfully to the input. A score for the whole sentence would not automatically explain an individual attachment. Nor would a high score on the chosen head establish that the parser used the right grammatical evidence. The diagnostic would still need comparison with changes to the sentence and the resulting parser scores.
Offering both rollout and flow in gparse could expose uncertainty about how evidence is distributed. A concentrated rollout map might suggest that a small part of the sentence dominates under the proportional account. A broader flow map might identify several tokens with substantial routes into the decision. This would support a useful distinction during debugging: a likely single-token dependency versus a set of plausible contributors. It would not establish that those contributors act jointly in a causal sense. The paper’s flow calculation measures available capacity to individual inputs, so a claim about token interactions would require an additional test.
In the learn stage, the strongest borrowing is the evaluation procedure. Mova could rank input tokens using an explanation method, perturb those tokens separately, and compare the ranking with the resulting changes in the relevant prediction. A rank-correlation check would turn an appealing display into a testable diagnostic. The perturbation would need to suit the component: the paper uses replacement with UNK, but the important principle is to document what was changed and what score was observed. Failure to agree would be useful evidence about the explanation, the perturbation, or both.
The tokens stage offers a more targeted test involving grammatical number. Sentences with an intervening noun of the opposite number could probe whether a tagger or morphology decision follows the actual subject. The agreement material associated with Linzen and colleagues gives the proposed test a clear structure: relevant evidence and a competing noun occur in the same input. Mova could inspect correct cases as well as failures, asking whether the attractor becomes prominent when the number decision goes wrong. These would be proposed tests, not results already demonstrated for Mova.
For the back stage, the application remains conditional. If generation eventually uses a left-to-right Transformer, any proposed attribution between meaning-graph nodes and output words would need to account for causal masking. The paper’s warning concerns the unequal access that different input positions have to later computation. It does not provide an implemented solution for graph-to-text attribution or show that attention alone captures the role of a meaning graph. Mova could adopt the normalization requirement as a condition for trusting such diagnostics, while separately validating the mapping between graph elements, attention positions, and generated words.
The problem and its context
Why an attention map can answer the wrong question
Attention assigns weights to representations that a computation combines. Visualizing those weights is convenient because they are already available inside the network. A reader can inspect a sentence, see a strong connection, and form an interpretation without training another analysis component. The difficulty is deciding what the connection means. A large weight identifies something the attention operation used heavily at that point in the computation. It does not, on its own, identify which original input supplied the information being used.
The distinction becomes more important with depth. At the input, a position has a relatively direct association with a token. After repeated attention operations, the representation at that position can contain information gathered from many tokens. Its location remains fixed, while its contents change. Naming it after the original token can therefore conceal the very mixing that makes contextual representations useful. An explanation that points to the position may accidentally attribute credit to its label rather than to the sources of its contents.
Abnar and Zuidema organize their paper around this problem of token identity. They distinguish attention to embeddings from attention to original tokens. The former is available directly from a layer’s attention matrix. The latter requires an approximation of how input information reached that layer. Their proposal leaves the trained computation intact and changes the way its attention is analyzed afterward. It does not attempt to make the hidden representations themselves easier to identify with particular tokens.
This focus also explains why a nearly uniform upper-layer attention map can be misleading. If several representations have already acquired similar task-relevant information, spreading attention across them need not imply indifference among the original words. A system can distribute its immediate attention while still relying strongly on information that entered through a particular input. Looking backward through the earlier layers may recover a more informative account of that dependence.
The interpretability debate the authors inherit
The paper places itself within the use of attention for interpretability. Its introduction connects attention-based inspection with work on translation, image captioning, sentiment classification, entailment, and the analysis of contextual representations. It cites Bahdanau and colleagues’ attention-based translation work and Attention Is All You Need as foundations of attention in neural sequence processing. These references establish the setting in which attention weights became a natural object to visualize.
The authors do not begin from the assumption that such visualization is automatically explanatory. They acknowledge the objections represented by Attention is not Explanation and Learning to Deceive with Attention-Based Explanations. At the same time, they cite Attention is not not Explanation among work supporting a more conditional assessment. Their position is that attention can be informative, but its interpretation needs both architectural care and empirical checks.
The authors also connect their observations with Is Attention Interpretable?, describing earlier evidence that attention magnitudes need not match input importance. Their contribution addresses a particular source of this mismatch: information has passed through multiple layers before the inspected attention is applied. This is narrower than resolving the entire debate about explanation. Even a perfect account of attention paths would still need assumptions about whether those paths capture the computation relevant to the prediction.
Why grammatical agreement is a useful setting
The main task comes from the agreement data introduced in Linzen and colleagues’ syntax-sensitive dependency study. The input stops before a verb, and the prediction concerns its number. This supplies a grammatical reason to expect some words to matter more than others. A subject’s number should govern agreement, while an intervening noun can offer a competing cue.
The paper illustrates the issue with a singular key followed by plural cabinets. Correct agreement depends on the key rather than the cabinets. The latter noun is an attractor because its number can pull the prediction away from the subject’s number. This makes the evaluation more informative than asking whether a highlighted word seems semantically related to the sentence. The task identifies both a useful signal and a plausible distraction.
Nonetheless, grammatical relevance and actual reliance remain different questions. A correctly classified example might still receive influence from an attractor. A mistaken example might expose a stronger reliance on the wrong noun. The authors therefore combine task knowledge with replacement tests, gradients, and inspected predictions. The grammatical setup guides interpretation, while the behavioral comparisons test whether the proposed attention scores track the trained system.
The method, step by step
Start with a decision and its attention matrices
The main experiment uses an encoder constructed from GPT-2 Transformer blocks with masking disabled. Its architecture has 6 layers and 8 attention heads, with representations of size 128. A special CLS token is added to the input, and the final representation at that position feeds the classifier. The authors connect this classification arrangement with BERT. The prediction is whether the verb following the observed prefix should be singular or plural.
The attribution question is then tied to CLS: which original sentence tokens contributed to the representation used for classification? Raw attention supplies weights from that representation to the representations immediately below it. Rollout and flow extend the analysis through the layers underneath. They can also begin from an intermediate representation, allowing the authors to compare how the diagnostic changes with depth.
The methods operate after training. They do not introduce an additional prediction objective or alter the learned attention weights used during inference. Instead, they construct derived scores from recorded attention. The authors identify a public repository named attention_flow for their implementations of the trained systems and analysis algorithms. They also use pretrained systems available through the Transformers software associated with Wolf and colleagues.
From layer attention to input attribution
The steps in order.
Represent the network as a layered graph
Each input token and each hidden representation becomes a node. Connections link a representation to the representations it attends to in the preceding layer. The graph is directed and has no cycles because these connections move backward through successive layers. Following an edge therefore means following a possible contribution toward an earlier stage of the computation.
This direction can initially seem counterintuitive. During prediction, information is computed forward from the input toward the classifier. During attribution, the analysis begins at a later representation and traces possible sources backward. A route from CLS to an input token represents a chain through which information from that token could have reached the inspected representation.
The paper uses the following graph notation:
G = (V, E)
Here, G names the graph, V is its collection of nodes, and E is its collection of directed edges. In the attention application, nodes correspond to input positions or hidden representations, while edges correspond to connections between successive layers. The notation describes the graph’s structure before specifying how its edge weights will be interpreted.
This representation already changes the question being asked. An isolated attention row describes the immediately preceding layer. A route through the graph describes a possible connection to the original input. The proposed methods differ in how they combine those routes, but both insist that the intervening layers matter.
Account for residual connections
A Transformer block contains residual routes around its attention and feed-forward components. These routes add a component’s input back to its output. If the attribution graph included only attention edges, it would omit the direct connection that carries information at the same position across a block.
The paper introduces the residual correction through a simplified expression for the attention operation:
Vˡ⁺¹ = Vˡ + W_att Vˡ
Vˡ denotes the representations entering the operation at layer l, and Vˡ⁺¹ denotes the resulting representations at the next layer. W_att is the attention-weight matrix. The first term on the right represents the residual contribution; the second represents attention-weighted mixing. This is the paper’s approximation for motivating the graph correction, rather than a complete equation for every operation inside a Transformer block.
Factoring the same expression gives:
Vˡ⁺¹ = (W_att + I)Vˡ
I is the identity matrix, which connects each position to itself. The other symbols retain their meanings. Adding I to the attention matrix therefore gives the graph a direct route between corresponding positions, alongside routes supplied by attention.
The authors then normalize the augmented matrix:
A = 0.5W_att + 0.5I
A is the attention matrix after the residual adjustment. W_att again supplies the attention weights, while I supplies the same-position connections. The coefficients 0.5 and 0.5 express the normalization used in the paper. They should not be interpreted as measured evidence that residual and attention contributions have equal influence in every representation.
This qualification matters because the graph is an approximation of information movement. It records a route that would otherwise be absent, but it does not measure every transformation applied to the vectors traveling along that route. The authors’ later caution about simplifying assumptions applies to this residual correction as well as to the propagation algorithms.
Combine heads without assuming isolation
A layer has multiple attention heads, each offering its own attention pattern. The main analysis averages the heads within each layer so that the attribution procedure receives a single matrix for that layer. This simplifies the graph and makes comparison across layers straightforward.
The appendix explains why analyzing a head independently needs care. Information from different heads is combined within the block, so following a supposedly isolated head through every lower layer would imply a separation that the architecture does not maintain. A head-specific diagnostic should retain the selected head at the layer of interest while combining information from heads in the layers below it.
The appendix writes its rollout construction as:
Ã(i, k) = A(i, k)Ā(i)
i identifies the layer being inspected, and k identifies the selected attention head. A(i, k) is the attention for that head, Ã(i, k) is the resulting head-specific rollout, and Ā(i) denotes the combined-head rollout used beneath it in the appendix’s notation. The operational point is to trace the selected head through a lower network that allows information from other heads.
The main reported experiments use head averages rather than this head-specific analysis. Consequently, their numerical findings support the combined diagnostic. They do not establish that every individual head has an equally interpretable role or that the appendix procedure isolates a head’s causal contribution.
Compute attention rollout
Rollout assumes that an edge weight describes the proportion of information passed along that connection. Under this assumption, a route’s contribution is obtained by multiplying its edge weights. A route passing through a weak connection contributes less, even if its other connections are strong.
Several routes can link the inspected representation to the same input token. Rollout adds their contributions. Matrix multiplication performs this calculation efficiently: each multiplication combines possible intermediate positions, multiplying weights along a route and adding the resulting products across routes.
The paper gives the recursive form:
Ã(lᵢ) = A(lᵢ)Ã(lᵢ₋₁) if i > j; otherwise Ã(lᵢ) = A(lᵢ) if i = j
à denotes rollout attention, while A is the layer attention used in the calculation after the residual adjustment. lᵢ identifies the current layer, and lᵢ₋₁ identifies the layer immediately below it. The index j specifies the lower endpoint of the rollout. Multiplication is matrix multiplication, and the base case ends the recursion at the selected lower layer.
For attribution to the original input, the paper sets j = 0. The resulting row for the selected representation gives scores over input positions. An upper-layer CLS representation can thus be associated with original words even when its immediate attention is spread across contextual representations.
The proportional assumption gives rollout a relatively strict interpretation. Each edge constrains the propagated contribution according to its particular weight. A token needs sufficiently weighted routes through the intervening layers to retain a large score. This helps explain the focused patterns observed in the visualizations, but focus is a consequence of the calculation rather than proof that the highlighted word alone determined the output.
Compute attention flow
Flow uses the same broad graph structure but changes the meaning assigned to an edge weight. A weight becomes a capacity: the maximum amount that the edge may carry. The selected hidden representation serves as the source, and an input token serves as the sink. A maximum-flow algorithm finds how much can pass between them while respecting the network’s constraints.
The paper denotes the edge capacities with:
C = {cᵤᵥ ∈ ℝ | eᵤ,ᵥ ∈ E and u ≠ v}
C is the collection of capacities. cᵤᵥ is the capacity of an edge from node u to node v, and eᵤ,ᵥ denotes that edge. E is the graph’s edge set, while ℝ denotes real-valued quantities. In the attention graph, the capacity assigned to a connection comes from its attention weight, including the residual adjustment used by the method.
A flow assigns a real-valued quantity to each edge:
f: E → ℝ
f is the assignment, E is the set of edges, and ℝ again indicates real values. The quantity assigned to a particular edge describes how much flow it carries. This assignment is constrained; the algorithm cannot independently fill every possible path without considering shared connections.
The first constraint is capacity:
fᵤᵥ ≤ cᵤᵥ
fᵤᵥ is the flow carried from u to v, and cᵤᵥ is that connection’s capacity. The flow cannot exceed the available capacity. The paper also requires conservation at every intermediate node: incoming flow must match outgoing flow, except at the source and sink.
These constraints explain an important difference from simply adding path bottlenecks. Along an isolated route, the smallest capacity limits how much can travel. But different routes may share an edge. Adding their independent maxima could claim more flow through the shared edge than its capacity permits. A maximum-flow algorithm coordinates the routes so that this cannot happen.
The resulting maximum value becomes the attention-flow score for the selected input token. Repeating the calculation for other input tokens yields a set of token scores. Because these are source-to-sink capacity calculations, they do not have exactly the same interpretation as rollout’s proportional accounting. Flow asks how much connectivity is available to each token under its constraints, instead of requiring propagation to follow every edge in a fixed proportion.
Compare the resulting rankings with independent signals
The authors use blank-out to estimate token importance behaviorally. Each token is replaced separately with UNK, and the analysis measures the resulting effect on the probability assigned to the correct class. This reference concerns a specific prediction score. It is not simply a count of whether the most likely class changed.
Input gradients provide another reference. They indicate sensitivity of the prediction to changes at the input representation. The paper reports correlations with gradient-derived importance, but it does not give a comparably detailed specification of the gradient aggregation in its main account. The evidence should therefore be read at the level actually reported: agreement with the authors’ input-gradient importance measure.
For both references, the authors use Spearman rank correlation. This asks whether methods order tokens similarly, instead of requiring their score magnitudes to share a scale. A high correlation supports agreement about which tokens rank above others. It does not show that the attention score numerically measures the probability change caused by replacing a word.
The correlation procedure is repeated at different layers. This is essential to the argument because raw attention and input attribution are expected to diverge as representations become more mixed. A final-layer comparison alone would show a performance difference; the layerwise comparison helps connect that difference to the paper’s proposed mechanism.
Consider the computational cost
The paper reports the following complexity for rollout:
O(d × n²)
O denotes asymptotic computational order, d is network depth, and n is the number of tokens. This is the complexity stated for the rollout calculation considered by the authors.
For flow, the reported complexity is:
O(d² × n⁴)
The symbols have the same meanings. Both procedures are polynomial in the quantities shown, but the expressions indicate substantially different scaling. The paper’s preference for methods requiring only attention weights makes them convenient to apply after training; it does not make the two calculations equally inexpensive.
These costs matter when deciding how much of a network to inspect. A diagnostic for a selected representation in a short agreement example is a different workload from extensive analysis over long sequences. The experiments establish the usefulness of the resulting scores in their tested setting, while the complexity expressions identify a practical limit on treating flow as an unrestricted replacement for every attention visualization.
Experiments and results
The agreement encoder and the reference measures
The central trained system predicts verb number from the sentence prefix. It uses 6 layers, 8 heads, and a hidden dimension of 128, with an added CLS representation supplying the classifier. The reported agreement accuracy is 0.96. That figure describes prediction performance; the attribution results measure something different.
The quantitative explanation evaluation uses 2000 examples from the test set. For each example, the authors compare the token ranking from raw attention, rollout, or flow with a reference ranking. The references are blank-out and input gradients. Thus, the experimental question is whether a diagnostic orders input tokens similarly to an intervention-based or sensitivity-based estimate.
This distinction prevents a misleading reading of the results. Rollout and flow do not achieve the agreement accuracy: they analyze a system that has already been trained. Their reported advantage lies in correlation with importance measures. No improvement to the underlying classifier’s accuracy is claimed.
Agreement with blank-out
The final-layer blank-out comparison shows a large separation between raw attention and the proposed alternatives. Rollout has the largest reported mean at this layer, while flow is close. The chart displays the mean correlations; the reported dispersion is discussed separately.
Verb number prediction, final-layer correlation with blank-out
Rollout and flow agree more closely with token replacement rankings than raw attention does.
The numbers
| System or setting | Spearman correlation |
|---|---|
| Raw attention | 0.29 |
| Attention rollout (this paper) | 0.71 |
| Attention flow | 0.70 |
Depth changes the comparison substantially. At the first layer, raw attention has a blank-out correlation of 0.69±0.27, whereas rollout and flow each have 0.32±0.26. The proposed methods therefore do not dominate at every depth. Their first-layer adjustment can reduce agreement with this particular reference.
At the next layer, the means are 0.10 for raw attention, 0.38 for rollout, and 0.44 for flow. Deeper still, the raw-attention mean becomes negative: the reported values include -0.11 and -0.09. In contrast, rollout rises through 0.51 and 0.62, while flow reaches 0.70 at both of those stages. These layerwise changes are central evidence for following the intervening attention structure.
For the final layer, the full entries are 0.29±0.39 for raw attention, 0.71±0.24 for rollout, and 0.70±0.22 for flow. The spread accompanying each mean is substantial, so an aggregate advantage should not be interpreted as a guarantee for every example. The table presents these values with ± notation without establishing that the displayed spreads are confidence intervals.
The final-layer blank-out result also qualifies the statement that flow is the more reliable method. Flow performs strongly across the deeper layers, but rollout has the slightly larger final-layer mean for this reference. The paper’s overall preference for flow rests on the broader pattern of comparisons and examples, rather than an uninterrupted lead in every reported cell.
Agreement with input gradients
The gradient comparison supplies a separate check on the same agreement system and the same test-sample count. At the final layer, flow has the largest mean correlation.
Verb number prediction, final-layer correlation with input gradients
Flow gives the strongest agreement with gradient-based token rankings in this comparison.
The numbers
| System or setting | Spearman correlation |
|---|---|
| Raw attention | 0.46 |
| Attention rollout | 0.54 |
| Attention flow (this paper) | 0.61 |
The first-layer pattern again favors raw attention. Its correlation is 0.53±0.33, compared with 0.22±0.31 for each proposed method. This reinforces the conclusion that the benefit concerns tracing through a deeper computation, instead of a universal advantage from altering any attention row.
The middle layers show a more pronounced weakness in raw attention. Reported means include -0.06 and 0.00, while rollout gives 0.39 and 0.47 at the corresponding stages. Flow gives 0.54 and 0.61. These results are consistent with the authors’ claim that immediate attention becomes a less useful guide to input importance as representations become contextualized.
At the final layer, the full values are 0.46±0.35 for raw attention, 0.54±0.31 for rollout, and 0.61±0.28 for flow. The comparison supports flow’s relative strength under this reference, while also showing that its agreement is incomplete. A diagnostic can improve on a baseline without becoming a complete explanation of the prediction.
What the agreement examples reveal
The visual analysis includes a correctly classified sentence containing an article as the subject and systems as an attractor. Changing the subject from singular to plural changes the prediction. Both rollout and flow assign substantial scores to the subject and the competing noun, whereas the higher-layer raw-attention maps are almost uniform.
This example is informative because success does not imply that the distractor has no influence. The diagnostic shows both nouns as plausible contributors even though the final answer is correct. A sharply grammatical interpretation that highlighted only the subject would miss this aspect of the observed computation.
A mistaken example contains a plural noun marker, NNS, before a later singular subject. Changing NNS to NNP changes the prediction. Rollout and flow give prominence to the earlier NNS position, making the erroneous decision more understandable. The observed intervention provides behavioral support for taking that position seriously.
The two proposed methods differ in emphasis. Rollout produces more concentrated maps. Flow distributes prominence across a broader set of heavily connected inputs. The authors regard this broader treatment as useful when several tokens remain plausible contributors, but the examples also show why the most informative visualization can depend on the case.
Sentiment classification with DistillBERT
The additional sentiment experiment uses DistilBERT, written as DistillBERT in the results table, after fine-tuning for SST-2. The paper identifies SST-2 with the sentiment task in GLUE and cites the Sentiment Treebank work for the underlying task. Its attribution evaluation uses 100 test examples and compares against input gradients.
SST-2, final-layer correlation with input gradients
The adjusted methods improve on raw attention while all correlations remain low.
The numbers
| System or setting | Spearman correlation |
|---|---|
| Raw attention | 0.09 |
| Attention rollout | 0.13 |
| Attention flow (this paper) | 0.14 |
The full final-layer entries are 0.09 ± 0.21 for raw attention, 0.13 ± 0.20 for rollout, and 0.14 ± 0.21 for flow. These are weak correlations. The appropriate conclusion is that the adjusted methods do somewhat better under this test, not that either produces strongly validated sentiment explanations.
The earlier reported layers are mixed. At the first layer, raw attention has a mean of 0.12, while both alternatives have 0.11. At another reported layer, rollout gives 0.12 and flow gives 0.11, against 0.09 for raw attention. Later, rollout reaches 0.13 and flow 0.12, against 0.08 for raw attention. The general direction favors adjustment in the deeper comparisons, but the absolute values remain small.
Masked pronouns with BERT
The BERT analysis examines coreference resolution through masked pronouns. The authors compare the probabilities assigned to his and her, then inspect attention from the masked position toward possible antecedents. The examples include an author and Sara in one case, and Mary and John in another.
In the first example, rollout and flow agree with the prediction, while the final-layer raw-attention picture does not appear consistent and changes considerably across layers. In the other example, only flow is described as consistent with the prediction. These observations demonstrate how the methods can be applied beyond the agreement classifier.
They remain qualitative observations. The paper does not report a broad pronoun-resolution accuracy evaluation for the attribution methods, a numerical faithfulness score for these examples, or evidence that the inspected associations explain every part of BERT’s decision. Their role is to illustrate diagnostic behavior in a different pretrained setting.
What the ablations show
Blank-out tests token importance, not method components
The paper includes input ablation through blank-out, but it does not provide a full component-removal study of the proposed algorithms. These are different uses of the word ablation. Replacing an input token tests the trained predictor’s behavior. Removing residual correction or changing head aggregation would test why the attribution method performs as it does.
Blank-out is valuable because it supplies a reference that is not merely another attention display. A token is altered, and the correct-class probability is observed. Comparing the resulting ranking with rollout or flow asks whether the diagnostic points toward positions whose modification has a larger effect on that score.
The test is still specific to the chosen alteration. Replacing a word with UNK changes the input in a particular way. The resulting effect can reflect the loss of the word, the presence of the replacement marker, and changes in the surrounding interpretation. The experiment supports agreement with blank-out importance; it does not establish a unique, intervention-independent ranking of words.
Layer depth is the strongest controlled comparison
The most revealing analysis keeps the trained system and reference measure fixed while inspecting attention at different layers. Raw attention performs relatively well near the input and much worse at several deeper points. Rollout and flow become more useful after their calculation has accumulated the lower-layer routes.
This pattern supports the paper’s proposed explanation for raw attention’s weakness. The problem is not simply that attention weights are always unrelated to useful evidence. Their relation to original words changes as the representations they weight become mixtures. A depth-sensitive comparison is therefore better evidence for the authors’ argument than a single attractive final-layer picture.
The shallow-layer results also expose a cost of the residual adjustment. Rollout and flow coincide at the first layer because there is no deeper path-combination distinction yet; their difference from raw attention comes from the added residual routes. Under both agreement references, this shared adjusted version correlates less well than raw attention there.
That observation prevents a blanket endorsement of the correction. It represents an architectural feature omitted by the raw graph, but the chosen weighting does not improve every measured comparison. Because the paper does not separately vary the residual contribution, the experiments cannot determine which residual weighting would be best.
Rollout versus flow tests a propagation assumption
The direct comparison between rollout and flow holds much of the analysis constant. Both use the attention graph, both account for residual routes, and both aim at original input positions. Their principal difference is how the weights constrain propagation.
Rollout’s multiplication makes weak edges consequential along every route. Flow permits any assignment that respects capacities and conservation. This relaxation can preserve several tokens as plausible contributors even when a strict proportional account would concentrate more strongly on particular paths.
The results support the usefulness of that relaxation, especially in the gradient comparisons and the qualitative pronoun cases. They do not show that capacity-based reasoning is always superior. Rollout has the larger final-layer blank-out mean in the agreement experiment, and the sentiment results are too weak to justify a sweeping choice based on faithfulness alone.
Nor should broader flow maps be read as direct evidence of interaction among tokens. A collection of inputs with high individual flow values is a collection with strong available routes. Demonstrating that their joint presence causes a prediction would require interventions on combinations, which the reported comparisons do not establish.
Number changes connect selected examples to behavior
The agreement examples include changes to noun number or noun markers that flip the prediction. These comparisons help connect a highlighted token to an observable change. The singular-to-plural change in the subject supports its relevance in a correct example. The marker change in a mistaken example supports the relevance of a misleading earlier noun.
These checks are more informative than visual inspection alone, but their scope is local. A prediction flip after changing a token does not prove that the corresponding attention score is a complete explanation. Other aspects of the representation can change at the same time, and the example does not establish the method’s reliability across the test set.
Together, the quantitative rankings and local changes provide complementary evidence. The correlations summarize behavior over many examples; the inspected changes show what that behavior can look like in a sentence. Neither replaces the other, and the paper’s strongest conclusions come from their agreement rather than from a single visualization.
Cross-task checks reveal uneven generalization
The sentiment and pronoun analyses test portability to systems and tasks beyond the trained agreement encoder. They show that the calculation is not tied to a classifier built specifically for the main experiment. Attention matrices from pretrained systems can also be processed.
The quality of the resulting explanation is a separate question. Sentiment correlations remain low, and the pronoun evidence is illustrative. These comparisons support methodological portability while limiting claims of uniformly strong attribution. Being able to compute a score on another architecture does not ensure that the score will track an independent importance measure there.
Limitations
Limits the authors explicitly identify
The authors repeatedly caution that attention weights provide an approximation to information propagation. Their graph uses a simple numerical account of connections, while the underlying network transforms vector representations through operations that the graph does not fully describe. Better correlation than raw attention is therefore evidence of a better diagnostic under the tested measures, rather than proof of a complete explanation.
They also distinguish their aim from improving the predictor. Rollout and flow do not train better attention weights, increase token identifiability inside the network, or establish improved task performance. They produce derived weights for inspection. The agreement accuracy describes the trained encoder, not an accuracy gain obtained by either diagnostic.
A further explicit limit concerns causal masking. The main analyses use encoders in which future positions are not hidden from earlier ones. In a decoder, later positions can access earlier tokens while the reverse is restricted. Accumulated paths can consequently favor tokens near the beginning even before considering the content of a particular example.
The authors state that receptive-field normalization is needed before applying the methods to such decoders. They do not present a decoder experiment demonstrating that a particular normalization solves the problem. This is a condition for future application, not a completed extension validated by the reported results.
Finally, they identify possible improvements that remain outside the experiments. One is to construct the graph from effective attention weights associated with identifiability work. Another is to adjust attention using gradient-based attribution. These suggestions acknowledge that the raw attention graph is only one possible approximation and that incorporating more of the computation could matter.
Limits visible in the evaluation
A careful reader should separate agreement with a reference measure from verified causal explanation. Blank-out and gradients capture different aspects of behavior. The former measures the effect of a specific discrete replacement; the latter concerns local sensitivity. Neither is established as an exhaustive account of why a prediction occurred.
Spearman correlation narrows the claim further. It evaluates ordering. Two methods can rank words similarly while assigning magnitudes with very different meanings. A correlation result does not show that a rollout score is a fraction of the final decision or that a flow score predicts the size of a probability change.
The reported variation across examples is also important. The ± values are often broad relative to the means. Aggregate improvement can coexist with individual failures, and the paper’s examples do not enumerate the conditions under which each method is likely to fail. A user of the diagnostic would still need to inspect cases where the reference measures and attention-based rankings disagree.
The main agreement task offers unusually clear linguistic guidance. A subject and an attractor supply an interpretable contrast. That is a strength for evaluation, but it also limits transfer. Tasks in which evidence is diffuse, redundant, or not associated with a clearly identifiable input token may be harder to assess with the same reasoning.
Limits of the graph itself
Residual correction represents a bypass with an identity matrix, but it does not measure the changing scale or content of the residual and attention contributions. The fixed normalized mixture is structurally motivated. It should not be mistaken for a learned estimate of how much each branch matters in every block.
Head averaging also discards distinctions. It can make the graph easier to analyze and avoids treating every head as an independent channel, but it may conceal opposing or specialized patterns. The appendix describes a way to inspect a selected head while combining lower layers, yet the main results do not evaluate the fidelity of that head-specific procedure.
Flow has a further interpretive boundary. Its scores describe maximum feasible source-to-sink transmission in the capacity graph. Different input tokens are evaluated through such connectivity calculations. A high score therefore says something about available routes under the approximation; it does not directly quantify the actual amount of a token’s semantic contribution to a prediction.
Rollout has the corresponding boundary on its proportional interpretation. Multiplying attention weights is mathematically appropriate for its path-summing assumption, but that assumption is not a direct measurement of vector information. A precise calculation can still rest on an incomplete description of the underlying computation.
Limits of scale and reproducibility detail
Flow’s reported complexity grows more steeply than rollout’s with sequence length and depth. The paper does not present an extensive runtime evaluation establishing its practicality across long inputs. Convenience of access to attention weights should therefore be distinguished from the cost of applying the analysis widely.
The sentiment check uses 100 test examples, and its correlations are low. The BERT pronoun analysis rests on selected examples. These experiments broaden the demonstrated applications but do not establish a universal result across tasks, architectures, or prediction types.
The training account gives important architectural settings and identifies the official implementation, but the article’s main methodological description does not specify every optimization or data-processing choice. Similarly, the gradient reference is less fully detailed than the blank-out procedure. Replication and extension would require attention to those implementation choices instead of relying only on the high-level equations.
What came after
The citation trail establishes influence more clearly than adoption
The later citation record places this work alongside research on visual Transformers, efficient attention, explanation methods, and the internal behavior of language systems. That breadth is meaningful: the question of tracing a layered representation back to its inputs is not confined to grammatical agreement. However, a citation alone does not establish that a later paper implemented rollout, used maximum flow, improved either method, or validated its assumptions.
The distinction is particularly important for this paper because it offers several things that can be cited separately. A later work might refer to the token-identity problem, the residual correction, rollout as a visualization, flow as an alternative propagation rule, or the warning against reading raw attention as explanation. Without a description of the citing paper’s use, those possibilities should remain separate.
Visual and efficient Transformer research
An Image is Worth 16x16 Words appears among the later works citing Abnar and Zuidema. Its stated subject is Transformer-based image recognition. That establishes a connection between the attention-flow paper’s citation history and visual Transformer research. It does not, on its own, establish which attribution calculation the image-recognition work used or what explanatory conclusions it drew from it.
Long Range Arena also cites the paper and concerns benchmarking efficient Transformers. This places the work in the bibliography of research focused on efficient sequence processing. The available citation information does not identify a rollout experiment, a flow comparison, or an explanation-quality result in that benchmark, so none can be attributed to it here.
These connections are useful to read with the original distinction in mind. A Transformer’s attention pattern can be relevant to both architectural analysis and input attribution, but those are different questions. The citation trail shows that the paper reached these broader discussions; it does not erase the need to identify what a particular later study actually measured.
Explanation methods and interpretability tools
The Elephant in the Interpretability Room explicitly frames a comparison between attention-based explanation and saliency methods in its title. Its citation of attention flow belongs to the debate that Abnar and Zuidema themselves treated cautiously. The relationship supported here is a shared concern with how attention should be evaluated as explanatory evidence. No particular finding about rollout or flow follows from the citation alone.
Towards Faithful Model Explanation in NLP is identified as a survey and cites this work. The connection places rollout and flow within a later literature concerned with faithfulness: whether an explanation follows the system’s actual behavior. The original paper’s comparisons against blank-out and gradients are directly relevant to that question, although the citation information does not specify the survey’s assessment of them.
Inseq concerns an interpretability toolkit for sequence generation and also appears in the citation list. This is a relevant setting for the original decoder warning. Sequence generation can require careful identification of the output being explained and the input positions available to it. The citation record does not establish that Inseq implements either proposed method or supplies the receptive-field correction requested by the original authors.
A Primer on the Inner Workings of Transformers provides another later connection. Its title places it in explanatory work about Transformer internals. Abnar and Zuidema’s distinction between a representation’s position and the origins of its information belongs naturally to that subject, but the exact role assigned to rollout or flow is not specified by the citation information.
Causal mechanisms and broader internal analysis
Interpretability at Scale concerns identifying causal mechanisms in Alpaca and cites the attention-flow paper. Its stated emphasis makes the boundary of the earlier work especially relevant: a graph-derived attribution and an identified causal mechanism are different forms of evidence. The citation establishes contact between these research areas without showing that maximum-flow scores themselves identify mechanisms.
The Hidden Attention of Mamba Models extends the citation trail to a work whose title concerns attention outside the Transformer setting studied experimentally by Abnar and Zuidema. The available information does not explain the connection’s technical form. It would therefore be unwarranted to claim that the original rollout equations transfer unchanged or that this later work validates them.
Attention Basin and Lost in the Prompt Order both place position or causal attention in their stated subjects. They also cite the paper. These are related concerns to the original warning that access patterns can bias attribution toward early tokens. Their titles and citation relationship do not establish that they derive their methods from that warning or solve the normalization problem.
The documented legacy is therefore best described at different levels of certainty. The original work supplies explicit algorithms, empirical comparisons, and architectural cautions. The later list establishes that these contributions entered a broad citation network spanning applications, tools, surveys, and internal analysis. Determining how any particular successor changed the method requires more than its title and citation relationship. That restraint preserves the paper’s own lesson: an informative connection is evidence to examine, not an explanation to accept automatically.
Institutions
Fields, topics and concepts
Shelves 4The field of science this work belongs to (OpenAlex fields).Computer Science · 19,503 worksArtificial Intelligence · 18,805 worksArts and Humanities · 17,959 worksLanguage and Linguistics · 17,789 works
Concepts 1Key ideas and methods explained on our concept pages.Transformer and attention · 30 works
Cite
Cite as Samira Abnar and Willem Zuidema. 2020. Quantifying Attention Flow in Transformers. Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics.
@inproceedings{abnar2020quantifying,
title = {{Quantifying Attention Flow in Transformers}},
author = {Samira Abnar and Willem Zuidema},
booktitle = {Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics},
year = {2020},
doi = {10.18653/v1/2020.acl-main.385},
url = {https://doi.org/10.18653/v1/2020.acl-main.385}
}References
- Marco Ancona, Enea Ceolini, Cengiz Öztireli, and Markus Gross. 2019. Gradient-Based Attribution Methods, pages 169–191. Springer International Publishing. OpenAlex ↗ · Scholar ↗
- Dzmitry Bahdanau, Kyunghyun Cho, and Yoshua Bengio. 2015. Neural machine translation by jointly learning to align and translate. In proceedings of the 2015 International Conference on Learning Representations.
- Gino Brunner, Yang Liu, Damian Pascual, Oliver Richter, Massimiliano Ciaramita, and Roger Wattenhofer. 2020. On identifiability in transformers. In International Conference on Learning Representations. OpenAlex ↗ · Scholar ↗
- Hanjie Chen and Yangfeng Ji. 2019. Improving the interpretability of neural sentiment classifiers via data augmentation. arXiv preprint arXiv:1909.04225. — arXiv:1909.04225 OpenAlex ↗ · Scholar ↗
- Kevin Clark, Urvashi Khandelwal, Omer Levy, and Christopher D. Manning. 2019. What does BERT look at? an analysis of BERT’s attention. In Proceedings of the 2019 ACL Workshop BlackboxNLP: Analyzing and Interpreting Neural Networks for NLP, pages 276–286, Florence, Italy. Association for Computationa… OpenAlex ↗ · Scholar ↗
- Andy Coenen, Emily Reif, Ann Yuan, Been Kim, Adam Pearce, Fernanda Viégas, and Martin Wattenberg. 2019. Visualizing and measuring the geometry of bert. arXiv preprint arXiv:1906.02715.
- Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. 2009. Introduction to Algorithms, Third Edition, 3rd edition. The MIT Press. OpenAlex ↗ · Scholar ↗
- Mostafa Dehghani, Stephan Gouws, Oriol Vinyals, Jakob Uszkoreit, and Łukasz Kaiser. 2019. Universal transformers. In proceedings of the 2019 International Conference on Learning Representations. OpenAlex ↗ · Scholar ↗
- Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. 2019. BERT: Pre-training of deep bidirectional transformers for language understanding. In proceedings of the 2019 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies.…
- Sarthak Jain and Byron C. Wallace. 2019. Attention is not Explanation. In proceedings of the 2019 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, pages 3543–3556. Association for Computational Linguistics.
- Jaesong Lee, Joong-Hwi Shin, and Jun-Seok Kim. 2017. Interactive visualization and manipulation of attention-based neural machine translation. In proceedings of the 2017 Conference on Empirical Methods in Natural Language Processing: System Demonstrations, pages 121–126. OpenAlex ↗ · Scholar ↗
- Tal Linzen, Emmanuel Dupoux, and Yoav Goldberg. 2016. Assessing the ability of LSTMs to learn syntax-sensitive dependencies. Transactions of the Association for Computational Linguistics, 4:521– 535.
- Danish Pruthi, Mansi Gupta, Bhuwan Dhingra, Graham Neubig, and Zachary C Lipton. 2019. Learning to deceive with attention-based explanations. arXiv preprint arXiv:1909.07913.
- Alec Radford, Jeffrey Wu, Rewon Child, David Luan, Dario Amodei, and Ilya Sutskever. 2019. Language models are unsupervised multitask learners. OpenAI Blog, 1(8). OpenAlex ↗ · Scholar ↗
- Tim Rocktäschel, Edward Grefenstette, Karl Moritz Hermann, Tomas Kocisky, and Phil Blunsom. 2016. Reasoning about entailment with neural attention. In International Conference on Learning Representations (ICLR).
- Victor Sanh, Lysandre Debut, Julien Chaumond, and Thomas Wolf. 2019. Distilbert, a distilled version of bert: smaller, faster, cheaper and lighter.
- Sofia Serrano and Noah A. Smith. 2019. Is attention interpretable? In proceedings of the 57th Annual Meeting of the Association for Computational Linguistics. Association for Computational Linguistics.
- Richard Socher, Alex Perelygin, Jean Wu, Jason Chuang, Christopher D. Manning, Andrew Ng, and Christopher Potts. 2013. Recursive deep models for semantic compositionality over a sentiment treebank. In Proceedings of the 2013 Conference on Empirical Methods in Natural Language Processing, pages 1631–…
- Shikhar Vashishth, Shyam Upadhyay, Gaurav Singh Tomar, and Manaal Faruqui. 2019. Attention interpretability across nlp tasks. arXiv preprint arXiv:1909.11218. — arXiv:1909.11218 OpenAlex ↗ · Scholar ↗
- Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Łukasz Kaiser, and Illia Polosukhin. 2017. Attention is all you need. In Advances in neural information processing systems, pages 5998–6008.
- Jesse Vig. 2019. Visualizing attention in transformer-based language models. arXiv preprint arXiv:1904.02679. — arXiv:1904.02679 OpenAlex ↗ · Scholar ↗
- Alex Wang, Amanpreet Singh, Julian Michael, Felix Hill, Omer Levy, and Samuel Bowman. 2018. GLUE: A multi-task benchmark and analysis platform for natural language understanding. In Proceedings of the 2018 EMNLP Workshop BlackboxNLP: Analyzing and Interpreting Neural Networks for NLP, pages 353–355,…
- Yequan Wang, Minlie Huang, Li Zhao, et al. 2016. Attention-based lstm for aspect-level sentiment classification. In proceedings of the 2016 conference on empirical methods in natural language processing, pages 606–615.
- Sarah Wiegreffe and Yuval Pinter. 2019. Attention is not not explanation. In proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing and the 9th International Joint Conference on Natural Language Processing (EMNLP-IJCNLP). Association for Computational Linguistics.
- Thomas Wolf, Lysandre Debut, Victor Sanh, Julien Chaumond, Clement Delangue, Anthony Moi, Pier-ric Cistac, Tim Rault, R’emi Louf, Morgan Funtowicz, and Jamie Brew. 2019. Huggingface’s transformers: State-of-the-art natural language processing. ArXiv, abs/1910.03771.
- Kelvin Xu, Jimmy Ba, Ryan Kiros, Kyunghyun Cho, Aaron Courville, Ruslan Salakhudinov, Rich Zemel, and Yoshua Bengio. 2015. Show, attend and tell: Neural image caption generation with visual attention. In proceedings of International Conference on Machine Learning, pages 2048–2057.
This page in Markdown https://md.research.elamur.ai/free/en/papers/abnar-2020-quantifying-attention-flow-transformers/