Reference architecture

GraphRAG & Entity-Knowledge Networks Reference Architecture

Production architecture blueprint for GraphRAG pipelines—covering entity-relation extraction, community detection, sub-graph summarization, and hybrid graph-vector retrieval.

18 minVerified 2026-08-073 primary sources
A governed production AI reference architecture with observable, secured service boundaries.

Architecture

Standard RAG struggles with multi-hop questions requiring global synthesis across an entire document corpus. GraphRAG connects extracted entities, relationships, and semantic communities into a structured knowledge graph to enable global summarization.

Document chunking & entity-relation LLM extraction
Knowledge graph construction (Nodes & Typed Edges)
Leiden community detection & hierarchical clustering
Sub-graph community report summarization
Global vs Local GraphRAG query routing
Contextual response generation with graph lineage
Conceptual teaching model synthesized from:LangGraph Agentic StateGraph Execution Engine RepositoryBuilding Effective AI Agents

1. Mathematical Formulation: Hierarchical Community Detection & Modular Indexing

GraphRAG partitions extracted entity-relationship graphs into dense communities using the Leiden Algorithm to maximize graph modularity ($Q$):

Graph Modularity Optimization Equation
Mathematical Formulation
Q = \frac{1}{2m} \sum_{i,j} \left[ A_{ij} - \frac{k_i k_j}{2m} \right] \delta(c_i, c_j)

Measures the density of entity connections inside sub-graph communities compared to random network distribution.


2. Architecture Comparison: Standard Vector RAG vs. Local GraphRAG vs. Global GraphRAG

Knowledge Retrieval Architecture Comparison Matrix
Architecture OptionPrimary Best-For Case

Decisions

| Decision | Required evidence | Review trigger | |---|---|---| | Use Leiden algorithm community detection for hierarchical graph partitioning. | Modular graph analysis showing non-overlapping dense sub-graphs | Graph partition modularity $Q < 0.3$ | | Pre-compute hierarchical community summaries at ingestion time. | Ingestion benchmark showing sub-second global query responses | Dataset-wide query response latency $> 2\text$ | | Combine local entity neighborhood graph traversals with global community maps. | Evaluation suite demonstrating 95%+ multi-hop accuracy | Failure on complex multi-entity query paths |


Alternatives and trade-offs

Standard vector RAG offers low ingestion cost and fast query response times but fails on broad dataset synthesis questions. Global GraphRAG solves dataset-wide summarization by pre-computing hierarchical community reports at the expense of higher initial ingestion LLM extraction costs.


Failure modes

  • Entity extraction prompts generating duplicate node aliases (e.g. "vLLM" vs "vLLM Engine").
  • Community detection algorithms creating overly sparse clusters on weakly connected graphs.
  • Large community reports exceeding LLM context windows during global query map-reduce rounds.

Operational checklist

  • [ ] Entity extraction prompt enforces entity canonicalization and deduplication.
  • [ ] Leiden algorithm modularity threshold is tuned for optimal community sizes (15–50 nodes per cluster).
  • [ ] Pre-computed community summaries are cached in vector storage for rapid global query routing.
  • [ ] Graph database connection pool is configured with automatic retry policies for multi-hop traversals.

Connected practice


Sources

  • langgraph-repo
  • anthropic-effective-agents
  • anthropic-trustworthy-agents