Modern AI Engineering

Lesson 10.12 · 27 min · video lesson

GraphRAG: Combining Knowledge Graphs with Retrieval

Ask a normal RAG bot "What are the main themes across all 5,000 of our incident reports?" and it will summarise five random chunks. How could it ever see the whole picture?

In short: GraphRAG uses an LLM to read every chunk of a corpus and extract entities and relationships into a knowledge graph, groups the graph into communities of closely connected entities, and writes a summary for each community. At question time, local search starts from the entities a question mentions and gathers their neighbourhood, while global search combines community summaries to answer questions about the whole dataset. It answers connection and big-picture questions that chunk retrieval cannot, at a much higher indexing cost.

What you will learn

  • What is GraphRAG?
  • Why normal RAG is not enough
  • The big picture of GraphRAG
  • How GraphRAG builds the knowledge graph
  • How GraphRAG answers a question
  • Local search vs Global search
  • When to use GraphRAG
  • Trade-offs of GraphRAG
  • Quick Summary

In this lesson

  1. What is GraphRAG?
  2. Why normal RAG is not enough
  3. The big picture of GraphRAG
  4. How GraphRAG builds the knowledge graph
  5. How GraphRAG answers a question: local vs global search
  6. When to use GraphRAG
  7. Trade-offs of GraphRAG
  8. Worked example, step by step
  9. Practice: try it yourself
  10. Quick summary

Key terms in this lesson

Knowledge graph
A network of entities (nodes) linked by typed relationships (edges).
Entity extraction
Using a model to find people, systems, places and other things, plus their relations, in text.
Community
A group of graph nodes more densely linked to each other than to the rest of the graph.
Community report
An LLM-written summary of the entities, relationships and key facts in one community.
Local search
Answering by expanding from entities mentioned in the question through their graph neighbourhood.
Global search
Answering by map-reducing community reports so the whole dataset contributes.
Leiden algorithm
A community-detection algorithm used by Microsoft GraphRAG to find hierarchical communities.

This lesson is part of the Generative AI Engineering and Complete AI Engineer tracks. See plans and pricing to open the full lesson, its video, labs and quiz, or try the free lesson first (free account needed).

← 10.11 Agentic RAG: Dynamic Retrieval with Multi-Step Reasoning · 10.13 Vectorless RAG: Retrieval Without Embeddings or a Vector Store →