How to measure LLM output consistency when the same prompt gives different answers
To measure LLM output consistency, run each test case several times at your production settings and compare the runs per case, not one run against another. Report the share of cases that pass on every run (pass^k) next to the average pass rate, each with a margin across cases. In CI, check the shape of every response in code, such as whether it parses, matches its JSON Schema, has the required fields, and stays within length limits, and keep repeated, judged runs for a small fixed set. The figures on this page come from public papers, not Slancha results.
The same prompt can give different answers on two runs, even at settings meant to be fixed. One run shows what a model can do. Several runs per case show what it does every time, and which cases flip.
Why the same prompt gives different answers
Sampling is the first reason. Above temperature zero, the model draws each token from a distribution, so two runs can split at the first word. Settings such as top-p change the draw too.
Fixed settings do not remove the spread. Atil and co-authors (2024) ran five LLMs configured to be deterministic on eight common tasks, 10 runs each. They saw accuracy variations of up to 15 percent across runs, and a gap of up to 70 percent between the best and worst possible results. None of the models gave repeatable accuracy across all tasks, much less identical output strings.
The prompt format is part of the input. Sclar and co-authors (ICLR 2024) found performance differences of up to 76 accuracy points from small changes in prompt format, in few-shot settings on an open model. So a new template, a new system message, or reordered examples make a new version of the prompt.
The model can change as well. LLM APIs are often updated without notice, as the post on testing a model upgrade covers, so a run today and a run next week may not reach the same model behind an alias.
What to measure per case across k runs
Pick a number of runs, k, and run every case k times with the same inputs and settings. Compute these per case before you average anything:
- Agreement rate. Whether all k runs give the same output. Atil and co-authors report the share of questions where all runs agree in two forms: TARr@N over raw output strings, and TARa@N over parsed answers, so two phrasings of one choice count as one answer. Normalize whitespace, case, and key order before you compare.
- Majority-answer share. The share of runs that give the most common parsed answer. Low values mark cases where the answer flips.
- All-k-pass and any-k-pass. Yao and co-authors (2024) define pass^k as the chance that all k trials of a task succeed, averaged across tasks, next to pass@k, the chance that at least one succeeds. pass@k fits tasks where a check can pick the best try, such as code with unit tests. pass^k fits work that needs reliability, such as customer service, where each user gets one try. In their τ-bench tests, even state-of-the-art function-calling agents succeeded on fewer than 50 percent of tasks, and pass^8 fell below 25 percent in the retail domain.
- Semantic agreement for free text. Two answers can differ in every word and mean the same thing. Group the k answers by meaning, for example with a judge that tests whether two answers say the same thing, and count the groups. Farquhar and co-authors (Nature, 2024) measure uncertainty at the level of meaning rather than word sequences, which they call semantic entropy, to detect confabulations: arbitrary and incorrect answers. Manakul and co-authors (EMNLP 2023) use a related idea on black-box models: when a model knows a fact, sampled answers tend to agree, and when it makes one up, the samples tend to diverge and contradict each other.
- Structural validity rate. The share of runs whose output passes the shape checks in the CI section below.
- Spread of length and latency. Log output tokens and latency for every run, and report the range per case, not only the mean.
Then average across cases. The average pass rate says how often the feature works. The share of cases that pass on all k runs says how often it works every time. The gap between them is the inconsistency, in one number.
The code below computes these numbers from a list of runs. The data are illustrative.
from collections import Counter
from math import comb
# Illustrative: 4 runs per case at production
# settings. Each run: (parsed answer, passed).
RUNS = {
"case-a": [("refund", True)] * 4,
"case-b": [("refund", True), ("refund", True),
("credit", False), ("refund", True)],
"case-c": [("escalate", False)] * 4,
}
def mean(values):
values = list(values)
return sum(values) / len(values)
def majority_share(runs):
counts = Counter(answer for answer, _ in runs)
return counts.most_common(1)[0][1] / len(runs)
def pass_all_k(runs, k):
# pass^k for one case: C(c, k) / C(n, k)
n, c = len(runs), sum(ok for _, ok in runs)
return comb(c, k) / comb(n, k)
def pass_any_k(runs, k):
# pass@k for one case
n, c = len(runs), sum(ok for _, ok in runs)
return 1 - comb(n - c, k) / comb(n, k)
k = 4
cases = RUNS.values()
print("pass rate", mean(mean(ok for _, ok in r)
for r in cases)) # 0.58
print("pass^4", mean(pass_all_k(r, k)
for r in cases)) # 0.33
print("pass@4", mean(pass_any_k(r, k)
for r in cases)) # 0.67
for name, r in RUNS.items():
print(name, "majority", majority_share(r))The average pass rate is above one half, but only one case in three passes on every run.
How many runs and cases
Fix k before you look at results, use the same k for every version you compare, and report k next to every pass^k number, since pass^k can only fall as k grows.
The case is the unit, not the run. The k runs of one case are repeats of one input, so average each case’s runs first, then compute the margin across cases. Miller (2024), in a paper on adding error bars to evals, recommends this when you resample answers: compute the standard error from the question-level means. He also recommends clustered standard errors when questions come in related groups, such as one question in several languages, and paired differences per question when you compare two models.
Repeat runs shrink the noise inside each case, but only more cases shrink the spread between cases, as Miller notes. The guide to how many examples an eval needs has the formula and tables for a given margin.
Testing the shape of responses in CI
Code can check the shape of a response, so most of a consistency check can run on every commit. Run these checks on every output:
- Parse it. If the feature returns JSON, parse every response and fail on a parse error. Count prose wrapped around the JSON as a failure, not something to strip.
- Validate it against a JSON Schema. The JSON Schema Validation vocabulary has keywords for value types, required properties, allowed values (enum), and string length (maxLength). List every field your code reads as required.
- Bound the length. Set a minimum and a maximum per field and per response, from what your interface and downstream code can take.
- Flag refusals. Mark responses that refuse on cases that should get an answer, with a short list of phrases or a small classifier, and track the rate.
Assert properties, not exact text. A snapshot of the full output fails whenever a word changes. Assert what must hold: the total equals the sum of the line items, the cited ID exists in the input, the label is an allowed category.
Then add a small repeated set: fixed cases that cover your main paths and past failures. Run each case k times on every change to the prompt, the model, or the settings, and fail the build when the share of cases that pass on all k runs drops below a threshold you set in advance. Keep the set small so the job stays fast, and fixed so results compare across builds.
Use a judge only for what code cannot check, such as whether a summary is faithful to its source. A judge adds its own spread, so check it against human labels before it gates a build, as the guide to checking an LLM judge against humans describes.
How to reduce the spread
- Pin the model version. Point production and tests at an exact version, not an alias, so a change of model is a change you make.
- Lower the temperature where the feature allows it. It is meant to narrow the spread, but it does not make outputs identical, as the deterministic-settings results above show. Test at the settings you ship. Miller advises against lowering the temperature in an eval only to cut variance, unless you plan to run the model at that temperature, since it can shift the variance or bias the result.
- Constrain the output. Where your stack supports structured output or decoding constrained to a schema, use it, and keep the schema checks in CI.
- Fix the prompt format. Keep the template, the system message, and the examples, in order, under version control, and treat any change as a new version.
- Re-run on every version change. When the model, the prompt, or the settings change, re-run the repeated set and compare each case with the last accepted run, as the post on testing a model upgrade describes.
Repeat runs are the expensive part
A set run k times costs k times one run, and each judged run adds a judge call per case. The guide to faster evals covers subsets, caching, and concurrent calls that keep a repeated set short, and the guide to what LLM evals cost has the cost formula. Spend the repeats where they matter: a small fixed set on every change, and the full set before a release.
Where Slancha fits
Consistency checks multiply runs: k runs per case, plus a judge call for each judged run. That repeat work is the expensive part of evals.
Slancha builds models that predict where a model has gaps, so a team can run fewer, targeted evals instead of the whole set. Slancha sells those models, not eval software: keep your existing eval or observability platform.
Pilots by arrangement.
More on eval cost: the ways to make AI evals cheaper.
Questions people ask
How do I measure LLM output consistency?
Run each test case several times at your production settings. For each case, compute the share of runs that agree and the share that pass, and whether every run passed. Then report the average pass rate and the share of cases that pass on every run, both with a margin across cases.
How are people testing the shape of LLM responses in CI?
With code, not snapshots. Parse every response, validate it against a JSON Schema, check required fields, allowed values, and length bounds, and flag refusals. Assert properties that must hold rather than exact text, and run a small fixed set several times per build with a threshold on the share of cases that pass every run.
Does temperature 0 make LLM outputs deterministic?
No. One study ran five LLMs configured to be deterministic, 10 runs each, and saw accuracy vary by up to 15 percent across runs; none gave repeatable accuracy across all tasks. A low temperature is meant to narrow the spread but does not remove it, so test at the settings you ship and run each case more than once.
What is the difference between pass@k and pass^k?
pass@k is the chance that at least one of k tries succeeds, which fits tasks where you can check and keep the best try. pass^k is the chance that all k tries succeed, averaged across tasks, which fits features where each user gets one try. Report pass^k next to the average pass rate to show how often a feature works every time.
How many times should I run each prompt?
Pick the number before you look at results, and use it for every version you compare, since the share of cases that pass every run can only fall as the number of runs grows. Repeat runs show each case’s spread, but only more cases narrow the margin on the feature as a whole, so size the case set first.
Sources
- Non-Determinism of "Deterministic" LLM Settings, Berk Atil, Sarp Aykent, Alexa Chittams, Lisheng Fu, Rebecca J. Passonneau, Evan Radcliffe, Guru Rajan Rajagopal, Adam Sloan, Tomasz Tudrej, Ferhan Ture, Zhe Wu, Lixinyu Xu and Breck Baldwin, arXiv:2408.04667, 2024 (v5, April 2025). Claims used: five LLMs configured to be deterministic, eight common tasks, 10 runs; accuracy variations up to 15% across runs; gap of up to 70% between best and worst possible performance; none of the LLMs consistently delivers repeatable accuracy across all tasks, much less identical output strings; TARr@N, the total agreement rate at N runs over raw output, and TARa@N, the same over parsed-out answers (abstract and section 3).
- τ-bench: A Benchmark for Tool-Agent-User Interaction in Real-World Domains, Shunyu Yao, Noah Shinn, Pedram Razavi and Karthik Narasimhan, arXiv:2406.12045, 2024. Claims used: pass^k is the chance that all k i.i.d. task trials succeed, averaged across tasks, proposed for agent tasks that need reliability and consistency such as customer service; pass@k is the chance that at least one of k trials succeeds, used for tasks with good checks such as code with unit tests; unbiased estimate C(c, k) / C(n, k) for c successes in n trials (“Pass^k metric” paragraph); even state-of-the-art function-calling agents succeed on less than 50% of tasks, and pass^8 is below 25% in retail (abstract).
- Adding Error Bars to Evals (a statistical approach to language model evals), Evan Miller, arXiv:2411.00640, 2024. Claims used: recommendations to compute standard errors with the Central Limit Theorem, to compute clustered standard errors when questions are drawn in related groups, to reduce variance by resampling answers, and to compare two models on question-level paired differences (section 1); when each question is answered several times, compute the standard error from the question-level means (section 3.1); resampling cannot shrink the variance between questions, which only more questions reduce (section 3); advice against lowering the sampling temperature to cut variance unless the purpose is to study the model at that temperature, since it can shift the variance or bias the estimate (section 3.3).
- A 2023 paper on black-box hallucination detection from sampled answers, Potsawee Manakul, Adian Liusie and Mark J. F. Gales, EMNLP 2023 (main conference), arXiv:2303.08896, 2023. Claims used: if an LLM has knowledge of a concept, sampled responses are likely to be similar and contain consistent facts; for hallucinated facts, sampled responses are likely to diverge and contradict one another; the approach works on black-box models without an external database (abstract).
- Detecting hallucinations in large language models using semantic entropy, Sebastian Farquhar, Jannik Kossen, Lorenz Kuhn and Yarin Gal, Nature 630, 625 (2024), doi:10.1038/s41586-024-07421-0. Claims used: entropy-based uncertainty estimators that compute uncertainty at the level of meaning rather than specific sequences of words, to detect confabulations, which are arbitrary and incorrect generations (abstract).
- Quantifying Language Models' Sensitivity to Spurious Features in Prompt Design or: How I learned to start worrying about prompt formatting, Melanie Sclar, Yejin Choi, Yulia Tsvetkov and Alane Suhr, ICLR 2024, arXiv:2310.11324. Claims used: performance differences of up to 76 accuracy points from subtle prompt-format changes in few-shot settings on one open-source model (abstract).
- JSON Schema Validation: A Vocabulary for Structural Validation of JSON, A. Wright, H. Andrews and B. Hutton (editors), JSON Schema draft 2020-12 (draft-bhutton-json-schema-validation-01, June 2022), json-schema.org. Claims used: validation keywords type (section 6.1.1), enum (6.1.2), maxLength (6.3.1) and required (6.5.3); json-schema.org/specification lists 2020-12 as the current version, split into Core and Validation.
Checked against arXiv (2408.04667, 2406.12045, 2411.00640, 2303.08896, 2310.11324; abstract pages, plus the arXiv HTML full text of 2408.04667, 2406.12045 and 2411.00640), nature.com and json-schema.org on .
Related guides
- How to test a model upgrade before you switch
- How to reduce token spend in an AI agent pipeline
- How to build agent evals from production traces
- How much do LLM evals cost?
- How many examples does an LLM eval need?
- Can a cheaper LLM judge replace an expensive one?
- How to check your LLM judge agrees with humans
- How to write an LLM-as-judge rubric that catches real failures
- Eval cost guide
- Eval speed guide
- Eval cost calculator
- Eval sample size calculator
- LLM eval glossary
- All guides