arXiv:2606.24467cs.AI2026-06被引 1

通过语义检索头精准压缩注意力缓存,大幅降低长文本推理内存占用。

CompressKV: Semantic-Retrieval-Guided KV-Cache Compression for Resource-Efficient Long-Context LLM Inference

论文配图:CompressKV: Semantic-Retrieval-Guided KV-Cache Compression for Resource-Efficient Long-Context LLM Inference
图 1 · 摘自论文原文
  • 基于语义检索头识别关键上下文,选择保留重要键值对
  • 仅用3%缓存保持LongBench上97%性能,0.7%存储达90%准确率
  • 按层分配缓存预算,适配资源受限设备的长文本推理

长上下文大语言模型推理受键值(KV)缓存内存开销和解码成本限制,难以在资源受限硬件上持续部署。现有缓存淘汰方法对GQA架构中所有注意力头采用启发式打分,忽略各头功能差异,导致关键信息被误删,损害模型性能。为此,我们提出CompressKV,一种面向GQA架构的高效KV缓存压缩框架。该方法不聚合所有头的注意力得分,而是识别出捕捉提示首尾及语义重要中间证据的语义检索头(SRHs),据此筛选应保留的键值对。同时,根据离线估算的逐层淘汰误差,动态分配缓存预算。在LongBench与Needle-in-a-Haystack上的实验表明,CompressKV在各类内存预算下均优于现有方法:在LongBench问答任务中仅使用3%缓存即可保持超过97%的全缓存性能;在Needle-in-a-Haystack任务中,仅0.7%存储量即达90%准确率。结果证明其显著提升了长上下文推理的资源-性能权衡。代码已开源:https://github.com/TUDa-HWAI/CompressKV

原文摘要 · Abstract (English)

Long-context large language model (LLM) inference is increasingly constrained by the memory footprint and decoding cost of key-value (KV) caches, limiting sustainable deployment on resource-constrained hardware. Existing KV cache eviction methods typically apply heuristic token scoring over all heads in GQA-based LLMs. These methods ignore the different functionalities of attention heads, leading to the eviction of critical tokens and thus degrading the performance of LLMs. To address this issue, we propose CompressKV, a resource-efficient KV-cache compression framework for GQA-based LLMs. Instead of aggregating attention scores from all heads, CompressKV identifies Semantic Retrieval Heads (SRHs) that capture both the initial and final tokens of a prompt and semantically important mid-context evidence, and uses them to select tokens whose KV pairs should be retained. Furthermore, CompressKV allocates cache budgets across layers according to offline estimates of layer-wise eviction error. Experiments on LongBench and Needle-in-a-Haystack show that CompressKV consistently outperforms existing KV-cache eviction methods across memory budgets. Notably, it preserves over 97\% of full-cache performance using only 3\% of the KV cache on LongBench question-answering tasks and achieves 90\% accuracy with just 0.7\% KV storage on Needle-in-a-Haystack. These results demonstrate an improved resource--performance trade-off for long-context LLM inference. Our code is publicly available at: https://github.com/TUDa-HWAI/CompressKV

KV缓存压缩长文本推理GQA架构资源效率

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。