Skip to content

Retrieval-augmented generation (RAG)

RAG lets a language model look up documents before answering and use them in its response. It is the mechanism behind most AI search with listed sources.

Last reviewed

Retrieval-augmented generation, or RAG, is a method in which a system first retrieves relevant documents, then gives them to a language model to write the answer. The idea was described in a 2020 NeurIPS paper by Lewis and colleagues.

AI search products use a version of it. The system turns the question into one or more searches, collects passages from pages, and has the model write an answer based on them, often listing the pages used.

It matters because it makes the answer depend on what can be retrieved right now, not only on the model’s training. Your pages influence the answer only if they can be fetched, are understood, and match the question closely enough to be selected.

Example: for a question about permit requirements for a food stall, the system retrieves a city page and two association pages, then writes a summary from those passages. A blog post that never states the rule is not selected.