用小模型辅助加速大模型推理,解决RAG长文本生成慢且质量差的问题。
CacheClip: Accelerating RAG with Effective KV Cache Reuse
- 用小模型预测关键token,只重算必要部分的缓存,减少冗余计算
- 在长文本任务中保持91.1%的生成质量,比现有方法提升4.5~16.1分
- 支持灵活调节重算比例,适合对速度与质量要求不同的实际场景
检索增强生成(RAG)系统因输入序列过长导致首字延迟严重。现有缓存复用方法存在根本权衡:前缀缓存需完全一致前缀,但现实中极少出现;直接预计算则因缺少跨块注意力而牺牲质量,且重复注意力项浪费资源。近期方法如APE和CacheBlend虽部分缓解问题,仍不足以支撑稳健的RAG应用。本文提出CacheClip框架,通过发现小型辅助模型与主模型在最后一层注意力分布上的相似性,高效识别恢复跨块注意力的关键token,显著提升跨块推理质量。该框架集成四项技术:(1) 辅助模型引导的令牌选择,实现缓存的有选择性重算;(2) 共享前缀设计,消除冗余注意力损耗;(3) 滑动窗口分组策略,维持局部一致性;(4) CPU-GPU混合架构,将辅助模型推理迁移至空闲CPU,避免额外GPU开销。重算比例可调,支持按需平衡效率与质量。实验表明,CacheClip在NIAH和LongBench上分别保留85.2%和91.1%的全注意力性能,优于CacheBlend和APE(NIAH提升16.1/12.8分,LongBench提升4.5/4.2分,重算比例=20%)。同时,在预填充阶段提速最高达3.33倍(重算比例=20%),为RAG系统提供了高效的实用解决方案。
原文摘要 · Abstract (English)
Retrieval-Augmented Generation (RAG) systems suffer from severe time-to-first-token (TTFT) bottlenecks due to long input sequences. Existing KV cache reuse methods face a fundamental trade-off: prefix caching requires identical prefixes that rarely occur in RAG scenarios, while direct precomputation sacrifices quality due to missing inter-chunk attention and repeated attention sinks. Recent methods like APE and CacheBlend partially address these issues but remain inadequate for robust RAG applications. This paper presents CacheClip, a novel framework that achieves both fast TTFT and high generation quality. Our key insight is that small auxiliary LLMs exhibit similar last-layer attention distributions to primary LLMs (the target model for generation), enabling efficient identification of tokens critical for restoring inter-chunk attention, thereby significantly improving response quality on cross-chunk reasoning tasks. CacheClip integrates four techniques: (1) auxiliary-model-guided token selection for selective KV cache recomputation, (2) shared prefixes to eliminate redundant attention sinks, (3) a sliding-window grouping strategy to maintain local coherence during partial KV cache updates, and (4) a CPU-GPU hybrid design that offloads auxiliary model inference to idle CPU resources, avoiding additional GPU overhead. The recomputation ratio is adjustable, allowing users to flexibly balance efficiency and quality for different deployment requirements. Experiments show CacheClip retains up to 85.2% and 91.1% of full-attention performance on NIAH and LongBench, outperforming CacheBlend and APE by 16.1 and 12.8 points on NIAH, and by 4.5 and 4.2 points on LongBench (with recomp% = 20%). Meanwhile, CacheClip accelerates LLM inference by up to 3.33$\times$ in prefill time (with recomp% = 20%), providing a practical solution to the efficiency-quality trade-off in RAG systems.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。