GraphRAG and Knowledge Graphs

Why vector RAG struggles with multi-hop and global questions, what knowledge graphs add, how GraphRAG is built (entity extraction, communities, summaries), local vs global search, hybrid graph-vector retrieval, and when it is worth the cost.

On this page

Simple definition#

A knowledge graph stores facts as entities (nodes: people, products, systems, contracts) and relationships (edges: owns, depends on, supplies). GraphRAG uses such a graph — often built automatically from documents by an LLM — to retrieve connected facts and summaries that plain vector search cannot find.

The problem with vector-only RAG#

Vector RAG retrieves chunks that look like the question. It struggles with:

  • Multi-hop questions — “Which customers are affected if supplier X fails?” needs supplier → components → products → contracts → customers; no single chunk contains the chain.
  • Global / summarisation questions — “What are the main themes in 5,000 customer complaints?” No top-5 chunks can answer that.
  • Relationship and aggregation questions — “Who are all the owners of systems that process card data?”

How a knowledge graph helps#

A slice of an enterprise knowledge graph
flowchart LR
    SUP["Supplier: ChipCo"] -->|"SUPPLIES"| COMP["Component: PX-9 chip"]
    COMP -->|"USED_IN"| P1["Product: Router R5"]
    COMP -->|"USED_IN"| P2["Product: Gateway G2"]
    P1 -->|"SOLD_UNDER"| C1["Contract: #2231 Acme Bank"]
    P2 -->|"SOLD_UNDER"| C2["Contract: #2240 Globex"]
    C1 -->|"HAS_SLA"| S1["SLA: 99.95%, 4h replacement"]
    TEAM["Team: Network Ops"] -->|"OWNS"| P1

“Which customers depend on ChipCo?” becomes a graph traversal: ChipCo → PX-9 → R5, G2 → contracts → Acme Bank, Globex — precise, complete and explainable.

The GraphRAG indexing pipeline#

The approach popularised by Microsoft Research’s GraphRAG:

GraphRAG indexing
flowchart TB
    D["Documents"] --> C["Chunk"]
    C --> X["LLM extracts entities, relationships<br/>and claims from each chunk"]
    X --> M["Merge duplicates<br/>entity resolution"]
    M --> G[("Knowledge graph")]
    G --> CD["Community detection<br/>Leiden algorithm, hierarchical"]
    CD --> CS["LLM writes a summary<br/>for every community"]
    CS --> IDX[("Community summaries")]
    C --> V[("Chunk embeddings")]
  1. Extract — an LLM reads each chunk and outputs entities (with types and descriptions) and relationships.
  2. Resolve — merge “IBM”, “I.B.M.” and “International Business Machines” into one node.
  3. Cluster — community detection groups densely connected entities into topics, at several levels (themes → sub-themes).
  4. Summarise — an LLM writes a report for each community.
  5. Embed entity descriptions, chunks and summaries for search.

Query modes#

Local vs global search
flowchart LR
    subgraph Local["Local search — specific entities"]
        L1["Find entities in question<br/>via embeddings"] --> L2["Expand neighbours<br/>1–2 hops"] --> L3["Collect related chunks,<br/>relationships, community info"] --> L4["Answer"]
    end
    subgraph Global["Global search — whole corpus"]
        G1["Take community summaries<br/>at chosen level"] --> G2["Map: partial answer<br/>from each summary"] --> G3["Reduce: combine into<br/>final answer"]
    end
  • Local search answers questions about specific entities and their connections.
  • Global search answers “what are the main themes…” questions using map-reduce over community summaries.
  • DRIFT search and similar hybrids start global and drill down locally.

Other ways to use graphs in RAG#

Approach How it works Good for
Text-to-Cypher / SPARQL LLM translates the question into a graph query against a curated graph Precise questions over well-modelled data (CMDB, org charts, product catalogues)
Graph-enhanced vector search Vector search finds entry chunks; follow graph edges to related chunks Adding context and multi-hop to normal RAG
Lightweight GraphRAG (LightRAG and similar) Cheaper extraction, dual-level keys, incremental updates Lower indexing cost
Existing enterprise graphs Use your master-data or ontology graph as a retrieval source Organisations with mature data governance
Hybrid vector + graph retrieval
flowchart LR
    Q["Question"] --> VS["Vector / hybrid search<br/>find relevant chunks"]
    VS --> E["Entities mentioned<br/>in those chunks"]
    E --> GT["Graph traversal<br/>neighbours, paths"]
    GT --> CTX["Context: chunks +<br/>relationship facts"]
    VS --> CTX
    CTX --> LLM["LLM answer<br/>with explainable path"]

Trade-offs#

Vector RAG GraphRAG
Indexing cost Low (embeddings) High — LLM calls over every chunk, plus summaries
Updates Easy, incremental Harder: re-extraction, re-clustering
Single-fact lookup Strong Similar
Multi-hop / relationships Weak Strong
Global summarisation Weak Strong
Explainability Cites chunks Cites chunks and paths
Extraction errors N/A Wrong or missing edges propagate

Common mistakes#

Review questions#

What is GraphRAG? A RAG approach that builds a knowledge graph of entities and relationships from documents — usually with an LLM — clusters it into communities with summaries, and retrieves graph neighbourhoods or community summaries to answer questions that need connections or corpus-wide understanding.

When does vector RAG fail where GraphRAG succeeds? Multi-hop questions that need chaining facts across documents, relationship and aggregation questions, and global questions such as “what are the main themes across all reports?”

Explain local vs global search in GraphRAG. Local search starts from entities in the question and gathers their neighbourhood, related chunks and community information. Global search runs map-reduce over community summaries to answer corpus-wide questions.

What are the costs and risks of GraphRAG? Expensive indexing (LLM extraction and summarisation over the whole corpus), harder incremental updates, and extraction errors that create wrong or missing relationships. It needs a schema, entity resolution and evaluation.

How else can graphs be used with LLMs? Text-to-Cypher over curated graphs, graph traversal to expand vector search results, and using existing enterprise knowledge graphs or ontologies as a retrieval source for agents.

Summary#

  • Knowledge graphs store entities and relationships; GraphRAG retrieves over them.
  • It shines on multi-hop, relationship and global questions where vector RAG fails.
  • Indexing: LLM extraction → entity resolution → community detection → summaries.
  • Local search for specific entities, global search for themes.
  • High indexing cost; use a schema, resolve entities, and evaluate against vector RAG.

References#