Formal Modular RAG Architecture
- Formal Modular RAG Architecture is a systematic and composable framework that decomposes retrieval-augmented generation into modular components with defined input/output specifications.
- The architecture enables rigorous benchmarking and ablation through precise module interfaces and parameterizable components, supporting extensive analysis and design-space exploration.
- It promotes extensibility and scalability by independently instantiating retrieval (SE, PF, PR) modules, allowing tailored instantiations for both accuracy and computational efficiency.
A formal modular Retrieval-Augmented Generation (RAG) architecture refers to a systematic, composable, and interface-driven decomposition of a RAG system, such that its core functionalities—retrieval, context aggregation, and generative reasoning—are realized as interoperable modules with well-defined input/output types and documented interface specifications, enabling rigorous benchmarking, ablation, extensibility, and tailored instantiation for diverse application scenarios and knowledge sources. In the context of Graph-based Retrieval-Augmented Generation (GraphRAG), a formal modular architecture encompasses fine-grained module boundaries, precise pipeline composition, and parameterizable components, supporting both analysis and design-space exploration in large-scale reasoning tasks (Cao et al., 2024).
1. Formal Problem Statement and Pipeline Structure
A modular GraphRAG framework assumes as input a text-attributed knowledge graph , where is a set of entities with textual descriptions and a set of labeled, directed edges for relations . Given a natural-language query , a preprocessing frontend extracts a set of query entities/relations present in .
The pipeline supports the following formal sequence:
- Entity/Relation Extraction:
- Reasoning Chain Retrieval: , where each is a multi-hop path.
- Augmented Prompt Construction: 0
- Answer Generation: 1
Compactly, 2.
2. Modular Decomposition of Retrieval
The retrieval phase is decomposed into three sequential modules, each with strictly defined interface contracts:
2.1 Subgraph-Extraction (SE)
- Inputs: Full graph 3, query entity set 4, parameters 5, 6.
- Outputs: Query-specific subgraph 7, 8.
- Algorithm: Personalized PageRank (PPR) from seed nodes, with possible semantic reranking via 9 if coupled with a neural/LLM scorer.
Interface:
2
2.2 Path-Filtering (PF)
- Inputs: Subgraph 0, seeds 1, method 2 {SPF, CPF, IPF}, 3, scoring function 4.
- Outputs: Candidate paths 5.
- Algorithms: Shortest-Path (Dijkstra, SPF), Complete Path Filtering (CPF, BFS enumeration), Iterative/Beam Search (IPF).
Interface:
3
2.3 Path-Refinement (PR)
- Inputs: Candidates 6, query 7, scoring function 8, 9.
- Outputs: Refined paths 0 (top-1).
- Algorithm: Score and select top-2 candidates.
Interface:
4
Module Interfaces Summary
| Module | Input Types | Output Types | Core Algorithm |
|---|---|---|---|
| SE | 3 | 4 | PPR, semantic rerank |
| PF | 5 | 6 | SPF, CPF, IPF (beam) |
| PR | 7 | 8 (top 9 paths) | Scoring + selection |
3. Systematic Taxonomy of Existing Techniques
Existing GraphRAG techniques can be mapped as valid module choices:
- SE: Purely structural (PPR, RWR), lexical (BM25), neural (Sentence-Transformer, DPR), LLM rerank (Llama/GPT), fine-tuned KG-coupled models.
- PF: Standard SPF/CPF (as in classical KBQA), beam-search + BM25/NN-based scorer, LLM-based scoring, fine-tuned in-domain LLMs.
- PR: Random, BM25 of path text, Sentence-Transformer rerankers, LLM re-ranking, LoRA-fine-tuned discriminators.
This mapping reveals a design space where each module is independently instantiable, provided interface consistency.
4. Assembly and Instantiation of New GraphRAG Pipelines
A concrete GraphRAG instance is specified by selecting one method per module, with budgetary/compatibility constraints:
- SE Module: {0, 1, 2, 3, 4}
- PF Module: {5, 6, 7, 8, 9}
- PR Module: {0, 1, 2, 3}
Parameters must be tuned to keep subgraph and candidate set sizes within hardware constraints.
Guidelines:
- Avoid double fine-tuning across SE and PF to prevent overspecialization.
- Non-NN pipelines (structural SE + basic PF/PR) are computationally frugal; LLM-powered pipelines offer accuracy at higher cost.
5. Evaluation Metrics and Multi-Objective Tradeoffs
Key evaluation metrics for modular GraphRAG architectures:
- Reasoning Quality 4: F1 or exact-match (HR@1) on generation output.
- Retrieval Quality 5: F1 versus ground-truth reasoning chains.
- End-to-End Quality 6.
- Runtime 7: 8 (seconds).
- Token Cost 9: aggregate LLM tokens processed.
- GPU Cost 0: LLM latency × GPU power.
Comprehensive optimization:
1
6. Empirical Design Principles for Modular GraphRAG
Empirical analysis in LEGO-GraphRAG provides the following guidance:
- SE: PPR maximizes recall; adding Sentence-Transformer reranking improves precision at low cost. Vanilla LLM reranking is more effective but incurs ~5× runtime overhead.
- PF: SPF and CPF are efficient; CPF provides richer context but is noisier. Beam search with ST reranking is optimal for F1/runtime; fine-tuning offers marginal gain. LLM beam search only helps with large, well-prompted models.
- PR: BM25 is fast but low quality; ST rerankers add 3–5 F1 points; LLM re-ranking is best but doubles runtime.
- Prompt Engineering: Increasing path count up to ~16 boosts F1, after which returns diminish. Few-shot prompts show inconsistent effects; zero-shot is robust.
- Overall Pipelines: PPR→SPF→ST for throughput; PPR+LLM_ft→BS+ST→LLM for accuracy (Cao et al., 2024).
The modular decomposition, taxonomy, and instantiation protocol in LEGO-GraphRAG enable systematic design, reproducibility, and principled experimentation in building advanced RAG systems grounded in structured knowledge graphs.