Table of Contents
Fetching ...

DynamicRAG: Leveraging Outputs of Large Language Model as Feedback for Dynamic Reranking in Retrieval-Augmented Generation

Jiashuo Sun, Xianrui Zhong, Sizhe Zhou, Jiawei Han

TL;DR

DynamicRAG tackles the critical yet underexplored problem of how many and which documents to pass to a generator in retrieval-augmented generation. By modeling the reranker as an RL agent and using LLM output quality as the reward, the approach dynamically adjusts k and the document order per query, trained in two stages: behavior cloning and interactive RL with Direct Preference Optimization. Empirically, DynamicRAG achieves state-of-the-art results among models of the same size across seven knowledge-intensive datasets, while using substantially less training data and improving efficiency. The work provides a practical framework for adaptive reranking that leverages downstream generation signals to guide retrieval, with strong implications for scalable, explainable, and high-quality RAG systems.

Abstract

Retrieval-augmented generation (RAG) systems combine large language models (LLMs) with external knowledge retrieval, making them highly effective for knowledge-intensive tasks. A crucial but often under-explored component of these systems is the reranker. Since irrelevant documents in RAG systems can mislead the generator, the reranker plays a vital role in refining retrieved documents to enhance generation quality and explainability. However, it is challenging to determine the appropriate number of documents ($k$) that the reranker should select: too few may result in missing critical information, while too many introduce noise and inefficiencies. Although recent studies have explored LLM-based rerankers, they primarily leverage internal model knowledge and overlook the rich supervisory signals that LLMs can provide, such as using response quality as feedback for optimizing reranking decisions. In this paper, we propose DynamicRAG, a novel RAG framework where the reranker dynamically adjusts both the order and number of retrieved documents based on the query. We model the reranker as an agent optimized through reinforcement learning (RL), using rewards derived from LLM output quality. Across seven knowledge-intensive datasets, DynamicRAG demonstrates superior performance, achieving state-of-the-art results among models of same parameter sizes. The model, data and code are available at https://github.com/GasolSun36/DynamicRAG.

DynamicRAG: Leveraging Outputs of Large Language Model as Feedback for Dynamic Reranking in Retrieval-Augmented Generation

TL;DR

DynamicRAG tackles the critical yet underexplored problem of how many and which documents to pass to a generator in retrieval-augmented generation. By modeling the reranker as an RL agent and using LLM output quality as the reward, the approach dynamically adjusts k and the document order per query, trained in two stages: behavior cloning and interactive RL with Direct Preference Optimization. Empirically, DynamicRAG achieves state-of-the-art results among models of the same size across seven knowledge-intensive datasets, while using substantially less training data and improving efficiency. The work provides a practical framework for adaptive reranking that leverages downstream generation signals to guide retrieval, with strong implications for scalable, explainable, and high-quality RAG systems.

Abstract

Retrieval-augmented generation (RAG) systems combine large language models (LLMs) with external knowledge retrieval, making them highly effective for knowledge-intensive tasks. A crucial but often under-explored component of these systems is the reranker. Since irrelevant documents in RAG systems can mislead the generator, the reranker plays a vital role in refining retrieved documents to enhance generation quality and explainability. However, it is challenging to determine the appropriate number of documents () that the reranker should select: too few may result in missing critical information, while too many introduce noise and inefficiencies. Although recent studies have explored LLM-based rerankers, they primarily leverage internal model knowledge and overlook the rich supervisory signals that LLMs can provide, such as using response quality as feedback for optimizing reranking decisions. In this paper, we propose DynamicRAG, a novel RAG framework where the reranker dynamically adjusts both the order and number of retrieved documents based on the query. We model the reranker as an agent optimized through reinforcement learning (RL), using rewards derived from LLM output quality. Across seven knowledge-intensive datasets, DynamicRAG demonstrates superior performance, achieving state-of-the-art results among models of same parameter sizes. The model, data and code are available at https://github.com/GasolSun36/DynamicRAG.
Paper Structure (50 sections, 15 equations, 7 figures, 16 tables, 1 algorithm)

This paper contains 50 sections, 15 equations, 7 figures, 16 tables, 1 algorithm.

Figures (7)

  • Figure 1: Illustration of our dynamic reranker framework. (a) It represents a RAG system without a reranker, where the system primarily focuses on training LLMs. (b) It represents a RAG system with a reranker, where the reranker is trained to filter the Top-$N$ documents to a fixed Top-$K$, which remains constant for all queries. (c) In contrast, it represents our dynamic reranker, where both the reranker and the generator are trained simultaneously. The dynamic reranker adapts to the difficulty of each query by dynamically determining the value of $k$.
  • Figure 2: Illustration of the training paradigm for our method. We treat Dynamic Reranker as an Agent, which interacts with the Environment, generating Top-K docs and receiving rewards to optimize itself.
  • Figure 3: Illustration of our training framework. During the training phase, we have a total of six steps. First, we retrieve the Top-$N$ documents based on the given question. Then, we use an expert model to score each document and filter a subset of data for behavior cloning by the dynamic reranker. Next, we use the trained dynamic reranker to sample multiple different trajectories. The responses generated by the generator serve as rewards to evaluate the quality of the trajectories, and we select the trajectory pairs with the highest and lowest rewards as the training data for DPO. During the inference phase, DynamicRAG only require two LLM inferences.
  • Figure 4: Performance with different retrievers between Vanilla-RAG and DynamicRAG.
  • Figure 5: Comparison of different RAG models in terms of efficiency and effectiveness. The x-axis represents the number of LLM calls, while the y-axis denotes the average performance on the NQ benchmark. Models closer to the top-left corner achieve better overall performance.
  • ...and 2 more figures