Retrieval-augmented generation (RAG). What it means.

Retrieval-augmented generation (RAG) is a technique where an AI system first retrieves relevant documents, then gives them to a language model to write an answer grounded in them.

By Brady Heinrich · Updated

Definition

Retrieval-augmented generation (RAG) is a technique where an AI system first retrieves relevant documents, then gives them to a language model to write an answer grounded in them.

What is RAG?

RAG stands for retrieval-augmented generation. Instead of answering from what the model memorised in training, the system looks things up first. It searches a set of documents, or the web, for material relevant to the question, places what it finds in the prompt and asks the model to answer using that material.

The point is to give a large language model facts it would not otherwise have: recent events, private company documents or anything too specific to have been learned in training.

How does retrieval-augmented generation work?

  1. Prepare the sources. Documents are split into passages and indexed so they can be searched, often as embeddings, which are numeric representations of meaning.
  2. Retrieve. When a question arrives, the system searches the index for the passages most relevant to it. On the public web, this step is a search engine query.
  3. Augment. The retrieved passages are added to the prompt alongside the question.
  4. Generate. The model writes an answer based on those passages, often citing which source each claim came from.

Answer quality depends on step 2. If retrieval returns the wrong passages, the model writes a confident answer from the wrong material.

RAG vs fine-tuning

RAGFine-tuning
What changesThe information given to the model at question timeThe model itself, through further training
Best forFacts that change or are privateStyle, format and specialised behaviour
UpdatingEdit the documentsRetrain
SourcesCan cite themCannot point to where an answer came from
Cost to startLowerHigher

They are not rivals. Many systems fine-tune for tone and use RAG for facts.

Does RAG stop hallucinations?

It reduces them and does not remove them. A model with the right passage in front of it is far more likely to answer correctly, but it can still misread a source, blend two sources or fill a gap with a guess. Good systems show citations so a person can check.

Why does RAG matter for marketers?

AI search products work this way. Google's documentation describes AI Overviews and AI Mode issuing several related searches and building a response from the results, and other assistants with web search follow the same pattern. Two things follow.

First, a page must be retrievable: crawlable, indexed and relevant to the query the system runs. Second, the system lifts passages, not whole pages. A paragraph that answers a question completely on its own is easier to retrieve and quote than one that depends on the three before it.

An example

A software company builds a support assistant. Its 800 help articles are split into passages and indexed. When a customer asks how to export invoices to a specific accounting tool, the system retrieves the three most relevant passages, and the model writes step-by-step instructions from them with a link to the source article.

The common mistake

Blaming the model when the answer is wrong. In most RAG systems the failure is retrieval: outdated, duplicated or badly split documents. Fix what is being retrieved before changing the model or the prompt.

How people search for retrieval-augmented generation

  • what is rag12,100 a month
  • rag ai9,900 a month
  • retrieval augmented generation8,100 a month
  • what is retrieval augmented generation1,300 a month
  • rag vs fine tuning480 a month

US monthly searches, Google Ads keyword data.

Related terms

Go deeper

Building something ambitious? Let's talk.

We reply within one business day.