# Why Can One Prompt Give Different Answers?

> Why the same prompt can give different answers: sampling, temperature, hidden inputs and model versions, explained for your AI interview.

**In short:** The model picks each next word by chance from a list of odds, so the same prompt can produce different wording. Lower temperature narrows that choice, but even then the vendor does not promise identical output.

AI and LLM interview question Q014, LLM fundamentals. Beginner, common (our estimate). From Venkat R. Murty's free Interview Kit: https://designervenkat.online/interview/ai/why-can-one-prompt-give-different-answers

## Say it in 30 seconds

The model picks each word by chance, weighted by its odds, so one prompt can give different wording. Temperature sets how wide that choice is. Lower temperature gives steadier answers, though nothing is locked in. The hidden instructions, the chat history and the retrieved documents also shape the answer, so they can change it too. In my work I pin the model version, keep the temperature low for labels, check the output in code, and test over many runs.

## Say it in 2 minutes

Under the hood, a language model writes one small piece of text at a time. Before each piece, it scores every option it could write next, and the app draws one option by those scores. Most draws favour the strong options, but a weaker one sometimes wins. Each draw changes what comes after it, so two runs of the same prompt can drift apart.

Temperature controls how wide that draw is. A low temperature makes the top options win more often, and a high one gives unusual words a real chance. Setting it to zero makes answers steadier, but Anthropic's glossary says results are still not fully deterministic. The input moves too. The hidden system prompt, the chat history, the documents a search adds and the model version can all change, and any of them can change the answer.

Take a claims assistant at an insurer. In a made-up test of twenty draws on one water-damage claim, it said "Needs review" eighteen times and "Auto-approve" twice. Two wrong approvals is a real risk. So I pin a named model snapshot, keep the temperature low for labels, check each label against a fixed list in code, and test every prompt over many runs before it ships.

The fixes have costs. A pinned model needs a retest before each upgrade, and a low temperature can flatten the wording. No setting removes the need to check the output. Fewer changes is the honest goal.

## What is a random draw, in plain words?

A language model writes text one small piece at a time. A piece is called a token, and it can be a word, part of a word or a symbol. Before each piece, the model scores every option it could write next.

The app then draws one option by those scores. Usually a strong option wins, but a weaker one sometimes wins too. Each draw changes the words that come after it, so two runs of the same prompt can end up in different places.

Think of a bank teller who knows three correct ways to explain a late fee. Each time a customer asks, the teller picks one of the three. The facts stay the same, and only the wording moves.

In an AI app, the model plays the teller. It knows several correct ways to word an answer, so the same question can come back worded differently each time.

- **Token:** A small piece of text the model works with: a word, part of one or a symbol.
- **Odds:** The score the model gives each possible next token before one is drawn.
- **Temperature:** A setting for how wide the random draw is. Low is narrow, high is wide.
- **Seed:** A number some services accept so repeated draws line up. A best effort only.
- **Snapshot:** A fixed version of a model, so its behaviour stays put until you move.

## Why does the random draw change the answer?

One draw is small. A long answer makes a draw for every piece of text it writes, and each one shapes the next. An early word that differs starts a new path through the sentences, so a second run can read differently even when the facts match.

*Diagram, Sampling against the top word: The app draws each next word by its odds, so a weaker word can win on some runs. Always taking the top word gives more repeatable answers, but services that run the model for you still give no guarantee.*
1. Sampling: the app draws each next word by its odds.
2. Greedy: the app always takes the single top word.
3. Draws differ from run to run, so the wording drifts.
4. No draw, so the wording repeats more often.

Greedy search is the name for always taking the most likely token. Sampling is the other route. Hugging Face's guide describes sampling as a random pick, weighted by the model's odds.

Here is a worked example with made-up numbers. An insurer's claims assistant reads a water-damage claim and picks one label. Its odds are 80% for "Needs review", 15% for "Auto-approve" and 5% for "Reject". In a test of twenty draws, it gave "Needs review" eighteen times and "Auto-approve" twice. Two approvals on a claim that needs a surveyor is the failure a team has to design out.

Here it is in plain Python. A fixed seed makes this demo repeat, so you can run it yourself. Google's docs say a seed is only a best effort.

```python
# A made-up claims triage step. The odds for one claim are invented numbers.
import random

LABELS = ["Needs review", "Auto-approve", "Reject"]
ODDS = [0.80, 0.15, 0.05]  # the model's odds for each label

def run(seed, odds, runs=20):
    rng = random.Random(seed)  # a fixed seed makes this demo repeat exactly
    picks = [rng.choices(LABELS, weights=odds)[0] for _ in range(runs)]
    return {label: picks.count(label) for label in LABELS}

print("Sampled:", run(seed=7, odds=ODDS))
print("Top word:", run(seed=7, odds=[1, 0, 0]))  # all the weight sits on the top label
```

Output:

```text
Sampled: {'Needs review': 18, 'Auto-approve': 2, 'Reject': 0}
Top word: {'Needs review': 20, 'Auto-approve': 0, 'Reject': 0}
```

## Does temperature zero stop the changes?

Temperature sets how wide the draw is. Google's docs say it controls the degree of randomness in token selection. Lower settings make the top options win more often, but they do not switch the randomness off.

- **High temperature: Wider draw.** Unusual words get a real chance, so repeats drift more and the wording varies.
- **Low temperature: Steadier.** The top options win more often. Good for labels and extraction, flatter for creative copy.
- **Temperature zero: Still not fixed.** Answers are steadier, but Anthropic's glossary says they are not fully deterministic.

> "Even with temperature set to 0, the results will not be fully deterministic, and identical inputs might produce different outputs across API calls." (Anthropic glossary)
>
> "Also, changing the model or parameter settings, such as the temperature, can cause variations in the response even when you use the same seed value." (Google Cloud)

Microsoft's Azure documentation says the same from its side: by default, asked the same question several times, a chat model is likely to give a different response. A seed is a number you can send so repeated requests draw alike. Google calls it a best effort, so it can help but cannot be relied on.

## What else changes when the prompt stays the same?

Your prompt is only one of the inputs. The model reads everything the app sends with it, and that can change without anyone editing the prompt.

*Diagram, One prompt, several inputs: The model reads your question together with hidden instructions, search results and earlier turns. A change in any of them can shift the first word and everything after it.*
1. Your question reaches the model.
2. Hidden instructions reach it too.
3. Search results added this run reach it.
4. Earlier turns in the chat reach it as well.
5. The model writes its answer, and it can come out differently.

- **Hidden system prompt:** The developer's instructions change when a team edits them, even by one line.
- **Chat history:** Earlier turns are part of the input, so the same question in a different chat is a different input.
- **Retrieved documents:** Search results change as the searchable store changes, and the order of the snippets can change too.
- **Model version:** A replacement model can answer differently. Anthropic advises testing it well before a model's retirement date.

## What do teams do about it?

Teams cut the variation they control, then test what is left. This is the order I use on a claims tool.

1. **Pin the model version:** Call a named snapshot, not a general name, so the model changes only when the team chooses a new one.
2. **Keep temperature low for labels:** Classification, extraction and forms want one right answer. Save higher settings for drafting.
3. **Check the output in code:** A label must be on the allowed list and a number must parse. Anything else goes to a retry or a person.
4. **Store the answer you showed:** If a user saw a label, save it. Asking again later can give a different one, and the record must match.
5. **Test over many runs:** Run each test prompt fifty times and count how often the label matches. One good run proves little.

> "Snapshots let you lock in a specific version of the model so that performance and behavior remain consistent." (OpenAI)

> **Tip:** Costs: a pinned version needs a retest before each upgrade, and a low temperature can flatten the wording. Bring real numbers from your own test runs to the interview.

## What does the interviewer want to hear?

**A strong answer covers**

- [ ] Sampling: the model draws each token by its odds.
- [ ] Temperature widens or narrows the draw. Zero is steadier, not fixed.
- [ ] The input is more than your prompt: hidden instructions, history, retrieved text.
- [ ] Pinned versions, low temperature for labels, and checks in code.
- [ ] Measured over many runs, not one good demo.
- [ ] Honest about limits: fewer changes, not a guarantee.

**Common traps**

- Trap: "Set temperature to zero and the answer never changes." Better: Zero makes it steadier, not fixed. Vendors say results can still differ, so test over many runs.
- Trap: "The model is random, so nothing can be done." Better: Several things are in your control: temperature, the pinned version, the inputs and the checks in code.
- Trap: "A bigger model will be more consistent." Better: Changing to another model can change the output, so pin the version, keep the temperature low for labels and check the output.

## Can you spot the drift?

**Spot the drift:** Which setting would most likely make the same claim get different labels?

A. {"model": "claims-triage-snapshot-a", "temperature": 0.0}
B. {"model": "claims-triage-latest", "temperature": 1.0}
C. {"model": "claims-triage-snapshot-a", "temperature": 0.2}
D. {"model": "claims-triage-snapshot-b", "temperature": 0.0}

**Answer:** B. The second option has no fixed version and uses a high temperature that widens every draw. The other three name a fixed snapshot and keep the temperature low.

**Quick check:** A claims team sees different labels for the same claim after a model update. What should they do first?

A. Raise the temperature so the model explores more
B. Pin the old snapshot, then test the new one on the same claims
C. Add 'always be consistent' to the system prompt
D. Move to the largest model available

**Answer:** B. Pinning stops the change while the team compares. Then the same test set runs on the new version, so the decision rests on evidence. A stricter prompt or a bigger model cannot promise the same output.

## Can you answer these from memory?

**Flash cards**

- **Why can one prompt give different answers?** The model draws each next word from its odds, so repeated runs can drift.
- **Does temperature zero make output fixed?** No. It makes answers steadier, but vendors say they are not fully deterministic.
- **What else can change the answer?** Hidden instructions, chat history, retrieved documents and the model version.
- **What is a snapshot?** A fixed version of a model, so its behaviour stays the same until you move.
- **What does a seed do?** A request for repeatable draws. Google calls it a best effort only.
- **What is the fix?** Pin the version, keep temperature low for labels, check output in code, test many runs.

## Likely follow-up questions

- Q010 What does temperature control? https://designervenkat.online/interview/ai/what-does-temperature-control
- Q012 What is top-p (nucleus) sampling? https://designervenkat.online/interview/ai/what-is-top-p-nucleus-sampling
- Q013 Greedy vs beam search vs sampling? https://designervenkat.online/interview/ai/greedy-vs-beam-search-vs-sampling
- Q256 Capability evals vs regression evals? https://designervenkat.online/interview/ai/capability-evals-vs-regression-evals
- Q257 How do you regression-test prompts? https://designervenkat.online/interview/ai/how-to-regression-test-prompts

## Learn it in depth

- [Sampling Parameters](https://designervenkat.online/learn/ai-engineering/sampling-parameters)
