Retrieval-Augmented Generation (RAG) significantly improves the performance of Large Language Models (LLMs) on knowledge-intensive tasks. However, varying response quality across LLMs under RAG necessitates intelligent routing mechanisms, which select the most suitable model for each query from multiple retrieval-augmented LLMs via a dedicated router model. We observe that external documents dynamically affect LLMs' ability to answer queries, while existing routing methods, which rely on static parametric knowledge representations, exhibit suboptimal performance in RAG scenarios. To address this, we formally define the new retrieval-augmented LLM routing problem, incorporating the influence of retrieved documents into the routing framework. We propose RAGRouter, a RAG-aware routing design, which leverages document embeddings and RAG capability embeddings with contrastive learning to capture knowledge representation shifts and enable informed routing decisions. Extensive experiments on diverse knowledge-intensive tasks and retrieval settings, covering open and closed-source LLMs, show that RAGRouter outperforms the best individual LLM and existing routing methods. With an extended score-threshold-based mechanism, it also achieves strong performance-efficiency trade-offs under low-latency constraints. The code and data are available at https://github.com/OwwO99/RAGRouter.
翻译:检索增强生成(RAG)显著提升了大型语言模型(LLM)在知识密集型任务上的性能。然而,不同LLM在RAG下的响应质量存在差异,这需要智能路由机制通过专用的路由模型为每个查询从多个检索增强的LLM中选择最合适的模型。我们观察到外部文档会动态影响LLM回答查询的能力,而现有路由方法依赖静态参数化知识表示,在RAG场景中表现出次优性能。为解决此问题,我们正式定义了新的检索增强LLM路由问题,将检索文档的影响纳入路由框架。我们提出RAGRouter,一种RAG感知的路由设计,它利用文档嵌入和RAG能力嵌入,结合对比学习来捕捉知识表示的动态变化,从而实现有依据的路由决策。在涵盖开源和闭源LLM的多种知识密集型任务和检索设置上进行的大量实验表明,RAGRouter优于最佳单一LLM及现有路由方法。通过扩展的基于分数阈值的机制,它还在低延迟约束下实现了优异的性能-效率权衡。代码与数据可在 https://github.com/OwwO99/RAGRouter 获取。