SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2004.05150 · 2020

Longformer: The Long-Document Transformer

Matthew Peters, Arman Cohan, Iz Beltagy

arXiv · PDF · Open in the Atlas

Code that ran

22 of 35 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 12 have no contract verdict; 8 failures of our instrument; 13 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/2004.05150.json · badge: /api/ran/2004.05150.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
allenai/longformer marked official in Papers with Code
Papers with Code archive
9 ran · 2 no recorded run
jaketae/pytorch-malware-detection community (classifier label)
classifier basis not recorded on the link
4 ran · 3 no recorded run
AIResearchHub/transformergallery community
Papers with Code archive
4 ran · 2 no recorded run
a-rios/ats-models community (classifier label)
classifier basis not recorded on the link
3 ran · 1 no recorded run
facebookresearch/xformers community
Papers with Code archive
1 ran · 3 no recorded run
amazon-science/efficient-longdoc-classification community
Papers with Code archive
1 ran · 1 no recorded run
schenliu/longformer-chinese community
Papers with Code archive
0 ran · 1 no recorded run
FunctionStatusWhere it lives
FeedForward Ran
ran on a synthesized input · constructed an object; no result was computed
AIResearchHub/transformergallery/transformer/longformer.py
code served (permissive licence) · get_code("2893a3bddf619d82")
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, FeedForward: 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)

# The FeedForward class takes dim and inner_dim as parameters
# dim is the input/output dimension
# inner_dim is the hidden layer dimension
# We'll use distinct sizes: dim=4, inner_dim=8

ARGS = {
    "dim": 4,
    "inner_dim": 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 FeedForward — 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 FeedForward 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
LongformerClassificationHead Ran
ran on a synthesized input
amazon-science/efficient-longdoc-classification/src/models.py
code served (permissive licence) · get_code("e71d9c8a8cff7aa3")
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 2, dtype family float, shape (2, 3) 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

class LongformerClassificationHead(torch.nn.Module):
    """Head for sentence-level classification tasks."""

    def __init__(self, hidden_size, hidden_dropout_prob, num_labels):
        super().__init__()
        self.dense = torch.nn.Linear(hidden_size, hidden_size)
        self.dropout = torch.nn.Dropout(hidden_dropout_prob)
        self.out_proj = torch.nn.Linear(hidden_size, num_labels)

    def forward(self, hidden_states, **kwargs):
        hidden_states = hidden_states[:, 0, :]
        hidden_states = self.dropout(hidden_states)
        hidden_states = self.dense(hidden_states)
        hidden_states = torch.tanh(hidden_states)
        hidden_states = self.dropout(hidden_states)
        output = self.out_proj(hidden_states)
        return output


INIT_ARGS = {
    "hidden_size": 4,
    "hidden_dropout_prob": 0.1,
    "num_labels": 3,
}

ARGS = {
    "hidden_states": torch.randn(2, 5, 4),
}

if __name__ == "__main__":
    model = LongformerClassificationHead(**INIT_ARGS)
    output = model(**ARGS)
    print(f"Output shape: {output.shape}")
    print(f"Output: {output}")
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 2, dtype family float, shape (2, 3) — shape (2, 3) 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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
PositionalEncoding Ran
ran on a synthesized input · constructed an object; no result was computed
AIResearchHub/transformergallery/transformer/longformer.py
code served (permissive licence) · get_code("6c89fcd0771cd674")
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, PositionalEncoding: 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)

# The PositionalEncoding class takes three arguments: d_model, max_len, and device
# - d_model: dimension of the model (int)
# - max_len: maximum length of sequences (int)
# - device: torch device to place tensors on

d_model = 4
max_len = 8
device = torch.device('cpu')

ARGS = {
    'd_model': d_model,
    'max_len': max_len,
    'device': device
}
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 PositionalEncoding — 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 PositionalEncoding 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
TokenEmbedding Ran
ran on a synthesized input · constructed an object; no result was computed
AIResearchHub/transformergallery/transformer/longformer.py
code served (permissive licence) · get_code("0840d53a3e87bbd0")
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, TokenEmbedding: 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)

# The TokenEmbedding class uses:
# - vocab_size: passed to nn.Embedding
# - d_model: passed to nn.Embedding
# - forward() takes ids tensor of shape [batch_size, length]
# - returns token_emb of shape [batch_size, length, d_model]

vocab_size = 100
d_model = 8

ARGS = {
    "vocab_size": vocab_size,
    "d_model": d_model,
}
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 TokenEmbedding — 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 TokenEmbedding 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
TransformerEmbedding Ran
ran on a synthesized input · constructed an object; no result was computed
AIResearchHub/transformergallery/transformer/longformer.py
code served (permissive licence) · get_code("4d2255c33fd872a1")
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, TransformerEmbedding: 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)

# Define the arguments for TransformerEmbedding
vocab_size = 100
d_model = 4
max_len = 8
device = 'cpu'

ARGS = {
    'vocab_size': vocab_size,
    'd_model': d_model,
    'max_len': max_len,
    'device': device
}
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 TransformerEmbedding — 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 TransformerEmbedding 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
_chunk Ran
ran; our contract draft was wrong, not the code
allenai/longformer/longformer/longformer.py
code served (permissive licence) · get_code("b3689e24866300ad")
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 4, dtype family float, shape (2, 3, 4, 3) 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)

# x should be a 3D tensor with shape (batch_size, seq_len, feature_dim)
# The function expects x.size(1) to be divisible by (w * 2)
# Let's use batch=2, seq_len=8 (divisible by 2*2=4), feature_dim=3
x = torch.randn(2, 8, 3)

# w is the overlap size parameter
# With seq_len=8 and w=2, chunk_size will be 2*2=4, and we get overlapping chunks
w = 2

ARGS = {
    "x": x,
    "w": w
}
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 4, dtype family float, shape (2, 3, 4, 3) — shape (2, 3, 4, 3) 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_invalid_locations_mask Ran
ran; our contract draft was wrong, not the code
allenai/longformer/longformer/longformer.py
code served (permissive licence) · get_code("215ac6dd58d2d468")
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 tuple. 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)

# Test case 1: w and d as integers, autoregressive=True
ARGS = {
    "w": 2,
    "d": 3,
    "autoregressive": True,
    "device": "cpu"
}
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 tuple — a tuple output has no array shape of its own; none is 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
_get_invalid_locations_mask_fixed_dilation Ran
ran, honoured the contract we drafted
allenai/longformer/longformer/longformer.py
code served (permissive licence) · get_code("1a6f3f01a17a0b4c")
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 (8, 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)

ARGS = {
    "seq_len": 8,
    "w": 3,
    "d": 2,
}
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 (8, 4) — shape (8, 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
_skew Ran
ran; our contract draft was wrong, not the code
allenai/longformer/longformer/longformer.py
code served (permissive licence) · get_code("54c6929644249d31")
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 4, dtype family float, shape (2, 4, 7, 3) 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)

# Construct arguments for _skew function
# The function takes a tensor x, pads it according to direction,
# and then reshapes it by swapping the last two dimensions

# x: a small tensor - batch_size=2, some spatial dims, last two dims will be swapped
x = torch.randn(2, 4, 3, 5)

# direction: tuple of padding amounts for F.pad
# F.pad expects (left, right, top, bottom, front, back, ...) for the last dimensions
# We'll pad the last dimension
direction = (1, 1, 0, 0)

# padding_value: scalar value to use for padding
padding_value = 0.0

ARGS = {
    "x": x,
    "direction": direction,
    "padding_value": padding_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 4, dtype family float, shape (2, 4, 7, 3) — shape (2, 4, 7, 3) 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
_skew2 Ran
ran; our contract draft was wrong, not the code
allenai/longformer/longformer/longformer.py
code served (permissive licence) · get_code("755bf82d9fe23d4b")
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 4, dtype family float, shape (2, 4, 3, 7) 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)

# Create a small 4D tensor with shape (B, C, M, L)
# Using distinct sizes: batch=2, channels=4, M=3, L=5
x = torch.randn(2, 4, 3, 5)

# padding_value can be any numeric value
padding_value = 0.0

ARGS = {
    "x": x,
    "padding_value": padding_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 4, dtype family float, shape (2, 4, 3, 7) — shape (2, 4, 3, 7) 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
average_tensors Ran
ran on a synthesized input
a-rios/ats-models/ats_models/average.py
code served (permissive licence) · get_code("62964c608dfd3d2c")
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

torch.manual_seed(0)

# Create a list of tensors with the same shape
tensor1 = torch.randn(2, 4)
tensor2 = torch.randn(2, 4)
tensor3 = torch.randn(2, 4)

ARGS = {
    'tensors': [tensor1, tensor2, tensor3]
}
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
construct_href Ran
ran on a synthesized input
jaketae/pytorch-malware-detection/src/bin/malshare.py
code served (permissive licence) · get_code("1d6037ddb5464048")
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 str. 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 numpy as np

def construct_href(link):
    root, rest = link.split('sample')
    action, hash_ = rest.split('detail')
    return f'{root}sampleshare{action}getfile{hash_}'

# The function takes a single parameter 'link' which is a string
# It splits on 'sample' to get root and rest
# Then splits rest on 'detail' to get action and hash_
# Returns a formatted string using these components

link = "https://example.com/sample/action/detail/abc123hash"

ARGS = {
    "link": link
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str 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
count_params Ran
ran on a synthesized input
jaketae/pytorch-malware-detection/src/deep_malware_detection/utils.py
code served (permissive licence) · get_code("4f4f44d30b573fa8")
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 int, ndim 0, dtype family int, shape () 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)

class SimpleModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear1 = nn.Linear(4, 3)
        self.linear2 = nn.Linear(3, 2)
        self.frozen_layer = nn.Linear(2, 1)
        # Freeze one layer so we can test trainable_only parameter
        for param in self.frozen_layer.parameters():
            param.requires_grad = False
    
    def forward(self, x):
        x = self.linear1(x)
        x = self.linear2(x)
        x = self.frozen_layer(x)
        return x

model = SimpleModel()

ARGS = {
    "model": model,
    "trainable_only": True
}
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 int, ndim 0, dtype family int, shape () — shape () 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
label_smoothed_nll_loss Ran
ran on a synthesized input
a-rios/ats-models/ats_models/metrics.py
code served (permissive licence) · get_code("9c78ceb4210479cf")
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 tuple, 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
import torch.nn.functional as F

torch.manual_seed(0)

# Create log probabilities tensor
# Shape: (batch_size=2, vocab_size=4)
lprobs = F.log_softmax(torch.randn(2, 4), dim=-1)

# Create target tensor with shape (batch_size=2,)
# Values should be indices in range [0, vocab_size)
target = torch.tensor([1, 2], dtype=torch.long)

# Epsilon for label smoothing
epsilon = 0.1

# Pad token ID
pad_id = 0

# Ignore index (default value)
ignore_index = -100

ARGS = {
    "lprobs": lprobs,
    "target": target,
    "epsilon": epsilon,
    "pad_id": pad_id,
    "ignore_index": ignore_index,
}
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 tuple, ndim 1, dtype family float — a tuple 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
local_1d_pattern Ran
ran, violated the contract we drafted
facebookresearch/xformers/xformers/components/attention/attention_patterns.py
pointer only (licence: NOASSERTION) · get_code("ca468da77bd87495")
How it ran

The body of this sample is withheld: GitHub could not classify the licence of this paper's repository, facebookresearch/xformers (NOASSERTION). 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.

predict Ran
ran on a synthesized input
jaketae/pytorch-malware-detection/src/deep_malware_detection/utils.py
code served (permissive licence) · get_code("e566c3f105753aa6")
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 tuple, ndim 3, dtype family int; 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 torch.nn as nn

torch.manual_seed(0)

# Create a simple model that takes inputs and produces outputs
class SimpleModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 3)
    
    def forward(self, x):
        return self.linear(x)

# Create model instance
model = SimpleModel()

# Create a data loader (list of (inputs, labels) tuples)
# Each input is shape (2, 4) - batch size 2, feature dim 4
# Each label is shape (2, 3) - batch size 2, output dim 3
data_loader = [
    (torch.randn(2, 4), torch.randint(0, 2, (2, 3))),
    (torch.randn(2, 4), torch.randint(0, 2, (2, 3)))
]

# Set device to CPU
device = torch.device('cpu')

ARGS = {
    'model': model,
    'data_loader': data_loader,
    'device': device,
    'apply_sigmoid': False,
    'to_numpy': True
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch, tqdm — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple, ndim 3, dtype family int — a tuple 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
remove_special_tokens Ran
ran on a synthesized input
a-rios/ats-models/ats_models/finetune_mbart.py
code served (permissive licence) · get_code("bce6838014c76d1e")
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 MockTokenizer. 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
from transformers import PreTrainedTokenizer

class MockTokenizer:
    def __init__(self):
        self.additional_special_tokens = ['<pad>', '<unk>', '<special_token>', '<custom>', '<remove_me>']
        self.special_tokens_map = {
            'additional_special_tokens': str(self.additional_special_tokens)
        }

tokenizer = MockTokenizer()
special_token_substrings = ['remove', 'custom']

ARGS = {
    'tokenizer': tokenizer,
    'special_token_substrings': special_token_substrings
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch, transformers — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type MockTokenizer — a MockTokenizer output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a MockTokenizer 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
sliding_chunks_matmul_pv Ran
ran; our contract draft was wrong, not the code
allenai/longformer/longformer/longformer.py
code served (permissive licence) · get_code("4261f70837b75c76")
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 4, dtype family float, shape (2, 8, 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
import torch.nn.functional as F

torch.manual_seed(0)

# Parameters for sliding_chunks_matmul_pv
bsz = 2
seqlen = 8
num_heads = 3
head_dim = 4
w = 2

# Create prob tensor: (bsz, seqlen, num_heads, 2*w+1)
prob = torch.randn(bsz, seqlen, num_heads, 2 * w + 1)

# Create v tensor: (bsz, seqlen, num_heads, head_dim)
v = torch.randn(bsz, seqlen, num_heads, head_dim)

ARGS = {
    'prob': prob,
    'v': v,
    'w': w,
}
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 4, dtype family float, shape (2, 8, 3, 4) — shape (2, 8, 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
sliding_chunks_matmul_qk Ran
ran; our contract draft was wrong, not the code
allenai/longformer/longformer/longformer.py
code served (permissive licence) · get_code("1b7525edcd068b10")
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 4, dtype family float, shape (2, 16, 3, 9) 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)

# The function sliding_chunks_matmul_qk expects:
# q: torch.Tensor with shape (bsz, seqlen, num_heads, head_dim)
# k: torch.Tensor with shape (bsz, seqlen, num_heads, head_dim)
# w: int (window size)
# padding_value: float

# Constraints from the function:
# - seqlen must be divisible by (w * 2)
# - We need seqlen % (w * 2) == 0

bsz = 2
num_heads = 3
head_dim = 4
w = 4
seqlen = w * 2 * 2  # 32, divisible by w*2=8

q = torch.randn(bsz, seqlen, num_heads, head_dim)
k = torch.randn(bsz, seqlen, num_heads, head_dim)

ARGS = {
    "q": q,
    "k": k,
    "w": w,
    "padding_value": -float('inf')
}
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 4, dtype family float, shape (2, 16, 3, 9) — shape (2, 16, 3, 9) 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
sliding_chunks_no_overlap_matmul_pv Ran
ran; our contract draft was wrong, not the code
allenai/longformer/longformer/longformer.py
code served (permissive licence) · get_code("1273524f034ce151")
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 4, dtype family float, shape (2, 8, 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
import torch.nn.functional as F

torch.manual_seed(0)

# Determine parameters for the function
# The function expects:
# - prob: shape (bsz, seqlen, num_heads, 3, w)
# - v: shape (bsz, seqlen, num_heads, head_dim)
# - w: chunk width (must divide seqlen evenly)

bsz = 2
num_heads = 3
head_dim = 4
w = 4
seqlen = w * 2  # Must be divisible by w (8 in this case)

# Create prob tensor with shape (bsz, seqlen, num_heads, 3, w)
prob = torch.randn(bsz, seqlen, num_heads, 3, w)

# Create v tensor with shape (bsz, seqlen, num_heads, head_dim)
v = torch.randn(bsz, seqlen, num_heads, head_dim)

ARGS = {
    "prob": prob,
    "v": v,
    "w": w
}
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 4, dtype family float, shape (2, 8, 3, 4) — shape (2, 8, 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
sliding_chunks_no_overlap_matmul_qk Ran
ran; our contract draft was wrong, not the code
allenai/longformer/longformer/longformer.py
code served (permissive licence) · get_code("3d4e46172b26669c")
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 4, dtype family float, shape (2, 8, 3, 12) 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)

# Construct arguments for sliding_chunks_no_overlap_matmul_qk
# Parameters: q, k, w, padding_value

# q and k must have shape (bsz, seqlen, num_heads, head_dim)
# where seqlen must be divisible by w
bsz = 2
num_heads = 3
head_dim = 4
w = 4  # window size
seqlen = 8  # must be divisible by w

q = torch.randn(bsz, seqlen, num_heads, head_dim)
k = torch.randn(bsz, seqlen, num_heads, head_dim)
padding_value = 0.0

ARGS = {
    "q": q,
    "k": k,
    "w": w,
    "padding_value": padding_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 4, dtype family float, shape (2, 8, 3, 12) — shape (2, 8, 3, 12) 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
train_val_test_split Ran
ran on a synthesized input
jaketae/pytorch-malware-detection/src/deep_malware_detection/dataset.py
code served (permissive licence) · get_code("e71dea05795c03bf")
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 tuple. 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 numpy as np
from sklearn.model_selection import train_test_split

# Create a sample index array
idx = np.arange(100)

# Define the arguments dictionary
ARGS = {
    'idx': idx,
    'val_size': 0.2,
    'test_size': 0.2,
    'shuffle': True
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, sklearn — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple — a tuple output has no array shape of its own; none is 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
Longformer Not yet run
unverified (harvested, no recorded run)
AIResearchHub/transformergallery/transformer/longformer.py
code served (permissive licence) · get_code("e23d4d61b776fd56")
How it ran

no invocation recorded.

LongformerClass Not yet run
unverified (harvested, no recorded run)
amazon-science/efficient-longdoc-classification/src/models.py
code served (permissive licence) · get_code("083425b2586f0566")
How it ran

no invocation recorded.

LongformerLayer Not yet run
unverified (harvested, no recorded run)
AIResearchHub/transformergallery/transformer/longformer.py
code served (permissive licence) · get_code("56f78e8f5e291c8d")
How it ran

no invocation recorded.

LongformerSelfAttention Not yet run
unverified (harvested, no recorded run)
allenai/longformer/longformer/longformer.py
code served (permissive licence) · get_code("c1eb691dab111921")
How it ran

no invocation recorded.

LongformerSelfAttention Not yet run
unverified (harvested, no recorded run)
schenliu/longformer-chinese/longformer/longformer.py
pointer only (licence: NONE) · get_code("3b707d0823eee4d2")
How it ran

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

_generate_nd_grid Not yet run
unverified (harvested, no recorded run)
facebookresearch/xformers/xformers/components/attention/attention_patterns.py
pointer only (licence: NOASSERTION) · get_code("cc7b7bd19f2134ba")
How it ran

The body of this sample is withheld: GitHub could not classify the licence of this paper's repository, facebookresearch/xformers (NOASSERTION). 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.

collate_fn Not yet run
unverified (harvested, no recorded run)
jaketae/pytorch-malware-detection/src/deep_malware_detection/dataset.py
code served (permissive licence) · get_code("be39561477eedbab")
How it ran

no invocation recorded.

create_long_model Not yet run
unverified (harvested, no recorded run)
a-rios/ats-models/ats_models/convert_bart2long.py
code served (permissive licence) · get_code("8a1120aa9e015927")
How it ran

no invocation recorded.

get_accuracy Not yet run
unverified (harvested, no recorded run)
jaketae/pytorch-malware-detection/src/deep_malware_detection/utils.py
code served (permissive licence) · get_code("e910798b9dfc1967")
How it ran

no invocation recorded.

local_nd_distance Not yet run
unverified (harvested, no recorded run)
facebookresearch/xformers/xformers/components/attention/attention_patterns.py
pointer only (licence: NOASSERTION) · get_code("69ca0d84582f00bd")
How it ran

The body of this sample is withheld: GitHub could not classify the licence of this paper's repository, facebookresearch/xformers (NOASSERTION). 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.

local_nd_pattern Not yet run
unverified (harvested, no recorded run)
facebookresearch/xformers/xformers/components/attention/attention_patterns.py
pointer only (licence: NOASSERTION) · get_code("2a87d1deca0f2b1a")
How it ran

The body of this sample is withheld: GitHub could not classify the licence of this paper's repository, facebookresearch/xformers (NOASSERTION). 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.

mask_invalid_locations Not yet run
unverified (harvested, no recorded run)
allenai/longformer/longformer/longformer.py
code served (permissive licence) · get_code("bec22b3675334717")
How it ran

no invocation recorded.

pad_sequence Not yet run
unverified (harvested, no recorded run)
jaketae/pytorch-malware-detection/src/deep_malware_detection/dataset.py
code served (permissive licence) · get_code("337700a5796189df")
How it ran

no invocation recorded.

Also present in other papers' code

Of 35 samples lifted from this paper's linked repositories, 35 carry a function identity and 0 do not. Of the 35 distinct functions with an identity, 11 are also present in other papers whose code we hold (11 with at least one paper dated earlier, 0 the same month, 4 later) and 24 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
FeedForward
brick of this paper's assembly: helper
2 other papers
1 dated earlier, 1 later · 2 only as an assembly brick
1901.02860 (2019-01)
Transformer-XL: Attentive Language Models Beyond a Fixed-Length Context
2203.08913 (2022-03)
Memorizing Transformers
PositionalEncoding
brick of this paper's assembly: helper
2 other papers
1 dated earlier, 1 later · 1 only as an assembly brick
1901.02860 (2019-01)
Transformer-XL: Attentive Language Models Beyond a Fixed-Length Context
2203.08913 (2022-03)
Memorizing Transformers
TokenEmbedding
brick of this paper's assembly: helper
2 other papers
1 dated earlier, 1 later · 2 only as an assembly brick
1901.02860 (2019-01)
Transformer-XL: Attentive Language Models Beyond a Fixed-Length Context
2203.08913 (2022-03)
Memorizing Transformers
TransformerEmbedding
brick of this paper's assembly: helper
2 other papers
1 dated earlier, 1 later · 1 only as an assembly brick
1901.02860 (2019-01)
Transformer-XL: Attentive Language Models Beyond a Fixed-Length Context
2203.08913 (2022-03)
Memorizing Transformers
collate_fn 1 other paper
1 dated earlier
1710.09435 (2017-10)
Malware Detection by Eating a Whole EXE
construct_href 1 other paper
1 dated earlier
1710.09435 (2017-10)
Malware Detection by Eating a Whole EXE
count_params 1 other paper
1 dated earlier
1710.09435 (2017-10)
Malware Detection by Eating a Whole EXE
get_accuracy 1 other paper
1 dated earlier
1710.09435 (2017-10)
Malware Detection by Eating a Whole EXE
pad_sequence 1 other paper
1 dated earlier
1710.09435 (2017-10)
Malware Detection by Eating a Whole EXE
predict 1 other paper
1 dated earlier
1710.09435 (2017-10)
Malware Detection by Eating a Whole EXE
train_val_test_split 1 other paper
1 dated earlier
1710.09435 (2017-10)
Malware Detection by Eating a Whole EXE

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

Transformer-based models are unable to process long sequences due to their self-attention operation, which scales quadratically with the sequence length. To address this limitation, we introduce the Longformer with an attention mechanism that scales linearly with sequence length, making it easy to process documents of thousands of tokens or longer. Longformer's attention mechanism is a drop-in replacement for the standard self-attention and combines a local windowed attention with a task motivated global attention. Following prior work on long-sequence transformers, we evaluate Longformer on character-level language modeling and achieve state-of-the-art results on text8 and enwik8. In contrast to most prior work, we also pretrain Longformer and finetune it on a variety of downstream tasks. Our pretrained Longformer consistently outperforms RoBERTa on long document tasks and sets new state-of-the-art results on Wiki-Hop and TriviaQA. We finally introduce the Longformer-Encoder-Decoder (LED), a Longformer variant for supporting long document generative sequence-to-sequence tasks, and demonstrate its effectiveness on the arXiv summarization dataset. 1 * Equal contribution. 1 https://github.com/allenai/longformer Model attention char-LM other pretrain matrix tasks Transformer-XL (2019) ltr yes no no Adaptive Span (2019) ltr yes no no Compressive (2020) ltr yes no no Reformer (2020) sparse yes no no Sparse (2019) sparse yes no no Routing (2020) sparse yes no no BP-Transformer (2019) sparse yes MT no Blockwise (2019) sparse no QA yes Our Longformer sparse yes multiple yes

For agents

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

get_harvested_code_for_paper("2004.05150")
get_code_for_paper("2004.05150")
have("2004.05150")

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

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

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

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

Connect an agent — have() is free.