Retrieval-Augmented Generation (RAG)
Retrieval augmented generation (RAG) is a technique that combines information retrieval with language model generation, retrieving relevant information from an external knowledge base at query time and passing it to the model along with the original query to improve accuracy and ground responses in evidence.
How it works
A plain language model only knows what was in its training data, frozen at training time. RAG adds a lookup step before generation, so the model can answer from content it was never trained on — your current product catalog, this week’s documentation, a knowledge base that changes daily.
The retriever converts the query into an embedding (see Embeddings) and matches it against a vector database of your content, also pre-converted into embeddings. The closest matches come back as passages of text, which get inserted into the prompt alongside the original query — that combined prompt is what the model actually sees. The model’s answer is then grounded in those specific passages, rather than only in whatever it memorized during training.
Practical example
A documentation site indexes every page into a vector database when the content changes. When a visitor asks an AI assistant “how do I reset my API key,” the retriever finds the two or three most relevant paragraphs from the real docs, and the model answers from those paragraphs — including an answer about a feature that shipped after the model’s training cutoff, because the retrieval step, not the model’s memory, is what’s current.
SEO / GEO
RAG is why machine-readable, well-structured content matters even outside of classic search rankings: a retriever can only find and pass along content it can parse cleanly. Clear headings, one topic per page, and avoiding content that depends on JavaScript to render (see Training vs. retrieval crawlers) all make a page easier for a retriever to chunk and match correctly — a separate, practical concern from whether the page ranks well in a traditional search result list.