Skip to content
AI DemystifiedHow AI actually works
Lesson 07 of 22Systemsintermediate5 min

RAG

Open-book AI: retrieve, then generate

What is RAG?

Without retrieval, a model answers from its parameters and the context already in the request. Retrieval-Augmented Generation adds a search step: select candidate evidence, place it in the request, then generate a response conditioned on that evidence. This can expose the model to current or private material without retraining its weights.

Lab honesty

This lab is an offline BM25 lexical retriever over a fixed corpus, not a production vector store. Scores are normalized teaching ranks, not embedding cosine similarity. Grounded answers quote exact retrieved sentences and abstain when no evidence matches. Production retrievers may be sparse, dense, or hybrid, often with re-ranking and task-specific evals.

Evaluate the chain, not only the final prose

  1. 1 · Retrieval: did the system find evidence that can answer the question?
  2. 2 · Context: did chunking or ranking omit a necessary qualifier?
  3. 3 · Grounding: is each answer claim supported by the supplied evidence?
  4. 4 · Usefulness: is the grounded answer complete and relevant to the user?

Demo queries

Press Enter or Retrieve to rank corpus chunks, then answer.

Corpus (6 docs)

  • Return Policyscore 100

    Customers may return unopened items within 30 days of purchase for a full refund. Opened electronics have a 14-day window. Gift cards are non-refundable.

  • Shipping Times

    Standard shipping takes 5 to 7 business days. Express shipping arrives in 2 business days. Orders placed after 2pm ship the next business day.

  • Aurora Headphones Specs

    The Aurora Wireless Headphones offer 40 hours of battery life, active noise cancellation, and Bluetooth 5.3. Weight is 250 grams. Waterproof rating is IPX4.

  • Nova Laptop Specs

    The Nova Laptop includes a 14-inch display, 16GB RAM, 512GB SSD, and up to 12 hours of battery life. It ships with a USB-C charger only.

  • Warranty FAQ

    All hardware carries a 1-year limited warranty covering manufacturing defects. Accidental damage is not covered. Register your device within 30 days of purchase.

  • Cafe Menu

    Today's specials include tomato soup, grilled cheese, and iced tea. The cafe closes at 6pm on weekdays.

Ranked retrieval

  1. Return Policy100%

Model answer

Grounded

[Return Policy] Customers may return unopened items within 30 days of purchase for a full refund. [Return Policy] Opened electronics have a 14-day window.

Key Insight

RAG adds evidence; it does not guarantee that the generator will use that evidence faithfully. Wrong chunks can yield a fluent wrong answer, and a citation can point to text that does not support the claim. Measure retrieval and answer grounding separately. Next: tools and agents that call systems beyond a document store.

Check your understanding

1/5

What does RAG stand for?

Sources, scope & review statusVerified Jul 29, 2026

Claims this lesson makes

  • Stable conceptRAG retrieves candidate evidence before generation, so retrieval quality and answer grounding require separate evaluation.
  • Stable conceptRetrieval can expose a generator to fresher or private evidence without encoding that evidence into the model parameters.

    Scope: Retrieval supplies evidence at inference time; it does not guarantee that the generator will cite or use that evidence faithfully.

  • Stable conceptA fluent answer with citations is not sufficient evidence of correctness: systems should evaluate whether the right evidence was retrieved and whether each answer claim is supported by it.

Next content review: 2027-07-29. Source links establish the lesson's claims; interactive numbers remain labeled simulations unless explicitly identified as measured data.