GraphRAG
Graph RAG · Graph retrieval-augmented generation
Retrieval-augmented generation over an extracted knowledge graph, using clustered communities and their summaries to answer questions about a whole corpus.
In DocSlurpIllustrated explainer
On this page
The problem: questions about everything
Most RAG questions are local: “Are we on track to beat our FY2027 earnings?” has an answer on one page, and top-k retrieval finds it. Now ask “What is driving our growth heading into FY2027?” No page answers that. The answer is a synthesis: revenue ahead of plan in the growth plan, a new market in the London launch review, an acquisition in the deal room guide.
Top-k retrieval fails here in a predictable way. It returns the five chunks most similar to the question, which tend to be five chunks that use the word “growth”, often from one document. The model writes a confident answer about that one corner and never sees the rest. Raising k doesn’t fix it: the corpus might be ten thousand pages, and you can’t paste them all into a context window.
The idea: summarize topics in advance, then ask every topic
GraphRAG, introduced by Edge et al. at Microsoft Research in 2024, splits the work into an indexing phase and a query phase.
At ingest:
- Extract a knowledge graph. A model reads every chunk and returns entities and relationships.
- Detect communities. Community detection splits the graph into groups of densely connected entities. The paper uses Leiden, applied recursively to get a hierarchy from small, specific communities to large, broad ones.
- Summarize each community. A model writes a report per community from its entities, relationships and source claims.
At query time, for a global question, it runs map-reduce over those reports:
- Map. Each community summary (or batch of summaries) is given the question and produces a partial answer plus a helpfulness score from 0 to 100. Answers scoring 0 are dropped.
- Reduce. The remaining partial answers are sorted by score, packed into the context in that order until it is full, and a final call writes one answer.
The figure walks through it with three communities. The earnings community says revenue runs 12% ahead of plan with 4 points of margin headroom (score 85). The London community says the new office adds a forecast $6.5M in first-year bookings (70). The deals community says Larkspur Studio adds design depth from Q1 2027 (60). The reduce step lists all three, earnings first. Every topic was consulted, which top-k retrieval can’t promise.
Why communities, and not just chunks
You could map over every chunk instead. That works on a small corpus and is ruinous on a large one: thousands of calls per question. Communities compress. A few hundred summaries can cover a corpus of tens of thousands of chunks, and because they are written at ingest, the cost is paid once rather than per question.
Communities also give the summaries a natural grain. Each covers one cluster of related entities, so its summary is about one topic, which is exactly the unit a “main themes” question wants. The hierarchy lets you choose the grain per question: root-level communities for “what is this corpus about?”, lower levels for more detail at more cost.
Local search is the other half
Microsoft’s implementation also has a local search mode for questions about specific entities: find the entities the question mentions, then gather their neighbors, relationships, community reports and source chunks into one context. That is close to graph expansion plus extra context, and it is what you want for “What does Larkspur Studio bring?”
Where it breaks
- Indexing is expensive. Every chunk is read by an extraction model, and every community gets a summary. On a large corpus that is a lot of model calls before the first query, and it must be partly redone as documents change.
- Summaries lose detail. A community report is a summary of a graph extracted from a summary-like reading of the text. Numbers, exceptions and exact wording often don’t survive. Global answers are good at themes and bad at specifics, and their citations point at summaries rather than pages unless the system carries source links through.
- Global search is slow and costly per query. Map calls scale with the number of communities consulted. It is the wrong tool for the local questions that make up most traffic.
- Extraction quality caps everything. A merge error or missed relationship changes the communities, and the communities shape every global answer.
- Evaluation is hard. “Main themes” has no single right answer. The paper judged comprehensiveness and diversity with an LLM, comparing against baselines head to head, rather than scoring against labels.
When to reach for it
Use GraphRAG’s global mode when users ask for overviews, themes or comparisons across a large corpus and accept a slower, more expensive answer. Keep ordinary hybrid retrieval for everything else, and route between them.
In DocSlurp
DocSlurp implements the indexing half and a lighter query half. With GraphRAG enabled on a project, the graph-enrich stage extracts each document’s graph and then re-clusters the whole project (core/worker/src/stages/graph-enrich.ts). Communities come from two-level weighted label propagation, not Leiden, and when a model is available, up to 200 new communities per refresh get model-written summaries; the rest get a templated list of their main entities and relations, and unchanged communities keep theirs (core/worker/src/graph/communities.ts).
At query time, community summaries are matched to the question by full-text search and join the other candidate lists before fusion, so a summary competes with passages rather than being consulted in a map step. When a search is filtered to particular documents, each summary is prefixed with a warning that it describes the wider project and is not evidence from the selected documents (core/server/src/search/community-context.ts). There is no global map-reduce mode.
In DocSlurp
In DocSlurp
DocSlurp builds the graph and community summaries at ingest when enabled (core/worker/src/stages/graph-enrich.ts, core/worker/src/graph/communities.ts). At query time, summaries are found by full-text match and fused with other candidates, labeled as broader context (core/server/src/search/community-context.ts). There is no global map-reduce query mode.