Unsupervised Query Routing for Retrieval Augmented Generation

Feiteng Mu, Liwen Zhang, Yong Jiang, Wenjie Li, Zhen Zhang, Pengjun Xie, Fei HuangarXiv 2025

Abstract

Query routing for retrieval-augmented generation (RAG) aims to assign an input query to the most suitable search engine. Existing works rely heavily on supervised datasets that require extensive manual annotation, resulting in high costs and limited scalability, as well as poor generalization to out-of-distribution scenarios. To address these challenges, we introduce a novel unsupervised method that constructs the "upper-bound" response to evaluate the quality of retrieval-augmented responses. This evaluation enables the decision of the most suitable search engine for a given query. By eliminating manual annotations, our approach can automatically process large-scale real user queries and create training data. We conduct extensive experiments across five datasets, demonstrating that our method significantly enhances scalability and generalization capabilities.

Introduction

Retrieval-Augmented Generation (RAG) has become a standard paradigm for grounding Large Language Models (LLMs) in external knowledge. However, the effectiveness of RAG is highly dependent on the quality of the retrieved context. In real-world applications, multiple search engines (e.g., Google, Bing, or specialized domain engines) are often available, each with distinct strengths. Query routing—the task of selecting the optimal engine for a specific query—is critical for maximizing response accuracy while managing computational costs.

Traditional query routing models are typically supervised, requiring pairs of queries and "gold-standard" answers to determine which engine performs best. This approach suffers from three major drawbacks: high annotation costs, limited coverage of real-world query distributions, and poor generalization to new topics. We propose an unsupervised framework that leverages the collective intelligence of multiple sources to create pseudo-labels, enabling the training of robust routing models on massive, unlabeled query logs.

Methodology: The Unsupervised Pipeline

Our framework transforms raw user queries into high-quality training data through a four-stage pipeline.

The four-stage unsupervised pipeline for query routing: (1) Single-sourced Response Generation, (2) Upper-bound Construction, (3) Label Construction, and (4) Model Training.

1. Single-sourced Response Generation

For each query $q$, we generate a response $r_m$ using context retrieved from each individual search engine $T_m$. This establishes a baseline performance for each available source.

2. Upper-bound Construction

We construct a "super-response" $r^*$ by aggregating the top results from all available search engines. The core hypothesis is that this multi-sourced context provides a superior "upper-bound" of quality compared to any single source. This $r^*$ serves as a pseudo-gold standard for evaluation.

3. Label Construction

To rank the performance of individual engines, we compare each single-source response $r_m$ against the upper-bound $r^*$. We employ two complementary metrics:

  • Similarity Score: Utilizing BertScore to measure the semantic overlap between $r_m$ and $r^*$.
  • Coherence Score: Using a high-capacity LLM (e.g., Qwen2-max) as a judge to perform pairwise comparisons, determining which response better addresses the user's intent. These scores are combined to produce a ranked list $\pi$ of engines for each query.

4. Model Training

The final step involves training a neural routing model $\mathcal{M}$ (based on backbones like GTE-large) to predict the rankings $\pi$ directly from the query $q$. We utilize a listwise ranking loss (ListMLE) to optimize the model's ability to select the top-performing engine.

Experimental Evaluation

We evaluated our method across five open-domain QA benchmarks: WebQA, NLPCC-MH, CDQA, SogouQA, and a new dataset, PrivateQA, focused on timeliness and recent events. To demonstrate scalability, we trained our models on a pool of 110,000 real-world unlabeled user queries.

Key Findings

  • Labeling Accuracy: Our unsupervised labeling process achieved an 86% agreement rate with human annotators, validating the "upper-bound" response as a reliable proxy for ground truth.
  • Generalization: In cross-dataset evaluations, our unsupervised model significantly outperformed supervised baselines. While supervised models often overfit to specific dataset biases, our approach captures the underlying relationship between query types and engine strengths.
  • Scaling Laws: Performance consistently improved as the volume of unlabeled training data increased, suggesting that the bottleneck for query routing is no longer human annotation but rather the availability of raw query logs.
  • Engine Complementarity: Analysis revealed distinct specializations; for instance, Bing was frequently preferred for news and financial queries, while Google excelled in technical and programming domains.

Conclusion and Future Work

By shifting from supervised to unsupervised learning, we have removed the primary barrier to scaling query routing systems. Our "upper-bound" construction method provides a scalable way to leverage real-world data distributions. Future work will focus on reducing the computational overhead of generating upper-bound responses and exploring the integration of numerical tool-use scores into the routing logic.

Summary updated

BibTeX
@misc{mu2025unsupervised,
  author = {Feiteng Mu and Liwen Zhang and Yong Jiang and Wenjie Li and Zhen Zhang and Pengjun Xie and Fei Huang},
  title = {{Unsupervised Query Routing for Retrieval Augmented Generation}},
  year = {2025},
  eprint = {2501.07793},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2501.07793},
}
Figure