arXivDaily arXiv每日学术速递 周一至周五更新
感恩节,周五至周末无更新,大家顺遂。周一再来吧
arXiv 2503.01330cs.CL
收藏

WeightedKV:用于大型语言模型的注意力分数加权键值缓存合并

WeightedKV: Attention Scores Weighted Key-Value Cache Merging for Large Language Models

Shanghai Jiao Tong University(上海交通大学)

Jian Yuan, Ziwei He, Haoli Bai, Jingwen Leng, Bo Jiang

AI总结:

提出无需训练的WeightedKV方法,通过丢弃不重要token的keys并按注意力分数加权合并其values,在低预算比例下优于基线方法,有效压缩KV缓存并保持上下文完整性。

摘要:

大型语言模型(LLMs)使用键值(KV)缓存来减少自回归生成中的冗余计算。然而,KV缓存大小在生成过程中线性增长,导致内存使用过多,尤其是对于长文本。大多数KV缓存压缩方法会驱逐不重要的KV对以维持固定的缓存大小,这会导致生成过程中token的永久丢失。然而,奇异值分解表明,values不像keys那样表现出强烈的低秩特性,这表明信息在values中分布得更加均匀,而keys内的分布则更具冗余性。因此,同时驱逐keys和values的方法可能会丢失关键信息,损害上下文的完整性,最终降低输出质量。为了解决这个问题,我们提出了WeightedKV,这是一种新颖的、无需训练的方法,它丢弃较不重要token的keys,同时通过以其平均注意力分数加权的凸组合将它们的values合并到相邻的token中。这样,保留的keys作为锚点引导生成过程,而合并的values提供了丰富的上下文背景。我们在四个广泛使用的语言建模数据集上评估了我们的方法,结果表明其性能优于所有基线方法,特别是在预算比例较低的情况下。

英文摘要:

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.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑