Q-RAG: Long Context Multi‑Step Retrieval via Value‑Based Embedder Training

Artyom Sorokin, Nazar Buzun, Aleksandr Anokhin, Egor Konstantinovich Vedernikov, Petr Anokhin, Mikhail Burtsev, Evgeny Burnaev

TL;DR

Q-RAG is a resource-efficient framework for multi-step retrieval in long-context Retrieval-Augmented Generation (RAG) systems. By fine-tuning only the embedder model using reinforcement learning—rather than the massive LLM itself—it achieves state-of-the-art performance on benchmarks like BabiLong and RULER for contexts up to 10 million tokens, all while training on a single GPU.

The Challenge of Multi-Step Retrieval

Standard RAG systems typically perform a single retrieval step: they take a user query, find relevant documents, and feed them to a Large Language Model (LLM). However, complex questions often require "multi-hop" reasoning, where finding one piece of information is necessary to formulate the search for the next.

Existing solutions for multi-step retrieval generally fall into two camps, both with significant drawbacks:

  1. LLM Agents: These use the LLM to generate search queries iteratively. They are slow, expensive, and highly sensitive to "noisy" or irrelevant retrieved passages.
  2. LLM Fine-tuning: These methods fine-tune the LLM to interact with retrieval tools. While effective, this is computationally prohibitive for large models and impossible for proprietary "black-box" APIs (like GPT-4).

Furthermore, as context windows grow to millions of tokens, LLMs suffer from "attention dilution," making it harder to find the "needle in the haystack." Q-RAG aims to solve these issues by making the retrieval process itself "smarter" without touching the LLM's weights.

The Q-RAG Approach

The authors treat multi-step retrieval as a Markov Decision Process (MDP) and train a retrieval agent using Value-Based Reinforcement Learning.

Q-RAG Agent Architecture
  • Q-RAG Agent: Instead of an LLM deciding what to search for, a specialized "State Embedder" and "Action Embedder" work together. The State Embedder encodes the query and previously retrieved chunks, while the Action Embedder encodes candidate chunks.
  • Soft Q-Learning: The model learns a Q-function that estimates the "utility" of retrieving a specific chunk. It uses a maximum-entropy objective to encourage exploration during training.
  • Relative Positional Encoding: To handle long narrative texts where the order of events matters, the authors introduced a novel encoding scheme. It maps chunk positions relative to already-retrieved facts, allowing the retriever to understand temporal sequences (e.g., "find what happened after the character moved to the kitchen").
  • Efficiency via PQN: They utilize the Parallel Q-Network (PQN) algorithm, which is an on-policy method. This avoids the massive memory overhead of a "replay buffer," which would otherwise require re-embedding millions of tokens repeatedly.

Key Insights

  • Reasoning in Latent Space: By performing the "reasoning" steps directly in the embedding space rather than through natural language generation, Q-RAG is significantly faster and less prone to the "hallucination" cycles that plague LLM agents.
  • Decoupling Retrieval from Generation: Because only the embedder is fine-tuned, Q-RAG can be paired with any LLM (including proprietary ones) without further training.
  • Temporal Awareness is Key: The "aha moment" for long-context narrative tasks was the relative positional encoding. Standard retrievers treat documents as a "bag of chunks"; Q-RAG treats them as a sequence, which is vital for following a story or a complex chain of events.
  • Extreme Scalability: The model was trained on 4k-token documents but generalized near-perfectly to 1M+ token contexts at inference time.

Key Results

The researchers evaluated Q-RAG across several challenging benchmarks, including BabiLong (ultra-long contexts), RULER (Needle-in-a-Haystack tasks), and HotpotQA/Musique (multi-hop open-domain QA).

BabiLong Benchmark Performance
  • State-of-the-Art Performance: Q-RAG outperformed recurrent models (like Titans and RMT) and other RAG baselines on BabiLong, showing virtually no performance degradation as context length increased to 10M tokens.
  • Near-Perfect Retrieval: On the RULER benchmark, Q-RAG achieved 100% accuracy on many Needle-in-a-Haystack (NIAH) tasks where other models began to fail at 32k or 128k tokens.
  • Compute Efficiency: Q-RAG was trained in approximately 12 hours on a single A100 GPU. In contrast, competing RL-based methods often require clusters of 8 or more GPUs to fine-tune the LLM.
  • Speed: Because it uses vector similarity rather than transformer-based trajectory scoring, it is significantly faster at inference time than methods like Beam-Retriever.

Limitations and Future Work

Currently, the model requires "support-fact" supervision (knowing exactly which chunks are the "right" ones) during training. The authors suggest that future versions could use LLM feedback (e.g., "did this retrieved chunk help you answer the question?") as a reward signal, removing the need for gold-standard support facts. Additionally, while decoupling the retriever and generator is a strength for flexibility, exploring tighter integration between the embedding space and the LLM's internal states could yield even further performance improvements.

Summary updated

BibTeX
@inproceedings{sorokin2026q,
  author = {Artyom Sorokin and Nazar Buzun and Aleksandr Anokhin and Egor KONSTANTINOVICH VEDERNIKOV and Petr Anokhin and Mikhail Burtsev and Evgeny Burnaev},
  title = {{Q-RAG: Long Context Multi‑Step Retrieval via Value‑Based Embedder Training}},
  booktitle = {International Conference on Learning Representations},
  year = {2026},
  url = {https://openreview.net/forum?id=MS9nWFY7LG},
}
Figure