Abstract
Retrieval models are key components of Retrieval-Augmented Generation (RAG) systems, which generate search queries, process the documents returned, and generate a response. RAG systems are often dynamic and may involve multiple rounds of retrieval. While many state-of-the-art retrieval methods are available through academic IR platforms, these platforms are typically designed for the Cranfield paradigm in which all queries are known up front and can be batch processed offline. This simplification accelerates research but leaves state-of-the-art retrieval models unable to support downstream applications that require online services, such as arbitrary dynamic RAG pipelines that involve looping, feedback, or even self-organizing agents. In this work, we introduce RoutIR, a Python package that provides a simple and efficient HTTP API that wraps arbitrary retrieval methods, including first stage retrieval, reranking, query expansion, and result fusion. By providing a minimal JSON configuration file specifying the retrieval models to serve, RoutIR can be used to construct and query retrieval pipelines on-the-fly using any permutation of available models (e.g., fusing the results of several first-stage retrieval methods followed by reranking). The API automatically performs asynchronous query batching and caches results by default. While many state-of-the-art retrieval methods are already supported by the package, RoutIR is also easily expandable by implementing the Engine abstract class. The package is open-sourced and publicly available on GitHub.
Introduction
Historically, information retrieval (IR) research has relied on the "Cranfield paradigm," where a fixed set of queries and documents are evaluated offline in batches. Academic IR platforms like Anserini or PyTerrier are highly optimized for this static environment. However, modern Retrieval-Augmented Generation (RAG) systems—especially agentic ones—are highly dynamic. They generate queries on the fly, require multiple rounds of retrieval, and rely on feedback loops.
Embedding offline academic IR models into these live, online pipelines introduces significant engineering overhead. Conversely, production search engines like Elasticsearch or Vespa are often too heavy and rigid for rapid academic prototyping. RoutIR addresses this gap by providing a simple, robust web API layer that wraps existing offline IR models so they can be queried dynamically by downstream RAG applications.
System Architecture
RoutIR acts as a thin, flexible wrapper around existing retrieval models, prioritizing high throughput and ease of use. Its architecture consists of three main components:
- Engines: Python classes that wrap core retrieval capabilities, such as first-stage retrieval, reranking, query rewriting, or result fusion. Users can add new models by subclassing the abstract
Engineclass. ARelayengine also exists to route requests to other servers, enabling distributed setups. - Processors: These wrap the Engines to handle caching (via memory or Redis) and asynchronous query batching.
- Pipelines: RoutIR allows users to define complex retrieval workflows dynamically within the API request using a context-free grammar.
Dynamic Pipeline Construction
A key innovation of RoutIR is its ability to construct pipelines on-the-fly. Instead of hardcoding a retrieval pipeline on the server, the client defines it dynamically. This allows an LLM agent to decide the complexity of its retrieval step at runtime—for instance, choosing to fuse multiple indexes for a difficult query or using a single fast retriever for simpler tasks.
For example, a client can send a string like {qwen3-neuclir, plaidx-neuclir}RRF% >> rank1 to instruct the server to run two retrievers in parallel, fuse the results using Reciprocal Rank Fusion (RRF), and pass the top results to a reranker.
Evaluation and Key Results
To benchmark serving effectiveness, RoutIR was evaluated using the TREC 2023 NeuCLIR MLIR task, featuring 76 test queries and a corpus of approximately 10 million web documents in Chinese, Persian, and Russian. The system was tested with three distinct architectures: Multi-vector (PLAID-X), Learned-sparse (MILCO via Anserini), and Dense (Qwen3 via FAISS/vLLM).
- High Throughput: Using batched asynchronous requests, RoutIR achieved throughputs of 9.60 queries/sec for Qwen3, 7.05 queries/sec for PLAID-X, and 3.27 queries/sec for MILCO.
- Real-World Reliability: RoutIR powered the 10-week JHU SCALE 2025 workshop, serving over 50 researchers using three RTX TITAN GPUs, and served as the search backend for the TREC RAGTIME Track.
- Ease of Integration: Integration into the GPT Researcher toolkit was demonstrated using only approximately 20 lines of Python code.
Conclusion and Future Work
RoutIR successfully bridges the gap between academic IR research and production-ready RAG systems. By decoupling serving from implementation and providing asynchronous batching, it enables efficient, dynamic retrieval. Future work includes integrating LLM-based rerankers, implementing the Model Context Protocol (MCP) interface for wider agent compatibility, and improving request-level load balancing.
Summary updated