Season 3 · Context Engineering · Episode 2

S3E2 RAG

Retrieval-Augmented Generation, demonstrated on you

What this lesson is about

RAG stands for Retrieval-Augmented Generation, and it is how an AI answers questions from documents it was never trained on. You ask something, it searches the files it has been given, pulls out the most relevant passage, and writes its answer using that passage alongside what it already knew. Today you take that process apart from the inside, because the Gem you are about to open is a RAG system and it knows it. The demonstration happens to you, live, rather than being described to you.

What you'll be able to do

A little background

The two halves of the name do the work. Retrieval is the search step: your files are cut into passages called chunks, and the ones closest in meaning to your question get pulled out. Generation is what happens next, when the model writes an answer with those chunks in front of it. Everything interesting about RAG lives in the seam between the two, because a model that retrieves the wrong chunk will still write a confident answer from it.

The Gem's corpus is invented on purpose. Nothing in it exists anywhere else, so if it can quote the document back to you, retrieval demonstrably happened — there is nowhere else the answer could have come from. That is the check that confirms the lesson landed, and it is the same check you can run on any RAG system you meet later.

How would you prove an AI is reading your file, rather than remembering something that sounds like it?

Readings

Where these facts come from

Every source on this page was opened and checked before it went here. Click through and check anything you are about to rely on.

Key words

RAG
Retrieval-Augmented Generation. The AI searches documents you gave it, then answers using what it found.
Chunk
One passage of a document, cut to a size the search step can work with. Retrieval returns chunks, not files.
Knowledge source
A file the AI searches when a question calls for it.
System prompt
Instructions that are always active, every session, never searched for.
Retrieval
The search step. Get this wrong and the model writes a fluent answer from the wrong passage.