Unlimiformer: Long-Range Transformers with Unlimited Length Input
Amanda Bertsch, Uri Alon, Graham Neubig, Matthew Gormley
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
Ask Lune
Know this paper in minutes, not an afternoon.
Lune can read every page of it and the top-tier papers that cite it, and gives you its claims, its evidence and its limits, each one cited to the paper it comes from. No skimming, no AI slop.
47 top-tier papers have cited it since. Know what they found before your reviewers do.
Lune can draw on
the full paper · the top-tier papers that cite it · related work
Free to start. No credit card required.
Lineage
- Transformers are RNNs: Fast Autoregressive Transformers with Linear Attention cites Reformer: The Efficient Transformer
- Big Bird: Transformers for Longer Sequences cites Reformer: The Efficient Transformer
- MoBA: Mixture of Block Attention for Long-Context LLMs cites Transformers are RNNs: Fast Autoregressive Transformers with Linear Attention
- MoBA: Mixture of Block Attention for Long-Context LLMs cites Big Bird: Transformers for Longer Sequences
- MoBA: Mixture of Block Attention for Long-Context LLMs cites Reformer: The Efficient Transformer
- MoBA: Mixture of Block Attention for Long-Context LLMs cites MInference 1.0: Accelerating Pre-filling for Long-Context LLMs via Dynamic Sparse Attention
- RepoBench: Benchmarking Repository-Level Code Auto-Completion Systems cites Big Bird: Transformers for Longer Sequences
- RepoBench: Benchmarking Repository-Level Code Auto-Completion Systems cites Reformer: The Efficient Transformer
- InfLLM: Training-Free Long-Context Extrapolation for LLMs with an Efficient Context Memory cites Transformers are RNNs: Fast Autoregressive Transformers with Linear Attention
- InfLLM: Training-Free Long-Context Extrapolation for LLMs with an Efficient Context Memory cites Big Bird: Transformers for Longer Sequences
- InfLLM: Training-Free Long-Context Extrapolation for LLMs with an Efficient Context Memory cites Reformer: The Efficient Transformer
- MInference 1.0: Accelerating Pre-filling for Long-Context LLMs via Dynamic Sparse Attention cites Transformers are RNNs: Fast Autoregressive Transformers with Linear Attention
- MInference 1.0: Accelerating Pre-filling for Long-Context LLMs via Dynamic Sparse Attention cites Big Bird: Transformers for Longer Sequences
- MInference 1.0: Accelerating Pre-filling for Long-Context LLMs via Dynamic Sparse Attention cites InfLLM: Training-Free Long-Context Extrapolation for LLMs with an Efficient Context Memory
- MInference 1.0: Accelerating Pre-filling for Long-Context LLMs via Dynamic Sparse Attention cites Reformer: The Efficient Transformer
Cited by top-tier papers47
- MInference 1.0: Accelerating Pre-filling for Long-Context LLMs via Dynamic Sparse AttentionHuiqiang Jiang, Yucheng Li, Chengruidong Zhang, Qianhui Wu et al.NeurIPS 2024 · 479 citations
- Generating Images with Multimodal Language ModelsJing Yu Koh, Daniel Fried, Russ SalakhutdinovNeurIPS 2023 · 403 citations
- RepoBench: Benchmarking Repository-Level Code Auto-Completion SystemsTianyang Liu, Canwen Xu, Julian J. McAuleyICLR 2024 · 338 citations
- InfLLM: Training-Free Long-Context Extrapolation for LLMs with an Efficient Context MemoryChaojun Xiao, Pengle Zhang, Xu Han, Guangxuan Xiao et al.NeurIPS 2024 · 223 citations
- MoBA: Mixture of Block Attention for Long-Context LLMsEnzhe Lu, Zhejun Jiang, Jingyuan Liu, Yulun Du et al.NeurIPS 2025 · 219 citations
Builds on21
- BERTScore: Evaluating Text Generation with BERTTianyi Zhang, Varsha Kishore, Felix Wu, Kilian Q. Weinberger et al.ICLR 2020 · 8,443 citations
- Big Bird: Transformers for Longer SequencesManzil Zaheer, Guru Guruganesh, Kumar Avinava Dubey, Joshua Ainslie et al.NeurIPS 2020 · 3,159 citations
- Reformer: The Efficient TransformerNikita Kitaev, Lukasz Kaiser, Anselm LevskayaICLR 2020 · 2,878 citations
- Transformers are RNNs: Fast Autoregressive Transformers with Linear AttentionAngelos Katharopoulos, Apoorv Vyas, Nikolaos Pappas, François FleuretICML 2020 · 2,665 citations
- Improving Language Models by Retrieving from Trillions of TokensSebastian Borgeaud, Arthur Mensch, Jordan Hoffmann, Trevor Cai et al.ICML 2022 · 1,629 citations
Related papers
- ∞-former: Infinite Memory TransformerPedro Henrique Martins, Zita Marinho, André F. T. MartinsACL 2022 · 12 citations
- IceFormer: Accelerated Inference with Long-Sequence Transformers on CPUsYuzhen Mao, Martin Ester, Ke LiICLR 2024 · 8 citations
- Long Sequence Modeling with Attention Tensorization: From Sequence to Tensor LearningAosong Feng, Rex Ying, Leandros TassiulasEMNLP Findings 2024 · 2 citations
- Nyströmformer: A Nyström-based Algorithm for Approximating Self-AttentionYunyang Xiong, Zhanpeng Zeng, Rudrasis Chakraborty, Mingxing Tan et al.AAAI 2021 · 675 citations
- Adapting Language Models to Compress ContextsAlexis Chevalier, Alexander Wettig, Anirudh Ajith, Danqi ChenEMNLP 2023 · 34 citations
