Retrieval-Augmented Generation
Fetching relevant documents at query time and feeding them into the prompt, so a model answers from retrieved text rather than memory.
Retrieval-Augmented Generation is a pattern where a system searches an external corpus for content relevant to a query, then inserts the retrieved passages into the Prompt before the Large Language Model generates its answer. The name comes from a 2020 paper (Lewis et al., Facebook AI Research), but the technique predates the paper's terminology by however long people had been pasting search results into a prompt by hand.
The point is to let a model answer questions about content it was never trained on, or that changed after training — a company's internal wiki, this week's news, a codebase that didn't exist at training time — without retraining or fine-tuning anything. Retrieval is usually done over an Embedding index stored in a Vector Database, where the query itself gets embedded and compared against stored document embeddings by similarity, though keyword search (BM25) and hybrid approaches are common too, especially where exact term matches matter more than semantic similarity.
RAG's core failure mode is retrieval quality, not generation quality: if the wrong passages get retrieved, the model will often generate a fluent, confident answer built on the wrong material, which reads identically to a correct answer until someone checks the source. This is a different flavor of Hallucination than ungrounded generation — the model isn't inventing facts, it's faithfully summarizing the wrong facts it was handed — and it means RAG system quality lives or dies on retrieval precision, chunking strategy, and reranking, well before the generation step gets involved.
RAG competes conceptually with just widening the Context Window and pasting everything in, and the tradeoff is mostly Token Budget: retrieval costs an indexing pipeline and adds a failure mode, but scales to corpora far larger than any context window, while a big-enough window with no retrieval is simpler until the corpus outgrows it.
See also4
Embedding
A numeric vector representing a piece of content such that semantic similarity between items becomes geometric distance between vectors.
Agents & Language Models4 connections
Vector Database
A datastore built to find the nearest neighbors of a high-dimensional vector quickly, at a scale exact search can't reach.
Agents & Language Models5 connections
Context Window
The bounded span of tokens a model can attend to in a single request.
Agents & Language Models20 connections
Hallucination
Fluent, confident output that is not grounded in anything real.
Agents & Language Models17 connections
Related1
Nearby in the graph rather than deliberately chosen. Looser, sometimes surprising.
Linked from3
- EmbeddingAgents & Language Models
A numeric vector representing a piece of content such that semantic similarity between items becomes geometric distance between vectors.
- Fine-TuningAgents & Language Models
Continuing to train an already-trained model on a narrower dataset to specialize its behavior, instead of prompting the base model.
- Vector DatabaseAgents & Language Models
A datastore built to find the nearest neighbors of a high-dimensional vector quickly, at a scale exact search can't reach.