Glossary termTechnique

Retrieval-Augmented Generation

Also known as: RAG

Technique that improves a language model's answers by first retrieving relevant documents and supplying them to the model as context.

Retrieval-augmented generation combines a search step with a generative model. When a question arrives, the system retrieves passages likely to contain the answer, from company documents, a knowledge base, the web or a personal archive, and inserts them into the model's prompt. The language model then writes a response grounded in that material, ideally citing its sources. This lets a model draw on information it was never trained on, including private or frequently updated data, without retraining.

The term comes from a 2020 paper by Patrick Lewis and colleagues at Facebook AI Research, University College London and New York University, which combined a neural retriever with a sequence-to-sequence generator. In practice, most RAG systems split documents into chunks, convert them to embeddings, store them in a vector database and retrieve the closest matches to the query, often combined with keyword search and a reranking step. Variants let agents decide when and what to search, or query structured sources such as knowledge graphs.

RAG is one of the most widely used patterns for building practical AI applications because it can reduce hallucination, allows answers to be checked against sources and keeps sensitive data under the owner's control. It does not eliminate errors: retrieval can miss the right passage or surface misleading ones, and models may still misread or ignore what they are given. Retrieved documents can also carry prompt injection attacks. Good RAG systems therefore invest heavily in document preparation, retrieval evaluation and clear source attribution.

Key points

  • RAG retrieves relevant documents at query time and passes them to a language model as context.
  • The approach was named in a 2020 paper led by Patrick Lewis at Facebook AI Research.
  • It lets models use private or frequently updated information without retraining.
  • RAG can reduce but not eliminate errors, and retrieved content can carry prompt injection.

Related entries

Glossary term

Vector Database

AIProgramming

Database designed to store embeddings and quickly find the vectors most similar to a query, supporting semantic search and AI retrieval.

Glossary term

Embedding

AIProgramming

A learned numerical vector that represents an item such as a word, document, image or user so that similar items have nearby vectors.

Glossary term

Search technique that matches queries to content by meaning and intent rather than by exact keywords, often using embeddings and language models.

Glossary term

Output from an AI model that sounds plausible and confident but is false, fabricated or unsupported by its input or by the facts.

Glossary term

The maximum amount of input, measured in tokens, that a language model can take into account at once, including the text it is generating.

Glossary term

Neural network trained on very large amounts of text to predict the next token, able to generate language and perform many tasks from prompts.

Technology

NotebookLM

AIOSINT

AI-powered research and note-taking assistant from Google that answers questions and generates summaries grounded in documents the user provides.

Glossary term

Prompt Injection

AICybersecurity

Security vulnerability in which crafted text causes an AI model to follow an attacker's instructions instead of those of its developer or user.

Featured in guides

Referenced by

Other entries that discuss or point to Retrieval-Augmented Generation.