Retrieval-Augmented Generation (RAG)
Retrieval-Augmented Generation (RAG) is a technique where a language model retrieves relevant documents from an external knowledge base before generating a response, reducing hallucination by 30-60% and enabling citation of sources.
Full definition
A RAG pipeline turns a query into an embedding, searches a vector database for the most semantically similar chunks of source content, packs the retrieved chunks into the LLM's context window, then asks the model to answer using only those chunks. Introduced by Lewis et al. (2020), RAG is now the dominant pattern for grounded enterprise AI — preferred over fine-tuning whenever the underlying knowledge changes more often than once a quarter.
Why it matters
RAG is the most cost-effective way to make a foundation model factual and current without retraining. It keeps proprietary data inside the enterprise, supports source citation (regulatory requirement in healthcare, finance, and legal), and decouples knowledge updates from model updates — change a document, the system reflects it on the next query.
Example
A legal-tech firm builds a RAG system over its case-law database. Attorneys ask "what are recent California rulings on non-compete enforceability?" The system retrieves the 5 most relevant cases and the LLM produces a summary with citations to each.
Frequently asked questions
Is RAG better than fine-tuning?
They solve different problems. RAG injects up-to-date, verifiable knowledge; fine-tuning teaches style, format, or reasoning patterns. Most production systems use both.
Does RAG eliminate hallucination?
No — but it reduces it dramatically. The model can still misread retrieved chunks or fabricate when retrieval fails. Citation-grounded prompts and answer validation are still required.
Related terms
- Vector DatabaseA vector database is a database optimized for storing and searching high-dimensional vectors (embeddings) by similarity rather than by exact match — the storage layer of every RAG and semantic-search system.
- EmbeddingAn embedding is a dense numerical vector — typically 384 to 4096 dimensions — that represents the semantic meaning of a piece of text, image, audio, or other content, so that semantically similar items end up near each other in vector space.
- HallucinationAn AI hallucination is when a language or generative model produces content that is plausible-sounding but factually incorrect, fabricated, or unfaithful to its sources — the single biggest failure mode of LLMs in regulated and high-stakes domains.
- Large Language Model (LLM)A Large Language Model (LLM) is a deep neural network — almost always a transformer — trained on hundreds of billions to trillions of words to predict the next token, and to generate, summarize, translate, or reason over text.
- Context WindowA context window is the maximum amount of text — measured in tokens — a language model can read and reason over in one inference call, equivalent to the model's working memory for that turn.
Source & further reading
Primary source: Lewis et al. — "Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks" (NeurIPS) (2020).
Citation policy: this entry is part of the AIDOLS AI Implementation Glossary and may be quoted for research, journalism, and education with attribution to aidolsgroup.com/it/glossary/rag/.