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.
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 LLM answers to organization-specific, updateable documents when generic pretrained knowledge is insufficient.
- How deep it goes
- Explains the full ingestion, retrieval, and generation workflow, then details chunking, embeddings, vector search, and tuning controls.
- Examples
- Demonstrates a PDF-backed pizza assistant and an agent that semantically searches an Italian recipe collection.
- What you can do after
- Apply it via Langflow to build and tune document-backed LLM flows using ingestion and retrieve-and-answer subflows.
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 →
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
- Deploys external knowledge retrieval alongside language-model generation for current, private, or domain-specific responses.
- How deep it goes
- Explains offline indexing, online retrieval, prompt enrichment, implementation components, tradeoffs, GraphRAG, and evaluation metrics.
- Examples
- Uses Marvel text classification, PDF question answering, blocked KV-cache retrieval, and knowledge-graph community summaries.
- What you can do after
- Build it from scratch with document parsing, chunking, embeddings, vector search, prompt formatting, and local model generation.
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 →
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 documents or code examples to an LLM at request time for grounded answers and application-specific context.
- How deep it goes
- Works through ingestion, similarity search, prompt assembly, token budgeting, and a coding-copilot failure; stops short of a full multistep-retrieval solution.
- Examples
- Uses Wikipedia retrieval, a Python coding dataset in Milvus, and a linked-list copilot test that performs worse with RAG.
- What you can do after
- Build it from scratch using document ingestion and vector search, then diagnose its effect by inspecting prompts and comparing no-RAG output.
Read how LLMs in Production 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
- Supplies retrieved search results as context for generative answers, summaries, and question answering.
- How deep it goes
- Explains chunk indexing, embedding-based retrieval, ranking, and prompt construction; flags chunking problems without prescribing a universal chunk size.
- Examples
- Works through a cited summary answering “What is a large language model?” and a prompt refinement for concision.
- What you can do after
- Build it from scratch as a retrieval-and-prompt workflow that supplies ranked passages to a language model and requests cited answers.
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
- Grounds chatbot and question-answering responses in retrieved text rather than relying only on a generator's learned responses.
- How deep it goes
- Works through a Haystack retriever, prompt template, generator pipeline, and test questions, without detailing retriever internals.
- Examples
- Tests LSTM-versus-RNN and Louvre Museum questions, including an “I don't know” response when retrieved sources do not answer.
- What you can do after
- Apply it via Haystack to connect a retriever to FLAN-T5 and request answers based on 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 retrieved documents or changing data rather than relying on a model’s training-time knowledge.
- How deep it goes
- Works through indexing, retrieval, context assembly, generation, and evaluation, including a policy-answering implementation and retrieval failure modes.
- Examples
- Uses inventory questions, store-credit return policies, an e-commerce chatbot, and a health-care policy assistant.
- What you can do after
- Build it from scratch with indexed passages and an LLM, or apply it via LangChain retrieval chains; evaluate answers against sources.
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
- Answers questions about supplied documents by retrieving relevant context before generating a response.
- How deep it goes
- Works through indexing, retrieval, prompt augmentation, server initialization, and grounding options; treats advanced RAG variants as alternatives.
- Examples
- Uses a PDF-indexed Next.js chat app and a multi-knowledge-base application supporting PDF and DOCX uploads.
- What you can do after
- Build it from scratch with LangChain.js retrieval and a Next.js chat interface, then configure a saved index for document queries.
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-model answers and content generation to relevant, current domain knowledge instead of leaving users with generic output.
- How deep it goes
- Works through retrieval, prompt augmentation, model selection, evaluation, and optimization, without a code-level implementation in the supplied excerpts.
- Examples
- Uses a B2B SaaS marketing need and an overly broad AI-trends query to show why targeted retrieval matters.
- What you can do after
- Build it from scratch as a baseline, then evaluate retrieval and responses before refining queries, search, and prompts.
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
- Ground language-model answers in retrieved current or proprietary data for enterprise question answering and chat.
- How deep it goes
- Works through retrieval architecture, data preparation, and an illustrative chat integration, while leaving production engineering beyond the example.
- Examples
- Demonstrates a Redis-backed chat application that searches embedded blog-post chunks and passes five matches to a GPT model.
- What you can do after
- Build it from scratch as an illustrative Redis-backed chat application, then plan security, scaling, and operations before production use.
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-news analysis and fraud-investigation summaries in retrieved, current or proprietary information.
- How deep it goes
- Traces ingestion through embeddings, retrieval, and structured output; treats the supplied response code as conceptual rather than production-ready.
- Examples
- Uses a current-post digest, multisource financial news, and fraud case files to show retrieval contexts.
- What you can do after
- Build it from scratch as a news-to-JSON retrieval pipeline, while checking source freshness, evidence, and governance controls.
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
- Supports answers to questions requiring current information or context-specific documents, such as company policies.
- How deep it goes
- Explains document embeddings, similarity-based retrieval, and supplying passages as context at a conceptual level, without implementation instructions.
- Examples
- Uses a travel-expense policy question and a restaurant recommendation informed by earlier preferences and retrieved reviews.
- What you can do after
- Evaluate/understand how retrieved sources can ground an answer while leaving relevance, reliability, and verification as open concerns.
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
- Grounds document Q&A by retrieving relevant knowledge-base passages before an LLM generates an answer.
- How deep it goes
- Builds a basic pipeline from ingestion through retrieval and generation, then discusses chunking, result counts, and embedding compatibility.
- Examples
- Uses an enterprise document chatbot and a Paestum-temples question answered through a ChromaDB-backed GPT-5-nano chatbot.
- What you can do after
- Build it from scratch with a vector database and LLM API, then test answers against retrieved evidence.
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
- Uses relevant support articles to help a customer-service chatbot answer domain-specific questions.
- How deep it goes
- Works through knowledge-base ingestion, similarity search, and prompt augmentation, using existing embedding and vector-store tools rather than implementing them from scratch.
- Examples
- Uses product and fountain-pen maintenance articles as searchable context for customer questions.
- What you can do after
- Apply it via Pinecone, LangChain, and LangGraph to retrieve support-article chunks and include them in chatbot answers.
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 agents with selected external knowledge or memory at decision time rather than placing entire stores in prompts.
- How deep it goes
- Explains ingestion and query-time retrieval step by step, then gives operational guidance for search, grounding, and access control.
- Examples
- Uses a France question, a source-and-retrieval table, and a customer support agent retrieving manuals and policies.
- What you can do after
- Apply it via a retrieval tool that filters relevant information, grounds answers in retrieved passages, and withholds unsupported answers.
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 →
Transformers in Action
A retrieval-augmented generation system generates outputs using information retrieved from an external collection.
- How it is used
- Grounds generated answers in current or domain-specific information retrieved at inference time without updating model weights.
- How deep it goes
- Works through pipeline components and design choices, including chunking, retrieval, optional reranking, and a basic implementation.
- Examples
- Uses a current-policy legal assistant, a LangChain retrieval pipeline, and a reranked financial question.
- What you can do after
- Apply it via LangChain to retrieve document context for generation and refine results with an optional reranker.
Read how Transformers in Action explains retrieval-augmented generation →
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 chat, question answering, reference lookup, and agent knowledge by adding retrieved external context to prompts.
- How deep it goes
- Explains indexing, chunking, embeddings, vector storage, similarity search, and generation, while deferring more advanced retrieval patterns.
- Examples
- Demonstrates PDF and text-document chat, LangChain chunking, Chroma retrieval, nursery-rhyme queries, and Nexus knowledge stores.
- What you can do after
- Build RAG workflows that index documents, retrieve semantically similar passages, and connect knowledge stores to supported agents.
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 →
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 →
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
- Supplies a chatbot with relevant document knowledge before it answers a question.
- How deep it goes
- Explains the retrieval-to-answer pipeline and proposes a prototype; defers chunking strategies, hybrid search, and reranking to further work.
- Examples
- Uses personal notes or recipes for a small prototype and company documents or research papers as knowledge sources.
- What you can do after
- Practice/perform it by running a RAG script on personal text files and checking the relevance of similarity-search results.
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 →
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 →
Related concepts
- language modeluses · A language model is a computational model that represents patterns in linguistic tokens to estimate sequence probabilities and predict or generate language from context.
- similarity searchuses · Similarity search is a retrieval technique that finds or ranks items by comparing their representations with a query according to 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 collection of information that can be accessed or queried to support reference, retrieval, or reasoning.
- information retrievaluses · Information retrieval is the process of locating and selecting relevant information from an available collection in response to a query or information need.
- fine-tuningcontrasts with · Fine-tuning is adapting a pretrained machine-learning model by training it further on targeted data or objectives for a task, domain, or behavior.
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.































