LLMs & GenAI

GraphRAG & Structured Retrieval

Combining Knowledge Graphs with vector search for global multi document summarization.

🔴 advanced5 min readrag
GraphRAG (Microsoft, 2024) combines Knowledge Graphs with RAG vector retrieval to answer complex global questions across massive document collections. Standard RAG vector search excels at local point queries ('What is John's salary?'), but fails on global holistic questions ('What are the main themes across all 5,000 documents?'). GraphRAG extracts Entities and Relationships into a Knowledge Graph, builds hierarchical entity communities using the Leiden algorithm, and generates community summaries for multi hop reasoning.

Vector RAG vs GraphRAG

Standard Vector RAG is great for Local Point Queries:

However, Vector RAG fails completely on Global Sense-Making Queries:

Why Vector RAG fails on global queries:

  1. Vector search returns top $K$ local chunks (e.g. $K=5$). 5 chunks cover $0.1%$ of the dataset.
  2. 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):

Step 2: Hierarchical Community Detection

The Leiden Algorithm partitions the Knowledge Graph into hierarchical sub-graph communities:

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"):

  1. Parallelize query over all high-level Community Summaries.
  2. Synthesize intermediate answers into a single comprehensive global response!

Detailed Comparison Matrix

Query TypeVector RAGGraphRAG
"What is John's email?"Fast & Cheap (Sub-10ms)Overkill
"Summarize main dataset themes"Fails (Retrieves 0.1% data)Excellent (Global Synthesis)
Multi-Hop ReasoningWeakStrong (Follows Graph Edges)
Indexing CostLow (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

  1. 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.
  2. 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

Question 1 of 3

What core limitation of standard Vector RAG does GraphRAG (Edge et al., 2024 - Microsoft) address?

More in LLMs & GenAI

See all →
Pretraining → SFT → RLHF5 minFine-Tune vs RAG vs Prompt: Choosing5 minRetrieval-Augmented Generation5 min