Log inStart free
LESSON 22.16 · 6 STAGES · 2 CONTROLS · 3 CHECKSPRO · PREVIEW

Graph RAG

Watch a knowledge graph follow a chain of facts that vector search misses.


Pro lesson. Stage 1 is free to watch. Pro opens all 6 stages, 2 controls and 3 checks, in this lesson and every other.

Go Pro · $8.25/mo
EXPLAINER · 22.16 · GRAPH RAG BAYTOP 3 HOLDS 1 OF 3 NEEDED FACTS
01
Stage 1 of 6 · Vector search
Vector search keeps the 3 text chunks closest to the question. They hold 1 of the 3 facts the answer needs.
Explain it simply

Each chunk on the left gets a score: how strongly it shares the question's words, with rare words counting more. The 3 highest scores, outlined, go to the model as its context. The chain on the right shows the facts the answer needs. Only one of them made the top 3, so the chain breaks.

Twelve chunks with scores. The top 3 are chunks 3, 9, 6. They hold 1 of the 3 facts the answer needs.

chunks, entities, facts in contexthopsscores, path, answermissing fact
vector searchquestion:WhereisthemakerofthechipintheVeladronebased?1Arden Labs makes the Kestrel chip.0.1662Arden Labs is based in Porto.0.2313The Kestrel chip powers the Vela drone.0.6624Mira Okafor founded Arden Labs.0.0005Brightwell makes the Osprey chip.0.1846Brightwell is based in Leeds.0.2647The Osprey chip powers the Juno robot.0.1588Mira Okafor studied in Leeds.0.0009Brightwell tests the Vela drone.0.53310Tessa Market sells the Juno robot.0.00011Tessa Market is based in Lyon.0.20812Porto hosts the Delta Fair.0.0001. The Kestrel chip powers the Vela drone.in the top 3 · rank 12. Arden Labs makes the Kestrel chip.missing · rank 73. Arden Labs is based in Porto.missing · rank 4facts the answer needstop 3: the chain stops at Kestrel chip (1 of 3)vector searchquestion:WhereisthemakerofthechipintheVeladronebased?1Arden Labs makes the Kestrel chip.0.1662Arden Labs is based in Porto.0.2313The Kestrel chip powers the Vela drone.0.6624Mira Okafor founded Arden Labs.0.0005Brightwell makes the Osprey chip.0.1846Brightwell is based in Leeds.0.2647The Osprey chip powers the Juno robot.0.1588Mira Okafor studied in Leeds.0.0009Brightwell tests the Vela drone.0.53310Tessa Market sells the Juno robot.0.00011Tessa Market is based in Lyon.0.20812Porto hosts the Delta Fair.0.0001. The Kestrel chip powers the Vela drone.in the top 3 · rank 12. Arden Labs makes the Kestrel chip.missing · rank 73. Arden Labs is based in Porto.missing · rank 4facts the answer needstop 3: the chain stops at Kestrel chip (1 of 3)
Toy: 12 one-sentence chunks, TF-IDF word vectors, a pattern extractor
STAGE 1 / 6
MATH · STAGE 1HOVER A SYMBOL OR A SHAPE
s(c)=cos⁡(q,c)=q⋅c∥q∥ ∥c∥\sy{sc}{out}{s}(c) = \cos(\sy{q}{data}{q}, \sy{c}{data}{c}) = \frac{q \cdot c}{\lVert q \rVert \, \lVert c \rVert}
s(c3)=0.662s(c_{3}) = 0.662

The score is the cosine of the question and chunk word vectors.

Common mix-ups

MYTHVector search finds every fact the answer needs.

The fix, and 1 more mix-up with the diagram to show them, come with Pro.

Predict, then reveal
3 CHECKS · PRO
Q01With 2 hops, can the graph answer the three-hop question?

Make your guess, then test it in the diagram. All 3 checks come with Pro.

PRO LESSON · YOU WATCHED STAGE 1 OF 6
Unlock the full explainer
  • 5 more stages and 2 live controls
  • 2 mix-up cards and 3 predict-then-reveal checks
  • Watch it as a narrated video, in three voices
  • Every Pro lesson and capstone · 656 in total

$99 a year, or $15 a month. Cancel any time.