RAG

Retrieval-augmented generation: before the model answers, look up relevant documents and paste them into the prompt, so it answers from the source instead of from memory.

A two-color risograph: a schoolboy points into an enormous open book propped on his exam desk while the classmates around him work from memory.

RAG (retrieval-augmented generation) is a way of giving a model the facts it needs right when it needs them. When a question comes in, a search step first finds the most relevant chunks of text (your company’s docs, a set of PDFs, a website) and pastes them into the model’s context window along with the question. The model then answers with the source sitting right in front of it.

The search is usually done with embeddings : every chunk of text gets turned into a list of numbers that captures its meaning, and the chunks whose numbers sit closest to the question’s get pulled in. That’s how “how do I get a refund” can find a page titled “Returns policy” without sharing a single word.

RAG is the most common fix for hallucination and for models not knowing anything newer than their training data. It doesn’t cure either. If the search grabs the wrong page, the model will confidently answer from the wrong page.