Q-RAG: Long Context Multi-Step Retrieval via Value-Based Embedder Training
Artyom Sorokin, Nazar Buzun, Aleksandr Anokhin, Egor VEDERNIKOV, Petr Anokhin, Mikhail Burtsev, Evgeny Burnaev
International Conference on Learning Representations 2026 · Oral
Overview
The talk "Q-RAG: Long Context Multi-Step Retrieval via Value-Based Embedder Training" presented by Artyom Sorokin, addresses one of the most persistent and resource-intensive challenges in large language models (LLMs): effectively handling ultra-long contexts. While LLMs have demonstrated remarkable capabilities, their quadratic attention complexity makes processing documents extending to hundreds of thousands or even millions of tokens prohibitively expensive during both training and inference. Current multi-step Retrieval Augmented Generation (RAG) approaches often involve fine-tuning the LLM itself to act as a retrieval agent, a process that demands substantial computational resources, typically requiring multiple high-end GPUs.

Key moments
- 0:00 Addressing long context challenges with a cheaper RAG method.
- 0:30 Q-RAG's core idea: training embedder for multi-step search.
- 1:00 Formulating RAG as a Markov Decision Process (MDP).
- 2:00 Enhancing embeddings with relative positional encoding for structure.
- 2:40 Achieving state-of-the-art results on ultra-long context benchmarks.
- 4:00 Significant cost advantage: fine-tuning embedder on one GPU.
- 4:20 Q&A: Why PQN was chosen as the RL backbone.
Q-RAG: Long Context Multi-Step Retrieval via Value-Based Embedder Training
Speakers: Artyom Sorokin; Nazar Buzun; Aleksandr Anokhin; Egor VEDERNIKOV; Petr Anokhin; Mikhail Burtsev; Evgeny Burnaev
Conference: ICLR 2026
YouTube: https://slideslive.com/39062208
Overview
The talk "Q-RAG: Long Context Multi-Step Retrieval via Value-Based Embedder Training" presented by Artyom Sorokin, addresses one of the most persistent and resource-intensive challenges in large language models (LLMs): effectively handling ultra-long contexts. While LLMs have demonstrated remarkable capabilities, their quadratic attention complexity makes processing documents extending to hundreds of thousands or even millions of tokens prohibitively expensive during both training and inference. Current multi-step Retrieval Augmented Generation (RAG) approaches often involve fine-tuning the LLM itself to act as a retrieval agent, a process that demands substantial computational resources, typically requiring multiple high-end GPUs.
This paper introduces Q-RAG, a novel and significantly more cost-effective alternative. Instead of the conventional method of fine-tuning the LLM, Q-RAG proposes training the embedder component to perform multi-step retrieval directly in the embedding space. By formulating the RAG process as a Markov Decision Process (MDP) and approximating the state-action value function using an inner product between state and action embeddings, Q-RAG enables the embedder to learn the "utility" of chunks for retrieval. This innovative approach not only bypasses the need for generating explicit textual search queries but also dramatically reduces the computational overhead associated with LLM fine-tuning, making advanced RAG techniques more accessible to a broader range of researchers and practitioners.
The significance of Q-RAG lies in its ability to achieve state-of-the-art performance on ultra-long context benchmarks, such as Babylong and Ruler, which involve documents up to 10 million tokens, while simultaneously slashing the hardware requirements from eight 80GB GPUs to a single GPU for fine-tuning. This represents a substantial leap in efficiency and democratizes access to powerful long-context RAG capabilities, making it a critical contribution to the field of efficient LLM deployment and knowledge retrieval.
Background
▶ Watch: Addressing long context challenges with a cheaper RAG method. (0:00)
The ability of Large Language Models (LLMs) to process and reason over extensive textual contexts is crucial for many real-world applications, from summarizing lengthy legal documents to engaging in complex, multi-turn conversations. However, the foundational transformer architecture, which underpins most modern LLMs, suffers from a critical limitation: its attention mechanism exhibits quadratic complexity with respect to the input sequence length. This means that as the context grows, the computational cost and memory footprint required for attention calculations increase exponentially, quickly becoming a prohibitive bottleneck for contexts beyond a few tens of thousands of tokens.
To mitigate this "long context problem," various research directions have emerged. These include architectural modifications like state space models (SSMs), transformers with recurrence, and linear attention models, all aiming to reduce the computational complexity of attention. Another prominent strategy involves agentic approaches, where LLMs are designed to interact with external tools or knowledge bases. Within this paradigm, multi-step Retrieval Augmented Generation (RAG) has gained significant traction. Multi-step RAG agents are designed to iteratively search for and retrieve relevant information from a knowledge base to answer complex queries that cannot be resolved with a single retrieval step. This iterative process often involves the LLM generating intermediate search queries, retrieving chunks, and then using the retrieved information to refine the query or generate a final answer.
A popular and effective direction within multi-step RAG has been to fine-tune an LLM to use retrieval as a tool. In this setup, the LLM learns not only to generate coherent text but also to strategically formulate search queries, evaluate retrieval results, and integrate them into its reasoning process. While powerful, this LLM fine-tuning approach presents its own set of challenges. Fine-tuning an LLM, especially one capable of handling complex multi-step reasoning, is an extremely resource-intensive endeavor. It typically requires substantial computational power, often demanding multiple high-memory GPUs (e.g., 8 GPUs with 80 gigabytes of memory each). This high cost of fine-tuning makes it inaccessible for many researchers, smaller organizations, or projects with limited budgets. The prohibitive expense and hardware requirements underscore the critical need for more efficient and accessible methods to enable effective multi-step RAG for long contexts without the burden of LLM fine-tuning. Q-RAG emerges as a direct response to this challenge, seeking a cheaper, yet equally effective, alternative.
Key Findings
▶ Watch: Formulating RAG as a Markov Decision Process (MDP). (1:00)
The Q-RAG project introduces several pivotal findings and contributions that significantly advance the state-of-the-art in efficient long-context multi-step retrieval. The core discovery is the feasibility and effectiveness of training the embedder component directly for multi-step search, rather than fine-tuning the entire Large Language Model (LLM). This fundamental shift in strategy allows for a dramatic reduction in computational resources while maintaining, and in many cases, surpassing, the performance of more expensive LLM-centric approaches.
A key contribution is the novel formulation of the Retrieval Augmented Generation (RAG) process as a Markov Decision Process (MDP). By conceptualizing RAG as a sequence of states, actions, and rewards, the authors enable the application of reinforcement learning techniques to train the retrieval agent. In this MDP, a "state" encapsulates the current query along with all information already retrieved, while "actions" correspond to selecting available chunks for retrieval. The system is guided by a sparse reward function that returns a positive signal (one) only when all necessary supporting chunks have been successfully found, and zero otherwise.
The researchers successfully approximate the state-action value function (Q-function) using a simple yet powerful mechanism: the inner product between the state embedding and the action (chunk) embedding. This redefines the traditional semantic similarity role of the dot product, transforming it into a measure of utility, indicating how useful a particular chunk is given the current state. This allows the embedder to directly learn which chunks are most valuable for advancing the multi-step retrieval process.
Q-RAG demonstrated state-of-the-art (SOTA) results on critical ultra-long context benchmarks. Specifically, it achieved SOTA performance on Babylong, a common sense and temporal reasoning benchmark designed for contexts ranging from 128,000 up to an astounding 10 million tokens. Furthermore, on the Ruler benchmark, which includes numerous "needle-in-a-haystack" tasks, Q-RAG again showed the best results with "almost no degradation" as context length increased. While performance on open-domain question answering benchmarks was described as "slightly better" but "comparable" to other strong multi-step RAG baselines, the significant advantage lies in the drastically reduced fine-tuning cost.
Another important finding is the introduction of relative positional encoding to enrich the chunk embeddings with structural document information. This mechanism captures both the absolute position of a chunk within a document (e.g., beginning, middle, end) and its relative position to already retrieved chunks, which proved crucial for reasoning about narrative or sequential information in long documents like books. Critically, these achievements were made possible with an unprecedented reduction in hardware requirements, needing only one GPU for fine-tuning, in stark contrast to the eight GPUs with 80 gigabytes of memory typically required for LLM-based RAG fine-tuning baselines. This makes Q-RAG a highly efficient and accessible solution for tackling long-context retrieval problems.
Technical Deep Dive
▶ Watch: Enhancing embeddings with relative positional encoding for structure. (2:00)
The technical ingenuity of Q-RAG lies in its shift from LLM-centric fine-tuning to an embedder-focused approach, leveraging principles from reinforcement learning. The core idea is to train the embedder directly to perform multi-step search, effectively generating "search queries" in the embedding space itself, thereby circumventing the need for the LLM to generate explicit textual search queries that are then converted into embeddings.
At the heart of Q-RAG is the formulation of the multi-step Retrieval Augmented Generation (RAG) task as a Markov Decision Process (MDP). This framework provides a structured way to model the sequential decision-making process involved in retrieving information.
- State: In the Q-RAG MDP, a state
sis defined as a combination of the initial queryQand all information (I_1, I_2, ..., I_k) that has already been retrieved in previous steps. This comprehensive state representation ensures that the agent's decisions are informed by the evolving context of the search. - Action Space: The action space
Aconsists of all available chunksc_jin the knowledge base that can be retrieved. At each step, the agent chooses one chunk to add to its retrieved information. - Reward Function: The system employs a sparse reward function. A reward of
+1is granted only when all supporting chunks necessary to answer the query have been successfully found. Otherwise, the reward is0. This sparsity encourages the agent to explore and find the complete set of relevant information.
To train the embedder within this MDP framework, Q-RAG approximates the state-action value function (Q-function). The Q-function, Q(s, a), estimates the expected cumulative reward for taking action a in state s and then following an optimal policy thereafter. In Q-RAG, this Q-function is approximated by the inner product between the embedding of the current state (state_embedding) and the embedding of a potential action (a chunk, action_embedding).
Q(s, c_j) ≈ state_embedding(s) ⋅ chunk_embedding(c_j)
Crucially, this means that the dot product, which typically measures semantic similarity between two embeddings, is re-purposed to become a measure of utility. It quantifies "How useful is chunk c_j given our current state s (query Q and already retrieved information)?" This direct utility approximation in the embedding space is a cornerstone of the Q-RAG method.
To encourage the agent to explore the vast search space effectively, especially given the sparse reward structure, Q-RAG incorporates a max entropy value function formulation. This encourages the policy to be more stochastic and explore diverse retrieval paths, rather than converging too quickly on a single, potentially suboptimal, path. The policy itself is then simply a softmax over the Q-values for all available chunks, effectively selecting chunks based on their learned utility:
π(a|s) = softmax(Q(s, a_1), Q(s, a_2), ..., Q(s, a_N))
The underlying reinforcement learning algorithm used as the backbone for Q-RAG is a modified version of PQN (Policy Q-Network). PQN is a variant of DQN (Deep Q-Network), but notably, it operates without a replay buffer. The decision to omit the replay buffer is a strategic one, primarily to save significant amounts of RAM and reduce computational time. In a multi-step retrieval setting, using a replay buffer would necessitate re-embedding all the information (chunks and states) when sampling steps from different trajectories, which can be extremely time-consuming and memory-intensive. By foregoing the replay buffer, PQN allows for more efficient training. Despite this departure from standard DQN, the Q-RAG implementation of PQN still utilizes target networks. The speakers explicitly state that adding target networks was found to stabilize training, leading to better overall results. Target networks help to decouple the Q-value estimation from the network being updated, preventing oscillations and improving convergence.
Beyond the core RL framework, Q-RAG introduces relative positional encoding to enhance the expressiveness of chunk embeddings, especially for lengthy, narrative documents. When dealing with a single, long document (e.g., a book), the semantic content of a chunk alone might not be sufficient for effective reasoning. Information such as "what happened last," "what happened first," or "what happened between two events" relies heavily on the chunk's position within the document and its relation to other pieces of information. The relative positional encoding captures two crucial aspects:
- Absolute Position: Where the chunk is located within its document (e.g., closer to the beginning, closer to the end, or somewhere in the middle).
- Relative Position to Retrieved Chunks: The relationship between the current chunk's position and the positions of all chunks that have already been retrieved in previous steps.
By integrating this structural and relational information directly into the embeddings, Q-RAG enables a more nuanced and context-aware retrieval process, essential for ultra-long context scenarios.
Experimental Setup & Results
▶ Watch: Significant cost advantage: fine-tuning embedder on one GPU. (4:00)
The Q-RAG methodology was rigorously tested across several challenging benchmarks, primarily focusing on long-context and open-domain question answering tasks, to validate its effectiveness and efficiency. The key objective was to demonstrate that fine-tuning an embedder, rather than an LLM, could achieve competitive or superior results with significantly reduced computational overhead.
Benchmarks Used:
- Babylong: This benchmark is designed for ultra-long context common sense and temporal reasoning. It features contexts of extreme lengths, ranging from 128,000 tokens up to an unprecedented 10 million tokens. Q-RAG achieved state-of-the-art (SOTA) results on this benchmark, particularly excelling at these extended context lengths. This highlights Q-RAG's robust capability to handle and reason over massive amounts of information.
- Ruler: The Ruler benchmark combines a variety of tasks, including numerous "needle-in-a-haystack" scenarios and several open-domain question answering tasks. In needle-in-a-haystack tasks, the challenge is to retrieve a very specific piece of information embedded within a vast amount of irrelevant text. Q-RAG demonstrated the best results on Ruler, critically showing almost no degradation with an increase in context length. This indicates its resilience and reliability in finding precise information even in extremely noisy and long contexts.
- Open-Domain Question Answering (QA): Q-RAG was also evaluated on a standard open-domain QA benchmark. Here, the results were described as "slightly better" but "actually kind of comparable to other strong multi-step RAG baselines." While not a dominant SOTA result in this category, it confirms that Q-RAG performs strongly even in general QA settings, competing effectively with more resource-intensive approaches.
Baselines and Key Advantage:
The primary baselines for comparison were other strong multi-step RAG methods that rely on fine-tuning large language models (LLMs) to act as retrieval agents. The critical distinction and main advantage of Q-RAG over these baselines is its approach to fine-tuning.
- Q-RAG: Only fine-tunes the embedding model. The LLM used for final answer generation remains frozen throughout the process.
- LLM Fine-tuning Baselines: Require extensive fine-tuning of the entire LLM, which significantly drives up computational costs.
Hardware and Resource Savings:
One of the most compelling results of the Q-RAG project is the stark contrast in hardware requirements for fine-tuning.
- To fine-tune LLM-based multi-step RAG baselines, the requirement is typically 8 GPUs, each equipped with 80 gigabytes of memory. This represents a substantial investment in high-end hardware.
- In contrast, Q-RAG needs only one GPU to fine-tune its embedder. This dramatic reduction in hardware requirements (an 8x reduction in GPU count and a significant reduction in total VRAM) makes the approach vastly more accessible and cost-effective.
In summary, Q-RAG not only achieves SOTA performance on benchmarks specifically designed to test ultra-long context capabilities but also does so with an unprecedented level of resource efficiency. Its ability to maintain performance with minimal degradation as context length increases, coupled with its drastically lower hardware footprint, positions it as a highly practical and impactful solution for real-world long-context retrieval challenges.
Practical Implications
▶ Watch: Q&A: Why PQN was chosen as the RL backbone. (4:20)
The development of Q-RAG carries profound practical implications for a wide array of stakeholders in the AI/ML ecosystem, including practitioners, infrastructure teams, model builders, and deployers. Its core innovation—training the embedder for multi-step retrieval instead of the LLM—addresses some of the most pressing challenges in deploying advanced RAG systems.
For Practitioners and Model Builders:
The most immediate benefit is democratized access to advanced multi-step RAG capabilities. Previously, developing sophisticated RAG agents capable of navigating complex, long-context documents often required significant financial investment in high-end GPUs and the expertise to fine-tune large LLMs. Q-RAG dramatically lowers this barrier, enabling researchers and developers with more modest hardware (a single GPU) to build and iterate on powerful retrieval systems. This means more teams can experiment with, adapt, and deploy multi-step RAG for their specific use cases, fostering innovation across diverse applications like legal document analysis, scientific literature review, customer support, and narrative understanding. Model builders can focus on optimizing the embedder and retrieval strategy rather than grappling with the complexities and costs of LLM fine-tuning.
For Infrastructure Teams and Deployers:
Q-RAG translates directly into substantial cost savings and improved operational efficiency. The reduction in hardware requirements from eight 80GB GPUs to just one GPU for fine-tuning is a game-changer. This not only cuts down on initial capital expenditure for hardware but also significantly reduces ongoing operational costs related to power consumption, cooling, and maintenance of large GPU clusters. For deployment, while inference still requires the LLM, the retrieval component's training is far lighter. This efficiency allows infrastructure teams to allocate resources more effectively, potentially running more experiments concurrently or deploying more RAG systems within existing budgets. The ability to handle ultra-long contexts (up to 10 million tokens) without performance degradation also means that deployers can confidently apply Q-RAG to highly complex, real-world document sets, which was previously impractical or prohibitively expensive.
Tradeoffs and Limitations:
While Q-RAG offers significant advantages, it's important to acknowledge its practical tradeoffs and current limitations:
- Annotation Requirement: The most significant bottleneck identified by the speakers is the need for annotation about what chunks are needed for training. The sparse reward function relies on knowing the "ground truth" supporting chunks. Generating these annotations can be a laborious and expensive process, especially for new domains or very long documents. This might limit its immediate applicability to domains where such annotations are already available or can be generated semi-automatically. The speakers acknowledge this as an area for future work, suggesting potential for self-supervised or weakly supervised annotation methods.
- Performance on General QA: While Q-RAG excels in ultra-long context and needle-in-a-haystack tasks, its performance on standard open-domain QA benchmarks is described as "comparable" or "slightly better" than LLM-fine-tuned baselines. This suggests that its primary strength and competitive advantage lie in scenarios where context length is extreme or precise retrieval from vast documents is paramount, rather than necessarily being a universal performance leader across all QA tasks. For simpler, shorter-context RAG, the benefits might be less pronounced compared to its advantages in specialized long-context use cases.
- Embedder Complexity: While the LLM is frozen, the complexity shifts to designing and training a highly effective embedder. The use of relative positional encoding adds sophistication, and optimizing this embedder for diverse retrieval strategies remains a crucial task.
- Integration with LLM: The Q-RAG method focuses on the retrieval step. The downstream LLM still needs to process the retrieved chunks and generate the final answer. While the LLM itself isn't fine-tuned for retrieval, its ability to effectively synthesize information from the retrieved chunks is still critical to end-to-end performance.
In conclusion, Q-RAG represents a significant step towards making advanced multi-step RAG for long contexts more accessible and sustainable. Its efficiency gains empower a broader community to leverage these powerful AI capabilities, albeit with the current challenge of data annotation that warrants further research.
Key Takeaways
- Cost-Effective Multi-Step RAG: Q-RAG offers a significantly cheaper alternative to LLM fine-tuning for multi-step retrieval, requiring only 1 GPU compared to 8 high-memory GPUs for equivalent LLM-based approaches.
- RAG as a Markov Decision Process (MDP): The method formulates multi-step retrieval as an MDP, enabling the use of reinforcement learning to train the embedder.
- Value-Based Embedder Training: The core innovation is approximating the Q-function (utility of a chunk) using the inner product between state and chunk embeddings, allowing the embedder to directly learn optimal retrieval actions.
- State-of-the-Art on Ultra-Long Contexts: Q-RAG achieves SOTA results on benchmarks like Babylong (up to 10 million tokens) and Ruler (needle-in-a-haystack), demonstrating robust performance with minimal degradation at extreme context lengths.
- Enhanced Contextual Understanding with Positional Encoding: The introduction of relative positional encoding imbues chunk embeddings with structural document information, improving reasoning over lengthy narratives and sequential events.
- Annotation as a Future Challenge: The primary limitation is the current reliance on annotated chunks for training, which is acknowledged as a key area for future research to develop more scalable annotation methods.
About the Speaker(s)
The talk "Q-RAG: Long Context Multi-Step Retrieval via Value-Based Embedder Training" was presented by Artyom Sorokin. He is part of the research team behind Q-RAG, along with co-authors Nazar Buzun, Aleksandr Anokhin, Egor VEDERNIKOV, Petr Anokhin, Mikhail Burtsev, and Evgeny Burnaev. While specific titles and affiliations were not detailed in the presentation, their collective work on Q-RAG represents a significant contribution to the field of efficient and accessible long-context processing for large language models.
Reviews
→ Top-rated talks at International Conference on Learning Representations 2026
All talks from International Conference on Learning Representations 2026