Retrieval-augmented generation (RAG)
Retrieval-augmented generation (RAG) is an AI architecture that grounds a language model's answer by first retrieving relevant passages from an external source — a product catalog, a document index — and feeding them into the model's context, instead of relying only on what the model memorized during training. The term comes from a 2020 paper by Patrick Lewis and coauthors at Facebook AI Research, UCL, and NYU, and the pattern now underlies most AI shopping assistants and enterprise search over a company's own content.
How RAG works, step by step
A query gets converted into a vector embedding, that vector is compared against an index of embedded content (product pages, spec sheets, documentation) to find the closest matches, and the retrieved passages are inserted into the model's prompt as context before it generates a response. The model still writes the answer, but it's writing from what was just handed to it rather than purely from training data.
The practical advantage: updating what the system "knows" means re-indexing the source content, not retraining the model. A new spec sheet or a corrected attribute becomes available to the system the next time it's indexed.
Why RAG matters for product data
AI shopping assistants and answer engines run a retrieval step before they compose a recommendation or answer a spec question — they search your product content, pull the passages that look relevant, and generate a response grounded in what they found. If a product's specifications, compatibility notes, or application context live in an unstructured PDF that never gets indexed, or are split across duplicate records with conflicting values, the retrieval step either misses it or hands the model something to reconcile mid-answer. Content that's structured, deduplicated, and chunked around the questions buyers actually ask is what a retrieval step can reliably surface.
RAG vs. semantic search vs. AEO
These three get used almost interchangeably and shouldn't be.
| Term | What it is |
|---|---|
| Semantic search | The retrieval mechanism alone: matching a query to content by meaning, returning ranked results |
| RAG | Semantic search's output fed into a language model, which generates a synthesized answer from it |
| AEO | The practice of structuring your content so a RAG-style pipeline retrieves and cites your product as that answer |
Semantic search is the machinery that finds candidate passages. RAG is that machinery plus generation. AEO is optimizing your content for both stages, so you're the passage that gets retrieved and the one the generated answer relies on.
What breaks RAG pipelines
- Duplicate or conflicting records. If two records describe the same SKU with different specs, retrieval can surface either one, and the generated answer inherits whichever it picked.
- Content that never gets indexed. A spec locked inside a scanned PDF or an image with no text layer is invisible to the retrieval step no matter how accurate it is.
- Missing attributes. If the fact a query needs was never captured as data, no amount of good retrieval finds it — there's nothing to retrieve.
- Inconsistent terminology. A query using "corrosion resistant" won't reliably retrieve a passage that only says "316 stainless," even though a person would connect the two.
Frequently asked questions
Who coined the term retrieval-augmented generation?
Patrick Lewis and coauthors, in a 2020 paper from Facebook AI Research (now Meta AI), University College London, and NYU, presented at NeurIPS 2020. The paper combined a retrieval step with a sequence-to-sequence generator and named the resulting pattern RAG.
Does RAG require retraining the model?
No — that's the core advantage. Updating the retrieval index with new or corrected content changes what the system can answer, without any model fine-tuning or retraining.
Is RAG the same as fine-tuning?
No. Fine-tuning changes the model's weights using training examples. RAG leaves the model as-is and instead supplies it with retrieved context at query time. The two are sometimes combined, but they solve different problems.
How does RAG relate to answer engine optimization?
AEO is the practice of shaping product content so it performs well inside a RAG-style pipeline — structured enough to be retrieved accurately, and clear enough that the generated answer cites it as the direct answer to the buyer's query.