arXivDaily arXiv每日学术速递 周一至周五更新
arXiv周末暂无论文更新,休息一下吧,周末愉快~~
arXiv 2509.01092cs.CLcs.AIcs.LG
收藏

REFRAG:重新思考基于 RAG 的解码

REFRAG: Rethinking RAG based Decoding

Meta Superintelligence Labs(Meta超智能实验室);National University of Singapore(新加坡国立大学);Rice University(Rice大学)

Xiaoqiang Lin, Aritra Ghosh, Bryan Kian Hsiang Low, Anshumali Shrivastava, Vijai Mohan

AI总结:

提出高效解码框架 REFRAG,利用 RAG 上下文的稀疏性进行压缩与扩展,在无精度损失下实现 30.85 倍首字加速并将上下文扩展 16 倍。

摘要:

大型语言模型(LLMs)已展现出卓越的能力,能够利用广泛的外部知识来增强多轮对话和智能体应用中的响应,例如检索增强生成(RAG)。然而,处理长上下文输入会引入显著的系统延迟,并需要大量内存用于键值缓存,从而导致吞吐量降低,并在知识丰富度与系统效率之间产生根本性的权衡。尽管最小化长上下文输入的延迟是 LLMs 的主要目标,但我们认为 RAG 需要专门的考量。在 RAG 中,LLM 的大部分上下文由检索到的拼接段落组成,其中只有一小部分与查询直接相关。由于重排序时的多样性或去重操作,这些段落通常表现出较低的语义相似性,从而产生块对角注意力模式,这与标准 LLM 生成任务中的模式不同。基于这一观察,我们认为在解码期间对 RAG 上下文进行的大部分计算是不必要的,可以在对性能影响最小的情况下予以消除。为此,我们提出 REFRAG,这是一个通过压缩、感知和扩展来改善 RAG 应用延迟的高效解码框架。通过利用稀疏结构,我们展示了 30.85 倍的首字时间加速(比先前工作提升 3.75 倍),且困惑度无损失。此外,我们针对大上下文的优化框架使 REFRAG 能够将 LLMs 的上下文大小扩展 16 倍。我们在包括 RAG、多轮对话和长文档摘要在内的各种长上下文任务中,跨越广泛的数据集,对 REFRAG 进行了严格验证。实验结果证实,与 LLaMA 模型及其他最先进的基线相比,REFRAG 在各种上下文大小下均实现了显著加速且准确率无损失。

英文摘要:

Large Language Models (LLMs) have demonstrated remarkable capabilities in leveraging extensive external knowledge to enhance responses in multi-turn and agentic applications, such as retrieval-augmented generation (RAG). However, processing long-context inputs introduces significant system latency and demands substantial memory for the key-value cache, resulting in reduced throughput and a fundamental trade-off between knowledge enrichment and system efficiency. While minimizing latency for long-context inputs is a primary objective for LLMs, we contend that RAG require specialized consideration. In RAG, much of the LLM context consists of concatenated passages from retrieval, with only a small subset directly relevant to the query. These passages often exhibit low semantic similarity due to diversity or deduplication during re-ranking, leading to block-diagonal attention patterns that differ from those in standard LLM generation tasks. Based on this observation, we argue that most computations over the RAG context during decoding are unnecessary and can be eliminated with minimal impact on performance. To this end, we propose REFRAG, an efficient decoding framework that compresses, senses, and expands to improve latency in RAG applications. By exploiting the sparsity structure, we demonstrate a 30.85 the time-to-first-token acceleration (3.75 improvement to previous work) without loss in perplexity. In addition, our optimization framework for large context enables REFRAG to extend the context size of LLMs by 16. We provide rigorous validation of REFRAG across diverse long-context tasks, including RAG, multi-turn conversations, and long document summarization, spanning a wide range of datasets. Experimental results confirm that REFRAG delivers substantial speedup with no loss in accuracy compared to LLaMA models and other state-of-the-art baselines across various context sizes.

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

↑