arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2605.25475cs.CLcs.AI
收藏

IndexMem: 基于潜在记忆的学习型KV缓存驱逐策略用于长上下文LLM推理

IndexMem: Learned KV-Cache Eviction with Latent Memory for Long-Context LLM Inference

The Hong Kong University of Science(香港科学与技术大学);Zhejiang University(浙江大学)

Xintong Yang, Hao Gu, Binxing Xu, Lujun Li, Bei Liu, Jiacheng Liu, Qiyuan Zhu, Yike Guo, Sirui Han

AI总结:

提出一种可学习的索引器预测KV重要性,并结合轻量级潜在记忆模块压缩被驱逐的令牌,以在有限KV预算下实现准确的长上下文推理。

摘要:

大型语言模型(LLM)越来越需要处理长上下文,但标准softmax注意力机制的KV缓存随序列长度线性增长,迅速成为长上下文推理的瓶颈。一种实用的补救措施是驱逐不太重要的KV条目;然而,现有的驱逐策略大多是启发式的,难以捕捉令牌重要性的丰富、输入相关的分布。在这项工作中,我们引入了一个可学习的索引器来预测KV重要性,从而能够更准确地保留关键令牌。同时,简单地驱逐令牌会永久丢弃其信息,导致不可逆的遗忘和长距离检索性能下降。为了解决这个问题,我们提出了一个轻量级的潜在记忆模块,将驱逐的令牌压缩成紧凑的、在线更新的状态,并提供残差读出以补偿通过KV驱逐丢失的注意力贡献。总的来说,我们的方法能够在有限的KV预算下实现准确的长上下文推理,在RULER(4K/16K)上对Qwen、Mistral和Llama模型(在激进驱逐下提升高达25分)带来一致的改进,在Needle-in-a-Haystack检索中显著更稳定,并且在LongBench得分和压缩曲线上优于现有的驱逐策略。

英文摘要:

Large Language Models (LLMs) are increasingly expected to operate over long contexts, yet standard softmax attention incurs a KV cache that grows linearly with sequence length, quickly becoming the bottleneck for long context inference. A practical remedy is to evict less important KV entries; however, existing eviction policies are largely heuristic and struggle to capture the rich, input-dependent distribution of token importance. In this work, we introduce a learnable indexer that predicts KV importance, enabling more accurate retention of critical tokens. Meanwhile, naively evicting tokens permanently discards their information, leading to irreversible forgetting and degraded retrieval over long ranges. To address this, we propose a lightweight latent memory module that compresses evicted tokens into a compact, online-updated state and provides residual readouts to compensate for the attention contributions lost through KV eviction. Collectively, our method enables accurate long-context inference under a bounded KV budget, delivering consistent improvements on RULER (4K/16K) across Qwen, Mistral, and Llama models (up to 25 points under aggressive eviction), markedly more stable Needle-in-a-Haystack retrieval, and superior LongBench scores and compression curves compared to existing eviction policies.

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

↑