Skip to content
←Back to glossaryAI

Retrieval-augmented generation (RAG)

An architecture combining a language model with document retrieval to ground its answers in sources, reducing hallucinations but opening a new attack surface.

Definition

NeurIPS 2020: Patrick Lewis and coauthors at Facebook AI presented the model that gave the technique its name, a generator paired with a dense vector index of Wikipedia that a neural retriever queries before each answer. Retrieval-augmented generation is an architecture that combines a large language model with a document-retrieval mechanism. Rather than answering solely from the knowledge frozen in its parameters, the model first queries a base of relevant documents and then grounds its answer in the retrieved extracts. The benefit is twofold, grounding answers in verifiable, up-to-date sources, which appreciably reduces the risk of hallucination, and allowing the system to reason over private or recent information the model never saw during training. This technique has become one of the most practical ways to make AI-based enterprise applications reliable. It does, however, introduce a new attack surface, because the retrieved documents become a route of entry for malicious instructions. An attacker who manages to insert booby-trapped content into the queried base can hijack the system's behavior through indirect prompt injection, the model treating as an instruction what was supposed to be mere data. Retrieval-augmented generation thus illustrates the permanent trade-off of AI security, in which every gain in capability opens a new vulnerability.

Its 5 cross-references, woven across the glossary's 18 categories
Retrieval-augmented generation (RAG): AI glossary illustration, AlgoPolis
Example

Textbook case: an internal corporate assistant answers employees' questions by drawing on the company's document base through retrieval-augmented generation. A corrupted document slipped into that base may contain a hidden instruction that hijacks the assistant, with no intrusion into the model itself.

Read next
Put it to work
Related terms
Related articles
Stay informed

Follow the research

One letter a week. First, the week's underwriting note, when one is published: a dated, argued decision, signed by Paul Bernardski. Then what the observatory published on cyber risk, political risk and insurance. No account, no tracking.

No spam, one-click unsubscribe, no data ever sold.