Skip to content
AI & Machine Learning

Retrieval-Augmented Generation (RAG)

Definition

An architectural pattern where a large language model queries external data sources (like vector databases or documents) to retrieve fresh, relevant context before generating a response.

Diagram

Retrieval-augmented generationA customer asks whether they can pause their plan. The system searches the company’s indexed documents for matching passages, passes the best ones to the model along with the question, and the model answers from them, citing its sources. Documents are indexed ahead of time and kept up to date.Question“Can I pause my plan?”Searchfind matching passagesTop passagesbilling policy, FAQModelquestion + passagesAnswerwith sources citedYour documentssplit, embedded, indexedahead of timeThe model’s training never saw these;updating them updates the answers.
Most RAG problems are search problems: if the right passage isn’t retrieved, the model can’t use it, and may guess instead. Test retrieval on its own, and have the model say when the documents don’t contain the answer.

Case study

Worked example