The Problem: The Answer Is in No Single Document
RAG (retrieval-augmented generation, whose principle is set out in RAG: principle and architecture) looks for the passages that resemble the question, then has the language model (large language model, shortened to LLM) read them.
That assumes the answer exists somewhere, written out in a passage. Take a question where it does not: "Who are the suppliers of the companies that ran into legal trouble in 2024?"
- One document discusses company X and its litigation.
- Another, unrelated document lists company X's suppliers.
- No document brings the two together.
Retrieval by resemblance cannot produce that answer, and not because it is badly tuned: it returns passages, and the passage that would be needed does not exist. Two facts that never met in the corpus have to be assembled. This is what is called a multi-hop question: you must go from the company to its legal trouble, then from the company to its suppliers.
The idea of Graph RAG is to build, in advance, a structure in which those links are written out explicitly, and then to walk it.
You extract from the documents a list of links of the form "A supplies B", "C works at D", and store them in a graph database. Searching then becomes: find the starting points named in the question, then follow the links outward.
A graph database is one whose unit of storage is not a table row but the pair of connected items: it is built to answer quickly the question of what is connected to what, and by what kind of link.

How It Works
Step 1: Build the Graph, Once
This is by far the expensive part, and it is important to see that it happens before any question is asked. For every piece of every document:
- A model reads the text and extracts the entities: people, companies, places, concepts, dates.
- The same model names the links between those entities: "X supplies Y", "Z works at W".
- Entities and links are written into a graph database, in practice Neo4j, or the NetworkX library for small volumes.
Company A β supplies β Company B β named in β 2024 litigation
One point deserves emphasis, because the reliability of the whole edifice rests on it: a language model decides what counts as an entity and what counts as a link. The graph is not an objective survey of the corpus, it is the output of an automated reading, with that reading's omissions and mistakes. If the model misses a link during extraction, no question will recover it afterwards, the edge does not exist. Conversely, if it invents a link, that link now has the appearance of a structured fact, which is more misleading than an ambiguous sentence in a text.

Step 2: Answer a Question
Here is what actually happens, step by step, when someone asks for the suppliers of companies that had legal trouble:
- The entities in the question are identified and matched to nodes in the graph.
- The system follows the edges out from those nodes: from the company to its litigation, from the company to its suppliers.
- The nodes and links met along the way are collected.
- All of that is turned into text, and that text becomes the context handed to the model, in place of the passages an ordinary RAG would have returned.
- The model writes the answer from that context.
You often read that Graph RAG lets the system reason over relationships. It is worth bringing this back to what occurs, because no new reasoning is at work.
There are three operations, and only three. One, at indexing time, a model wrote a list of links, that is text generation, with the failure modes of text generation. Two, at question time, a program walks edges, or else a model writes a query that the database executes: either way this is database work, exact and unintelligent. Three, a model writes the answer from what was collected.
Multi-hop reasoning is therefore, materially, an edge traversal in a database. What the graph contributes is not a capacity to deduce; it is the fact that the link is written down explicitly instead of having to be guessed from a textual resemblance.
Microsoft's Approach: Community Summaries
The implementation published by Microsoft adds an idea that answers a practical problem: a graph built over a real corpus has far too many nodes to walk them all for every question.
From Local to Global: A Graph RAG Approach to Query-Focused Summarization (Edge et al., 2024)Community detection. In a graph, some groups of nodes are far more connected to one another than to the rest. A community detection algorithm finds those groups automatically, without knowing what they are about: it looks only at the density of links. Microsoft uses the Leiden algorithm in its hierarchical variant, which yields nested communities, large groups split into subgroups, like parts split into chapters.
Each community then gets a summary written by the model, prepared in advance, once and for all. This amounts to automatically writing the table of contents and a chapter summary for a corpus that had neither.
From there, two ways to search:
- Local search, for a targeted question, what do we know about company X? You start from the node concerned and explore its immediate neighbourhood.
- Global search, for a question of synthesis, what are the major themes in this corpus? The graph is not walked at all: the already-written community summaries are read, the model answers against each of them, and those partial answers are then aggregated into one overall answer.

This claim repays a close reading, because it is narrower than what is usually taken from it.
The paper compares Graph RAG with a conventional vector RAG baseline on a specific category of question: those that require forming an overall picture of a whole corpus (the authors speak of global sensemaking) over datasets in the region of a million tokens. On those questions it reports substantial improvement on two named criteria: the comprehensiveness of the answer and its diversity, meaning the number of angles covered.
So the finding is not that Graph RAG answers better across the board. It is that on questions of global synthesis, the answer covers more ground. The result says nothing about targeted factual questions, where a vector RAG has no reason to be beaten, the answer sits in a passage, and the passage is enough.
The intuition is straightforward: a vector RAG returns a handful of passages close to the question, which can never stand in for an entire corpus. The community summaries, by contrast, have seen the whole corpus go by.
The Special Case: Having the Model Write the Query
There is a second way to interrogate a graph, distinct from walking edges: ask the model to write the query that the database will execute. For Neo4j that query is written in Cypher, the graph query language, the graph equivalent of SQL (Structured Query Language) for table-based databases.
The mechanism, in three beats: the model receives the question in plain language plus a description of the graph's structure, and produces text that is a Cypher query; the database executes that query and returns exact results; the model then writes the answer from those results.
With the LangChain library it looks like this:
from langchain_neo4j import Neo4jGraph, GraphCypherQAChain
graph = Neo4jGraph(
url="bolt://localhost:7687",
username="neo4j",
password="...",
)
chain = GraphCypherQAChain.from_llm(
llm=llm, # the model that will write the Cypher query
graph=graph,
# Without this flag the library REFUSES to start:
# it requires you to acknowledge that you are executing
# queries written by a model.
allow_dangerous_requests=True,
)
result = chain.invoke("Suppliers linked to sanctioned companies?")
That allow_dangerous_requests parameter is not decorative: the library raises an error and stops if you do not pass it explicitly. Its message advises narrowing the permissions of the account used by the connection to the strict minimum.
The reason is mechanical. What gets executed against the database is text produced by a language model. Two consequences follow.
First, that text can be influenced by everything the model has read, including the contents of the indexed documents. An instruction concealed in a document becomes a way of steering the query that gets issued: this is indirect prompt injection, described in tool use and orchestration.
Second, the only solid guarantee lies not in the instruction given to the model but in the permissions of the database account. A read-only account, restricted to the necessary data, bounds the damage whatever the model writes. An instruction of the form "never write a delete query" is not a guarantee, it is a wish.
The class names and import paths of these libraries change often, the old langchain_community.graphs path has been superseded by the langchain-neo4j package. What stays true is the mechanism: a model writes a query, a database executes it.
The Real Cost
The cost of Graph RAG is not where you expect it. It is not in answering questions, it is in building the graph, and it should be worked out before committing.
Let us do the arithmetic without inventing figures. Extraction requires passing every piece of every document to the model, at least once. The number of model calls at indexing time is therefore:
where is the number of pieces the documents were split into (see Chunking strategies) and the number of groups detected in the graph, each receiving a summary.
Three consequences, and they are the only things worth remembering:
- Cost grows in proportion to corpus size. Ten times the documents, ten times the calls. Compare this with a vector RAG, whose indexing requires no generative model calls at all: computing a vector representation is incomparably cheaper than having a text written.
- The amount depends entirely on the price of the model used, which varies between providers and falls year on year. That is why this page quotes no price: do the arithmetic with today's rate and the real size of your corpus.
- This cost is paid more than once. Every change to the corpus means extracting the new links and recomputing the communities and their summaries, a single new document can redraw the groups.
Documents change, entities appear, links shift. Without an update procedure the graph drifts silently out of step with the corpus: it goes on answering, confidently, from a stale picture.
This is the nastiest failure mode, because it produces no visible error, just out-of-date answers wearing the appearance of grounded ones.
When to Use It
Graph RAG earns its place if the questions require traversing several relationships to resolve; if you need syntheses covering the whole corpus; or if the domain is relational by nature, regulatory compliance, audit, supply chains, ownership structures. What these cases share is that the links between entities are the very object of the question.
A conventional vector RAG is enough if the questions are factual and targeted ("what is the refund policy?"); if the corpus holds no network of entities worth walking; or if the indexing budget is tight.
In practice you keep both arrangements and choose per question: factual questions to vector search, fast and cheap; relational or synthesis questions to the graph. That routing is precisely the subject of agentic RAG.
The price is that you now maintain two indexes instead of one, and that the router itself can be wrong.
One last remark, and it is the most important for judging an arrangement of this kind: the quality of a Graph RAG is capped by the quality of the extraction. Everything is built on the list of links a model produced at indexing time. A graph from a mediocre extraction yields mediocre answers wearing an appearance of rigour, since they rest on an explicit structure. Before comparing architectures, then, the question to ask is: have the extracted links been checked, and against what sample?
1. Why can a vector RAG not answer the question about suppliers of companies that had legal trouble in 2024?
2. What actually happens when people say a Graph RAG system reasons over relationships?
3. At indexing time, the extraction model misses a link that is present in a document. What is the consequence?
4. What exactly does Microsoft's Graph RAG paper (Edge et al., 2024) demonstrate?
5. When a model writes the Cypher queries that are executed on the graph database, what is the only solid guarantee against damage?