SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2105.14850 · ACL · 2021

Cascaded Head-colliding Attention

Lingpeng Kong, Lin Zheng, Zhiyong Wu

arXiv · PDF · Open in the Atlas

Code that ran

9 of 10 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (4 of them constructed an object rather than computing a result; 1 honoured the contract we drafted, 1 violated it and 2 have no contract verdict; 5 failures of our instrument; 1 no recorded run), measured 2026-11-22; 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/2105.14850.json · badge: /api/ran/2105.14850.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
LZhengisme/CODA canonical (classifier label)
classifier basis not recorded on the link
3 ran · 0 no recorded run
pytorch/fairseq community
Papers with Code archive
4 ran · 1 no recorded run
copy not recorded community
not in the paper's declared repositories
2 ran · 0 no recorded run
FunctionStatusWhere it lives
Embedding Ran
ran; our contract draft was wrong, not the code · constructed an object; no result was computed
LZhengisme/CODA/fairseq/models/coda_transformer.py
pointer only (licence: MIT); the stored copy get_code serves, from instance-wise-ordered-transformer/iot, is pointer only (licence: NOASSERTION) · get_code("96cbb5e9ca5b6be0")
How it ran

The body of this sample is withheld: MIT, as GitHub detects it on this paper's repository, LZhengisme/CODA, is in the permissive set, but a licence decision keeps the body a pointer: the reason for that decision is not recorded with 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. A run is recorded.

Kmeans Ran
ran on a synthesized input · constructed an object; no result was computed
pytorch/fairseq/fairseq/modules/kmeans_attention.py
code served (permissive licence) · get_code("9f73b0c0fce2870d")
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, through the batch API) and returned an instance of its own class, Kmeans: the run constructed the object and did not call it, so no result was computed. The image it ran in was not recorded. If your copy returns the same type 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
import torch.nn as nn

torch.manual_seed(0)

ARGS = {
    'num_heads': 2,
    'head_dim': 4,
    'num_clusters': 3,
    'ema_decay': 0.999,
    'commitment': 0.0001,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Kmeans — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a Kmeans output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
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
KmeansAttention Ran
ran on a synthesized input · constructed an object; no result was computed
pytorch/fairseq/fairseq/modules/kmeans_attention.py
code served (permissive licence) · get_code("70d8f18adccf84c1")
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, through the batch API) and returned an instance of its own class, KmeansAttention: the run constructed the object and did not call it, so no result was computed. The image it ran in was not recorded. If your copy returns the same type 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
import torch.nn as nn

torch.manual_seed(0)

ARGS = {
    'num_clusters': 8,
    'window_size': 4,
    'num_heads': 2,
    'head_dim': 3,
    'causal': False,
    'dropout': 0.1,
    'ema_decay': 0.999,
    'commitment': 0.0001,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type KmeansAttention — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a KmeansAttention output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
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
Linear Ran
ran; our contract draft was wrong, not the code · constructed an object; no result was computed
LZhengisme/CODA/fairseq/models/coda_transformer.py
pointer only (licence: MIT); the stored copy get_code serves, from instance-wise-ordered-transformer/iot, is pointer only (licence: NOASSERTION) · get_code("8cd8cb0d1e9e63e4")
How it ran

The body of this sample is withheld: MIT, as GitHub detects it on this paper's repository, LZhengisme/CODA, is in the permissive set, but a licence decision keeps the body a pointer: the reason for that decision is not recorded with 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. A run is recorded.

default Ran
ran, violated the contract we drafted
this paper's copy was not recorded; identical code first harvested from lucidrains/routing-transformer
pointer only · get_code("27ab3e63c68fe18a")
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. A run is recorded.

ema Ran
ran, honoured the contract we drafted
pytorch/fairseq/fairseq/modules/kmeans_attention.py
code served (permissive licence) · get_code("62b973828672478f")
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, through the batch API) and returned Tensor, ndim 2, dtype family float, shape (2, 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
import torch.nn as nn

torch.manual_seed(0)

# The ema function takes three parameters: old, new, and decay
# old: can be None or a tensor (checked with exists())
# new: a tensor (used when old doesn't exist)
# decay: a scalar value for the exponential moving average coefficient

# Create sample tensors
old_tensor = torch.randn(2, 4)
new_tensor = torch.randn(2, 4)
decay_value = 0.99

ARGS = {
    "old": old_tensor,
    "new": new_tensor,
    "decay": decay_value
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
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 2, dtype family float, shape (2, 4) — shape (2, 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
is_empty Ran
ran; our contract draft was wrong, not the code
this paper's copy was not recorded; identical code first harvested from lucidrains/DALLE-pytorch
pointer only · get_code("a91aa4d3b29e189e")
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. A run is recorded.

kmeans_iter Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
pytorch/fairseq/fairseq/modules/kmeans_attention.py
code served (permissive licence) · get_code("dfbee029313fac6a")
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, through the batch API) and returned Tensor, ndim 3, dtype family float, shape (3, 6, 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
import torch.nn.functional as F

torch.manual_seed(0)

# Looking at kmeans_iter function signature:
# def kmeans_iter(x, means, buckets=None):
# 
# Required parameters:
# - x: used in x.shape and operations like scatter_add_, so needs to be a tensor
#      with shape (b, h, l, d) based on unpacking and similarity function
# - means: used in means.shape[1] to get num_clusters, shape (h, num_clusters, d)
# - buckets: optional, used in batched_bincount and expand_dim operations

# Construct x tensor: shape (batch=2, heads=3, length=5, dim=4)
b, h, l, d = 2, 3, 5, 4
x = torch.randn(b, h, l, d, dtype=torch.float32)

# Construct means tensor: shape (heads=3, num_clusters=6, dim=4)
num_clusters = 6
means = F.normalize(torch.randn(h, num_clusters, d), dim=-1)

# buckets is optional, so we can pass None to test the default case
buckets = None

ARGS = {
    "x": x,
    "means": means,
    "buckets": buckets,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
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 3, dtype family float, shape (3, 6, 4) — shape (3, 6, 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
safe_readline Ran
ran; our contract draft was wrong, not the code
LZhengisme/CODA/fairseq/binarizer.py
pointer only (licence: MIT); the stored copy get_code serves, from agi-content-generation/EKD, is pointer only (licence: NOASSERTION) · get_code("82bdf940665aeeb4")
How it ran

The body of this sample is withheld: MIT, as GitHub detects it on this paper's repository, LZhengisme/CODA, is in the permissive set, but a licence decision keeps the body a pointer: the reason for that decision is not recorded with 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. A run is recorded.

ema_inplace Not yet run
unverified (harvested, no recorded run)
pytorch/fairseq/fairseq/modules/kmeans_attention.py
code served (permissive licence) · get_code("b46ee69b75929ac8")
How it ran

no invocation recorded.

Also present in other papers' code

Of 10 samples lifted from this paper's linked repositories, 10 carry a function identity and 0 do not. Of the 10 distinct functions with an identity, 5 are also present in other papers whose code we hold (5 with at least one paper dated earlier, 3 the same month, 3 later) and 5 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
safe_readline 66 other papers
19 dated earlier, 3 the same month, 42 later, 2 same year, order not determinable
1610.02424 (2016-10)
Diverse Beam Search: Decoding Diverse Solutions from Neural Sequence Models
1802.06901 (2018-02)
Deterministic Non-Autoregressive Neural Sequence Modeling by Iterative Refinement
1904.01038 (2019-04)
FAIRSEQ: A Fast, Extensible Toolkit for Sequence Modeling
and 63 more not named here
Linear 58 other papers
16 dated earlier, 2 the same month, 40 later · 5 only as an assembly brick
1409.0473 (2014-09)
Neural Machine Translation by Jointly Learning to Align and Translate
1706.03762 (2017-06)
Attention Is All You Need
1904.01681 (2019-04)
Augmented Neural ODEs
and 55 more not named here
Embedding 29 other papers
10 dated earlier, 3 the same month, 16 later
1904.01681 (2019-04)
Augmented Neural ODEs
1906.12183 (2019-06)
Neural ODEs as the Deep Limit of ResNets with constant weights
2002.03184 (2020-02)
Time-aware Large Kernel Convolutions
and 26 more not named here
default
brick of this paper's assembly: helper
1 other paper
1 dated earlier
2003.05997 (2020-03)
Efficient Content-Based Sparse Attention with Routing Transformers
is_empty
brick of this paper's assembly: helper
1 other paper
1 dated earlier
2102.12092 (2021-02)
Zero-Shot Text-to-Image Generation

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-22.

Repositories linked to this paper

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

Abstract

Transformers have advanced the field of natural language processing (NLP) in many ways. At the heart of the Transformer architecture is the multi-head attention (MHA) mechanism which models pairwise interactions between the elements of the sequence. Despite its massive success, the current framework ignores interactions among different heads, leading to the problem that many of the heads are redundant in practice, which underutilizes the capacity of the model. To improve parameter efficiency, we re-formulate the MHA as a latent variable model from a probabilistic perspective. We present cascaded head-colliding attention (CODA) which explicitly models the interactions between attention heads through a hierarchical variational distribution. We conduct extensive experiments and demonstrate that CODA outperforms the transformer baseline, by 0.6 perplexity on Wikitext-103 in language modeling, and by 0.6 BLEU on WMT14 EN-DE in machine translation, due to its improvements on the parameter efficiency. 1

For agents

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

get_harvested_code_for_paper("2105.14850")
get_code_for_paper("2105.14850")
have("2105.14850")

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

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

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

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

Connect an agent — have() is free.