Efficient Streaming Language Models with Attention Sinks

Guangxuan Xiao, Yuandong Tian, Beidi Chen, Song Han, Mike Lewis
2/12/2026

No official code found. Best implementation: mit-han-lab/streaming-llm (7,248 stars, MIT, last commit 2024-07-11). 1 more below.

Abstract

Deploying Large Language Models (LLMs) in streaming applications such as multi-round dialogue, where long interactions are expected, is urgently needed but poses two major challenges. Firstly, during the decoding stage, caching previous tokens' Key and Value states (KV) consumes extensive memory. Secondly, popular LLMs cannot generalize to longer texts than the training sequence length. Window attention, where only the most recent KVs are cached, is a natural approach -- but we show that it fails when the text length surpasses the cache size. We observe an interesting phenomenon, namely attention sink, that keeping the KV of initial tokens will largely recover the performance of window attention. In this paper, we first demonstrate that the emergence of attention sink is due to the strong attention scores towards initial tokens as a"sink"even if they are not semantically important. Based on the above analysis, we introduce StreamingLLM, an efficient framework that enables LLMs trained with a finite length attention window to generalize to infinite sequence lengths without any fine-tuning. We show that StreamingLLM can enable Llama-2, MPT, Falcon, and Pythia to perform stable and efficient language modeling with up to 4 million tokens and more. In addition, we discover that adding a placeholder token as a dedicated attention sink during pre-training can further improve streaming deployment. In streaming settings, StreamingLLM outperforms the sliding window recomputation baseline by up to 22.2x speedup. Code and datasets are provided at https://github.com/mit-han-lab/streaming-llm.

View on arXivView PDF

Code Implementations(2)

MIT

[ICLR 2024] Efficient Streaming Language Models with Attention Sinks

7,248399PythonSep 29, 20232 years agoMIT
Apache-2.0

⚡ Build your chatbot within minutes on your favorite device; offer SOTA compression techniques for LLMs; run LLMs efficiently on Intel Platforms⚡

2,177216C, C++Nov 11, 20222 years agoApache-2.0
4-bitsautoroundchatbotchatpdfgaudi3+11 more

Similar Papers

Cite this paper

@article{xiao2026efficient,
  title  = {Efficient Streaming Language Models with Attention Sinks},
  author = {Guangxuan Xiao and Yuandong Tian and Beidi Chen and Song Han and Mike Lewis},
  year   = {2026},
  eprint = {2309.17453},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/pdf/2309.17453},
  journal = {ICLR 2023 2023}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2309.17453.svg)](https://codeofpaper.com/paper/2309.17453)

Discussion