recallA retrieval
field guide

GraphRAG

Build this skill

Explain how GraphRAG builds community summaries and answers local and global questions, and judge its cost.

Questions about the whole collection

Some of the most useful questions cannot be answered by any small set of passages. "What are the main themes in student complaints this year?" "Summarise how hostel rules have changed across all circulars." "Which issues come up most in the placement cell's notices?" A naïve RAG system retrieves the top few chunks and summarises those, missing everything else. These are called global or sensemaking questions: they are about the collection as a whole.

GraphRAG is an approach published by Microsoft Research in 2024 (in a paper titled "From Local to Global") to handle such questions. It uses a language model to build a knowledge graph from the documents, groups the graph into communities of closely related entities, and writes a summary of each community ahead of time. Questions about the whole collection can then be answered from these summaries rather than from a handful of raw chunks.

How GraphRAG builds its index

ChunkdocumentsExtract graphentities +relationsFindcommunitiesclusters ofentitiesSummariseone report percommunityIndexgraph +summaries +chunks

Expensive work is done ahead of time: building the graph and summarising each community.

  1. Extract entities and relationships from every chunk with a language model, building a knowledge graph (people, committees, hostels, policies, events and the links between them).
  2. Detect communities: groups of entities that are densely connected to each other, using a graph clustering method (GraphRAG uses the Leiden algorithm). Communities are found at several levels, from a few large groups down to many small ones.
  3. Summarise each community: a language model writes a short report describing its entities, relationships and main points.

At question time, GraphRAG offers different search modes.

Global search answers whole-collection questions. It sends the question to many community summaries, gathers the relevant points from each, and combines them into one answer, a map-reduce pattern: map the question over summaries, then reduce the partial answers.

Local search answers questions about specific entities. It finds the entities related to the question, then gathers their neighbours, relationships, community summaries and the original text chunks that mention them.

DRIFT search, added by Microsoft in late 2024, combines the two: it starts from community-level information and then follows up with more focused local searches.

Step through a global question below.

Strengths and costs

GraphRAG's strength is questions that need a broad view: themes, trends, summaries of many documents, and questions that depend on connections between entities. Microsoft's evaluation found that for such global questions, GraphRAG produced more comprehensive and diverse answers than a standard vector RAG baseline.

Its costs are significant, and worth understanding before choosing it:

Vector RAG GraphRAG
Indexing cost Embed each chunk once A language model reads every chunk, plus writes every community summary
Updating Re-embed changed chunks Graph and summaries may need rebuilding as documents change
Best questions Specific facts in a few passages Themes, summaries, relationship-heavy questions
Answer time Fast Global search can make many model calls

The indexing cost is the biggest practical concern: running a language model over an entire large collection, and again when it changes, can be expensive. Variants such as Microsoft's LazyGraphRAG, and lighter graph-based approaches, aim to reduce this.

The program below shows the global-search idea in miniature: partial answers from community summaries are ranked by importance and combined.

python · runs in your browser

Expected output:

text
Main issues this year:
 - Repeated water outages in Block B (Maintenance, importance 9)
 - Menu changed twice after student complaints (Mess food, importance 8)
 - Gates close at 9 PM during exam week (Gate timings, importance 7)
 - Reminders about late hostel fee payments (Fees, importance 6)

This is the "reduce" half of the map-reduce pattern. The list holds what the "map" step produced: one partial answer per community, each with an importance score. sorted(..., key=lambda c: -c[2])[:4] keeps the four most important points, and the loop writes them out as one combined answer.

Follow your curiosity.

↑ ↓ to explore · Enter to open · Escape to close