Deutsch
Retrieval & grounding

Retrieval-augmented generation (RAG)

Also known as: RAG, retrieval augmented generation

Retrieval-augmented generation (RAG) is a method in which a language model retrieves relevant information from an external source before answering and uses it in the response. This lets the model work with current or specialized content that is not in its training data and point to the sources it used.

At a glance

Type
technique (architecture around a language model)
Steps
retrieval, augmentation, generation
Since
2020, term from Lewis et al.

Last checked:

How does RAG work?

A RAG system works in three steps:

  1. Retrieval: For the incoming question, the system searches a document collection for matching passages. This is often a vector search over embeddings, sometimes combined with classic keyword search.
  2. Augmentation: The retrieved passages are added to the prompt together with the question.
  3. Generation: The language model writes the answer based on the question and the added context.

Before any of this, the source documents are usually split into chunks, converted into embeddings and stored in a vector database. That indexing step runs once and is repeated when the content changes.

The term comes from a paper by Patrick Lewis and co-authors, first posted on May 22, 2020 and accepted at NeurIPS 2020. They combined a pretrained sequence-to-sequence model, which they called parametric memory, with a dense vector index of Wikipedia as non-parametric memory.

Compared with retraining or fine-tuning a model, RAG has practical advantages. The knowledge base can be swapped or updated without touching the model, and answers can cite their sources. The trade-offs are extra infrastructure and an added retrieval step before each answer.

Retrieval-augmented generation: retrieve first, then answerA question triggers a search in a search index or vector database. The best passages are added to the prompt together with the question. The language model writes the answer from them and points to the sources of the passages. The answer can only cite what was retrieved first.1 QUESTION2 RETRIEVAL3 CONTEXT4 ANSWERQuestionfrom a useror an appRetrievalsearch orvector search findsmatching passagesKnowledge sourcesearch index, web,vector databasePrompt with contextquestion + passages[1] passage · URL A[2] passage · URL B[3] passage · URL CLLMAnswertext withsource links[1][3]Citations point to retrieved passagesSchematic, based on Lewis et al. (2020) and Google’s grounding docs.
In retrieval-augmented generation, the system first retrieves matching passages and passes them to the language model as context. Google calls the link between model output and verifiable sources grounding. The answer can only cite what was retrieved first (an inference from the method, not a Google statement). Sources: Lewis et al. (2020): Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks (arXiv 2005.11401); Google Cloud: Grounding overview (Vertex AI); Google Cloud: Grounding with Google Search (Vertex AI).

What does RAG mean for SEO and GEO?

Many AI search products follow this pattern. They search the web for a question, read the pages they find and summarize them. Google’s Gemini API, for example, documents a flow in which the model runs searches, processes the results and returns an answer with citations. Perplexity runs PerplexityBot to surface and link websites in its answers.

For site owners, a page can only serve as a source if the relevant bot is allowed to fetch it and can read its content. Pages that answer a specific question in a clearly labeled section give a retrieval system an obvious passage to pick. For its own AI features, Google states that its systems understand pages covering several topics and that there is no need to break content into tiny pieces.

Example

A company builds a chatbot for its product manuals. The manuals are split into sections and stored as vectors. When a customer asks “How do I reset the device?”, the system fetches the three closest sections, passes them to the language model and shows links to the manual pages under the answer.

FAQ

Is ChatGPT a RAG model? The model itself is not. RAG describes an architecture built around a model. When ChatGPT uses web search or uploaded files to support an answer, that follows the RAG pattern.

Does RAG prevent hallucinations? It can reduce them because the model works from retrieved text. It cannot rule them out. If retrieval returns the wrong passages or the model misreads them, the answer is still wrong.

What is RAG in an LLM, with an example? A support assistant that looks up the current returns policy in the company’s knowledge base before answering, then quotes and links it, is a typical RAG setup.

Sources

  1. Lewis et al.: Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks, arXiv:2005.11401 (submitted 2020-05-22), NeurIPS 2020arxiv.org
  2. What is RAG (Retrieval-Augmented Generation)? – AWSaws.amazon.com
  3. Grounding with Google Search – Gemini API Docsai.google.dev
  4. Google's guide to optimizing for generative AI features on Google Search – Google Search Central (updated 2026-07-10)developers.google.com
  5. Perplexity Crawlers – Perplexity Docsdocs.perplexity.ai

Last updated: