提出不丢值只合并关键信息的缓存压缩方法,提升长文本生成质量。
WeightedKV: Attention Scores Weighted Key-Value Cache Merging for Large Language Models
- 仅丢弃低重要性token的key,将其value加权合并到邻近token
- 在4个数据集上优于所有基线,尤其在低预算下表现突出
- 无需训练、适合需高效长文本生成的场景
大语言模型(LLMs)通过键值(KV)缓存减少自回归生成中的重复计算,但缓存大小随生成线性增长,导致内存占用过高,尤其在长文本生成时。现有压缩方法多通过淘汰不重要KV对来保持固定缓存大小,造成生成过程中不可逆的令牌丢失。然而,奇异值分解显示,值(values)不像键(keys)那样具有强低秩性,说明信息在值中分布更均匀,而非集中在少数部分。因此,同时淘汰键和值可能损失关键信息,破坏上下文完整性,最终影响输出质量。为此,我们提出WeightedKV,一种无需训练的新方法:丢弃低重要性令牌的键,将其值通过注意力平均得分加权合并到相邻令牌。保留的键作为生成引导锚点,合并后的值则提供丰富上下文背景。我们在四个常用语言建模数据集上评估该方法,结果表明其性能全面超越所有基线,尤其在低预算比例下优势明显。
原文摘要 · Abstract (English)
Large Language Models (LLMs) use key-value (KV) cache to reduce redundant computation in autoregressive generation. However, the KV cache size increases linearly during generation, leading to excessive memory usage, especially for long texts. Most KV cache compression methods evict the unimportant KV pairs to maintain a fixed cache size, which leads to the permanent loss of tokens during generation. However, singular value decomposition shows that \textit{values} do not exhibit a strong low-rank property as \textit{keys} do, suggesting that information is distributed more evenly across \textit{values}, in contrast to its more redundant distribution within \textit{keys}. Therefore, methods that evict both \textit{keys} and \textit{values} risk losing crucial information and compromise context integrity, ultimately degrading the output quality. To address this problem, we propose WeightedKV, a novel, training-free approach that discards the \textit{keys} of less important tokens, while merging their \textit{values} into neighboring tokens via a convex combination weighted by their average attention scores. In this way, the retained \textit{keys} serve as anchors that guide the generation process, while the merged \textit{values} provide a rich contextual backdrop. We assess our method on four widely used language modeling datasets, demonstrating superior performance compared to all baseline methods, particularly with a lower budget ratio.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。