arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2605.14037cs.LGcs.CL
收藏

自修剪键值注意机制:通过预测未来效用学习何时写作

Self-Pruned Key-Value Attention: Learning When to Write by Predicting Future Utility

Meta FAIR

Gergely Szilvasy, Manuel Faysse, Maria Lomeli, Matthijs Douze, Pierre-Emmanuel Mazaré, Loïc Cabannes, Wen-tau Yih, Hervé Jégou

AI总结:

本文提出自修剪键值注意机制,通过预测未来效用减少长序列的KV缓存大小,提升内存使用和解码速度,同时保持验证损失和下游任务性能。

摘要:

在现代测试时计算和代理范式下,语言模型处理越来越长的序列。基于transformer架构的高效文本生成日益受到键值缓存内存足迹和带宽的限制。为了解决这一限制,我们引入了自修剪键值注意机制(SP-KV),该机制旨在预测未来KV效用以减少长期KV缓存的大小。该策略在细粒度上运作:一个轻量级的效用预测器对每个键值对进行评分,而最近的KVs总是通过本地窗口可用,较旧的对被写入缓存并在全局注意中使用,仅当其预测效用超过给定阈值时。LLM和效用预测器通过下一个标记预测损失联合端到端训练,并从预训练LLM检查点中进行调整。与强制固定压缩比不同,SP-KV进行动态稀疏化:该机制适应输入,通常将KV缓存大小减少3到10倍,更长的序列往往更具可压缩性。这导致内存使用和解码速度的巨大提升,验证损失和广泛下游任务性能几乎没有下降。除了作为有效的KV缓存减少机制外,我们的方法还揭示了结构化的层和头特定稀疏模式,可用于指导混合局部-全局注意架构的设计。

英文摘要:

Under modern test-time compute and agentic paradigms, language models process ever-longer sequences. Efficient text generation with transformer architectures is increasingly constrained by the Key-Value cache memory footprint and bandwidth. To address this limitation, we introduce Self-Pruned Key-Value Attention (SP-KV), a mechanism designed to predict future KV utility in order to reduce the size of the long-term KV cache. This strategy operates at a fine granularity: a lightweight utility predictor scores each key-value pair, and while recent KVs are always available via a local window, older pairs are written in the cache and used in global attention only if their predicted utility surpasses a given threshold. The LLM and the utility predictor are trained jointly end-to-end exclusively through next-token prediction loss, and are adapted from pretrained LLM checkpoints. Rather than enforcing a fixed compression ratio, SP-KV performs dynamic sparsification: the mechanism adapts to the input and typically reduces the KV cache size by a factor of $3$ to $10\times$, longer sequences often being more compressible. This leads to vast improvements in memory usage and decoding speed, with little to no degradation of validation loss nor performance on a broad set of downstream tasks. Beyond serving as an effective KV-cache reduction mechanism, our method reveals structured layer- and head-specific sparsity patterns that we can use to guide the design of hybrid local-global attention architectures.

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

↑