Retrieval-Augmented Generation
Subject: Computer and Technology noun /rɪˈtriː.vəl ɔːɡˈmɛn.tɪd ˌdʒɛn.əˈreɪ.ʃən/ 1 definition
- artificial-intelligence
- machine-learning
- information-retrieval
- natural-language-processing
-
Definition (noun)
Entry #298 · UpdatedRetrieval-Augmented Generation (RAG) is an AI architectural pattern that pairs an external information retrieval system with a generative Large Language Model (LLM) to ground responses in verifiable, non-parametric knowledge at inference time. When a query arrives, a retriever searches an indexed knowledge store—using dense vector embeddings, sparse lexical matching, or hybrid scoring—to fetch the most relevant document chunks, often followed by metadata filtering and reranking. The selected passages are injected into the LLM's prompt context window, conditioning the generator to produce grounded answers and inline citations without modifying its underlying neural weights. RAG's core purpose is to incorporate rapidly changing, proprietary, or auditable data at low cost compared to fine-tuning, while remaining bounded by retrieval recall, chunking strategy, context-window capacity, and the model's faithfulness to the supplied evidence.
Common Forms
Naive (Standard) RAG: Embeds fixed-size document chunks into a vector store, performs single-pass approximate nearest neighbor similarity search for the incoming query, and appends the top-k retrieved chunks directly to the LLM prompt.
Hybrid RAG: Combines dense vector similarity search with sparse lexical scoring (such as BM25) via Reciprocal Rank Fusion (RRF), often followed by a cross-encoder reranker to balance semantic recall with exact keyword and identifier precision.
Graph RAG: Extracts entities and relationships into a knowledge graph during indexing and traverses graph neighborhoods or community summaries at query time, enabling multi-hop reasoning across interconnected records where isolated text chunks fall short.
Agentic (Iterative) RAG: Embeds retrieval inside an autonomous reasoning loop where the LLM dynamically decides whether to retrieve, rewrites or decomposes complex queries, validates fetched context, and invokes search tools across multiple turns before generating a final answer.
Example
An internal developer support assistant indexes 120,000 Markdown runbooks into 512-token chunks stored as 1,536-dimensional embeddings alongside a BM25 lexical index in PostgreSQL with
pgvector. When an on-call engineer asks why HTTP503errors spike oncheckout-apiafter a TLS certificate rotation, the RAG service retrieves the top 4 matching chunks via hybrid search, injects them into the LLM's system prompt, and returns a step-by-step remediation citingdocs/runbooks/tls-rotation.mdin 1.2 seconds.