Retrieval-Augmented Generation (RAG)

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.

Key takeaways

  • RAG retrieves relevant documents at query time and feeds them to the model as context, rather than relying only on training data.
  • Most RAG systems use a vector database to find the passages most similar to a user's question.
  • RAG reduces hallucination by grounding answers in retrieved source text.
  • Unlike fine-tuning, RAG doesn't require retraining the model — it changes what information is available, not how the model behaves.
  • RAG is how most AI assistants answer questions about recent events or private company documents.

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.

Frequently asked

What is RAG used for?
RAG is used to let AI models answer questions accurately about information outside their training data, such as recent news, internal documents, or a specific knowledge base.
Is RAG the same as fine-tuning?
No. Fine-tuning retrains a model's weights to change its behavior; RAG retrieves relevant text at answer time and leaves the model itself unchanged.
Why do LLMs need RAG?
LLMs only know what was present in their training data and can't access new or private information on their own. RAG gives them a way to look that information up before answering.
Does RAG stop hallucinations completely?
No, but it significantly reduces them by grounding the model's answer in retrieved source text instead of relying purely on memorized patterns.

Mentioned in the news