# Why AI gives different answers to the same question

Randomness is the first layer. Context drift and a serving stack that never repeats itself exactly are the other two.

> Why does AI give different answers to the same question?

## Short answer

Because a language model does not look up an answer. It **samples** one token at a time from a probability distribution, and that distribution is conditioned on far more than the sentence you typed. Change the sampling, the hidden context, or the serving stack, and you get a different draw.

Three layers produce the difference. **Decoding randomness** (temperature, top-p, seeds) is the layer you can see and set. **Context drift** — chat history, system prompts, message order, retrieved documents — silently rewrites the question. **System drift** — dynamic batching, kernel reduction order, model version, routing — changes output even at temperature zero, because floating-point addition is not associative and GPU kernels reorder their sums by batch shape.

- **Layers of variation**: Decoding, context, serving stack
- **Temperature zero**: Reduces variation, does not eliminate it
- **Batch shape**: Changes floating-point reduction order

## An answer is a sample, not a lookup

A language model scores every token in its vocabulary, turns those scores into a probability distribution, and picks one token. That token is appended to the input and the loop repeats. **Generation is a chain of conditional draws, not retrieval from a table.**

Temperature divides the scores before normalization: low values sharpen the distribution toward the top candidate, high values flatten it so unlikely tokens get real probability. Top-p truncates the tail and renormalizes. A seed fixes the pseudorandom sequence used for the draw — which makes a run repeatable only if everything upstream of the draw is also identical, and it usually is not.

At temperature zero the sampler takes the highest-probability token, which sounds deterministic. It is not, because the *scores* are the output of floating-point arithmetic whose order changes with batch shape. Divergence matters only when it changes the winner: the LLM-42 work found that tokens become inconsistent only when floating-point drift is large enough to alter the sampler's pick among near-tied candidates . Early flips compound, because a different token becomes part of the context for every token after it.

> A model's answer is one draw from a distribution, not the distribution's peak.

## Context is part of the question

The visible question is one term in a much larger conditional. A chat model computes the next token from the **entire token sequence**: system instructions, prior turns, the order of your messages, retrieved documents, tool outputs, and the formatting around all of it. Change any of those and you have asked a different question, even when the sentence you typed is byte-identical.

Order is the sharpest example. The same three retrieved paragraphs, shuffled, produce different answers because they now sit at different positions and carry different attention weights. A long session does this slowly: an aside early in the conversation keeps conditioning every later turn, so the model appears to change its mind when nothing in your last message changed. Product-level personalization is the deliberate version — the same underlying model behaves differently in two apps because one appends a persona and a policy block.

The honest caveat: prompt sensitivity is real and easy to demonstrate, but it is not a single number. It varies by task, by model, and by how far apart the candidate answers are. The retrieved evidence here contains no controlled measurement of the effect size, so treat any specific magnitude you read elsewhere as task-specific.

> Note: An irrelevant sentence can outperform a relevant one in the wrong position — relevance is not the only thing attention is sensitive to.

## The same model is not the same system

A transformer's forward pass is a deterministic function of its weights, its input tokens, and its numeric environment . Weights and tokens can be held fixed. The numeric environment cannot, because it depends on who else is calling the service at that moment.

Serving systems batch requests to keep GPUs busy. The kernels implementing matrix multiplication, normalization, and attention are **not batch-invariant**: batch shape selects different reduction strategies, and floating-point addition is not associative, so summing the same numbers in a different order yields slightly different results . One reported demonstration sent a thousand identical requests to a 235B-parameter model and received eighty distinct completions . The per-token differences come from how each token's own reductions are performed, not from the values of the other requests in the batch .

Disabling batching restores determinism and destroys throughput; dynamic batching is the single largest serving optimization . Batch-invariant kernels fix it by construction but impose fixed overhead whether or not a workload needs determinism . LLM-42 takes a third route: decode fast and nondeterministically, then verify against a fixed-batch reference and roll back mismatches, paying only for traffic that demands determinism . Model versioning and request routing add a slower-moving layer of the same problem.

> Nondeterminism in a deployed model is a throughput purchase — its price is now known.

> Note: Temperature-zero reproducibility guidance describes the sampler, not the arithmetic. The taxonomy in — floating-point drift, kernel scheduling, batch dependence, library heuristics — is useful, but that source is an unvetted preprint; only the first three are corroborated by the system-level work in .

## When variation is a feature and when it is a fault

Variation is a property, and whether it is a defect depends on what the output is for. In **extraction, classification, and factual lookup**, the same input should map to the same output; two different labels for the same support ticket are a bug, not creativity. In **brainstorming, naming, and red-teaming**, a single deterministic answer is the failure mode — temperature zero makes a generator repeat its safest guess.

The controls overlap. Schema-constrained decoding, enum-only answers, and short output limits all shrink the space the model can wander through, which raises consistency — and moves the failure from *visible variation* to a **schema-valid wrong answer**. A JSON object can be perfectly formed and contain the wrong invoice total.

Caching is the blunt instrument: key on model version, prompt, and parameters, and the second identical request returns the first answer. That buys latency and stability together, and freezes any error in place until the cache is invalidated.

The practical line is to validate the output rather than the prose. Run the extractor, then check the total against the line items. Consistency without verification just makes a mistake reproducible.

> Note: Near-tied candidates are the tipping point: when top-two token probabilities are close, a tiny numerical nudge decides the answer; when one candidate dominates, the same nudge changes nothing.

## What consistency can and cannot be engineered

Diagnose before you control. Repeat an identical prompt in a fresh session at temperature zero — if the output still moves, you have **system drift**, not sampling. Replay it with the exact same history against a fresh context — if the answer changes, you have **context drift**. Then vary only temperature, which isolates **decoding**.

Each layer has a matching control, and each control has a blind spot. Pinning a model snapshot and recording its date stops silent upgrades but forfeits improvements. A fixed seed reduces variance where it is supported without touching arithmetic order. Versioning prompts and retrieval sets turns "the AI got worse" into a diff you can inspect. For pipelines that feed another system, constrain the format and validate the content, and key the cache on model version so a snapshot change does not silently serve stale answers.

The strongest caveat: **bitwise reproducibility is an infrastructure property, not a prompt setting.** Reaching it requires batch-invariant kernels or a determinism-enforcing scheduler, and both cost throughput . For most products the right target is a stable-enough distribution plus a validation layer, not an identical string.

> Consistency is engineered within limits, not assumed.

## Common misconceptions

- **Myth:** Temperature zero makes the model deterministic. **Reality:** It removes sampling randomness only. Batch-dependent floating-point reduction order still shifts token scores, and drift changes the output when it flips a near-tied candidate .
- **Myth:** The same prompt is the same input. **Reality:** Prompt text is a fraction of the conditioning. System instructions, history, message order, retrieved documents, and tool results all enter the same conditional.
- **Myth:** Setting a seed makes results reproducible. **Reality:** A seed fixes a pseudorandom stream. It does not control kernel selection, batching, hardware, or provider-side routing.
- **Myth:** Different answers mean the model is malfunctioning. **Reality:** Sampling from a distribution is the intended design. The defect is an unstable output where the task requires a stable one.

## FAQ

### A team sets temperature to 0 and still sees occasional different outputs for the same prompt. What is the most likely explanation?

Temperature zero removes sampling noise, but the underlying arithmetic is not batch-invariant: different batch shapes reorder floating-point sums and can flip a near-tied token choice .

### A support assistant gives different answers to identical typed questions over a long chat. Which control addresses the most likely cause?

In a long session the accumulated history and retrieved context are themselves changing the conditional, so the effective question differs even when the typed sentence does not.

### Which statement best captures when variation should be suppressed?

The task decides. Exploration benefits from multiple draws; structured extraction needs a stable mapping from input to output, backed by format constraints and content validation.

### Can batch-invariant kernels become the default without a throughput penalty?

If yes, bitwise reproducibility becomes a standard product property; if no, it stays a premium setting for auditable workloads.

### How much output variation comes from provider-side routing versus the model itself?

Providers rarely publish routing details, which makes cross-vendor reproducibility auditing closer to folklore than measurement.

### Is semantic-equivalence scoring reliable enough to replace exact-match evaluation?

Teams need a pass/fail signal on nondeterministic systems, and a weak scorer can silently grade a regression as acceptable.

---

Delve Editorial · https://delve.prisflow.com/p/why-does-ai-give-different-answers-to-the-same-question
