Inference Scaling for Long-Context Retrieval Augmented Generation

Zhenrui Yue, Honglei Zhuang, Aijun Bai, Kai Hui, Rolf Jagerman, Hansi Zeng, Zhen Qin, Dong Wang, Xuanhui Wang, Michael Bendersky

TL;DR

Researchers from Google DeepMind and their collaborators have established Inference Scaling Laws for RAG, demonstrating that the performance of Retrieval-Augmented Generation scales nearly linearly with increased "test-time compute" (total input tokens). By moving beyond simply adding more documents to the prompt and instead optimizing the mix of in-context demonstrations and iterative reasoning steps, they achieved performance gains of up to 58.9% over standard RAG.

The Problem: More Data Isn't Always Better

Retrieval-Augmented Generation (RAG) is the standard method for grounding Large Language Models (LLMs) in external facts. With the advent of long-context models—such as Gemini 1.5 Pro with its 2-million token window—the natural instinct is to simply "stuff the prompt" with hundreds of retrieved documents.

However, a frustrating reality emerges: more data doesn't always mean better answers. Standard RAG often hits a performance plateau or even declines as the context grows. Models can get "lost in the middle" or become distracted by the noise of irrelevant documents. The core challenge is figuring out how to utilize massive context windows effectively. This raises a critical question: Is there a "scaling law" for inference compute in RAG, similar to the well-documented scaling laws for model training?

Methods: Scaling Test-Time Compute

The authors introduce two primary strategies to scale "test-time compute," which they measure as Effective Context Length (the total number of input tokens processed across all steps):

  1. DRAG (Demonstration-based RAG): Instead of just providing documents and a question, DRAG provides multiple "many-shot" examples. Each example includes its own set of retrieved documents, a question, and an answer. This teaches the model how to find needles in the haystack.
  2. IterDRAG (Iterative Demonstration-based RAG): For complex, multi-hop questions, the model doesn't just look once. It breaks the query into sub-questions, retrieves documents for each, and generates intermediate answers. This "reasoning chain" uses more compute but bridges the gap for difficult queries.
Architecture of DRAG and IterDRAG

The core of the paper is the Computation Allocation Model. This mathematical framework is designed to predict the optimal combination of three parameters for any given token budget:

  • $k$: Number of retrieved documents.
  • $m$: Number of in-context examples (shots).
  • $n$: Number of iterative reasoning steps.

Datasets

The study focused on "knowledge-intensive" tasks, specifically multi-hop reasoning where the answer isn't found in a single document. Datasets included Bamboogle, HotpotQA, MuSiQue, and 2WikiMultiHopQA (requiring multi-hop connections), alongside TriviaQA and Natural Questions for simpler one-hop retrieval, and StrategyQA for implicit reasoning. The researchers used Gemini 1.5 Flash as the primary model, scaling inference compute up to 5 million tokens.

Key Insights and Ideas

  • The Linear Scaling Law: When parameters ($k, m, n$) are optimally configured, RAG performance improves nearly linearly with the log of the compute budget. This major finding suggests we haven't hit the ceiling of RAG performance; we simply haven't been spending our "token budget" wisely.
Inference Scaling Law for RAG
  • Standard RAG is Inefficient: Standard RAG (just increasing documents) plateaus early, often around 10,000 tokens. To scale further, adding demonstrations (shots) is essential.
  • The "Noise" Teacher: Adding in-context examples (DRAG) acts as a guide. It shows the model how to ignore irrelevant documents to find the one that matters, effectively teaching it to filter noise.
  • Iterative vs. Parallel: For small compute budgets, DRAG (many-shot) is most effective. For massive budgets (128k tokens and beyond), IterDRAG (iterative steps) becomes the superior strategy because it narrows the "compositionality gap" of complex questions.

Key Results

  • Massive Gains: Using the optimal configurations predicted by their model, the researchers saw up to 58.9% improvements in accuracy compared to standard RAG.
  • Predictive Accuracy: Their computation allocation model was highly accurate ($R^2 = 0.903$), meaning they can reliably predict the "sweet spot" for $k, m,$ and $n$ without exhaustive grid searching for every new task.
  • State-of-the-Art: Even using a "compact" model like Gemini 1.5 Flash, the scaling strategies allowed it to outperform much larger models and specialized fine-tuned baselines on multi-hop benchmarks.

Limitations and Future Work

While performance scales linearly up to 1M tokens, the authors noticed a slight slowdown in gains between 1M and 5M tokens, suggesting current long-context models still have inherent architectural limitations in handling ultra-long sequences. Furthermore, the scaling law assumes a baseline level of retriever performance; if the retriever fails to find relevant documents entirely, inference scaling cannot fix the answer.

Finally, iterative steps (IterDRAG) significantly increase latency. Future work will need to balance the trade-off between accuracy gains and the "wall-clock" time of inference, potentially by incorporating a "re-ranker" into the scaling law to further reduce noise efficiently.

Summary updated

BibTeX
@inproceedings{yue2025inference,
  author = {Zhenrui Yue and Honglei Zhuang and Aijun Bai and Kai Hui and Rolf Jagerman and Hansi Zeng and Zhen Qin and Dong Wang and Xuanhui Wang and Michael Bendersky},
  title = {{Inference Scaling for Long-Context Retrieval Augmented Generation}},
  booktitle = {International Conference on Learning Representations},
  year = {2025},
  url = {https://openreview.net/forum?id=FSjIrOm1vz},
}
Figure