GraphRAG & Structured Retrieval
Combining Knowledge Graphs with vector search for global multi document summarization.
Vector RAG vs GraphRAG
Standard Vector RAG is great for Local Point Queries:
- "What is the refund policy for Product X?" $\to$ Vector search retrieves 2 matching chunks $\to$ LLM answers accurately.
However, Vector RAG fails completely on Global Sense-Making Queries:
- "What are the top 5 recurring risk themes across all 5,000 audit reports?"
Why Vector RAG fails on global queries:
- Vector search returns top $K$ local chunks (e.g. $K=5$). 5 chunks cover $0.1%$ of the dataset.
- The LLM never sees the remaining $99.9%$ of documents, missing overarching trends.
GraphRAG (Microsoft Research - Edge et al., 2024) combines Knowledge Graphs with LLM summarization to answer global dataset level questions.
RAW DOCUMENTS
│
▼
1. KNOWLEDGE GRAPH EXTRACTION (LLM extracts Entities & Relationships)
│
▼
2. HIERARCHICAL COMMUNITY DETECTION (Leiden Algorithm groups entity clusters)
│
▼
3. COMMUNITY SUMMARIZATION (LLM pre-summarizes each entity community)
│
▼
GLOBAL QUERY ──► Aggregate Community Summaries ──► Synthesized Global Answer!
Step-by-Step GraphRAG Pipeline
┌──────────────────────────┬──────────────────────────┬──────────────────────────┐
│ 1. ENTITY EXTRACTION │ 2. LEIDEN CLUSTERING │ 3. COMMUNITY SUMMARIES │
├──────────────────────────┼──────────────────────────┼──────────────────────────┤
│ LLM extracts Entities │ Groups connected nodes │ Pre-summarizes each node │
│ (People, Products) & │ into hierarchical │ cluster into a structured│
│ Relationships (Edges) │ community clusters │ executive summary text. │
│ from text chunks. │ (Level 0, 1, 2). │ Runs OFFLINE! │
└──────────────────────────┴──────────────────────────┴──────────────────────────┘
Step 1: Entity & Relationship Extraction
An LLM processes text chunks to extract structured Nodes (Entities) and Edges (Relationships):
- Node:
[Company A](Type: Organization) - Node:
[Product X](Type: Software) - Edge:
[Company A] --(ACQUIRED)--> [Product X]
Step 2: Hierarchical Community Detection
The Leiden Algorithm partitions the Knowledge Graph into hierarchical sub-graph communities:
- High-Level (Level 0): Macro clusters (e.g. "Tech Industry Mergers").
- Low-Level (Level 2): Micro clusters (e.g. "Product X API Integration").
Step 3: Community Summarization
An LLM pre-generates executive summaries for every discovered community cluster offline.
Step 4: Global Search Execution
When a user asks a global question ("Summarize key acquisition risks"):
- Parallelize query over all high-level Community Summaries.
- Synthesize intermediate answers into a single comprehensive global response!
Detailed Comparison Matrix
| Query Type | Vector RAG | GraphRAG |
|---|---|---|
| "What is John's email?" | Fast & Cheap (Sub-10ms) | Overkill |
| "Summarize main dataset themes" | Fails (Retrieves 0.1% data) | Excellent (Global Synthesis) |
| Multi-Hop Reasoning | Weak | Strong (Follows Graph Edges) |
| Indexing Cost | Low (Vector embedding) | High (LLM Graph Extraction) |
Say this out loud
GraphRAG combines Knowledge Graphs with LLMs for global dataset sense-making. Standard Vector RAG retrieves local point chunks but fails on broad questions. GraphRAG extracts entities and relationships into a graph, clusters nodes into hierarchical communities using the Leiden algorithm, and pre summarizes clusters offline to generate global dataset answers.
Followups to expect
- How does GraphRAG perform Local Search? Local Search in GraphRAG identifies entity nodes matching user query keywords, expands to 1-hop and 2-hop graph neighbors, and includes relevant text chunks in context for detailed multi-hop QA.
- Why is GraphRAG indexing expensive? Running LLM entity extraction across thousands of raw document chunks requires significant LLM API calls during initial indexing. Use smaller models (like LLaMA 3 8B) for entity extraction to lower cost.
Check yourself
What core limitation of standard Vector RAG does GraphRAG (Edge et al., 2024 - Microsoft) address?