Michalina Graczyk

How to test LLMs: Oh, that non-determinism

4 min read
🇬🇧
llmtestingquality-assuranceai

This post is translated from Polish. Read the original

How to test LLMs

Oh, that non-determinism

Language models (LLMs) have one trait that turns the classic QA approach upside down: they are non-deterministic. This means that even if we send the same prompt several times, in the same context, the model can generate different answers. And not because it works badly, but because that is how it is designed.

It sounds innocent, but for a tester it is like checking a product that can behave differently, unpredictably, every single time. In traditional testing we rely on one rule: input → expected output. Simple, predictable, with a defined result. In the world of LLMs this rule stops existing. Instead of one “expected”, we have a range of possible answers that can be correct… or not. And that is where things get tricky.

Why does non-determinism break classic tests?

Classic tests assume determinism: we know what answer to expect. LLMs do not, because suddenly:

  • “works/does not work” stops making sense,
  • regression is not about comparing two strings,
  • “correctness” is not binary,
  • tests start to look like grading an essay, not like an assertion.

The model can answer correctly today, “almost correctly” tomorrow, and drift off into a hallucination completely the day after. It all depends on:

  • the conversation context,
  • the wording of the prompt,
  • the model version,
  • the temperature and generation parameters,
  • and even changes in the model itself on the provider’s side.

That is why testing LLMs is no longer about looking for one perfect output, but about evaluating the quality of answers against agreed criteria.

What to check when there is no “expected output”?

When you test language models, it is not enough to click and check whether “something showed up”. It is still AI, and its answers must be:

  • correct (no hallucinations),
  • coherent (no jumping between topics),
  • compliant with the instruction (the model must do what you ask for),
  • in the right format (we do not want every answer in a different format),
  • safe (no toxic content and no sensitive data).

QA work is not about checking whether the model answered, but how it answered.

Non-determinism is not a problem - it is a challenge

In practice you can test LLMs effectively, but you need to approach it differently than before:

  • Use evals instead of classic assertions.
  • Build a golden set instead of one expected output.
  • Check by categories (accuracy, safety, compliance), not by a single result.
  • Remember that the model can change its behavior from version to version.
  • Use quality evaluation instead of binary evaluation. Non-determinism is not a flaw, it is a property. And the job of QA is to understand how to test LLMs correctly.

Quick summary: how to think about it in daily QA work

  • You do not evaluate whether the LLM is “correct” - you evaluate whether its answer to a given prompt is correct.
  • Instead of one test, you test quality criteria.
  • Instead of expecting identical results, you expect stability within defined limits.
  • You verify not only the output, but also the risk the answer creates.
  • You check as a human, not as a bot.

Checklist for this post

  • An LLM is never 100% repeatable - and that is normal.
  • Testing must take into account the differences between answers.
  • We evaluate the output qualitatively, not with a 1:1 comparison.
  • Non-determinism is not a bug; the bug is ignoring it in the testing process.

In the next parts I will explain what evals, golden sets, guardrails and other LLM goodies are ;)

Stay up to date with LLM and QA! 🚀

Practical notes on testing, QA processes and modern quality strategy. No fluff - for testers and leaders who want to get quality right. The newsletter is in Polish.

When you join, you agree to receive news from me. You can unsubscribe at any time.