Language models & chatbots

RAG (Retrieval-augmented generation)

RAG (retrieval-augmented generation) is a technique where an AI looks up relevant documents first, then uses them to write an answer grounded in real sources.

A language model on its own answers from memory, which is frozen and sometimes wrong. RAG gives it an open book. When you ask a question, the system first searches a collection of documents for relevant passages, then places those passages into the prompt with your question. The model writes its answer using that material.

The three words describe the steps. Retrieval finds the right chunks, usually with semantic search over a vector database. Augmentation adds them to the prompt. Generation is the model composing the reply. Because the sources are right there, the answer can quote them and stay current without retraining.

RAG is the standard way to let AI answer questions about private or fresh information, such as company policies or this week's news. It reduces hallucination but does not eliminate it, and its quality depends heavily on the retrieval step. It was introduced by Meta AI researchers in 2020.

Example

A customer asks a support bot about returns; the bot fetches the latest returns policy page and answers from it, instead of guessing from year-old training data.

Lesson: What is RAG? →