Context trick
Look it up, then ask
The model’s training is a frozen cookbook. Your live menu is not in there. RAG means: find a few pages, paste them into the script, then pack · read · pick as usual.
- 1 · FindSearch the library. Keep two or three pages, not the shelf.
- 2 · PasteDrop those pages into the user (or system) bubble.
- 3 · PickSame call as lesson 0003. The model now “read” the pages.
Find · paste · pick. If the answer already fits in the script, skip the library.
Why a library at all?
Lewis et al. split memory in two: facts baked into the weights, and a pile of documents you can look up and swap when the world changes. That lookup-plus-generate recipe is what they named RAG. Retrieval-Augmented Generation (2020)
Anthropic’s one-line version of how people use it today: retrieve the relevant bits, append them to the prompt. The knowledge base can be huge; the window stays small. Contextual Retrieval
Karpathy’s picture: window = RAM, files = disk. RAG is paging a few files into RAM — not buying a bigger brain.
The pizza kitchen
Example · without RAG
What this shows. The waiter (the model) is reciting a cookbook printed last year. Your actual allergen sheet never got into the weights.
Example · with RAG
“Walnut pizza: walnut crumb. Contains tree nuts. Not safe for nut allergy.”
Question: Is the walnut pizza safe for nut allergies?
What this shows. Same pack · read · pick. The new move is the paste. You can point at the note later — that is provenance. Lewis et al. cared about being able to update the pile without retraining.
Skill: paste two pages, not the shelf
Type a question. This toy library lights up at most two cards (word overlap, not magic). Those are what you would paste.
Kitchen shelf
Walnut pizza: walnut crumb. Contains tree nuts. Not safe for nut allergy.
Kitchen opening hours: Tuesday to Sunday, 17:00–22:00. Closed Monday.
Margherita 14. Walnut pizza 18. Garlic bread 6.
House red 7 a glass. No walnut in the wine list.
Friday: Sam on dough, Riley on pass. Nothing about toppings.
Delivery radius 3 km. Cash or card. Allergen sheet is in the kitchen binder, not here.
Pasted into the script:
Do look up
Private docs, prices, policies, anything that changes. The shelf is bigger than RAM.
Skip the shelf
The fact is already in the script, or it is “2+2”. Extra pages are hay (lesson 0002’s U-curve).
A later trick (not this lesson) is embeddings: “near in meaning,” not just matching words. Anthropic also warns agents not to preload everything — sometimes you keep a pointer and fetch just in time. Same idea: spend RAM on the page you need. Effective context engineering
Check
Primary source. Read the first page of Lewis et al. — parametric vs lookup memory — arxiv.org/abs/2005.11401. Then Anthropic’s opening of Contextual Retrieval (retrieve, append to the prompt). Skip BM25 and rerankers for now.
Card: find · paste · pick.