about
Landmark Attention: Random-Access Infinite Context Length for Transformers (arxiv.org)
22 points by johntb86 on May 27, 2023 | hide | past | pdf | 4 comments on HN

In plain words: A summary token stands for each chunk of text, letting attention choose which chunks to load and still jump to any part of the context. It matched a leading long-context model while fetching far fewer tokens, and stretched one 7-billion-parameter model past 32k tokens.

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

Amirkeivan Mohtashami, Martin Jaggi
arXiv:2305.16300 · cs.CL, cs.LG · submitted May 25, 2023 · updated Nov 20, 2023
abstract · pdf · html · Published as a conference paper at NeurIPS 2023 - 37th Conference on Neural Information Processing Systems

add comment on HN
Also discussed: May 2023 (1 point, 0 comments)

They say it's infinite but then they use it to increase Llama's context length to 32k tokens instead of infinity. Still seems interesting.
Actually cool if it works. This would make many things possible on a single desktop. I'm afraid landmarking is actually a lossy compression. And the real content's size still limits model's even theoretical abilities.
It's infinite but not free. Larger context still means more VRAM used and longer compute times.
The link to the repo (https://github.com/epfml/landmark-attention) leads to "we'll publish something later".