通过校准提升注意力缓存压缩的准确性,减少长文本生成时的精度损失。
CaliDrop: KV Cache Compression with Calibration
- 基于相邻位置查询相似性,对剔除的键值对进行预判校准。
- 在高压缩比下仍保持接近原始模型的生成准确率。
- 适合需要高效长文本生成的部署场景,如客服机器人、文档摘要。
大型语言模型(LLMs)在生成过程中需大量计算资源。尽管键值(KV)缓存通过存储注意力中间结果显著加速了推理,但其内存占用随序列长度、批量大小和模型规模线性增长,在长上下文场景中成为瓶颈。现有缓存压缩技术包括令牌淘汰、量化和低秩投影,常相互结合使用。本文聚焦于改进令牌淘汰策略。该策略利用注意力模式通常稀疏的特性,移除较不重要的KV条目以节省内存,但往往导致显著的精度下降,尤其在高压缩比下。为此,我们提出 extbf{CaliDrop},一种通过校准增强的令牌淘汰新方法。初步实验表明,相邻位置的查询具有高度相似性。基于此,CaliDrop对被剔除的令牌执行推测性校准,以缓解淘汰带来的精度损失。大量实验显示,CaliDrop显著提升了现有淘汰方法的准确性。
原文摘要 · Abstract (English)
Large Language Models (LLMs) require substantial computational resources during generation. While the Key-Value (KV) cache significantly accelerates this process by storing attention intermediates, its memory footprint grows linearly with sequence length, batch size, and model size, creating a bottleneck in long-context scenarios. Various KV cache compression techniques, including token eviction, quantization, and low-rank projection, have been proposed to mitigate this bottleneck, often complementing each other. This paper focuses on enhancing token eviction strategies. Token eviction leverages the observation that the attention patterns are often sparse, allowing for the removal of less critical KV entries to save memory. However, this reduction usually comes at the cost of notable accuracy degradation, particularly under high compression ratios. To address this issue, we propose \textbf{CaliDrop}, a novel strategy that enhances token eviction through calibration. Our preliminary experiments show that queries at nearby positions exhibit high similarity. Building on this observation, CaliDrop performs speculative calibration on the discarded tokens to mitigate the accuracy loss caused by token eviction. Extensive experiments demonstrate that CaliDrop significantly improves the accuracy of existing token eviction methods.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。