Retrieval-augmented generation
Retrieval-augmented generation is a technique that retrieves relevant information from external sources and supplies it as context to a generative model when producing an output.
Retrieval Augmented Generation, The Foundational Ideas
Retrieval-augmented generation (RAG) supplies retrieved external information to a language model before it generates a response.
- How it is used
- Connects language models to changing or private knowledge to produce answers grounded in retrieved evidence.
- How deep it goes
- Explains offline indexing, query-time stages, a naive pipeline, and canonical document marginalization, including sequence- versus token-level choices.
- Examples
- Uses warranty support, a contradictory airline-policy answer, and a probability calculation comparing evidence split across passages.
- What you can do after
- Build it from scratch as a retrieve-then-generate baseline, then diagnose whether retrieval or generation needs improvement.
Grokking AI Applications
A generative AI technique that retrieves relevant external information and supplies it to a model as context for generation.
- How it is used
- Connects language models to changeable, organization-specific knowledge for contextual answers.
- How deep it goes
- Explains ingestion, retrieval, and generation, then demonstrates a working flow and tuning choices.
- Examples
- Uses a pizza restaurant PDF and a cookbook search to illustrate document-grounded assistants.
- What you can do after
- Apply it via Langflow to build and tune a document-grounded question-answering flow.
Read how Grokking AI Applications explains retrieval-augmented generation →
Effective Conversational AI
Retrieval-augmented generation is a technique that conditions generated responses on information retrieved from external documents or data sources.
- How it is used
- Answers long-tail chatbot questions by generating responses from retrieved documents instead of requiring a predefined answer for every intent.
- How deep it goes
- Works through retrieval, generation, document preparation, fallback decisions, and component-level evaluation, with implementation kept largely high-level.
- Examples
- Contrasts a generic response with a document-grounded answer to an ibuprofen question and compares intent, search, and RAG chatbots.
- What you can do after
- Evaluate/understand it by checking answer relevance, user context, grounding, retrieval quality, and whether weak evidence calls for handover.
Read how Effective Conversational AI explains retrieval-augmented generation →
Build an Advanced RAG Application (From Scratch)
Retrieval-augmented generation is a generation technique that retrieves relevant external information and supplies it to a language model when producing a response.
- How it is used
- Grounds conversational search and question answering in retrieved domain information before generating a natural-language response.
- How deep it goes
- Builds complete retrieval-to-generation pipelines, including embeddings, chunking, FAISS or Qdrant storage, prompting, and joint evaluation.
- Examples
- Demonstrates Paris hotel recommendations from review retrieval and research-paper answers from chunked DBLP abstracts.
- What you can do after
- Build RAG assistants that retrieve semantic context, generate cited answers, and evaluate retrieval and answer quality.
Read how Build an Advanced RAG Application (From Scratch) explains retrieval-augmented generation →
Domain-Specific Small Language Models
An application system that combines retrieval from external sources with text generation to ground outputs in outside knowledge.
- How it is used
- Supplies external, potentially recent or private information to a language model at answer time.
- How deep it goes
- Works through document preparation, embedding search, prompt construction, generation, tradeoffs, and phase-specific evaluation.
- Examples
- Uses a PDF question-answering prototype and a FAISS similarity-search exercise to illustrate retrieval.
- What you can do after
- Build it from scratch with small models, document chunks, embedding search, and context-enriched prompts; evaluate retrieval and generation separately.
Read how Domain-Specific Small Language Models explains retrieval-augmented generation →
Software Testing with Generative AI
Retrieval-augmented generation is a generation technique that retrieves relevant external information and supplies it to a language model as context.
- How it is used
- Improves testing and software-development responses by injecting task-relevant project context into language-model prompts.
- How deep it goes
- Explains retrieval, prompt assembly, corpus ingestion, similarity matching, vector databases, implementation, and failure modes.
- Examples
- Demonstrates page-object generation, user-story retrieval, booking tests, and PUT branding payload-risk recommendations.
- What you can do after
- Build it from scratch using a document corpus, similarity search, prompt construction, an LLM API, and response parsing.
Read how Software Testing with Generative AI explains retrieval-augmented generation →
Enterprise RAG
A RAG system combines information retrieval with language-model generation to answer questions using retrieved evidence.
- How it is used
- Answers business questions in plain language by retrieving current information from company sources before generation.
- How deep it goes
- Builds the full system workflow from evaluation and ingestion through retrieval agents and answer generation, while flagging production design constraints.
- Examples
- Uses product lookup, coffee inventory, earnings calls, hospital records, financial reports, and electronics manuals as retrieval tasks.
- What you can do after
- Build it from scratch as an enterprise RAG question-answer system with evaluation, ingestion, retrieval, and generation stages.
Read how Enterprise RAG explains retrieval-augmented generation →
LLMs in Production
Retrieval-augmented generation is a technique that supplies a generative model with information retrieved from external sources at response time.
- How it is used
- Supplies external context at inference time to ground responses and customize assistants without fine-tuning.
- How deep it goes
- Walks through ingestion, similarity search, prompt construction, token budgeting, and retrieval testing, with a comparison against a no-RAG baseline.
- Examples
- Uses Wikipedia question answering and a Python coding copilot to demonstrate retrieval and its limitations.
- What you can do after
- Apply it via Pinecone, LangChain, and Milvus to retrieve context, construct prompts, and test results against a baseline.
Read how LLMs in Production explains retrieval-augmented generation →
LLM Customization and Fine-Tuning
A technique that retrieves relevant external information and supplies it to a generative model when producing a response.
- How it is used
- Uses retrieval to supply changing or proprietary knowledge at inference time without retraining model weights.
- How deep it goes
- Works through a minimal retrieval pipeline, separate evaluation measures, production extensions, and failure diagnostics.
- Examples
- Uses earnings-call questions and legal contract review to distinguish fresh knowledge from learned behavior.
- What you can do after
- Build a minimal retrieval pipeline and diagnose retrieval, grounding, and latency failures.
Read how LLM Customization and Fine-Tuning explains retrieval-augmented generation →
AI-Powered Search
Retrieval augmented generation is a technique that supplies retrieved external information to a generative model as context for producing a response.
- How it is used
- Uses search as an external knowledge source for generative answers and summaries.
- How deep it goes
- Explains chunk indexing, vector retrieval, and prompt construction, then demonstrates a cited summary.
- Examples
- Uses a query about large language models, numbered web results, citations, and a concise-prompt refinement.
- What you can do after
- Apply it via GPT-4 to summarize retrieved search results with citations.
Read how AI-Powered Search explains retrieval-augmented generation →
Natural Language Processing in Action, Second Edition
Retrieval-augmented generation is a language-generation technique that retrieves external information and conditions generation on the retrieved information.
- How it is used
- Uses retrieval to ground question-answering and chatbot responses in a relevant document collection.
- How deep it goes
- Builds a retriever-to-prompt pipeline and demonstrates source-based answering and abstention.
- Examples
- Tests questions about LSTMs and RNNs, the Louvre, and artificial intelligence saving the world.
- What you can do after
- Apply it via Haystack by connecting a retriever to a PromptNode and querying retrieved documents.
Machine Learning Platform Engineering
Retrieval-augmented generation is a method that supplies retrieved external information to a generative model when producing an output.
- How it is used
- Powers a natural-language documentation assistant by retrieving relevant company information before generating an answer.
- How deep it goes
- Works through document ingestion, embeddings, vector search, prompt construction, and generation, then addresses operational evaluation and safety.
- Examples
- Uses an internal documentation chatbot, API-key rotation questions, a manual retrieval pipeline, and a LangChain RetrievalQA chain.
- What you can do after
- Build it from scratch as a document-to-answer pipeline, then evaluate retrieval, responses, costs, and safety before deployment.
Read how Machine Learning Platform Engineering explains retrieval-augmented generation →
Building Reliable AI Systems
A retrieval-augmented generation approach that retrieves and synthesizes stored information without taking actions in the real world.
- How it is used
- Grounds customer-facing answers in changing external documents and data rather than relying only on model training.
- How deep it goes
- Explains indexing, retrieval, context integration, generation, and evaluation, including implementation trade-offs and failure modes.
- Examples
- Uses retail return policies and warranty questions, plus an e-commerce chatbot and a health-care policy assistant.
- What you can do after
- Apply it via LangChain and vector search to build a grounded question-answering pipeline with source information.
Read how Building Reliable AI Systems explains retrieval-augmented generation →
Build AI-Enhanced Web Apps
Retrieval-augmented grounding is a grounding technique that retrieves relevant external information and incorporates it into response generation.
- How it is used
- Grounds conversational answers in retrieved document context rather than pretrained knowledge alone.
- How deep it goes
- Walks through indexing, retrieval, prompt augmentation, generation, and server integration, focusing on key implementation excerpts.
- Examples
- Uses a PDF-indexing chat application and a multi-knowledge-base assistant accepting PDF and DOCX documents.
- What you can do after
- Apply it via LangChain.js to index documents and connect retrieval-augmented queries to a web application.
Read how Build AI-Enhanced Web Apps explains retrieval-augmented generation →
The Art of AI Product Development
An architecture that retrieves relevant external information and supplies it to a generative model as context for producing an output.
- How it is used
- Connects language models to domain-specific, current knowledge for question answering and content generation.
- How deep it goes
- Develops an end-to-end workflow with model selection, component and system evaluation, and retrieval and prompt optimization.
- Examples
- Uses a marketing content app and an AI-trends query narrowed to SaaS and workflow automation.
- What you can do after
- Evaluate and improve a RAG system by testing retrieval and generation separately and assessing overall response quality.
Read how The Art of AI Product Development explains retrieval-augmented generation →
Generative AI in Action
Retrieval-augmented generation is a generation technique that retrieves relevant external information and supplies it to a generative model as context for its response.
- How it is used
- Grounds enterprise language-model responses in current or proprietary data, particularly for chat and question answering.
- How deep it goes
- Explains retrieval architecture and pipeline planning, then demonstrates an end-to-end chat implementation while identifying additional production engineering needs.
- Examples
- Uses a Redis-indexed blog chatbot that retrieves five matching chunks and prompts for a fallback when no answer is found.
- What you can do after
- Apply it using Redis vector search and a language model to create a chat application over indexed data.
Read how Generative AI in Action explains retrieval-augmented generation →
Financial AI in Practice
A method that retrieves relevant external information and supplies it to a generative model when producing an output.
- How it is used
- Grounds financial assistants and qualitative market analysis in current, domain-specific information.
- How deep it goes
- Details ingestion, embedding, retrieval, prompting, and operational controls, including chunking choices and freshness risks.
- Examples
- Uses a news-to-JSON market research pipeline and fraud investigation documents to illustrate retrieval and controls.
- What you can do after
- Build a news retrieval feature pipeline and use retrieved context to produce structured qualitative signals.
Read how Financial AI in Practice explains retrieval-augmented generation →
Introduction to Generative AI, Second Edition
Retrieval-augmented generation is a generative technique that retrieves external information and supplies it to a model as context before generation.
- How it is used
- Uses retrieval to ground customer-service and enterprise question answering in context-specific documents.
- How deep it goes
- Explains the pipeline from document embeddings and similarity search to context insertion, while noting that implementations vary.
- Examples
- Illustrates retrieval with a company travel-expense question and a restaurant recommendation informed by prior preferences and reviews.
- What you can do after
- Evaluate how retrieval can support more grounded answers and why source quality and verification still matter.
Read how Introduction to Generative AI, Second Edition explains retrieval-augmented generation →
AI Agents and Applications
Retrieval-augmented generation is a technique that retrieves relevant external information and supplies it to a language model as context for response generation.
- How it is used
- Uses retrieval to ground knowledge-base Q&A in external documents rather than pretrained knowledge alone.
- How deep it goes
- Explains ingestion and query stages, then implements a basic chatbot with separate retrieval, prompting, and generation functions.
- Examples
- Uses questions about Paestum’s temples to demonstrate retrieval, answer synthesis, and an explicit admission of missing information.
- What you can do after
- Builds a basic RAG chatbot using ChromaDB and OpenAI, with explicit functions for retrieval, prompting, and generation.
Read how AI Agents and Applications explains retrieval-augmented generation →
Data Pipelines with Apache Airflow, Second Edition
A RAG workflow is a retrieval-augmented generation workflow that retrieves relevant information and supplies it to a generative model for producing an output.
- How it is used
- Answers questions from an expanding recipe collection by retrieving relevant content for a language model instead of retraining it after additions.
- How deep it goes
- Works through ingestion, two-part chunking, embedding, similarity search, and answer generation; leaves embedding-model training details aside.
- Examples
- Uses family recipes, a lasagna question, a two-dimensional flavor analogy, and a recipe chat assistant.
- What you can do after
- Build it from scratch with Airflow-managed recipe ingestion, Weaviate retrieval, and a language-model response to a user question.
Investing for Programmers
Retrieval-augmented generation is a technique that retrieves relevant external information and supplies it to a generative model when producing a response.
- How it is used
- Deploys external information as additional model context for financial research, specialized questions, and agent workflows.
- How deep it goes
- Explains document loading, chunking, embeddings, similarity retrieval, prompting, and graph execution, while deferring broader data-source coverage.
- Examples
- Demonstrates company files, earnings transcripts, investor preferences, autonomous-driving research, and a LangGraph retrieve-generate pipeline.
- What you can do after
- Build it from scratch with LangChain and LangGraph by loading documents, indexing chunks, retrieving context, and generating an answer.
Read how Investing for Programmers explains retrieval-augmented generation →
Knowledge Graphs and LLMs in Action
Retrieval-augmented generation is a technique that supplies a generative language model with relevant information retrieved from an external source before answer generation.
- How it is used
- Deploys LLMs as grounded assistants for private-data question answering and other enterprise workflows.
- How deep it goes
- Explains the retrieval-generation pipeline, vector implementation, graph extension, and failure modes, but defers complete production validation.
- Examples
- Uses weather APIs, cyclotron research documents, proprietary influence networks, and CASE123 witness statements.
- What you can do after
- Build it from scratch as a vector-search assistant that retrieves context and generates grounded answers, then evaluate retrieval failures.
Read how Knowledge Graphs and LLMs in Action explains retrieval-augmented generation →
Build Python Web Apps with Streamlit
Retrieval-augmented generation is a technique that retrieves relevant external information and supplies it to a language model when generating a response.
- How it is used
- Provides a customer service chatbot with relevant private company knowledge for answering queries.
- How deep it goes
- Explains the RAG workflow and implements document ingestion, similarity search, and prompt augmentation.
- Examples
- Uses product and fountain pen maintenance support articles to supply a customer service chatbot with context.
- What you can do after
- Apply it via LangChain, Pinecone, and LangGraph to retrieve support articles and augment a chatbot’s prompt.
Read how Build Python Web Apps with Streamlit explains retrieval-augmented generation →
Data Storytelling with Altair and AI
Retrieval-augmented generation is a technique that supplies a language model with relevant information retrieved from an external knowledge source when generating output.
- How it is used
- Adds domain-specific context for generating data-story commentaries and annotations.
- How deep it goes
- Builds a complete HTML-to-vector-database retrieval pipeline, including chunking, embeddings, prompting, and querying.
- Examples
- Demonstrates smartphone-description answers, FDA-based aquaculture commentary, and a PDF-report annotation exercise.
- What you can do after
- Apply it via LangChain, Chroma, and OpenAI to generate source-grounded commentaries from external documents.
Read how Data Storytelling with Altair and AI explains retrieval-augmented generation →
AI Agents in Action, Second Edition
Retrieval-augmented generation is a technique that retrieves pertinent information at generation or decision time and adds it to a model's context.
- How it is used
- Supplies task-specific knowledge and user memory to agents when they answer or make decisions.
- How deep it goes
- Explains ingestion and retrieval step by step, then gives practical guidance on hybrid search, grounding, scaling, and access boundaries.
- Examples
- Illustrates retrieval with a capital-of-France query and a support agent searching manuals, policies, and release notes.
- What you can do after
- Operate/configure retrieval by selecting search methods, filtering metadata, grounding answers, and limiting access to sensitive content.
Read how AI Agents in Action, Second Edition explains retrieval-augmented generation →
Spring AI in Action
Retrieval-augmented generation is a technique that supplies retrieved external information to a generative model when producing a response.
- How it is used
- Enables Spring AI applications to answer questions about private, recent, or otherwise untrained document content.
- How deep it goes
- Explains chunking, embeddings, vector storage, similarity search, metadata filters, prompt injection, and retrieval controls.
- Examples
- Demonstrates a board-game assistant retrieving Burger Battle and Carcassonne rule chunks through a Qdrant-backed service.
- What you can do after
- Build it from scratch by loading documents, querying a vector store, and injecting retrieved context into a Spring AI prompt.
Read how Spring AI in Action explains retrieval-augmented generation →
Just Use Postgres!
Retrieval-augmented generation is a technique in which a generative model incorporates information retrieved from an external knowledge source when generating an answer.
- How it is used
- Deploys private data and knowledge bases to make conversational answers more relevant or task-specific.
- How deep it goes
- Traces retrieval, augmentation, and generation through a Python prototype, stopping short of comprehensive production guidance.
- Examples
- Demonstrates conversational movie recommendations using pirate-film questions, retrieved records, and TinyLlama-generated answers.
- What you can do after
- Apply it via Python, Ollama, LangChain, Postgres, and pgvector to retrieve context and generate answers.
Read how Just Use Postgres! explains retrieval-augmented generation →
Architecting for Autonomy
A pattern that retrieves relevant external information and supplies it to a model as context for producing an output.
- How it is used
- Connects agents to enterprise data while governing how candidate knowledge enters their working context.
- How deep it goes
- Defines retrieval’s role and authority boundaries, with governance guidance but no retrieval implementation details.
- Examples
- Uses a contract dispute involving an amendment, competing agreement versions, and judgments from different jurisdictions.
- What you can do after
- Evaluate whether retrieved information has sufficient authority for a decision and respond when the governing source cannot be established.
Read how Architecting for Autonomy explains retrieval-augmented generation →
Building Specialized AI Systems
A system that retrieves relevant external information and supplies it to a generative model to augment its response.
- How it is used
- Provides external knowledge to language-model responses when retrieval is essential and standard output formats are acceptable.
- How deep it goes
- Explains chunk storage, vector representations, retrieval, and generation, but defers implementation details and RAG variations.
- Examples
- Uses a drug-interaction scenario to contrast retrieved facts with patient-specific clinical judgment.
- What you can do after
- Evaluate/understand whether RAG, RAG plus fine-tuning, or RAG plus few-shot learning fits external-knowledge and personalization needs.
Read how Building Specialized AI Systems explains retrieval-augmented generation →
Transformers in Action
A retrieval-augmented generation system generates outputs using information retrieved from an external collection.
- How it is used
- Grounds language-model responses in current or domain-specific external information without changing model weights.
- How deep it goes
- Explains indexing, retrieval, generation, optional refinement, and tuning, with pipeline and reranking implementations.
- Examples
- Uses a legal policy assistant, a web-page question-answering pipeline, and financial question answering with reranking.
- What you can do after
- Apply it via LangChain, Chroma, and OpenAI embeddings, with optional Flashrank reranking.
Read how Transformers in Action explains retrieval-augmented generation →
Vibe Engineering
Retrieval-augmented generation is a technique that retrieves relevant external information and supplies it as context for a language model's generated response.
- How it is used
- Selects repository context for coding-agent queries without loading the entire codebase into the prompt.
- How deep it goes
- Explains indexing, embedding-based retrieval, prompt augmentation, and manual context overrides, then distinguishes retrieval from persistent memory.
- Examples
- Uses an authentication repair request to retrieve a login handler and its related tests.
- What you can do after
- Evaluate retrieval context and intervene with file pinning, directory mentions, path exclusions, or a clean session when automatic selection drifts.
Read how Vibe Engineering explains retrieval-augmented generation →
LLM Evaluation and Alignment, The Foundational Ideas
Retrieval-augmented generation is a generation technique that retrieves external information and incorporates it into model responses.
- How it is used
- Grounds model responses in retrieved, verifiable information for narrow-domain or up-to-date questions.
- How deep it goes
- Explains retrieval, generation, agentic variants, failure modes, and evaluation metrics without detailing implementation algorithms.
- Examples
- Uses a financial research assistant, earnings reports, retrieved passages, unsupported claims, and a single-turn architecture diagram.
- What you can do after
- Evaluate retrieval and generation independently, diagnose hallucination causes, and select metrics for RAG production monitoring.
AI Agents in Action
Retrieval augmented generation is a language-model pattern that retrieves relevant external information and incorporates it into generated responses.
- How it is used
- Supports document question answering and supplies retrieved context to agent prompts.
- How deep it goes
- Walks through document indexing and query-time retrieval, then demonstrates knowledge-store setup and retrieval testing.
- Examples
- Uses a movie script for agent question answering and rephrased nursery-rhyme queries to test semantic retrieval.
- What you can do after
- Apply RAG via LangChain to a chosen application and test the workflow’s effectiveness.
Read how AI Agents in Action explains retrieval-augmented generation →
MongoDB 8.0 in Action, Third Edition
Retrieval-augmented generation is an AI technique that retrieves external information and supplies it to a generative model when producing a response.
- How it is used
- Grounds chatbot answers in retrieved external information to reduce plausible but incorrect responses.
- How deep it goes
- Walks through document chunking, embeddings, vector retrieval, prompt assembly, and generation, then describes a LangChain-orchestrated chatbot.
- Examples
- Uses an Atlas best-practices chatbot grounded in PDF documentation and GPT-4 responses.
- What you can do after
- Apply it via LangChain and Atlas Vector Search to retrieve documentation as context for a GPT-4 chatbot.
Read how MongoDB 8.0 in Action, Third Edition explains retrieval-augmented generation →
Designing AI Systems
A retrieval-augmented generation pipeline retrieves relevant context and supplies it to a generative model when producing a response.
- How it is used
- Grounds organizational assistant responses in retrieved documents, with basic and model-controlled retrieval options.
- How deep it goes
- Explains ingestion and semantic retrieval, then illustrates workflow integration, score filtering, source attribution, and a model-controlled search tool.
- Examples
- Uses an electronics return policy and an organizational assistant answering policy and planning questions.
- What you can do after
- Apply it via the Data Service to retrieve source-attributed context and tune a relevance threshold.
Read how Designing AI Systems explains retrieval-augmented generation →
Essential GraphRAG
A retrieval-augmented generation pipeline combines information retrieval with language-model generation to produce responses grounded in retrieved information.
- How it is used
- Improves language-model accuracy by supplying current, private, domain-specific, or structured information at query time.
- How deep it goes
- Explains retrieval and generation, implements vector and advanced pipelines, and extends the pattern with knowledge graphs.
- Examples
- Uses an Einstein inventions paper, an Einstein patent question, prompt templates, vector-search data flows, and The Odyssey graph pipeline.
- What you can do after
- Build it from scratch as a vector-search RAG pipeline and evaluate step-back prompting against a simpler retrieval approach.
Read how Essential GraphRAG explains retrieval-augmented generation →
Machine Learning System Design
A generation approach that retrieves relevant external information and supplies it to a generative model as input.
- How it is used
- Uses retrieval to provide external, relevant information as input to a generative model.
- How deep it goes
- Defines the retrieval-and-prompting pattern but does not detail retrieval quality, indexing, prompting, or production operations.
- Examples
- Uses domain-specific LLM solutions that pull relevant data from a vector database before generation.
- What you can do after
- Apply it by retrieving relevant external data and inserting that data into a generative model’s prompt.
Read how Machine Learning System Design explains retrieval-augmented generation →
Machines that Think
Retrieval-augmented generation is a technique that retrieves external information and supplies it to a generative model as input context.
- How it is used
- Addresses reliability and context-window limits by supplying selectively retrieved external knowledge at generation time.
- How deep it goes
- Explains an embedding-based retrieval pipeline and its limitations, while noting that RAG encompasses multiple system designs.
- Examples
- Uses legal archives, medical databases, and corporate repositories to illustrate knowledge sources too large for a single context window.
- What you can do after
- Evaluate retrieval as a reliability measure while recognizing that relevant evidence does not guarantee grounded generation.
Read how Machines that Think explains retrieval-augmented generation →
Build Applications with Local AI Models on a Mac
Retrieval-augmented generation is a technique that retrieves relevant information from an external knowledge source and supplies it to a language model alongside a question or instruction.
- How it is used
- Extends a chatbot with knowledge from personal documents or internal knowledge bases.
- How deep it goes
- Explains the retrieval-to-answer pipeline and assigns a prototype; defers advanced chunking, filtering, hybrid search, and reranking to further learning.
- Examples
- Uses class notes or recipes in a 5–10-file prototype and suggests chatting with uploaded PDFs.
- What you can do after
- Apply it via Open WebUI by uploading PDFs and chatting with them.
Read how Build Applications with Local AI Models on a Mac explains retrieval-augmented generation →
The AI Pocket Book
A method of augmenting an LLM prompt with retrieved external documents so the model can answer using information not in its training data.
- How it is used
- Provides task-specific or current information to LLMs through retrieved documents added to prompts.
- How deep it goes
- Explains retrieval, prompt augmentation, retrieval quality, context limits, and cost, but not retrieval algorithm internals.
- Examples
- Uses internal-document chatbots, current webpages, keyword matching, source citation, and added prompt documents.
- What you can do after
- Build it from scratch by searching indexed documents, adding relevant content to prompts, and managing context limits.
Read how The AI Pocket Book explains retrieval-augmented generation →
Building LLM Applications with DSPy
A language-model application pattern that retrieves external information and supplies it as context for response generation.
- How it is used
- Uses external knowledge to help language models answer questions requiring information unavailable during training.
- How deep it goes
- Builds a DSPy module around retrieval and generation, including vector search, but does not detail the full search infrastructure here.
- Examples
- Uses company return-policy questions and Wix support queries, retrieving relevant articles to ground answers.
- What you can do after
- Build a DSPy application that retrieves relevant knowledge-base articles and supplies them with a user query to generate an answer.
Read how Building LLM Applications with DSPy explains retrieval-augmented generation →
Context Engineering
A retrieval-augmented generation pipeline sequences retrieval and generation operations to supply retrieved information to a generative model.
- How it is used
- Supplies query-specific external knowledge to an LLM without retraining, supporting answers about changing, proprietary, or domain-specific information.
- How deep it goes
- Explains offline indexing and online generation, then implements sparse retrieval and configures a local vector-backed pipeline.
- Examples
- Uses TF-IDF document retrieval and a locally ingested PDF manual to illustrate alternative pipelines.
- What you can do after
- Apply it using scikit-learn and the OpenAI API, or configure a local pipeline with Ollama, Qdrant, and Agno.
Read how Context Engineering explains retrieval-augmented generation →
Grokking Software Architecture
Retrieval-augmented generation is an architecture that retrieves relevant external information and supplies it as context to a generative AI model before response generation.
- How it is used
- Grounds model answers in retrieved database facts rather than relying on the model’s own learned information.
- How deep it goes
- Explains retrieval and prompt augmentation, but does not specify indexing, retrieval tuning, or implementation steps.
- Examples
- Uses private-document question answering and an open-book-test analogy to illustrate the pattern.
- What you can do after
- Understand how retrieved facts can ground answers and recognize vector search’s accuracy and infrastructure tradeoffs.
Read how Grokking Software Architecture explains retrieval-augmented generation →
Authorization in Action
Retrieval-augmented generation is a technique that supplies a generative model with externally retrieved information when producing an output.
- How it is used
- Uses externally retrieved enterprise data to ground generated responses while keeping authorization decisions outside the AI.
- How deep it goes
- Explains RAG’s data flow and safety boundary, emphasizing authorization before retrieval rather than detailed implementation.
- Examples
- Uses a financial-records assistant and enterprise document or record retrieval to illustrate authorization-sensitive responses.
- What you can do after
- Operate/configure RAG systems by enforcing authorization before retrieval and sending only permitted data to the model.
Read how Authorization in Action explains retrieval-augmented generation →
Rearchitecting LLMs
Retrieval-augmented generation is a technique that retrieves external information at generation time and provides it to a language model as context.
- How it is used
- Provides up-to-date or private external knowledge to a language model during generation.
- How deep it goes
- Defines the technique and its trade-offs, but stops short of implementation details, retrieval design, and evaluation procedures.
- Examples
- Uses private organizational data and up-to-date information as the concrete knowledge sources.
- What you can do after
- Apply it via a RAG pipeline to give a language model access to external information.
Read how Rearchitecting LLMs explains retrieval-augmented generation →
Designing AI Agents
A technique that retrieves relevant information from an external corpus and supplies it to a language model to inform generation.
- How it is used
- Supplies selected external evidence when a corpus is too large or changeable to load directly.
- How deep it goes
- Specifies write and read paths, design responsibilities, evaluation metrics, and failure modes without prescribing a single implementation.
- Examples
- Uses session APIs, documents, logs, prior sessions, and compiled artifacts as implementation examples.
- What you can do after
- Evaluate pipelines by accepted outcomes, token use, latency, citation coverage, and missed-authority failures.
Read how Designing AI Agents explains retrieval-augmented generation →
Also covered in
- Decision EngineeringIn early access (MEAP)
- AI GovernanceIn early access (MEAP)
- First-Party Data Activation
- Digital Twins in Action
- Evaluating AI SystemsIn early access (MEAP)
- Deep Learning with JAX
- Deep Learning with R, Third Edition
- Build an AI Agent (From Scratch)
- Deep Learning with Python, Third Edition
- Architecting an Apache Iceberg Lakehouse
- Hugging Face in Action
- AI Recommender SystemsIn early access (MEAP)
What to know first
- language modelA language model is a computational model that represents patterns in linguistic sequences to assign probabilities, predict, generate, or evaluate language.
- embeddingAn embedding is a numerical vector representation of an item in a feature space, encoding selected properties or relationships for computational tasks such as comparison or retrieval.
- similarity searchSimilarity search is a retrieval technique that finds or ranks items by their similarity to a query, often by comparing feature or vector representations under a similarity or distance measure.
- promptA prompt is text or other input supplied to an AI model to provide instructions, context, or other information that guides its response or generated output.
Related concepts
- language modeluses · A language model is a computational model that represents patterns in linguistic sequences to assign probabilities, predict, generate, or evaluate language.
- similarity searchuses · Similarity search is a retrieval technique that finds or ranks items by their similarity to a query, often by comparing feature or vector representations under a similarity or distance measure.
- hallucinationaddresses · A hallucination is model-generated content that is false, fabricated, or unsupported by relevant evidence but presented as plausible or factual.
- knowledge baseuses · A knowledge base is an organized body or representation of information that people or computational systems can consult to support retrieval, reference, reasoning, or tasks.
- information retrievaluses · Information retrieval is the process of finding and selecting information relevant to a query or information need from a collection.
- fine-tuningcontrasts with · Fine-tuning is the continued training of a pretrained model on targeted data or objectives to adapt its parameters or behavior to a task, domain, or use.
Questions about retrieval-augmented generation
What is retrieval-augmented generation?
Retrieval-augmented generation is a technique that retrieves relevant information from external sources and supplies it as context to a generative model when producing an output.
Which Manning books explain retrieval-augmented generation?
Retrieval Augmented Generation, The Foundational Ideas, Grokking AI Applications, Effective Conversational AI, Build an Advanced RAG Application (From Scratch), Domain-Specific Small Language Models, Software Testing with Generative AI, Enterprise RAG, LLMs in Production and 38 more.
What should I know before learning retrieval-augmented generation?
Manning books that teach retrieval-augmented generation usually introduce language model, embedding, similarity search and prompt first.
What is the difference between retrieval-augmented generation and fine-tuning?
Retrieval-augmented generation is a technique that retrieves relevant information from external sources and supplies it as context to a generative model when producing an output. Fine-tuning is the continued training of a pretrained model on targeted data or objectives to adapt its parameters or behavior to a task, domain, or use.
What is retrieval-augmented generation also called?
Retrieval-augmented generation is also called RAG.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.













































