Vibe Coder · Unit 17: RAG and Your Data · Lesson 1 of 6
What RAG is
A model does not know your documents. Retrieval-augmented generation finds the right passages first and gives them to the model, so answers come from your material, with sources.
Read the short notes and pictures.Do everything inside a blue frame.
The gap
A language model knows what was in its training data and what is in the conversation. Your help articles, your pricing rules and last week’s policy change are in neither. Ask anyway and it will produce a confident, plausible answer that may be wrong. You met this in the unit on how models work. RAG is the standard fix.
The idea in one line
Retrieval-augmented generation means: before the model answers, find the passages in your own material that bear on the question, and put them in the prompt. The model then answers from what is in front of it, and can point to where the answer came from.

Two phases
Once, ahead of time: indexing
1. Collect the documents. 2. Cut them into chunks. 3. Turn each chunk into an embedding. 4. Store chunks and embeddings.
Every question: answering
1. Turn the question into an embedding. 2. Find the chunks closest to it. 3. Give the model the question and those chunks. 4. Return the answer with its sources.
The words
Chunk
A piece of a document, small enough to be about one thing: a few paragraphs.
Embedding
A list of numbers that represents the meaning of a piece of text. Similar meanings give similar numbers.
Vector store
A database that holds embeddings and can find the ones closest to a given one.
Retrieval
Finding the chunks most relevant to a question.
Grounding
Making the model answer only from the retrieved text, and say so when the answer is not there.
Embeddings are what make this work better than keyword search. "Money back in two weeks" and "refund within 14 days" share almost no words, but their embeddings are close, so one finds the other.
What RAG is good and bad at
Good: facts that live in documents
Policies, manuals, product details, past decisions.
Good: material that changes
Update the documents and re-index. No retraining.
Weak: questions across everything
"Summarise all our customer feedback" needs every chunk, not the top five.
Weak: bad documents
If the source is wrong, out of date or contradictory, so is the answer.

Your product’s helper answers "What is your refund policy?" with a policy you changed last month. Name the two most likely causes.
Gather your knowledge
Decide what your product’s helper should be able to answer. Collect the source material for it: help text, policies, product details, pricing rules. Put it in one folder, remove anything out of date, and write ten real questions it should answer.
Done when
The ten questions are your test set for the whole unit.
Keep these
- RAG finds relevant passages, then answers from them.
- Chunks become embeddings; closeness means similar meaning.
- Ground the model: answer from the passages or say you do not know.