liveBook · Manning

Retrieval-augmented generation

As explained in 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.

A marketing team needs content that reflects its workflow-automation product, proprietary insights, and current market developments. Generic language-model responses miss that context; manually searching scattered documents slows the work. Retrieval-augmented generation (RAG) connects the model to relevant information when it produces a response. section 7.1.2 section 7.0

RAG combines semantic search with language-model generation. Search retrieves relevant documents from a knowledge base; their contents augment the prompt; the model uses that context to answer a question or create content. This can improve specificity and factual grounding without retraining the model, but it does not guarantee accuracy or reproduce a brand’s voice on its own. section 7.3 section 5.4.3

Figure 7.9 Schema of a RAG system. Users prompt the system with a query, the results of which are fed into the embedding database. Those results generate an augmented prompt fed to an LLM, which generates a final response to the user query.
A diagram of a data flow

AI-generated content may be incorrect.

Trace the path from a user query through retrieved results and an augmented prompt to the generated response. section 7.3

A practical baseline separates the decisions that affect the answer:

  • Choose a language model and construct a prompt that includes the retrieved chunks. Account for input-token cost and the model’s ability to use long contexts; decide whether answers should rely on database information alone or also draw on general knowledge. section 7.3.1
  • Evaluate retrieval and generation separately, then assess the complete response. Search measures include precision, recall, and mean reciprocal rank; response checks include context relevance, groundedness, and answer relevance. section 7.3.2 section 7.4
  • Refine weak results rather than treating the model as the only lever. Query expansion or classification can improve retrieval; prompt constraints can curb content unsupported by retrieved documents. Chunking, embeddings, lexical search, and metadata filters offer further retrieval options. section 7.3.3 section 7.4

A broad trend question

“What trends should we be aware of in AI?” may retrieve irrelevant industries. Expanding it into questions about SaaS platforms and workflow automation gives retrieval a more useful target. If the resulting report still introduces unrelated healthcare examples, prompt constraints can steer generation back toward retrieved evidence. section 7.3.3

RAG is an accuracy and relevance strategy, not a substitute for checking outputs. Keep evaluating with real user queries: a response that sounds confident but misses the customer’s domain can cost trust and require extensive editing. section 7.0 section 7.3.2

How The Art of AI Product Development covers it

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 it assumes
Assumes a working search component for the basic setup, while explaining how retrieved documents become generation context.
What you can do after
Build it from scratch as a baseline, then evaluate retrieval and responses before refining queries, search, and prompts.
How it connects
Links semantic search, embeddings, prompt engineering, fine-tuning, and language-model evaluation.

Also explained in

Compare how 32 books explain retrieval-augmented generation →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of The Art of AI Product Development. The section links point to the parts of the book it draws on.