2025-03-05 · 进阶 · 机器学习 · 自然语言处理

Q-Filters: Leveraging QK Geometry for Efficient KV Cache Compression

该论文提出了一种名为Q-Filters的无需训练的KV Cache压缩方法,通过利用查询键向量的几何性质来高效地筛选出不太重要的键值对,从而实现高效的键值缓存压缩。

更新于 2025-03-06。作者:Nathan Godey、Alessio Devoto、Yu Zhao、Simone Scardapane、Pasquale Minervini、Éric de la Clergerie、Benoît Sagot。

中文摘要

自回归语言模型依赖于键值(KV)缓存,这避免了在生成过程中重新计算过去的隐藏状态,从而使其更快速。随着模型大小和上下文长度的增加,KV 缓存成为一个显著的内存瓶颈,这需要压缩方法来限制其在生成过程中的大小。在这篇论文中,我们发现查询(Q)和键(K)向量的一些令人惊讶的特性,这使得我们能够高效地近似注意力分数,而不需要计算注意力图。我们提出了 Q-Filters,这是一种无需训练的 KV 缓存压缩方法,它基于单一的无上下文投影过滤掉不那么关键的键值对。与许多替代方案相反,Q-Filters 与 FlashAttention 兼容,因为它不需要直接访问注意力权重。在长上下文设置中的实验结果表明,Q-Filters 在检索任务中与基于注意力的压缩方法(如 SnapKV)具有竞争力,同时在生成设置中持续优于高效的压缩方案(如 Streaming-LLM)。值得注意的是,Q-Filters 在“大海捞针”任务中达到了 99% 的准确率,同时将生成困惑度下降减少了高达 65%,与 Streaming-LLM 相比。

英文摘要

Autoregressive language models rely on a Key-Value (KV) Cache, which avoids re-computing past hidden states during generation, making it faster. As model sizes and context lengths grow, the KV Cache becomes a significant memory bottleneck, which calls for compression methods that limit its size during generation. In this paper, we discover surprising properties of Query (Q) and Key (K) vectors that allow us to efficiently approximate attention scores without computing the attention maps. We propose Q-Filters, a training-free KV Cache compression method that filters out less crucial Key-Value pairs based on a single context-agnostic projection. Contrarily to many alternatives, Q-Filters is compatible with FlashAttention, as it does not require direct access to attention weights. Experimental results in long-context settings demonstrate that Q-Filters is competitive with attention-based compression methods such as SnapKV in retrieval tasks while consistently outperforming efficient compression schemes such as Streaming-LLM in generation setups. Notably, Q-Filters achieves a 99% accuracy in the needle-in-a-haystack task with a x32 compression level while reducing the generation perplexity drop by up to 65% in text generation compared to Streaming-LLM.

解读

一句话总结

该论文提出了一种名为Q-Filters的无需训练的KV Cache压缩方法,通过利用查询键向量的几何性质来高效地筛选出不太重要的键值对,从而实现高效的键值缓存压缩。

问题1:这篇论文想要解决什么具体问题?

问题2:论文的核心创新点是什么?

问题3:实验结果如何验证了方法的有效性?

问题4:这个研究的实际应用价值是什么?

来源