CacheFocus:面向高效检索增强生成的动态缓存重定位
CacheFocus: Dynamic Cache Re-Positioning for Efficient Retrieval-Augmented Generation
AI总结:
针对大语言模型输入长度有限和计算成本高的问题,提出无需额外训练的CacheFocus方法,通过动态缓存重定位等策略增强长度归一化并降低延迟,在长输入场景下性能优于现有方法且稳定。
摘要:
大语言模型(LLMs)在各类语言任务中表现出色,但受限于输入长度有限和计算成本高的问题。现有方法——如相对位置编码(例如RoPE、ALiBi)和滑动窗口机制——可部分缓解这些问题,但通常需要额外训练,或在输入较长时性能下降。本文提出CacheFocus方法,无需进一步训练即可增强长度归一化并降低推理延迟。该方法利用查询无关的离线缓存高效复用上下文KV缓存库,通过重定位缓存键解决异常token分布放大问题,并引入层自适应缓存剪枝在预填充阶段丢弃低相关性缓存。此外,自适应位置分配策略动态重新分配缓存位置,以最大化可用位置编码范围的使用。在Natural Questions和TriviaQA数据集上的实验表明,即使输入超过LLaMA-2模型的4K限制,CacheFocus仍优于其他方法,凸显其对长上下文LLMs的实际有效性;即使在Qwen2模型的最大输入长度较大时,随着文档数量增加,CacheFocus仍保持稳定性能,有效管理长文本生成而不退化。
英文摘要:
Large Language Models (LLMs) excel across a variety of language tasks yet are constrained by limited input lengths and high computational costs. Existing approaches\textemdash such as relative positional encodings (e.g., RoPE, ALiBi) and sliding window mechanisms\textemdash partially alleviate these issues but often require additional training or suffer from performance degradation with longer inputs. In this paper, we introduce \textbf{\textit{CacheFocus}}, a method that enhances length normalization and reduces inference latency without any further training. Our approach leverages query-independent, offline caching to efficiently reuse a Context KV Cache Store. We address the amplification of abnormal token distributions problem by re-positioning cached keys and introducing Layer-Adaptive Cache Pruning to discard low-relevance caches during pre-filling. Additionally, our Adaptive Positional Allocation Strategy dynamically reassigns cache positions to maximize the use of the available positional encoding range. Experiments on the Natural Questions and TriviaQA datasets demonstrate that CacheFocus outperforms alternative methods even when inputs exceed the $4$K limit of the \texttt{LLaMA-2} model, emphasizing its practical effectiveness for long-context LLMs. Moreover, even with large maximum input length of \texttt{Qwen2}, the performance of CacheFocus shows that it maintains consistent performance even as the number of documents increases, effectively managing long-text generation without degradation.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。