Reproduce “Landmark Attention: Random-Access Infinite Context Length for Transformers” on OpenResearch

Run Claude Code, Codex or any coding agent as a research agent: literature, hypotheses and experiments on your laptop, cluster or cloud GPUs.

Universal app for Apple silicon and Intel. Requires macOS 11 or later.

About this paper

Amirkeivan Mohtashami, Martin Jaggi

Researchers at EPFL developed "Landmark Attention," a novel Transformer mechanism that enables processing of arbitrarily long input sequences by augmenting input with special tokens that gate access to blocks of information. This approach reduces inference computation and memory by factors equal to the block length and successfully extends the context capacity of a LLaMA 7B model to over 32,000 tokens while maintaining high retrieval accuracy.

Key insights

  • Attention can be explicitly repurposed for efficient, learnable retrieval of entire blocks of information from arbitrarily long contexts, rather than just computing pairwise relationships.
  • By decoupling training context length from inference context length and leveraging a memory hierarchy, Transformer inference can achieve significant computational and memory savings for long sequences.
  • Fine-tuning pre-trained large language models with Landmark Attention effectively extends their context understanding capabilities to tens of thousands of tokens without full re-training.
  • The attention weights on landmark tokens provide an interpretable mechanism for understanding which parts of a long context the model is actively recalling.

Summary by alphaXiv.

Tip: change arxiv.org to autoarxiv.org in any arXiv abstract link to open the paper here.