SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2305.16300 · NeurIPS · 2023

Random-Access Infinite Context Length for Transformers

Martin Jaggi, Amirkeivan Mohtashami

arXiv · PDF · Open in the Atlas

Code that ran

We lifted 13 functions out of this paper's own repositories and ran 11 of them in a sandbox. "Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results.

RepositoryRoleRan
epfml/landmark-attention canonical 1 of 1
cstankonrad/long_llama — 7 of 8
eugenepentland/landmark-attention-qlora extension 3 of 4
FunctionStatusWhere it lives
LandmarkGroupedSoftmaxFunction Ran epfml/landmark-attention/lm_benchmark/models/landmark.py
code served (permissive licence) · get_code("56f315f8e37b2615")
LongLlamaConfig Ran cstankonrad/long_llama/src/modeling_longllama.py
code served (permissive licence) · get_code("200bdb3c0f9ea777")
LongLlamaMemCache Ran cstankonrad/long_llama/src/modeling_longllama.py
code served (permissive licence) · get_code("44ea22afb757bd8f")
LongLlamaMemConfig Ran cstankonrad/long_llama/src/modeling_longllama.py
code served (permissive licence) · get_code("630a906a0e052341")
LongLlamaRotaryEmbedding Ran cstankonrad/long_llama/src/modeling_longllama.py
code served (permissive licence) · get_code("1b00d77243e94b30")
extract_alpaca_dataset Ran eugenepentland/landmark-attention-qlora/llama/train_qlora.py
code served (permissive licence) · get_code("b5445674ab17410f")
extract_unnatural_instructions_data Ran eugenepentland/landmark-attention-qlora/llama/train_qlora.py
code served (permissive licence) · get_code("f82430123a91cf21")
generate_prompt Ran eugenepentland/landmark-attention-qlora/llama/run_test.py
code served (permissive licence) · get_code("b9c4c8084f5cc40a")
mem_apply_update Ran cstankonrad/long_llama/src/modeling_longllama.py
code served (permissive licence) · get_code("8dfd75aa2742a590")
rotate_as_if_first Ran cstankonrad/long_llama/src/modeling_longllama.py
code served (permissive licence) · get_code("016091371cf37346")
rotate_one Ran cstankonrad/long_llama/src/modeling_longllama.py
code served (permissive licence) · get_code("a348555c65c6e5ff")
LongLlamaAttention Not yet run cstankonrad/long_llama/src/modeling_longllama.py
code served (permissive licence) · get_code("a7aa1ee408f70207")
local_dataset Not yet run eugenepentland/landmark-attention-qlora/llama/train_qlora.py
code served (permissive licence) · get_code("ec8bb649218d4f43")

Repositories linked to this paper

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

Abstract

While Transformers have shown remarkable success in natural language processing, their attention mechanism's large memory requirements have limited their ability to handle longer contexts. Prior approaches, such as recurrent memory or retrieval-based augmentation, have either compromised the random-access flexibility of attention (i.e., the capability to select any token in the entire context) or relied on separate mechanisms for relevant context retrieval, which may not be compatible with the model's attention. In this paper, we present a novel approach that allows access to the complete context while retaining random-access flexibility, closely resembling running attention on the entire context. Our method uses a landmark token to represent each block of the input and trains the attention to use it for selecting relevant blocks, enabling retrieval of blocks directly through the attention mechanism instead of by relying on a separate mechanism. Our approach seamlessly integrates with specialized data structures and the system's memory hierarchy, enabling processing of arbitrarily long context lengths. We demonstrate that our method can obtain comparable performance with Transformer-XL while significantly reducing the number of retrieved tokens in each step. Finally, we show that fine-tuning LLaMA 7B with our method successfully extends its context length capacity to over 32k tokens, allowing for inference at the context lengths of GPT-4. We release the implementation of landmark attention and the code to reproduce our experiments at https://github.com/epfml/landmark-attention/.

For agents

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

get_harvested_code_for_paper("2305.16300")
get_code_for_paper("2305.16300")
have("2305.16300")

Connect an agent — have() is free.