HASZB_AIHASZB_AI

Search across courses, lessons, glossary terms, prompts and tools.

Lab 07

RAG Lab

Retrieval gives a model relevant text at request time. It does not retrain the model, and it does not make the answer true.

Educational simulation. Retrieval here is keyword overlap, not embeddings. A real system converts the question and every chunk into vectors and compares meanings, so it can match “money back” to “refund” even with no shared words. This one matches only on words that actually appear, so wording matters far more here than it would in production. No model is called at the end.

Ask the documents

The pipeline

  1. QuestionHow long do I have to ret…
  2. Search8 chunks
  3. Rank1 matched
  4. Add to context139 chars
  5. Model
  6. Answer

Chunk size

Usually the best balance: enough surrounding meaning to stay coherent, little enough that irrelevant text does not ride along.

How many to retrieve

Retrieve too few and the answer is missing evidence. Retrieve too many and the useful passage competes with noise for the model's attention — and you pay for every token either way.

Retrieved context (1)

  • #1Returns and refundsscore 0.85

    Customers may return any physical item within 14 days of delivery for a full refund. The item must be unused and in its original packaging.

    matched: return

Reading the result

What just happened
1 passage scored above zero and were placed into the model's context. Everything else in the corpus was never sent.
Why it matters
Retrieval does not retrain anything. It selects text and pastes it into the prompt at request time. If the right passage is not retrieved, the model cannot use it — no amount of prompting recovers it.
Where you meet this
Every “chat with your documents” product is this loop. When one confidently answers from the wrong document, the retrieval step picked wrong, not the model.

The corpus

  • Returns and refunds

    Retrieved from

  • Shipping and delivery

    Not retrieved

  • Accounts and data

    Not retrieved

  • Contacting support

    Not retrieved