esc
  • WorkflowsPages
  • Case studiesPages
  • Machine Learning FoundationsLearn
  • AI EngineeringLearn
  • AI Guardrails & Red TeamingLearn
  • UI/UXLearn
  • Design SystemsLearn
  • Production System DesignLearn
  • AI papersPages
  • Interview KitPages
  • Book a callContact
  • Download ResumeContact
Let’s talk

I’ll build the agent for it.

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.

11 min readBeginnerCommon · estimateFacts checked 26 November 2026

Say it out loud

Read it once, then say it without looking. Start with the short one; use the long one when they ask you to go deeper.

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.

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.

Key words

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.

Sampling against the top word

Same prompt, many runs

sent again and again

Sampled (random draw)

Draw by the odds

a weaker word sometimes wins

Top word (greedy)

Take the top word

no draw, so less variety

Wording drifts

runs can each differ

More repeatable

still no guarantee from the vendor

  1. 1Sampling: the app draws each next word by its odds.
  2. 2Greedy: the app always takes the single top word.
  3. 3Draws differ from run to run, so the wording drifts.
  4. 4No draw, so the wording repeats more often.
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.

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

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.

One prompt, several inputs

Everything the model reads

Your question

the words you typed

Hidden instructions

system prompt users often cannot see

Retrieved documents

search results added this run

Chat history

earlier turns in the same chat

Model

one word at a time, by odds

Different wording

any changed input can do it

  1. 1Your question reaches the model.
  2. 2Hidden instructions reach it too.
  3. 3Search results added this run reach it.
  4. 4Earlier turns in the chat reach it as well.
  5. 5The model writes its answer, and it can come out differently.
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.
  • 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. 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. 2

    Keep temperature low for labels

    Classification, extraction and forms want one right answer. Save higher settings for drafting.

  3. 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. 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. 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."

    BetterZero 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."

    BetterSeveral things are in your control: temperature, the pinned version, the inputs and the checks in code.

  • Trap"A bigger model will be more consistent."

    BetterChanging 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?

Quick check

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

Can you answer these from memory?

Flash cards · tap a card to flip it

1 / 6

What will they ask next?

  1. Q010What does temperature control?10 min
  2. Q012What is top-p (nucleus) sampling?10 min
  3. Q013Greedy vs beam search vs sampling?12 min
  4. Q256Capability evals vs regression evals?10 min
  5. Q257How do you regression-test prompts?12 min

Learn it in depth

Last updated on 26 November 2026

Shipping an AI feature that must label the same way every time?

I design and build AI products and agents, and the system behind them: pinned versions, checks in code and tests over many runs. Book a short call and tell me what yours needs to do.