Home / Memory & context

WTF is RAG? (Retrieval-Augmented Generation)

mainstreamFirst seen 22 May 2020

Fetching relevant documents first and putting them in the prompt, so the model answers from real data.

Also called: retrieval augmented generation

TL;DR

Models don't know your company wiki or last week's news. RAG searches your data for the passages most relevant to the question and pastes them into the prompt, so the model can answer from them and cite them instead of guessing.

How it works

Classic RAG: chunk documents, embed the chunks into vectors, store them in a vector index; at query time, embed the question, retrieve the top-k most similar chunks (often combined with keyword search and a reranker), and insert them into the prompt. Quality depends mostly on chunking, retrieval recall and reranking, not on the generator. In agentic setups, retrieval becomes a tool the agent can call repeatedly with its own queries.

Origin

Coined / introduced by
Lewis et al. (Facebook AI Research)
When
22 May 2020
Story
Named in the 2020 paper 'Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks'.

Related jargons

Sources