What is modular RAG?

Modular RAG is an architectural approach splitting a retrieval-augmented generation system into independent modules such as query rewriting, retrieval, reranking, compression, generation and verification, allowing them to be combined in different flows with routing, branching and looping.

It follows naive RAG (one-step retrieval and generation) and advanced RAG (pre- and post-retrieval improvements); modular RAG turns these steps into swappable parts beyond a linear flow. Agentic Retrieval-Augmented Generation goes further by adding an agent deciding the flow.

Topic
Embeddings, document processing and RAG
Also known as
Modular Retrieval-Augmented Generation

How modular RAG works

  1. The system is split into modules and operators, each doing one job.
  2. By query type, a router chooses which modules run and in what order.
  3. Patterns can be linear, conditional, branching or looping until the answer suffices.
  4. Each module is measured, replaced and scaled separately; fusion modules merge results from different sources.

In more detail

Latency budgets, cost multipliers and loop limits

Every additional module (query rewriting, dense and sparse retrieval, cross-encoder reranking, faithfulness verification and retry loops) adds latency and LLM inference cost. Production modular RAG pipelines must enforce strict hop and loop limits (such as a maximum of two rewrites), latency budgets and deterministic fallbacks to prevent runaway loops and degraded time-to-first-token.

Module-level and end-to-end observability

Modular pipelines fail silently if only the final answer is evaluated. Teams pair end-to-end metrics (answer faithfulness, relevance, citation accuracy) with component-level metrics (retriever recall@k, router accuracy, reranker NDCG) and distributed tracing so regressions can be pinpointed to a specific module.

Permission propagation across sources and indirect prompt injection defence

When routing spans vector indexes, keyword search, knowledge graphs (GraphRAG) and relational databases (Text-to-SQL), access controls must be enforced prior to retrieval or fusion. Enforcing document-level permissions (RBAC/ABAC) and sanitising retrieved passages protects against unauthorised data exposure and indirect prompt injection.

Commonly confused terms

TermHow it differs
Agentic RAGModular RAG uses predefined or learned routing, conditional logic and bounded loops across specialised modules; Agentic RAG lets an autonomous LLM agent dynamically plan multi-step tool calls, inspect intermediate results and decide when to stop.
Long-context promptingLong-context prompting feeds entire documents directly into the model's context window without a retrieval router; modular RAG selectively retrieves, filters and routes only the relevant chunks or structured query paths to control cost, latency and noise.

Why modular RAG matters for on-premises AI

As enterprise RAG systems grow, one linear flow no longer fits different document types, sources and question forms. A survey of RAG classifies its evolution into naive, advanced and modular paradigms. The paper proposing the modular RAG framework shows decomposing complex systems into independent modules and specialised operators gives a reconfigurable structure, with routing, scheduling and fusion enabling linear, conditional, branching and looping patterns. The cost is complexity: each module must be monitored and evaluated.

ON-PREMISES EXAMPLE

A bank builds a modular RAG routing regulatory questions to its regulation index, product questions to product documents and numerical questions to a text-to-SQL module; if an answer cannot be verified against sources, the flow rewrites the query and retrieves again.

Common questions

How does modular RAG differ from advanced RAG?

Advanced RAG improves a linear flow. Modular RAG splits steps into swappable modules combined with routing, branching and loops.

When is modular RAG needed?

When different question types need different sources and steps and one linear flow falls short.

Sources

In the glossary: Glossary, M to Q

What does this term mean for your infrastructure?

We can work out together in a technical assessment how it maps onto your data, hardware and security requirements.

Request a technical assessment →

This site sets no cookies. Visitor numbers are counted in aggregate using a cookieless method that does not identify anyone. See the Privacy Policy for details.