Skip to content
mentoor

Topic 2 of 4 · 4 min read

GraphRAG and knowledge-graph retrieval

Goal: Decide whether a corpus and question mix justify GraphRAG and estimate the extra indexing cost.

GraphRAG builds a graph of entities and relations from your documents, then summarises clusters of that graph, so it can answer questions about the whole corpus that plain chunk retrieval cannot. It is slower and more expensive to build, and for many questions it is not needed.

Check yourself · 1 of 3

Which question is GraphRAG built to handle better than plain chunk retrieval?

Choose one answer

Why it matters

Plain RAG retrieves a handful of chunks that look like the question. That works for "what is the refund window?" because one passage holds the answer. It fails for "what are the main themes across these 400 incident reports?" because no single chunk says that. Microsoft Research introduced GraphRAG for exactly this kind of corpus-wide question, which the paper calls query-focused summarisation.

How it works

  1. Extract. A model reads each chunk and lists entities (people, services, products, places) and the relations between them, such as "billing-service depends on ledger-db".
  2. Build the graph. Entities become nodes, relations become edges. Duplicate names ("Acme", "Acme Inc.") are merged.
  3. Find communities. A clustering algorithm groups densely connected nodes, for example everything around the payments systems.
  4. Summarise. A model writes a report for each community, at several levels from small clusters to large ones.
  5. Answer. For a global question, the system asks each community report for a partial answer and combines them. For a local question about one entity, it starts from that node and walks its neighbours.

You can also keep a graph you already have, such as an org chart or a product dependency map in a graph database, and query it directly with a graph query language. That needs no extraction step.

Before and after

A question over a pile of customer interviews: "What do users complain about most?"

  • Plain RAG returns the five chunks closest to the word "complain". The answer lists whatever those five say, and sounds complete.
  • GraphRAG answers from community reports: onboarding friction, export bugs, pricing confusion, each backed by many documents.

What it costs

Every chunk goes through a model at index time, often more than once, so indexing can cost far more than embedding the same text. You pay again when documents change, because entities and summaries must be rebuilt. Estimate it before you commit: number of chunks times tokens per chunk times the number of model passes, priced at your model's rate. Run it on a sample first.

What goes wrong

  • Using it for lookup questions. If answers sit in one passage, plain or hybrid retrieval is cheaper and just as good.
  • Extraction errors. A model may invent a relation or split one entity in two. The graph then holds confident mistakes that every summary inherits.
  • Stale summaries. Documents change, community reports do not, and the answer describes last quarter.
  • No evaluation. Without a test set of global questions, you cannot tell if the extra cost bought better answers.

Decide by the question mix: mostly lookups, stay with plain RAG; many "across everything" questions on a stable corpus, GraphRAG is worth a trial.

Examples

Incident reports versus a refund policy

A support team has 400 incident reports and a 6-page refund policy. "What is the refund window?" is a lookup: one chunk of the policy answers it, so hybrid retrieval is enough. "Which services were involved most often in outages this year?" spans every report. That is the case for entity extraction and community summaries.

A quick cost estimate

A corpus has 20,000 chunks of about 600 tokens each, which is 12 million tokens. If entity extraction makes two model passes per chunk, that is about 24 million input tokens before the community summaries. Multiply by your model's input price, run the pipeline on 500 chunks first, and extrapolate from the measured bill.

Key points

  • GraphRAG extracts entities and relations, clusters the graph into communities and writes a summary for each.
  • It targets global questions about a whole corpus, such as main themes, where no single chunk holds the answer.
  • Lookup questions answered by one passage are served better and cheaper by plain or hybrid retrieval.
  • Indexing runs a model over every chunk, so estimate chunks times tokens times passes before committing, and rebuild when documents change.
  • Extraction mistakes and stale community reports become confident wrong answers, so evaluate on real global questions.

Common mistakes

  • Choosing GraphRAG because it sounds more advanced, without a list of the questions users actually ask.
  • Skipping a cost estimate and discovering the indexing bill after the full corpus has run.
  • Trusting extracted entities without sampling them, so duplicates and invented relations go unnoticed.
  • Treating the graph as one-off and never rebuilding it when the documents change.

Check yourself · 2 of 3

What is the main extra cost of GraphRAG compared with plain RAG?

Choose one answer

Check yourself · 3 of 3

A team extracted entities from their wiki. The graph has one node for "Acme" and another for "Acme Inc.". What is the likely effect?

Choose one answer

Practice items, not counted towards your mastery.

Start here

More for this topic