RAG — Retrieval-augmented generation
Letting the model look things up in your documents before answering, and show where the answer came from. Like an open-book exam.
The model answers from whatever it absorbed in training, like an exam from memory.
The application first finds the relevant pages in your documents and puts them in front of the model, like an open-book exam with page references.
Open book is better, but the student can still misread the page, and the search can hand it the wrong page. The page reference is what lets you check.
The fuller definition
Retrieval-augmented generation combines a retrieval step with generation: a system finds relevant material and supplies it to a model to help produce an answer.
Go deeper
- Question“What is the notice period?”
- RetrieveSearch the indexed documents; pull the best-matching passages.
- GenerateThe model answers from the question plus those passages.
- CiteEach statement points to the passage it came from.
Two things can still go wrong: the search misses the clause that matters, or the model misreads the clause it was given. The citation lets you check which happened.
A concrete example
A question about a contract retrieves selected clauses before the model drafts a response.
The distinction that matters
Retrieval can miss key material, and a model can misinterpret retrieved text. RAG does not eliminate hallucinations.
Related terms
Retrieval
Searching a larger set of records for useful parts. Finding a passage does not prove it answers the question.
Documents & retrievalChunking
Cutting a long document into smaller pieces so they can be searched and fed to the model.
Documents & retrievalGrounding
Basing an answer on a named source or set of facts. A link to a source does not prove the answer follows from it.
Where it is taught
How document-grounded AI answers workSource and further reading
Lewis et al. · Retrieval-augmented generationThe definition and example are written for this library. The link gives background, official documentation or legal authority as labelled. Legal scope depends on the jurisdiction and current text; product features depend on release and settings.