Long-Context Inference with Retrieval-Augmented Speculative Decoding

Guanzheng Chen, Qilong Feng, Jinjie Ni, Xin Li, Michael Shieh
2/14/2026

No official code found. Best implementation: real-absolute-AI/RAPID (22 stars, last commit 2025-03-02).

Abstract

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.

View on arXivView PDF

Code Implementations(1)

[ICML 2025 Spotlight] RAPID: Long-Context Inference with Retrieval-Augmented Speculative Decoding

220PythonFeb 27, 20251 years ago

Similar Papers

Cite this paper

@article{chen2026longcontext,
  title  = {Long-Context Inference with Retrieval-Augmented Speculative Decoding},
  author = {Guanzheng Chen and Qilong Feng and Jinjie Ni and Xin Li and Michael Shieh},
  year   = {2026},
  eprint = {2502.20330},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2502.20330},
  journal = {ICML 2025 2025}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2502.20330.svg)](https://codeofpaper.com/paper/2502.20330)

Discussion