Glossary
Modular RAG
An approach to retrieval augmented generation that splits the pipeline into swappable modules, such as query rewriting, retrieval, reranking and generation, with routing, branches and loops between them.
Modular RAG is a way of designing retrieval augmented generation systems as a set of independent modules, such as query rewriting, retrieval, reranking and generation, that can be swapped, skipped, repeated or run in parallel. Where naive RAG runs one fixed sequence, a modular pipeline lets a router or orchestrator choose which steps run for each query. Most production RAG systems built with current frameworks are modular in practice, whether or not their builders use the term.
Where the idea comes from
The term comes from surveys of RAG research published in 2023 and 2024, which grouped systems into naive, advanced and modular stages. A 2024 follow-up paper described modular RAG as a reconfigurable framework of modules, sub-modules and operators, and named four flow patterns: linear, conditional, branching and looping. The idea is older than the label. Search engineers have long split retrieval into query understanding, candidate generation and ranking stages.
The usual modules
Module | What it does | Example techniques |
|---|---|---|
Indexing | Prepares content for retrieval | Chunking, embeddings, metadata |
Pre-retrieval | Reshapes the query | |
Routing | Picks a source or path | A vector index, a knowledge graph or the web |
Retrieval | Finds candidate passages | Vector, keyword or hybrid search |
Post-retrieval | Filters and orders candidates | |
Generation | Writes the answer | Prompt template, citations, structured output |
Orchestration | Decides what runs next | Conditions, loops, reciprocal rank fusion |
Flow patterns
A linear flow runs the modules in a fixed order, which is what advanced RAG looks like. A conditional flow uses a router to pick a path per query, for example sending numerical questions to a SQL tool and policy questions to a document index. A branching flow runs several retrievals in parallel, such as one per rewritten query, and fuses the results. A looping flow repeats retrieval until a check passes, as in corrective RAG, Self-RAG and multi-hop retrieval. When a language model chooses the next step itself, the system becomes agentic RAG.
Why teams adopt it
The main gain is that each part can be tested and replaced on its own. A team can swap the reranker or the embedding model without touching ingestion, measure the change against a golden dataset, and roll it back if recall drops. Routing also saves money, since a simple factual question does not need query decomposition and three retrieval passes.
The cost is complexity. Every module adds latency, a failure mode and something to monitor. Frameworks such as LangChain, LlamaIndex and Haystack provide the building blocks, but the wiring, evaluation and upkeep stay with the team. The RAG pipeline entry covers the stages in order, and LangChain vs LlamaIndex compares two of the frameworks.
Modular RAG and Exabase
Exabase fits as one or more modules rather than as a whole framework. Deep Search can serve as the retrieval module: content stored as Resources is indexed on arrival, text queries combine semantic and keyword matching, multi-query search fans out several queries in one call, and filters narrow results by folder, tag, type or date. A precision setting per call lets a router ask for broad recall on research questions and a tight match on factual ones.
Extract covers the indexing module for PDFs, audio, video and web pages, and Memory adds a module for what the agent knows about the user, with optional query expansion and reranking in memory search. The router, the prompt and the generation step remain in your code or framework, and a Worker can re-extract changed documents on a schedule. The searching resources guide, the RAG pipelines use case and Exabase vs LlamaIndex show how the pieces fit, and RAG accuracy covers why retrieval is usually the module to fix first.
FAQs
What is the difference between naive, advanced and modular RAG?
Naive RAG runs retrieve then generate once. Advanced RAG keeps that single path and adds steps around it, such as query rewriting and reranking. Modular RAG treats every step as a replaceable module and allows routing, parallel branches and loops between them.
Is modular RAG the same as agentic RAG?
Agentic RAG is one kind of modular RAG, in which a language model chooses the next module at run time. Modular RAG also covers pipelines whose routing is fixed code or simple rules.
Which frameworks support modular RAG?
LangChain, LlamaIndex and Haystack all let you compose retrievers, rerankers, routers and generators as separate components. Exabase vs Haystack and Exabase vs LangChain cover where a managed retrieval layer fits alongside them.
Does modular RAG improve accuracy?
It can, because each weak stage can be replaced and measured. The gain comes from the modules chosen, mostly better retrieval and reranking, more than from the structure itself. Why reranking can’t fix a bad first pass explains why the retrieval module matters most.
When is modular RAG more than you need?
For a small, stable corpus with simple questions, a single well-tuned retrieval step is easier to run and debug. Add modules when evaluation shows a specific failure, such as missed exact terms or questions that need two documents.
Can Exabase be one module in a modular RAG system?
Yes. Deep Search works as the retrieval module, Extract as the ingestion module and Memory as a user-context module, each through the REST API or the TypeScript SDK. Your orchestrator calls them alongside any other components, and each tenant can have its own Base.
Related pages: Naive RAG, Agentic RAG, Corrective RAG, Self-RAG, RAG pipeline, Retriever, Reranking, RAG accuracy, RAG pipelines use case, LangChain vs LlamaIndex.