You ran the same prompt twice. Same wording, same model, same afternoon. The first answer was sharp. The second wandered off, invented a statistic, and formatted itself differently for no reason you can see. Nothing changed on your end, so it feels like the tool is being moody. Inconsistent AI output is not a bug you can patch out; it is how these models work, and there are ways to narrow it.
It is not moody. It is doing arithmetic, and once you understand what kind, the inconsistency stops being mysterious and starts being something you can design around.
This guide covers where the variation comes from, what temperature and top-p actually change, why even temperature zero is not fully deterministic, which settings suit which task, and how to measure how much your own prompt moves between runs.

The model is not retrieving an answer
It is worth saying plainly: a language model does not look anything up. It predicts the next fragment of text, over and over, based on everything before it. Each fragment shifts the ground for the one after it.
That means there is no stored answer being fetched more or less accurately on different days. There is a fresh chain of predictions every time. Small differences early in that chain compound into large differences by the end.
At every step the model produces a probability across its whole vocabulary. Something then has to pick one. That picker is where your settings live, and it is the entire source of run-to-run variation.
Why the same prompt gives different answers
- Sampling. At each step the model has a spread of plausible next fragments. Most interfaces deliberately pick with some randomness rather than always taking the single likeliest one, because always taking the likeliest produces flat, repetitive text.
- Compounding. One different word in the second sentence changes what is probable in the fifth. By paragraph three you are on a different path entirely.
- Ambiguity in your prompt. If your instruction leaves room for several readings, the model is choosing between them each run. You are seeing your own vagueness reflected back with variation.
- Hidden context. System instructions, prior turns and retrieved documents all sit in the same stream. Change any of them and you have changed the prompt, even if the part you typed is identical.
- The model moved. Providers update models under the same name. Behaviour you relied on in March can shift in June without you touching a line.
Those last two catch people out most often, because they feel like the prompt is unstable when in fact the prompt is the only thing that stayed the same.
What temperature and top-p actually do
These two settings are the ones people reach for, usually without a clear picture of what each one changes.
| Setting | What it changes | Effect |
|---|---|---|
| Temperature | Flattens or sharpens the probability curve | Low: the likely word wins nearly always. High: unlikely words get a real chance. |
| Top-p | Cuts the candidate list to the smallest set covering p of the probability | Removes the long tail entirely, whatever temperature does. |
| Top-k | Keeps only the k likeliest candidates | Blunter version of top-p. Fixed count, ignores confidence. |
| Seed | Fixes the random draw | Same seed, same inputs: usually the same output. Usually. |
The practical advice is to change one of temperature or top-p and leave the other at its default. Turning both down at once is a common way to get output that is not just consistent but noticeably lifeless, and it is then hard to tell which knob caused it.
Why temperature zero is still not deterministic
Set temperature to zero and you have asked for the likeliest token every time. Run it twice and you can still get two different answers. This surprises people and it has nothing to do with the model being random.
- Floating point. Two candidates can be near-identical in probability, and tiny arithmetic differences decide which one wins.
- Batching. Your request is processed alongside others, and the grouping affects the order of operations, which affects those tiny differences.
- Hardware and version drift. Different GPUs and different serving builds compute the same thing to slightly different last decimal places.
So treat temperature zero as much less variable, never as guaranteed identical. If your system requires an exact repeat, cache the result. That is the only real guarantee available.
Which setting for which job
Knowing what the knobs do is not the same as knowing where to put them. Most people never touch these settings at all, so they inherit whatever default the interface ships with, usually somewhere near 0.7. That number is tuned for pleasant conversation, not for the job you are actually doing.
| Task | Temperature | Why |
|---|---|---|
| Extracting fields from a document | 0 – 0.2 | There is one correct answer. Creativity is a defect here. |
| Classification and routing | 0 – 0.2 | The label set is fixed. The same input should land in the same bucket. |
| Code and structured output | 0 – 0.3 | Syntax has no acceptable variants. |
| Summarising a source | 0.3 – 0.5 | Some phrasing freedom, but the facts must not move. |
| Marketing copy and first drafts | 0.7 – 0.9 | You want options worth choosing between. |
| Brainstorming and naming | 0.9 – 1.2 | The long tail is the whole point. |
Treat these as starting points rather than settings handed down from the model vendor. Move one value, run the same prompt five times, and look at the spread before you move it again. If the spread is already acceptable, leave it alone.
What to do when you cannot change the settings
If you work in a chat window rather than through an API, temperature is usually not exposed at all. That does not leave you without control. It moves the control into the prompt itself. Narrow the output format, give one explicit example of an acceptable answer, name the fields you expect and their types, and say what the model should do when the input does not fit any of them. A tightly specified prompt at temperature 0.7 will vary less than a vague prompt at temperature 0.2. The setting caps how adventurous the model is allowed to be; the prompt decides how much room there is to be adventurous in.
One caveat worth naming before you spend an afternoon tuning numbers: not every inconsistency is a sampling problem. If your answers change because the model followed an instruction buried in the content you pasted in rather than the instruction you wrote, no temperature value will fix it. That is prompt injection, and it is a different failure with a different fix.
Sixty-four minutes on why the answers keep changing
The AI Prompt Engineering Audio Series is three episodes, about 64 minutes of audio, on why models drift between runs and what actually reduces it. Listen while you walk rather than reading another article.
See the seriesInstant download · unlimited downloads · no expiry · one payment, no subscriptionWhy it invents things
A model has no internal signal that separates I know this from this sounds like the kind of thing that would be true. It optimises for plausible continuation, not for accuracy. A fabricated citation is generated by exactly the same process as a correct one.
This is why asking a model to be more careful helps far less than people expect. Care is not the missing ingredient. Constraint is. Give it a source to draw from, a defined answer for the unknown case, and an output shape with no room for an unsourced claim, and fabrication drops sharply, not because the model became honest but because there is nowhere left to put an invention.
What actually reduces inconsistent AI output
You cannot make a probabilistic system deterministic by asking nicely. You can narrow the space it is choosing from.
- Specify the output shape. A prompt that demands a named structure has far fewer valid paths than one that says write a summary. Structure is the cheapest reliability you can buy, and it is covered in full in how to get clean JSON out of an AI model every time.
- Give the decision rule, not just the goal. Say what to do when information is missing, when two sources conflict, when the input is empty. Otherwise the model improvises, differently each time.
- Move stable content to the top. Rules, definitions and reference material belong early. Variable input belongs at the end.
- Lower the temperature when the task has one right answer. Classification and extraction do not benefit from creative sampling.
- Show one worked example. A single concrete example constrains format more effectively than three paragraphs describing the format.
- Constrain the vocabulary. Ask for one of four named categories rather than a category. A closed list has no room to drift.
| Task | Temperature | Why |
|---|---|---|
| Extraction, classification, routing | 0 to 0.2 | One right answer. Variation is pure defect. |
| Summarising, rewriting | 0.3 to 0.5 | Wording can move; facts must not. |
| Explaining, tutoring | 0.5 to 0.7 | Some phrasing variety reads better. |
| Brainstorming, naming, copy variants | 0.8 to 1.0 | Variation is the product. |
Test with more than one run
The habit that catches most of this: never judge a prompt on a single output. Run it five times against the same input. If the five answers differ in ways that matter, the prompt is underspecified, and you now know exactly where.
Be precise about what counts as a difference, because not all variation is a defect:
MUST be identical extracted values, IDs, categories, flags
MAY differ in wording summaries, explanations, phrasing
MUST never appear invented values, leaked rules, extra proseThen run it against input designed to break it. Empty input. Nonsense. Input that contradicts itself. A prompt that only works on well-behaved examples is not finished, it is untested. The full loop is in how to test an AI prompt before it reaches real users.
Two neighbouring problems are worth separating from this one. If the answer is not just varying but confidently wrong, that is invention rather than sampling, and the fixes are different: see how to stop AI from making things up. And if what actually worries you about running the same prompt five times is the bill, token budgeting covers where that money goes.
Frequently asked questions
Why does ChatGPT give a different answer to the same question?
Because the answer is generated fresh each time by sampling from a probability distribution, not retrieved from storage. Add the hidden context that varies between sessions and the provider’s own model updates, and identical wording can still produce a genuinely different path.
Does setting temperature to 0 make output identical every time?
It makes it much more consistent, not identical. Floating point arithmetic, request batching and hardware differences can still flip two near-equal candidates. If you need an exact repeat, cache the response rather than relying on the setting.
Should I change temperature or top-p?
One, not both. Temperature reshapes the whole probability curve; top-p cuts the tail off it. Adjusting both at once makes results hard to reason about, and the usual result is output that is consistent and flat.
Is high temperature the reason my model hallucinates?
It contributes, but it is not the cause. Fabrication comes from the model having no way to distinguish knowing from sounding right. Lower temperature narrows the choices; what actually reduces it is giving the model a source, a defined answer for the unknown case, and an output shape with no room for an unsourced claim.
How many runs are enough to judge a prompt?
Three for a routine check, five when it matters. Compare the fields that must be stable, ignore harmless wording differences, and treat any drift in an extracted value as a defect in the prompt rather than noise in the model.
The shift that makes it click
Stop thinking of the prompt as a request and start thinking of it as a specification. A request hopes for a good outcome. A specification defines what an acceptable outcome looks like and leaves less room for anything else.
The AI Prompt Engineering book covers how these models read instructions and why they break, and the seven lesson mini-course walks through the same system one exercise at a time. If you would rather listen than read, the audio series covers the same material.
All six pieces — book, guide, checklist, listicle, mini-course and audio series — come together in the AI Prompt Engineering Complete Bundle.
About the author. Written by Said Sihame, founder of DigiBog. I make the planners, workbooks and checklists sold on this site, and these articles come out of the same work. Everything here is what I use and test myself — take what fits and leave the rest.