GraphRAG
GraphRAG retrieves the context an LLM needs by traversing a knowledge graph, not only by matching embeddings. Vector search finds the entities a question is about, and graph traversal follows their relationships to the facts connected to them.
The retrieved context is added to the user’s question before it goes to the LLM. In this example, a question about a patient’s symptoms is enriched with the related medical records and treatments from the knowledge graph:

In Memgraph, a whole retrieval runs as one Cypher query: search, expansion, ranking and prompt assembly happen inside the database. This is Atomic GraphRAG.
Retrieval pipelines
Which pipeline to use depends on the type of question:
| Question type | Where the answer is | Pipeline | Example question |
|---|---|---|---|
| Analytical | A value in the graph | Text2Cypher | “How many organizations of each type are covered?” |
| Local | Around one entity | Local graph search | “What is connected to NVIDIA?” |
| Global | Across the whole dataset | Query-focused summarization | “What are the main themes overall?” |
The diagram shows the steps of each pipeline, from the question type to the context passed to the LLM:

To let an agent choose the pipeline for each question, see Agentic GraphRAG.
Run the example
The command starts Memgraph and the Memgraph MCP server in Docker, loads a knowledge graph of finance news and runs all three pipelines on it. You need Docker and git, and no API key.
curl -sSL https://install.memgraph.com/agentic-graphrag | bashAgentic GraphRAG explains each step and how to connect an agent to the graph.
Build your own
Before you start, check the prerequisites: a running Memgraph with MAGE, your data and an LLM API key. Then:
- Model your domain as a graph. See Data modeling and Model a knowledge graph.
- Load your data into Memgraph. See Knowledge graph creation.
- Create a vector index, a text index or both, so a query can find the entities a question is about.
- Write the retrieval as a Cypher query, starting from the pipeline that fits your questions. See Atomic GraphRAG.
- Connect your LLM or agent through the Memgraph MCP server or a framework such as LangChain or LlamaIndex.
- Before you go to production, size and configure Memgraph for the workload. See Memgraph in GraphRAG use cases.
To use a framework that builds the knowledge graph and runs retrieval for you, see LightRAG, which stores its graph in Memgraph. For every package you can build with, see AI Toolkit and integrations.
Examples
- GraphRAG notebook: Builds a knowledge graph, computes embeddings and implements several retrieval strategies, step by step.
- Agentic GraphRAG app: An agent that chooses a retrieval strategy for each question and runs vector search, deep path traversals, community detection and PageRank.
- GenAI stack: An application template with Memgraph, LangChain and GPT or Llama.
Case studies
These Memgraph users describe how they use GraphRAG and knowledge graphs:
- Precina Health uses GraphRAG on patient data for type 2 diabetes care.
- Cedars-Sinai uses a knowledge graph and retrieval-augmented generation in Alzheimer’s research.