Papers › Quantifying Attention Flow in Transformers

Quantifying Attention Flow in Transformers

2 May 2020ACL 2020 6arXiv:2005.00928archive 2025-07-28

Samira Abnar, Willem Zuidema

In the Transformer model, "self-attention" combines information from attended embeddings into the representation of the focal embedding in the next layer. Thus, across layers of the Transformer, information originating from different tokens gets increasingly mixed. This makes attention weights unreliable as explanations probes. In this paper, we consider the problem of quantifying this flow of information through self-attention. We propose two methods for approximating the attention to input tokens given attention weights, attention rollout and attention flow, as post hoc methods when we use attention weights as the relative relevance of the input tokens. We show that these methods give complementary views on the flow of information, and compared to raw attention, both yield higher correlations with importance scores of input tokens obtained using an ablation method and input gradients.

PaperPDFConference PDFCodeCode Syntology ran

In Syntology Open this paper in Syntology's Atlas, the map of the papers in Syntology's graph and their citations.

For agents, Syntology's MCP tool lists every function and class Syntology harvested from this paper and whether it ran (how to connect): get_harvested_code_for_paper(arxiv_id="2005.00928")

Code

Syntology Ran 2 of 8 code samples harvested from 5 repositories linked to this paper; 6 have no recorded run. Of those that ran: 2 ran · fixture could not drive it.

By repository: official repository: 1 sample from 1 repository, 0 ran; community (archive-listed): 6 samples from 4 repositories, 2 ran; 1 identical to code first harvested elsewhere. The run record, sample by sample. “Ran” means executed on a synthesized input, not that the code is correct or reproduces the paper.

samiraabnar/attention_flow officialmentioned in papermentioned on GitHubtf report
jacobgil/vit-explain mentioned on GitHubpytorch report
mt-upc/transformer-contributions mentioned on GitHubpytorch report
vasgaowei/TS-CAM mentioned on GitHubpytorch report
vasgaowei/ts-cam-voc mentioned on GitHubpytorch report
yiyixuxu/TimeSformer-rolled-attention mentioned on GitHubpytorch report

Repository list and official/mentioned flags are the archive's, frozen 2025-07-28. Reachability, where shown, is from one Syntology probe window (2026-09-16 to 2026-09-18); repositories not probed show nothing. GitHub stars are not tracked.

Code Syntology ran Syntology

8 samples harvested; 2 ran; 0 honoured the contract we drafted; 6 have no recorded run. Read from Syntology's graph 2026-09-24; that is when this build read the record, not when the samples ran.

2ran · fixture could not drive it
6unverified

Licence: 6 of the 8 samples are pointer only, meaning Syntology does not serve that copy's text. This page shows no code text for any sample; each one links to its file in the repository.

Harvested from 5 repositories linked to this paper, official or community; each sample names its own and says which. Some samples are identical code Syntology first harvested from another repository; for those, this paper's copy is not located and its licence is not recorded. “Ran” means the sample executed on a synthesized input. It does not mean the output is correct, and nothing here reproduces the paper's results. “Honoured” and “violated” refer to a contract Syntology drafted from the code itself; “our draft was wrong” and “fixture could not drive it” are failures of Syntology's instrument, not of the code.

Each sample ends with its code_sha256, Syntology's identity for that exact code. An agent fetches the stored sample with Syntology's MCP tool get_code(code_sha256="…") (how to connect); click an identity to copy that call.

Repository labels, per sample. official repository: The archive marks this repository official for the paper. named in the paper: The archive records that the paper mentions this repository; it is not marked official. community (archive-listed): In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper. found in paper text by Syntology: Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted. community: Not in the archive's code links for this paper; a community repository Syntology harvested. Samples from a repository marked official are listed first. Licence labels name the repository's licence as recorded at harvest. “Pointer only” means Syntology does not serve that copy's text, for one of four reasons: no licence file was found; the licence was not identified; the licence is recorded as permissive but that copy's record is not marked cleared; or the licence is outside the permissive list Syntology serves text under (MIT, Apache-2.0, BSD and similar). Some licences outside that list permit redistribution, such as WTFPL, and GPL-3.0 under its conditions; they are simply not on the list. Hover a licence label for the reason. File links open the file on GitHub at the default branch, which may have changed since the harvest.

compute_flows samiraabnar/attention_flow/attention_graph_util.py official repository unverified no licence file found · pointer only · 6f25137dea73163a · report
compute_joint_attention mt-upc/transformer-contributions/src/utils_contributions.py community (archive-listed) ran · fixture could not drive it fingerprinted Apache-2.0 (permissive) · b71e31585fecd495 · report
create_video_input yiyixuxu/TimeSformer-rolled-attention/visualize_attn_util.py community (archive-listed) ran · fixture could not drive it no licence file found · pointer only · 5b7e4e55c4239a5f · report
DividedAttentionRollout yiyixuxu/TimeSformer-rolled-attention/visualize_attn_util.py community (archive-listed) unverified no licence file found · pointer only · 412f47c929382c33 · report
combine_divided_attention yiyixuxu/TimeSformer-rolled-attention/visualize_attn_util.py community (archive-listed) unverified no licence file found · pointer only · eaadbe978c71548a · report
rollout jacobgil/vit-explain/vit_rollout.py community (archive-listed) unverified MIT (permissive) · 84871575d6e5f5d9 · report
rollout leemsaebom/attention-guided-cam-visual-explanations-of-vision-transformer-guided-by-self-attention/Methods/AttentionRollout/AttentionRollout.py community (archive-listed) unverified no licence file found · pointer only · f06c5e0a3af9b83c · report
get_frames identical code first harvested elsewhere unverified licence of this copy not recorded · 7c6f43d2449917c6 · report

Results from the paper archive 2025-07-28

No leaderboard rows for this paper in the archive.

Methods

Absolute Position EncodingsAdamAttentionBPEDense ConnectionsDropoutLabel SmoothingLayer NormalizationLinear LayerMulti-Head AttentionPosition-Wise Feed-Forward LayerReLUResidual ConnectionSoftmaxTransformer

Report a problem or propose a change · a person checks every report against the paper or source before anything changes; decisions are listed on /corrections