Search and Retrieval, lesson 13
Knowledge graphs and GraphRAG
Store the links between facts, and know when a graph beats vectors.
"Vector search" and "Combining keyword and vector search": finding the passages that look most like a question. "Why grounded answers still go wrong": answers that need two passages at once. This lesson stores the links between facts, so a question can follow them.
Part 1. Answers that sit between passages
An e-bike maker keeps its supplier notes in the same search system as its handbook. Nine of them are below, one sentence each. A buyer hears that Norfield Metals may shut its plants, and asks: "Which products depend on Norfield Metals?"
Example 1.1
Nine notes, and what search returns
- n1Norfield Metals supplies our aluminium frames.n2Brake discs come from Norfield Metals, under a contract renewed in 2025.n3Norfield Metals has two plants, both in Poland.n4Kestrel Cells makes the battery packs.n5Volta Circuits builds the motor controllers.
The notes about suppliers. Each one says who makes which part.
- n6The Trail e-bike uses the aluminium frame.n7The Trail e-bike and the City scooter are both fitted with brake discs.n8Battery packs go into the Trail e-bike and the City scooter.n9The motor controller is fitted to the City scooter.
The notes about products, written by another team. None of them names a supplier.
- Which products depend on Norfield Metals?BM25 top 3→n1 2.44n3 2.17n2 1.79
BM25 as in "Keyword search with TF-IDF and BM25" (k1 = 1.5, b = 0.75, punctuation stripped). Only the three notes with "Norfield" and "Metals" score at all, and the short note about Poland beats the one about brake discs.
- products named inn6n7n8n9shared words with the question: 0
No note that names a product shares a word with the question. An embedding search orders things differently, but those notes are about bikes and scooters, not Norfield, so they sit far from the question too.
Your turn
The model gets n1, n3 and n2, plus the question. What's the best answer it can honestly give?
"Why grounded answers still go wrong" split a two-topic question into two searches. That needs both topics up front, and here you only learn to search for "brake discs" after reading the first results. A model can search, read and search again, paying extra calls on every question. Or you can record the links once, while indexing, and follow them for almost nothing later.
Multi-hop question
A question whose answer joins facts from two or more passages, where each fact leads to the next. Each step along a link is a hop. "Which products depend on Norfield Metals?" takes two: supplier to part, then part to product.
Chains are one of three kinds of question that top-k search handles badly. The second is about the whole collection: "What are the most common reasons for late deliveries?", asked of 20,000 notes, has an answer spread across all of them. The third is counting. "How many of our suppliers have plants in Poland?" needs every matching note, search hands over at most k, and nothing tells the model how many it missed.
Your turn
The supplier notes grow to 20,000. Which question can top-5 search still answer well?
Part 2. Facts as triples
Keep going with Pro
You've done the first part. Pro opens the rest of this lesson, and every other one.
- Facts as triples
- Walking the graph
- GraphRAG, and when a graph is worth it
Search and Retrieval overviewSpotted a mistake? Tell us.