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

Learning path · 3 steps

LLM Evals: Test an AI Feature Before and After You Ship
  1. 1
    Why You Cannot Ship an LLM Feature Without an Eval: Five Parts, Three Graders, One Tiny Eval
  2. 2
    Building a Golden Dataset for LLM Evals: Cases, a Schema, a Coverage Table and a Seeded Split
  3. 3
    Regression Testing an LLM Bot in CI: A Golden Set, Two pytest Gates and GitHub Actions
  1. Blog
  2. /
  3. AI Engineering
  4. /
  5. Evals and Testing

Learning path: LLM Evals: Test an AI Feature Before and After You Ship · Step 1 of 3

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.

Chaand Sheikh

·27 November 2026Evals and Testing

What you will learn

  • Define an eval as a repeatable test set plus scoring, run on every change
  • Name the five parts: dataset, system under test, graders, score and threshold
  • Choose between rule checks, an LLM judge and human review
  • Run a tiny eval in Python that ships one prompt and blocks another

Before you start

  • Basic Python
  • What an LLM Can and Cannot Do

An eval is a repeatable test set plus scoring, run on every change. Think of it as unit tests, but for the behaviour of a language model. This article shows why you need one, what's inside it, and a tiny eval in plain Python that you can run in a second.

A prompt change that looked better

A support bot answers customer questions. Someone says the answers sound cold, so the prompt goes from version 1 to version 2: Be warm and friendly. To check it, we try three questions. All three answers look nicer. Great, we ship it.

In production, other questions break. The warm answers forgot the facts: refund time, free-shipping limit, opening hours. Three examples that look good tell you nothing about the rest. We need a way to check all of them, every single time.

A driving test, not a feeling

A driving test has a fixed route and a checklist. The examiner doesn't say "I felt good about this driver". Most of us check a prompt the other way: try a few examples, it feels better, ship it. Different examples each time, no number, and nobody can repeat it.

An eval works like the driving test: a fixed set of cases, every case scored, a pass rate compared with a threshold, then ship or block. Same cases each time, one number, and anyone can repeat it.

The five parts of an eval

Five parts of an eval 1 Datasettest casesthe route 2 Systembot + promptthe car 3 Graderspass or failthe examiner 4 Scorepass ratethe marks 5 Thresholde.g. 0.8the pass mark Change the prompt, run the same five parts, compare the score: ship or block.
Each part maps to a piece of the driving test.
  1. Dataset: the test cases. Each has a question and what a good answer must contain. (Building one properly is the topic of Building a Golden Dataset.)
  2. System under test: the bot, with its prompt, answering each question.
  3. Graders: decide if each answer passes.
  4. Score: how many cases passed, as a pass rate.
  5. Threshold: below it, the change doesn't ship.

Three kinds of graders

GraderHow it worksGood forWatch out
Rule checkCode looks at the answer: does it contain the fact? Is it short enough?Cheap, instant, same result every timeOnly checks what you can write as a rule
LLM as judgeAnother model scores the answer against a short rubricTone and meaningThe judge can be wrong too; check it against human marks
Human reviewA person reads a sample and marks itThe final word on qualitySlow and costly; use it on a small sample

Start with rule checks. Add a judge and humans only where a rule can't decide.

tiny_eval.py

Here's a tiny eval with no model call and no keys. The answers for each prompt version were written by hand and saved, so the result is easy to follow. The cases first:

"""A tiny eval: saved support-bot answers, a rule grader, a pass rate. No LLM, no keys."""

CASES = [
    {"question": "How do I reset my password?", "must_include": "forgot password",
     "v1": "Use the reset option on the page.",
     "v2": "Click Forgot password on the sign-in page and we will email you a link."},
    {"question": "How do I cancel my plan?", "must_include": "billing",
     "v1": "Open Settings, then Billing, then Cancel plan.",
     "v2": "Happy to help! Head to Settings and choose Billing to cancel."},
    {"question": "How fast is my data deleted?", "must_include": "30 days",
     "v1": "Your data is deleted within 30 days.",
     "v2": "Your data is deleted within 30 days of your request."},
    {"question": "How long do refunds take?", "must_include": "5 business days",
     "v1": "Refunds arrive within 5 business days.",
     "v2": "Great question! Refunds are quick and easy."},
    {"question": "When is shipping free?", "must_include": "$50",
     "v1": "Shipping is free on orders over $50.",
     "v2": "Shipping is free on big orders."},
    {"question": "When is support open?", "must_include": "9 am",
     "v1": "Support is open from 9 am, Monday to Friday.",
     "v2": "We are always here for you, any time!"},
]
THRESHOLD = 0.8

Each case has a question, the fact a good answer must include, and the saved answer from each prompt version. THRESHOLD = 0.8 means 80% of the cases must pass. Then the grader and the score:

def grade(answer, must_include):
    return must_include.lower() in answer.lower()


def run_eval(version):
    results = [grade(case[version], case["must_include"]) for case in CASES]
    rate = sum(results) / len(CASES)
    print(f"prompt {version}: {sum(results)}/{len(CASES)} passed ({rate:.0%})")
    for case, ok in zip(CASES, results):
        if not ok:
            print(f"  FAIL  {case['question']}  (needs '{case['must_include']}')")
    print("  ->", "SHIP" if rate >= THRESHOLD else "BLOCK")


if __name__ == "__main__":
    run_eval("v1")
    run_eval("v2")

grade is a rule check: is the required fact inside the answer? Both sides are lowercased, so capitals don't matter. run_eval grades every case, prints the pass rate and each failure with the missing fact, then compares the rate with the threshold.

Same cases, two prompts

python tiny_eval.py
prompt v1: 5/6 passed (83%)
  FAIL  How do I reset my password?  (needs 'forgot password')
  -> SHIP
prompt v2: 3/6 passed (50%)
  FAIL  How long do refunds take?  (needs '5 business days')
  FAIL  When is shipping free?  (needs '$50')
  FAIL  When is support open?  (needs '9 am')
  -> BLOCK

Prompt v1 passed 5 of 6, 83%, above 80%: ship. Its one failure is the password question, because the answer never said "forgot password". Prompt v2 passed 3 of 6, 50%: block. It lost the refund time, the free-shipping limit and the opening hours.

Remember, v2 looked friendlier on the first three questions. The eval shows it lost the facts on the other three. A vibe check would have shipped it.

Where evals run

An eval only protects you if it runs without anyone having to remember:

  • Before merge: every prompt or code change runs the eval first, and a low score blocks the merge. That's set up in Regression Testing in CI.
  • Nightly: a bigger test set runs on a schedule, so slow drift gets caught early.
  • On production samples: score a small sample of real traffic, and add the failures to the test set.

That last one matters most: every bug you find in production becomes a new test case, so the eval gets stronger over time.

Common mistakes

  • Checking a new prompt on the three examples that made you write it.
  • Changing the test cases between runs. Then two scores can't be compared.
  • Grading for one exact sentence. Check the facts a good answer needs; many wordings can pass.
  • Using an LLM judge for things a rule can check, like "contains $50". Slower, costlier, and less reliable.
  • Having a score but no threshold. Without a pass mark, nothing blocks.

Quick recap

IdeaIn one line
EvalA repeatable test set plus scoring, run on every change
Five partsDataset, system under test, graders, score, threshold
GradersRules first; a judge or humans only where rules can't decide
This runv1 83%, ship; v2 50%, block
WhereBefore merge, nightly, on production samples

Try it yourself

  1. Run the file and read the SHIP and BLOCK lines.
  2. Add a seventh case with its own required fact, and an answer for each version.
  3. Move THRESHOLD to 0.5 and then 0.9. Which version still ships?

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 the learning path LLM Evals: Test an AI Feature Before and After You Ship · step 1 of 3

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

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

From ML Metrics to LLM Evals: Same Ruler, New Targets

Precision and recall don't disappear when you build with LLMs; they move. A spam filter at 0.75/0.75, precision@3 and recall@3 on six help-desk documents, exact match vs a key-fact check on two written answers, and the rubric that replaces a single label.

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

  • A prompt change that looked better
  • A driving test, not a feeling
  • The five parts of an eval
  • Three kinds of graders
  • tiny_eval.py
  • Same cases, two prompts
  • Where evals run
  • Common mistakes
  • Quick 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.