SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2108.12409 · 2021

Train Short, Test Long: Attention with Linear Biases Enables Input Length Extrapolation

Mike Lewis, Noah Smith, Ofir Press

arXiv · PDF · Open in the Atlas

Code that ran

16 of 16 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (6 of them constructed an object rather than computing a result; 4 honoured the contract we drafted, 0 violated it and 9 have no contract verdict; 3 failures of our instrument; 0 no recorded run), measured 2026-11-22; 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/2108.12409.json · badge: /api/ran/2108.12409.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
ofirpress/attention_with_linear_biases canonical (classifier label)
classifier basis: census
4 ran · 0 no recorded run
answerdotai/modernbert community
Papers with Code archive
5 ran · 0 no recorded run
jaketae/alibi community
Papers with Code archive
4 ran · 0 no recorded run
lucidrains/PaLM-jax community
Papers with Code archive
2 ran · 0 no recorded run
brkkaya/a_linear_attention_with_biases community
Papers with Code archive
1 ran · 0 no recorded run
FunctionStatusWhere it lives
ALiBiConfig Ran
ran on a synthesized input · constructed an object; no result was computed
jaketae/alibi/alibi/attention.py
code served (permissive licence) · get_code("678123248e9a2d53")
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, ALiBiConfig: 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_layers": 6,
    "d_model": 256,
    "num_heads": 8,
    "max_len": 256,
    "dropout": 0.1,
    "causal": True,
    "expansion_factor": 1,
}
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 ALiBiConfig — 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 ALiBiConfig 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
ALiBiMultiHeadAttention Ran
ran on a synthesized input
jaketae/alibi/alibi/attention.py
code served (permissive licence) · get_code("8099385f6961bb81")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) and returned Tensor, ndim 3, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim 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 math
from torch import nn
from torch.nn import functional as F
from dataclasses import dataclass

@dataclass
class ALiBiConfig:
    num_layers: int = 6
    d_model: int = 256
    num_heads: int = 8
    max_len: int = 256
    dropout: float = 0.1
    causal: bool = True
    expansion_factor: int = 1

def get_alibi_slope(num_heads):
    x = (2 ** 8) ** (1 / num_heads)
    return torch.tensor([1 / x ** (i + 1) for i in range(num_heads)]).unsqueeze(-1).unsqueeze(-1)

def get_relative_positions(seq_len: int) -> torch.tensor:
    x = torch.arange(seq_len)[None, :]
    y = torch.arange(seq_len)[:, None]
    return x - y

class ALiBiMultiHeadAttention(nn.Module):

    def __init__(self, config: ALiBiConfig) -> None:
        super().__init__()
        self.causal = config.causal
        self.num_heads = config.num_heads
        self.scale = math.sqrt(config.d_model)
        self.dropout = nn.Dropout(config.dropout)
        self.register_buffer('m', get_alibi_slope(self.num_heads))
        self.kqv = nn.Linear(config.d_model, 3 * config.d_model, bias=False)
        if config.causal:
            self.register_buffer('mask', torch.tril(torch.ones(1, 1, config.max_len, config.max_len)))

    def forward(self, x: torch.tensor) -> torch.tensor:
        batch_size, seq_len, _ = x.shape
        key, query, value = self.kqv(x).chunk(3, dim=-1)
        key = key.view(batch_size, seq_len, self.num_heads, -1).permute(0, 2, 3, 1)
        query = query.view(batch_size, seq_len, self.num_heads, -1).transpose(1, 2)
        value = value.view(batch_size, seq_len, self.num_heads, -1).transpose(1, 2)
        bias = (self.m * get_relative_positions(seq_len)).unsqueeze(0)
        score = torch.matmul(query, key) / self.scale + bias
        if self.causal:
            score = score.masked_fill(self.mask[:, :, :seq_len, :seq_len] == 0, float('-inf'))
        attn = F.softmax(score, dim=-1)
        out = torch.matmul(attn, value)
        out = out.transpose(1, 2).reshape(batch_size, seq_len, -1)
        out = self.dropout(out)
        return out

config = ALiBiConfig(
    num_layers=2,
    d_model=8,
    num_heads=4,
    max_len=16,
    dropout=0.1,
    causal=True,
    expansion_factor=1
)

INIT_ARGS = {
    'config': config
}

ARGS = {
    'x': torch.randn(2, 5, 8)
}
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
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 — no output shape is stated: observe_signature.py observed this class with its constructor sizes canonicalised where it could, which the node does not record, so its shape is not stated as this setup block's
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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
AliBiAttention Ran
ran on a synthesized input · constructed an object; no result was computed
brkkaya/a_linear_attention_with_biases/models/alibi_attn.py
pointer only (licence: NONE) · get_code("12ef66be25ef338d")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, brkkaya/a_linear_attention_with_biases 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.

BertAlibiUnpadSelfAttention Ran
ran on a synthesized input · constructed an object; no result was computed
answerdotai/modernbert/src/bert_layers/attention.py
code served (permissive licence) · get_code("201cc87ee9341bc1")
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, BertAlibiUnpadSelfAttention: 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)

class Config:
    def __init__(self):
        self.hidden_size = 16
        self.num_attention_heads = 4
        self.attention_probs_dropout_prob = 0.1
        self.deterministic_fa2 = False

ARGS = {
    'config': Config()
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
einops, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type BertAlibiUnpadSelfAttention — 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 BertAlibiUnpadSelfAttention 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
GatedLinear Ran
ran on a synthesized input
ofirpress/attention_with_linear_biases/fairseq/modules/downsampled_multihead_attention.py
pointer only (licence: MIT) · get_code("ca6cbbd64821d7fa")
How it ran

The body of this sample is withheld: MIT, as GitHub detects it on this paper's repository, ofirpress/attention_with_linear_biases, 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.

IndexFirstAxis Ran
ran on a synthesized input · constructed an object; no result was computed
answerdotai/modernbert/src/bert_layers/attention.py
code served (permissive licence) · get_code("06c2a55caabae8b8")
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, IndexFirstAxis: 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

torch.manual_seed(0)

# IndexFirstAxis.forward expects:
# - ctx: autograd context (handled by torch.autograd.Function)
# - input: (b, ...) 2+ dimensional tensor
# - indices: (num_idx) 1D tensor with values in range [0, b)

# Create a small input tensor with shape (batch=2, height=3, width=4)
input_tensor = torch.randn(2, 3, 4, requires_grad=True)

# Create indices tensor selecting which elements from first axis to gather
# indices should have values in [0, 2) since first axis has size 2
indices_tensor = torch.tensor([0, 1], dtype=torch.long)

ARGS = {
    "input": input_tensor,
    "indices": indices_tensor,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
einops, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type IndexFirstAxis — 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 IndexFirstAxis 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
IndexPutFirstAxis Ran
ran on a synthesized input · constructed an object; no result was computed
answerdotai/modernbert/src/bert_layers/attention.py
code served (permissive licence) · get_code("1760a9fa00a33980")
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, IndexPutFirstAxis: 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

torch.manual_seed(0)

# IndexPutFirstAxis.forward takes:
# - ctx: autograd context (handled internally)
# - values: torch.Tensor with ndim >= 2
# - indices: torch.Tensor with ndim == 1
# - first_axis_dim: int specifying output first dimension

# Create a small values tensor with ndim >= 2
# Using shape (2, 4) - batch of 2, feature dim of 4
values = torch.randn(2, 4)

# Create indices tensor with ndim == 1
# Indices should index into first_axis_dim
# Let's say first_axis_dim is 5, so indices should be in range [0, 4]
indices = torch.tensor([1, 3], dtype=torch.long)

# first_axis_dim should be >= max(indices) + 1
first_axis_dim = 5

ARGS = {
    "values": values,
    "indices": indices,
    "first_axis_dim": first_axis_dim
}
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 IndexPutFirstAxis — 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 IndexPutFirstAxis 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 on a synthesized input · constructed an object; no result was computed
ofirpress/attention_with_linear_biases/fairseq/modules/downsampled_multihead_attention.py
pointer only (licence: MIT) · get_code("77d359c7acb72d6a")
How it ran

The body of this sample is withheld: MIT, as GitHub detects it on this paper's repository, ofirpress/attention_with_linear_biases, 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.

augmented_memory Ran
ran on a synthesized input
ofirpress/attention_with_linear_biases/fairseq/models/speech_to_text/modules/augmented_memory_attention.py
pointer only (licence: MIT) · get_code("1769a89f798d0556")
How it ran

The body of this sample is withheld: MIT, as GitHub detects it on this paper's repository, ofirpress/attention_with_linear_biases, 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.

calc_alibi_bias Ran
ran, honoured the contract we drafted
lucidrains/PaLM-jax/palm_jax/palm_lite.py
code served (permissive licence) · get_code("076a228889dcba7c")
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 ndarray, ndim 3, dtype family float, shape (4, 1, 8) 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 numpy as onp
from math import log2, floor

# The function calc_alibi_bias takes two parameters:
# - seq_len: an integer representing sequence length
# - heads: an integer representing number of attention heads

# Looking at the function body:
# - seq_len is used in onp.arange(seq_len), so it needs to be a positive integer
# - heads is passed to get_alibi_slopes(heads), which uses log2 and floor operations
#   and expects an integer

# Create small but distinct values for the two parameters
seq_len = 8
heads = 4

ARGS = {
    "seq_len": seq_len,
    "heads": heads,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
einops, numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ndarray, ndim 3, dtype family float, shape (4, 1, 8) — shape (4, 1, 8) 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
get_alibi_slope Ran
ran, honoured the contract we drafted
jaketae/alibi/alibi/attention.py
code served (permissive licence) · get_code("aa08d318b01ec8ef")
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 (8, 1, 1) 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)

def get_alibi_slope(num_heads):
    x = (2 ** 8) ** (1 / num_heads)
    return torch.tensor([1 / x ** (i + 1) for i in range(num_heads)]).unsqueeze(-1).unsqueeze(-1)

ARGS = {
    "num_heads": 8
}
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 (8, 1, 1) — shape (8, 1, 1) 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
get_alibi_slopes Ran
ran, honoured the contract we drafted
lucidrains/PaLM-jax/palm_jax/palm_lite.py
code served (permissive licence) · get_code("0e4286158fe03dff")
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 list, ndim 1, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim 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
from math import log2, floor

def get_alibi_slopes(heads):

    def get_slopes_power_of_2(n):
        start = 2 ** (-2 ** (-(log2(n) - 3)))
        ratio = start
        return [start * ratio ** i for i in range(n)]
    if log2(heads).is_integer():
        return get_slopes_power_of_2(heads)
    closest_power_of_2 = 2 ** floor(log2(heads))
    return get_slopes_power_of_2(closest_power_of_2) + get_slopes_power_of_2(2 * closest_power_of_2)[0::2][:heads - closest_power_of_2]

ARGS = {
    "heads": 8
}
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 list, ndim 1, dtype family float — a list output has no array shape of its own; none is stated
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
get_relative_positions Ran
ran, honoured the contract we drafted
jaketae/alibi/alibi/attention.py
code served (permissive licence) · get_code("69e643285942e484")
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 int, shape (5, 5) 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)

ARGS = {
    "seq_len": 5
}
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 int, shape (5, 5) — shape (5, 5) 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
pad_input Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
answerdotai/modernbert/src/bert_layers/attention.py
code served (permissive licence) · get_code("802fa8542c8445f9")
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 (2, 3, 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)

# Parameters for pad_input function
batch = 2
seqlen = 3
hidden_dim = 4

# Create hidden_states tensor: (total_nnz, hidden_dim)
# Let's say we have 4 tokens total (total_nnz = 4)
total_nnz = 4
hidden_states = torch.randn(total_nnz, hidden_dim)

# Create indices tensor: (total_nnz,)
# Indices should map tokens to positions in the flattened (batch*seqlen) dimension
# batch*seqlen = 2*3 = 6, so indices should be in range [0, 6)
indices = torch.tensor([0, 2, 3, 5], dtype=torch.long)

ARGS = {
    'hidden_states': hidden_states,
    'indices': indices,
    'batch': batch,
    'seqlen': seqlen
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
einops, 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 (2, 3, 4) — shape (2, 3, 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
ofirpress/attention_with_linear_biases/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, ofirpress/attention_with_linear_biases, 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.

unpad_input_only Ran
ran; our contract draft was wrong, not the code
answerdotai/modernbert/src/bert_layers/attention.py
code served (permissive licence) · get_code("4e534e11984c06b5")
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 (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)

# hidden_states: (batch, seqlen, ...)
# attention_mask: (batch, seqlen), bool / int, 1 means valid and 0 means not valid.

batch_size = 2
seq_len = 3
hidden_dim = 4

# Create hidden_states with shape (batch, seqlen, hidden_dim)
hidden_states = torch.randn(batch_size, seq_len, hidden_dim)

# Create attention_mask with shape (batch, seqlen)
# Mix of 1s (valid) and 0s (invalid)
attention_mask = torch.tensor([
    [1, 1, 0],
    [1, 0, 1]
], dtype=torch.int64)

ARGS = {
    "hidden_states": hidden_states,
    "attention_mask": attention_mask,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
einops, 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 (4, 4) — shape (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

Also present in other papers' code

Of 16 samples lifted from this paper's linked repositories, 16 carry a function identity and 0 do not. Of the 16 distinct functions with an identity, 5 are also present in other papers whose code we hold (1 with at least one paper dated earlier, 1 the same month, 5 later) and 11 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
27 dated earlier, 1 the same month, 36 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
pad_input
brick of this paper's assembly: helper
6 other papers
6 later
2306.15006 (2023-06)
DNABERT-2: EFFICIENT FOUNDATION MODEL AND BENCHMARK FOR MULTI-SPECIES GENOMES
2311.12570 (2023-11)
BEND: Benchmarking DNA Language Models on biologically meaningful tasks
2402.08777 (2024-02)
DNABERT-S: Pioneering Species Differentiation with Species-Aware DNA Embeddings
and 3 more not named here
unpad_input_only
brick of this paper's assembly: helper
2 other papers
2 later
2407.09941 (2024-07)
Hydra: Bidirectional State Space Models Through Generalized Matrix Mixers
2601.05776 (2026-01)
One Script Instead of Hundreds? On Pretraining Romanized Encoder Language Models
IndexFirstAxis
brick of this paper's assembly: helper
1 other paper
1 later
2306.15006 (2023-06)
DNABERT-2: EFFICIENT FOUNDATION MODEL AND BENCHMARK FOR MULTI-SPECIES GENOMES
IndexPutFirstAxis
brick of this paper's assembly: helper
1 other paper
1 later · 1 only as an assembly brick
2306.15006 (2023-06)
DNABERT-2: EFFICIENT FOUNDATION MODEL AND BENCHMARK FOR MULTI-SPECIES GENOMES

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

Since the introduction of the transformer model by Vaswani et al. (2017), a fundamental question has yet to be answered: how does a model achieve extrapolation at inference time for sequences that are longer than it saw during training? We first show that extrapolation can be enabled by simply changing the position representation method, though we find that current methods do not allow for efficient extrapolation. We therefore introduce a simpler and more efficient position method, Attention with Linear Biases (ALiBi). ALiBi does not add positional embeddings to word embeddings; instead, it biases query-key attention scores with a penalty that is proportional to their distance. We show that this method trains a 1.3 billion parameter model on input sequences of length 1024 that extrapolates to input sequences of length 2048, achieving the same perplexity as a sinusoidal position embedding model trained on inputs of length 2048 but training 11% faster and using 11% less memory. ALiBi's inductive bias towards recency also leads it to outperform multiple strong position methods on the WikiText-103 benchmark. 1

For agents

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

get_harvested_code_for_paper("2108.12409")
get_code_for_paper("2108.12409")
have("2108.12409")

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

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

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

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

Connect an agent — have() is free.