RAG-FGO: Dynamic Optimization of Query-Rewriting Agents for Generative RAG

Qigan Sun, Xudong Wang, Chaoning Zhang, Chenghao Li, Jiaquan Zhang, Jiehui Xie, Sungyoung Lee, Jie Zou, Ning Xie, Peng Wang, Yang Yang, Heng Tao ShenarXiv 2026

TL;DR

RAG-FGO introduces a dynamic optimization framework that treats query rewriting as an evolvable, agent-based task. By jointly optimizing discrete prompt templates and continuous decoding parameters using a fungal-growth-inspired search strategy, it significantly boosts retrieval accuracy and downstream performance in complex Retrieval-Augmented Generation (RAG) scenarios.

What Problem Does This Paper Address?

Retrieval-Augmented Generation (RAG) is the go-to solution for reducing hallucinations in Large Language Models (LLMs) by grounding them in external knowledge. However, the system's success hinges on the quality of the retrieval, which in turn depends on the query.

Standard RAG often fails because user queries are poorly aligned with how information is stored in a knowledge base. While "generative retrieval" (using an LLM to rewrite the query) helps, it faces three major hurdles:

  1. Noisy Feedback: Retrieval results are stochastic and inconsistent, making it hard to tell if a prompt change actually helped.
  2. Mixed Optimization Space: You have to optimize both the text of the prompt (discrete) and parameters like temperature or top-p (continuous).
  3. Static Limitations: A single, fixed rewriting strategy rarely generalizes across different domains or complex, multi-hop questions.

Methods

The authors propose RAG-FGO (Fungal Growth Optimizer), which reframes query rewriting as a black-box optimization problem. Instead of a static prompt, they use Query-Rewriting Agents that bundle a prompt template with specific decoding configurations.

The core of the framework is inspired by the growth patterns of fungi (hyphae):

  • Global Search (Exploration): Like a fungus sending out long-distance spores, the system uses an LLM to perform "semantic jumps"—restructuring prompts entirely to escape local optima and find "info-rich" zones in the retrieval space.
  • Local Search (Exploitation): Once a promising region is found, the system performs fine-grained tweaks, such as synonym replacement or minor parameter adjustments, to "settle" into the best possible configuration.
  • Elite-Preserving Memory Pool: To combat the "noise" of retrieval feedback, RAG-FGO maintains a pool of the best-performing agents across iterations. This ensures that a lucky (but actually poor) agent doesn't derail the optimization and that high-quality strategies are never lost.
Fig. 1: Conceptual illustration of the FGO-inspired search dynamics in RAG-FGO. Hyphae grow from low-efficiency (info-sparse) zones toward high-efficiency (info-rich) zones in the retrieval space. (i) Local search enables fine-grained exploitation within promising regions; (ii) global search facil- itates large semantic jumps to escape local optima and discover new resource-rich areas.

Datasets

The researchers evaluated RAG-FGO across a massive suite of benchmarks to test different capabilities:

  • QA Benchmarks: LongBench (long context), HotpotQA, 2WikiMultihopQA, MuSiQue (multi-hop reasoning), Natural Questions (NQ), SQuAD, StrategyQA, AmbigQA (ambiguity), and PopQA (long-tail knowledge).
  • Reasoning Benchmarks: MATH500, MMLU-pro, GPQA, DROP, and MuSR (symbolic reasoning).

Key Insights and Ideas

  • Joint Optimization is Critical: The paper argues that you cannot optimize prompts and decoding parameters in isolation. A "creative" prompt might need a lower temperature to stay on track, while a "structured" prompt might benefit from higher diversity. RAG-FGO unifies these into a single agent.
  • The "Hyphae" Metaphor Works: The dual-search strategy (global jumps + local tweaks) effectively navigates the non-differentiable landscape of LLM prompting where traditional gradient-based methods fail.
  • Stability through Memory: The most important component for performance was the elite-preserving memory pool. Without it, the "volatility" of retrieval feedback causes the system to frequently discard good strategies in favor of temporary, noisy gains.
Fig. 2: Overview of the main components of RAG-FGO. (a) A query-rewriting agent consists of a prompt template and continuous decoding parameters. (b) Variation optimization evolves agents via local search (synonym-level or minor phrasing edits) and global search (LLM-driven prompt rewriting). (c) Candidate agents are scored, ranked, and filtered to select elites. (d) The elite-preserving memory pool retains elite agents and prunes inferior ones across iterations for subsequent refinement.

Key Results

RAG-FGO consistently outperformed state-of-the-art baselines (like ReAct and Aflow) across various LLM backbones, including GPT-4o-mini, Qwen2.5, and Gemma2.

  • Performance Gains: On the GPT-4o-mini backbone, RAG-FGO achieved an average F1 score of 77.1% across QA tasks, compared to 68.9% for the best baseline (Aflow).
  • Robustness: The system showed particularly strong improvements in "knowledge-heavy" and "ambiguous" datasets like PopQA and AmbigQA, where precise query alignment is most difficult.
  • Ablation Success: Removing the memory pool caused a massive drop (~6-7 F1 points), proving that managing stochasticity is just as important as the search algorithm itself.

Limitations and Future Work

  • Offline Overhead: The optimization process happens in an offline "training" phase. While the resulting agent is fast at inference time, the initial search requires a significant token budget.
  • Static Knowledge Bases: The current version assumes the knowledge base is static during optimization. It does not yet support "online" adaptation where the agent learns as the underlying data changes.
  • Future Directions: The authors suggest exploring more efficient "surrogate objectives" to reduce the computational cost of the search and extending the framework to multi-modal RAG (e.g., retrieving images or video).

Summary updated

Abstract

In retrieval-augmented generation (RAG), query rewriting serves as a core interface that aligns user intent with external knowledge bases, and its effectiveness directly determines overall system performance. However, generative retrieval faces three critical challenges in real-world deployment: noisy retrieval feedback, the difficulty of jointly optimizing discrete prompt templates and continuous decoding-control parameters, and the limited generalization of static rewriting strategies under semantically complex scenarios. To address these issues, we propose RAG-FGO, a dynamic optimization framework for generative retrieval strategies. RAG-FGO formulates query rewriting as a non-differentiable black-box optimization problem in a mixed discrete-continuous space, and represents prompt templates and decoding parameters as adaptively optimizable query-rewriting agents. The framework performs global search to enable semantic jumps and structural reorganization that escape local optima, while applying local perturbations for fine-grained alignment and precise refinement. In addition, RAG-FGO introduces an elite-preserving memory pool that accumulates high-quality strategies across iterations, thereby mitigating the impact of stochasticity and noisy feedback on optimization stability. Experimental results on a diverse suite of benchmarks demonstrate the effectiveness and robustness of the proposed method, supporting its applicability to complex semantic retrieval tasks.
BibTeX
@misc{sun2026rag,
  author = {Qigan Sun and Xudong Wang and Chaoning Zhang and Chenghao Li and Jiaquan Zhang and Jiehui Xie and Sungyoung Lee and Jie Zou and Ning Xie and Peng Wang and Yang Yang and Heng Tao Shen},
  title = {{RAG-FGO: Dynamic Optimization of Query-Rewriting Agents for Generative RAG}},
  year = {2026},
  eprint = {2611.17788},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2611.17788},
}
Figure