Skip to content
BytePatterns

Retrieval-Augmented Generation

AI & ML: lesson 11 of 15

Fetch the facts first, then let the model write.

Lesson 11 of 15 · 5 min

Retrieval-Augmented Generation

Step 1 of 12

RAG puts a search step in front of the model. First, index your own corpus.

The Idea

Retrieval-augmented generation puts a search step in front of the model. The question is embedded, the nearest passages are pulled from your own corpus, and they go into the prompt with an instruction to answer only from them.

Real-World Example

A newsroom fact-checker. Before a claim goes to print they pull the two or three primary documents bearing on it and rewrite the sentence citing those, rather than trusting memory.

The Tradeoff

You get fresh, citable, permission-aware answers without retraining anything. You pay with a pipeline that can fail at every stage: clumsy chunking, a retriever that misses the one passage that mattered, and a model that answers anyway when nothing relevant came back. Retrieval quality caps the whole system.

Your turn

Put the steps in the right order.

  1. Send the question plus the retrieved passages to the model
  2. Split the source documents into chunks and embed each one
  3. Embed the incoming question with that same model
  4. Return the closest chunks by vector similarity

Mini quiz

1 / 3

In a RAG system, retrieval happens: