Temperature
A language model does not just pick the single best next token. It has a probability for every token in its vocabulary, and temperature controls how boldly it chooses among them.
Each candidate token has a raw score (logit). Dividing every logit by the temperature before softmax reshapes the distribution: low temperature sharpens it toward the top choice, high temperature flattens it so unlikely tokens get a real chance. Temperature 0 always takes the top token (repeatable); high temperature rambles.
Variants & real-world flavors
Temperature reshapes the whole probability distribution; the other samplers decide which tokens are even eligible. Greedy always takes the single most likely token — deterministic, repetitive. Beam search tracks several candidate continuations and keeps the best-scoring whole sequence — standard in translation, dull in open-ended writing. Top-k samples only from the k most likely tokens; top-p (nucleus) instead keeps the smallest set whose probabilities sum to p, adapting the cutoff to the model's confidence; min-p keeps tokens above a fraction of the top token's probability, a newer variant that behaves well at high temperature. Repetition and frequency penalties push down already-used tokens. Production APIs typically combine temperature with top-p — the two knobs you see in every playground.
Check yourself
Why does the same prompt at temperature 0 give the same answer every time, but wander at temperature 1.5?
Go deeper (free): Hugging Face — How to generate text ↗