Skip to content
p.mba

Type to search tools, guides, glossary terms, frameworks, formula sheets and pages.

Menu

Glossary · Data Science & AI

Retrieval-Augmented Generation

Also called: RAG · grounded generation

A technique that retrieves relevant documents from a trusted source and adds them to a language model's prompt so its answer is grounded in that material.

Definition

Retrieval-augmented generation pairs a search step with a generative model: the system finds passages relevant to the question, usually by comparing numerical embeddings of the query and documents, and inserts them into the prompt before the model answers. Patrick Lewis and colleagues described the approach in a 2020 paper. It lets a model use current or private information it was never trained on, keeps prompts within the context window, and allows answers to cite their sources. Quality depends on the retrieval step: if the right passages are not found, the model may still guess.

Worked example

Hypothetical scenario: a consulting team loads 400 past project reports into a RAG tool. When asked which pricing approaches worked for industrial clients, the tool retrieves six relevant report sections and answers with citations, which the team then opens to verify.
  • Large Language Model: A neural network trained on very large amounts of text to predict the next token, which lets it generate, summarize, translate and reason over language.
  • Context Window: The maximum amount of text, measured in tokens, that a language model can consider at once, covering the prompt, any documents supplied and its own reply.
  • Hallucination: When an AI model produces a fluent, confident answer that is false or unsupported, such as an invented fact, number or citation.
  • Prompt: The instructions, context and examples given to a generative AI model to steer what it produces.
  • Fine-Tuning: Further training a pretrained AI model on a smaller, task-specific dataset so it performs better on that task or adopts a particular style.

Courses

More in Data Science & AI

All glossary terms