What is RAG (Retrieval-Augmented Generation) and why is it used?

Reviewed by Jason Burns, Editorial Steward · Last updated

Retrieval-Augmented Generation (RAG) is a pattern that retrieves relevant documents from an external knowledge base at query time and includes them in the prompt so the language model answers grounded in that content instead of relying only on its training data. As Patrick Lewis et al., put it on the record: "We introduce RAG models where the parametric memory is a pre-trained seq2seq model and the non-parametric memory is a dense vector index of Wikipedia, accessed with a pre-trained neural retriever."

Source: arxiv.org/abs/2005.11401

Sources