Overview

2 Nothing happens until someone writes an eval

This chapter makes the case that effective RAG projects begin with evals—concrete question–answer test cases that define success before any code is written. Adopting an eval‑driven development mindset (akin to test‑driven development) turns vague objectives into measurable targets, aligns stakeholders on expectations, and provides a practical roadmap for progress. Evals clarify scope, set pass/fail criteria, and help teams focus on what matters for the business, laying the foundation for a reliable, purpose‑built RAG chatbot.

The workflow starts by collecting 10–20 representative questions and correct answers from stakeholders, subject‑matter experts, and real customer interactions. You iteratively build the system to pass these evals, diagnosing misses as either retrieval failures or generation mistakes, then refining prompts, data coverage, or logic until answers match expectations. Evals serve as guardrails against scope creep, a communication tool when new requests arise, and an end‑to‑end diagnostic aid after the system is live. To ensure comprehensive coverage, include evals for every data source your chatbot will query and re‑run earlier tests whenever you improve later ones to avoid regressions.

To scale quality assurance, the chapter shows how to automate evals in a CI/CD pipeline. A test harness sends eval questions to the chatbot and compares responses to expected answers, often using an LLM as a semantic judge. Because LLM judgments can be variable and costly, combine them with rule‑based checks (for exact numbers, units, or required terms) and occasional human oversight. Automated evals catch regressions early, enforce consistency and safety requirements, and provide continuous feedback as prompts and code evolve. Practically, you wire this up with lightweight scripts, environment‑secured keys, pytest, and GitHub Actions—starting with failing tests and iterating until they pass.

The iterative process for building a RAG system using evals. Steps include defining evals, implementing the system, testing, modifying prompts, and retesting for refinement.
Using evals as test cases in CI/CD pipelines. Evals ensure the chatbot consistently meets performance standards by running, modifying, and retesting prompts in a continuous feedback loop.
How the Automated Eval process works. Evals interact with the chatbot and large language model (LLM) to assess and ensure response accuracy, passing or failing based on similarity.
The automated eval system for RAG development. Evals compare chatbot answers to expected outputs and automate testing via GitHub Actions, ensuring high-quality performance.

Summary

  • Evals are essential for RAG Development. Evals serve as test cases that transform broad objectives into specific, measurable goals, guiding the development of your Retrieval Augmented Generation (RAG) chatbot.
  • Obtain Evals Before Coding. Getting evals from stakeholders before writing any code is crucial to avoid hidden assumptions, ensure alignment with expectations, and protect the project from misaligned outcomes.
  • Utilize a step-by-step approach by starting with simple question-answer pairs, identifying required data, building agents and search functions, providing clear instructions, testing responses, troubleshooting issues, and iterating.
  • Integrate evals into your deployment pipeline to automate testing, use Large Language Models (LLMs) for response comparison, and cover all data sources to ensure comprehensive and efficient evaluation.
  • Evals enhance communication between developers and stakeholders, enable continuous improvement, and are critical for developing, testing, and maintaining a reliable RAG chatbot that meets organizational needs and adds substantial value.

FAQ

What is an eval in Enterprise RAG, and why write it first?An eval is a concrete question-and-answer pair that defines the behavior your RAG chatbot must deliver. Writing evals first turns vague goals into measurable targets, just like test-driven development: define tests (evals), see them fail, then build until they pass. This prevents guesswork and aligns the system with business needs.
How many evals do I need, and who should provide them?Start with 10–20 evals. Source them from stakeholders who own the business outcomes: your boss, customers, subject-matter experts, and customer support teams (tickets, call transcripts, FAQs). They ensure relevance and uncover hidden requirements.
What makes an effective eval?Each eval should be a realistic, business-relevant question with a precise, correct answer. Capture required formats (units, dates, naming), cover each important use case and data source, and clarify edge cases. The clearer the expected answer, the easier it is to measure success.
What happens if I start coding without evals?Without evals, you risk building to unstated assumptions, shifting targets, and misaligned expectations. Evals provide a shared contract: when a new question appears later, you can add it to the evals and iterate with clarity instead of reworking blindly.
How does Eval-Driven Development work for a RAG chatbot?The workflow is iterative: define evals, implement the RAG system, run the evals, adjust prompts/code, and re-run until they pass. Start with the simplest eval, then expand while continuously re-testing to avoid breakages.
How do I automate evals and integrate them into CI/CD?Create a test that sends each eval question to your chatbot, compares its response to the expected answer, and returns PASS/FAIL. Run these tests on every change using a CI service (e.g., GitHub Actions with pytest). Store API keys as environment secrets, and expect initial failures until the system is built.
How should I compare chatbot answers to expected answers?Use an LLM judge to assess semantic similarity so correct answers with different phrasing still pass. Add rule-based checks for exact fields (numbers, dates, required keywords) to reduce false positives. Keep a human in the loop for oversight and tune thresholds over time.
How do evals prevent regressions when I tweak prompts or code?Run the full eval suite on every change. If a fix for one question breaks others, CI catches it immediately, enabling quick rollbacks or adjustments before users are affected.
How do evals help test all data sources and catch operational issues?Create at least one eval per data source (products, customers, orders, policies, knowledge base, etc.). Failing evals can reveal outages, misconfigurations (like expired API keys), or indexing gaps, providing end-to-end assurance beyond unit tests.
What’s the difference between unit tests and evals in a RAG system?Unit tests validate individual components (retrievers, rankers, parsers). Evals are end-to-end acceptance tests that verify the entire pipeline produces the correct answer for real user questions. Both are needed for reliable systems.

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
  • Enterprise RAG 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
  • Enterprise RAG ebook for free