learning-it by example

Back to the video

GraphRAG Explained With a Tiny Graph in Python

With two sentences, text search had the facts for 1 of 6 questions. A graph written by hand had them for all 6.

Video #46 ยท RAG and vector search

Steps in the video

  1. 0:00 Text search had the facts for one question in six
  2. 0:29 The idea
  3. 1:07 Setup
  4. 1:29 Thirteen sentences, six questions
  5. 1:56 Build the graph and follow it
  6. 2:19 Three ways to find the facts
  7. 3:13 What this does not show
  8. 3:58 Mistakes to avoid
  9. 4:25 My take and next steps
  10. 4:52 Recap

Files

  • compare.py (53 lines)
  • corpus.py (27 lines)
  • graph.py (41 lines)

Download the code (zip)

Tested with

Python 3.12.15 | ollama==0.6.3

What this does not show

Thirteen made-up sentences, six questions and one small model in one seeded run; a toy graph, not Microsoft GraphRAG (no communities or summaries); text search was held to two sentences while the hand-written graph handed over five to eight of the thirteen.

Sources

Learning IT by Example.