Retrieval-Augmented Generation (RAG)

How RAG works — the retrieve-then-generate pattern behind Google AI Overviews, ChatGPT Search, and Perplexity — and what it means for getting your content cited.

First published: Jun 24, 2026 · Last updated: Jul 19, 2026 · Advanced
demand #2 in How Search Works#2 in AI Search#4 on the site

RAG (Retrieval-Augmented Generation) is the retrieve-then-generate pattern behind AI search. It runs two phases at query time — retrieval (find relevant passages from an external index) and augmented generation (feed those passages to an LLM to write a grounded, cited answer) — without ever changing the model's weights. It's how AI answers cover information beyond a model's training cutoff. The retrieval phase chains chunking → embeddings → vector search → re-ranking → top-k passages. RAG reduces hallucinations but doesn't eliminate them — and insufficient retrieved context can make them worse. For SEO there's no separate AI index: being crawlable, indexed, and structured into clear, self-contained passages is the prerequisite for being retrieved and cited.

Lewis and colleagues’ 2020 system paired sequence generation with dense retrieval from a non-parametric indexStoring a crawled page in the search index so it can appear in results. Crawled is not the same as indexed — Google selects what to keep, and indexing isn't guaranteed.. Evidence for this claim The original RAG paper combined a pretrained sequence-to-sequence model with a non-parametric dense-vector index retrieved during generation. Scope: Lewis et al.'s 2020 RAG architecture and experiments, not every modern retrieval system. Confidence: high · Verified: Lewis et al.: Retrieval-Augmented Generation Google Cloud’s current overview defines RAG more broadly as supplying retrieved external knowledge to a model. Evidence for this claim Google Cloud describes RAG as retrieving relevant information from external knowledge sources and providing it to a model to improve generated responses. Scope: General RAG architecture in Google Cloud documentation; quality depends on retrieval, source quality, and generation. Confidence: high · Verified: Google Cloud: RAG overview

TL;DR — RAG is a two-phase, inference-time pattern: retrieval (find relevant passages in an external corpus) then augmented generation (feed those passages to an LLMA large language model (LLM) is a deep-learning model trained on massive text corpora to predict the next token and generate human-like text. LLMs use the transformer architecture and power AI search features like Google's AI Overviews (Gemini) and Bing Copilot (GPT-4). to produce a grounded, cited answer). The weights never change — it combines the model’s parametric memory with non-parametric memory retrieved live. The retrieval phase chains chunkingChunking is splitting a document into smaller passages so AI systems can embed, index, and retrieve the single most relevant piece — not the whole page — in response to a query. It's a foundational step in RAG pipelines and the conceptual cousin of Google's passage ranking.embeddingsEmbeddings are dense numerical vectors — lists of floating-point numbers — that represent the meaning of text in a high-dimensional space. Semantically similar content lands close together, so search and AI systems can match by meaning, not just keywords.vector searchVector search finds content by comparing the meaning of a query against stored content as numerical vectors, retrieving the closest ones in a high-dimensional embedding space. At scale it uses approximate nearest neighbor (ANN) algorithms — not exact comparison — to search billions of vectors in milliseconds.re-rankingReranking is the second stage of a retrieval pipeline: after a cheap, broad first pass pulls a candidate set of documents or passages, a slower, more precise model re-scores and reorders that shortlist by true relevance before the results are served or handed to an LLM. → top-k. “Naive” RAG is retrieve-then-generate; advanced RAG adds query rewriting and re-ranking; agentic RAG adds iterative, multi-hop retrieval. Retrieval can ground answers but does not guarantee correctness; in one Gemma evaluation, insufficient context coincided with more incorrect answers. For SEO: there’s no separate AI index; crawlabilityCrawlability is how well search engine crawlers can discover, access, and fetch a site's pages. A crawlability issue is any technical condition — blocked access, broken links, server failures, or bloated URL inventory — that stops pages from reaching the index., indexingStoring a crawled page in the search index so it can appear in results. Crawled is not the same as indexed — Google selects what to keep, and indexing isn't guaranteed., and passage-level clarity are the prerequisites for being retrieved.

The two phases (and why “inference time” is the whole point)

Retrieval is a pipeline: chunk, embed, search, re-rank, then hand the survivors to the model. Source: /ai-search/how-search-works/rag/

Five stages run left to right at inference time. Chunking splits documents into retrievable passages. Embeddings represent each passage as a dense vector. Vector search retrieves candidates and some systems combine it with BM25 keyword search. Re-ranking re-scores and narrows the candidate set. The top surviving passages enter the model context. The model's weights do not change.

© Patrick Stox LLC · CC BY 4.0 ·

RAG combines trained model memory with retrieved context at query time — without changing the weights. Source: /ai-search/how-search-works/rag/

Two sources feed one generation step. Parametric memory is knowledge encoded in the model weights during training and is limited by the training data and cutoff. Non-parametric memory consists of passages retrieved from an external index at query time. Generation uses both while the weights remain unchanged, producing an answer that can be grounded in and cite the retrieved sources; this does not guarantee correctness.

© Patrick Stox LLC · CC BY 4.0 ·

Break the acronym apart and you have the model: Retrieval plus Augmented Generation. A query comes in; the system retrieves the most relevant passages from an external corpus; it injects those passages into the LLM’s context windowA token is the smallest unit of text (or image/audio/video) an LLM processes — roughly 4 characters, or about ¾ of an English word. A context window is the maximum number of tokens (input plus output) a model can hold at once, like its short-term memory.; the LLM generates an answer grounded in them.

The detail that everyone gets wrong: this happens at inference time, and the model’s weights are never touched. RAG is not training and it is not fine-tuning. The original 2020 paper from Patrick Lewis and colleagues at Facebook AI Research framed it as combining two kinds of memory — parametric memory (knowledge baked into the weights during training) and non-parametric memory (knowledge retrieved live from an index). RAG uses both at once. AWS puts the practical case plainly: retraining a foundation model for fresh or domain-specific knowledge is expensive, and “RAG is a more cost-effective approach to introducing new data to the LLM.”

(The naming, for what it’s worth, was an accident. Lewis later admitted: “We definitely would have put more thought into the name had we known our work would become so widespread… We always planned to have a nicer sounding name, but when it came time to write the paper, no one had a better idea.”)

Inside the retrieval phase

“Retrieve the relevant passages” is doing a lot of work in that sentence. In a real system it’s a pipeline:

  1. ChunkingChunking is splitting a document into smaller passages so AI systems can embed, index, and retrieve the single most relevant piece — not the whole page — in response to a query. It's a foundational step in RAG pipelines and the conceptual cousin of Google's passage ranking.. Documents get split into retrievable pieces. Chunk size is a real tradeoff — too small and a passage loses its context; too large and it floods the token budget with irrelevance. Strategies range from fixed token counts (100/256/512) to recursive/sliding windows to “Small2Big” (retrieve a small sentence, return its parent chunk for generation).
  2. EmbeddingsEmbeddings are dense numerical vectors — lists of floating-point numbers — that represent the meaning of text in a high-dimensional space. Semantically similar content lands close together, so search and AI systems can match by meaning, not just keywords.. Each chunk is turned into a dense vector — a numeric representation of its meaning — so similarity is computed semantically, not by keyword match. This is why content about a topic gets retrieved even when it doesn’t use the exact query phrasing.
  3. Vector searchVector search finds content by comparing the meaning of a query against stored content as numerical vectors, retrieving the closest ones in a high-dimensional embedding space. At scale it uses approximate nearest neighbor (ANN) algorithms — not exact comparison — to search billions of vectors in milliseconds.. The query is embedded too, and the system finds the chunks whose vectors sit closest to it. Most production stacks run hybrid searchHybrid search runs keyword (lexical/BM25) search and vector (semantic) search together, then merges the two result lists into one ranking — commonly with Reciprocal Rank Fusion — so it catches both exact-term matches and meaning-based matches that either method alone would miss. — dense vector retrieval plus BM25 keyword search — because each catches recall the other misses.
  4. Re-ranking. A separate model re-scores the candidates by relevance to the query and reorders them, “effectively reducing the overall document pool.” Only the top survivors make it into the context.
  5. Top-k into the prompt. The best passages are concatenated with the user’s query and handed to the generator.

Chunking is the fragile link. Anthropic identified that “traditional RAG solutions remove context when encoding information” — a chunk pulled out of its document loses the surrounding context that made it meaningful. Their Contextual Retrieval technique (prepending chunk-specific context before indexing) reduced failed retrievals by 49%, and by 67% combined with re-ranking. That’s a strong signal that the chunking problem is real — and that self-contained, context-rich passages are easier to retrieve correctly.

Naive, advanced, and agentic RAG

The survey literature (Gao et al., 2023) splits RAG into a useful taxonomy:

  • Naive RAG“a traditional process that includes indexing, retrieval, and generation.” Retrieve top-k once, generate once. It “struggles with precision and recall, leading to the selection of misaligned or irrelevant chunks.”
  • Advanced RAG — adds “pre-retrieval and post-retrieval strategies.” Pre-retrieval: query rewriting and better indexing (including HyDE, where the model generates a hypothetical answer, embeds that, and retrieves documents that look like answers rather than questions). Post-retrieval: re-ranking and context compressionCompression (HTTP content encoding) shrinks text-based responses — HTML, CSS, JS, JSON, SVG, XML sitemaps — before they're sent over the network, using an algorithm like Gzip, Brotli, or Zstd, so the browser or crawler downloads fewer bytes. It's not a ranking factor, but it speeds up page loads and helps pages stay under crawler fetch limits..
  • Modular / agentic RAG — the model retrieves, reasons about what’s still missing, and retrieves again, iterating across multiple hops. This is the current state of AI searchAI search uses large language models and retrieval-augmented generation (RAG) to synthesize an answer from multiple sources rather than returning a ranked list of links. Examples include Google AI Overviews, ChatGPT Search, and Perplexity.. As Michael King put it: “The retrieve-once-then- generate pattern that defined the first wave is obsolete… Agentic RAG is now the default.”

This matters for SEO because content now has to survive multiple retrieval rounds and contradiction-checking — not just a single retrieval pass.

Does RAG eliminate hallucinations? No.

In one evaluation, Gemma answered incorrectly on 10.2% of questions with no context and 66.1% with insufficient context; this is not a universal model effect. Source: Data: Google Research

Two bars report Gemma's incorrect-answer rate in one Google Research evaluation. With no context, the rate is 10.2 percent. With insufficient context, the rate is 66.1 percent. The comparison comes from Google Research's ICLR 2025 sufficient-context study and should not be generalized to every model, dataset, or retrieval system.

RAG can ground answers in retrieved sources, but the LLM can still misread or over-interpret what it pulled. Google Research (ICLR 2025) documented a counterintuitive result in one evaluation: Gemma produced incorrect answers on 10.2% of questions with no context and 66.1% with insufficient context. The researchers report that models can “excel with sufficient context but fail to recognize when context is insufficient.” Treat that as a model- and evaluation-specific warning, not proof that retrieval universally causes worse answers. The practical lesson is narrower: retrieval quality and context sufficiency need to be evaluated rather than assumed. Google operationalized the finding as an LLM re-ranker in its Vertex AI RAG Engine.

RAG vs. fine-tuning

These get conflated constantly, and they’re fundamentally different:

  • RAG retrieves external information at query time. Weights unchanged. Best for fresh/changing information, citation requirements, and cost. The survey found “RAG consistently outperforms [unsupervised fine-tuning], for both existing knowledge encountered during training and entirely new knowledge.”
  • Fine-tuning modifies the model’s weights in a separate training run. Best for changing style and behavior, or teaching stable domain knowledge that doesn’t change.

You’d reach for RAG to make a model know the latest facts; you’d reach for fine-tuning to change how it talks.

RAG in the wild: Google, ChatGPT, Perplexity

  • Google AI OverviewsAI Overviews are the AI-generated summary box Google shows above or within its regular search results, written by Gemini models from pages retrieved out of Google's normal Search index. It's a Search feature, not a separate platform or index.. Google calls RAG “a technique (also known as groundingGrounding is anchoring an AI model's answer to source documents it retrieves at the moment you ask — not to the patterns frozen into its weights during training. Retrieval-Augmented Generation (RAG) is the most common way to do it.)… relying on our core Search ranking systems to retrieve relevant, up-to-date web pages from our Search index.” Two things follow. First, there is no separate AI index“our generative AI features on Google Search are rooted in our core Search ranking and quality systems.” Second, Google runs query fan-outQuery fan-out is the technique where an AI search system breaks a single user question into multiple related sub-queries, runs those searches concurrently, and synthesizes the retrieved results into one answer. Google confirms AI Overviews and AI Mode 'may use a query fan-out technique' issuing multiple related searches across subtopics.: “concurrent, related queries generated by the model to request more information.” A single question can spawn multiple sub-queries, each retrieving different content — so your content has to satisfy the implied sub-questions, not just the head query.
  • ChatGPT Search. Launched (October 2024) with Bing as its data partner, and OpenAI’s own crawlerA crawler — also called a spider or bot — is an automated program that fetches web pages, extracts their links, and queues new URLs to visit. Search engines use crawlers to discover and download content for their index. documentation confirms OAI-SearchBot does independent fetching and indexing for search citations, separate from GPTBot’s training-crawl. OpenAI hasn’t published the current retrieval mix between Bing and its own index, and OpenAI has since positioned ChatGPT Search as a standalone competitor to Bing rather than a wrapper around it — so treat “it’s basically Bing” as a simplification. The documented, actionable lever is narrower and more durable: don’t block OAI-SearchBot in robots.txtA plain-text file at the root of a host that tells crawlers which URLs they may and may not request. It controls crawling, not indexing — a blocked URL can still be indexed if it's linked from elsewhere., because that’s the crawler OpenAI itself names as the one that indexes content for search citations.
  • Perplexity. Built on hybrid retrieval (Vespa.ai — BM25 + dense) with custom embedding models and a strict re-ranking threshold: by third-party analysis, only the top ~30% of 60-plus retrieved sources survive to the generation stage, and “citations are not retrofitted post-generation — they are structurally assigned during context assembly.” Deep Research runs the agentic loop across dozens of searches.

What RAG means for SEO

Strip away the jargon and the playbook is concrete:

  • Being in the index is the prerequisite — full stop. No separate AI index means the crawl → index → retrieve chain has to be intact. If a page can’t be crawledCrawling is how search engines use automated bots (like Googlebot and Bingbot) to discover URLs and download pages. A page has to be crawlable to be indexed, but crawling on its own isn't a ranking factor. and indexed, it can’t be retrieved into an AI answer. The same is true for the AI engines that build their own pools: AI crawlersAI crawlers are bots from AI companies that fetch web pages to train language models, build AI-search indexes, or answer live user questions. They come in three categories, each with its own user-agent tokens and its own robots.txt controls. like OAI-SearchBot and PerplexityBot have to be allowed to fetch you, or you’re invisible to those answers.
  • Write self-contained passages. RAG retrieves fragments, not whole pages. As iPullRank’s Francine Monahan put it, AI systems examine “fragments of pages rather than the page as a whole” — so craft “stand-out passages and phrases” that answer a specific question on their own. This is exactly the H2/H3 structure and clear topic sentences good SEO already rewards. Google explicitly says not to chop your content into tiny pieces for AI — well-structured content chunks well on its own.
  • Cover the sub-topics. Query fan-out means one question can trigger many retrievals. Depth across related sub-questions beats one page stuffed around a single keyword.
  • Authority drives citation more than rank position. From an 8,000-citation analysis: “Strong organic search presence and broad web visibility leads to AI citations, not the other way around” — and “highly authoritative content from a lower-ranking page” sometimes gets cited over a less credible top-ranking one. My own data lines up (from my AI Overview citation research): mentions on heavily-linked pages are the strongest predictor of AI Overview inclusion (ρ ≈ 0.70), and branded web mentions correlated ~0.66 across 75,000 brands.
  • Fresh content has an edge. AI citationsAn AI citation is the visible source link an AI answer engine shows next to its generated text — the clickable reference that credits the web page it used. A citation's presence is a separate thing from whether the cited page actually supports the statement, and from being retrieved (read behind the scenes) or merely mentioned (named without a link); citation is driven more by brand mentions and being retrievable than by traditional ranking. skew meaningfully fresher than organic results, so currency matters.

If you want the one-sentence version: RAG didn’t replace SEO — it raised the stakes on the parts of SEO that were always about being findable and being clear.

Add an expert note

Pin an expert quote

New person? Create their unclaimed profile at /admin/experts/ → Pin a quote first.