arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2502.20330cs.CL
收藏

RAPID:基于检索增强投机解码的长上下文推理

RAPID: Long-Context Inference with Retrieval-Augmented Speculative Decoding

National University of Singapore(新加坡国立大学);DAMO Academy, Alibaba Group(阿里巴巴集团达摩院);Hupan Lab, 310023, Hangzhou, China(杭州研究院)

Guanzheng Chen, Qilong Feng, Jinjie Ni, Xin Li, Michael Qizhe Shieh

AI总结:

RAPID提出检索增强投机解码,利用RAG草稿器在缩短上下文中推测生成,加速长上下文LLM推理并提升质量,实验显示性能提升和超2倍加速。

摘要:

长上下文大语言模型(LLM)的出现为处理长篇文档提供了一种传统检索增强生成(RAG)的有前景的替代方案。然而,长上下文推理的计算开销带来了显著的效率挑战。虽然投机解码(SD)传统上利用较小的草稿模型加速推理,但在长上下文场景中,由于受内存限制的KV缓存操作,其有效性大幅降低。我们提出了检索增强投机解码(RAPID),利用RAG在长上下文推理中同时加速生成并提升生成质量。RAPID引入了RAG草稿器——一种在缩短的检索上下文上运行的草稿LLM——来推测长上下文目标LLM的生成。我们的方法开启了一种新范式,即同规模甚至更大的LLM可以作为RAG草稿器,同时保持计算效率。为了充分利用更强RAG草稿器可能具备的优越能力,我们开发了一种推理时知识迁移,通过RAG丰富目标分布。在LLaMA-3.1和Qwen2.5骨干网络上的大量实验表明,RAPID有效整合了RAG和长上下文LLM的优势,实现了显著的性能提升(例如,在InfiniteBench上LLaMA-3.1-8B从39.33提升到42.83),同时长上下文推理加速超过2倍。我们的分析还揭示了RAPID在不同上下文长度和检索质量下的鲁棒性。

英文摘要:

The emergence of long-context large language models (LLMs) offers a promising alternative to traditional retrieval-augmented generation (RAG) for processing extensive documents. However, the computational overhead of long-context inference presents significant efficiency challenges. While Speculative Decoding (SD) traditionally accelerates inference using smaller draft models, its effectiveness diminishes substantially in long-context scenarios due to memory-bound KV cache operations. We introduce Retrieval-Augmented Speculative Decoding (RAPID), which leverages RAG for both accelerating and enhancing generation quality in long-context inference. RAPID introduces the RAG drafter-a draft LLM operating on shortened retrieval contexts-to speculate on the generation of long-context target LLMs. Our approach enables a new paradigm where same-scale or even larger LLMs can serve as RAG drafters while maintaining computational efficiency. To fully leverage the potentially superior capabilities from stronger RAG drafters, we develop an inference-time knowledge transfer that enriches the target distribution by RAG. Extensive experiments on the LLaMA-3.1 and Qwen2.5 backbones demonstrate that RAPID effectively integrates the strengths of both RAG and long-context LLMs, achieving significant performance improvements (e.g., from 39.33 to 42.83 on InfiniteBench for LLaMA-3.1-8B) with more than 2x speedups for long-context inference. Our analyses also reveal the robustness of RAPID across various context lengths and retrieval quality.

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

↑