Notes

Modular RAG

Most introductions to retrieval-augmented generation describe a straight line: take the question, fetch a few documents, hand both to the model. Modular RAG is what you get when that line is cut into interchangeable parts that can be reordered, repeated, or skipped.

A pipeline made of components

The system is assembled from named modules with defined inputs and outputs — a query rewriter, a retriever, a reranker, a generator, plus optional routing, memory and fusion stages. Swapping dense vector search for hybrid search becomes a configuration change rather than a rewrite. Control flow turns explicit too: a router sends an arithmetic question straight to the model while a policy question goes to the document store, and a loop retrieves a second time when the first pass comes back thin. It is the third tier in the naive, advanced and modular taxonomy used by the standard RAG survey.

Why the structure pays off
  • Failures become locatable — you can ask whether retrieval missed the passage or the generator ignored it, because those are separate stages with inspectable outputs.
  • Each module is measurable on its own: retrieval recall, rerank precision, answer faithfulness.
  • One deployment serves several behaviours, since different question types travel different paths.

LlamaIndex and Haystack are built around this idea, exposing retrieval and generation as composable nodes. The cost is real — more hops, more latency, more configuration to get wrong — so modular RAG earns its complexity once a single fixed pipeline has visibly stopped fitting the questions being asked of it.

Modular RAG is a retrieval-augmented generation design in which query rewriting, retrieval, reranking, generation and routing are separate interchangeable modules rather than one fixed retrieve-then-generate chain, so stages can be reordered, repeated or bypassed per request. It matters because each stage can be swapped, measured and debugged independently, letting one system serve varied question types and letting one component improve without rebuilding the pipeline.

Think of a kitchen rather than a vending machine. A vending machine does one thing in one fixed order. A kitchen has separate stations — someone reads the order, someone fetches ingredients, someone checks quality, someone cooks — and you can rearrange them for different dishes. Modular RAG is the kitchen version of an assistant that looks things up before answering. Instead of one rigid routine, the looking-up, the double-checking and the writing are separate steps that can be swapped, repeated or skipped. The payoff is practical: when an answer comes out wrong, you can tell which station dropped the ball.