Retrieval-augmented generation (RAG)

Grounding a model's answers in your own documents and data by retrieving the relevant passages first and giving them to the model with the question.

Definition

RAG was described in a 2020 research paper by Lewis and colleagues. In a RAG system, a question is first used to search a knowledge source, usually with embeddings and a vector database, sometimes combined with keyword search. The best-matching passages are added to the model's context, and the model answers from them, ideally citing them.

RAG lets a general model answer from up-to-date, private information without retraining it, and makes answers easier to check. Its quality depends mostly on the retrieval: if the right passage is not found, the model will answer from memory or guess. Many enterprise AI projects are, at their core, RAG over company documents.

Sources

  1. Lewis et al., Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks (2020)