← Learning

Graph RAG: Knowledge-Graph-Based Retrieval

A linear, one-concept-per-lesson path through Graph RAG, the knowledge-graph-based retrieval architecture, from extracting entities and relationships by hand to a complete FastAPI service combining networkx graph traversal with ChromaDB hybrid retrieval. 26 lessons · 3 tiers.

Prerequisites: Comfortable writing basic Python. Assumes you've done this site's Naive RAG and Hybrid RAG courses (or otherwise know what dense retrieval, embeddings, and cosine similarity are) - this course builds on that foundation by extracting entities and relationships into a graph instead of retrieving chunks. Distinct from this site's pggraph course, which teaches the Postgres AGE extension and Cypher, not the Graph RAG architecture itself.

Lessons use Google's Gemini free tier (gemini-embedding-001 for embeddings, gemini-3.5-flash-lite for chat), the same models as this site's other RAG courses. No Docker, no database, no extra account - GOOGLE_API_KEY in a .env file is the only setup.

Built on networkx, the graph library this course graduates to in the Advanced tier.

Course source

Every lesson's README and lesson.py for this course live in the ai-agent-engineering repo.

View on GitHub →
Graph RAG: Knowledge-Graph-Based Retrieval

Beginner

Extracting entities and relationships by hand, building an adjacency-dict graph, and traversing it to answer multi-hop questions.

  1. 01What Is Graph RAGGitHub
  2. 02Where Naive Retrieval Fails Multi-HopGitHub
  3. 03Extracting Entities by HandGitHub
  4. 04Extracting Relationships by HandGitHub
  5. 05Building a Graph by HandGitHub
  6. 06Graph Traversal by HandGitHub
  7. 07Answering a Multi-Hop QuestionGitHub
  8. 08End-to-End Graph QAGitHub
  9. 09Checkpoint: Graph Q&A CLIGitHub

Intermediate

Making the graph practical: vector-picked starting nodes, entity normalization, persistence, and citations.

  1. 10Combining Graph and Vector RetrievalGitHub
  2. 11Normalizing Ambiguous EntitiesGitHub
  3. 12Multi-Document GraphsGitHub
  4. 13Persisting the GraphGitHub
  5. 14Limiting Traversal DepthGitHub
  6. 15Prompting for Cited Multi-Hop AnswersGitHub
  7. 16Failure Modes of Graph RetrievalGitHub
  8. 17Minimal Evaluation: Chunk vs. GraphGitHub
  9. 18Checkpoint: Graph Q&A With CitationsGitHub

Advanced

Graduating the graph to networkx, hybrid retrieval with chromadb, and a capstone.

  1. 19Where Hand-Rolled Graphs Break DownGitHub
  2. 20Introducing networkxGitHub
  3. 21Repointing Traversal at networkxGitHub
  4. 22Graph and ChromaDB Hybrid RetrievalGitHub
  5. 23Refactoring Into ingest() and ask()GitHub
  6. 24Wrapping It as a ServiceGitHub
  7. 25Capstone: A Complete Graph RAG ServiceGitHub
  8. 26Where Graph RAG Hits a WallGitHub
Start at Lesson 1

Contact

Book a Call