Shaf Lab

Model evaluation

Measuring how well a model or AI system performs on the tasks you actually care about.

Model evaluation, often shortened to evals, measures how well a model or a whole AI system performs on the tasks you care about. It ranges from public benchmarks that compare models in general to private test sets built from your own users' requests. For a product, the private set matters far more, because benchmark scores rarely predict performance on a specific task.

A useful eval has three parts: a fixed set of representative inputs, a definition of a good output for each, and a scoring method. Scoring can be exact checks, such as whether the JSON parses or the right document was retrieved; task metrics, such as error rates for speech; human ratings; or a model acting as a judge. Prefer the cheapest method that reliably agrees with human judgment.

Build the set from reality. Start with a few dozen real examples, include the hard and embarrassing cases, and add every production failure you fix as a new test so it cannot quietly return. Run the eval on every change to the prompt, model, retrieval, or tools, and compare against the previous version, not against an absolute score.

Evaluate the whole system, not just the model. In retrieval and agent systems, many failures come from the wrong context, a bad tool result, or a broken step in the loop. Measure each stage separately where you can, so a drop in quality points to its cause.

Error analysis (AI evals)

Reading real outputs, noting what went wrong, and grouping those observations into failure types you can count.

Error analysis is the habit of reading a batch of real traces from an AI system, writing a short observation on what went wrong in each, and then sorting those observations into a few named failure types with counts. It comes first because it tells you which evals are worth building. Generic scores such as helpfulness or ROUGE rarely line up with what is actually breaking in a specific product.

The method borrows two steps from qualitative research. In open coding you write free-form observations with no fixed categories, focusing on the first thing that went wrong in each trace. In axial coding you group those observations into a failure taxonomy with crisp, non-overlapping definitions, and count how often each appears. Keep sampling until new traces stop revealing new categories, which usually takes around a hundred. Then fix the obvious bugs directly and build automated checks only for failures that are frequent, costly, or likely to come back.

Golden datasets (AI evals)

A curated, versioned set of test inputs with trusted expected outputs, used to score every change.

A golden dataset, or gold set, is a curated collection of test cases for an AI system, each with an input and a trusted description of what a good output looks like. That description might be a reference answer, a list of facts the answer must contain, or simply "must refuse". Someone who knows the domain reviews the labels, and the set is versioned so every score maps to an exact set of cases.

Seed it from real traffic, especially requests that failed, and make sure every failure type you care about has cases, including rare ones. Prefer expectations that are easy to check over long reference paragraphs. Fifty to a hundred well-chosen cases catch most regressions, but telling two close systems apart takes more. Gold sets go stale as products and users change, so add new production failures regularly, retire cases that no longer reflect real use, and keep them out of prompts and training data so they keep measuring skill rather than memory.

Synthetic eval data

Test inputs generated by a model, structured along defined dimensions, to cover cases real traffic lacks.

Synthetic eval data is test input generated by a model rather than collected from users. It helps before launch, when there is no traffic yet, and for failures that are too rare in real logs to test well. Simply asking a model for test questions tends to return bland, repetitive prompts, so the useful approach is structured.

First define dimensions, the ways real inputs vary, such as topic, user expertise, and intent. Generate combinations of those values, check that they cover what matters, and only then turn each combination into a natural-sounding request in a separate step. Run every input through the full system and review the results like real traces. Synthetic data cannot tell you how common a failure is, and it is weakest in specialist or high-stakes domains, so replace or validate it with real data as soon as you can.

Code-based graders

Deterministic checks in ordinary code, such as regex, schema validation, unit tests, or state inspection.

A code-based grader is an eval check written in ordinary code instead of asking a model or a person. Typical examples are exact or pattern matches, length limits, JSON schema validation, running generated code against unit tests, checking which tool was called with which arguments, and inspecting the environment afterward to confirm a file, row, or event really exists.

They are fast, nearly free, reproducible, and easy to debug, which makes them ideal for running on every pull request. Their weakness is brittleness: a correct answer phrased differently can fail an overly strict check. Use them for anything that truly has one right form, and reserve model-based judges for qualities that need judgment, such as tone or whether an answer is supported by its retrieved context.

LLM-as-judge

Using a capable language model to grade outputs against a rubric or to pick the better of two answers.

LLM-as-judge uses a capable language model to grade outputs, either scoring a single answer against a rubric or choosing the better of two answers. It scales to thousands of examples at low cost and can assess qualities that exact checks cannot, such as helpfulness, faithfulness to retrieved context, or tone.

Judges have known biases. They tend to favor the first answer shown, longer answers, and answers in their own style or from their own model family, and they can be swayed by confident wording. Reduce these by swapping answer order and averaging, using specific rubrics with concrete criteria, asking for a short justification before the score, and using a different model from the one being judged. Before trusting a judge, check its agreement with human labels on a sample, and recheck when you change the judge model or prompt.

LLM judge calibration

Measuring how often an LLM judge agrees with human labels, then correcting or improving it.

Judge calibration means checking an LLM judge against human labels before trusting its scores. A person labels a sample of outputs as pass or fail, the judge grades the same outputs, and you compare. Keep the examples used to write the judge prompt separate from the examples used to measure it, or you only learn how well it copied its own examples.

Report two numbers rather than raw accuracy, since failures are usually rare. The true positive rate is the share of human-flagged failures the judge also caught. The true negative rate is the share of human-approved outputs the judge also passed. Knowing both lets you correct the failure rate the judge reports on unlabeled traffic. Recheck whenever the judge model, its prompt, or the product changes, because agreement drifts.

Pairwise evaluation

Showing a judge two outputs for the same input and asking which is better.

Pairwise evaluation shows a judge, human or model, two outputs for the same input and asks which one is better. It mirrors how people naturally compare, picks up small differences that absolute scores miss, and is the basis of human-preference leaderboards that turn many head-to-head votes into a ranking with an Elo-style rating.

The alternative is pointwise scoring, where each output is graded alone against a rubric. Pointwise gives absolute pass rates that suit monitoring and release gates. Pairwise gives only relative results, so it fits questions like whether a new prompt beats the old one. Model judges tend to favor whichever answer appears first, so run every comparison in both orders and count a win only when it holds both ways.

Inter-annotator agreement

How consistently different human labelers assign the same labels, corrected for chance.

Inter-annotator agreement measures how often different people give the same label to the same item. It tells you whether a rubric is clear enough to produce trustworthy labels, and it sets a ceiling: an automated grader cannot meaningfully beat the level at which humans agree with each other.

Raw percent agreement is misleading when one label dominates, so use chance-corrected statistics. Cohen's kappa compares two annotators, Fleiss' kappa extends to more, and Krippendorff's alpha handles any number of annotators, missing labels, and ordered scales. Low agreement usually points to an ambiguous rubric rather than careless annotators. Small teams often do better with a single domain expert labeling consistently, adding more annotators only when the domain demands it.

Regression evals

An eval suite of tasks the system already handles, expected to pass nearly 100% and run on every change.

Regression evals check that an AI system still does everything it used to do. They contrast with capability evals, which target tasks the system struggles with and are expected to start at a low pass rate. A regression suite should pass close to 100 percent, so any drop signals that something broke.

Run cheap deterministic checks on every pull request, model-graded checks on a sample, and the full suite nightly or before release. Because outputs vary between runs, repeat tasks and compare pass rates rather than single results, and set thresholds per failure type rather than one blended score. When a capability task starts passing reliably, promote it into the regression suite, and add every production bug you fix as a new case.

Online evals

Scoring a live AI system on real traffic with sampled graders, guardrails, and user signals.

Online evals score an AI system after it ships, on real traffic, as opposed to offline evals that run a fixed dataset before release. Common forms are running graders on a sample of production traces, small guardrail classifiers in the request path that block bad responses, user signals such as retries, edits, and thumbs-down, and controlled experiments.

Offline evals stop known failures from returning, while online evals find the ones nobody anticipated. Their most valuable output is a steady stream of new failing traces, which feed the next round of error analysis and become new cases in the offline dataset. That loop between production and the test set is what keeps evals honest over time.

Guardrail metrics (A/B tests)

Metrics an experiment must not make worse, such as latency, cost, or error rate, whatever the main result.

In a controlled experiment, guardrail metrics are the measures that must not get worse, even if the primary metric improves. They protect against wins that quietly cost something important. They are a different idea from AI guardrails, the filters that block unsafe model output, though the two can overlap.

For AI features, typical guardrails are p95 latency and time to first token, cost per request, error and fallback rates, false-refusal rate, safety flags, a sampled hallucination rate, and complaints or escalations. Experimentation practice also uses trust guardrails that check the test itself is valid, such as confirming that a 50/50 traffic split actually arrived as 50/50 before reading any result.

Eval-driven development

Writing the evaluation for an AI behavior before changing the system, like test-first coding.

Eval-driven development applies the test-first idea to AI systems: define how a behavior will be measured before changing prompts, models, or tools, then iterate until the eval passes. It forces a team to agree on what success means, which resolves ambiguity in a spec early.

It works best when success is crisp and known in advance, such as a required output format, a phrase that must never appear, or a request that must always be refused. For fuzzy qualities like tone or helpfulness, failure modes are hard to predict, so many practitioners first study real outputs and write evals only for failures that actually show up. Either way, every bug that reaches users should become a test before it is fixed.

RAG evaluation

Scoring retrieval and generation separately to find whether a RAG failure came from search or from the answer.

RAG evaluation measures a retrieval-augmented system in two halves. The retrieval half asks whether the right passages came back. The generation half asks whether the answer used those passages faithfully and actually addressed the question. Scoring them separately tells you whether to fix search or fix the prompt and model.

Retrieval is scored with relevance labels and metrics such as recall and precision at k. Generation is usually scored by calibrated model judges for faithfulness, answer relevance, and correct abstention when the passages lack the answer. If retrieval recall is low, no prompt will save the answer. If recall is high but faithfulness is low, the problem is in generation. Include multi-hop and unanswerable questions in the test set on purpose.

Retrieval recall and precision

The share of relevant passages a search returns, and the share of returned passages that are relevant.

Recall at k is the share of all relevant passages that appear in the top k results. Precision at k is the share of those top k results that are actually relevant. For retrieval-augmented generation, recall matters most, because a model cannot use a passage that was never retrieved. Low precision wastes context space and can distract the model.

Related rank-aware metrics fill in the picture. Hit rate at k counts questions with at least one relevant result. Mean reciprocal rank rewards putting the first relevant result near the top. Normalized discounted cumulative gain handles graded relevance. All of them need labels saying which passages answer each question, and they are cheap enough to compare chunking, embedding, and reranking choices without running the generator at all.

RAG faithfulness

Whether every claim in a generated answer is supported by the retrieved context.

Faithfulness, also called groundedness, asks whether every claim in a generated answer is backed by the passages the system retrieved. It is the main hallucination metric for retrieval-augmented systems. A common method splits the answer into short atomic claims and has a judge check each one against the context.

Faithfulness is not the same as correctness. An answer can be faithful to a wrong document, or correct but drawn from the model's training rather than the retrieved documents, which matters when you promise answers come from your material. Report both, include questions the corpus cannot answer to test whether the system admits it, and calibrate the faithfulness judge against human labels.

Agent evaluation

Testing multi-step AI agents on outcomes, trajectories, and reliability across repeated runs.

Agent evaluation tests systems that plan, call tools, and change state over many steps. Checking the final message is not enough: an agent can say a flight is booked when no booking exists. Good agent evals look at the outcome, meaning the actual state of the environment afterward, the trajectory of steps it took, and how reliably it succeeds across repeated trials.

Each task runs in a sandboxed environment that resets between trials and that graders can inspect, such as a container with tests, a mock API backed by a real database, or a simulated user. Grade outcomes first and add trajectory rules for safety and efficiency, without insisting on one exact path, since capable agents often find valid routes nobody planned. Track turns, tokens, and time per task alongside success.

Tool-call accuracy

Whether a model picks the right tool, passes correct arguments, and avoids unneeded calls.

Tool-call accuracy measures how well a model uses the functions it is given. It breaks into parts you can check separately: choosing the right tool or correctly choosing none, supplying required arguments with valid types and correct values, calling tools in a workable order, and avoiding unnecessary, repeated, or forbidden calls.

Compare arguments structurally, as parsed objects, rather than as strings, so key order and spacing do not cause false failures. Include cases where no tool should be called, since over-eager calling is a common failure, and cases where a tool returns an error or nothing, to test recovery. Where possible, also execute the calls in a sandbox and check the result.

pass@k and pass^k

The chance at least one of k attempts succeeds, versus the chance all k attempts succeed.

Because models answer differently on each run, evals often sample several attempts per task. pass@k is the probability that at least one of k attempts succeeds. It suits settings where a test or a person can pick the working attempt, such as code generation, and is usually estimated from more samples than k with an unbiased formula.

pass^k is the probability that all k attempts succeed, which matters for customer-facing agents that must work every time. The two diverge quickly. An agent that succeeds 75 percent of the time per try has a pass^3 of only about 42 percent, while its pass@3 is over 98 percent. Always state which one a reported number means.

AI benchmarks

Public, fixed test sets for comparing models, distinct from private evals of your own product.

An AI benchmark is a public, fixed test that lets anyone compare models on the same tasks, such as knowledge questions, math problems, real GitHub issues, or tool-use scenarios. Some use automatic scoring, while human-preference arenas rank models from many head-to-head votes. Holistic suites report several metrics at once, such as accuracy, calibration, robustness, and efficiency, to avoid one-number rankings.

Benchmarks are good for shortlisting models but poor at predicting performance on your specific product, which depends on your prompts, data, tools, and users. They also wear out as models saturate them or as test items leak into training data. Use them to narrow the field, then decide with a private eval built from your own traffic.

Benchmark contamination

When test items leak into a model's training data, so scores reflect memory instead of skill.

Benchmark contamination, or data leakage, happens when test questions or their answers end up in a model's training data. Because large models train on most of the public web, including code hosting sites, public benchmarks are at constant risk. Once leaked, higher scores measure exposure rather than ability. A widely used coding benchmark built from public repositories was retired by a major lab in 2026 after models were found reproducing its reference fixes.

Detection methods include prompting a model with the start of a test item to see if it completes the rest verbatim, comparing scores on items published before and after a model's training cutoff, building fresh look-alike test sets, and perturbing names and numbers to see if accuracy collapses. To protect your own evals, keep them private, out of prompts, fine-tuning data, and retrieval corpora, and refresh them with new cases.

Word error rate

The share of reference words a speech recognizer got wrong, counting substitutions, deletions, and insertions.

Word error rate, or WER, is the standard accuracy metric for speech recognition. The recognized text is aligned with a reference transcript by edit distance, and the substitutions, deletions, and insertions are added up and divided by the number of reference words. Since insertions count, it can exceed 100 percent. Character error rate applies the same formula to characters and suits languages written without spaces.

The biggest pitfall is text normalization. Capitalization, punctuation, numbers written as digits or words, and spelling variants all count as errors unless both sides are normalized the same way, so WER figures computed with different normalizers are not comparable. WER also weighs every word equally, so a dropped "not" costs the same as a dropped filler word. Pair it with task-level checks when meaning matters.

Phone error rate

The share of reference speech sounds a recognizer got wrong, counting substitutions, deletions, and insertions.

Phone error rate, or PER, measures how accurately a speech system recognizes phones, the individual speech sounds of a language. The predicted sequence is aligned with a reference transcription using edit distance. The substitutions, deletions, and insertions are added up and divided by the number of phones in the reference. It is the sound-level counterpart of word error rate.

Because insertions count, a system that outputs many extra phones can exceed 100 percent. PER is used for phoneme recognition, pronunciation assessment, and work on languages without standard spelling, where word-level scoring is impractical. Scores depend on the phone set and transcription conventions, so compare systems only on the same reference set.