liveBook · Manning

Retrieval-augmented generation

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

Retrieval-augmented generation (RAG) grounds a generative language model with question-relevant context retrieved from an external source before answer generation. It combines an LLM, a guiding prompt, and retrieval tools that access structured databases or unstructured text and images. This extends pretrained models toward private, fresher, more transparent, and less hallucination-prone applications without treating their outputs as inherently reliable. section 13.4.1 section 13.5

A practical RAG pipeline proceeds through these stages:

  • Prepare source data by dividing documents into passages, converting passages into fixed-length semantic embeddings, and storing them in an indexed vector database. section 13.4.1
  • Embed the user’s question and retrieve the most similar passages or invoke another retrieval tool, such as a weather-forecast API. section 13.4.1
  • Combine the question with the retrieved context in a prompt, then ask the LLM to generate an answer constrained by that information. section 13.4.1
  • Validate results with human feedback or supervision because probabilistic models can still produce incorrect answers despite grounding. section 13.4.1

Private-data question answering

A proprietary influence network can answer “Who were the influencers of cyclotron research funding?” through an AI interface, avoiding direct Cypher queries, graph navigation, and manual dashboard interpretation. A vector implementation embeds private documents, runs similarity search for “What is known about cyclotron research?”, and returns the top two text chunks for generation. section 13.4

Witness-statement summarization

Supplying all witness statements connected to CASE123 turns an otherwise impossible case-specific request into a manageable summarization task. Removing one critical statement can reverse the answer to whether the perpetrator is left-handed, demonstrating that confident generation cannot compensate for incomplete retrieval. section 14.2.1 section 14.2.2

How Knowledge Graphs and LLMs in Action covers it

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 it assumes
Assumes familiarity with LLMs, prompts, embeddings, databases, and private data while illustrating retrieval and grounding directly.
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.
How it connects
Connects large language models, prompt engineering, embeddings, vector databases, knowledge graphs, AI agents, and human-in-the-loop validation.

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 Knowledge Graphs and LLMs in Action. The section links point to the parts of the book it draws on.