Single logo
  • Courses
  • Blog
  • About
Join free on SkoolJoin free on Skool

In this topic

AI Engineering
  • LLM Tokens, Context Windows and Cost: What One Question Really Costs
  • What an LLM Can and Cannot Do: One Prediction Loop, Its Strengths and Its Gaps
  • Structured LLM Output with Pydantic: Describe the Shape Once, Check Every Reply
  • The RAG Pipeline Explained: 7 Stages From Documents to a Cited Answer
  • Similarity Search: Finding the Closest Vectors with NumPy and NearestNeighbors
  • Why RAG Exists: The Problem It Solves, Compared With Pasting Everything and Fine-Tuning
  • Real Embedding Models: an Open Model or a Provider API, Then Search, Duplicates and Recommendations
  • Chunking Strategies for RAG: Fixed Size, Sentences or Headings, Measured on One Handbook
  • Vector Databases Hands-On: The Same Search in Chroma and pgvector
  • RAG Prompt Assembly and Citations: Number the Blocks, Fit a Token Budget, Check Every Claim
  • Hybrid Search: BM25 Plus Dense Embeddings, Merged With Reciprocal Rank Fusion
  • Reranking With a Cross-Encoder: When the Second Pass Helps, and When It Doesn't
  • Retrieval Evals: Score the Retriever With Recall@K, MRR and nDCG Before Blaming the Model
  • Choosing a Vector Index: Flat, HNSW or IVF-PQ, a Memory Estimate, and Filters That Starve Small Customers
  • Citations and Abstention in RAG: What a Citation Proves, and When the Right Answer Is "It's Not in the Documents"
  • Embedding Migration With Zero Downtime: Two Indexes, a Dual-Write Backfill, a Shadow Check and a Flag
  • Why You Cannot Ship an LLM Feature Without an Eval: Five Parts, Three Graders, One Tiny Eval
  • Building a Golden Dataset for LLM Evals: Cases, a Schema, a Coverage Table and a Seeded Split
  • Retrieval Evals: Score the Retriever With Recall@K, MRR and nDCG Before Blaming the Model
  • Regression Testing an LLM Bot in CI: A Golden Set, Two pytest Gates and GitHub Actions
  • Testing a RAG Bot Before It Ships: Slices, a Release Gate per Slice, and the Week After
  • Fallback Models for an LLM App: A Chain That Checks Region and Fit, Flags Degraded Answers and Gets Rehearsed
  • Back Pressure for LLM Traffic: Bound the Queue, Give Chat Its Own Lane, Count Tokens, Cancel When the Caller Leaves
  • Load Balancing LLM Traffic: Count the Work, Weigh the Prefix Cache, Check Real Health, Drain Before Deploys
  • A Message Queue for Document Ingestion: At Least Once, Leases, an Idempotent Consumer and a Dead Letter Queue
  • Caching for AI Apps: Four Layers, What Goes in Each Key, and How a Delete Travels
  • Semantic Caching: Why a Similarity Threshold Can't Stop Confident Wrong Answers
  • LLM Model Routing: Rules, a Classifier or a Cascade, Judged on Cost per Win and Every Topic
  • Cutting p95 and Cost in Half for an LLM App: Read the Bill, Match the Lever, Guard Success
  • Observability and Tracing for LLM Apps: A Span per Stage, Redaction First, Bad Traces Become Tests
  • Guardrails for an LLM Agent: Check What Comes In, What It Wants to Do, and What Goes Out
  • Embedding Migration With Zero Downtime: Two Indexes, a Dual-Write Backfill, a Shadow Check and a Flag
  • Design a Multi-Tenant RAG Assistant, Part 1: Requirements, Rough Numbers and a Contract
  • Design a Multi-Tenant RAG Assistant, Part 2: Tenant Isolation, a Scoped Cache and Walking an Outage
  • A 500 MB PDF Takes 50 s to Answer, Get It to 2 s: Measure First, Then Promise Per Path
  • A 500 MB PDF From 50 s to 2 s, the Fast Path: Queue, Status, Streaming and an Acceptance Test That Fails
  • Guardrails for an LLM Agent: Check What Comes In, What It Wants to Do, and What Goes Out
  1. Blog
  2. /
  3. AI Engineering
  4. /
  5. Evals and Testing

Testing a RAG Bot Before It Ships: Slices, a Release Gate per Slice, and the Week After

In a simulated 210-case eval, a new model lifts the average from 0.895 to 0.929 and leaks 4 restricted documents. A gate per slice blocks it where the average says release. Plus why 20 of 20 can mean 0.88, and why the gate must also run when the index changes.

Chaand Sheikh

·27 November 2026Evals and Testing

What you will learn

  • Build a golden set from slices sized by cost of failure, not by how common they are
  • Write a release gate per slice, so an average that says release can still be blocked
  • Judge a small slice by its lower bound, not its clean score
  • Score retrieval, answer and tools apart, then keep watching after a staged rollout

Before you start

  • Why You Cannot Ship an LLM Feature Without an Eval
  • Building a Golden Dataset for LLM Evals

An interviewer asks: what would you test before shipping a RAG customer support bot? The usual answer is "I'd try some questions and see if the answers look good." This article gets you past that answer. You build a test set, score each part of the bot, and put a gate in front of the release.

The cases and model results here come from a small simulation with a fixed seed. They show the idea. They don't measure a production bot.

The answer in four steps

  1. A golden set: a fixed list of questions, with the hard ones in it on purpose.
  2. Score each part separately: retrieval, the answer and the tools.
  3. A release gate: rules you wrote down before the candidate ran.
  4. Roll out slowly and keep watching, because testing doesn't end at launch.

Think of a restaurant's soft opening. A few friends get a fixed menu. Someone orders a dish you don't serve, and the waiter should say so. Someone has an allergy, and that plate has to be right. When a plate comes out wrong, you ask whether it was the shopping, the kitchen or the waiter. You agreed beforehand that one allergy mistake means you don't open, however good the food tastes. And after opening, you still read the first week's complaints.

Better fluency, worse facts

For illustration, picture a model update whose answers read beautifully. Everyone who tries it likes it. But smooth wording isn't correct wording, and a confident wrong answer reads just as well as a right one. Trying it by hand can't catch that.

Now with numbers, from the simulated eval set of 210 cases. The old model scores 0.895 overall and the new one 0.929. It went up, so you'd ship it. Look inside, though. On questions that touch restricted documents, it went from 30 out of 30 to 26. In this scenario that's four cases where someone saw a document they weren't allowed to see. One average can't show you that.

The golden set: slices by cost, not by frequency

A golden set is fixed questions, each with the right answer or the right behaviour written beside it. You take them from past tickets and past incidents. The simulated set has four slices:

SliceCasesWhat a pass means
Answerable120The document exists; we found it and the answer sticks to it
Unanswerable40No document exists; the bot abstains and says it doesn't know
Restricted30Same question, two users with different permissions; one must not see the document
Unsafe20The bot should decline

The slices aren't sized by how common they are. The rare ones are in there because they're expensive when they fail. For how to build and check the cases themselves, see Building a Golden Dataset.

Score each part

A bot has parts, and one pass or fail doesn't tell you which part broke.

  • Retrieval: did the right document come back at all? If not, no model can save the answer.
  • Answer: given that document, does every claim come from it? That's grounding.
  • Tools, if the bot uses them: did it call the right one, with the right details, and did it work?

So a failed case points at one part, like the shopping, the kitchen or the waiter. To be honest about the simulation: it gives one pass or fail per case. On your own bot you'd keep these three scores apart.

The release gate

The rules are written before the candidate runs. Each slice has a limit, and the restricted slice allows zero failures. Here is the simulated run:

SIMULATED results, fixed seed
baseline  overall 0.895
  answerable   104/120 rate 0.87  low 0.81
  unanswerable  34/40  rate 0.85  low 0.74
  restricted    30/30  rate 1.00  low 0.92
  unsafe        20/20  rate 1.00  low 0.88
candidate  overall 0.929
  answerable   113/120 rate 0.94  low 0.90
  unanswerable  36/40  rate 0.90  low 0.80
  restricted    26/30  rate 0.87  low 0.73
  unsafe        20/20  rate 1.00  low 0.88
  average gate:  release
  contract gate: block
    - restricted: 4 fails, max 0
    - restricted: down 0.13
candidate2  overall 0.948
  answerable   113/120 rate 0.94  low 0.90
  unanswerable  36/40  rate 0.90  low 0.80
  restricted    30/30  rate 1.00  low 0.92
  unsafe        20/20  rate 1.00  low 0.88
  average gate:  release
  contract gate: release
SIMULATED week after release
  rollback: (5, 'leak')
Average says release, gate says block Answerable 113/120 pass Unanswerable 36/40 pass Restricted 26/30, max 0 fails Unsafe 20/20 pass Average gate 0.929 overall: release Per-slice gate 2 reasons on the list: block Simulated candidate, 210 cases
Each slice goes through its own rule. One slice over its limit puts a reason on the list, and any reason blocks.

Answerable passes, unanswerable passes. Restricted has four failures against a limit of zero, and it's down 0.13 on the old model, so two reasons go on the list. Unsafe passes, but the list isn't empty, so the decision is block. The average said release, the gate says block, and it tells you why.

Then the simulation is set so a second candidate gets restricted back to 30 out of 30. That isn't a fix; it only shows how the gate reacts. Overall 0.948, no reasons, release.

This is the part the earlier eval articles leave out. Regression Testing in CI gates on one pass rate and a drop from baseline. A per-slice gate adds a hard stop on the slice where one failure is too many.

The trap: 20 out of 20 is not perfect

Unsafe is 20 out of 20, so weak candidates call it perfect. It means twenty cases didn't catch anything. With so few cases, the true pass rate could reasonably be as low as 0.88. That's the low column in the output above. So you judge a small slice by that lower number, not by the clean score.

A clean score and its lower bound 0.80 0.90 1.00 Restricted 30/30 low 0.92 Unsafe 20/20 low 0.88
Both slices show 1.00 in the simulated baseline. The fewer the cases, the further down the plausible true rate can sit.

The week after

The failure test comes after launch too. You release to a small share first, and watch. In the simulation, day five shows one leak, because a new index exposed a restricted document. The rule says roll back.

Notice that the gate had passed that release. It tested a model, and the index changed later. So run the gate on index changes as well, and add that leak to the golden set so it's caught next time.

Follow-ups

  • A slice is too small to tell you anything. Now what? Add cases. Don't loosen the rule.
  • The team keeps rerunning until it passes. What's wrong? The set has stopped being a test. Tune on one set, and lock another for the release decision.
  • Why zero failures on restricted but not on the others? Because the cost isn't even. And zero on the set doesn't mean zero in the world.

A simple rubric

LevelWhat the answer has
Weak"We tried it and the answers looked good."
SolidA golden set, split into slices, with a threshold for each
StrongAlso scores retrieval, answer and tools apart, treats a permission failure as a hard stop, rolls out gradually, and says what the gate can't see

The rubric is a guide for practice, not a measurement.

Recap

IdeaWhat to remember
Hand testingCan't catch a confident wrong answer
Golden setSlices sized by cost of failure; rare, expensive cases on purpose
GateRules per slice, written first; simulated: average 0.929 said release, gate said block
Small slices20 of 20 has a lower bound of 0.88
After launchStaged rollout, gate on index changes, new incidents into the set

For the basics of an eval, see Why You Cannot Ship Without an Eval.

Try it yourself

Think of a support bot you've used. Write three questions it should refuse or get exactly right, and say which slice each one belongs to.

Tried the exercise? Share your answer or ask a question.

The StudyEasy AI Community is free to join, with the lesson files, notebooks and code.

Join free on Skool

Keep going in AI Engineering · 21 of 37

Previous
Regression Testing an LLM Bot in CI: A Golden Set, Two pytest Gates and GitHub Actions
Next post
Fallback Models for an LLM App: A Chain That Checks Region and Fit, Flags Degraded Answers and Gets Rehearsed

Related course on Udemy

Machine Learning Engineer: From First Model to ML Engineer

Learn machine learning in Python, then ship it: data analysis, regression, classification, tuning, deployment and MLOps.View on Udemy ↗: Machine Learning Engineer: From First Model to ML Engineer (paid course, opens in a new tab)

Related posts

Why You Cannot Ship an LLM Feature Without an Eval: Five Parts, Three Graders, One Tiny Eval

A friendlier prompt looked better on three questions and broke on others. An eval catches that: a fixed set of cases, a grader, a pass rate and a threshold. A tiny Python eval scores two prompt versions on the same six questions: v1 passes 83% and ships, v2 passes 50% and is blocked.

Building a Golden Dataset for LLM Evals: Cases, a Schema, a Coverage Table and a Seeded Split

The answer key for a support bot: 24 cases in one JSONL file, from 12 past tickets, 8 edge cases and 4 attacks. A Pydantic schema catches 4 problems in a broken file, a stats table finds that payments and account have no hard case, and a seeded split gives the same 16 dev and 8 test cases every time.

Retrieval Evals: Score the Retriever With Recall@K, MRR and nDCG Before Blaming the Model

When a RAG answer is wrong, check the retriever first. Score two retrievers on 24 graded queries with Recall@5, MRR and nDCG@5: overall there's no clear winner (0.757 vs 0.819, 0.854 vs 0.826, 0.769 vs 0.782), but the paraphrase slice drops to about 0.5 for both, and one query scores zero everywhere.

Regression Testing an LLM Bot in CI: A Golden Set, Two pytest Gates and GitHub Actions

A teammate changes one prompt line to make answers shorter, and four of ten golden questions lose their facts. A pytest eval on saved answers catches it: 12 passed for the old prompt, 2 failed gates and 4 xfailed cases for the new one, exit code 1, and the pull request check turns red.

On this page

  • The answer in four steps
  • Better fluency, worse facts
  • The golden set: slices by cost, not by frequency
  • Score each part
  • The release gate
  • The trap: 20 out of 20 is not perfect
  • The week after
  • Follow-ups
  • A simple rubric
  • Recap
  • Try it yourself
Community · Free to join
Single logo

StudyEasy AI Community

Hosted onSkool

Learn AI engineering, share what you build, and connect with other learners.

  • Free resources: lesson files, notebooks and code

  • Ask questions and join engineering discussions

  • Meet real people learning and building with AI

Join free on Skool

Related course on Udemy

Machine Learning Engineer: From First Model to ML Engineer

Learn machine learning in Python, then ship it: data analysis, regression, classification, tuning, deployment and MLOps.View on Udemy ↗: Machine Learning Engineer: From First Model to ML Engineer (paid course, opens in a new tab)

Single logo

Empowering Education, One Course at a Time

About
About usContact usFAQs
Legal
Terms of ServicePrivacy Policy

© 2026 StudyEasy Organization. All rights reserved.