Tools

Temperature & Top-p Visualiser

See how temperature, top-k and top-p change outputs

How to use the sampling visualiser

  1. Choose an example sentence. The bars show how likely a language model might be to pick each next token.
  2. Move the temperature slider: low values sharpen the distribution towards the top choice, high values flatten it so unlikely words get a chance.
  3. Lower top-k to keep only the k most likely tokens, or lower top-p to keep the smallest set of tokens whose probabilities add up to p.
  4. Press Sample 20 times to see what a model with these settings would actually produce.

What temperature, top-k and top-p do

A language model does not output words directly. At each step it produces a score (logit) for every token in its vocabulary, and these are turned into probabilities with the softmax function. Sampling settings decide how a token is then picked. Temperature divides the logits before softmax: at 0 the model always takes the most likely token (greedy decoding), giving repeatable but sometimes dull or repetitive text; around 0.7–1 is balanced; above 1, answers become creative and eventually incoherent.

Top-k discards everything except the k best candidates, and top-p, or nucleus sampling, keeps the most likely tokens until their combined probability reaches p, so the number of candidates adapts to how confident the model is. Both stop the model from occasionally choosing absurd tokens like "banana" while still allowing variety. For facts, code and data extraction, use low temperature; for brainstorming and fiction, raise it. The probabilities here are illustrative examples, not taken from a real model, and everything runs in your browser.

What temperature should I use?

0–0.3 for factual answers, code and structured output; 0.7–1.0 for general chat and writing; above 1 only for very creative tasks.

Should I change temperature and top-p together?

Providers usually recommend changing one at a time. Their effects overlap, and combining low values of both can make output repetitive.

Does temperature 0 make output fully deterministic?

Nearly, but not always: tiny numerical differences on servers can still change results occasionally.