Case & CodeA FIELD GUIDE TO AI
Start learning
Beginner

RAG — Retrieval-augmented generation

In plain words

Letting the model look things up in your documents before answering, and show where the answer came from. Like an open-book exam.

Closed book versus open book
Without retrieval

The model answers from whatever it absorbed in training, like an exam from memory.

With retrieval (RAG)

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

Retrieval-augmented generation, step by step
  1. Question“What is the notice period?”
  2. RetrieveSearch the indexed documents; pull the best-matching passages.
  3. GenerateThe model answers from the question plus those passages.
  4. 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

Where it is taught

How document-grounded AI answers work

Source and further reading

Lewis et al. · Retrieval-augmented generation

The 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.

Lessons, terms, practical guides and sources ESC