[論文レビュー] Efficient Streaming Language Models with Attention Sinks
StreamingLLM は、有限のアテンション窓で訓練された LLM が、初期のアテンション・シンク KV ペアの小さな集合を保持することで無限長のシーケンスへ一般化し、安定した perplexity を達成するとともに、複数のモデルにおいてスライディングウィンドウのベースラインに対して最大で 22.2x のデコード速度アップを実現します。
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.
研究の動機と目的
- 無制限のテキスト入力を伴うストリーミングアプリケーションにおける LLM の効率的展開を動機づける。
- 長文に対してウィンドウ注意が機能しなくなる原因を診断し、アテンション・シンクの振る舞いを特定する。
- 非ファインチューニングの単純なフレームワーク(StreamingLLM)を提案し、有限窓モデルを無限入力へ一般化する。
- 専用のシンクトークンで事前学習することがストリーミング性能をモデル横断でさらに改善することを示す。
提案手法
- 自己回帰型 LLM において大きな注意スコアを引きつける初期トークンとしてアテンション・シンクを識別する。
- 推論時に初期の小さなシンク KV のセットとスライディングウィンドウ KV を組み合わせて StreamingLLM を実演する。
- ローリング KV キャッシュにおける相対位置エンコーディング(RoPE/ALiBi)の取り扱いを説明する。
- ストリーミングを安定化させるため、2つの事前学習バリアントを提案する: vanilla のアテンション、ゼロ・シンク、そして学習可能なシンクトークン。
- Llama-2、MPT、Falcon、Pythia を横断して評価し、4M トークン長文テストと StreamEval を含む。

実験結果
リサーチクエスチョン
- RQ1ファインチューニングなしで、有限のアテンション窓で訓練された LLM は、事前学習ウィンドウよりはるかに長いテキストを正確にモデル化できるか。
- RQ2長い系列に対するウィンドウ注意の性能低下の原因は何か、アテンション・シンクがそれを説明・緩和できるか。
- RQ3事前学習時に専用のアテンション・シンクトークンを導入することは、全体の性能を損なうことなくストリーミング展開を改善するか。
- RQ4StreamingLLM は ultra-long texts に対して複数のモデルファミリでどの程度のスピードアップと安定した perplexity を実現できるか。
主な発見
- ウィンドウ注意は初期トークンが追い出されると崩壊し、高い perplexity を生じる。
- 初期トークンはアテンション・シンクとして機能し、深い層で不均等なアテンションを複数モデルにわたり引きつける。
- StreamingLLM は長文が 20K+ トークンまで、また最大で 4百万トークンまで安定した perplexity を維持し、滑動窓再計算ベースラインと同等の性能を発揮する。
- 初期シンクトークンを4つ用いるだけでストリーミングを安定化でき、一つまたは二つのシンクでは不十分。
- 学習可能なシンクトークンを用いた事前学習は、シンクトークンのみで安定したストリーミング perplexity を得られ、標準的な NLP ベンチマークでの性能を維持する。

この論文を読む
Nubintのビューアで原文を開き、読みながら気になる箇所をすぐに質問できます。
Nubintでこの論文を読むこのレビューはAIが論文の原文をもとに作成しました。引用する前に原文をご確認ください。