Retrieval Augmented Generation (RAG)

Retrieval Augmented Generation (RAG)


RAG is a language model producing an answer from documents fetched at query time rather than from its weights alone. When a question arrives a retrieval step runs first, relevant passages are found, and those passages are placed inside the prompt. The model then writes its answer from them.

On the preparation side documents are split into chunks, each chunk is embedded and written to a vector store. When a query comes in it is embedded with the same model and the nearest chunks are retrieved. Most systems add a reranking step here, because the first retrieval is fast but coarse. The retrieved passages get trimmed to fit the context window and handed to the model along with their source information.

What the approach really solves is freshness and verifiability. A model's training data is frozen at a date, while RAG builds the answer from today's document. It can also show which source the answer rests on, which reduces hallucination and gives the reader something to check.

A concrete case: a software company's support assistant is wired to the product documentation. When a user asks about a feature released last week, the model does not know it from training, but retrieval finds the relevant doc page and the answer comes from there. Update the documentation and the assistant's answer updates with it, no retraining involved.

Retrieval is the weak link. Fetch the wrong passage and the model answers confidently and wrongly, which is why retrieval quality gets measured on its own.

From generative AI strategy to custom agent development and retrieval architectures, we help you scale AI responsibly.
Discuss your AI project