How to compare two prompts or two Claude models on evidence

Day 5, 30 minutes · advanced

Goal of this lessonCompare two prompt versions or two models on the same test set, over three trials, in a table of score, spread, speed and cost.

Why it matters

Sooner or later you have two options: a new prompt or the old one, a cheaper model or a stronger one. Without an eval, you try both on a few emails and pick the one that felt better. With an eval, you run both on the same test set and look at the numbers.

But numbers from a small test set can fool you. Claude does not give the same answer every time, so a score that went up by one case may be luck. Today you compare two versions of Tjalling's prompt over several runs, with a simple margin that tells you when a difference is too small to trust. At the end you have a comparison table and a written decision that you can defend.

The words you need today

  • Variant: one version you test, here a combination of a model and a prompt.
  • Trial: one run of a variant over the whole test set. Because answers vary between runs, you run several trials.
  • Margin (the +/- in the table): how far the score could move by chance. A difference smaller than the margin is not evidence.
  • Latency: how long a call takes. The script measures seconds per call, from sending the request to getting the full answer.

What to compare

The page on choosing a model says to build tests for your own use case first, then test with your real prompts and data, compare the models on accuracy, quality and edge cases, and weigh performance against cost. The same works for two prompts.

A rule of thumb from this course: change one thing at a time. Variant A and variant B use the same model and the same test set; only the prompt differs. Variant B adds the two rules Tjalling wrote down in lesson 2 (bills are invoice; with two requests, the first decides) and asks for JSON without code fences. If you change the model and the prompt together, you cannot tell which change did it.

To compare models instead, give B the same prompt as A and another model. The page suggests starting with a fast, low-cost model such as Claude Haiku 5.5 and moving up only for gaps it cannot close.

Reading the table

compare.py prints one row per variant:

  • score: the average over all cases and all trials.
  • +/-: the margin, this course's simplified version of the ideas in Anthropic's research post on error bars (report a standard error, resample each question several times, compare models on the same questions): average each case over its trials first, then take 1.96 times the standard error of those case averages. In plain words: roughly how much the score could change with another set of similar emails.
  • per trial: the score of each run. If these jump around, your results are noisy.
  • seconds per call and USD per call: speed and an estimate of cost from the token counts and the prices on the pricing page.

Below the table, the line B minus A shows the average difference per case, with its own margin. The research post recommends this paired comparison when two variants run on the same questions: it removes the noise from some emails simply being harder than others. Under it you see the cases where the two variants differ. Read those emails: they tell you why B is better or worse.

Small test sets, wide margins

With 12 cases, the margin is wide. The research post explains that an eval with few questions can only detect large differences; small ones go unnoticed. So:

  • If the difference is larger than its margin, you have evidence.
  • If it is smaller, you do not. Add test cases, or accept that both variants are about equally good and pick the cheaper or faster one.
  • A score of 100% with a margin of 0% does not mean the prompt is perfect. It means it passed these 12 emails three times. Real emails will hold surprises.
  • No difference is also a result. If both variants pass the same cases, the new prompt did not help on this test set, and that is worth knowing.

Cost and speed count too

Criterion 4 from lesson 1 is speed and price. A model that scores the same but costs many times more is not better for Tjalling. The models overview lists Claude Haiku 5.5 as the fastest and cheapest of the current models. Use the table, not a feeling, to decide whether a stronger model is worth its price.

The steps

  1. Define the two variants: the current prompt and a new one, with the same model.
  2. Create the comparison script: three trials per variant, the same graders as lesson 3, one table row per variant.
  3. Run it and read the table, the B minus A line and the cases that differ.
  4. Optionally compare two models: same prompt, another model in variant B.
  5. Write your decision with the numbers that support it.

Follow the steps below.

Today's actions

Ticks are not saved without an account

Do it in Claude API

Claude API

  1. Open a terminal in your spokeworth-evals folder and turn on the virtual environment: source .venv/bin/activate on macOS or Linux, .venv\Scripts\Activate.ps1 on Windows.
  2. Create variants.py with this code. Variant A is your current prompt. Variant B adds two rules for the edge cases and asks for JSON without code fences. Both use Claude Haiku 5.5.
    from classifier import PROMPT
    
    PROMPT_B = PROMPT.replace(
        "Answer with JSON only",
        "A question about a bill or a payment is invoice. With two requests, the first one decides.\n"
        "Answer with JSON only, without code fences",
    )
    
    # Each variant: (model, prompt). To compare two models, give B the same prompt and another model.
    VARIANTS = {
        "A": ("claude-haiku-5-5", PROMPT),
        "B": ("claude-haiku-5-5", PROMPT_B),
    }
    
    # US dollars per million input and output tokens, from the Claude pricing page.
    PRICES = {"claude-haiku-5-5": (0.10, 0.50), "claude-sonnet-5-5": (2, 10), "claude-opus-5-5": (4, 20)}
    
    TRIALS = 3
  3. Create compare.py with this code. It runs both variants three times over the whole test set, grades each answer with grade() and prints one table row per variant.
    import json
    import statistics
    
    from classifier import classify
    from graders import grade
    from variants import PRICES, TRIALS, VARIANTS
    
    cases = [json.loads(line) for line in open("test_set.jsonl", encoding="utf-8") if line.strip()]
    scores = {}
    
    print("variant | score | +/- | per trial | seconds per call | USD per call")
    for name, (model, prompt) in VARIANTS.items():
        per_case, trials, seconds, cost = [0.0] * len(cases), [], 0.0, 0.0
        for t in range(TRIALS):
            passed = 0
            for i, case in enumerate(cases):
                output, usage, sec = classify(case["email"], model=model, prompt=prompt)
                ok = all(grade(output, case).values())
                per_case[i] += ok / TRIALS
                passed += ok
                seconds += sec
                cost += (usage.input_tokens * PRICES[model][0] + usage.output_tokens * PRICES[model][1]) / 1e6
            trials.append(f"{passed / len(cases):.0%}")
        scores[name] = per_case
        margin = 1.96 * statistics.stdev(per_case) / len(cases) ** 0.5
        n = len(cases) * TRIALS
        print(f"{name} {model} | {statistics.mean(per_case):.0%} | {margin:.0%} | {' '.join(trials)} | {seconds / n:.1f} | {cost / n:.5f}")
    
    diffs = [b - a for a, b in zip(scores["A"], scores["B"])]
    margin = 1.96 * statistics.stdev(diffs) / len(diffs) ** 0.5
    print(f"B minus A: {statistics.mean(diffs):+.0%} +/- {margin:.0%}")
    for case, d in zip(cases, diffs):
        if d:
            print(case["id"], f"B minus A: {d:+.0%}")
  4. Run python compare.py. With the 12 course cases it makes 72 API requests; each extra case adds six. Read the table: score, margin (+/-), the score of each trial, seconds per call and US dollars per call.
  5. Read the line B minus A. If the margin is larger than the difference, this test set cannot tell the two variants apart. Then read the case lines below it: those are the emails where the variants differ.
  6. To compare two models instead, change B in variants.py to ("claude-sonnet-5-5", PROMPT) and run python compare.py again.
  7. Create decision.txt. Write which variant you keep and copy the table rows and the B minus A line that support it.

Note: Cost per call is estimated from the token counts in usage and the prices in variants.py, which come from the pricing page on 4 December 2026 (Haiku 5.5 prices are for prompts up to 100,000 tokens). Check the pricing page before you rely on them.

Paid planPay as you go: buy prepaid credits in the Claude Console (minimum 5 US dollars). There is no free tier. Max, Ultra and Team plans include monthly API credits.

Checked on 4 December 2026 · Source: Claude API docs: Choosing the right model (opens in a new tab)

Create a free account to save your progress. Sign in or sign up