Retrieval-augmented generation
Definition
Retrieval-augmented generation (RAG) retrieves passages relevant to a question from an external index and generates an answer with a model whose prompt contains those passages and an instruction to answer from them and cite them.
In practice
Models do not know private or recent data, and retraining for every change is impractical. RAG keeps knowledge in an index instead: an ingestion pipeline chunks, embeds and indexes documents, and the query path embeds the question, retrieves top-k (often hybrid), reranks, builds a grounded prompt, generates and validates citations. Retrieval costs tens of milliseconds; generation costs seconds and sets throughput.
Most bad answers are retrieval misses, not model failures, so evaluate retrieval and generation separately. Permissions must be enforced as filters inside the search, never by asking the model, and retrieved text is untrusted input that can carry prompt injection. Structured questions are often better served by querying a database than by retrieving text.
Example
An HR assistant retrieves 6 policy chunks for "How many days of parental leave do I get?", answers "20 weeks [1]" and links to section 4.2 of the current leave policy.