SimLayerKV: A Simple Framework for Layer-Level KV Cache Reduction

要約

大規模言語モデル (LLM) の最近の進歩により、長いコンテキストを処理できるようにその機能が拡張されました。
ただし、モデル層の数と入力シーケンスの長さが増加すると、キーバリュー (KV) キャッシュの保存に必要なメモリが大幅に増加し、効率的な推論に課題が生じます。
この問題を軽減するために、識別された遅延レイヤー内のキャッシュを選択的に削除することでレイヤー間の KV キャッシュの冗長性を減らす、シンプルかつ効果的な方法である SimLayerKV を紹介します。
私たちのアプローチは、ロングコンテキスト LLM の特定のレイヤーが「遅延」動作を示し、非遅延レイヤーと比較して長距離依存関係のモデリングにあまり寄与しないという観察に基づいています。
注意の重みパターンを分析することにより、これらの遅延層の動作は、特定の入力の生成中にトークン間で一貫していることがわかります。
この洞察が SimLayerKV の動機となり、遅延レイヤーを特定し、それに応じて KV キャッシュを削減します。
SimLayerKV はトレーニング不要で汎用性があり、わずか 7 行のコードで実装できます。
私たちは、LongBench ベンチマークの 16 タスクにわたって、LLaMA2-7B、LLaMA3-8B、Mistral-7B などの 3 つの代表的な LLM について広範な実験を実施しました。
結果は、SimLayerKV が 4 ビット量子化と組み合わせた場合、わずか 1.2% のパフォーマンス低下で 5$\times$ の KV キャッシュ圧縮率を達成することを示しています。
私たちのコードは https://github.com/sail-sg/SimLayerKV で入手できます。

要約(オリジナル)

Recent advancements in large language models (LLMs) have extended their capabilities to handle long contexts. However, increasing the number of model layers and the length of input sequences significantly escalates the memory required to store key-value (KV) cache, posing challenges for efficient inference. To mitigate this issue, we present SimLayerKV, a simple yet effective method that reduces inter-layer KV cache redundancies by selectively dropping cache in identified lazy layers. Our approach is based on the observation that certain layers in long-context LLMs exhibit ‘lazy’ behavior, contributing less to modeling long-range dependencies compared to non-lazy layers. By analyzing attention weight patterns, we find that the behavior of these lazy layers is consistent across tokens during generation for a given input. This insight motivates our SimLayerKV, which identifies lazy layers and reduces their KV cache accordingly. SimLayerKV is training-free, generalizable, and can be implemented with only seven lines of code. We conduct extensive experiments on three representative LLMs, e.g., LLaMA2-7B, LLaMA3-8B, and Mistral-7B across 16 tasks from the LongBench benchmark. The results demonstrate that SimLayerKV achieves a KV cache compression ratio of 5$\times$ with only a 1.2% performance drop when combined with 4-bit quantization. Our code is available at https://github.com/sail-sg/SimLayerKV.

arxiv情報

著者 Xuan Zhang,Cunxiao Du,Chao Du,Tianyu Pang,Wei Gao,Min Lin
発行日 2024-10-17 17:58:14+00:00
arxivサイト arxiv_id(pdf)

提供元, 利用サービス

arxiv.jp, Google

カテゴリー: cs.AI, cs.CL, cs.LG パーマリンク