The same chunks, with and without their heading path
Shared words stand in for a real ranker. A real embedding model is smoother, but it improves in the same direction, as the lab below shows.
A chunk cut from its page can say It costs 25 dollars without saying what costs it. Prepending the document title and heading path before embedding fixes that, while the model can be shown a tidier version of the same chunk.
Change the code and press Run (Ctrl+Enter). Predict what will happen first, then break it on purpose and read what changes. Your edits are saved and match the lesson page.
Ready for more? This phase has 6 hands-on exercises with automatic checks.
Practice questions
Write the code in the editor, run it, then open the model answer to compare.
Write embedded_text(path, text) returning path: text, and display_text(source, path, text) returning [source] last heading - text. Print both for plans.md, Plans > Day pass, It costs 12 dollars..
Write with_neighbours(chunks, i, window) and print the result for the list ["a", "b", "c", "d", "e"] with i = 0 and window = 1, then i = 2, window = 1.
Explain it without notes
Why can a perfectly good chunk be impossible to retrieve, and how does a heading path help?
Explain the difference between embedded text and display text, and why you store both.
What is neighbour expansion and what does it cost?
Why should the context prefix be short?
Expected output
How much is the monthly pass?
Plans > Single ride text only 0 with its path 0
Plans > Day pass text only 0 with its path 1
Plans > Monthly pass text only 0 with its path 2
What does a single ride cost?
Plans > Single ride text only 0 with its path 2
Plans > Day pass text only 0 with its path 0
Plans > Monthly pass text only 0 with its path 0
embed: Plans > Monthly pass: It costs 25 dollars and includes unlimited rides of up to 45 minutes.
show: [plans.md] Monthly pass - It costs 25 dollars and includes unlimited rides of up to 45 minutes.