5Guides Updated 1 December 2026 6 min read

Model Evaluation for LLMs: A Practical Guide

A practical model evaluation workflow for LLMs: a 30–50 case golden set, cheap automatic checks, careful LLM-as-judge, cost and latency per case, and regression tests.

By AI Model Hub Desk · 30 November 2026

A clipboard checklist with three mustard ticks and one empty box, next to a small rack of test cards.

To evaluate a new AI model, run it on 30 to 50 real examples from your own product, score each answer with the cheapest check that works (exact match, regex, JSON shape, then an LLM judge only where you must), and record cost and latency per case. Compare that to the model you run today. Public benchmarks help you pick candidates; this small, boring test set decides.

Key takeaways

  • Your own golden set beats any public leaderboard for the final decision, because it contains your inputs, formats and edge cases.
  • Start with deterministic checks. They are free, fast and never disagree with themselves.
  • Use an LLM judge only for open-ended answers, and check the judge against human labels first.
  • Track pass rate, cost per case and latency per case together. A model that is 2 points better at 5x the price may be the wrong pick.
  • Keep the results file. Re-run the same set on every model or prompt change and fail the build on regressions.

How should I evaluate a new AI model?

Treat it like any other dependency upgrade: same inputs, measured outputs, a clear pass bar. A workable loop looks like this:

  1. Shortlist two or three models using public boards. Our LLM benchmarks explainer covers which ones still mean something.
  2. Build a golden set of 30 to 50 cases from real traffic or real tickets.
  3. Write a check per case that a script can run.
  4. Run every candidate through the same harness with the same prompt and settings.
  5. Compare pass rate, cost and latency against your current model.
  6. Save the results as the baseline for the next upgrade.

Thirty cases will not give you tight statistics. They will catch broken formats, wrong refusals and obvious quality drops, which is what most model swaps get wrong.

What metrics matter in model evaluation?

Pick metrics that match the shape of the answer, not the ones that sound sophisticated.

Answer shapeCheckCost to runExample
One correct valueExact match after trimmingFreeA date in YYYY-MM-DD
Value inside free textRegexFreeA SKU like AB-1234 appears
Structured outputParse JSON, check keys and typesFree{"intent": "refund", "order_id": "1182"}
CodeRun the testsCompute onlyGenerated function passes unit tests
Open-ended textLLM-as-judge with a rubricOne extra model callSupport reply is accurate and polite
AnyCost per case, p50/p95 latencyFree to recordDollars and seconds per case, per model

Two numbers people forget: cost per case (input and output tokens times the provider's list price) and latency per case. Reasoning models can spend many output tokens before they answer, so a lower token price does not always mean a cheaper case.

How do I build a golden set that reflects my needs?

Pull cases from where the model will actually work: support tickets, search queries, documents, failing examples from last month. A good 30–50 case set mixes:

  • Common cases (about half): the requests you see every day.
  • Hard cases: long inputs, messy formatting, two questions in one.
  • Edge cases: empty input, wrong language, a request you want refused.
  • Known failures: anything your current model got wrong in production.

For each case store the input, the expected answer or rule, and the check type. Do not tune prompts on the same cases you report. Keep a few back as a holdout.

A dependency-free Python harness

This harness uses only the Python standard library. The model call sits behind one function, call_model, which here returns canned answers so you can run it without an API key. Swap that function for your provider's SDK call and return the text plus the token counts from the response.

import json, re, sys, time

# 1) Your golden set: grow this to 30-50 real cases from your own logs.
CASES = [
    {"id": "refund-1", "prompt": "Customer: I want my money back for order 1182.",
     "check": "json", "schema": {"intent": str, "order_id": str}, "expect": {"intent": "refund"}},
    {"id": "date-1", "prompt": "Extract the date: 'Invoice issued 3 March 2026'. Reply YYYY-MM-DD only.",
     "check": "exact", "expect": "2026-03-03"},
    {"id": "sku-1", "prompt": "Which SKU is mentioned? 'Ship 4x AB-1234 tomorrow'",
     "check": "regex", "expect": r"\bAB-1234\b"},
]
PRICE_IN, PRICE_OUT = 2.00, 10.00  # USD per 1M tokens: copy from your provider's pricing page

def call_model(prompt):
    """The only function that touches a provider. Return (text, input_tokens, output_tokens)."""
    fake = {"refund-1": '{"intent": "refund", "order_id": "1182"}',
            "date-1": "3 March 2026", "sku-1": "The SKU is AB-1234."}
    key = next(c["id"] for c in CASES if c["prompt"] == prompt)
    return fake[key], len(prompt) // 4, 20

def grade(case, out):
    if case["check"] == "exact":
        return out.strip() == case["expect"]
    if case["check"] == "regex":
        return re.search(case["expect"], out) is not None
    if case["check"] == "json":
        try:
            data = json.loads(out)
        except json.JSONDecodeError:
            return False
        typed = all(isinstance(data.get(k), t) for k, t in case["schema"].items())
        return typed and all(data.get(k) == v for k, v in case["expect"].items())
    raise ValueError(case["check"])

def run(baseline_path=None):
    rows = []
    for case in CASES:
        t0 = time.perf_counter()
        out, tin, tout = call_model(case["prompt"])
        ms = (time.perf_counter() - t0) * 1000
        cost = (tin * PRICE_IN + tout * PRICE_OUT) / 1_000_000
        rows.append({"id": case["id"], "pass": grade(case, out), "ms": round(ms, 1), "usd": cost})
    for r in rows:
        print(f'{r["id"]:<10} {"PASS" if r["pass"] else "FAIL"}  {r["ms"]:>7} ms  ${r["usd"]:.6f}')
    passed = sum(r["pass"] for r in rows)
    print(f"{passed}/{len(rows)} passed, total ${sum(r['usd'] for r in rows):.6f}")
    if baseline_path:  # regression: anything that passed before and fails now
        before = {r["id"]: r["pass"] for r in json.load(open(baseline_path))}
        broke = [r["id"] for r in rows if before.get(r["id"]) and not r["pass"]]
        print("regressions:", broke or "none")
        return 1 if broke else 0
    json.dump(rows, open("baseline.json", "w"), indent=1)
    return 0

if __name__ == "__main__":
    sys.exit(run(sys.argv[1] if len(sys.argv) > 1 else None))

Running it with the fake model (we ran this on Python 3.14) prints:

refund-1   PASS      0.0 ms  $0.000222
date-1     FAIL      0.0 ms  $0.000234
sku-1      PASS      0.0 ms  $0.000224
2/3 passed, total $0.000680

The date case fails on purpose: the fake model answers 3 March 2026 instead of 2026-03-03. That is exactly the kind of format drift a model swap causes. The first run writes baseline.json. Later runs take a baseline path, for example python3 evalh.py baseline.json, print any case that passed before and fails now, and exit with code 1, so CI can block the change.

Things to add as your set grows: load cases from a JSONL file, run each case three times for non-deterministic models, and record p95 latency, not only the mean.

When should I use LLM-as-judge, and what can go wrong?

Use a model as a grader when the answer is open text and no rule can score it. The idea is well studied, and so are its failure modes. The MT-Bench and Chatbot Arena paper reported strong agreement between GPT-4 judges and humans, and also documented position bias, verbosity bias and self-enhancement bias.

A short checklist before you trust a judge:

  • Give it a rubric with yes/no criteria, not a 1–10 vibe score.
  • When comparing two answers, swap their order and keep only verdicts that agree both ways.
  • Use a judge from a different model family than the candidates, where you can.
  • Hand-label 20 cases and measure how often the judge agrees with you.
  • Log the judge's reasons, and read the failures.

How do I catch regressions on model upgrades?

Pin model versions where the provider allows it, and treat a version change like a code change. Re-run the golden set, diff against the saved baseline, and look at every case that flipped from pass to fail before you look at the average. Add each new production bug as a case, so the set gets sharper over time.

Which open-source eval tools are worth a look?

Once a single script stops being enough, these maintained open-source projects cover the same ideas with more features:

  • promptfoo: config-driven prompt and model comparisons, plus red-teaming (MIT).
  • Inspect: the UK AI Security Institute's framework for LLM evaluations (MIT).
  • DeepEval: pytest-style LLM test cases and metrics (Apache-2.0).
  • lm-evaluation-harness: EleutherAI's harness for running standard academic benchmarks (MIT).

Start with the script above. Move to a framework when you need dashboards, shared datasets or many evaluators, not before.

Sources

About the author

AI Model Hub Desk, Editors

The editors of AI Model Hub. We cover new models for the people who build with them.

Connecting services