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 architecture continues to evolve: a second generation, RAG 2.0, treats the system as an end-to-end search pipeline spanning information extraction, document preprocessing, indexing, and retrieval,[^c6] and multimodal variants extend the paradigm from text to images, audio, and video.[^c7] 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] Context engineering — the work of giving agents the right context at the right time, drawing on fresh data, relevant memory, and trusted knowledge — has become a critical discipline for teams building production agents.[^c8] Knowledge-graph RAG, detailed on [[knowledge-graph-rag]], adds entity and relationship structure to retrieval, while context window limits and their mitigations are covered under [[context-window]].
Deployment spans a wide spectrum, from fully managed cloud services to sovereign, air-gapped, and on-device installations. Managed services such as Amazon Bedrock Knowledge Bases simplify the entire RAG workflow,[^c10] while data-privacy pressures push enterprise workloads toward private infrastructure: by 2028, 40% of large enterprises are forecast to adopt private clouds for AI workloads to meet data-privacy requirements.[^c9] Multi-tenant SaaS products require deliberate isolation between customers, discussed under [[deployment-models]] and [[data-privacy-and-security]]. The open-source ecosystem around RAG is dominated by frameworks such as [[langchain]] and [[llamaindex]], with purpose-built engines such as [[ragflow]] and managed cloud services providing faster paths to deployment.