arXiv:2508.11661cs.LGcs.CL2025-08AAAI被引 4

提出首个面向多文档检索生成的稀疏注意力压缩方法,显著提升长序列推理效率。

Sparse Attention across Multiple-context KV Cache

论文配图:Sparse Attention across Multiple-context KV Cache
图 1 · 摘自论文原文
  • 基于多上下文间互补信息动态筛选关键键值缓存
  • 仅需15%序列长度即可保持全重计算精度
  • 适合需要高效处理多源检索文本的生成任务

大语言模型在长序列推理中面临显著成本挑战。为提升效率,复用历史键值(KV)缓存成为主流方法。近期研究通过稀疏注意力机制选择最相关缓存,降低序列长度。然而现有方法仅适用于单上下文场景,因存在因果注意力依赖而无法处理检索增强生成(RAG)中的多文档独立缓存。在多上下文缓存中,各文档缓存独立存储,缺乏跨上下文注意力,导致现有稀疏方法失效。尽管已有工作通过部分重计算缓解精度损失,但需保留全部缓存,难以降低内存开销。本文提出SamKV,首次探索多上下文缓存的注意力稀疏化。SamKV在稀疏化某上下文时考虑其他上下文的互补信息,并局部重计算被删减部分。实验表明,该方法将序列长度压缩至15%,且精度与全重计算基线相当,显著提升多上下文RAG场景下的吞吐量。

原文摘要 · Abstract (English)

Large language models face significant cost challenges in long-sequence inference. To address this, reusing historical Key-Value (KV) Cache for improved inference efficiency has become a mainstream approach. Recent advances further enhance throughput by sparse attention mechanisms to select the most relevant KV Cache, thereby reducing sequence length. However, such techniques are limited to single-context scenarios, where historical KV Cache is computed sequentially with causal-attention dependencies. In retrieval-augmented generation (RAG) scenarios, where retrieved documents as context are unknown beforehand, each document's KV Cache is computed and stored independently (termed multiple-context KV Cache), lacking cross-attention between contexts. This renders existing methods ineffective. Although prior work partially recomputes multiple-context KV Cache to mitigate accuracy loss from missing cross-attention, it requires retaining all KV Cache throughout, failing to reduce memory overhead. This paper presents SamKV, the first exploration of attention sparsification for multiple-context KV Cache. Specifically, SamKV takes into account the complementary information of other contexts when sparsifying one context, and then locally recomputes the sparsified information. Experiments demonstrate that our method compresses sequence length to 15% without accuracy degradation compared with full-recompuation baselines, significantly boosting throughput in multi-context RAG scenarios.

稀疏注意力KV缓存RAG长序列推理

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