Overview

9 RAG Development Framework & Further Exploration

This concluding chapter assembles the book’s core ideas into a practical, end‑to‑end framework for building Retrieval‑Augmented Generation systems. It positions RAG development as an iterative, cyclic journey that begins with open‑ended business needs and arrives at reliable, production‑grade applications. The framework spans six stages—Initiation, Design, Development, Evaluation, Deployment, and Maintenance—emphasizing not only technical choices but also stakeholder alignment, measurable success criteria, and operational readiness. Throughout, it stresses clear requirements, a high‑level architecture for early alignment, and a holistic view of data, models, orchestration, and governance so teams can move methodically from concept to working systems.

The Design and Development stages translate intent into modular pipelines that are easy to evolve. On the indexing side, the chapter details data ingestion and parsing, cleaning and metadata extraction, PII handling, chunking strategies (fixed, structured, semantic, agentic), embeddings selection or fine‑tuning, optional knowledge graphs, and storage choices across vector, graph, and document stores. The generation pipeline is framed as seven steps: query optimization, retrieval (including hybrid, iterative, or graph‑aware strategies), context optimization (reranking and compression), augmentation via prompting, LLM‑based generation, and post‑generation response optimization. Development favors modular services for each capability and flexible orchestration, with fine‑tuning reserved for cases where prompting alone cannot meet style or domain needs. Evaluation combines component‑level retrieval metrics (precision, recall, MRR, nDCG), RAG‑specific measures (context relevance, faithfulness, hallucination rate, coverage, answer relevance), and system metrics (latency, throughput, cost per query) using ground‑truth datasets to guide iteration.

Deployment choices—such as blue‑green, canary, rolling, shadow, A/B testing, and interleaving—are matched to risk tolerance, scale, and monitoring needs, while Maintenance centers on continuous tracking of quality, performance, user behavior, security, and data drift to sustain reliability. The chapter also surveys directions for further exploration: when to favor fine‑tuning versus RAG (and how they complement each other), how long‑context models can reduce indexing needs yet raise costs, and why hybrid “self‑routing” approaches can balance accuracy with efficiency. It highlights managed RAG offerings that accelerate delivery at the cost of some control, and it flags query types that remain challenging—multi‑step reasoning, broad or implicit questions, and complex prompts—where retrieval, reasoning, and guardrails must improve. The net result is a concise playbook that equips practitioners to design, evaluate, ship, and evolve robust RAG systems.

The six stages of the RAG Development Framework are iterative and cyclic in nature.
A use case evaluation card with the evaluating questions can help in assessing if a RAG system is required to address the use case
An illustrative requirements document for a customer support system requiring RAG.
Illustrative requirements document with success metrics defined and requirements analyzed for clarity and precision.
High level architecture of a proposed customer support bot highlighting inputs, outputs along with the data, human-in-the-loop and cache layers.
The indexing pipeline of the RAG system is executed using the Data layer in the RAGOps stack.
Key questions need to be answered to make the choices for the generation pipeline
Modular structure allows for flexibility and scalability of individual components
The triad of RAG evaluation proposed by TruEra
Prompt Engineering requires low modifications to the model and external knowledge, focusing on harnessing the capabilities of LLMs themselves. Fine-tuning, on the other hand, involves further training the model. (Source: Retrieval-Augmented Generation for Large Language Models: A Survey’
A hybrid approach utilizing RAG and long context in LLMs can lead to better performance without adversely increasing the costs.
Common reasons for failure of RAG. (Source: Retrieval Augmented Generation or Long-Context LLMs? A Comprehensive Study and Hybrid Approach)

FAQ

What are the six stages of the RAG Development Framework, and why is it iterative?The framework has six stages: Initiation, Design, Development, Evaluation, Deployment, and Maintenance. It is intentionally iterative and cyclic—feedback and findings at later stages (e.g., Evaluation or Maintenance) loop back to earlier stages to refine requirements, design choices, and components.
How do I decide if my use case really needs RAG?Validate that RAG’s benefits are essential for the use case. Ask: - Does the application need data not present in an LLM’s training? - Is fresh, frequently updated data required? - Are factual accuracy and verifiable citations critical? - Would users benefit from source attribution? If not, a pure LLM application (e.g., creative writing, translation, grammar correction) may suffice.
What should the Initiation stage deliver?Outcomes include: - Clear problem framing and stakeholder alignment. - A structured requirements set (business objectives, user needs, functional and non-functional needs, constraints). - Quantified success metrics (e.g., latency, throughput, % queries resolved). - A high-level architecture showing inputs/outputs, data, and key components (e.g., cache, human-in-the-loop). - A go/no-go decision to proceed to detailed design.
What are the key design choices in the indexing pipeline?Decisions span three areas: - Data ingestion: source systems and connectors, file formats, web scraping, internet access, custom parsers. - Transformation: cleaning, metadata extraction, PII redaction, chunking strategy (fixed, structure-driven, semantic, agentic), embeddings vs. knowledge graphs, and whether to fine-tune embeddings. - Storage: vector DB selection and collections strategy, need for graph DB and/or document store, managed vs. self-hosted services, current and future scale.
What are the main steps in the generation pipeline, and when are optimizations needed?The pipeline includes: - Query optimization (routing, rewriting) when data is large or queries are short/generic. - Retrieval (dense, hybrid, iterative/adaptive, graph) tuned for precision/recall, filtering, and ranking. - Context optimization (reranking, compression) to fit context windows and reduce noise. - Augmentation (prompting): persona/system prompt, examples, constraints to context. - Generation: model selection (open-source vs. managed), size, fine-tuning needs, deployment constraints. - Response optimization: verification, formatting, citations, and downstream workflows. Note: Each optimization can improve quality but adds latency and cost.
Why build modular RAG pipelines, and what modules are typical?Modularity improves flexibility, scalability, maintainability, and swap-ability of components. Common modules include: data loading/parsing, metadata extraction, chunking, embeddings, storage, query optimization, retrieval, augmentation (prompting), generation (LLMs), and memory. Orchestrate these via a workflow layer; frameworks (e.g., LangChain) can accelerate development, while custom builds provide finer control where needed.
How should I evaluate a RAG system?Use layered metrics and ground truth: - Retriever metrics: precision, recall, Precision@k, F1, MRR, MAP, nDCG. - Generation metrics: coherence, conciseness. - RAG metrics: context relevance, faithfulness/groundedness, hallucination rate, coverage, answer relevance. - System metrics: latency, throughput, resource utilization, cost per query. Create a Ground Truth (Question/Prompt–Context–Response) set to benchmark variants (e.g., retrieval strategies, optimizations, service providers).
Which deployment strategies fit RAG systems, and what are the trade‑offs?Options include: - Blue-Green: zero downtime, easy rollback; higher cost due to duplicate environments. - Canary: gradual rollout and real feedback; more monitoring and version management. - Rolling: staged updates across servers; rollback can be complex mid-rollout. - Shadow: mirrors live traffic without user exposure; duplicate infra required. - A/B testing: direct comparison across user splits; needs robust traffic splitting/analytics. - Interleaving: blends outputs for fast, unbiased comparisons; attribution can be complex. Choose based on risk tolerance, scale, and criticality.
What should be monitored in the Maintenance stage, and what are common failure modes?Continuously track: - Component and RAG metrics for degradation. - System metrics (latency, throughput, errors, downtime), resource usage, and attacks. - User behavior (query types, shifts), engagement (CSAT, repeat use), and business KPIs (cost savings, revenue impact). Common difficult queries for RAG include multi-step reasoning (multi-hop), vague/general questions, complex/long queries, and implicit questions requiring deep context understanding.
RAG vs. fine‑tuning vs. long‑context LLMs: how to choose, and can they be combined?They are complementary: - Use RAG to inject up-to-date, external knowledge without changing model weights. - Use fine-tuning to adapt style/tonality/vocabulary or task behavior. - Long-context LLMs can sometimes outperform RAG but may be costlier; hybrid routing (e.g., send easy queries to RAG, hard ones to full context) balances accuracy and cost. Also consider managed RAG offerings (e.g., Bedrock Knowledge Bases, Azure AI Search, Vertex AI RAG Engine) when speed-to-value and managed scalability outweigh the need for fine-grained control.

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