# Retrieval-augmented generation: how AI search reads before it answers

> Retrieval-augmented generation (RAG) is a technique where a language model first retrieves relevant documents, then writes its answer from them. It was named in a 2020 paper by Lewis et al. AI search engines use it with web search as the retriever, which is why their answers can cite pages published after the model was trained.

Source: https://surfacedd.com/glossary/retrieval-augmented-generation · Updated 2026-11-19

## What is retrieval-augmented generation?

Retrieval-augmented generation (RAG) is a way of building AI answers in two steps: **retrieve** documents relevant to the question, then **generate** an answer using them as context. The term comes from a 2020 paper by Patrick Lewis and colleagues, which described models that "combine pre-trained parametric and non-parametric memory for language generation" ([Lewis et al., arXiv 2005.11401](https://arxiv.org/abs/2005.11401)).

Those two kinds of memory are the whole idea, in plain words:

- **Parametric memory** is what the model learned in training, stored in its weights. It's fixed at the training cut-off and can't point to where a fact came from.
- **Non-parametric memory** is an external store the model can look things up in. In the original paper it was "a dense vector index of Wikipedia", searched with a neural retriever. In AI search it's the web, reached through a search engine.

The paper's motivation still describes the problem today: models that only use their weights have limited ability to "access and precisely manipulate knowledge". Retrieval lets the model work from current, specific text, and lets it say which document it used.

## How RAG works in AI search engines

When ChatGPT search, Perplexity, Gemini with grounding or Claude with web search answers a question, the pipeline looks like this:

| Step | What happens | Where your page can drop out |
|---|---|---|
| 1. Decide | The model decides whether the question needs a search | Questions about stable facts often skip retrieval entirely |
| 2. Fan out | It writes one or more search queries, often several | Your page doesn't match any of the [fan-out queries](/guides/query-fan-out) |
| 3. Retrieve | The search back-end returns results; pages are fetched | The engine's crawler is blocked, or the page isn't in its index |
| 4. Select | Passages from the results go into the model's context | Your page is fetched but its useful part is buried or missing |
| 5. Generate and cite | The model writes the answer and attaches citations | It read your page but cited another one |

The web-search version of RAG is usually called [grounding](/glossary/grounding). Each engine's API exposes parts of this pipeline: the queries it ran, the sources it cited, and for some engines the sources it read without citing. 

## A worked example: the same question, with and without retrieval

The quickest way to see RAG at work is to ask one question twice: once to a model with no tools, which can only use its parametric memory, and once with web search on. Surfacedd's Brand Audit does exactly this: it asks two prompts (one about information, one about reputation) across six runs, three with web search on and three training-only. 

Here is what the comparison tells you, illustrated with a fictional brand that changed its pricing model three months ago:

| What you see | Training-only answer | Web-on (RAG) answer | What it means |
|---|---|---|---|
| Pricing description | Old per-seat pricing | New flat pricing, citing the pricing page | Retrieval has caught up. The model's memory will lag until its next training cycle |
| Product list | Missing the newest product | Includes it, citing a review site | Your own page isn't the one retrieved for this; a third party is |
| Founding year | Correct | Correct | Stable fact, both routes agree |
| Reputation | Neutral | Mixed, citing a forum thread | A live source is shaping the answer. That's the page to look at |

The fix differs by column. A wrong training-only answer is slow to change: you influence future training data by keeping facts consistent everywhere, and the [LLM SEO guide](/guides/llm-seo) covers what's realistic there. A wrong web-on answer is fast to change, because it comes from a page that exists today, can be identified from the citation, and can be corrected or out-competed.

## What RAG means for the pages you publish

Because retrieval works on passages, not whole sites, a few habits raise your odds of being selected in step 4:

- **Answer the question in the first sentence or two under each heading.** Engines lift passages, so a section that only makes sense after reading the three before it is a weak candidate.
- **Put facts in server-rendered HTML.** Many AI crawlers don't run JavaScript; a price that only appears after a script runs may never reach the model. 
- **State facts with their entity and unit.** "Plan X costs Y per month, billed yearly, as of November 2026" survives being lifted out of context. "It's affordable" doesn't.
- **Let the right crawlers in.** Blocking an engine's search crawler removes you at step 3, however good the page is. See the [OAI-SearchBot](/glossary/oai-searchbot) and [PerplexityBot](/glossary/perplexitybot) entries.

None of these makes a citation certain. They remove reasons for your page to drop out.

## In Surfacedd

Brand Audit puts the training-only and web-on answers side by side for the same prompts, lists the pages each live answer cited, and scores each cited page for how well it matches your facts (alignment, 0–100) and how quotable it is (citability, 0–100), with a recommended action. That tells you which column of the table above you're dealing with before you spend time on a fix. An audit costs a few cents in API fees, shown before it runs. 

![Brand Audit showing 5 of 6 AI setups naming the brand, with each model's information and reputation verdict labelled web or training only](https://surfacedd.com/shots/app/brand-audit-detail-light.png "Sample workspace, fictional brand")
For ongoing tracking, every answer Surfacedd collects stores the search queries the engine ran and the sources it cited, so you can see steps 2 to 5 for your own prompts. See [Brand Audit](/features/brand-audit) for the feature, or [pricing](/pricing) for the one-time licence. 

## Related terms

- [Grounding](/glossary/grounding): RAG with a web search engine as the retriever.
- [AI citation](/glossary/ai-citation): the link a RAG answer gives the page it used.
- [CCBot](/glossary/ccbot): a crawler that feeds training data, the other route into a model.
- [AI hallucination](/glossary/ai-hallucination): what retrieval reduces, and what it can't fix when the retrieved page is wrong.

## Sources

- [Lewis et al., "Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks" (arXiv 2005.11401)](https://arxiv.org/abs/2005.11401), checked 2026-11-19
- [Web search tool (OpenAI API docs)](https://developers.openai.com/api/docs/guides/tools-web-search), checked 2026-11-19
- [Grounding with Google Search (Google AI Studio)](https://aistudio.google.com/docs/google-search), checked 2026-11-19
