Retrieval and search · MLD-1033
Retrieval-augmented generation
Generating outputs conditioned on information retrieved from an external collection during the workflow.
Expanded guide · editorial review 2026-11-01. Original definitions, examples, notes and citations are preserved below. New examples are illustrative, not benchmark results.
Prerequisites
How it works
Retrieval-augmented generation combines a retriever with a generator. A retriever selects relevant material from an external collection; the generator conditions its response on that material. This separates some updateable knowledge from model weights. The original RAG paper studies trained retrieval-generation systems; modern prompt-based pipelines are related engineering designs.
Worked example
For a campus policy assistant, index approved policies with document identifiers and revision dates. Retrieve passages for a question, provide them to the generator and require citations. If the relevant rule is absent, the assistant should report that limitation. This is a proposed design, not a tested deployment.
A useful pipeline
question -> retrieve candidates -> rerank -> assemble context -> generate -> check cited evidence. Evaluate each stage so generation cannot hide retrieval failures.
What to test
Use questions with known supporting passages. Measure retrieval recall separately from answer correctness and citation support. Include stale documents, contradictory passages and questions outside the collection.
Common pitfall
Retrieval does not guarantee grounding. An answer can cite a real document that fails to support its specific claim.
Sources for the expanded explanation
Editorial synthesis checked against the linked primary material; no independent replication is claimed.
Original example
Answer using passages from a document index.
Original caveat
Retrieval does not guarantee that generated claims are supported.
Context and aliases
Level: Intermediate. Stages: Data · Retrieval · Inference · Evaluation.
Tags: ML · NLP · SLM · LLM · IR.
Aliases: RAG.
Related concepts
Concepts linking here
Technology connections
- CrewAI — Framework for role-oriented multi-agent workflows.
- DSPy — Programming and optimization framework for language-model pipelines.
- Haystack — Composable pipelines for search and language-model applications.
- LangChain — Integrations and abstractions for building model-powered applications.
- LangGraph — Stateful graph-based agent orchestration.
- LlamaIndex — Data connectors, indexing and retrieval components for LLM applications.
- Microsoft Agent Framework — Framework for building and coordinating agents with enterprise integrations.
- OpenAI Agents SDK — SDK for model-driven tools, handoffs and tracing.
- PydanticAI — Typed agent framework built around Python and Pydantic.
- Semantic Kernel — SDK for integrating models, functions and orchestration into applications.
- smolagents — Lightweight library for agents using model-selected tools and code.
- Temporal — Durable workflow execution platform.