Temperature and Truncation Do Not Commute: Exact Conditions for Order-Independent Decoding
Abstract
Two systems that report identical sampling settings can sample from different distributions. Settings are reported as a short tuple such as temperature 0.7, top-p 0.95, while temperature scaling and truncation are applied in sequence to the logit vector and the order of the two steps is fixed by the inference implementation, not by the tuple. Temperature and min-p truncation are order independent under the reparameterization , a closed-form correction that depends on neither the model nor the vocabulary. Temperature and top-p are not order independent in general, and at fixed and fixed no change of the top-p threshold alone can make the two orders agree for every distribution, so the natural remedy of retuning is unavailable. Below unit temperature the effect is bounded by , and the same bound explains why it is largest at intermediate temperatures and vanishes as falls further. Over the complete vocabulary on approximately 290,000 next-token distributions per model, the corrected min-p pairing gives zero total variation distance in all 24 tested combinations, while the uncorrected min-p and top-p pairings reach 0.231 and 0.496 at and are zero only at . The Transformers library instantiates one of the two orders by default. On GSM8K, swapping the top-p order under a shared random stream changes exact-match accuracy by a statistically significant 1.34 percentage points. Reporting the composition order, or adopting the corrected min-p threshold, makes the reported configuration determine the sampled distribution.
Then back it, or bet against it.
Related papers
Open the market on this paper to see 7 more related papers.