Sampling Playground: Temperature, Top-p, Top-k and Min-p
Drag temperature and the truncation settings over a distribution you supply, and see the before and after bars, the mass discarded and the entropy that results.
2^H, where H is the entropy of the final distribution — the number of equally likely candidates this sampler is really choosing between. Before any setting was applied it was 5.45 out of 12 candidates.
Faint bar: the distribution at temperature 1 with nothing truncated. Solid bar: after temperature, truncation and renormalisation. Struck-through rows were cut and can never be sampled, whatever their logit was.
- Candidates supplied
- 12
- Candidates surviving the filters
- 12
- Probability mass kept before renormalising
- 100.00%
- Most likely candidate
- the at 41.4%
- Entropy at temperature 1, untruncated
- 2.447 bits
- Entropy after your settings
- 2.447 bits
- Perplexity after your settings
- 5.45
- One draw at seed 7
- the
What temperature actually does
Temperature is not a creativity dial and it is not a confidence setting. It divides every logit by a constant before the softmax, and because the softmax is exponential, dividing the inputs compresses the ratios between the outputs. Set it to 0.2 and the gaps blow up: the top candidate takes nearly all the mass and the tail vanishes. Set it to 2 and the gaps shrink towards nothing, so a candidate the model scored two logits lower becomes a realistic outcome. The model computed one set of logits; temperature only changes how you read them.
Top-p and top-k do something categorically different, and this is the distinction the two bars above are drawn for. Temperature reshapes the whole distribution and leaves every candidate reachable. Truncation deletes candidates outright — a token below the cut has probability exactly zero and cannot be produced at any temperature. That is why raising temperature under a tight top-p feels like it does nothing: you are redistributing mass inside a set of three survivors. Watch the "candidates surviving" row while you drag temperature with top-p at 0.9: high temperature flattens the distribution, which makes the nucleus wider, which lets more tokens through. The two settings interact, and neither is a monotone knob on its own.
What this page leaves out is the part that decides whether the output is any good: the logits themselves. A well-calibrated model at temperature 1 and a badly-calibrated one at temperature 0.3 can produce identical distributions here. Sampling settings cannot add information the model did not have, and no value of top-p makes a wrong answer less wrong — it only changes how often you see the second-best one.