Efficient Streaming Language Models with Attention Sinks

AI-generated keywords: StreamingLLM Large Language Models Attention Sink Length Extrapolation Context Window Extension

AI-generated Key Points

  • Challenges of deploying Large Language Models (LLMs) in streaming applications:
  • Extensive memory consumption during decoding stage
  • Inability of popular LLMs to generalize to longer texts than training sequence length
  • Proposed framework called StreamingLLM:
  • Addresses challenges and enables LLMs to generalize to infinite sequence lengths without fine-tuning
  • Leverages attention sink by keeping Key and Value states (KV) of initial tokens to improve performance
  • StreamingLLM enables stable and efficient language modeling with up to 4 million tokens or more for LLMs like Llama-2, MPT, Falcon, and Pythia
  • Addition of a placeholder token as dedicated attention sink during pre-training improves streaming deployment
  • Related work in three main areas: Length Extrapolation, Context Window Extension, and Improving LLMs' Utilization of Long Text
  • StreamingLLM outperforms baseline methods like sliding window recomputation with up to 22.2x speedup in streaming settings
  • Code and datasets for implementation provided on GitHub.
Also access our AI generated: Comprehensive summary, Lay summary, Blog-like article; or ask questions about this paper to our AI assistant.

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

License: CC BY 4.0

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.

Submitted to arXiv on 29 Sep. 2023

Ask questions about this paper to our AI assistant

You can also chat with multiple papers at once here.

AI assistant instructions?

Results of the summarizing process for the arXiv paper: 2309.17453v2

The paper discusses the challenges of deploying Large Language Models (LLMs) in streaming applications, particularly in multi-round dialogue where long interactions are expected. The two main challenges identified are the extensive memory consumption during the decoding stage and the inability of popular LLMs to generalize to longer texts than their training sequence length. The authors propose a framework called StreamingLLM that addresses these challenges and enables LLMs trained with a finite length attention window to generalize to infinite sequence lengths without any fine-tuning. The emergence of a phenomenon called "attention sink" is observed, where initial tokens receive strong attention scores even if they are not semantically important. This observation leads to the introduction of StreamingLLM, which leverages attention sink by keeping the Key and Value states (KV) of initial tokens to improve performance. The authors demonstrate that StreamingLLM enables LLMs like Llama-2, MPT, Falcon, and Pythia to perform stable and efficient language modeling with up to 4 million tokens or more. Additionally, the authors propose adding a placeholder token as a dedicated attention sink during pre-training, which further improves streaming deployment. They show that pre-training language models with this single sink token preserves their performance in streaming cases without requiring multiple initial tokens as attention sinks. The paper also discusses related work in three main areas: Length Extrapolation, Context Window Extension, and Improving LLMs' Utilization of Long Text. While progress has been made in these areas individually, none of them achieve infinite length extrapolation or fit for streaming applications like StreamingLLM does. Overall, the proposed StreamingLLM framework addresses the challenges of deploying LLMs in streaming applications by leveraging attention sink and introducing a dedicated attention sink token. It outperforms baseline methods like sliding window recomputation by achieving up to 22.2x speedup in streaming settings. Code and datasets for implementation are provided on GitHub.
Created on 28 Nov. 2023

Assess the quality of the AI-generated content by voting

Score: 0

Why do we need votes?

Votes are used to determine whether we need to re-run our summarizing tools. If the count reaches -10, our tools can be restarted.

The previous summary was created more than a year ago and can be re-run (if necessary) by clicking on the Run button below.

Similar papers summarized with our AI tools

Navigate through even more similar papers through a

tree representation

Look for similar papers (in beta version)

By clicking on the button above, our algorithm will scan all papers in our database to find the closest based on the contents of the full papers and not just on metadata. Please note that it only works for papers that we have generated summaries for and you can rerun it from time to time to get a more accurate result while our database grows.

Disclaimer: The AI-based summarization tool and virtual assistant provided on this website may not always provide accurate and complete summaries or responses. We encourage you to carefully review and evaluate the generated content to ensure its quality and relevance to your needs.