How Do You Test an AI That Doesn't Give the Same Answer Twice?

Traditional software testing rests on an assumption so basic nobody states it: the same input produces the same output. Write a test, assert the result, done.

Language models break that assumption. Ask the same question twice and you may get two differently-worded answers — both potentially correct, or one subtly wrong. So how do you test a system that doesn't repeat itself, when it's answering questions about someone's insurance coverage?

This is the question that separates AI demos from AI in production, and most teams hit it after they've already promised a launch date.

Why your existing QA process doesn't transfer

Your test suite asserts equality. `assert result == expected`. With an LLM, the correct answer might be phrased fifty ways, so exact-match assertions fail on correct output and pass on nothing useful.

Worse, the failure modes are different in kind:

  • Fluent wrongness. Traditional bugs look like errors. LLM failures look like confident, well-written, incorrect answers. Nothing throws.
  • Silent regression. A model or prompt update degrades quality on a category of question with no error, no stack trace, nothing in the logs.
  • Distribution, not determinism. A system that's right 97% of the time isn't "passing" or "failing" — it has a quality distribution, and you need to measure it.

The evaluation harness: your new test suite

The answer is to replace assertions with evaluation — a repeatable harness that scores model behaviour across a curated set of cases. Treat it exactly as seriously as unit tests, because it plays the same role.

1. Build a golden dataset. A few hundred real questions with expert-verified correct answers. This is the single highest-value artifact you'll build, and it's tedious human work nobody wants to fund. Fund it anyway — without it you're guessing forever.

Cover: common questions, known edge cases, previously-observed failures, and — crucially — questions that should be refused ("what should I do about my neighbour's dispute?").

2. Score on multiple dimensions. "Correct" is too coarse. For a coverage-answering system:

  • Factual accuracy — does it match the source document?
  • Groundedness — is every claim traceable to retrieved text, or did it invent?
  • Completeness — did it mention the exclusion that changes the answer?
  • Appropriate refusal — did it decline when it should have?
  • Retrieval quality — measured separately, because most "model" failures are retrieval failures.

That last point is the one teams learn late: when the answer is wrong, the model usually did fine with what it was given. Evaluate retrieval independently or you'll spend months tuning the wrong component.

3. Combine automated and human scoring. Automated metrics and LLM-as-judge give you speed and regression detection on every change. Periodic human expert review calibrates whether the automated scores mean anything. You need both; either alone drifts.

4. Run it on every change. Prompt edit, model version, retrieval tweak, document update — re-run the harness and compare. This is your CI. Without it, you're shipping changes to a system whose behaviour you can't characterise.

Production monitoring is not optional

Offline evaluation tells you about your golden set. Production tells you about reality, and reality drifts:

  • Log everything — question, retrieved context, answer, confidence, latency.
  • Track refusal rate. A sudden drop often means the system started answering things it shouldn't.
  • Capture user corrections and escalations. Every time a human overrides the AI, that's a free labelled failure case. Feed it into the golden set.
  • Watch for question drift. Users will ask things your golden set never anticipated.

The governance angle

In insurance this stops being engineering hygiene and becomes a compliance requirement. With the NAIC bulletin adopted across 23 US jurisdictions and the EU AI Act treating insurance AI as high-risk, you must demonstrate your AI system is tested, monitored, and performing as intended.

"We tried it and it seemed good" is not a defensible position. An evaluation harness with versioned results is exactly the evidence those frameworks expect — which means the engineering discipline and the regulatory requirement are the same work. Do it once, satisfy both.

Where teams go wrong

The common pattern: build the demo, impress everyone, get a launch date, then discover there's no way to know whether it's actually good — and no time to build one. The evaluation harness gets deferred and never arrives, so the system runs in production with quality nobody can characterise.

Build the harness before the launch date exists. It's less exciting than the demo and it's the thing that determines whether the demo survives contact with real users.

You can't assert your way to confidence with a non-deterministic system. You can measure your way there — but only if you build the thing that measures.

We build evaluated, monitored, governed AI systems and the data foundations under them. More at IntelliBooks.

Comments

Popular posts from this blog

Why Your Insurance Data Warehouse Didn't Fix Anything

Straight-Through Processing: From 10% to 90%

Embedded Insurance: Why the API Is the Easy Part