Retrieval-Augmented Generation
Retrieval-Augmented Generation (RAG) is the dominant production architecture for grounding large language models in external knowledge, combining a language model's text generation ability with an external information retrieval process. A standard LLM is like a student taking a closed-book exam, answering from memory; a RAG system is like an open-book exam, where the student can look up answers from reference text.[^c5]
The paradigm was introduced by Lewis et al. in 2020, combining a pre-trained sequence-to-sequence model as parametric memory with a dense vector index of Wikipedia accessed through a neural retriever as non-parametric memory.[^c1] It exists because LLMs are trained on enormous bodies of data but not on any particular organization's data; RAG solves this by adding that data to what the model can access.[^c2] At query time, RAG grounds the model in external knowledge by retrieving relevant passages and injecting them into the prompt.[^c3] This reduces hallucination, provides up-to-date and domain-specific information, and makes citations and attribution possible.
A production RAG system spans the full lifecycle: ingestion parses and cleans documents, indexing chunks and embeds them into vector and keyword stores, retrieval searches those indexes and fuses and re-ranks candidates, and generation integrates the retrieved context into the prompt before the LLM answers. The pipeline is engineered around foundational concepts such as [[embeddings]], [[chunking]], [[vector-databases]], [[hybrid-search]], and [[re-ranking]], and is operated with the practices described under [[monitoring-and-observability]], [[evaluation-metrics]], and [[cost-optimization]].
As the field has matured, the architecture has grown beyond a single retrieve-then-generate loop. Agentic variants orchestrate iterative retrieval, query rewriting, and multi-hop reasoning, and alternative patterns such as Cache-Augmented Generation load the whole corpus into a long-context prompt and reuse it, where RAG retrieves a few chunks per query.[^c4] The open-source ecosystem around RAG is dominated by frameworks such as [[langchain]] and [[llamaindex]], with purpose-built engines and managed cloud services providing faster paths to deployment.