AI for Beginners · Lesson 12

RAG

Training is frozen, and it never saw your own documents in the first place. This lesson names the standard fix — three ideas you already have, wired together — and shows the acronym you'll see on almost every "chat with your data" product: RAG.

CourseAI for Beginners
Lesson12 of 14
Builds onAgents
The gap training can't close

Two things training will never cover

Lesson 7 named the knowledge cutoff: training is finished and frozen before the model ever reaches you, so anything after that point genuinely was never shown to it. There's a second gap, just as real — anything that was never public in the first place. Your company's own documents, a private wiki, last week's meeting notes. No amount of training could have included them, because they were never there to read.

Neither gap can be closed by retraining. But both can be closed a completely different way: instead of teaching the model in advance, hand it the answer at the moment it's needed.

Three words you already have

RAG

You already have every piece of this. Retrieval is Lesson 5's nearest-neighbor search — finding the right chunk of text by distance, not by matching exact words. Augmented means added to — specifically, poured into context, Lesson 8's word for background handed to the model right before it answers. Generation is what a model has done since Lesson 1: read what's in front of it, and predict. Put the three together and you get the term behind nearly every "chat with your own documents" product: RAG, for Retrieval-Augmented Generation.

The RAG pipeline: question, search, add to context, answer Four boxes left to right: your question, search your documents by nearest neighbor, add the matches to context, the model answers. Each arrow is labelled with the lesson concept it reuses. THE CLASSIC PATTERN Your question Search your documents nearest neighbor, Lesson 5 Add matches to context the pour, Lesson 8 Model answers same loop, Lesson 1
Nothing new is happening in any single box — this is three ideas the course already built, wired together in one order.

Under the hood: your question gets its own embedding, that embedding finds the nearest chunks in a pile of your documents, and those chunks — not the whole archive, just the closest handful — get pasted into the prompt alongside your actual question. The model never "reads your wiki." It reads whatever got handed to it this one time, exactly like every other pour since Lesson 1.

Not magic — still the same model

Retrieval can still get it wrong

RAG fixes what the model was never shown. It doesn't fix Lesson 7. If the search step hands back the wrong chunk — or nothing genuinely relevant exists in the documents at all — the model still answers fluently and confidently from whatever it was given. That's not a new failure. It's the same stray pick, just now leaning on your documents instead of the open internet.

Garbage in, garbage out, applies here exactly as it always has. A good retrieval step narrows what the model can lean on. It doesn't guarantee the lean is correct.

There's a second limit underneath that one, and it isn't a mistake — it's the shape of the tool itself. Nearest-neighbor search only ever finds one kind of connection: things that read alike. It has no way to notice a cause, a sequence, or a hierarchy between two facts that happen to share almost no words — a decision in one document and its consequence three documents later, a rule and the exception buried somewhere else entirely. No lexical overlap means no path for a similarity search to walk, even when the connection is real and important.

That's a structural gap, not a bug waiting to be patched. See orqo's knowledge graph for what the alternative looks like: typed relationships — causal, hierarchical, temporal, and more — that a system can actually follow, instead of hoping two related things happen to sound the same.

Doing this more than once

Retrieval can be a tool, not just a first step

The pattern above searches once, before the model ever starts. But you already know a model can ask for a tool — Lesson 9 — and that it can keep asking, deciding for itself what to do next — Lesson 11. Nothing stops "search the documents" from being one more tool in that loop.

That's what people mean by agentic RAG: instead of one search handed over up front, the agent decides when to search, what to search for, and whether the first batch of matches was actually good enough to answer with — searching again, with a better question, if it wasn't. Same three ingredients. Just folded into the loop instead of run once before it.

The thing behind "chat with your data"

This is the default, almost everywhere

RAG is genuinely the standard answer across the industry to "how does an AI know about our own stuff" — chunk the documents, embed them, search by similarity, hand the model what's close. Lesson 5 already showed you the mechanism, before this lesson ever gave the pattern its own name.

It's worth knowing you're looking at the industry default, not the only option — the section above already pointed at what a structural alternative actually looks like.

Next

One last question, now that it can act and remember

An agent that can act, and an agent that can retrieve whatever it needs from your own documents — both raise the same question, one more time, in a sharper form: what actually happens to everything that passes through it?

The whole picture, continued

The glossary, 2 rows longer

Everything from the lessons before this one, plus what this lesson added.

The board The word for it
The board and its pegsThe structure — the model
A single pegA neuron
A single step from one peg to the nextA connection
How red or blue a patch of floor isA weight — a parameter
The whole painted floorThe trained model
Boards stacked, one on the nextLayers — "deep"
Smearing the floor in, coin by coinTraining
Dropping one coin through a finished boardUsing it — inference
Which slot you pour intoYour input — your prompt
The bins, relabelled with tokensThe vocabulary — every token it could pick
The tallest pile among the binsThe prediction — the likeliest next token
Feeding the growing line back in and running againThe loop — how one guess becomes a sentence
One bin's label, preciselyA token — not always a whole word
How many bins there are, in totalVocabulary size — tens of thousands
The size of the mountain of text it was shownTraining data — measured in tokens
A bin's own address, plotted in spaceAn embedding — meaning turned into a list of numbers
How close two addresses sitSimilarity — how related two things are
The measurement's real name, out in the wildCosine similarity — same idea as similarity, different name
About meaning, not exact spellingSemantic
A neighbourhood of addresses that share a topicA domain — a cluster of related meaning
Scanning every address for whichever one sits closest to a new pointNearest neighbor — the closest real match to a computed point
A small, separate machine that only plots words as points — it never writes a sentenceAn embedding model — not the same as a language model
The total number of coloured patches, across every boardParameters — the number people quote
How many tokens the funnel can hold in one pourInput tokens — the context window
How many tokens come back outOutput tokens — what it writes back
Everything you've met so far, built at real-world sizeA Large Language Model — an LLM
A shorter pile winning, extended forward with full confidenceA hallucination
The point where the training reading stoppedThe knowledge cutoff
How sharp or blended the colour stays before a coin is pouredTemperature — the dial on how often a stray pick wins
Pouring the same slot twice, not always the same pileNon-deterministic — same input, no guaranteed identical output
Background, examples, or a role, added right into the pourContext
Asking for many small steps instead of one big leapChain-of-thought prompting
A friendly chat window built around the boardA product — like ChatGPT or Claude.ai
A door that lets software pour in and read out directlyAn API
What each million tokens costs to send in or get backAPI pricing — pricier for bigger models, and for output
Recalling the start of the line instead of re-pouring itCached tokens — priced far cheaper than fresh input
The board asking the app to go do something real before it answersTool use — or function calling
One shared shape for listing tools and calling themMCP — Model Context Protocol
A program that speaks that shape and hands back its whole toolboxAn MCP server
The loop deciding, acting, and watching what happened, on repeatAn agent — a model with tools, looping until the goal is met
Deciding its own steps, and knowing when it's doneAutonomy
Reading what just happened before deciding what's nextReactivity
Starting on its own, from a schedule or an eventPro-activeness
Talking to other agents, and to people, not just toolsSocial ability
+ New in this lesson
Search first, hand the model what you found, then let it answerRAG — Retrieval-Augmented Generation
Folding the search step into the loop, so it can search again if neededAgentic RAG

46 rows now. It keeps growing as the course goes on.

Lesson 12 of 14

Sign in to orqo

Choose how you'd like to continue.

More ways to sign in are on the way.