Microsoft GraphRAG Explained: Knowledge Graphs for Better RAG

Microsoft GraphRAG Explained: Knowledge Graphs for Better RAG

Microsoft GraphRAG is a graph-based approach to retrieval-augmented generation (RAG) that builds a knowledge graph from a document collection so a language model can answer questions about the whole corpus, not just the few chunks most similar to a query. It was introduced by Microsoft Research as an answer to a familiar weakness of plain vector RAG: it retrieves what looks similar, not necessarily what is needed. If your users ask broad, sense-making questions such as “what are the main themes in these reports”, GraphRAG is built for exactly that, while straightforward fact lookup is still faster and cheaper with ordinary vector search.

Standard RAG works well when the answer sits in one or two passages. It breaks down when the question spans hundreds of documents, because no single chunk contains the answer and the top matches are often only superficially similar to the question. GraphRAG fixes this by indexing the corpus into entities and relationships first, then summarising groups of related entities, so the system reasons over the structure of the data rather than over raw chunks alone.

Key takeaways

  • Microsoft GraphRAG is an open-source method from Microsoft Research that adds a knowledge graph layer to RAG.
  • It uses a language model to extract entities and relationships, groups them into communities with the Leiden algorithm, and writes a summary for each community.
  • Global search answers whole-corpus questions with a map-reduce pass over community summaries; local search answers questions about specific entities.
  • It suits broad, thematic questions over private document collections, and is overkill for simple fact lookup.
  • Indexing is the expensive part, because it runs language-model calls over every chunk of the corpus.

What Microsoft GraphRAG actually is

Microsoft GraphRAG is both a method and an open-source Python package. The method was described in a Microsoft Research introduction to GraphRAG, and the code is published on GitHub under the Microsoft organisation. It does not replace vector search. Instead, it builds a second index, a knowledge graph, alongside the usual chunk index, and uses that graph to answer questions that vector similarity alone handles badly.

The core idea is simple to state and expensive to run. A language model reads every document and pulls out the entities it mentions, such as people, organisations, places and concepts, together with the relationships between them. Those entities and relationships form a graph. The graph is then divided into communities of closely connected entities, and the model writes a summary of each community. At query time, the system can answer from those summaries instead of from raw text chunks.

This matters because many real questions are global rather than local. A question such as “which suppliers appear most often in these contracts” or “what changed in customer sentiment this year” has no single passage as its answer. The answer is a pattern across the corpus, and a graph index is a natural way to represent that pattern. For a deeper look at the general approach, see our guide to Graph RAG and how knowledge graphs fix retrieval blind spots.

How GraphRAG indexing works

Indexing happens offline, before any user asks a question, and it runs in four stages. Each stage uses the language model, which is why indexing a large corpus takes time and tokens. Understanding the stages helps you judge whether the cost is justified for your data.

Stage 1: chunking and entity extraction

The corpus is split into text units, usually paragraphs or short passages, and the language model extracts entities, relationships and claims from each unit. An entity might be a company, a product or a regulation, and a relationship might be that one company acquired another or that a policy applies to a department. Each extraction keeps a reference to the source text it came from, so answers can be traced back to documents.

Stage 2: entity resolution and graph construction

The same entity often appears under different names, so extracted mentions are deduplicated and merged into single nodes. The result is one graph in which nodes are entities and edges are relationships, each carrying a short description. This graph is the structured view of the corpus, and its quality depends directly on the extraction model: a weak model produces a noisy graph, and a noisy graph produces vague answers.

Stage 3: community detection with the Leiden algorithm

The graph is partitioned into communities, groups of entities that are densely connected to each other and loosely connected to the rest. GraphRAG uses the Leiden algorithm for this, applied at several resolutions to build a hierarchy, from broad themes at the top down to narrow topics at the bottom. A community might correspond to a product line, a legal dispute or a research theme, depending on the corpus.

Stage 4: community summaries

A language model writes a summary for every community, working bottom-up so that higher-level summaries draw on the summaries below them. Together, these summaries form a hierarchical description of the whole dataset, produced before any question is asked. That is the feature that sets GraphRAG apart: the system can report on the semantic structure of your data without knowing the questions in advance.

A printed diagram of connected circles and lines on a desk
GraphRAG turns a pile of documents into a structured map of entities and relationships before any question is asked.

Global search vs local search

GraphRAG offers two query modes, and choosing between them is the main decision at query time. Global search is for questions about the whole corpus. It groups community summaries to fit the model’s context window, asks the model to produce a partial answer from each group, then combines those partial answers into a final response. This map-reduce pattern is what lets it answer questions that no single chunk could answer.

Local search is for questions about specific entities. It finds entities related to the query, fans out to their neighbours in the graph, and combines that neighbourhood with relevant community context and, in the open-source implementation, with vector search over text chunks. Local search is the right choice for questions such as “what does this contract say about the renewal clause”, where the answer is tied to particular entities.

Best for: global search suits analysts asking thematic questions across a whole collection; local search suits users looking up facts about a named person, product or clause.

Microsoft GraphRAG vs naive RAG

Aspect Naive vector RAG Microsoft GraphRAG
Index Text chunks with embeddings Knowledge graph plus community summaries, alongside chunks
Best question type Specific fact lookup Broad, whole-corpus questions
Multi-hop reasoning Weak, needs extra retrieval rounds Supported through graph traversal
Indexing cost Low, one embedding pass High, language-model calls over every chunk
Query latency Fast Slower, especially for global search
Explains its answers Chunk citations only Graph paths and community summaries as evidence

The table makes the trade-off plain. GraphRAG is not a faster version of vector RAG; it is a different tool for a different class of question. Teams that adopt it for simple question answering usually find the extra indexing cost buys them nothing, while teams with thematic, exploratory questions find plain RAG unusable. If you are still deciding between retrieval styles, our comparison of knowledge graph RAG and plain vector search sets out the decision in more detail.

When Microsoft GraphRAG is worth it

GraphRAG earns its cost when three conditions hold. First, the corpus is large enough that no one can hold it in mind, typically hundreds or thousands of documents. Second, the questions are open-ended and thematic rather than lookups. Third, the documents are rich in named entities and relationships, such as news archives, research papers, contracts or support tickets, rather than flat lists of facts.

It is a poor fit when the corpus is small, when questions are mostly “find this clause” lookups, or when the data changes every hour, because each change means re-running the extraction pipeline. It is also a poor fit when budget is tight: indexing calls the language model once per chunk for extraction, again for community summaries, and the bill scales with corpus size rather than with the number of questions asked.

Best for: research teams, analysts and knowledge workers exploring large private collections where the questions are not known in advance.

Costs, limits and honest trade-offs

The main cost is indexing. Every chunk passes through the language model at least once, and community summarisation adds more calls on top. For a large corpus, that is a substantial one-off spend, plus the cost of re-indexing when documents change. Incremental indexing can soften this, but it adds engineering work of its own.

Quality is the second limit. The graph is only as good as the extraction step, and extraction errors, such as merged entities that should be separate or relationships stated with the wrong direction, propagate into every answer. A small pilot on a representative slice of the corpus is the cheapest way to find out whether your documents extract cleanly before you index everything.

Latency is the third. Global search runs several model calls per question, so answers take longer than a vector lookup. For interactive chat this can be noticeable, and many teams use global search for analytical questions and local search for everything else. Finally, GraphRAG does not remove hallucination: a summary can still misstate what its community contains, so groundedness checks remain necessary. Our guide to RAG groundedness evaluation explains how to measure that risk.

Getting started checklist

  • Pick a corpus with at least a few hundred documents and genuinely thematic questions.
  • Run a pilot on a small slice first and inspect the extracted entities by hand.
  • Choose a capable extraction model; a weak model produces a noisy graph.
  • Decide which query mode each use case needs, global or local, before building the interface.
  • Budget for indexing tokens as a one-off cost, plus re-indexing when documents change.
  • Set up groundedness checks so summarised answers are verified against source text.
  • Keep vector search alongside the graph; the two indexes complement each other.
  • Measure answer quality on real user questions, not on a demo set you wrote yourself.

Frequently asked questions

Is Microsoft GraphRAG free to use?

The GraphRAG package is open source and published on GitHub, so there is no licence fee for the software itself. You still pay for the language model and embedding calls it makes, and for the infrastructure that hosts the index, which is where most of the real cost sits.

Does GraphRAG replace vector search?

No. GraphRAG adds a graph index alongside vector search rather than replacing it. Local search in the reference implementation combines graph context with vector retrieval, and plain vector search remains the cheaper option for straightforward lookups.

What is the difference between global and local search?

Global search answers questions about the whole corpus by running a map-reduce pass over community summaries. Local search answers questions about specific entities by traversing the graph around them and combining that with retrieved chunks.

How long does indexing take?

It depends on corpus size and the models used, because extraction and summarisation both call a language model. Small collections index in minutes; large ones can take hours, and re-indexing is needed when the underlying documents change materially.

Can GraphRAG work with models other than OpenAI?

Yes. The package is designed to work with different language-model providers, and community setups exist for locally hosted models. The extraction quality you get depends on the model you choose, so the choice matters more here than in plain RAG.

When should I not use GraphRAG?

Skip it when your questions are mostly fact lookups, when the corpus is small, or when documents change so fast that re-indexing would never finish. In those cases a well-tuned vector RAG system will serve you better at a fraction of the cost.

Latest articles

Scroll to Top