Skip to content
AI Engineer Guide.

concept · concepts · intermediate · concept 48 of 57

GraphRAG

0 of 57 complete

Why it matters

Vector retrieval returns passages that resemble the question, which fails when the answer requires joining facts about several entities or summarising a whole corpus. A graph makes those joins explicit: entities are nodes, mentions are edges, and a traversal can collect everything connected to a subject. The price is an extraction pipeline whose errors — merged entities, missed relations — are hard to see and expensive to fix.

Mental model

GraphRAG is a map of relationships rather than a pile of pages: you can trace how one entity connects to another. The metaphor breaks because the map is drawn by a model that sometimes merges two towns with similar names, and every route through them is then wrong.

How it works

A three-edge join, and the merge that breaks itInteractive

The join is a path: Acme Inc. → annual plan → refund policy → Clause 4.2 is three edges, and a two-edge traversal stops one short.

Step 1/7 · Read the graph

Step 1 of 7

Read the graph

Eleven entities, one document and the edges extraction asserted. Two seams matter: the merge on the left and the three-edge chain on the right that reaches the clause.

Narrow layout: nodes in reading order, each followed by its outgoing edges. The wide drawing shows the same graph as geometry.

  1. No outgoing edge.

    entity

    5 connections

    Acme Inc.

    resolved customer

    The resolved customer. Resolution writes one merge edge before traversal; a wrong merge produces a confident wrong neighbourhood rather than an error.

  2. No outgoing edge.

  3. No outgoing edge.

callconflictprovenancewider stroke + "this step" = current path

entity · document · 12 nodes · 12 edges · fixed authored layout, no simulation · list

Figure. Local GraphRAG answers by traversing asserted relations: the resolved customer reaches the annual plan, the plan has a refund policy, and the policy states Clause 4.2 — three edges, so a two-edge traversal stops one short. The provenance edge keeps the clause traceable to the chunk that asserted it, and the conflict edge is the entity conflation that would make every route through the merged node confidently wrong.

What to notice. The clause is three edges from the resolved customer, not two, and the region and plan filters are graph joins rather than metadata lookups. The figure omits the extraction pass, entity-resolution thresholds, community summaries and the vector-search comparison; it shows one bounded local traversal. Names, counts and the tier mapping are illustrative for this corpus — annual is treated as the enterprise tier here.

Text version

Eleven entities and one document, twelve nodes in total. A ticket mention of Acme resolves to Acme Inc. with a same-as edge; the EU region is a second seed and connects to Acme Inc., Northwind GmbH and Contoso Ltd. Acme and Northwind connect to the annual plan, Contoso to the monthly plan, and Acme is billed by INV-8841. The annual plan has a refund policy, which states Clause 4.2; the clause has a provenance edge to Chunk 218. Acme Corp is a separate entity with a wrong-merge conflict edge into Acme Inc. Steps light the whole graph, seed resolution, one edge out, two edges out, the three-edge path to the clause, the collected subgraph with provenance, and the wrong merge.

  1. Extract entities and relations per chunk with a schema that names the node and edge types you need.
  2. Resolve duplicates such as aliases, abbreviations and legal versus trading names before writing edges, since merging later is harder.
  3. Store the graph with provenance edges back to the chunk that asserted each relation.
  4. For local questions, find the seed entity and traverse a bounded neighbourhood, then rank the collected text.
  5. For global questions, cluster the graph into communities, summarise each, and answer from summaries with drill-down.
  6. Evaluate entity resolution and relation precision separately from answer quality, because both feed it.

Trade-offs

ChoiceGood forCostFails when
Graph plus vectorMulti-entity and relational questionsTwo indexes and a construction pipelineThe corpus is small or questions are simple lookups
Local traversalPrecise neighbourhoods around an entityMisses relations not extractedQuestions need corpus-wide aggregation
Community summariesGlobal questions over a large corpusSummarisation cost and stalenessDocuments change frequently
Vector onlyCheap and simpleCannot join facts across documents reliablyQuestions require connecting entities
Trade-off mapInteractive

Good for

Multi-entity and relational questions

Cost

Two indexes and a construction pipeline

Fails when

The corpus is small or questions are simple lookups

  1. The corpus is small or questions are simple lookups
  2. Questions need corpus-wide aggregation
  3. Documents change frequently
  4. Questions require connecting entities

Figure. Each choice with what it buys, what it costs, and the case where it loses.

What to notice. The fourth column is the decision: if the losing case describes your situation, the choice is wrong.

Text version

Four trade-offs: Graph plus vector is good for Multi-entity and relational questions, costs Two indexes and a construction pipeline, and fails when The corpus is small or questions are simple lookups. Local traversal is good for Precise neighbourhoods around an entity, costs Misses relations not extracted, and fails when Questions need corpus-wide aggregation. Community summaries is good for Global questions over a large corpus, costs Summarisation cost and staleness, and fails when Documents change frequently. Vector only is good for Cheap and simple, costs Cannot join facts across documents reliably, and fails when Questions require connecting entities

Failure modes

  • Entity conflation. Two distinct entities with similar names merge, so traversal returns the wrong neighbourhood. Debug: list the highest-degree nodes and inspect their aliases for collisions.
  • Relation loss. A relation stated implicitly is never extracted, so the graph is missing the edge the question needs. Debug: take a known multi-hop question and check whether its path exists as edges.
  • Stale communities. Summaries are generated once and drift as documents change. Debug: compare a summary's claims with the current text of its member chunks.

In production

Monitor graph size, extraction failure rate and the share of queries with no seed entity. Rebuild communities on a schedule and keep provenance so any edge can be traced to text.

Common misconceptions

People think: GraphRAG is strictly better than vector RAG.

Actually: It is better for relational and global questions and worse on cost and simple lookups.

People think: The graph captures all the document's meaning.

Actually: It captures only the entity and relation types you asked for, which is a lossy projection.

Interview angle

Explain what the graph buys — explicit joins and global summaries — and what it costs in extraction and entity resolution. Distinguish local from global search. Saying documents are stored as a knowledge graph, without saying how relations are extracted or evaluated, is the vague answer.

Sources