SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2305.01625 · NeurIPS · 2023

Unlimiformer: Long-Range Transformers with Unlimited Length Input

Graham Neubig, Uri Alon, Amanda Bertsch, Matthew Gormley

arXiv · PDF · Open in the Atlas

Code that ran

4 of 5 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 0 violated it and 1 has no contract verdict; 3 failures of our instrument; 1 no recorded run), measured 2026-11-23; 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/2305.01625.json · badge: /api/ran/2305.01625.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
abertsch72/unlimiformer canonical (classifier label)
classifier basis: census
4 ran · 1 no recorded run
FunctionStatusWhere it lives
decode Ran
ran on a synthesized input
abertsch72/unlimiformer/src/utils/decoding.py
code served (permissive licence) · get_code("5cfc5db67bc70f8f")
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 dict. 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

class MockTokenizer:
    def __init__(self):
        self.pad_token_id = 0
    
    def decode(self, token_ids, skip_special_tokens=False, clean_up_tokenization_spaces=False):
        return " ".join(str(t) for t in token_ids if t != -100)
    
    def batch_decode(self, token_ids_list, skip_special_tokens=False, clean_up_tokenization_spaces=False):
        return [" ".join(str(t) for t in token_ids if t != -100) for token_ids in token_ids_list]

class MockDataArgs:
    def __init__(self):
        self.ignore_pad_token_for_loss = True

# Test case 1: string values (switch_case = -1)
id_to_something_strings = {
    "id_1": "hello world",
    "id_2": "test string"
}

# Test case 2: list of strings (switch_case = 0)
id_to_something_list_strings = {
    "id_1": ["hello", "world"],
    "id_2": ["test", "strings"]
}

# Test case 3: list of token id lists (switch_case = 1)
id_to_something_token_lists = {
    "id_1": [np.array([1, 2, 3, -100]), np.array([4, 5, 6])],
    "id_2": [np.array([7, 8, -100, 9])]
}

# Test case 4: single token id array (switch_case = 2)
id_to_something_token_ids = {
    "id_1": np.array([1, 2, 3, -100]),
    "id_2": np.array([4, 5, -100, 6])
}

tokenizer = MockTokenizer()
data_args = MockDataArgs()

# Using switch_case 2 scenario as main test
ARGS = {
    "id_to_something": id_to_something_token_ids,
    "tokenizer": tokenizer,
    "data_args": data_args
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict 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
prepare_ctrl_input Ran
ran; our contract draft was wrong, not the code
abertsch72/unlimiformer/src/run_generation.py
code served (permissive licence) · get_code("a766a95b9fd5ee9c")
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 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 logging
import torch

logger = logging.getLogger(__name__)

class MockTokenizer:
    def __init__(self):
        self.control_codes = {
            'Links': 12345,
            'Books': 12346,
            'Recipes': 12347
        }
    
    def encode(self, text, add_special_tokens=False):
        # Return a list starting with a control code
        return [12345, 1, 2, 3, 4, 5]

class MockArgs:
    def __init__(self):
        self.temperature = 0.5

ARGS = {
    'args': MockArgs(),
    '_': None,
    'tokenizer': MockTokenizer(),
    'prompt_text': 'Links This is a test prompt'
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type 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
prepare_xlm_input Ran
ran; our contract draft was wrong, not the code
abertsch72/unlimiformer/src/run_generation.py
code served (permissive licence) · get_code("b7bf53f6b6b11a4b")
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 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 torch.nn as nn

torch.manual_seed(0)

class MockConfig:
    def __init__(self):
        self.use_lang_emb = True
        self.lang2id = {'en': 0, 'fr': 1, 'de': 2}
        self.lang_id = None

class MockModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.config = MockConfig()
    
    def forward(self, x):
        return x

class MockTokenizer:
    def __init__(self):
        pass
    
    def encode(self, text):
        return [101, 2054, 2003, 102]

class MockArgs:
    def __init__(self):
        self.xlm_language = 'en'

model = MockModel()
tokenizer = MockTokenizer()
args = MockArgs()
prompt_text = "What is this?"

ARGS = {
    'args': args,
    'model': model,
    'tokenizer': tokenizer,
    'prompt_text': prompt_text
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type 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
prepare_xlnet_input Ran
ran; our contract draft was wrong, not the code
abertsch72/unlimiformer/src/run_generation.py
code served (permissive licence) · get_code("80844fa7cfa6e8d8")
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 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

torch.manual_seed(0)

class MockTokenizer:
    def __init__(self):
        pass

class MockArgs:
    def __init__(self):
        self.prefix = "Custom prefix text. "
        self.padding_text = "Padding text fallback. "

ARGS = {
    "args": MockArgs(),
    "_": None,
    "tokenizer": MockTokenizer(),
    "prompt_text": "This is the prompt text to append."
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
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
drop_duplicates_in_input Not yet run
unverified (harvested, no recorded run)
abertsch72/unlimiformer/src/utils/duplicates.py
code served (permissive licence) · get_code("abbee6221df98330")
How it ran

no invocation recorded.

Also present in other papers' code

Of 5 samples lifted from this paper's linked repositories, 5 carry a function identity and 0 do not. Of the 5 distinct functions with an identity, 4 are also present in other papers whose code we hold (4 with at least one paper dated earlier, 0 the same month, 4 later) and 1 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
prepare_ctrl_input 11 other papers
5 dated earlier, 6 later
1910.03771 (2019-10)
HuggingFace's Transformers: State-of-the-art Natural Language Processing
2009.14259 (2020-09)
Visually-Grounded Planning without Vision: Language Models Infer Detailed Plans from High-level Instructions
2106.06168 (2021-06)
Generate, Annotate, and Learn: NLP with Synthetic Text
and 8 more not named here
prepare_xlm_input 11 other papers
5 dated earlier, 6 later
1910.03771 (2019-10)
HuggingFace's Transformers: State-of-the-art Natural Language Processing
2009.14259 (2020-09)
Visually-Grounded Planning without Vision: Language Models Infer Detailed Plans from High-level Instructions
2106.06168 (2021-06)
Generate, Annotate, and Learn: NLP with Synthetic Text
and 8 more not named here
prepare_xlnet_input 8 other papers
2 dated earlier, 6 later
1910.03771 (2019-10)
HuggingFace's Transformers: State-of-the-art Natural Language Processing
2210.15097 (2022-10)
Contrastive Decoding: Open-ended Text Generation as Optimization
2402.05827 (2024-02)
On the Robustness of Editing Large Language Models
and 5 more not named here
drop_duplicates_in_input 2 other papers
1 dated earlier, 1 later
2201.03533 (2022-01)
SCROLLS: Standardized CompaRison Over Long Language Sequences
2501.00712 (2025-01)
Rethinking Addressing in Language Models via Contextualized Equivariant Positional Encoding

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

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 proposal of transformers (Vaswani et al., 2017), these models have been limited to bounded input lengths, because of their need to attend to every token in the input. In this work, we propose Unlimiformer: a general approach that wraps any existing pretrained encoder-decoder transformer, and offloads the cross-attention computation to a single k-nearest-neighbor (kNN) index, while the returned kNN distances are the attention dot-product scores. This kNN index can be kept on either the GPU or CPU memory and queried in sub-linear time; this way, we can index practically unlimited input sequences, while every attention head in every decoder layer retrieves its top-k keys, instead of attending to every key. We evaluate Unlimiformer on several long-document and book-summarization benchmarks, showing that it can process even 500k token-long inputs from the BookSum dataset, without any input truncation at test time. We demonstrate that Unlimiformer improves pretrained models such as BART (Lewis et al., 2020a) and Longformer (Beltagy et al., 2020) by extending them to unlimited inputs without additional learned weights and without modifying their code. Our code and models are publicly available, and support LLaMA-2 as well 2 . * Now at Google DeepMind 2 https://github.com/abertsch72/unlimiformer 37th Conference on Neural Information Processing Systems (NeurIPS 2023).

For agents

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

get_harvested_code_for_paper("2305.01625")
get_code_for_paper("2305.01625")
have("2305.01625")

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

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

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

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

Connect an agent — have() is free.