AI Search & Agents

Retrieval-Augmented Generation (RAG)

In shortA method where an AI system retrieves relevant passages from an index first, then writes its answer from them, so responses are grounded in sources.

Updated 24 Oct 2026· 2 min read

Retrieval-augmented generation (RAG) combines a search step with a Large Language Model (LLM). Before the model writes anything, the system retrieves passages that look relevant to the question and adds them to the prompt. The model then answers from that material, which makes the answer more current and lets the system cite where the information came from.

The term comes from a 2020 research paper by Lewis and colleagues at Facebook AI Research. Today the same basic pattern sits behind AI Overviews, AI Mode, ChatGPT search, Perplexity and most company chatbots built on internal documents.

How it works

  • Index: documents are split into chunks and each chunk is stored, usually as an embedding in a vector index, often alongside a keyword index.
  • Retrieve: the user’s question (or the sub-queries generated from it, see Query Fan-Out) is matched against the index with Vector Search, BM25 or both.
  • Re-rank: a second model scores the candidates more carefully and keeps the best few. See Re-ranking.
  • Generate: the top passages go into the model’s Context Window with instructions to answer from them, and the answer is returned with citations.

In MLforSEO’s five-stage retrieval funnel, millions of candidate chunks are narrowed to thousands, hundreds and then tens before individual claims are extracted and selected for the answer. Most content is eliminated long before anyone judges how well it is written.

How it’s used in SEO and marketing

  • Understanding AI search. Being retrieved as a candidate passage is step zero for an AI citation, which is why structure, chunking and entity clarity matter.
  • Content design. Self-contained, clearly headed sections give retrieval systems passages they can use. See Chunking (Content Chunking).
  • Building your own tools. A vector index of your pages can power on-site semantic search, related-post widgets, internal-link suggestions or a support assistant that answers from your own documentation.

Example

In 10 Ways to Automate Internal Linking with AI, page embeddings built for “read next” suggestions are loaded into a vector database (for example pgvector). The same index can then power a RAG assistant that answers visitors’ questions from the site’s own pages, so the work done for internal linking pays off twice.

Limitations and things to watch

  • RAG reduces hallucination but does not remove it. The model can still misread or over-generalise a passage.
  • Answer quality depends on retrieval quality: if the right passage is never retrieved, the model cannot use it.
  • Your content can be used as context without being cited by name, which standard analytics will not show.
  • Public AI search systems do not publish their exact pipelines, so treat any description of them as a model of how they behave.

Learn it on MLforSEO

Where Retrieval-Augmented Generation (RAG) shows up on MLforSEO

Sources and further reading

Other terms from AI Search & Agents

See all 34 AI Search & Agents terms →