SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2005.00928 · ACL · 2020

Quantifying Attention Flow in Transformers

Samira Abnar, Willem Zuidema

arXiv · PDF · Open in the Atlas

Code that ran

2 of 8 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 1 honoured the contract we drafted, 0 violated it and 0 have no contract verdict; 1 failure of our instrument; 6 no recorded run), measured 2026-11-21; repository links from the Papers with Code archive attributed under CC BY-SA, no affiliation; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2005.00928.json · badge: /api/ran/2005.00928.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
yiyixuxu/TimeSformer-rolled-attention community
Papers with Code archive
1 ran · 2 no recorded run
mt-upc/transformer-contributions community
Papers with Code archive
1 ran · 0 no recorded run
samiraabnar/attention_flow marked official in Papers with Code
Papers with Code archive
0 ran · 1 no recorded run
copy not recorded community
not in the paper's declared repositories
0 ran · 1 no recorded run
jacobgil/vit-explain community
Papers with Code archive
0 ran · 1 no recorded run
leemsaebom/attention-guided-cam-visual-explanations-of-vision-transformer-guided-by-self-attention community
Papers with Code archive
0 ran · 1 no recorded run
FunctionStatusWhere it lives
compute_joint_attention Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
mt-upc/transformer-contributions/src/utils_contributions.py
code served (permissive licence) · get_code("b71e31585fecd495")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1) and returned Tensor, ndim 4, dtype family float, shape (3, 2, 4, 4) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

torch.manual_seed(0)

# The function expects att_mat to be a tensor with shape (layers, batch, seq_len, seq_len)
# or similar attention matrix format where:
# - att_mat[i] is indexable by layer
# - att_mat[i] can be matrix multiplied with joint_attentions[i-1]
# - unsqueeze(0) adds a dimension at position 0

# Create a small attention matrix tensor
# Shape: (num_layers, batch_size, seq_len, seq_len)
num_layers = 3
batch_size = 2
seq_len = 4

att_mat = torch.randn(num_layers, batch_size, seq_len, seq_len)

ARGS = {
    "att_mat": att_mat
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 4, dtype family float, shape (3, 2, 4, 4) — shape (3, 2, 4, 4) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
create_video_input Ran
ran, honoured the contract we drafted
yiyixuxu/TimeSformer-rolled-attention/visualize_attn_util.py
pointer only (licence: NONE) · get_code("5b7e4e55c4239a5f")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, yiyixuxu/TimeSformer-rolled-attention when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

DividedAttentionRollout Not yet run
unverified (harvested, no recorded run)
yiyixuxu/TimeSformer-rolled-attention/visualize_attn_util.py
pointer only (licence: NONE) · get_code("412f47c929382c33")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, yiyixuxu/TimeSformer-rolled-attention when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. No invocation recorded.

combine_divided_attention Not yet run
unverified (harvested, no recorded run)
yiyixuxu/TimeSformer-rolled-attention/visualize_attn_util.py
pointer only (licence: NONE) · get_code("eaadbe978c71548a")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, yiyixuxu/TimeSformer-rolled-attention when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. No invocation recorded.

compute_flows Not yet run
unverified (harvested, no recorded run)
samiraabnar/attention_flow/attention_graph_util.py
pointer only (licence: NONE) · get_code("6f25137dea73163a")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, samiraabnar/attention_flow when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. No invocation recorded.

get_frames Not yet run
unverified (harvested, no recorded run)
this paper's copy was not recorded; identical code first harvested from yiyixuxu/TimeSformer-rolled-attention
pointer only; the stored copy get_code serves, from yiyixuxu/TimeSformer-rolled-attention, is pointer only (licence: NONE) · get_code("7c6f43d2449917c6")
How it ran

The body of this sample is withheld: this paper's copy of the code was not recorded (its link names no repository or source path), so no licence was read for it. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. No invocation recorded.

rollout Not yet run
unverified (harvested, no recorded run)
jacobgil/vit-explain/vit_rollout.py
code served (permissive licence) · get_code("84871575d6e5f5d9")
How it ran

no invocation recorded.

rollout Not yet run
unverified (harvested, no recorded run)
leemsaebom/attention-guided-cam-visual-explanations-of-vision-transformer-guided-by-self-attention/Methods/AttentionRollout/AttentionRollout.py
pointer only (licence: NONE) · get_code("f06c5e0a3af9b83c")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, leemsaebom/attention-guided-cam-visual-explanations-of-vision-transformer-guided-by-self-attention when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. No invocation recorded.

Also present in other papers' code

Of 8 samples lifted from this paper's linked repositories, 8 carry a function identity and 0 do not. Of the 8 distinct functions with an identity, 2 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 2 later) and 6 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

FunctionAlso present inEarliest-datedOthers named
compute_flows
brick of this paper's assembly: entry
1 other paper
1 later
2202.07304 (2022-02)
XAI for Transformers: Better Explanations through Conservative Propagation
get_frames
brick of this paper's assembly: helper
1 other paper
1 later
2102.05095 (2021-02)
Is Space-Time Attention All You Need for Video Understanding?

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-21.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

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.

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2005.00928")
get_code_for_paper("2005.00928")
have("2005.00928")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2005.00928.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2005.00928.svg)](https://syntology.ai/paper/2005.00928)

Connect an agent — have() is free.