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

缓存什么更持久:用于LLMs中内存受限KV缓存的令牌保留

Cache What Lasts: Token Retention for Memory-Bounded KV Cache in LLMs

Department of Computer Science, Yale University(耶鲁大学计算机科学系);JPMorganChase AI Research(摩根大通人工智能研究)

Ngoc Bui, Shubham Sharma, Simran Lamba, Saumitra Mishra, Rex Ying

AI总结:

TRIM-KV通过学习令牌的内在重要性实现内存受限的KV缓存优化,有效提升LLM在低内存环境下的推理性能。

摘要:

内存和计算仍然是长视界LLM推理的核心瓶颈,因为自注意力的二次成本和不断增长的键值(KV)缓存。现有的内存受限推理策略,如量化、卸载或启发式KV驱逐,要么导致高调度成本,要么依赖于不可靠的基于注意力的重要性代理。我们提出了TRIM-KV,一种新的方法,通过轻量级保留门学习每个令牌在创建时的内在重要性。每个门预测一个标量保留分数,随时间衰减,反映该令牌对特定层和头部的长期用途。当内存预算超过时,分数低的令牌会被驱逐,确保缓存始终包含最关键的令牌。TRIM-KV通过从冻结的LLM中进行蒸馏结合容量损失进行高效训练,仅需门的微调,并增加极小的推理开销。在数学推理(GSM8K、MATH-500、AIME24)、过程生成(LongProc)、对话长记忆基准(LongMemEval)以及长上下文理解(LongBenchV2和SCBench)中,TRIM-KV在数学推理(GSM8K、MATH-500、AIME24)、过程生成(LongProc)、对话长记忆基准(LongMemEval)以及长上下文理解(LongBenchV2和SCBench)中,TRIM-KV始终优于强大的驱逐和可学习检索基线,特别是在低内存情况下。令人惊讶的是,它甚至在某些情况下超过了全缓存模型,表明选择性保留可以作为一种正则化形式,抑制无信息令牌的噪声。定性分析进一步揭示,学习的保留分数与人类直觉一致,自然恢复诸如sink tokens、滑动窗口和gist压缩等启发式方法,而无需显式设计。除了效率外,保留分数提供了关于层和头部特定作用的见解,表明了通往LLM可解释性的新路径。

英文摘要:

Memory and computation remain core bottlenecks in long-horizon LLM inference due to the quadratic cost of self-attention and the ever-growing key-value (KV) cache. Existing strategies for memory-bounded inference, such as quantization, offloading, or heuristic KV eviction, either incur high orchestration costs or rely on unreliable attention-based proxies of importance. We propose TRIM-KV, a novel approach that learns each token's intrinsic importance at creation time via a lightweight retention gate. Each gate predicts a scalar retention score that decays over time, reflecting the long-term utility of the token for a specific layer and head. Tokens with low scores are evicted when the memory budget is exceeded, ensuring that the cache always contains the most critical tokens. TRIM-KV is trained efficiently through distillation from a frozen LLM combined with a capacity loss, requiring only gate fine-tuning and adding negligible inference overhead. Across mathematical reasoning (GSM8K, MATH-500, AIME24), procedural generation (LongProc), conversational long-memory benchmarks (LongMemEval), and long-context understanding (LongBenchV2 and SCBench), TRIM-KV consistently outperforms strong eviction and learnable retrieval baselines, especially in low-memory regimes. Remarkably, it even surpasses full-cache models in some settings, showing that selective retention can serve as a form of regularization, suppressing noise from uninformative tokens. Qualitative analyses further reveal that learned retention scores align with human intuition, naturally recovering heuristics such as sink tokens, sliding windows, and gist compression without explicit design. Beyond efficiency, retention scores provide insights into layer- and head-specific roles, suggesting a new path toward LLM interpretability.

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

↑