AI · LLM · Test automation · CI/CD

LLM Evals: Testing AI Features the Way You Test Software

Verifying LLM-based features with test automation discipline: evaluation sets, rule-based and LLM-as-judge checks, tracking regressions, CI integration and managing cost.

Sander Yazıcıoğlu Published: 2 min read Türkçe oku

LLM Evals: Testing AI Features the Way You Test Software

After years of working on test automation platforms, what surprised me most when I started building LLM features was this: teams changed the prompt, said "I tried a few examples and it looks better", and shipped it. We'd never accept that in classic software. LLMs aren't untestable because they're non-deterministic; they're just tested differently. These tests are called evals.

The eval set: your test cases

Everything starts with a good data set:

  • Real inputs: anonymised examples from user logs.
  • Edge cases: empty input, very long input, another language, malicious input.
  • Known failures: every production failure becomes a new case in the set, just like writing a regression test for a bug.

50–200 cases is a good start for most features.

{ "id": "summary-017", "input": "...test log...", "expect": { "mentions": ["TimeoutException"], "maxWords": 80, "language": "en" } }

Three kinds of checks

1. Rule-based (cheap, deterministic): does it match the JSON schema, contain certain words, stay within length, use the right language?

expect(() => RunSummary.parse(JSON.parse(output))).not.toThrow();
expect(output).toContain('TimeoutException');

2. Reference comparison: for classification and extraction, compare directly with the expected value and compute accuracy, precision and recall.

3. LLM-as-judge: for open questions such as "is this summary faithful to the source log? Does it invent anything?", another model scores the output. Write the judge prompt with clear criteria (a yes/no checklist, not 1–5) and validate the judge against a few hand-labelled examples.

Track regressions, not a score

A single average score misleads. Compare case by case on every change: which cases improved, which broke? A 2% average gain with five critical cases broken may be unacceptable.

Wire it into CI

- run: npm run eval -- --suite=summaries --baseline=main
  • Run evals automatically on PRs that change prompts, models or the retrieval pipeline.
  • Post the result as a table in a PR comment.
  • Block merging below a threshold.

I describe the general CI structure in frontend CI with GitHub Actions; the same principles apply.

Handling non-determinism

  • Use temperature: 0 for rule-based checks.
  • Run critical cases several times to measure randomness; flaky behaviour is a bad sign here too. I shared my experience with unstable mobile tests in why Appium tests are flaky; the diagnostic approach is surprisingly similar.

Cost

Judging 500 cases with a large model on every PR is expensive. Run a fast subset on PRs and the full set nightly. Run rule-based checks before the judge to filter obvious failures cheaply.

Measure in production too

Eval sets cover known situations. In production, catch the unknown with user feedback (thumbs up/down), tool-calling error rates and periodic judging of sampled outputs, and feed what you find back into the set.

Conclusion

LLM features get tested too: a set built from real cases, layered checks from cheap to expensive, case-by-case regression tracking and a CI gate. That discipline becomes essential in more complex systems such as RAG and MCP.

All articles →