Retrieval-augmented generation (RAG) is a technique that lets an AI model look up relevant information from an external source before answering, instead of relying only on what it memorized during training.
What is retrieval-augmented generation?
Retrieval-augmented generation, or RAG, combines a language model with a search step. When a user asks a question, the system first retrieves relevant passages from a document store, database, or the web, then feeds those passages to the model alongside the question so it can generate an answer grounded in that retrieved text.
How RAG works
A typical RAG pipeline converts documents into embedding vectors and stores them in a vector database. When a query comes in, it's embedded the same way and compared against the stored vectors to find the closest matches. Those matches are inserted into the model's context window as supporting evidence before it generates a response.
Why RAG matters
Standard LLMs only know what was in their training data, which goes stale and can't include private or proprietary documents. RAG lets a model answer questions about current events, internal company knowledge bases, or specific documents without retraining the underlying model, and it reduces hallucination by giving the model real source text to draw from rather than relying purely on memorized patterns.
RAG vs fine-tuning
RAG and fine-tuning solve different problems. Fine-tuning changes how a model behaves or writes by further training it on examples; RAG changes what information the model has access to at answer time, without touching the model's weights at all. Many production systems use both together.