Reference architecture

GraphRAG & Entity Knowledge Networks

A production guide for combining vector similarity search with Neo4j and NetworkX graph traversal, entity extraction prompts, and sub-graph community detection.

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

Architecture

Traditional vector-only RAG indexes text passages independently, failing to connect implicit relationship networks across disparate documents.

Raw document ingestion
LLM entity & relationship extraction
Neo4j graph & vector store indexing
Hybrid vector & graph traversal search
Sub-graph community context synthesis
LLM grounded response generation
Conceptual teaching model synthesized from:Retrieval-Augmented Generation for Knowledge-Intensive NLP TasksIntroduction to Information Retrieval

GraphRAG combines dense vector embeddings with graph database topologies (Neo4j, NetworkX, Memgraph) to extract entities, relationships, and hierarchical community clusters.

Extract entity relationship triples
Deduplicate entity node identities
Detect modularity community clusters
Evaluate multi-hop question answering
Refine extraction prompts & thresholds
Conceptual teaching model synthesized from:Retrieval-Augmented Generation for Knowledge-Intensive NLP TasksIntroduction to Information Retrieval

Graph Retrieval Comparison

| Architecture | Retrieval Mechanism | Multi-Hop Ability | Indexing Overhead | Best Used For | |---|---|---|---|---| | Vector RAG | Cosine similarity on chunks | Poor (Disjoint passages) | Low | Single-passage lookup | | GraphRAG (Triples) | Entity node k-hop expansion | High (Explicit edges) | Medium | Entity relationship queries | | Hierarchical GraphRAG | Community detection summaries | Very High (Global synthesis) | High | Enterprise corpus summarization |

Entity Extraction & Community Detection

GraphRAG constructs knowledge networks in 3 stages:

Entities, Relationships = LLM_Extract(Document_Passages)
Graph_Database = Build_Network(Entities, Relationships)
Communities = Leiden_Community_Detection(Graph_Database)
  1. Triple Extraction: LLM extracts structured triples (Subject, Relationship, Object) from text chunks.
  2. Node Deduplication: Canonical entity normalization merges variants (e.g., "vLLM", "vLLM Engine", "PagedAttention Engine") into single graph nodes.
  3. Leiden / Louvain Clustering: Detects densely connected sub-graph communities and generates hierarchical community summaries.

Decisions

| Decision | Required evidence | Review trigger | |---|---|---| | Combine vector similarity with 2-hop graph expansion for complex enterprise domain queries. | Benchmark showing +25% multi-hop QA recall improvement | Corpus containing highly interconnected domain entities | | Enforce strict canonical entity normalization during triple ingestion. | Graph audit showing < 5% duplicate node variants | Entity explosion degrading graph query performance | | Pre-compute community summaries using hierarchical Leiden clustering. | Evaluation showing > 85% accuracy on global corpus summarization | Requirement to support high-level overview queries |

Alternatives and trade-offs

GraphRAG provides unparalleled multi-hop reasoning and holistic document synthesis, but increases ingestion LLM costs by 3x–5x compared to standard vector chunking due to triple extraction prompts.

Failure modes

  • Entity node explosion caused by failing to canonicalize entity names during ingestion.
  • Extraneous edge generation creating noisy graph paths between weakly related topics.
  • Graph database query timeouts on un-indexed 4-hop depth Cypher traversals.

Operational checklist

  • [ ] Entity extraction prompts use structured JSON output schemas.
  • [ ] Canonical entity resolution runs periodically to merge duplicate nodes.
  • [ ] Graph database queries enforce maximum hop depth ($N \le 2$).
  • [ ] Vector search seed nodes are combined with graph neighborhood expansions.

Connected practice

Sources

  • rag-paper
  • information-retrieval-book