Long Horizon Temperature Scaling
Paper · 2023 · Andy Shih, Dorsa Sadigh and Stefano Ermon
Summary
Lowering the temperature of a text generator is a common way to make its output less random. The usual procedure makes each next token easier to predict from the text already written. But the most likely next token can start an unlikely completion, and several equally likely answers can receive different treatment simply because some of them begin with the same word. Long Horizon Temperature Scaling, or LHTS, asks what happens when temperature acts on the probability of a complete output. It treats this as a problem of learning a new sampling distribution for text generation.
The authors start with a generator that can score outputs and train a second generator to approximate what would happen if those scores were rescaled jointly. Training gives each example a weight based on how likely the original generator considers it and on the desired temperature. For a generator that produces text from left to right, the authors calculate a different weight at each position. The weight reflects the likelihood of the observed continuation from that point. This keeps the training signal focused on the part of the text that the next decision can still affect. Once trained, the new generator samples in its usual way. The extra computation goes into fine-tuning.
On CIFAR-10, a fine-tuned diffusion generator produces images with a better combination of original-generator likelihood and Fréchet Inception Distance than the tested procedure that reduces diffusion noise. In a Text8 character experiment, the authors train a generator to accept a temperature input and observe a smooth likelihood response even below the training range. Using that input together with ordinary next-character temperature gives higher sample likelihood and visibly less repetition than a sharply cooled next-character baseline. On longer OpenWebText generations, GPT-2 also shows an improved likelihood–repetition tradeoff, especially at the medium and large sizes.
The task results depend on what the evaluation rewards. At a myopic temperature of 0.0, LHTS has the highest analogy accuracy in 4/6 comparisons across GPT-2 sizes and question variants. For GPT-2 large on questions with shared beginnings among the choices, the table reports 0.317 accuracy for LHTS and 0.290 for the pretrained generator at that same decoding temperature. OpenWebText MAUVE scores, which compare generated text with reference text at the distribution level, fall under the tested LHTS settings. The paper shows that a learned temperature can improve some tradeoffs in generation and answer selection, with the size and direction of the effect depending on the task and metric. Exact joint scaling remains an intractable target in the settings the authors address.
Deep dive: Long Horizon Temperature Scaling
Long Horizon Temperature Scaling learns to favor likely complete outputs and tests how that changes image diversity, text repetition, and analogy accuracy. · about 37 minutes to read
The problem and its context
What a temperature changes
A temperature changes how strongly a probability distribution favors its more likely outcomes. In a classification task, the outcomes might be a short list of labels. Lowering the temperature concentrates probability on the labels already scored highly. Raising it gives lower-scoring labels more room. Earlier calibration work discussed in the paper used this freedom to adjust how confident a system was after training. When all the outcomes fit in a short list, the scaled probabilities can be computed and normalized directly. A generative system faces a different problem because an outcome may be an entire document or an image. The paper uses that distinction to revisit temperature in the language model.
In text generation, an autoregressive generator scores a token given the preceding tokens. A token is the unit the generator predicts at a time. In the character experiment it is a character. In the GPT-2 experiments the generator works with its own tokens, so a word in a choice need not correspond to a single sampling decision. The probability of a complete sequence comes from multiplying its successive conditional probabilities. That factorization gives a practical way both to score an observed sequence and to sample an unseen one. Start from the prompt, draw a token, append it, then use the expanded prefix to draw again. Each draw only needs a distribution over the vocabulary. The method relies on tokenization.
A conventional decoding temperature fits neatly into that procedure. The generator already has scores for all available next tokens, so it can divide those scores by the temperature before it normalizes them. This is the procedure the authors call myopic scaling. The paper discusses it as an established user-facing control for systems in the GPT line and points to accounts of those systems and their deployment. Its usefulness is easy to understand. When a task expects a narrow class of answers, such as a short response to a question, a sampler that gives less weight to improbable next tokens may produce fewer irrelevant continuations. The paper situates that practice in work including Language Models are Few-Shot Learners and On the Opportunities and Risks of Foundation Models.
The difficulty is that the probability of a prefix includes the probability of everything that can follow it. A common opening can lead to many different continuations, each carrying only a small fraction of that opening's probability. A less common opening can lead almost entirely to a particular response. Sharpening the decision at the opening favors the former branch if its combined mass is higher. Sharpening the distribution of completed responses favors whichever individual responses were already more probable. These two operations ask the generator to prefer different things.
The paper's action-choice example makes the distinction concrete. The generator assigns 0.3 to each of three intended responses and 0.1 to irrelevant responses. Two intended actions start with the verb for tapping, and the other begins with the verb for closing. At the first step, the tap token benefits from the mass assigned to both of its continuations. Myopic cooling strengthens that token's position before the generator chooses what to tap. The intended actions had equal probabilities as complete responses, so joint rescaling preserves their equality while reducing the influence of the irrelevant answers in the example. The asymmetry introduced by myopic scaling comes from the way the choices are written.
The same issue appears at the extreme of cooling. Choosing the most probable token at each step determines a path through a tree of possible sequences. A different first step may have lower conditional probability and still lead to a more probable complete path. A greedy path is easy to obtain. Finding the globally most probable output asks a harder question about all the ways the sequence could continue. The pronunciation or spelling of an answer plays no special role in the mathematics. Any shared prefix can group outcomes together at an intermediate decision.
How earlier generation methods approached the problem
The paper describes several ways earlier work altered generation after training. Top-k sampling restricts the choices available at a step to a number of highly ranked tokens. Nucleus sampling uses the cumulative probability of ranked tokens to determine which remain available. Such procedures change which local alternatives the generator can sample. A beam search instead retains several candidate continuations while extending them, and variants of beam search can promote diversity across candidates. Search spends computation during generation to consider more than the next local winner. The related-work discussion includes Hierarchical Neural Story Generation and A Simple, Fast Diverse Decoding Algorithm for Neural Generation.
One appeal of search is that a sequence can be assessed as it grows, with new candidates competing against paths that started out more promising. A temperature-scaled joint distribution poses a separate requirement. It specifies how much probability every output should receive relative to every other output, leaving a role for sampling and diversity even when the distribution is sharper. Finding a short list of likely candidates can be a sensible generation strategy in its own right. It does not on its own provide that distribution over all possible outputs. The paper's proposed approach instead moves the work of approximating that distribution into training, a setup it relates to amortized inference.
Temperature had also acquired a different meaning in some generators that use latent variables. A latent variable is an internal quantity used to construct an output. Some earlier work used a narrower prior distribution over these internal quantities to generate less varied samples. This gives a useful control over the sampling procedure, but the operation acts in the internal space. Its relationship to the probability of a complete image or other observable output depends on how internal variables are mapped to outputs. The authors call such controls pseudo-temperatures and discuss them in connection with approaches including NVAE.
There is also a connection to controllable generation. A generator can be trained to accept a signal specifying what kind of output is desired. The earlier work the authors discuss includes image diffusion conditioned on a class and Quark, which divides examples according to a control signal and reinforces the generator with its own outputs. A likelihood-based control could similarly sort generated text into groups according to its score. LHTS begins with a more specific objective. A given temperature should induce a particular relative weighting over outcomes. This defines what the training signal should approximate, which is useful when comparing a trained temperature control with the partition-based approach in Quark.
The method, step by step
From the original generator to a new sampler
The starting point is a generator that can assign a likelihood to an example. The authors keep it as a reference and train a second generator, often initialized with the same parameters. For an image, the reference evaluates the image as a whole. For text, its successive token scores can be combined to evaluate a whole sequence or the part that follows a prefix. A training example's reference score determines how much influence that example has on the update. The new generator learns from the examples that would have more mass at the requested temperature, with the weighting adjusted for how frequently they occur under the original distribution.
An autoregressive example can be considered from several positions. Near its end, the decision being trained has few tokens left to affect. At an earlier position, the decision opens up a longer continuation. The paper computes weights for these positions separately. This still lets the learner use an ordinary next-token prediction loss. The change is in how much a mistake at a particular position matters, given the continuation associated with that position. At generation time, the result can still be sampled token by token. the training has already changed the probabilities from which those draws are made.
Learning a sampler with a long horizon temperature
The steps in order.
Define the distribution to be learned
The paper defines joint scaling by dividing the original log probability of a complete output by the temperature, then subtracting a normalizing term.
log pₜ(x) = log p(x)/T − log Zₜ
Here x is a complete output, p(x) is its probability under the original generator, and pₜ(x) is its probability under the target distribution at temperature T. The subscript ₜ denotes that temperature. log is the natural logarithm, and Zₜ is the partition function, the common normalization that makes the resulting distribution have total mass 1. For a discrete output space, it is the sum of all the original probabilities raised to the reciprocal of T. The density version uses the corresponding integral. This is a definition for positive temperatures where the target can be normalized.
A temperature below 1 increases the contrast between outcomes with different original probabilities. Equal probabilities remain equal. At 1, the target recovers the original distribution. The target depends only on the joint score, so it makes no distinction between an output probability computed directly and one obtained by combining a sequence of conditional scores. Computing the partition function directly, however, requires accounting for the full output space. A generator that can score or sample one output efficiently does not thereby gain the ability to calculate that sum.
For comparison, a next-token temperature uses its own normalization for every distinct prefix.
log pₜᵐʸᵒᵖⁱᶜ(xᵢ | x<ᵢ) = log p(xᵢ | x<ᵢ)/T − log ∑ₖ exp(log p(xᵢ = k | x<ᵢ)/T)
Here i is a token position, xᵢ the token at that position, and x<ᵢ the prefix before it. The vertical bar marks conditioning on that prefix. p supplies the original token probabilities, pₜᵐʸᵒᵖⁱᶜ supplies the rescaled conditional probabilities, T is the temperature, and k ranges over the available tokens in the sum ∑ₖ. The functions exp and log convert between probability weights and their natural logarithms. The sum in this formula is over a vocabulary, which is why the calculation is practical.
The original autoregressive joint log probability is the sum of the original conditional log probabilities. After local temperature scaling, an analogous sum uses the new conditional scores, but their normalizers depend on the prefixes traversed by the particular sequence.
log pₜ(x) ≠ ∑ᵢ log pₜᵐʸᵒᵖⁱᶜ(xᵢ | x<ᵢ)
The left side is the jointly scaled log probability of a whole output x. The right side sums, over positions i, the myopically scaled log probability of each xᵢ given its prefix x<ᵢ, using the same temperature T on both sides. The inequality indicates that these expressions are generally different. Both operations divide log probabilities by the same temperature. The discrepancy comes from normalizing a sequence of separate distributions where the joint definition normalizes the entire distribution at once.
Turn a distributional target into a weighted loss
The authors call the learner qₜ. It needs to provide a usable training loss and a practical way to sample after training. The objective starts with forward Kullback–Leibler divergence, a discrepancy that averages a log-probability difference under the distribution the learner is meant to match.
KL(pₜ ∥ qₜ) = Eₓ∼pₜ[log pₜ(x) − log qₜ(x)]
KL denotes the divergence, pₜ is the target at temperature T, and qₜ is the learned distribution at that temperature. The sign ∥ separates the first distribution from the second. Eₓ∼pₜ denotes an average over outputs x drawn according to pₜ, and log takes the natural logarithm. When only qₜ can change, the target term in the expectation is fixed. Minimizing the divergence is therefore equivalent to minimizing the average negative log probability assigned by the learner to draws from the target.
The target is precisely the distribution from which the authors cannot readily draw. They use importance sampling to express the same expectation using draws from the original generator. Importance sampling compensates for using a different source of examples by multiplying each loss by the ratio of target probability to source probability.
Eₓ∼pₜ[−log qₜ(x)] = Eₓ∼p[exp(((1 − T)/T) log p(x) − log Zₜ) · (−log qₜ(x))]
Eₓ∼pₜ averages over the target and Eₓ∼p averages over the original distribution. x is an output, p(x) its reference probability, and qₜ(x) its learner probability. T is the requested temperature, and Zₜ normalizes the target. exp turns the bracketed log weight into an ordinary weight, and · marks its multiplication by the negative log probability. The weight is obtained by dividing the joint target probability by the reference probability. The 1 in its exponent comes from accounting for the reference probability already present in the sampling distribution.
The partition function is still in the equation, but it affects all examples at a fixed temperature in the same way. Multiplying an entire loss by a positive constant leaves its minimizer in the same place. The authors replace the inaccessible log normalizer with a baseline based on the training data.
b = (1/|D|) ∑ₓ∈D ((1 − T)/T) log p(x)
b is the baseline at the chosen temperature, D the set of training examples, and |D| the number of examples in that set. The sum runs over outputs x in D. p(x) is the original generator's probability for an output and log is its natural logarithm. T controls how far the exponent departs from its value at temperature 1. Centering the exponent this way sets the weight of an example at the mean score to 1. An example far from the mean can still have an extreme weight because the next operation is exponentiation.
wₜ(x) = exp(((1 − T)/T) log p(x) − b)
wₜ(x) is the weight of output x at temperature T. p(x) is the original probability, log converts it to a log score, and b is the baseline subtracted before applying exp. At a temperature below 1, a higher original likelihood gives an example a larger weight. This is the extra influence needed to approximate the sharper target using examples that were already sampled according to their original probabilities.
L(qₜ) = −Eₓ∼p[wₜ(x) log qₜ(x)]
L(qₜ) is the training objective for the learner at temperature T. Eₓ∼p is an average over original-generator draws x, wₜ(x) supplies the importance weights, and log qₜ(x) is the learner's log score. The leading minus makes a high log probability beneficial when the loss is minimized.
The relationship to the original divergence can be made explicit. It identifies exactly where the procedure gets its target and which parts of the loss are irrelevant to the optimum.
Zₜ exp(b) L(qₜ) = KL(pₜ ∥ qₜ) + H(pₜ)
Zₜ is the target's partition function, exp(b) is the positive factor contributed by the baseline, and L(qₜ) is the weighted training loss. KL(pₜ ∥ qₜ) is the forward divergence from the temperature-scaled target to the learner. H(pₜ) is the target's entropy, its expected negative log probability. That term is constant with respect to the learner. The identity holds for the population objective with the stated weights. A finite set of training examples, modified weights and a finite-capacity learner can all affect how closely an implementation reaches that target.
Train an autoregressive generator on continuation weights
Whole-output weighting assigns one score to a sequence and uses it to weight every token prediction in the sequence. That can give a token update large weight because of events that occurred before the token. The autoregressive derivation uses the fact that the loss for a token is conditioned on a prefix. Once that prefix is fixed, its own probability is common to all its possible continuations. By centering separately within each prefix-conditioned prediction problem, the authors remove a source of variation that offers no information about how those continuations should be ranked.
A full continuation begins with the very token being predicted. The reference score for that continuation incorporates both the current token's probability and the probabilities of the later tokens given all preceding ones.
log p(x≥ᵢ | x<ᵢ) = ∑ⱼ≥ᵢ log p(xⱼ | x<ⱼ)
x≥ᵢ denotes the suffix from position i onward, and x<ᵢ is its preceding prefix. p is the reference generator and log is the natural logarithm. The sum runs over positions j from i to the end of the sequence, with xⱼ the token at position j and x<ⱼ the prefix at that position. The vertical bar marks conditioning. A reverse cumulative sum computes the suffix scores together from the vector of individual token log probabilities. The reference makes a pass over observed text and the cumulative sum reuses its scores across positions.
The paper explains the conditional weighting by separating the expectation into a choice of position, a choice of prefix and a draw of the suffix. Each inner loss concerns a particular next-token distribution. A baseline can depend on the prefix as long as it is shared by the possible continuations of that prefix.
Lᴬᴿ(qₜ) = −Eᵢ,ₓ<ᵢ∼p[exp(−b(x<ᵢ)) Eₓ≥ᵢ∼p(·|x<ᵢ)[wₜ(x) log qₜ(xᵢ | x<ᵢ)]]
Lᴬᴿ denotes the autoregressive loss, qₜ the learner at temperature T, and p the original generator. The outer expectation averages over the chosen position i and reference prefixes x<ᵢ. The inner expectation is over reference continuations x≥ᵢ conditioned on the prefix, with · indicating a slot for any continuation. x is the combined sequence and xᵢ its token at the chosen position. wₜ(x) is the whole-example importance weight, log qₜ(xᵢ | x<ᵢ) is the learner's conditional log probability, and exp(−b(x<ᵢ)) is the multiplier from a finite prefix-dependent baseline. For fixed-length windows, averaging over positions rather than summing changes the overall loss scale by a constant.
The proof treats each conditional loss as a prediction problem of its own. At a given prefix, the exact importance weights turn the reference expectation into a loss whose optimum is the next-token conditional of the jointly scaled distribution. Multiplying that loss by a positive constant preserves the answer for that prefix. This is the sense in which the loss is strictly proper: with unrestricted predictions, it selects the target distribution on the prefixes with mass. A generator with shared parameters must fit the conditional predictions together. In that case the scaling can influence which compromises it makes during training.
The baseline the authors choose removes the contribution of the prefix to the reference score and adds a term that depends on the position.
b(x<ᵢ) = ((1 − T)/T) log p(x<ᵢ) + b(i) − b
b(x<ᵢ) is the prefix baseline in the conditional objective. x<ᵢ is the text before position i, and p(x<ᵢ) is its joint probability under the reference generator. T is the temperature, log the natural logarithm, b(i) the position-specific baseline, and b the baseline from the whole-example objective. The subtraction of b cancels the baseline already included in the original weight. The first term cancels the part of the exponent contributed by the prefix likelihood.
b(i) = (1/|D|) ∑ₓ∈D ((1 − T)/T) log p(x≥ᵢ | x<ᵢ)
b(i) is the empirical baseline for position i. The sum is over training sequences x in D, with |D| their number. x≥ᵢ is each sequence's suffix, x<ᵢ its prefix, and p(x≥ᵢ | x<ᵢ) is the original generator's conditional probability for that continuation. log is the natural logarithm and T applies the temperature-dependent factor. The separate mean at each position accounts for the fact that continuations starting early in a window generally contain more terms in their log score than those near its end.
Lᴬᴿ(qₜ) = −Eᵢ,ₓ∼p[exp(((1 − T)/T) log p(x≥ᵢ | x<ᵢ) − b(i)) · log qₜ(xᵢ | x<ᵢ)]
Lᴬᴿ(qₜ) is the resulting autoregressive loss for the learner at temperature T. The expectation samples a position i and a sequence x from the reference distribution p. x≥ᵢ is the continuation, x<ᵢ its conditioning prefix, and xᵢ the token being predicted. The term inside exp is the scaled reference suffix log probability minus the baseline b(i). The weight multiplies the learner's conditional log probability. With complete suffixes, the weight still depends on what happens after the current token, which is the distinction between this objective and a local adjustment of the learner's token scores at decoding time.
Bound the variability of the training signal
A full suffix can still be long enough for a few training examples to dominate the update. The practical variant limits the number of terms used to calculate the suffix score. The authors compute the reverse cumulative sum, then subtract the cumulative score that begins just outside the desired horizon. Near the end of the context window they use the shorter continuation available there.
k = min(i + h, context length)
i is the starting position, h the specified horizon, and k the boundary of the score window in the paper's slicing notation. min takes the earlier of the horizon boundary and the end of the context. The learner's prediction is still conditioned on the preceding prefix. The horizon limits which future token scores contribute to the importance weight.
The paper also clips the log weight above a threshold. This affects the cases that would otherwise receive especially large weights, such as unusually high-scoring continuations at low temperatures. The running baseline lets training proceed without a separate pass over a large corpus to calculate the empirical means. Written in terms of the running score instead of a baseline already multiplied by the temperature factor, the algorithm applies the following weight at each position.
wᵢ = exp(min(((1 − Tⱼ)/Tⱼ) · (sᵢ − bᵢ/n), c))
wᵢ is the weight at position i, Tⱼ is the selected temperature indexed by j, and sᵢ is the current horizon-limited reference log score. In this expression bᵢ is an accumulated sum of scores at that position and n counts the updates contributing to that sum. Their quotient is the running mean. c is the upper clipping threshold, min imposes that ceiling before exp forms the weight, and · indicates multiplication. The running sum in this algorithm is distinct from the temperature-adjusted baselines in the preceding derivation.
The objective is expressed as an expectation over the original generator, but the implementation can train on the original data instead. The authors report that drawing fresh autoregressive samples during training slowed training by around a factor of 3. Their faster procedure uses examples from the data distribution, scores them with the pretrained generator and uses those scores to compute the weights. This substitutes a tractable supply of examples for the original sampling distribution, on the assumption that the generator approximates the distribution of its training data. The reference remains fixed while the learner is updated.
When learning several temperatures in a weight-tied generator, training selects a temperature and updates parameters shared across the settings. More extreme temperatures can produce larger weights and losses. The algorithm therefore tracks a running loss statistic for each temperature and uses it to rescale that temperature's contribution. It stops gradients through the normalization calculation so that the normalizer sets the scale of the update without becoming an additional objective. The implementation also allows a KL penalty on departure from the pretrained next-token distribution. The penalty uses the reference probabilities over possible next tokens, while the weighted prediction loss scores the observed token.
For a continuous control, the character experiment places the scalar temperature at a special initial context position. A learned linear embedding maps that scalar into the vector space of the Transformer. The data follow it in the remaining positions, so all later predictions can use the temperature as part of their conditioning information. At inference, another scalar can be passed through the same linear map, including a scalar outside the interval used for training. This makes extrapolation possible as an operation. Whether the resulting probabilities respond coherently is an empirical question.
Use the same principle for diffusion
The diffusion application keeps the whole-example weighting. A diffusion generator learns to undo steps of a process that adds noise to a clean image. Its data likelihood can be estimated with a variational lower bound, which works with a tractable distribution over intermediate noisy states. The paper describes the bound using a comparison at the terminal noise state, comparisons between reverse-step distributions and a reconstruction term at the clean end.
log p(x₀) ≥ Eₕ[log p(x₀ | x₁) − Dₖₗ(h(xₖ | x₀) ∥ p(xₖ)) − ∑ⱼ>1 Dₖₗ(h(xⱼ₋₁ | xⱼ, x₀) ∥ p(xⱼ₋₁ | xⱼ))]
x₀ is the clean image, x₁ its state after the first noising step, xₖ the terminal state indexed by K, and xⱼ and xⱼ₋₁ are neighboring intermediate states. Here h denotes the forward variational process, unrelated to the suffix horizon, and Eₕ averages over its paths given the image. p supplies the generative probabilities, including the terminal prior p(xₖ), the reverse transitions and the reconstruction probability p(x₀ | x₁). The bar denotes conditioning. Dₖₗ denotes KL divergence, ∥ separates its two arguments, and the sum collects the intermediate steps indexed by j after the reconstruction step. The lower bound supplies a score for the clean image when its true likelihood is unavailable.
The authors use the reference diffusion generator's bound to compute an image weight. The training loss for their DDPM, a denoising diffusion probabilistic model, is a squared error between the noise that was added and the learner's estimate of that noise. The same image weight multiplies the noise-prediction loss for whichever noising step is sampled for the update.
L(qₜ) = Eₖ,ₓ₀,ε[wₜ(x₀) · ‖ε − εqₜ(√ᾱₖ · x₀ + √(1 − ᾱₖ) · ε, k)‖²]
L(qₜ) is the diffusion training loss at temperature T. The average is over a diffusion step k, a clean image x₀ and a noise draw ε. The schedule coefficient ᾱₖ determines how much clean signal remains at that step. The expression with square roots constructs the noisy image, with 1 − ᾱₖ governing the noise contribution. εqₜ is the learner's prediction of the added noise given that image and the step index. The squared norm is the noise-prediction error, and wₜ(x₀) is the weight for the complete clean image, computed from the reference score.
The resulting diffusion generator uses its usual sampling procedure after training. This contrasts with the experimental diffusion baseline, which changes the amount of noise used during each reverse step. In the paper's published implementation, the general loss and the autoregressive continuation weighting are available in the LongHorizonTemperatureScaling code repository.
Experiments and results
CIFAR-10 images
For the image experiment, the authors start with a pretrained DDPM and score the images in the CIFAR-10 training set. They use the joint evidence lower bound for each image, without dividing that value by the number of dimensions, to calculate its LHTS weight. The resulting weight applies to a whole image because the target distribution is defined over whole images. Fine-tuning runs for 50,000 steps with a batch size of 128, a learning rate of 2e-4 and an LHTS log-weight clip of 0.5. The training setup includes 5000 warmup steps. The experiment adapts an existing generator, so the results compare ways of altering its output distribution from that common starting point.
The baseline reduces the Gaussian noise introduced during the reverse diffusion steps. Smaller noise is intended to make trajectories less random and favor high-likelihood images. Changing the noise also changes the intermediate sampling distributions. The experiment asks how the resulting image distribution compares with one produced by learning a weighted loss. The main figure includes baseline pseudo-temperatures of 0.99, 0.985 and 0.98 and LHTS temperatures of 0.999, 0.995 and 0.99. The values belong to different controls. An equal number for both settings does not imply the same degree of sharpening, so the comparison uses measured outcomes over the settings.
The outcomes are sample log likelihood under the pretrained DDPM and Fréchet Inception Distance, abbreviated FID. FID measures discrepancy between sets of images in a feature space and is interpreted in the paper in terms of sample quality and diversity. Lower is better on that metric. The main plot reports FID using 50k samples and puts negative FID on its vertical axis so better values appear higher. The authors compare the methods against the baseline's Pareto frontier, the set of baseline choices for which an improvement on one axis comes at a cost on the other. The LHTS curve offers a better tradeoff over the plotted comparison.
The image panel gives a concrete pair of operating points. The pseudo-temperature setting behind the displayed samples has likelihood −3.09 and FID 3.94. For the LHTS panel, the corresponding values are −3.07 and 3.66. The authors describe the displayed generations as uncurated. The metric comparison supports the account of the panels because the gain is present on both reported measures for those points.
CIFAR-10 DDPM FID for the settings in the sample comparison
Long horizon scaling gives the lower FID of the displayed settings.
The numbers
| System or setting | FID |
|---|---|
| Pseudo-temperature scaling | 3.94 |
| LHTS (this paper) | 3.66 |
The appendix checks Structural Similarity Index, or SSIM, on CIFAR-10. The paper describes it as measuring closeness to a ground-truth image, so it addresses a different property from FID over sets of samples. At pseudo-temperatures 0.98, 0.985 and 0.99, SSIM is 0.915, 0.913 and 0.913 respectively. The long horizon temperatures 0.99, 0.995 and 0.999 give 0.911, 0.913 and 0.913 respectively. The authors see rough alignment between SSIM and the likelihood values in the main image experiment. The strongest SSIM in this comparison belongs to the pseudo-temperature baseline. The advantage measured by FID is thus specific to how the methods balance fidelity and diversity at the distribution level.
Text8 character generation
The character experiment uses Text8 to examine joint temperature in a setting where generation and fine-tuning are simpler than with GPT-2. The reference is a 12-layer Transformer that the authors train from scratch, then preserve as the source of importance scores. The experimental settings give an embedding size of 768 and a hidden size of 3072. The listed learning rate is 5e-4, the batch size is 512, and the training schedule lists 200 epochs. LHTS uses a log-weight clip of 3 and a suffix horizon of 25. The text is presented in randomly cropped character chunks, which also accounts for the fragmentary form of the example generations in the paper.
The learner is a copy of the reference with the scalar temperature embedded at the beginning of the sequence. The training temperatures range from 0.9 to 1.1. The authors choose this interval because lower temperatures can make importance weights large and the updates unstable. They then vary the temperature at inference and measure the resulting sample likelihood under the reference. The likelihood continues to improve smoothly as the long horizon temperature falls below 0.9 in the reported heatmap. This is evidence that the learned input control behaves coherently beyond the training range on that measurement.
The heatmap also varies the myopic decoding temperature. The controls can be combined because they operate at different stages. The long horizon input conditions the learned next-character distribution, and the myopic control then rescales that distribution at sampling time. The paper highlights a setting with long horizon temperature 0.1 and myopic temperature 0.3. Its average sample likelihood on the reference is −0.97. A myopic-only temperature of 0.1 gives −1.05. The examples from the combined setting contain more varied chunks. Those from the myopic-only setting return to a small set of recurring sequences.
That comparison is useful because the settings are chosen to illustrate the tradeoff rather than to equate two unrelated temperature numbers. Strong local cooling can make repeated choices at the beginnings of chunks especially influential. Learning from continuation scores makes it possible to give more probability to several different paths that produce high-likelihood chunks. In the comparison the authors display, the resulting samples are more varied even while their average reference likelihood is higher. The diversity evidence in this character analysis comes from the displayed chunks and their observed repetitions. The more systematic token-repetition evaluation comes in the GPT-2 study.
OpenWebText and GPT-2
The language experiment begins with pretrained GPT-2 in small, medium and large sizes, using the weights from HuggingFace and a context of 1024. The authors fine-tune on OpenWebText. The appendix specifies a learning rate of 1e-4, batch size of 512, 1000 steps, and LHTS suffix horizon of 8. The log-weight clip is 3 and the auxiliary KL coefficient is 0.05. In this setup, the horizon of the score is much shorter than the context available to make a prediction. A prediction can use the long prefix, while its importance weight considers a bounded piece of the continuation.
The comparisons use ordinary myopic temperature and a likelihood-control adaptation of Quark. Quark was designed to condition generation on a control signal. In this experiment, the control represents which partition of joint likelihoods an example falls into. This gives it access to whole-sequence likelihood as a signal, so the comparison addresses a more specific question than simply whether future likelihood is useful. LHTS uses position-specific weights and a temperature objective, while the Quark comparison uses partition membership.
For each plotted temperature setting in the likelihood–diversity analysis, the paper evaluates 1k sequences of context 1024. Sample likelihood is measured by the pretrained GPT-2 of the corresponding size. The diversity measure uses token-level repetition. Low repetition is valuable in this comparison because a generator can increase its average score by repeatedly emitting a narrow set of easy, likely continuations. A procedure that increases likelihood while holding repetition down offers a better tradeoff under the paper's metrics. The paper draws on prior work including Neural Text Generation with Unlikelihood Training.
The myopic settings shown along the frontier are 0.8, 0.775 and 0.75. The LHTS points use a long horizon temperature of 0.95. The improvement in the plotted tradeoff is especially clear for GPT-2 medium and GPT-2 large. The Quark points fall outside the plot's displayed bounds on repetition, so the figure offers the direction of that comparison without showing the corresponding magnitudes. Repetition and likelihood capture the specific qualities tested in this experiment. They leave room for differences on broader measures of how closely generations resemble the data.
Analogy questions and shared beginnings
The authors build a set of 1400 multiple-choice questions from an analogy bank. The relationships include countries and capitals, verb forms, and terms paired by gender. Each prompt gives three examples showing the form of the task. The test item presents a word pair and asks the generator to produce the choice that has the corresponding relationship. The question is posed as free generation after the prompt, so the generator can give irrelevant text or a reply that matches more than one choice. The source of the analogy bank is Efficient Estimation of Word Representations in Vector Space.
To score the output, the evaluator looks for exactly one match to the correct choice among the next eight generated tokens and disregards double matches. The authors sample 50 times for each question. They report the results for separate distinct and duplicate variants. In the duplicate variant, three alternatives start with the same word, and the correct choice can be among the choices with that shared beginning. The example in the paper uses several candidates that begin with Moscow and a different candidate that presents the correct relationship between a capital and its country. This setup creates the sort of shared branch that motivates the paper. It also retains the substantive question of which completed pair is analogous.
The table evaluates myopic decoding temperatures of 1.0, 0.5 and 0.0. The LHTS column uses a long horizon temperature of 0.95 alongside the listed myopic settings. Lowering the myopic temperature generally improves answer accuracy in this setup because the systems become less likely to emit irrelevant completions. That shared benefit makes it important to compare systems at the same myopic temperature. At 0.0, the paper reports LHTS ahead in 4/6 size-by-variant settings. The most competitive setting highlighted by the authors is GPT-2 large on the duplicate questions, where they describe a 10% improvement over the myopic baseline.
GPT-2 large accuracy on duplicate analogy questions at myopic temperature 0.0
LHTS gives the highest accuracy on this shared-prefix question set.
The numbers
| System or setting | Accuracy |
|---|---|
| Pretrained | 0.290 |
| Quark | 0.285 |
| LHTS (this paper) | 0.317 |
The distinct questions show why the duplicate comparison needs to be read as a particular result. At myopic temperature 0.0, GPT-2 large gives 0.275 accuracy with LHTS, 0.264 with the pretrained system and 0.270 with Quark. GPT-2 medium reaches 0.252 with LHTS against 0.233 with the pretrained generator. GPT-2 small is much closer on distinct questions, at 0.255 with LHTS and 0.254 with the pretrained generator. These are all within-size comparisons at the same decoding setting. They show that a win can range from a visibly separated result to a very small margin in the reported values.
The duplicate questions also provide counterexamples to a universal improvement. At myopic temperature 0.0, GPT-2 small gives 0.230 with LHTS and 0.275 with the pretrained generator. GPT-2 medium gives 0.232 with LHTS, 0.228 with the pretrained generator and 0.250 with Quark. Thus the large variant's better result under shared beginnings coexists with a pretrained advantage for small and a Quark advantage for medium. For GPT-2 large on duplicate questions the LHTS advantage is already visible at myopic temperature 0.5, where the reported accuracy is 0.310, compared with 0.279 for each baseline. The interaction between generator size, question variant and decoding setting matters to the pattern.
Quality, calibration and additional tasks
For GPT-2 large, the authors also measure MAUVE on OpenWebText, with 1000 generations and prompts of 30 tokens. MAUVE compares generated text with reference text as distributions. It asks a broader question about resemblance than the earlier token-repetition analysis. In this experiment the unscaled system scores 0.76. Using myopic temperature alone gives 0.57 at 0.8 and 0.41 at 0.0. A long horizon temperature of 0.9 gives 0.00 with myopic temperature 1.0 and likewise 0.00 with myopic temperature 0.0. Higher likelihood under the pretrained generator can be accompanied by poorer distributional resemblance on MAUVE.
GPT-2 large MAUVE scores on OpenWebText
The unscaled generator has the highest MAUVE score and the tested LHTS settings have the lowest.
The numbers
| System or setting | MAUVE |
|---|---|
| No scaling | 0.76 |
| Myopic only, temperature 0.8 | 0.57 |
| Myopic only, temperature 0.0 | 0.41 |
| LHTS, myopic temperature 1.0 (this paper) | 0.00 |
| LHTS, myopic temperature 0.0 | 0.00 |
The HELM comparisons use GPT-2 large and give a more task-specific view. They juxtapose myopic-only temperatures of 0.8 and 0.0 with long horizon temperature 0.9 at myopic temperatures 1.0 and 0.0. XSUM tests the generation of summaries. At the common myopic temperature of 0.0, XSUM test ROUGE-2 is 0.019 for the myopic-only system and 0.02 with LHTS. Test perplexity, for which lower is preferred, is 2.305 and 1.725 respectively. The LHTS setting with myopic temperature 1.0 has XSUM test ROUGE-2 of 0.013 and perplexity of 5.137. The paper's earlier work includes the introduction of the benchmark in Don't Give Me the Details, Just the Summary!.
In BoolQ, the evaluation includes exact match and expected calibration error, which measures how closely stated confidence aligns with observed correctness. At myopic temperature 0.0, exact match rises from 0.583 with myopic-only scaling to 0.603 with LHTS. The reported exact-match fairness metric rises from 0.483 to 0.507, and the robustness metric from 0.35 to 0.43. On the expected calibration error using 10 bins, lower is better, and the value rises from 0.164 to 0.174. The task therefore supplies a case where the accuracy and perturbation metrics improve under a setting whose calibration metric worsens. The classification benchmark is BoolQ.
On the open-book NaturalQA reading-comprehension task, the F1 score at myopic temperature 0.0 is 0.257 for myopic-only scaling and 0.248 with LHTS. The F1 fairness measure moves from 0.153 to 0.164, while the corresponding robustness measure moves from 0.074 to 0.055. Expected calibration error using 10 bins is 0.134 for myopic-only scaling and 0.14 for the LHTS setting. A different LHTS decoding setting, at myopic temperature 1.0, achieves a lower calibration error of 0.086 alongside an F1 score of 0.146. The preferred setting depends on which measurement is used. The authors describe their HELM results as mixed and call for larger-scale evaluations before drawing stronger conclusions.
What the ablations show
The two temperature controls contribute differently
The most direct analysis of the temperature control is the Text8 heatmap. It varies the input to the fine-tuned generator and the temperature applied to its output probabilities during decoding. Holding the long horizon control fixed and moving the myopic control changes the concentration of the next-character distribution. Moving the long horizon control changes the conditional probabilities the learner supplies in the first place. Since both are available in the same generator, the grid shows what can happen when their effects are combined. The highlighted example demonstrates that a strong long horizon setting can be paired with a gentler local setting to find higher-scoring and more varied outputs than a stronger local setting alone.
The extrapolation result comes from a related comparison along the long horizon dimension. The training interval is deliberately limited to mild temperatures. The authors continue the same temperature axis at inference and see reference likelihood move smoothly into the unseen range. The learned scalar input is therefore doing something more informative than selecting among the exact temperatures on which the generator trained. The result is a statement about one response variable in the character study. A smooth monotonic likelihood trend alone cannot identify how closely the entire probability distribution at each point matches the intended target.
These comparisons help interpret the short suffix horizons used in the experiments. The horizon specifies how far ahead the score looks for a particular training token. It is not the distance over which an inference-time effect must end. A sequence of changed conditional predictions can alter a much longer generation. The paper does not tabulate a separate sweep that would identify the horizon with the best tradeoff or show how much of the gain comes from enlarging it. The heatmap varies temperatures, with the underlying training choices already built into the fine-tuned generator.
The analogy comparison changes the grouping of choices
The distinct-versus-duplicate design tests a failure mechanism more directly than the aggregate analogy accuracy would on its own. Word pairs with a shared opening can pool probability at the first prediction. In principle, joint scaling should sharpen the relative scores of completed responses without privileging a group merely because its choices have the same opening. Giving the comparison both forms of the questions makes it possible to inspect results where the paper's concern is especially relevant.
GPT-2 large displays the clearest benefit on the duplicate variant, where LHTS can improve on the myopic-only system at the same decoding temperature. But GPT-2 small gives the opposite ordering on the duplicate variant at its coldest myopic setting, and for GPT-2 medium the best duplicate score there is Quark's. That variation places limits on a causal explanation. The accuracy observations are consistent with an advantage from emphasizing continuations, but correctness also depends on whether the original generator favors the correct relationship and whether the emitted text matches a choice. The duplicate construction does not report the sampled probability assigned to each individual option. It reveals a practical setting in which grouping is relevant and the two methods can disagree.
The table's sweep over myopic temperatures isolates another part of the result. Across the tested systems, stronger local cooling helps suppress unresponsive generations. LHTS is evaluated on top of that useful local control. The coldest comparisons therefore ask whether changes learned during fine-tuning still help when the systems already benefit from reducing local randomness. The gain for the large system survives that comparison, while the smaller systems show that the learned correction can lose or gain depending on question structure.
What the auxiliary comparisons establish
The paper includes an auxiliary KL term intended to keep predictions close to the reference generator. The authors report that including it made no observable difference in their experiments. They do not give a per-task numerical breakdown of that comparison. It is evidence that the reported behavior did not visibly depend on that term under their trials, while leaving its effect under other temperatures and training settings open. The main mechanism in the objective remains the importance weighting of the training loss.
Quark helps distinguish a continuation-weighted objective from a coarser use of whole-example likelihood. The authors observe that its likelihood-based reinforcement was unstable during training and suggest that partitioning complete sequences gives a cruder control signal than reweighting individual conditional losses by suffix. The comparison changes several things at once, including the learning procedure and how likelihood is represented. It supports the reported performance ordering in the tested setup. It cannot isolate whether partition granularity, training stability or the absence of suffix-specific weights accounts for that ordering.
The image and language appendices offer analyses of the choice of metric. Image likelihood and SSIM can move in roughly similar ways even when the FID comparison favors one method, since SSIM does not assess diversity across generations. In language, repetition can improve relative to a cooled baseline while MAUVE declines relative to unscaled generation. Those findings explain why the paper reports pairs of measures in its main figures. A change that advances one sampling objective may alter some other property the experimenter cares about. The appendix measurements make that tradeoff visible without quantifying how much each individual training adjustment contributes.
Limitations
Limits identified by the authors
Exact joint scaling is computationally intractable in the settings the paper targets. At a temperature approaching 0, the target concentrates on the globally highest-probability outputs. Identifying those outputs can already be intractable, even before asking for access to a complete rescaled distribution. LHTS learns a sampler intended to approximate the target. The mathematical equivalence between its population objective and forward KL establishes what ideal fitting would do. It does not certify the accuracy of the samples produced by a particular fine-tuned generator.
The method incurs a fine-tuning cost. The authors emphasize ordinary sampling cost after that adaptation, which distinguishes the method from performing a new search at each request. Someone starting with a generator and choosing a temperature at decoding time can rescale next-token probabilities immediately. LHTS requires access to reference scores, data and an opportunity to update the generator. The paper demonstrates this for particular architectures and data sources, with separate computational settings for the image, character and language experiments.
The authors also point to multi-temperature training and to objectives based on divergences other than forward KL as directions that remain open. The continuous character experiment shows the viability of a learned temperature control under a particular setup. At sufficiently low temperatures the weights used in training can become difficult to manage, which motivates beginning with a milder range. The resulting extrapolation experiment measures likelihood and examines generated chunks. It leaves the accuracy of the full extrapolated distribution unknown.
For the additional language benchmarks, the authors caution that the scores are generally low and describe GPT-2 as relatively small for the tasks. They view evaluations on larger generators as necessary for firmer conclusions. Their data show some gains in perplexity, exact match and behavior under perturbations, as well as losses in calibration, MAUVE and some F1 comparisons. The paper's broader applicability claim concerns the form of the method for likelihood-based generators. The experimental evidence comes from DDPM, the Text8 character generator and the tested GPT-2 sizes.
Limits visible in the experimental setup
Several practical choices change how closely training implements the theoretical objective. The derivation starts with expectations under the original generator, whereas the faster procedure uses corpus examples. Reference scores still determine their weights, but the likelihood ratio in the derivation assumes examples arrive with reference probabilities. If the corpus and reference distributions differ, this substitution changes which examples reach the learner and how often. A short training run on an available corpus can be useful without satisfying the population assumptions exactly.
Clipping alters the weights of the examples that would have received the most influence. The authors identify this as a trade of bias for lower variance. Limiting the horizon also changes the source of the weight, since scores beyond that horizon are absent from the objective used for that token. Shared parameters and the learned temperature embedding further constrain what distributions are available to the learner. In diffusion, the whole-image weight relies on a likelihood bound, so its value is governed partly by how well the bound scores each image. These distinctions matter when interpreting the proof of strict properness. The proof describes exact conditional weighting, and the finite experiments test practical approximations to it.
The likelihood comparisons use the pretrained source as the evaluator. This is well matched to the paper's goal of favoring outputs the original generator already considers likely. It provides limited evidence about independent criteria such as factual correctness or overall writing quality. Token repetition captures another concrete aspect of generation but does not measure coherence across a complete passage. The MAUVE results make a related distinction observable on OpenWebText. Sharpening can give more mass to a desirable part of the original distribution for a particular task and at the same time yield text less representative of the reference distribution.
The analogy evaluation uses a limited prompting and scoring protocol. A correct answer must emerge within the specified token window and match a choice uniquely. The benchmark therefore couples reasoning about an analogy with adherence to the requested response format. The reported accuracy can improve because irrelevant replies become less common, because the correct pair becomes more probable relative to alternatives, or through both effects. The fixed-window match does not assign a separate score to each of those mechanisms. The observed benefits support the task-specific use of LHTS, and the variation across the tested regions of question answering leaves broader claims open.
Finally, the paper compares diffusion noise reduction with learned image reweighting on a particular dataset and with chosen operating points. The frontier and displayed samples establish that the LHTS settings can improve on the tested pseudo-temperatures for the reported combination of metrics. The SSIM comparison favors a pseudo-temperature setting at its highest reported value. That difference is a reminder that concentration under the reference, closeness to a particular image and the distribution of generated images are separate empirical targets.
What came after
MEGA cites Long Horizon Temperature Scaling in a study of multilingual evaluation. This brings a citation from work whose name identifies a broad evaluation setting beyond the English-language generation experiments in LHTS. The citation establishes a connection between the papers. It leaves open whether the multilingual evaluation used a long horizon sampler, treated temperature as an experimental variable or cited LHTS in its discussion of related work. MEGA
Learning Uncertainty from Sequential Internal Dispersion in Large Language Models also cites LHTS. Its named subject is uncertainty inferred from dispersion across a sequence, while LHTS uses sequence likelihood to define a sampling distribution and evaluates calibration as one outcome. The citation establishes that the later uncertainty work refers to LHTS. It leaves the role of the earlier objective, its continuation weights and its temperature control unspecified. Learning Uncertainty from Sequential Internal Dispersion in Large Language Models
Cite
Cite as Andy Shih, Dorsa Sadigh and Stefano Ermon. 2023. Long Horizon Temperature Scaling. arXiv (Cornell University).
@misc{andy2023long,
title = {{Long Horizon Temperature Scaling}},
author = {Andy Shih, Dorsa Sadigh and Stefano Ermon},
year = {2023},
doi = {10.48550/arxiv.2302.03686},
eprint = {2302.03686},
archivePrefix = {arXiv},
url = {https://doi.org/10.48550/arxiv.2302.03686}
}This page in Markdown https://md.research.elamur.ai/free/en/papers/andy-2023-long-horizon-temperature-scaling/