AI Folks
  • Courses
  • Web Of AI
  • Pricing
  • Enterprise
Log in
PreviousGuardrails and approvalNextAnswers from your sources with NotebookLM

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.

Linen, hand-drawn. Four nodes: the question, embed it, find the closest chunks, and the model with question plus chunks.
At question time: embed, find the closest chunks, then answer.

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.
Indexing is done again whenever the documents change.

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

  1. 1

    Good: facts that live in documents

    Policies, manuals, product details, past decisions.

  2. 2

    Good: material that changes

    Update the documents and re-index. No retraining.

  3. 3

    Weak: questions across everything

    "Summarise all our customer feedback" needs every chunk, not the top five.

  4. 4

    Weak: bad documents

    If the source is wrong, out of date or contradictory, so is the answer.

Linen, hand-drawn. A chat: can I get a refund, and an answer that names its source, the refund policy, section 2.
A grounded answer names its source.

The instruction that matters most

Tell the model: answer only from the provided passages; if the answer is not in them, say you do not know. Without that line a RAG system will happily fall back on guessing, and you will not be able to tell.

ActivityYour turnWrite it yourself first, then compare.

Your product’s helper answers "What is your refund policy?" with a policy you changed last month. Name the two most likely causes.

ActivityBuild stepA helper that answers from your documents

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.
Back toVibe CoderNext lessonAnswers from your sources with NotebookLM