Overview

2 RAG-enabled Systems and Their Design

This chapter introduces how Retrieval Augmented Generation is turned into a working system by pairing a prepared knowledge base with real‑time question answering. It explains that RAG-enabled applications hinge on two complementary pipelines: an offline indexing pipeline that consolidates and maintains non‑parametric memory from disparate sources, and an online generation pipeline that retrieves, augments, and uses an LLM to produce contextual answers. The chapter motivates why consolidation is crucial—collecting data in one place, normalizing formats, and splitting it into manageable pieces—so the system can respond accurately and efficiently at runtime.

The indexing pipeline covers connecting to external sources, extracting and parsing content, splitting text into chunks, converting text to embeddings, and storing them in vector databases, with ongoing updates to keep the knowledge base current. The generation pipeline then uses a retriever to find relevant context, prompt management to combine it with the user query, and an LLM setup to generate answers, balancing quality and latency. Around these cores sit production concerns: orchestration to coordinate components, evaluation and monitoring for quality and reliability, and supporting capabilities such as caching for performance, guardrails for policy and safety, and security against threats like prompt injection and data poisoning.

Evaluation is framed as checking alignment across prompt, retrieved context, and final answer, using metrics such as relevance, recall, and precision, often grounded by curated datasets and reinforced with continuous monitoring and user feedback. The chapter also sketches the evolving LLMOps infrastructure that powers such systems across layered services: data and vector storage, model providers, prompt tooling, evaluation frameworks, orchestration, deployment and hosting, and monitoring. By the end, readers gain a coherent blueprint of RAG system design—its pipelines, quality loop, and operational stack—setting the stage for deeper dives into each component in subsequent chapters.

Generation Pipeline covering the five steps of Retrieval Augmented Generation
Indexing Pipeline covering the steps to create the Knowledge Base for RAG
The Indexing Pipeline and the Generation Pipeline together make a RAG-enabled system.
Components of a production ready RAG-enabled system
Four Components of the indexing pipeline facilitate the creation of the knowledge base
Three Components of the generation pipeline enable the real-time query-response process of a RAG enabled system
The triad of RAG evaluation proposed by TruEra

Summary

  • A Retrieval Augmented Generation (RAG) enabled system consists of two main pipelines: the Indexing Pipeline and the Generation Pipeline.
  • The Indexing Pipeline is responsible for creating and maintaining the knowledge base, which involves data loading, text splitting, data conversion (embeddings), and data storage in a vector database.
  • The Generation Pipeline manages real-time interactions by retrieving information, augmenting queries, and generating responses using a Large Language Model (LLM).
  • Evaluation and monitoring are crucial components to assess system performance, covering the relevance between the retrieved information and query, the final response and retrieved information, and the final response and the original query.
  • The service infrastructure for RAG-enabled systems includes layers for data, models, prompts, evaluation, app orchestration, deployment, application hosting, and monitoring.
  • Additional components like caching, guardrails, and security measures are often employed to improve performance, ensure compliance, and address potential threats.

FAQ

What is a RAG-enabled system and how does it work at a high level?Retrieval-Augmented Generation (RAG) combines external knowledge with an LLM to produce contextual answers. It uses two pipelines: - Indexing pipeline (offline): builds and maintains a consolidated knowledge base. - Generation pipeline (real time): retrieves relevant info, augments the user query with it, and prompts the LLM to generate the answer.
Why are there two pipelines (indexing and generation), and how do they interact?The indexing pipeline prepares the knowledge base in advance by connecting to sources, extracting and transforming data, and storing it for search. The generation pipeline queries this store when a user asks a question, retrieves the most relevant pieces, augments the prompt, and invokes the LLM. Indexing must be set up before generation can deliver reliable, low-latency answers.
What are the main steps and components of the indexing pipeline?Indexing typically follows five steps that group into four components: - Data Loading: connect to sources (internet, CMS, data lakes), extract and parse content in various formats (PDF, DOC, JSON, HTML). - Data Splitting: break long documents into smaller chunks to improve retrieval quality and efficiency. - Data Conversion (Embeddings): convert text into numerical vectors suited for similarity search. - Data Storage: persist embeddings in a vector database to support fast retrieval and updates.
What is data splitting (chunking) and why does it matter?Chunking breaks long text into smaller, coherent segments. Benefits include: - Better recall and precision during retrieval. - Lower latency and more efficient search. - More targeted augmentation of prompts with only the most relevant context.
What are embeddings and vector databases in a RAG system?Embeddings are numerical representations of text that capture semantic meaning, enabling similarity search. A vector database stores these embeddings and supports operations like nearest-neighbor search so retrievers can quickly find the most relevant chunks for a given query.
What are the key components of the generation pipeline?The generation pipeline has three core components: - Retriever: searches the vector store and fetches the most relevant chunks (critical for accuracy and latency). - Prompt Management: augments the user query with retrieved context and structures the prompt effectively. - LLM Setup: selects and configures the LLM(s) (foundation, managed, fine-tuned) to generate the final response.
Do you always need an indexing pipeline?No. If retrieval is outsourced (e.g., a third-party API provides the needed facts like weather) or the user supplies the documents directly (e.g., a summarizer), you may not build your own knowledge base. For internal, reusable knowledge over large corpora, an indexing pipeline is typically essential.
How do you evaluate the quality of a RAG system?Use quantitative metrics (e.g., relevance, recall, precision) and the “RAG triad”: - Prompt ↔ Context: Is retrieved context relevant to the query? - Answer ↔ Context: Does the answer faithfully use the retrieved info? - Answer ↔ Prompt: Does the answer address the user’s question? Ground-truth datasets help with offline evaluation, and continuous monitoring plus user feedback support ongoing improvement.
What infrastructure layers commonly support production RAG systems?An evolving LLMOps stack spans: - Data Layer (embeddings processing/storage) - Model Layer (LLM providers) - Prompt Layer (prompt management/evaluation tools) - Evaluation Layer (RAG metrics frameworks) - App Orchestration (workflow coordination) - Deployment Layer (cloud/platforms) - Application Layer (app hosting) - Monitoring Layer (runtime monitoring and alerts) An orchestration layer coordinates components end-to-end.
What additional production considerations should I plan for (caching, guardrails, security)?- Caching: semantic caching of LLM responses reduces latency and cost for similar queries. - Guardrails: rules to enforce policy, regulatory, and ethical constraints on outputs. - Security: defenses against prompt injection, data poisoning, and sensitive data leaks. - Monitoring: track performance, detect failures, and guide iterative improvements.

pro $24.99 per month

  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose one free eBook per month to keep
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime

lite $19.99 per month

  • access to all Manning books, including MEAPs!

team

5, 10 or 20 seats+ for your team - learn more


choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • A Simple Guide to Retrieval Augmented Generation ebook for free
choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • A Simple Guide to Retrieval Augmented Generation ebook for free
choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • A Simple Guide to Retrieval Augmented Generation ebook for free