LLM Evals in Java: How to Test Non-Deterministic AI Systems

You shipped the summarizer on Tuesday. It takes an earnings-call transcript and returns JSON — a title plus three bullets — that the mobile app parses and renders as a card. On Thursday you tweaked the system prompt: "be a bit more conversational, users find raw JSON cold." You eyeballed three outputs. They looked warmer, friendlier, better. You shipped it.

The following Tuesday, support tickets arrive: the mobile card is blank. Your "warmer" prompt now wraps the JSON in chatty prose — Here is your summary! on top, Hope that helps. at the bottom. The mobile parser, which does exactly what it was told and extracts nothing gracefully, choked on the preamble. A week of summaries silently failed to render, and the only reason you found out is that a user complained. Your three eyeballed samples all happened to be clean.

This is the testing gap every AI feature has. The prompt is code, the model is a dependency you don't control, and "it looked fine to me" is not a test suite. This post is about the thing that replaces it: evals — a dataset of inputs with expected properties, run on every prompt, model, or code change, with real counters and a verdict your CI can gate on.

Why unit tests don't transfer

A unit test asserts a contract: same input → same output. An LLM hands you: same input → different valid outputs. "Summarize Q3" has a hundred correct wordings, and a test that pins one of them will fail on the ninety-nine others while the feature works perfectly. Pin the wording and you get the worst of both worlds: a red suite and a working feature, until someone deletes the test in frustration.

The shift is small but total: stop asserting the output and start asserting properties of the output. You don't care which words the summary uses. You care that it contains the Q3 revenue figure, that it parses as JSON, that the mobile client can render it. Properties are stable where strings are not — and a harness that checks properties is the closest thing to a test suite a non-deterministic system gets.

The eval harness pattern

An eval harness is deliberately boring infrastructure:

  1. A golden dataset — inputs paired with the properties their outputs must have. Checked in, versioned, reviewed like code.
  2. A runner — feeds each input to the model n times (because one run of a stochastic system tells you nothing), applies the assertions, and records pass/fail with reasons.
  3. A verdict — per-case pass rates, rolled up into counters, compared against thresholds. Pass the threshold and you ship; miss it and you hold. The exit code says which, so CI can enforce it.

The loop it creates is the whole discipline:

1 · Change prompt, model, code 2 · Run dataset n runs per case 3 · Compare vs pass thresholds 4 · SHIP / HOLD exit code gates CI HOLD → revise, then re-run Every prompt edit earns its merge by beating the threshold — not by looking good in three samples.

Two things make this different from "a folder of test prompts." First, the dataset is versioned alongside the prompts — when the prompt changes, the dataset is the thing that tells you whether the change helped. Second, the verdict is mechanical: a threshold and an exit code, not a vibe. If a human has to squint at every run to decide, you don't have evals, you have a demo.

Assertion types, from strongest to weakest

Not all checks are equal. Order them by how much you can trust them, and spend your effort accordingly:

AssertionChecksUse it whenWatch out for
Exact matchOutput equals an expected stringMachine-consumed fields: enums, single-word classifiers, status codesBrittle to harmless rewording — positive vs POSITIVE fails while meaning the same thing
Contains / regexKey facts appear in the proseSummaries, answers — anywhere many wordings are validCase and phrasing: normalize deliberately, and assert the facts, not the sentences
Format / schemaOutput parses the way downstream expectsAnything another program consumes — this is the check that would have saved the mobile cardCheap and high-value; run it on everything with a downstream parser
LLM-as-judgeA second model scores tone, helpfulness, etc. against a rubricQualities no regex can seeWeakest signal. Verbosity bias (longer reads as better), self-preference (a model favors its own style). Always a different model than the generator, calibrated against human labels, never the only signal.
Human spot-checkA person reads a sample of outputsEvery run — it catches what scripts can't, like the summary that's technically correct and completely misleadingDoesn't scale; sample, don't exhaust

Notice the shape: deterministic checks first, model-graded checks last. LLM-as-judge is genuinely useful — "is this response appropriately cautious?" is not a regex question — but treat it as the weakest signal in the stack. A judge that shares the generator's weights is grading its own homework; a judge with no human-calibrated baseline is an opinion with an API. Use it, label it, and never let it be the only thing standing between a prompt edit and production.

The regression workflow

Evals earn their keep as regression protection: the thing that catches the Thursday prompt tweak before it becomes the Tuesday support tickets. The workflow that makes that real:

  • Check the dataset in. src/test/resources/evals/ or equivalent — inputs, expected properties, and the prompt version they were written against. A dataset that lives in someone's laptop is not a regression suite.
  • Run it as a separate CI job, not inside the unit-test job. It has different failure modes (flakes, API errors, cost), different runtime (minutes, not seconds), and different owners. A minimal shape:
# .github/workflows/evals.yml — separate job, gates the merge
jobs:
  evals:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-java@v4
        with: { distribution: temurin, java-version: '21' }
      - run: javac --release 21 EvalHarness.java
      - run: java EvalHarness 3   # non-zero exit blocks the merge
  • Give it its own API budget. Evals call the model — hundreds of cases × n runs × a judge call each is real money per CI run. Cap the job's spend at the provider level, sample the expensive checks, and track dollars-per-run in the summary (the harness below does).
  • Compare against the last green run, not just the threshold. A case dropping from 100% to 92% still passes an 80% threshold — and still deserves a look. Thresholds are the gate; trends are the early warning.
  • Version the system, the dataset, and the scoring logic together. When a failure appears six months from now, "which prompt, which model, which checks" must be answerable from the repo, not from memory.

Measure what matters: real counters

An eval run should produce numbers you can put on a dashboard, not adjectives. Four counters cover most of it:

  • Task success rate over n runs — checks passed ÷ checks run. Each case runs multiple times because a single run of a stochastic system is anecdote, not measurement.
  • Format-validity rate — outputs that parse ÷ outputs produced. Your parser is a contract with downstream; measure the contract directly.
  • Errors — calls that threw, tracked separately. A timeout is not a fail; it's an error, recorded with its message, and the run continues.
  • Cost and latency per run — tokens × rate, wall-clock ms. The bill is a metric too, and "the evals got 3× more expensive" is a change worth noticing.

One honesty rule governs all four: small eval sets give weak signal, and you must say so. Seven cases at 100% is not proof — it's seven anecdotes with a spreadsheet. Report the n alongside the rate, every time.

Worked example: EvalHarness

Enough theory. Here is a complete, runnable harness — one file, no dependencies, no API key. The model client is a stub with scripted responses: some pass, some fail, one throws a simulated timeout. That is deliberate: the harness must be demonstrable without spending a cent, and its numbers are plainly the stub's numbers, not a claim about any real model. Swap StubModelClient for an HTTP client and the same harness runs against production.

import java.time.Duration;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.function.ToIntFunction;
import java.util.regex.Pattern;

/**
 * EvalHarness — a minimal evaluation harness for non-deterministic AI features.
 *
 * Runs a golden dataset of cases, each several times, through a ModelClient,
 * checks every output with scripted assertions, and prints a summary table with
 * real counters: per-case pass rates, task success rate, format-validity rate,
 * tokens, cost, and latency. Exits non-zero when any case falls below the pass
 * threshold, so a CI job can gate on it.
 *
 * The ModelClient here is a STUB with scripted responses: some pass, some fail,
 * one throws. No API key, no network. Its numbers are the stub's numbers — the
 * point is the shape of the harness, not the scores.
 */
public class EvalHarness {

    // ------------------------------------------------------------------
    // Model client boundary — swap StubModelClient for a real HTTP client
    // ------------------------------------------------------------------
    interface ModelClient {
        /** Returns the model's text output for a prompt. May throw on failure. */
        String complete(String prompt) throws ModelException;
        /** Estimated prompt+completion tokens for the last call (cost accounting). */
        int lastCallTokens();
    }

    static class ModelException extends Exception {
        ModelException(String message) { super(message); }
        ModelException(String message, Throwable cause) { super(message, cause); }
    }

    // ------------------------------------------------------------------
    // Assertions — a check returns null on pass, or the reason it failed
    // ------------------------------------------------------------------
    interface Assertion {
        String name();
        String check(String output);
    }

    /** Exact match: for the structured bits a downstream parser depends on. */
    static Assertion exact(String expected) {
        return new Assertion() {
            public String name() { return "exact-match"; }
            public String check(String output) {
                return output.strip().equals(expected) ? null
                    : "expected exactly " + repr(expected) + " but got " + repr(output.strip());
            }
        };
    }

    /** Key facts must appear: for prose where many wordings are valid. */
    static Assertion containsAll(String... requiredFacts) {
        return new Assertion() {
            public String name() { return "contains-facts"; }
            public String check(String output) {
                List<String> missing = new ArrayList<>();
                String lower = output.toLowerCase(Locale.ROOT);
                for (String fact : requiredFacts) {
                    if (!lower.contains(fact.toLowerCase(Locale.ROOT))) {
                        missing.add(fact);
                    }
                }
                return missing.isEmpty() ? null : "missing required facts: " + missing;
            }
        };
    }

    /** Shape check: the output must parse the way the mobile client expects. */
    static Assertion matchesFormat(Pattern pattern, String description) {
        return new Assertion() {
            public String name() { return "format"; }
            public String check(String output) {
                return pattern.matcher(output.strip()).matches() ? null
                    : "output did not match format: " + description;
            }
        };
    }

    /**
     * Stand-in for an LLM-as-judge call. In production this would send the output
     * plus a rubric to a *different* model and parse its 1-5 score. Here a
     * deterministic heuristic stands in. Treat this as the weakest signal:
     * judges have verbosity and self-preference biases, so never ship on it alone.
     */
    static Assertion judgedScore(int minScore, ToIntFunction<String> judge) {
        return new Assertion() {
            public String name() { return "llm-judge(stub)"; }
            public String check(String output) {
                int score = judge.applyAsInt(output);
                return score >= minScore ? null
                    : "judge score " + score + " below minimum " + minScore;
            }
        };
    }

    // ------------------------------------------------------------------
    // Dataset
    // ------------------------------------------------------------------
    record EvalCase(String id, String prompt, List<Assertion> assertions) {}

    record CaseResult(String id, int runs, int passed, int errors,
                      int formatPassed, int formatChecked,
                      long msTotal, int tokensTotal, List<String> failureReasons) {}

    private static final Pattern SUMMARY_JSON = Pattern.compile(
        "^\\{\\s*\"title\"\\s*:\\s*\".*?\"\\s*,\\s*\"bullets\"\\s*:\\s*\\[.*\\]\\s*\\}$",
        Pattern.DOTALL);
    private static final Pattern SENTIMENT_ENUM =
        Pattern.compile("^(POSITIVE|NEGATIVE|NEUTRAL)$");
    private static final Pattern MIN_LENGTH = Pattern.compile("^.{10,2000}$", Pattern.DOTALL);

    /** The golden dataset: checked in, versioned, run on every prompt/model change. */
    static List<EvalCase> goldenDataset() {
        return List.of(
            new EvalCase("summarize-ok",
                "[case:summarize-ok] Summarize the earnings call as JSON with title and bullets.",
                List.of(
                    matchesFormat(SUMMARY_JSON, "{\"title\":...,\"bullets\":[...]}"),
                    containsAll("Q3 revenue", "churn", "guidance"))),
            new EvalCase("summarize-missing-fact",
                "[case:summarize-missing-fact] Summarize the earnings call as JSON with title and bullets.",
                List.of(
                    matchesFormat(SUMMARY_JSON, "{\"title\":...,\"bullets\":[...]}"),
                    containsAll("Q3 revenue", "churn", "guidance"))),
            new EvalCase("summarize-bad-format",
                "[case:summarize-bad-format] Summarize the earnings call as JSON with title and bullets.",
                List.of(
                    matchesFormat(SUMMARY_JSON, "{\"title\":...,\"bullets\":[...]}"),
                    containsAll("Q3 revenue", "churn", "guidance"))),
            new EvalCase("sentiment-exact",
                "[case:sentiment-exact] Classify sentiment. Reply with exactly one word.",
                List.of(
                    matchesFormat(SENTIMENT_ENUM, "one of POSITIVE|NEGATIVE|NEUTRAL"),
                    exact("POSITIVE"))),
            new EvalCase("sentiment-case-drift",
                "[case:sentiment-case-drift] Classify sentiment. Reply with exactly one word.",
                List.of(
                    matchesFormat(SENTIMENT_ENUM, "one of POSITIVE|NEGATIVE|NEUTRAL"),
                    exact("POSITIVE"))),
            new EvalCase("tone-judge-weak",
                "[case:tone-judge-weak] Write one friendly sentence about the Acme Widget.",
                List.of(
                    matchesFormat(MIN_LENGTH, "10-2000 chars"),
                    // heuristic stand-in: terse dismissive copy scores 2, warm copy scores 4
                    judgedScore(3, out -> out.contains("meh") ? 2 : 4))),
            new EvalCase("summarize-timeout",
                "[case:summarize-timeout] Summarize the earnings call as JSON with title and bullets.",
                List.of(matchesFormat(SUMMARY_JSON, "{\"title\":...,\"bullets\":[...]}")))
        );
    }

    // ------------------------------------------------------------------
    // Stubbed model client — deterministic scripted responses, no API key
    // ------------------------------------------------------------------
    static class StubModelClient implements ModelClient {
        private int tokens;

        public int lastCallTokens() { return tokens; }

        public String complete(String prompt) throws ModelException {
            sleep(8); // stub latency: the real client spends seconds here
            if (prompt.contains("[case:summarize-ok]")) {
                tokens = 210;
                return """
                    {"title":"Q3 revenue up 12%","bullets":[
                      "Revenue rose 12% year over year on cloud growth.",
                      "Mobile app churn fell to 3.1% after the onboarding redesign.",
                      "Guidance raised: full-year growth now expected at 10%."]}""";
            }
            if (prompt.contains("[case:summarize-missing-fact]")) {
                tokens = 190;
                return """
                    {"title":"Quarterly update","bullets":[
                      "Revenue grew on cloud strength.",
                      "The mobile app improved after redesign.",
                      "Guidance was raised for the full year."]}""";
            }
            if (prompt.contains("[case:summarize-bad-format]")) {
                tokens = 260;
                return """
                    Here is your summary!
                    {"title":"Q3 revenue up 12%","bullets":[
                      "Revenue rose 12% year over year."]}
                    Hope that helps.""";
            }
            if (prompt.contains("[case:sentiment-exact]")) {
                tokens = 24;
                return "POSITIVE";
            }
            if (prompt.contains("[case:sentiment-case-drift]")) {
                tokens = 24;
                return "positive"; // a "harmless" prompt tweak broke the parser
            }
            if (prompt.contains("[case:tone-judge-weak]")) {
                tokens = 60;
                return "meh product is ok i guess, does the thing";
            }
            if (prompt.contains("[case:summarize-timeout]")) {
                throw new ModelException("simulated timeout after 30s waiting for completion");
            }
            tokens = 40;
            return "UNKNOWN CASE";
        }

        private static void sleep(long ms) {
            try {
                Thread.sleep(ms);
            } catch (InterruptedException e) {
                Thread.currentThread().interrupt();
            }
        }
    }

    // ------------------------------------------------------------------
    // Runner
    // ------------------------------------------------------------------
    /** Illustrative pricing only — replace with your provider's real rates. */
    private static final double USD_PER_1K_TOKENS = 0.002;

    public static void main(String[] args) {
        int runsPerCase = args.length > 0 ? parseRuns(args[0]) : 3;
        double passThreshold = 0.80;

        ModelClient client = new StubModelClient();
        List<EvalCase> dataset = goldenDataset();
        List<CaseResult> results = new ArrayList<>();

        for (EvalCase c : dataset) {
            results.add(runCase(client, c, runsPerCase));
        }

        printTable(results, runsPerCase);
        boolean allAboveThreshold = printSummary(results, runsPerCase, passThreshold);

        System.out.println();
        System.out.println("NOTE: outputs above come from StubModelClient — scripted responses,");
        System.out.println("no API calls. Its pass rates are the stub's, not any real model's.");
        System.exit(allAboveThreshold ? 0 : 1);
    }

    private static int parseRuns(String arg) {
        try {
            int n = Integer.parseInt(arg);
            if (n < 1) throw new IllegalArgumentException("runs must be >= 1");
            return n;
        } catch (NumberFormatException e) {
            throw new IllegalArgumentException("first arg must be an integer (runs per case)", e);
        }
    }

    /** One case failing must never abort the whole run — record and continue. */
    private static CaseResult runCase(ModelClient client, EvalCase c, int runs) {
        int passed = 0, errors = 0, formatPassed = 0, formatChecked = 0;
        long msTotal = 0;
        int tokensTotal = 0;
        List<String> failureReasons = new ArrayList<>();

        for (int i = 1; i <= runs; i++) {
            long start = System.nanoTime();
            try {
                String output = client.complete(c.prompt());
                msTotal += Duration.ofNanos(System.nanoTime() - start).toMillis();
                tokensTotal += client.lastCallTokens();

                List<String> failures = new ArrayList<>();
                for (Assertion a : c.assertions()) {
                    String reason = a.check(output);
                    if (a.name().equals("format")) {
                        formatChecked++;
                        if (reason == null) formatPassed++;
                    }
                    if (reason != null) {
                        failures.add(a.name() + ": " + reason);
                    }
                }
                if (failures.isEmpty()) {
                    passed++;
                } else {
                    failureReasons.add("run " + i + " -> " + String.join("; ", failures));
                }
            } catch (Exception e) {
                failureReasons.add("run " + i + " -> ERROR: " + e.getMessage());
                errors++;
            }
        }
        return new CaseResult(c.id(), runs, passed, errors, formatPassed, formatChecked,
            msTotal, tokensTotal, failureReasons);
    }

    private static void printTable(List<CaseResult> results, int runsPerCase) {
        System.out.println();
        System.out.printf("%-24s %5s %7s %9s %10s%n",
            "CASE", "RUNS", "PASSED", "PASS RATE", "AVG MS");
        System.out.println("-".repeat(62));
        for (CaseResult r : results) {
            double rate = (double) r.passed() / r.runs();
            double avgMs = r.runs() - r.errors() == 0 ? 0
                : (double) r.msTotal() / (r.runs() - r.errors());
            System.out.printf("%-24s %5d %7d %8.1f%% %10.1f%n",
                r.id(), r.runs(), r.passed(), rate * 100, avgMs);
            for (String reason : r.failureReasons()) {
                System.out.println("    ! " + reason);
            }
        }
    }

    private static boolean printSummary(List<CaseResult> results, int runsPerCase,
                                        double threshold) {
        int totalRuns = 0, totalPassed = 0, totalErrors = 0;
        int formatPassed = 0, formatChecked = 0;
        long totalMs = 0;
        int totalTokens = 0;
        List<String> belowThreshold = new ArrayList<>();

        for (CaseResult r : results) {
            totalRuns += r.runs();
            totalPassed += r.passed();
            totalErrors += r.errors();
            formatPassed += r.formatPassed();
            formatChecked += r.formatChecked();
            totalMs += r.msTotal();
            totalTokens += r.tokensTotal();
            if ((double) r.passed() / r.runs() < threshold) {
                belowThreshold.add(r.id());
            }
        }

        double taskSuccess = (double) totalPassed / totalRuns;
        double formatValidity = formatChecked == 0 ? 0 : (double) formatPassed / formatChecked;
        double estCost = totalTokens / 1000.0 * USD_PER_1K_TOKENS;

        System.out.println();
        System.out.println("SUMMARY");
        System.out.printf("  task success rate : %.1f%% (%d/%d checks passed)%n",
            taskSuccess * 100, totalPassed, totalRuns);
        System.out.printf("  format-validity   : %.1f%% (%d/%d outputs parse as expected)%n",
            formatValidity * 100, formatPassed, formatChecked);
        System.out.printf("  errors            : %d (model call threw; recorded, run continued)%n",
            totalErrors);
        System.out.printf("  tokens            : %d  |  est. cost: $%.4f (illustrative pricing)%n",
            totalTokens, estCost);
        System.out.printf("  total wall time   : %d ms%n", totalMs);

        System.out.println();
        if (belowThreshold.isEmpty()) {
            System.out.printf("VERDICT: SHIP — all %d cases at/above %.0f%% threshold%n",
                results.size(), threshold * 100);
            return true;
        }
        System.out.printf("VERDICT: HOLD — %d of %d cases below %.0f%% threshold: %s%n",
            belowThreshold.size(), results.size(), threshold * 100, belowThreshold);
        return false;
    }

    private static String repr(String s) {
        return "\"" + (s.length() > 60 ? s.substring(0, 57) + "..." : s) + "\"";
    }
}

Compile and run it — pass a number to change the runs per case:

javac --release 21 EvalHarness.java
java EvalHarness 3

This is the actual output from running it (exit code 1 — the HOLD verdict):

CASE                      RUNS  PASSED PASS RATE     AVG MS
--------------------------------------------------------------
summarize-ok                 3       3    100.0%        8.7
summarize-missing-fact       3       0      0.0%        8.0
    ! run 1 -> contains-facts: missing required facts: [Q3 revenue, churn]
    ! run 2 -> contains-facts: missing required facts: [Q3 revenue, churn]
    ! run 3 -> contains-facts: missing required facts: [Q3 revenue, churn]
summarize-bad-format         3       0      0.0%        8.0
    ! run 1 -> format: output did not match format: {"title":...,"bullets":[...]}; contains-facts: missing required facts: [churn, guidance]
    ! run 2 -> format: output did not match format: {"title":...,"bullets":[...]}; contains-facts: missing required facts: [churn, guidance]
    ! run 3 -> format: output did not match format: {"title":...,"bullets":[...]}; contains-facts: missing required facts: [churn, guidance]
sentiment-exact              3       3    100.0%        8.0
sentiment-case-drift         3       0      0.0%        8.0
    ! run 1 -> format: output did not match format: one of POSITIVE|NEGATIVE|NEUTRAL; exact-match: expected exactly "POSITIVE" but got "positive"
    ! run 2 -> format: output did not match format: one of POSITIVE|NEGATIVE|NEUTRAL; exact-match: expected exactly "POSITIVE" but got "positive"
    ! run 3 -> format: output did not match format: one of POSITIVE|NEGATIVE|NEUTRAL; exact-match: expected exactly "POSITIVE" but got "positive"
tone-judge-weak              3       0      0.0%        8.0
    ! run 1 -> llm-judge(stub): judge score 2 below minimum 3
    ! run 2 -> llm-judge(stub): judge score 2 below minimum 3
    ! run 3 -> llm-judge(stub): judge score 2 below minimum 3
summarize-timeout            3       0      0.0%        0.0
    ! run 1 -> ERROR: simulated timeout after 30s waiting for completion
    ! run 2 -> ERROR: simulated timeout after 30s waiting for completion
    ! run 3 -> ERROR: simulated timeout after 30s waiting for completion

SUMMARY
  task success rate : 28.6% (6/21 checks passed)
  format-validity   : 66.7% (12/18 outputs parse as expected)
  errors            : 3 (model call threw; recorded, run continued)
  tokens            : 2304  |  est. cost: $0.0046 (illustrative pricing)
  total wall time   : 146 ms

VERDICT: HOLD — 5 of 7 cases below 80% threshold: [summarize-missing-fact, summarize-bad-format, sentiment-case-drift, tone-judge-weak, summarize-timeout]

NOTE: outputs above come from StubModelClient — scripted responses,
no API calls. Its pass rates are the stub's, not any real model's.

Reading the results

Every number above is real — computed by the harness from the stub's responses, not typed by hand. Walk the rows, because each one teaches something:

  • summarize-ok passes 3/3: valid JSON shape, all three facts present. This is your baseline — the behavior you want to protect.
  • summarize-missing-fact fails contains-facts: the shape is fine but "Q3 revenue" and "churn" vanished from the prose. A fact dropped silently is the failure mode eyeballing misses — the summary reads fine.
  • summarize-bad-format is Thursday's incident, replayed: chatty preamble breaks the format check, which is exactly what the mobile parser choked on. If this case had existed before the "warmer" prompt shipped, the merge would have been blocked.
  • sentiment-case-drift shows exact-match brittleness: positive means the same thing as POSITIVE, but the parser disagrees. The lesson isn't "never use exact match" — it's to choose the assertion deliberately, and to normalize (or case-fold) when the contract allows it.
  • tone-judge-weak shows the judge signal firing — and notice it's still just one row among deterministic checks, not the verdict.
  • summarize-timeout proves the harness survives a throwing client: the error is recorded with its message, the run continues, and errors are counted separately from failures. A timeout is not a fail.

The summary counters are the dashboard: 28.6% task success (6/21), 66.7% format-validity (12/18), 3 errors, 2,304 tokens at an illustrative $0.0046, 146 ms of wall time. The verdict is HOLD and the process exits 1 — which is precisely what you want a CI gate to do with this dataset. And the honesty footnote, stated plainly: the stub is deterministic, so 3 runs give the same answer 3 times. A real model varies run to run — which is exactly why the harness runs each case n times instead of once.

When it breaks: 4 traps

1. The eval set is too small to mean anything. Five examples at 100% is not evidence — it's anecdote with a spreadsheet. As a rule of thumb: if a single example flipping changes your verdict, you don't have an eval, you have a demo. Grow the set from real user traffic and support tickets, and always report the n next to the rate.

2. You're testing on your training examples. If the golden cases are the same five prompts you tuned the prompt against, you're measuring how well the prompt memorizes your own taste, not how it handles the wild. Source cases from production logs, rotate in fresh ones, and retire cases the prompt has visibly overfit.

3. The judge is the same model that generated. Self-preference bias is real: a model grades its own style generously and penalizes phrasing it wouldn't use. The judge must be a different model, its rubric versioned, and its scores calibrated against human labels before you trust them — then spot-check it forever, because judges drift too.

4. You ignored cost until the bill arrived. Hundreds of cases × n runs × a judge call per output is real money on every CI run, and eval spend is the easiest budget to blow because nobody feels it until finance asks. Cap the job's spend, sample the expensive checks, and keep dollars-per-run in the summary table where every engineer sees it.

The principle

Every prompt edit feels like an improvement to the person who made it — that is exactly why "it looked better to me" shipped a week of blank mobile cards. The fix isn't more careful eyeballing; it's a harness that turns "better" into a number before the merge.

If you can't measure it, you don't know if the prompt edit helped.

Build the dataset before you need it, run it on every change, gate the merge on the verdict, and keep the counters honest — rates with their n, errors separate from failures, costs in dollars. Non-deterministic systems don't get unit tests. They get evals. And evals, run relentlessly, are how you ship AI features without learning about your regressions from support tickets.

This post is part of the Java Learning Roadmap 2026 — AI for Java Developers track.

Comments

Popular posts from this blog

JSP Servlet Interview Questions For Freshers Series 1

What are the core classes and interfaces of hibernate 4

Java Banking Finance Services and Insurance (BFSI) domain interview questions