Sub topic 5
Why answers differ between runs and how many repeats you need
This chapter assumes you have a prompt set and a documented test protocol from the earlier chapters. It also assumes you can read short Python functions and are comfortable with the idea of a percentage. Here you learn why the same prompt gives different answers, how much that matters, and how to choose the number of repeats.
Why one answer proves little
Suppose you ask an assistant, "What are the best web analytics tools for a small online shop?" and it names your brand. You ask again and it does not. Neither answer is wrong. Both are samples from a range of answers the assistant could give.
A single run tells you that your brand can appear. It does not tell you how often it appears. Brand visibility is a rate, so you need several runs per prompt before you can report anything.
Where the variation comes from
Several mechanisms make answers differ. They have different causes and different fixes, so it helps to separate them.
Sampling inside the model
A language model builds an answer one token (a word or word fragment) at a time. At each step it has a probability distribution over possible next tokens. Most assistants pick from that distribution at random, weighted by probability, instead of always taking the top choice. A setting called temperature controls how adventurous the pick is. Higher values spread choices out, and lower values concentrate them.
Consumer chat products usually do not let you set temperature. Even if you could, a low temperature reduces variation without removing it. Small differences early in an answer, such as listing Example BI first, change what follows.
Retrieval and live search
Many assistants search the web or a document index before answering. The pages retrieved can differ between runs because:
- the search backend returns results in a different order or from a different index shard,
- the assistant rewrites your prompt into different search queries each time,
- pages change, appear, or disappear between runs.
Different retrieved pages lead to different answers and different cited sources. This is often the largest source of variation in assistants that search.
Model and system changes
Providers update models, system prompts, and retrieval pipelines without announcement. A request may also be routed to a different model version under load. This variation is not random noise. It shifts results over days or weeks, so you need your date and settings records to interpret it.
Context and personalisation
The same prompt can produce different answers depending on:
- earlier messages in the conversation,
- saved memory or custom instructions,
- account type and whether you are logged in,
- location, language, and time of day.
You control these by testing under the same conditions, as described in the protocol chapter. A fresh conversation per run is the minimum. If you reuse a conversation, later runs are influenced by earlier answers, and your runs are no longer independent.
Noise you can control and noise you cannot
Separate the variation into two groups.
| Source | Can you control it? | What to do |
|---|---|---|
| Conversation history | Yes | Start a new conversation for every run |
| Account, memory, custom instructions | Yes | Use the same account state, ideally with memory off |
| Mode (search on or off, model choice) | Yes | Fix it and record it |
| Location and language | Partly | Keep them the same and record them |
| Token sampling | No | Repeat the prompt |
| Search results | No | Repeat the prompt, and spread runs over time |
| Silent model updates | No | Record the date, and re-test on a schedule |
Control what you can, then repeat to average over what you cannot.
Treating each run as a yes-or-no trial
For a single metric such as "was the brand mentioned?", each run is a trial with two outcomes. If you run a prompt n times and the brand appears in k of them, the observed mention rate is k divided by n.
This observed rate is an estimate of the true rate for that prompt under your conditions. The estimate has a margin of error that depends mostly on n. With few runs, the margin is wide.
For example, 3 mentions in 5 runs gives 60%. The true rate could plausibly be anywhere from about 23% to 88%. That range is too wide to say anything useful about the prompt.
Putting a range on the rate
The Wilson score interval is a standard way to get a range for a proportion. It behaves better than the simple "plus or minus" formula when n is small or the rate is near 0% or 100%. Those are the situations you will meet most often.
The following script computes the observed rate and a 95% interval for each prompt. It reuses the record shape from the earlier chapters.
from collections import defaultdict
from math import sqrt
def wilson_interval(hits: int, total: int, z: float = 1.96) -> tuple[float, float]:
"""Return a 95% Wilson score interval for hits out of total."""
if total == 0:
return (0.0, 1.0)
p = hits / total
denom = 1 + z**2 / total
centre = (p + z**2 / (2 * total)) / denom
half = z * sqrt(p * (1 - p) / total + z**2 / (4 * total**2)) / denom
return (max(0.0, centre - half), min(1.0, centre + half))
def rate_with_interval(records: list[dict], brand: str) -> dict[str, dict]:
totals = defaultdict(int)
hits = defaultdict(int)
for r in records:
totals[r["prompt_id"]] += 1
if brand in r["mentions"]:
hits[r["prompt_id"]] += 1
out = {}
for pid in totals:
low, high = wilson_interval(hits[pid], totals[pid])
out[pid] = {
"runs": totals[pid],
"hits": hits[pid],
"rate": round(hits[pid] / totals[pid], 2),
"low": round(low, 2),
"high": round(high, 2),
}
return out
records = (
[{"prompt_id": "disc-01", "mentions": ["Acme Analytics"]}] * 3
+ [{"prompt_id": "disc-01", "mentions": []}] * 2
)
print(rate_with_interval(records, "Acme Analytics"))
# {'disc-01': {'runs': 5, 'hits': 3, 'rate': 0.6, 'low': 0.23, 'high': 0.88}}You do not need to do this arithmetic by hand. The point is to see how the range narrows as n grows.
How the margin shrinks with more runs
The table shows the approximate 95% interval half-width for an observed rate of 60%. The half-width is how far the interval extends on each side of the centre.
| Runs per prompt | Interval for 60% observed | Approximate half-width |
|---|---|---|
| 5 | 23% to 88% | 33 points |
| 10 | 31% to 83% | 26 points |
| 20 | 39% to 78% | 20 points |
| 50 | 46% to 72% | 13 points |
| 100 | 50% to 69% | 9 points |
The margin shrinks with the square root of the number of runs. Going from 20 runs to 80 runs only halves the margin. Beyond a point, extra runs on one prompt are poor value. It is better to spend that effort on more prompts.
Choosing a number of repeats
There is no single correct n. The right number depends on what decision the result supports.
- Exploration (5 runs per prompt). Use this for a first look at which prompts are worth watching. Treat results as hints only. Do not report them as rates.
- Reporting a baseline (10 to 20 runs per prompt). This is a practical default for a manual or lightly scripted process. Report the rate with its interval.
- Detecting change over time (20 or more runs per prompt, each round). To say that visibility changed, the intervals from two rounds should not overlap. For a shift from 40% to 60%, 20 runs per round is usually not enough. Expect to need 50 or more. A change of 5 to 10 points is generally not detectable at manual-testing volumes.
Also consider your budget. If you have 40 prompts and 20 runs each, that is 800 answers per assistant per round. If that is too many to record and check, reduce the number of prompts before you reduce the repeats below 10. A smaller set measured properly is more useful than a large set measured once.
Aggregate across prompts
The mention rate for a whole category, such as discovery prompts, combines many prompts. This is more stable than any single prompt, because variation averages out. If you have 10 discovery prompts with 10 runs each, that is 100 trials for the category. The category rate has a margin close to the n = 100 row above.
Be careful here. Prompts in a category are different questions, and some are much easier for your brand than others. Averaging them hides that. Report prompt-level rates, and add the category rate as a summary.
Edge cases
Rates of 0% and 100%
If the brand appears in 0 of 10 runs, the true rate is not necessarily 0. A useful rule of thumb is the rule of three. With 0 hits in n runs, the upper end of a 95% interval is about 3 divided by n. For n = 10 that is 30%. So "0 of 10" means "probably under 30%". To claim a rate under 10%, you need about 30 runs.
The same logic applies to 10 of 10. It means the rate is probably above 70%, not that it is guaranteed.
Runs that are not independent
The interval maths assumes each run is an independent trial. This fails when:
- you reuse a conversation,
- the assistant caches answers for identical prompts,
- you fire all runs in a quick burst and get the same search snapshot.
Signs of this problem are answers that are identical word for word, or a result that looks too stable to be real. If you see it, change the timing, spread runs across several hours or days, and use new conversations. If the assistant still returns identical answers, record that fact. It is a finding about the assistant, and your effective sample size is smaller than the run count.
Variation in position and wording
A brand can be mentioned in every run but appear first in some and fifth in others. Repeating runs lets you report position as an average or a distribution, as covered in the scoring chapter. The same applies to accuracy. A fact that is correct in 7 of 10 answers is a problem even though no single answer looks unusual.
Variation across assistants and modes
Do not pool runs from different assistants or modes into one rate. A search-enabled mode and a non-search mode behave like two different systems. Calculate each separately, and compare them only after you have a rate for each.
What to record for each repeat
For the variation analysis to work, each run needs its own record. At a minimum, store:
- the prompt ID and run number,
- the assistant, mode, and model name if shown,
- the date and time,
- the full answer text,
- the names mentioned and any cited sources.
If you only save a "yes" or "no", you cannot rescore later. The next chapter covers the recording format in detail.
A worked decision
You test one comparison prompt, 10 runs each, in two rounds one month apart.
- Round 1: 4 of 10 mentions, interval about 17% to 69%.
- Round 2: 6 of 10 mentions, interval about 31% to 83%.
The rates differ by 20 points, but the intervals overlap heavily. You cannot conclude that visibility improved. You can say the data is consistent with no change and with a sizeable change. To decide, you would either run more repeats or wait for a larger, more consistent shift across many prompts.
Exercise
A prompt returns your brand in 0 of 10 runs. A colleague writes in the report, "Our brand is never mentioned for this prompt." What is wrong with that statement, and what would you write instead?
Show answer
Zero hits in 10 runs shows only that the true rate is probably low, not that it is zero. By the rule of three, the upper end of a 95% interval is about 3/10, or 30%. A better statement is "Our brand was mentioned in 0 of 10 runs, so the mention rate is probably below about 30%." To support a lower ceiling, such as under 10%, you would need about 30 runs.
Exercise
You have a budget of 300 answers per round for one assistant. You can run 30 prompts at 10 runs each, or 100 prompts at 3 runs each. Which do you choose for reporting a baseline, and why?
Show answer
Choose 30 prompts at 10 runs each. With 3 runs, each prompt's rate is too uncertain to report, and you cannot give a useful interval. With 10 runs you can report a rate and range per prompt, and the 30 prompts still give a reasonable category-level picture. If broader coverage matters, add prompts later rather than cutting repeats below about 10.