AI Temperature & Top-p Simulator
Watch temperature, top-p, top-k and min-p reshape a token distribution, with the arithmetic shown at each stage. Paste your own logprobs, or start from the sample.
Sampling parameters
10 of 10 tokens surviveTokens in play
10
of 10 candidates
Top token
58.9%
was 58.9% at defaults
Entropy
1.82 bits
1.82 before truncation
Effective choices
3.5
2^entropy — how many tokens it is really choosing between
The distribution
after temperature, then truncation, then renormalisation- sat8.258.9%
- ran7.119.6%
- jumped6.49.7%
- slept5.95.9%
- was5.22.9%
- looked4.61.6%
- climbed3.80.723%
- stared3.10.359%
- purred2.40.178%
- exploded-1.5<0.01%
Struck-through rows show the probability the token had before it was cut. Surviving probabilities are renormalised to sum to 100%, which is why truncation raises the leader's odds rather than just deleting a tail.
Your distribution
token and logit per line, or paste a logprobs response10 candidates read.
The sample values are illustrative, not any real model's output — this is a calculator for the arithmetic a provider runs between the model and the token you receive. Paste the logprobs block from your own response to use real numbers. Everything is computed in your browser. See also the Token Counter and the LLM Cost Calculator.
About the AI Temperature & Top-p Simulator
This temperature simulator computes what temperature, top-p, top-k and min-p actually do to a token distribution, rather than describing it. Every explanation of these parameters is prose — "higher temperature is more creative" — and that is not wrong, but it will not tell you that at temperature 0.7 your third-choice token still has an 8% chance of being picked, or that top-p 0.9 has already discarded it.
The arithmetic is short and exact, so the honest version of this page is the arithmetic. Everything here is a pure function over a vector of logits: this is the whole computation a provider runs between the model's output and the token you receive, with nothing else in between.
The order the stages run in matters and is the documented one — temperature, then softmax, then top-k, then min-p, then top-p, then renormalise. Applying top-p before temperature selects a different set of survivors, and it is a common thing to get wrong when reimplementing this.
The renormalisation step is the one most people have not internalised. Truncation does not just delete a tail: the surviving probabilities are rescaled to sum to 1, so cutting the bottom half of the distribution actively raises the leader's odds. Watch the top token's percentage climb as you lower top-p.
The bundled distribution is illustrative and made up — it is a calculator, not a claim about any model's output for a particular sentence. Paste the logprobs block from one of your own API responses to work with real numbers.
- Temperature, top-p, top-k and min-p, applied in the documented order
- Every candidate's probability before and after, with the reason it was cut
- Renormalisation shown explicitly, so you can see truncation raise the leader's odds
- Entropy in bits, and effective choices as 2^entropy — a legible version of the same number
- Temperature 0 handled as the mathematical limit, not as a division by zero
- Accepts an OpenAI logprobs response pasted whole, a JSON array, or two plain columns
- Numerically stable softmax, so real-world logit magnitudes do not overflow to NaN
How to use it
- Start with the bundled distribution to get a feel for the controls.
- Move temperature and watch the bars. Below 1 the distribution sharpens; above 1 it flattens; at 0 it collapses onto a single token.
- Lower top-p and watch tokens drop out — and watch the survivors' percentages rise as the remainder is renormalised.
- Compare top-p against top-k. Top-k keeps a fixed count whatever the shape; top-p keeps a fixed share of probability, so it adapts.
- Paste your own numbers: request logprobs with top_logprobs from your API and paste the response block straight in.
- Read the effective-choices figure. It answers "how many tokens is the model really choosing between here" better than any single parameter does.
Real-world use cases
AI & LLM application engineers
See exactly how temperature and top-p interact before shipping a default for a new endpoint, instead of guessing from prose descriptions of what each parameter does.
Backend developers
Debug repetitive or incoherent output in production by pasting the application's actual logit or logprobs values to see which parameter is doing the cutting.
Prompt & AI engineers
Explain to teammates why top-p adapts to the shape of a distribution and top-k does not, using the visual bars instead of restating the usual analogy from memory.
ML & eval engineers
Compare min-p and top-k behavior — supported by most local runtimes but not every hosted API — before switching a deployment's sampling configuration.
Educators & technical writers
Reference the exact renormalisation arithmetic when writing internal documentation on LLM sampling, rather than repeating the imprecise "higher temperature means more creative" explanation.
Examples
Temperature 0 is not a very low temperature
temperature = 0
The top token gets 100%; every other token gets 0%.
The limit as temperature approaches zero, computed directly. A naive implementation divides the logits by zero and returns NaN for everything.
Top-p keeps the token that crosses the threshold
probabilities [0.95, 0.05], top-p 0.9
One token survives, at 100%.
The token crossing the threshold is kept, not cut. Cutting it would leave p = 0.9 keeping nothing at all on this distribution.
Truncation raises the leader's odds
logits [2, 1, 0], top-k 2
66.5% → 73.1% for the top token
The third token's 9% is redistributed proportionally, not discarded. This is why aggressive top-k makes output more repetitive than the same reduction in temperature.
Min-p scales with confidence
min-p 0.5
Everything below half the top token's probability is cut.
A relative floor rather than an absolute one, so it cuts hard when the model is confident and barely at all when it is uncertain — the argument for min-p over top-p.
Common errors
| Message | Cause | Fix |
|---|---|---|
| Setting temperature and top-p together gives unpredictable results | They compose, and the interaction is not intuitive: temperature reshapes the distribution that top-p then measures, so raising temperature widens the nucleus at any fixed p. | Move one at a time here and watch. The common advice to change only one of them exists because of exactly this — it is not superstition. |
| Output is repetitive even at high temperature | A low top-k or top-p is cutting the distribution before temperature can matter. Truncation happens after temperature and overrides it. | Raise top-p towards 1 and watch the effective-choices figure. If it stays near 1, truncation is the constraint, not temperature. |
| Output is incoherent at high temperature | Flattening the distribution enough gives real probability to tokens that were never plausible — the bottom of the sample distribution is there to show this. | Keep a top-p cut in place while raising temperature. That is what top-p is for: it removes the tail without constraining the choice among plausible tokens. |
| Pasted logprobs produce a strange-looking distribution | Log probabilities are negative and logits generally are not. Both are accepted as-is, and softmax over log probabilities is a valid but different operation. | That is expected — the shape is preserved either way. For exact reproduction of your API's behaviour, use logprobs, since that is what the provider actually had. |
Frequently asked questions
›What is the difference between temperature and top-p?
Temperature rescales the whole distribution before any choice is made — every token's probability changes, and none is removed. Top-p removes tokens: it keeps the smallest set whose probabilities sum to p and discards the rest, then renormalises. Temperature changes the odds; top-p changes what is on the table.
›Should I use top-p or top-k?
Top-p, in most cases. Top-k keeps a fixed number of tokens whether the model is certain or not, so k=40 is far too permissive when one token has 99% of the mass and far too strict when fifty are plausible. Top-p adapts to the shape, which is what you actually want.
›Is temperature 0 the same as deterministic output?
In this arithmetic, yes — the highest-probability token is always chosen. In a real API, not quite: floating-point non-determinism in batched GPU inference means identical requests can still diverge occasionally. Temperature 0 removes the sampling randomness, not every source of variation.
›What is min-p and why is it not in every API?
A floor set as a fraction of the top token's probability, so it cuts aggressively when the model is confident and barely at all when it is not. It is newer than top-p and argued to be strictly better, and it is available in most local runtimes and in some hosted APIs but not all.
›What does the entropy figure mean?
How undecided the model is, in bits. Zero means one token has all the probability. Two bits means the uncertainty is equivalent to a uniform choice among four options — which is what the effective-choices figure states directly, since it is just 2 raised to the entropy.
›Where do I get real logprobs?
Ask for them in the request: logprobs: true with top_logprobs: 10 on the OpenAI API returns the top candidates at each position. Paste the response body straight in — the token/logprob pairs are found wherever they are nested.
›Are the bundled numbers from a real model?
No, and the page says so in two places. They are chosen to make the parameters' effects legible. Nothing about this page depends on them being real — it is a calculator, and pasting your own logprobs is the intended use.
›Why does raising top-k sometimes make no visible difference?
Because top-k only has an effect once its value is smaller than however many tokens min-p and top-p would otherwise keep. On the bundled ten-candidate distribution, a top-k of 40 keeps everything — it only starts cutting the AI's candidate list once you lower it below what the other two are already keeping. Watch the 'tokens in play' figure rather than the top-k slider itself to see whether it is the active constraint.
Last updated