RAG (retrieval-augmented generation)

A technique where a system first looks up relevant material, then gives it to the model to answer from.

technique

A model only knows what it absorbed in training. Retrieval-augmented generation, or RAG, adds a step before the answer: search a collection of documents for the passages most relevant to the question, then place those passages in the prompt.

The model then writes its answer using that material. The search step often uses embeddings, so it can find passages that match the meaning of a question rather than only its exact words.

RAG lets a model work with private, specialised or recent information without retraining it, and makes it easier to show sources. It is only as good as what it retrieves: if the right passage is not found, the answer can still miss.

Example

A staff assistant answering “How many days of leave do I get?” first pulls the relevant section of the company handbook, then answers from it.

Related