Reproduce “Efficient Streaming Language Models with Attention Sinks” on OpenResearch

Turn your favorite coding agents into research agents that review literature, develop hypotheses, and run experiments.

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

About this paper

Guangxuan Xiao, Yuandong Tian, Beidi Chen, Song Han, Mike Lewis

StreamingLLM enables long-running generation with a bounded cache by retaining initial key–value entries and recent tokens while discarding the middle. In a Llama-2-13B test on the first 65,000-token PG-19 book, it reaches perplexity 5.40 with four initial and 1,020 recent tokens, versus 5,158.07 for a 1,024-token recent-only cache; this finding is specific to that model, cache, and sample.

Key insights

  • A "attention sink" phenomenon exists where LLMs disproportionately assign attention to initial tokens, which act as stable points for residual attention due to the SoftMax mechanism.
  • Retaining these initial "attention sink" tokens is crucial for maintaining stable perplexity and preventing performance collapse in windowed attention when processing long sequences.
  • Pre-training LLMs with a dedicated learnable sink token can optimize their architecture for efficient streaming, enabling stable performance with only a single explicit sink token.

Summary by alphaXiv.

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