# The Well-Tempered Classifier: Some Elementary Properties of Temperature Scaling

Pierre-Alexandre Mattei, Bruno Loureiro

► To cite this version:

Pierre-Alexandre Mattei, Bruno Loureiro. The Well-Tempered Classifier: Some Elementary Properties of Temperature Scaling. 2026. hal-05517705

HAL Id: hal-05517705

https://hal.science/hal-05517705v1

Preprint submitted on 18 Feb 2026

HAL is a multi-disciplinary open access
archive for the deposit and dissemination of sci-
entific research documents, whether they are pub-
lished or not. The documents may come from
teaching and research institutions in France or
abroad, or from public or private research centers.

L'archive ouverte pluridisciplinaire HAL, est
destinée au dépôt et à la diffusion de documents
scientifiques de niveau recherche, publiés ou non,
émanant des établissements d'enseignement et de
recherche français ou étrangers, des laboratoires
publics ou privés.

<figure><img src="image_1.png" /></figure>

Distributed under a Creative Commons CC BY 4.0 - Attribution - International License
# The Well-Tempered Classifier:
Some Elementary Properties of Temperature Scaling

Pierre-Alexandre Mattei¹ and Bruno Loureiro²

¹Université Côte d'Azur, Inria, CNRS, LJAD, France

²Département d'Informatique, École Normale Supérieure - PSL, CNRS, France

February 17, 2026

## Abstract

Temperature scaling is a simple method that allows to control the uncertainty of probabilistic models. It is mostly used in two contexts: improving the calibration of classifiers and tuning the stochasticity of large language models (LLMs). In both cases, temperature scaling is the most popular method for the job. Despite its popularity, a rigorous theoretical analysis of the properties of temperature scaling has remained elusive. We investigate here some of these properties. For classification, we show that increasing the temperature increases the uncertainty in the model in a very general sense (and in particular increases its entropy). However, for LLMs, we challenge the common claim that increasing temperature increases diversity. Furthermore, we introduce two new characterisations of temperature scaling. The first one is geometric: the tempered model is shown to be the information projection of the original model onto the set of models with a given entropy. The second characterisation clarifies the role of temperature scaling as a submodel of more general linear scalers such as matrix scaling and Dirichlet calibration: we show that temperature scaling is the only linear scaler that does not change the hard predictions of the model.

## 1 Introduction

Reliable uncertainty quantification in deep learning remains an open problem, poised between strong theoretical limits (Foygel Barber et al., 2021) and a flurry of proposed solutions (see e.g. Silva Filho et al., 2023; Angelopoulos et al., 2023; Ulmer et al., 2023; Papamarkou et al., 2024 for presentations of the different paradigms at play).

In a seminal paper, Guo et al. (2017) advocated the use of an old and very simple uncertainty quantification method called *temperature scaling*. This technique employs a single scalar parameter (the temperature) to tune the confidence of a trained neural network. In the complex landscape of uncertainty quantification, temperature scaling imposed itself as an immensely popular method. Its use goes from calibrating models in industrial machine learning—it is implemented in the Scikit-learn library (Pedregosa et al., 2011)—to controlling inference in large language models (LLMs)—its use is pervasive in virtually all LLMs, and is explicitly mentioned in the technical reports of GPT-4 (Achiam et al., 2023), Gemini (Gemini Team, 2025), DeepSeek (Liu et al., 2024), and Mistral (Rastogi et al., 2025). Often, other uncertainty quantification techniques use temperature scaling as a building block (e.g. Berta et al., 2025a; Gibbs et al., 2025).

In spite of this popularity, there is a surprising lack of theoretical investigations of temperature scaling. Exceptions include Clarté et al. (2023a;b), who studied in particular its asymptotic behaviour under model misspecification, Dabah and Tirer (2025) who looked at the interplay between temperature scaling and conformal prediction, and Berta et al. (2025b), who studied in which cases it can (and cannot) be optimal. This relative absence may be due to the fact that the model is quite simple, and resembles many well-studied models in statistics, machine learning, and statistical physics. Nevertheless, we believe a thorough yet elementary inspection of temperature scaling to be both timely and interesting. After reviewing and revisiting temperature scaling in Section 2 (both for classification and LLMs), our main contributions are:
* In Section 3, we show that for classification, increasing the temperature has the expected effect of increasing the uncertainty of the model. However, we highlight that this may not be the case for LLMs.

* We provide in Section 4 a geometric interpretation of temperature scaling as an information projection: a tempered model is the model closest to the original one that has the required level of entropy.

* An important property of temperature scaling is that it is accuracy-preserving: it does not change the ordering of the classes. We show in Section 5 that is actually a defining property, in the sense that it is the only accuracy-preserving linear scaler.

**Notation.** Vectors are denoted by boldfaces. We denote by $\Delta_K = \{\pi \in [0, 1]^K | \pi_1 + \dots + \pi_K = 1\}$ the K-simplex and by $H$ the Gibbs-Shannon entropy of a discrete distribution.

## 2 What is temperature scaling?

We start with a pretrained model $f: \mathcal{X} \to \mathbb{R}^K$ where $K$ is the number of classes — for instance, a neural network trained on a classification problem. The output of this model are the logits, i.e. the softmax preactivations $\mathbf{z} = f(\mathbf{x})$. Standard predictive probabilities are obtained by then applying a softmax layer:

$$p(y|\mathbf{z}) = \text{Categorical}(y|\pi) = \pi_y, \qquad (1)$$

with

$$\pi = \text{Softmax}(\mathbf{z}) \in \Delta_K, \qquad (2)$$

where $y \in \{1, \dots, K\}$ is the class label and

$$\text{Softmax}(\mathbf{z}) = \left( \frac{e^{z_1}}{e^{z_1} + \dots + e^{z_K}}, \dots, \frac{e^{z_K}}{e^{z_1} + \dots + e^{z_K}} \right). \qquad (3)$$

Here, we mean “model” in a very broad sense: while $f$ could be a standard classifier (with features $\mathbf{x}$ and label $y$), it could also be, for instance, an autoregressive language model (in that case, $\mathbf{x}$ would be the previous tokens, $y$ the next token(s), and $K$ the size of the vocabulary).

Each $\pi_k \in [0, 1]$ corresponds to the probability that the model assigns to class $k$. Sometimes, one may not be too happy with these probabilities. In particular, in the context of classification tasks with neural networks, a widely reported issue is that these probabilities are generally overconfident, leading to poor calibration (Guo et al., 2017; Minderer et al., 2021) and difficult distillation (Hinton et al., 2015). For LLMs, it is desirable to let users sharpen or smoothen these probabilities to give them control of the amount of stochasticity of the generations, also referred to as “diversity” in this context. Temperature scaling is a simple and efficient method that allows us to slightly alter the probabilities in order to meet one of these goals.

The idea is to multiply all logits by a learnable parameter $\beta > 0$, called the *inverse temperature* in analogy to a Boltzmann-Gibbs distributions in statistical physics. This leads to a new conditional distribution

$$p_{\beta}(y|\mathbf{z}) = \text{Categorical}(y|\pi_{\beta}) \text{ with } \pi_{\beta} = \text{Softmax}(\beta\mathbf{z}). \qquad (4)$$

Since $\beta$ is constrained to be positive, the coefficients of $\beta\mathbf{z}$ are ordered in the same way as those of $\mathbf{z}$. Thus, the hard predictions of $p_{\beta}$ will be identical to the ones of the original model. In particular, this implies that temperature scaling is accuracy-preserving: it does not change the accuracy of the initial model. This feature was already highlighted by Guo et al. (2017), and is particularly relevant for modern deep classifiers, which generally excel in terms of accuracy, but are often overconfident. As we will see in Section 5, this is in fact a defining characteristic of temperature scaling.

**What if we don't have the logits?** We may not have access to the logits $\mathbf{z}$, but only to the class probabilities $\pi$. A natural idea is to replace the logits by the log-probabilities $\log \pi$. Since the softmax is not invertible, $\log \pi$ is not necessarily equal to $\mathbf{z}$ and there may be a risk of losing partial information when using
log $\pi$ instead of $\mathbf{z}$. Fortunately, this is not the case and the two approaches are equivalent. More precisely, as detailed in Appendix A,

$$ \text{Softmax}(\beta \mathbf{z}) = \text{Softmax}(\beta \log \boldsymbol{\pi}) = \left( \frac{\pi_1^{\beta}}{\pi_1^{\beta} + \dots + \pi_K^{\beta}}, \dots, \frac{\pi_K^{\beta}}{\pi_1^{\beta} + \dots + \pi_K^{\beta}} \right). \quad (5) $$

Because of this equivalence, some papers (e.g. Guo et al., 2017) define temperature scaling using the logits, and some using the log-probabilities (e.g. Berta et al., 2025b).

Another simple way of write Equation (5) is $p_{\beta} \propto p^{\beta}$.

## 2.1 Why is $\beta$ called the inverse temperature?

A tempered softmax probabilistic classifier admits a natural interpretation in terms of a statistical physics problem in the canonical ensemble with $K$ discrete states and inverse temperature $\beta$, where each state $k \in \{1, \dots, K\}$ has energy given by the (negative) logit $E_k = -z_k$. From this perspective, the tempered categorical distribution is just the Boltzmann-Gibbs distribution of the system:

$$ p_{\beta}(y|\mathbf{z}) = \frac{e^{-\beta E_y}}{\mathcal{Z}(\beta, \mathbf{z})}, \quad (6) $$

where the denominator

$$ \mathcal{Z}(\beta, \mathbf{z}) = e^{\beta z_1} + \dots + e^{\beta z_K}. \quad (7) $$

is called the partition function. Another equivalent point of view would be to see $p_{\beta}$ as an exponential family distribution with sufficient statistic $z_y$.

The partition function has a few remarkable yet elementary properties that will considerably simplify computations related to temperature scaling. In particular, the derivatives of its logarithm are related to the moments of the logit of a random label.

**Lemma 1.** We have

$$ \frac{d \log \mathcal{Z}(\beta, \mathbf{z})}{d\beta} = \mathbb{E}_{y \sim p_{\beta}(y|\mathbf{x})}[z_y], \quad (8) $$

$$ \frac{d^2 \log \mathcal{Z}(\beta, \mathbf{z})}{d\beta^2} = \text{Var}_{y \sim p_{\beta}(y|\mathbf{x})}(z_y). \quad (9) $$

Variants of Lemma 1 are standard results in statistical physics (see e.g. Kardar, 2007) and in the theory of conditional exponential families (see e.g. Domke, 2020). We give a proof in our specific context in Appendix B. These results will prove useful to study the properties of the likelihood, that can be written, for a single data point, as

$$ \log p_{\beta}(y|\mathbf{x}) = \beta z_y - \log \mathcal{Z}(\beta, \mathbf{z}). \quad (10) $$

From the statistical physics perspective, this is simply the free energy cost for the system to occupy state $y$.

## 2.2 How to tune the temperature?

### 2.2.1 Calibrating classifiers

In the context of calibration, to tune $\beta$, it is customary to use a fresh set of labelled data $(\mathbf{x}_1, y_1), \dots, (\mathbf{x}_n, y_n)$, called a calibration set. Once the corresponding predictions $\pi_1, \dots, \pi_n$ have been computed (this involves a forward pass through the neural network), the inverse temperature is tuned by minimising the cross-entropy loss (or equivalently, maximising the log-likelihood) of the one-parameter model $p_{\beta}$ over the calibration set. This leads to the estimate

$$ \hat{\beta} = \operatorname*{argmin}_{\beta>0} \mathcal{L}(\beta), \quad \text{with} \quad \mathcal{L}(\beta) = -\frac{1}{n} \sum_{i=1}^{n} \log p_{\beta}(y_i|\mathbf{x}_i). \quad (11) $$
It is sensible to tune the temperature using the cross-entropy for several reasons. First, when $n \to \infty$, $p_\beta$ will converge to the closest model (in terms of Kullback-Leibler divergence) to the true data-generating process (see e.g. van der Vaart, 2000, Example 2.25). Moreover, the cross-entropy is a proper scoring rule, which means that maximising it should lead to well-calibrated predictions (Blasiok et al., 2023). Typically, cross-entropy is also used for training the classifier. Employing the same loss for training and calibration suggests an apparent paradox: since we used the same loss for training and calibration, why was the initial model poorly calibrated? Classical statistical intuition suggests that one possible reason is that the original model, typically an overparametrised deep neural network, was likely subject to severe overfitting, which leads to overconfidence. On the other hand, temperature scaling involves fitting a one-parameter model, which is unlikely to overfit. However, modern networks can overfit without losing in generalisation error, a phenomenon known as benign overfitting. In particular, asymptotic results on high-dimensional logistic regression have shown a non-monotonic behaviour of the calibration with overparametrisation (Bai et al., 2021; Clarté et al., 2023a,c), suggesting a more complex picture for the source of overconfidence in overparametrised models.

Minimising the cross-entropy over the calibration set is not a particularly difficult task, as we shall see below. Interestingly, its gradient has a simple moment-matching interpretation for the cross-entropy, and its Hessian can be written as the variance of the logs of the original model.

**Proposition 1.** The function $\mathcal{L}$ is smooth and convex. For any $\beta$, its first and second derivative satisfy

$$ \frac{d\mathcal{L}(\beta)}{d\beta} = \frac{1}{\beta} \left( \underbrace{-\frac{1}{n} \sum_{i=1}^{n} \log p_{\beta}(y_i|\mathbf{x}_i)}_{\text{cross-entropy}} - \underbrace{-\frac{1}{n} \sum_{i=1}^{n} \mathbb{E}_{y \sim p_{\beta}(y|\mathbf{x}_i)}[\log p_{\beta}(y|\mathbf{x}_i)]}_{\text{expected cross-entropy}} \right), \quad (12) $$

$$ \frac{d^2 \mathcal{L}(\beta)}{d\beta^2} = \frac{1}{n} \sum_{i=1}^{n} \mathrm{Var}_{y \sim p_{\beta}(y|\mathbf{x}_i)}(z_{iy}). \quad (13) $$

If there exists at least one prediction not entirely made of ties, i.e. if there exists $i \in \{1, \dots, n\}$, $y, y' \in \{1, \dots, K\}$ such that $z_{iy} \neq z_{iy'}$, then $\mathcal{L}$ is strictly convex. Otherwise, if all predictions are ties, $\mathcal{L}$ is constant.

If there is at least one misclassification in the calibration set, then $\mathcal{L}$ has a unique minimiser. Otherwise, if the calibration accuracy is one, $\mathcal{L}$ is strictly decreasing: in a sense, the optimal temperature is thus zero.

The proof is a straightforward consequence of Lemma 1 and is provided in Appendix C. This result shows that, under very mild conditions, $\mathcal{L}$ will be easy to optimise. The initial implementation of Guo et al. (2017) used L-BFGS (Liu and Nocedal, 1989) to minimise $\mathcal{L}$ but simpler algorithms like the bisection method (advocated by Berta et al., 2025a) are also good options. Temperature scaling was recently implemented as an option of the CalibratedClassifierCV function, within the popular Scikit-learn library (Pedregosa et al., 2011), using an algorithm of Brent (1973) through the minimize_scalar function of Scipy (Virtanen et al., 2020). Given the simplicity of the problem, any well-tuned optimiser should be able to find $\hat{\beta}$ efficiently. The only potentially problematic case is the one of a classifier with zero classification error on the calibration set. This may happen either because the model has perfectly learned a truly deterministic relationship between $x$ and $y$ (in this case, the initial model was not confident enough and temperature scaling will fix this by making the model fully deterministic), or, more realistically, because the calibration set was too small (which is cause for concern, because temperature scaling will then artificially increase overconfidence). A simple way to alleviate the latter is to add the constraint $\beta \le 1$ which implies that the tempered model cannot be more confident than the original one. Another option is to slightly regularise the optimisation problem: for instance, Berta et al. (2025a) suggest using a form of Laplace smoothing.

Equation (12) leads to an interesting interpretation of maximum likelihood as moment-matching. Indeed, finding a $\hat{\beta}$ such that $\nabla \mathcal{L}(\hat{\beta}) = 0$ means that the expected value of the cross-entropy of the tempered model, matches its actual observed value. This is related to the moment-matching interpretation of maximum-likelihood in exponential families (see e.g. Domke, 2020). Although minimising the cross-entropy is arguably the most popular choice for tuning $\beta$, any other moment-matching technique can be chosen in principle. For instance, we could imagine matching the accuracy instead of the cross-entropy. This would be equivalent
to the expectation consistency of Clarté et al. (2023b), who, based on the observation that for the optimal classifier the expected accuracy should match the expected confidence, proposed to find a $\hat{\beta}$ such that

$$ \frac{1}{n} \sum_{i=1}^{n} p_{\hat{\beta}}(y_i | \mathbf{x}_i) = \frac{1}{n} \sum_{i=1}^{n} \mathbf{1}(\hat{y}(\mathbf{x}_i) = y_i), \qquad (14) $$

where $\hat{y}(\mathbf{x}) = \operatorname{argmax}_y p_{\beta}(y|\mathbf{x})$ is the hard label predictor. Note that since tempering does not change the accuracy, the right-hand side is independent of $\beta$, and this condition can be imposed by optimising the difference over $\beta > 0$ as in temperature scaling. Clarté et al. (2023b) has shown that expectation consistency is competitive with minimising the cross-entropy and has proven that it can outperform it in synthetic classification tasks.

Other alternatives to maximum likelihood have been explored. Mozafari et al. (2018) designed a loss function tailored for small calibration sets. Shen et al. (2024) used variational Bayesian inference, in an LLM context.

### 2.2.2 Calibrating language models

There are two different notions of calibration for LLMs. The first one, next token calibration, is the simply the calibration of the autoregressive task of predicting the next token. The second one, semantic calibration, refers to calibration of question-answering tasks. In general, language models are somewhat well-calibrated for both tasks after their pretraining phase, but this calibration is jeopardised by both fine-tuning based on reinforcement learning and chain-of-thought reasoning (Nakkiran et al., 2025).

Temperature scaling has been used to tackle this lack of calibration, typically using calibration data in a fashion similar to what we described for classification (Shen et al., 2024; Xie et al., 2024).

### 2.2.3 Manual tuning for language models

In contrast with the calibration setting described above, temperature scaling is most often used in language models as a manual decoding hyperparameter, rather than a parameter learned from labelled calibration data. In this context, the temperature is typically exposed to the user and adjusted heuristically to control the perceived diversity of the generated text. Alternative techniques to control text diversity are also used (e.g. nucleus sampling, Holtzman et al., 2020).

Peeperkorn et al. (2024) empirically showed that changing the temperature is very weakly correlated with text creativity. We will see in Section 3 that temperature can have counter-intuitive effects on LLMs.

## 2.3 Extensions of temperature scaling

### 2.3.1 Linear scalers

In their seminal paper, Guo et al. (2017) also introduced a more general scaler called matrix scaling, defined as

$$ \tilde{p}_{\mathbf{W},\mathbf{b}}(y|\mathbf{x}) = \operatorname{Categorical}(y|\operatorname{Softmax}(\mathbf{W}\mathbf{z} + \mathbf{b})), \qquad (15) $$

where $\mathbf{W} \in \mathbb{R}^{K \times K}$ and $\mathbf{b} \in \mathbb{R}^K$ are trainable parameters. For binary classification, matrix scaling reduces to Platt's (1999) scaling, and in the general multiclass case, it is equivalent to training a logistic regression model on top of the logits of the pretrained model. A similar model called Dirichlet calibration was introduced by Kull et al. (2019). Motivated by a generative perspective (seeing the probabilities of the initial model as a mixture of Dirichlet distributions), they proposed using log-probabilities instead of logits:

$$ \tilde{p}_{\mathbf{W},\mathbf{b}}(y|\mathbf{x}) = \operatorname{Categorical}(y|\operatorname{Softmax}(\mathbf{W} \log \boldsymbol{\pi} + \mathbf{b})). \qquad (16) $$

While more flexible than temperature scaling, matrix scaling is generally trickier to fit on small calibration sets because of its much larger number of parameters. Another issue is that it is possible that the calibrated model will predict different labels than the original one, i.e. the mode of $\tilde{p}_{\mathbf{W},\mathbf{b}}$ may not be the same as the one of $p$, which may lead to a drop in accuracy. Partly due to these issues, Guo et al. (2017) found temperature scaling empirically superior to matrix scaling. Several papers have consequently proposed specific
regularisation techniques to avoid overfitting, dating back to Platt (1999) who used a form of soft labelling (to alleviate the fact that he was training the scaler using the training set). More recently, Kull et al. (2019) and Berta et al. (2025b) proposed regularisation strategies tailored for matrix scaling. Their conclusions were that, when carefully regularised, it can be competitive with temperature scaling.

### 2.3.2 Nonlinear scalers

A common limitation of temperature/matrix scaling and Dirichlet calibration is that they are linear in the logits or log-probabilities of the initial model. A simple way to turn temperature scaling into a nonlinear scaler is to use as temperature the output of a neural network. This idea has been explored in several works (Tian et al., 2020; Tomani et al., 2022; Joy et al., 2023). Another nonlinear extension of temperature scaling is based on using a mixture of temperature-scaled models (Zhang et al., 2020).

## 2.4 The history of temperature scaling

It seems that the first use of temperature scaling was by Cox (1958), who used it as a simple parametric test of calibration for binary classifiers. His null hypothesis was $\beta = 1$, which indeed implies perfect calibration. Cox (1958) also mentioned that, when $\hat{\beta} > 1$, “probabilities show the right general pattern of variation, but do not vary enough”. On the other hand, when $\hat{\beta} \in (0, 1)$, “probabilities vary too much”. Cox’s (1958) test and its variants are still widely used in medical research (Stevens and Poppe, 2020).

The use of a temperature parameter together with a softmax layer is probably an old and common practice. It was particularly popularised by Hinton et al. (2015). For neural language models, one of the early uses of a temperature was in the influential blog post of Karpathy (2015) on the successes of recurrent neural nets.

# 3 Does higher temperature mean higher uncertainty?

The general motivation for tempering models is that it helps control their level of uncertainty. In this section, we investigate formalisations of this claim. We choose and fix some input $x \in \mathcal{X}$. A key motivating property of temperature scaling, already mentioned by Guo et al. (2017), is its limiting behaviour. When $\beta \to 0$, $p_{\beta}(y|x)$ converges to the uniform distributions over its support. On the other hand, when $\beta \to \infty$, $p_{\beta}(y|x)$ converges to a point mass at the maximum probability class when $p(y|x)$ is unimodal (for a proof, see e.g. Girardin and Regnault, 2016, Proposition 1). Thus, by scaling the temperature, we can interpolate between the most uncertain model (the uniform distribution), and the most certain one (the point mass). We will see that this interpolation happens monotonically in a fairly general sense.

## 3.1 Entropy is an increasing function of the temperature

The fact that $\beta \mapsto H(p_{\beta})$ decreases was recently proven by Dabah and Tirer (2025, Proposition A.5) who showed that its derivative was nonpositive. We revisit this result here and provide an alternative and shorter proof, relying on the properties of the log-partition function (Lemma 1). This proof, inspired by standard statistical physics computations, highlights that the entropy is directly related to the variance of the logits.

**Proposition 2.** For all $\beta > 0$,

$$ \frac{dH(p_{\beta}(y|x))}{d\beta} = -\beta \mathrm{Var}_{y \sim p_{\beta}(y|x)}(z_y) \le 0. \qquad (17) $$

As we saw in Proposition 1, the variance of the logits is also related to the second derivative of the likelihood, and hence, to the Fisher information. Therefore, an interpretation of this result is that the entropy will vary faster when there is a lot of information in the calibration set.

While the (Shannon-Gibbs) entropy is the most common uncertainty measure in machine learning, many others exist. We will see that most reasonable measures of uncertainty, temperature scaling behaves monotonically.
## 3.2 Beyond the Shannon-Gibbs entropy: majorisation

Majorisation is a strong measure of dispersion for discrete distributions, originally introduced in the influential book of Hardy et al. (1952). The notion has been applied (in particular to derive new inequalities) in many subfields of applied mathematics (Marshall et al., 2011) or statistical physics (Sagawa, 2022).

There are many different equivalent definitions of majorisation (see e.g. Marshall et al., 2011, p.14), but a compelling one is the following.

**Definition 1.** Let $\pi = (\pi_1, ..., \pi_K)$ and $\rho = (\rho_1, ..., \rho_K)$ be vectors in $\mathbb{R}^K$. We say that $\pi$ majorises $\rho$, and denote it $\pi \prec \rho$ when, for all convex functions $\phi: \mathbb{R} \to \mathbb{R}$,

$$ \sum_{k=1}^{K} \phi(\pi_k) \leq \sum_{k=1}^{K} \phi(\rho_k). \qquad (18) $$

**Why is majorisation a good measure of dispersion?** It is instructive to look at a few examples of convex functions. Taking $\phi(\pi) = \pi \log \pi$ means that $\pi \prec \rho$ implies $H(\pi) \leq H(\rho)$. This means that majorisation is a stronger measure of dispersion than entropy. Actually, $\pi \prec \rho$ also implies that $\pi$ has a smaller Renyi entropy than $\rho$, and the same result is true for many generalisations and variants of entropy (see e.g. Kvälseth, 2022).

It turns out that the effect of temperature on majorisation has been known for a while. The following result was originally derived by Marshall and Olkin (1965) to bound the condition numbers of some matrices, and is mentioned and proven by Marshall et al. (2011, p. 189). Dabah and Tirer (2025, Theorem 4.1) proved the exact same result, but did not highlight its connection to majorisation theory.

**Theorem 3.1.** Let $\pi \in \Delta_K$. If $0 < \beta_1 < \beta_2$. Then,

$$ \pi_{\beta_1} \prec \pi_{\beta_2}. \qquad (19) $$

This result directly implies that $\beta \mapsto H(p_{\beta}(y|x))$ is a decreasing function, not only for the Shannon entropy but for all other entropies that are weaker than majorisation. For instance, the function $\beta \mapsto \max_y \log p_{\beta}(y|x)$ is increasing.

## 3.3 The impact of temperature on class proportions

Altering the uncertainty of the conditional distribution $p_{\beta}(y|x)$ for a fixed $x$ is likely to have an impact on the marginal distribution $p_{\beta}(y)$, i.e. the class proportions. Let $p(x)$ be the distribution of the features. The class proportions can be written

$$ p_{\beta}(y) = \int p_{\beta}(y|x)p(x)dx. \qquad (20) $$

A direct consequence of Jensen's inequality and Theorem 3.1 is that, when $\beta_1 < \beta_2$, $p_{\beta_2}(y)$ majorises $p_{\beta_1}(y)$. Thus, $H(p_{\beta}(y))$ will also be a decreasing function of $\beta$.

Concretely, increasing the temperature will make the class proportions more spread out. This behaviour should be kept in mind in imbalanced scenarios, for which temperature scaling is likely to “help” the minority classes.

## 3.4 For language models, increasing the temperature can decrease the entropy

The previous results are fairly intuitive and grant that temperature scaling behaves “as it should” for classification. However, we will see here that it can have an unexpected on language models. Most state-of-the-art language models are autoregressive models of the form

$$ p(x_1, \dots, x_T) = p(x_1) \prod_{t=1}^{T-1} p(x_{t+1}|x_t), \qquad (21) $$
<figure><img src="image_2.png" /><figcaption>Figure 1: Entropies of two tempered versions of a toy language model. Standard temperature scaling has the expected monotonic effect on entropy, but is impractical for LLMs. The “myopic" version, widely used in practice, has a much less intuitive behaviour.</figcaption></figure>

where $x_1, \dots, x_T$ are tokens living in a finite vocabulary $\mathcal{X}$. Standard temperature scaling of the joint model is intractable in this case, since computing

$$p_{\beta}(x_1, \dots, x_T) \propto p(x_1)^{\beta} \prod_{t=1}^{T-1} p(x_{t+1} | x_t)^{\beta}, \qquad (22)$$

would involve dealing with a normalising constant that is a sum over $|\mathcal{X}|^T$ terms. A much simpler alternative, widely used in practice, is to apply temperature scaling independently to all decoding steps, leading to the distribution

$$p'_{\beta}(x_1, \dots, x_T) = p_{\beta}(x_1) \prod_{t=1}^{T-1} p_{\beta}(x_{t+1} | x_t), \qquad (23)$$

called myopic temperature scaling in Shih et al. (2023).

Of course, in general, there is no reason to expect that $p_{\beta} = p'_{\beta}$. Should this be a source of concern? Shih et al. (2023) provide a tractable approximation of $p_{\beta}$ called long horizon temperature scaling and compare this approximation to $p'_{\beta}$. Based on these experiments and on a toy example, they convincingly argue that tuning the temperature of the approximation of $p_{\beta}$ leads to a much better quality/diversity trade-off than tuning the temperature of $p'_{\beta}$.

While standard temperature scaling $p_{\beta}$ has the predictable behaviour described previously (most reasonable measures of diversity will increase as the temperature increase), we provide here a counter-example that highlights that the entropy of $p'_{\beta}$ can be nonmonotonic!

Consider the simple toy autoregressive model on a binary vocabulary $\mathcal{X} = \{0, 1\}$

$$p(x_1, x_2) = p(x_1)p(x_2|x_1), \qquad (24)$$

with $p(x_1) = \mathcal{B}(x_1|\pi)$ and $p(x_2|x_1) = \mathcal{B}(x_2|\rho_{x_1})$ for some $\pi, \rho_0, \rho_1 \in (0, 1)$. Surprisingly, for some values of the parameters, $\beta \mapsto H(p'_{\beta})$ does not always decrease. Indeed, Figure 3 shows that when $\pi = 0.51, \rho_0 = 0.01$, and $\rho_1 = 0.51$, the entropy of myopic temperature scaling decreases when $\beta$ small, but then starts to increase before finally decreasing again. Why is this the case? It is instructive to decompose the joint entropy using the chain rule:

$$H(p'_{\beta}) = H(p_{\beta}(x_1)) + \mathbb{E}_{p_{\beta}(x_1)}[H(p_{\beta}(x_2|x_1))]. \qquad (25)$$

The entropy of $p_{\beta}(x_1)$ is decreasing so the monotonicity of the joint entropy will mostly depend on the conditional entropy of $x_2$ given $x_1$. When $\beta$ becomes smaller it becomes more and more certain that $x_1 = 0$. However, the conditional entropy of $x_2$ is much larger when $x_1 = 0$ than when $x_1 = 1$, so there will be a regime for which increasing $\beta$ will increase the entropy.
<figure><img src="image_3.png" /><figcaption>Figure 2: Temperature scaling as an information projection. In both cases, the initial model $p$ is projected onto the set $Q$ of distributions of constant entropy $h^* = 0.9$. The blue arrow is the path of all tempered models between $p$ and its projection $p_{\beta^*}$. This path can be interpreted as the geodesic between $p$ and $p_{\beta^*}$. (Left) The initial distribution $p = (0.01, 0.09, 0.9)$ has a lower entropy than $h^*$, and is warmed up towards $p_{\beta^*}$ with $\beta^* \approx 0.37$. (Right) The initial distribution $p = (0.4, 0.35, 0.25)$ has a higher entropy than $h^*$, and is cooled down towards $p_{\beta^*}$ with $\beta^* \approx 3.98$.</figcaption></figure>

This mechanism suggests that similar non-monotonic effects may arise whenever early-token uncertainty strongly conditions later-token entropy. More details on this experiment can be found in Appendix E.

# 4 A geometric interpretation

We provide here geometric insights about how changing the temperature allows to travel along the simplex. None of these results are new, but they were, to the best of our knowledge, not discussed in this context.

## 4.1 Temperature scaling as an information projection

We saw in the previous section that temperature scaling allows to move from the initial model towards models with higher or lower entropy. There is a precise geometric interpretation of this fact, that we describe here.

Again, we fix some input $x \in \mathcal{X}$. The purpose of temperature scaling was to alter the initial model $p(y|x)$ to make it more or less uncertain, i.e. to increase or decrease its entropy. A geometric approach to this problem would be to select an entropy level $h^* > 0$ that we would like to reach, and find the distribution closest to $p(y|x)$ that has this given entropy. For instance, if $h^* \ge H(p)$ then we are looking for a model less confident than $p$. Considering the Kullback-Leibler divergence as a measure of closeness, this becomes the following information projection problem:

$$q^*(y|x) \in \operatorname*{argmin}_{q \in \mathcal{Q}} \mathrm{KL}(q(y|x) || p(y|x)), \qquad (26)$$

where $Q = \{q \text{ s.t. } H(q) = h^*\}$. It turns out that the solution to this problem is exactly temperature scaling.

**Theorem 4.1.** If $p(y|x)$ is unimodal and has full support, then the information projection problem (26) has a unique solution $q^*$, and there exists $\beta^* \ge 0$ such that $q^*(y|x) = p_{\beta^*}(y|x)$.

This result, illustrated on Figure 2, means that we can interpret a tempered model as the closest model with the required amount of uncertainty. A version of this theorem dates back, at least, to Sgarro (1978). A recent proof using Lagrange multipliers can be found in Girardin and Regnault (2016, Theorem 1), who also discuss what happens when there are several modes or when the distribution does not have full support.

Theorem 4.1 is also a well-known result in the statistical physics literature, where it is typically known in terms of its dual formulation (in the Lagrange sense). Indeed, recalling that in the statistical physics perspective of Section 2.1 $p(y|x)$ is the Boltzmann-Gibbs distribution with energies $E_y$ and at temperature $\beta = 1$, opening up the expression of the KL divergence we can write:

$$\mathrm{KL}(q(y|x) || p(y|x)) = -H(q(y|x)) - \mathbb{E}_{y \sim q(y|x)}[\log p(y|x)] = -H(q(y|x)) + \mathbb{E}_{y \sim q(y|x)}[E_y] + \log \mathcal{Z}(1, z). \quad (27)$$
Hence, minimising the KL($q||p$) at fixed entropy $H(q) = h^*$ is equivalent to maximising the entropy $H(q)$ at fixed “internal energy” $E_q[E_y] = u^*$, which is precisely the original construction of the canonical ensemble in Boltzmann (1885), later formalised by Gibbs (1902). Indeed, entropy and energy are conjugate variables in thermodynamics, with the linear relationship between them typically used as a definition for the inverse-temperature in equilibrium statistical physics. From this perspective, the assumption of unimodality of $p(y|x)$ in Theorem 4.1 is equivalent to the existence of a unique ground state (i.e. unique minimal energy $E_y = -z_y$). This connection between information geometry and statistical physics was pioneered by Jaynes (1957).

Note this result does not hold under other metrics than the Kullback-Leibler divergence, and temperature scaling will generally not be optimal. Girardin and Regnault (2016, Proposition 4) provide a similar result for the reverse Kullback-Leibler divergence.

## 4.2 Tempering along geodesics

What does it mean, geometrically, to move from one temperature to another? A starting point is to notice that, for any $0 < \beta_1 < \beta < \beta_2$,

$$p_{\beta} \propto p^{\beta} = p^{\alpha\beta_1+(1-\alpha)\beta_2} = p_{\beta_1}^{\alpha} p_{\beta_2}^{1-\alpha}, \qquad (28)$$

with $\alpha = (\beta_2 - \beta)/(\beta_2 - \beta_1) \in (0, 1)$. This means that $p_{\beta}$ is the normalised geometric mean of $p_{\beta_1}$ and $p_{\beta_2}$. Such normalised geometric means, sometimes called “products of expert”, “geometric mixtures”, or “logarithmic pool”, have many interesting properties (see e.g. Amari, 2007; Carvalho et al., 2023).

In particular, in information geometry, if we see the family of discrete distributions as an exponential family, the curve $\beta \in (\beta_1, \beta_2) \mapsto p_{\beta}$ is the geodesic from $p_{\beta_1}$ to $p_{\beta_2}$ (see, e.g. Amari, 2016, Section 2.4). This means that moving from one temperature to another will be moving along a geodesic, as seen in Figure 2.

# 5 Temperature scaling is the only accuracy-preserving linear scaler

We prove here another simple characterisation of temperature scaling, as the only linear scaler that does not alter “hard” model predictions. We say that a scaler is accuracy-preserving when it does not change the model predictions, i.e. when the argmax of the scaled predictions is the same as the one of the original predictions. Note that the argmax of a vector is defined as the set of indices that attain the max of the vector (in particular it is not necessary a single label).

Guo et al. (2017) attributed the superiority of temperature scaling over matrix scaling to its accuracy-preserving nature. This property was then further studied by Zhang et al. (2020), who coined the term “accuracy-preserving”, and Rahimi et al. (2020), who both tried to design accuracy-preserving scalers that are more flexible than temperature scaling. These works, as well as other accuracy-preserving scalers proposed thereafter (Esaki et al., 2024; Zhang et al., 2025), gain this additional flexibility by making scalers nonlinear. Here, we prove that this nonlinearity is necessary: it is impossible for a linear scaler to be both order-preserving and more flexible than temperature scaling.

Our main tool will be the following result, that characterises argmax-invariant linear functions. To the best of our knowledge, this result has not appeared in the literature, and may be of independent interest.

**Theorem 5.1.** Let $\mathbf{W} \in \mathbb{R}^{K \times K}$ and $\mathbf{b} \in \mathbb{R}^K$ such that, for all $\mathbf{z} \in \mathbb{R}^K$ we have

$$\operatorname{argmax}(\mathbf{W}\mathbf{z} + \mathbf{b}) = \operatorname{argmax}(\mathbf{z}). \qquad (29)$$

Then, there exist $\alpha \in \mathbb{R}^K$, $\beta > 0$, and $\gamma \in \mathbb{R}$ such that

$$\mathbf{W} = \beta \mathbf{I}_K + \mathbf{1}_K \alpha^T, \quad \text{and} \quad \mathbf{b} = \gamma \mathbf{1}_K. \qquad (30)$$

The proof is available in Appendix F. There are two different kinds of linear scalers:

* the matrix scaling model $\tilde{p}_{\mathbf{W},\mathbf{b}}$, defined in Equation (15), which is linear in the logits,

* the Dirichlet calibration model $\tilde{p}_{\mathbf{W},\mathbf{b}}$, defined in Equation (16), which is linear in the log-probabilities.

While the two scalers are not formally equivalent, they both contain temperature scaling as a submodel. The following result shows that this is the only submodel that is accuracy-preserving in both cases.
**Corollary 1.** Let $\mathbf{W} \in \mathbb{R}^{K \times K}$ and $\mathbf{b} \in \mathbb{R}^K$ such that $\tilde{p}_{\mathbf{W},\mathbf{b}}$ (respectively $\tilde{p}_{\mathbf{W},\mathbf{b}}$) is accuracy-preserving. Then, there exists $\beta \ge 0$ such that $\tilde{p}_{\mathbf{W},\mathbf{b}} = p_\beta$ (respectively $\tilde{p}_{\mathbf{W},\mathbf{b}} = p_\beta$).

The proof is a direct application of Theorem 5.1, and is available in Appendix G.

This result clarifies why attempts to design more expressive accuracy-preserving scalers must inevitably depart from linearity (at least when the initial model has a good accuracy). Conversely, it explains why temperature scaling often performs competitively despite its extreme simplicity: among all linear recalibrations, it already exhausts the available degrees of freedom once accuracy is fixed. This result is therefore both an argument in favour of temperature scaling, and also one in favour of nonlinear scalers.

# 6 Discussion

We revisited the elementary properties of temperature scaling, and hope that this work can serve as an invitation to study this simple and popular model.

For probabilistic classifiers, temperature scaling behaves exactly as intended. Increasing the temperature monotonically increases uncertainty in the strong sense of majorisation. This justify its interpretation as a principled uncertainty control tuner. In contrast, we showed that these guarantees do not extend automatically to autoregressive language models as they are used in practice. This observation challenges the common assumption that temperature acts as a reliable diversity knob at the sequence level.

Beyond uncertainty, our results also clarify the structural role of temperature scaling among calibration methods: it is the only linear calibration method that preserves hard predictions. Consequently, any attempt to design more expressive accuracy-preserving scalers must necessarily rely on nonlinear transformations.

One question that remains wide open is *why does temperature scaling perform so well?* Berta et al. (2025b) showed that even in very simple cases, the optimal scaler is generally nonlinear, thus it is surprising to see a model that simple work that well. Another avenue of future research would be to investigate the practical relevance of our counter-example for real-life LLMs.

Despite its theoretical nature, our work leads to two practical take-home messages:

* For LLMs, temperature can have counterintuitive effects on the diversity, which may explains why other methods to play with text stochasticity are sometimes preferred (Holtzman et al., 2020), and is in line with the empirical findings of Peeperkorn et al. (2024).

* To calibrate very accurate classifiers, temperature scaling should be preferred to matrix scaling and Dirichlet calibration, since temperature scaling is the only way to implement accuracy-preservation into these models.

# Acknowledgements

BL was supported by the French government, managed by the National Research Agency (ANR), under the France 2030 programme with the reference "ANR-23-IACL-0008" and the Choose France - CNRS AI Rising Talents program.

PAM was also supported by the French government, through the France 2030 programme managed by the ANR, with the reference number "ANR-23-IACL-0001".

# References

J. Achiam, S. Adler, S. Agarwal, L. Ahmad, I. Akkaya, F. L. Aleman, D. Almeida, J. Altenschmidt, S. Altman, S. Anadkat, et al. GPT-4 technical report. arXiv preprint arXiv:2303.08774, 2023.

S. Amari. Integration of stochastic models by minimizing $\alpha$-divergence. *Neural computation*, 19(10):2780–2796, 2007.

S. Amari. *Information geometry and its applications*, volume 194. Springer, 2016.
A. N. Angelopoulos, S. Bates, et al. Conformal prediction: A gentle introduction. Foundations and trends® in machine learning, 16(4):494–591, 2023.

Y. Bai, S. Mei, H. Wang, and C. Xiong. Don't just blame over-parametrization for over-confidence: Theoretical analysis of calibration in binary classification. In International conference on machine learning, pages 566–576. PMLR, 2021.

E. Berta, D. Holzmüller, M. I. Jordan, and F. Bach. Rethinking early stopping: Refine, then calibrate. arXiv preprint arXiv:2501.19195, 2025a.

E. Berta, D. Holzmüller, M. I. Jordan, and F. Bach. Structured matrix scaling for multi-class calibration. arXiv preprint arXiv:2511.03685, 2025b.

J. Blasiok, P. Gopalan, L. Hu, and P. Nakkiran. When does optimizing a proper loss yield calibration? *Advances in Neural Information Processing Systems*, 36:72071–72095, 2023.

L. Boltzmann. Über die Möglichkeit der begründung einer kinetischen gastheorie auf anziehende kräfte allein. *Annalen der Physik*, 260(1):37–44, 1885.

R. Brent. Algorithms for minimization without derivatives. *Prentice-Hall, Englewood Cliffs NJ*, 1973.

L. M. Carvalho, D. A. M. Villela, F. C. Coelho, and L. S. Bastos. Bayesian Inference for the Weights in Logarithmic Pooling. *Bayesian Analysis*, 18(1):223–251, 2023.

L. Clarté, B. Loureiro, F. Krzakala, and L. Zdeborová. On double-descent in uncertainty quantification in overparametrized models. In *International Conference on Artificial Intelligence and Statistics*, pages 7089–7125. PMLR, 2023a.

L. Clarté, B. Loureiro, F. Krzakala, and L. Zdeborová. Expectation consistency for calibration of neural networks. In *Uncertainty in Artificial Intelligence*, pages 443–453. PMLR, 2023b.

L. Clarté, B. Loureiro, F. Krzakala, and L. Zdeborová. Theoretical characterization of uncertainty in high-dimensional linear classification. *Machine Learning: Science and Technology*, 4(2):025029, 2023c.

D. R. Cox. Two further applications of a model for binary regression. *Biometrika*, 45(3/4):562–565, 1958.

L. Dabah and T. Tirer. On temperature scaling and conformal prediction of deep classifiers. In *International Conference on Machine Learning*. PMLR, 2025.

J. Domke. Moment-matching conditions for exponential families with conditioning or hidden data. arXiv preprint arXiv:2001.09771, 2020.

Y. Esaki, A. Nakamura, K. Kawano, R. Tokuhisa, and T. Kutsuna. Accuracy-preserving calibration via statistical modeling on probability simplex. In *International Conference on Artificial Intelligence and Statistics*, pages 1666–1674. PMLR, 2024.

R. Foygel Barber, E. J. Candes, A. Ramdas, and R. J. Tibshirani. The limits of distribution-free conditional predictive inference. *Information and Inference: A Journal of the IMA*, 10(2):455–482, 2021.

G. Gemini Team. Gemini: a family of highly capable multimodal models. arXiv preprint arXiv:2312.11805, 2025.

I. Gibbs, J. J. Cherian, and E. J. Candès. Conformal prediction with conditional guarantees. *Journal of the Royal Statistical Society Series B: Statistical Methodology*, page 1100–1126, 2025.

J. W. Gibbs. *Elementary principles in statistical mechanics: developed with especial reference to the rational foundations of thermodynamics*. C. Scribner's sons, 1902.

V. Girardin and P. Regnault. Escort distributions minimizing the kullback-leibler divergence for a large deviations principle and tests of entropy level. *Annals of the Institute of Statistical Mathematics*, 68(2): 439–468, 2016.
C. Guo, G. Pleiss, Y. Sun, and K. Q. Weinberger. On calibration of modern neural networks. In *International conference on machine learning*, pages 1321–1330. PMLR, 2017.

G. H. Hardy, J. E. Littlewood, and G. Pólya. *Inequalities (2nd edition)*. Cambridge University Press, 1952.

G. Hinton, O. Vinyals, and J. Dean. Distilling the knowledge in a neural network. *NIPS 2014 Deep Learning Workshop, arXiv preprint arXiv:1503.02531*, 2015.

A. Holtzman, J. Buys, L. Du, M. Forbes, and Y. Choi. The curious case of neural text degeneration. *International Conference on Learning Representations*, 2020.

E. T. Jaynes. Information theory and statistical mechanics. *Physical review*, 106(4):620, 1957.

T. Joy, F. Pinto, S.-N. Lim, P. H. Torr, and P. K. Dokania. Sample-dependent adaptive temperature scaling for improved calibration. In *Proceedings of the AAAI Conference on Artificial Intelligence*, volume 37, pages 14919–14926, 2023.

M. Kardar. *Statistical Physics of Particles*. Cambridge University Press, 2007.

A. Karpathy. The unreasonable effectiveness of recurrent neural networks. Blog post, https://karpathy.github.io/2015/05/21/rnn-effectiveness/, 2015.

M. Kull, M. Perello Nieto, M. Kängsepp, T. Silva Filho, H. Song, and P. Flach. Beyond temperature scaling: Obtaining well-calibrated multi-class probabilities with dirichlet calibration. *Advances in neural information processing systems*, 32, 2019.

T. O. Kvålseth. Entropies and their concavity and Schur-concavity conditions. *IEEE Access*, 10:96006–96015, 2022.

A. Liu, B. Feng, B. Xue, B. Wang, B. Wu, C. Lu, C. Zhao, C. Deng, C. Zhang, C. Ruan, et al. DeepSeek-v3 technical report. *arXiv preprint arXiv:2412.19437*, 2024.

D. C. Liu and J. Nocedal. On the limited memory BFGS method for large scale optimization. *Mathematical programming*, 45(1):503–528, 1989.

A. Marshall and I. Olkin. Norms and inequalities for condition numbers. *Pacific Journal of Mathematics*, 15 (1):241–247, 1965.

A. W. Marshall, I. Olkin, and B. Arnold. *Inequalities: Theory of Majorization and Its Applications*. Springer, 2011.

M. Minderer, J. Djolonga, R. Romijnders, F. Hubis, X. Zhai, N. Houlsby, D. Tran, and M. Lucic. Revisiting the calibration of modern neural networks. *Advances in neural information processing systems*, 34:15682–15694, 2021.

A. S. Mozafari, H. S. Gomes, W. Leão, S. Janny, and C. Gagné. Attended temperature scaling: a practical approach for calibrating deep neural networks. *arXiv preprint arXiv:1810.11586*, 2018.

P. Nakkiran, A. Bradley, A. Goliński, E. Ndiaye, M. Kirchhof, and S. Williamson. Trained on tokens, calibrated on concepts: The emergence of semantic calibration in LLMs. *arXiv preprint arXiv:2511.04869*, 2025.

T. Papamarkou, M. Skoularidou, K. Palla, L. Aitchison, J. Arbel, D. Dunson, M. Filippone, V. Fortuin, P. Hennig, J. M. Hernández-Lobato, et al. Position: Bayesian deep learning is needed in the age of large-scale AI. In *International Conference on Machine Learning*, pages 39556–39586. PMLR, 2024.

F. Pedregosa, G. Varoquaux, A. Gramfort, V. Michel, B. Thirion, O. Grisel, M. Blondel, P. Prettenhofer, R. Weiss, V. Dubourg, J. Vanderplas, A. Passos, D. Cournapeau, M. Brucher, M. Perrot, and E. Duchesnay. Scikit-learn: Machine learning in Python. *Journal of Machine Learning Research*, 12:2825–2830, 2011.
M. Peeperkorn, T. Kouwenhoven, D. Brown, and A. Jordanous. Is temperature the creativity parameter of large language models? In *ICCC*, 2024.

J. Platt. Probabilistic outputs for support vector machines and comparisons to regularized likelihood methods. *Advances in large margin classifiers*, 10(3):61–74, 1999.

A. Rahimi, A. Shaban, C.-A. Cheng, R. Hartley, and B. Boots. Intra order-preserving functions for calibration of multi-class neural networks. *Advances in neural information processing systems*, 33:13456–13467, 2020.

A. Rastogi, A. Q. Jiang, A. Lo, G. Berrada, G. Lample, J. Rute, J. Barmentlo, K. Yadav, K. Khandelwal, K. R. Chandu, et al. Magistral. *arXiv preprint arXiv:2506.10910*, 2025.

T. Sagawa. *Entropy, divergence, and majorization in classical and quantum thermodynamics*. SpringerBriefs in Mathematical Physics, 2022.

A. Sgarro. An informational divergence geometry for stochastic matrices. *Calcolo*, 15(1):41–49, 1978.

M. Shen, S. Das, K. Greenewald, P. Sattigeri, G. Wornell, and S. Ghosh. Thermometer: Towards universal calibration for large language models. *arXiv preprint arXiv:2403.08819*, 2024.

A. Shih, D. Sadigh, and S. Ermon. Long horizon temperature scaling. In *International Conference on Machine Learning*, pages 31422–31434. PMLR, 2023.

T. Silva Filho, H. Song, M. Perelo-Nieto, R. Santos-Rodriguez, M. Kull, and P. Flach. Classifier calibration: a survey on how to assess and improve predicted class probabilities. *Machine Learning*, 112(9):3211–3260, 2023.

R. J. Stevens and K. K. Poppe. Validation of clinical prediction models: what does the “calibration slope” really measure? *Journal of clinical epidemiology*, 118:93–99, 2020.

J. Tian, W. Cheung, N. Glaser, Y.-C. Liu, and Z. Kira. Uno: Uncertainty-aware noisy-or multimodal fusion for unanticipated input degradation. In *2020 IEEE International Conference on Robotics and Automation (ICRA)*, pages 5716–5723, 2020. doi: 10.1109/ICRA40945.2020.9197266.

C. Tomani, D. Cremers, and F. Buettner. Parameterized temperature scaling for boosting the expressive power in post-hoc uncertainty calibration. In *European conference on computer vision*, pages 555–569. Springer, 2022.

D. Ulmer, C. Hardmeier, and J. Frellsen. Prior and posterior networks: A survey on evidential deep learning methods for uncertainty estimation. *Transactions on Machine Learning Research*, 2023.

A. van der Vaart. *Asymptotic statistics*, volume 3. Cambridge university press, 2000.

P. Virtanen, R. Gommers, T. E. Oliphant, M. Haberland, T. Reddy, D. Cournapeau, E. Burovski, P. Peterson, W. Weckesser, J. Bright, S. J. van der Walt, M. Brett, J. Wilson, K. J. Millman, N. Mayorov, A. R. J. Nelson, E. Jones, R. Kern, E. Larson, C. J. Carey, İ. Polat, Y. Feng, E. W. Moore, J. VanderPlas, D. Laxalde, J. Perktold, R. Cimrman, I. Henriksen, E. A. Quintero, C. R. Harris, A. M. Archibald, A. H. Ribeiro, F. Pedregosa, P. van Mulbregt, and SciPy 1.0 Contributors. SciPy 1.0: Fundamental Algorithms for Scientific Computing in Python. *Nature Methods*, 17:261–272, 2020. doi: 10.1038/s41592-019-0686-2.

J. Xie, A. Chen, Y. Lee, E. Mitchell, and C. Finn. Calibrating language models with adaptive temperature scaling. In *Proceedings of the 2024 Conference on Empirical Methods in Natural Language Processing*, pages 18128–18138, 2024.

J. Zhang, B. Kailkhura, and T. Y.-J. Han. Mix-n-match: Ensemble and compositional methods for uncertainty calibration in deep learning. In *International conference on machine learning*, pages 11117–11128. PMLR, 2020.

Y. Zhang, G. Batista, and S. S. Kanhere. Instance-wise monotonic calibration by constrained transformation. In *Proceedings of the Forty-First Conference on Uncertainty in Artificial Intelligence*, 2025.
# Appendix

## A Proof that using the logits and using the log-probabilities are equivalent

With the notations of Section 2, since $\pi = \text{Softmax}(\mathbf{z})$, we find

$$ \text{Softmax}(\beta \log \pi) = \text{Softmax} \left( \beta \left( \mathbf{z} - \log \left( \sum_{y=1}^{K} e^{z_y} \right) \mathbf{1}_K \right) \right) \quad (31) $$

$$ = \text{Softmax}(\beta \mathbf{z}), \quad (32) $$

using the fact that the Softmax is invariant to adding the same constant (here $-\beta \log(e^{z_1} + \dots + e^{z_K})$) to all coordinates.

## B Proof of Lemma 1 (derivatives of the log-partition function)

The log-partition function is defined as

$$ \log \mathcal{Z}(\beta, \mathbf{z}) = \log \left( \sum_{y=1}^{K} e^{\beta z_y} \right). \quad (33) $$

Thus, its first derivative is

$$ \frac{d \log \mathcal{Z}(\beta, \mathbf{z})}{d\beta} = \frac{\sum_{y=1}^{K} z_y e^{\beta z_y}}{\mathcal{Z}(\beta, \mathbf{z})} = \sum_{y=1}^{K} z_y \underbrace{\frac{e^{\beta z_y}}{\mathcal{Z}(\beta, \mathbf{z})}}_{p_{\beta}(y|\mathbf{x})} = \mathbb{E}_{y \sim p_{\beta}(y|\mathbf{x})} [z_y]. \quad (34) $$

The second derivative can also be seen as expectation, using the fact that $\frac{d}{d\beta} p_{\beta}(y|\mathbf{x}) = \frac{d \log p_{\beta}(y|\mathbf{x})}{d\beta} p_{\beta}(y|\mathbf{x})$,

$$ \frac{d^2 \log \mathcal{Z}(\beta, \mathbf{z})}{d\beta^2} = \frac{d}{d\beta} \sum_{y=1}^{K} z_k p_{\beta}(y|\mathbf{x}) = \sum_{y=1}^{K} z_k \frac{d \log p_{\beta}(y|\mathbf{x})}{d\beta} p_{\beta}(y|\mathbf{x}) = \mathbb{E} \left[ z_y \frac{d \log p_{\beta}(y|\mathbf{x})}{d\beta} \right]. \quad (35) $$

Now, using the definition of $p_{\beta}(y|\mathbf{x})$ and Equation (34) yields

$$ \frac{d \log p_{\beta}(y|\mathbf{x})}{d\beta} = z_y - \frac{d \log \mathcal{Z}(\beta, \mathbf{z})}{d\beta} = z_y - \mathbb{E}_{y \sim p_{\beta}(y|\mathbf{x})} [z_y]. \quad (36) $$

Plugging this back in Equation (35) finally leads to

$$ \frac{d^2 \log \mathcal{Z}(\beta, \mathbf{z})}{d\beta^2} = \mathbb{E} [z_y(z_y - \mathbb{E}_{y \sim p_{\beta}(y|\mathbf{x})} [z_y])] = \mathbb{E}_{y \sim p_{\beta}(y|\mathbf{x})} [z_y^2] - \mathbb{E}_{y \sim p_{\beta}(y|\mathbf{x})} [z_y]^2 = \text{Var}_{y \sim p_{\beta}(y|\mathbf{x})} (z_y). \quad (37) $$

## C Proof of Proposition 1 (properties of the likelihood)

The negative log-likelihood is equal to

$$ \mathcal{L}(\beta) = -\frac{1}{n} \sum_{i=1}^{n} \log p_{\beta}(y_i|\mathbf{x}_i) = -\frac{1}{n} \sum_{i=1}^{n} (\beta z_{y_i} - \log \mathcal{Z}(\beta, \mathbf{z}_i)). \quad (38) $$

Thus, using Lemma 1, we find

$$ \frac{d\mathcal{L}(\beta)}{d\beta} = -\frac{1}{n} \sum_{i=1}^{n} (z_y - \mathbb{E}_{y \sim p_{\beta}(y|\mathbf{x})} [z_y]). \quad (39) $$
<figure><img src="image_4.png" /><figcaption>Figure 3: Terms involved in the computation of the entropy of the myopically scaled model. (Left) The marginal and conditional entropies of Equation 45. (Right) The two terms of the decomposition of Equation (46). The source of nonmotonicity is the term $\pi_{\beta}H(p_{\beta}(x_2|x_1 = 1)$, that is the product of an increasing and a decreasing functions.</figcaption></figure>

Now, since $\log p_{\beta}(y|\mathbf{x}_i) = \beta z_{y_i} - \log \mathcal{Z}(\beta, \mathbf{z}_i)$, we can write $z_{y_i} = (1/\beta)(\log p_{\beta}(y|\mathbf{x}_i) + \log \mathcal{Z}(\beta, \mathbf{z}_i))$, and plugging that in Equation (39), we find

$$ \frac{d\mathcal{L}(\beta)}{d\beta} = \frac{1}{\beta} \left( \underbrace{-\frac{1}{n}\sum_{i=1}^{n} \log p_{\beta}(y_i|\mathbf{x}_i)}_{\text{cross-entropy}} - \underbrace{-\frac{1}{n}\sum_{i=1}^{n} \mathbb{E}_{y \sim p_{\beta}(y|\mathbf{x}_i)}[\log p_{\beta}(y|\mathbf{x}_i)]}_{\text{expected cross-entropy}} \right). \quad (40) $$

The second derivative is a direct consequence of the second derivative of the log-partition (Lemma 1):

$$ \frac{d^2 \mathcal{L}(\beta)}{d\beta^2} = \frac{1}{n} \sum_{i=1}^{n} \mathrm{Var}_{y \sim p_{\beta}(y|\mathbf{x}_i)}(z_y). \quad (41) $$

## D Proof of Proposition 2 (monotonicity of the entropy)

The entropy is equal to

$$ H(p_{\beta}(y|\mathbf{x})) = -\sum_{y=1}^{K} p_{\beta}(y|\mathbf{x}) \log p_{\beta}(y|\mathbf{x}) = -\sum_{y=1}^{K} p_{\beta}(y|\mathbf{x}) (\beta z_y - \log \mathcal{Z}(\beta, \mathbf{z})) \quad (42) $$

$$ = -\beta \underbrace{\mathbb{E}_{y \sim p_{\beta}(y|\mathbf{x})}[z_y]}_{\frac{d \log \mathcal{Z}(\beta, \mathbf{z})}{d\beta}} + \log \mathcal{Z}(\beta, \mathbf{z}). \quad (43) $$

Thus, using Lemma 1 again, we find

$$ \frac{dH(p_{\beta}(y|\mathbf{x}))}{d\beta} = -\beta \frac{d^2 \log \mathcal{Z}(\beta, \mathbf{z})}{d\beta^2} - \frac{d \log \mathcal{Z}(\beta, \mathbf{z})}{d\beta} + \frac{d \log \mathcal{Z}(\beta, \mathbf{z})}{d\beta} = -\beta \frac{d^2 \log \mathcal{Z}(\beta, \mathbf{z})}{d\beta^2} = -\beta \mathrm{Var}_{y \sim p_{\beta}(y|\mathbf{x})}(z_y). \quad (44) $$

## E More details on the toy language model

In the context of Section 3.4, the entropy of the myopic model can be decomposed using the chain rule as

$$ H(p'_{\beta}) = H(p_{\beta}(x_1)) + \mathbb{E}_{p_{\beta}(x_1)}[H(p_{\beta}(x_2|x_1))], \quad (45) $$
where $H(p_{\beta}(x_1))$ is the marginal entropy of the first token, that we will denote $H_{p_{\beta}}(x_1)$, and $\mathbb{E}_{p_{\beta}(x_1)}[H(p_{\beta}(x_2|x_1))]$ is the conditional entropy, that we will denote $H_{p_{\beta}}(x_2|x_1)$. According to Proposition 2, $H_{p_{\beta}}(x_1)$ is decreasing. Since $p(x_1) = \mathcal{B}(x_1|\pi)$ and $p(x_2|x_1) = \mathcal{B}(x_2|\rho_{x_1})$, the conditional entropy can be decomposed as

$$H_{p_{\beta}}(x_1) = (1 - \pi_{\beta})H(p_{\beta}(x_2|x_1 = 0)) + \pi_{\beta}H(p_{\beta}(x_2|x_1 = 1)). \quad (46)$$

The two entropies of the conditional distributions are decreasing (again, because of Proposition 2). However, since $\pi = 0.55$, $\pi_{\beta}$ is an increasing function of $\beta$, which explains that the conditional entropy can actually be locally increasing.

# F Proof of Theorem 5.1 (characterisation of linear accuracy-preserving functions)

**Theorem F.1.** Let $\mathbf{W} \in \mathbb{R}^{K \times K}$ and $\mathbf{b} \in \mathbb{R}^K$ such that, for all $\mathbf{z} \in \mathbb{R}^K$ we have

$$\operatorname{argmax}(\mathbf{W}\mathbf{z} + \mathbf{b}) = \operatorname{argmax}(\mathbf{z}). \quad (47)$$

Then, there exist $\alpha \in \mathbb{R}^K$, $\beta > 0$, and $\gamma \in \mathbb{R}$ such that

$$\mathbf{W} = \beta \mathbf{I}_K + \mathbf{1}_K \alpha^T, \quad \text{and} \quad \mathbf{b} = \gamma \mathbf{1}_K. \quad (48)$$

*Proof.* The roadmap of the proof goes as follows: first, we will prove that $\mathbf{b}$ has the desired form, then we will prove that $\mathbf{W}$ has the desired form (by studying separately the cases $K = 2$ and $K \ge 3$). Finally, we will show that $\beta > 0$.

Applying Equation (47) to $\mathbf{z} = 0$ leads to $\operatorname{argmax}(\mathbf{b}) = \operatorname{argmax}(\mathbf{0}_K) = \{1, \dots, K\}$, therefore all coefficients of $\mathbf{b}$ need to be equal, and thus there exists $\gamma \in \mathbb{R}$ such that $\mathbf{b} = \gamma \mathbf{1}_K$.

We now turn to $\mathbf{W}$. The fact that $\mathbf{b} = \gamma \mathbf{1}_K$ implies that, for all $\mathbf{z} \in \mathbb{R}^K$,

$$\operatorname{argmax}(\mathbf{W}\mathbf{z} + \mathbf{b}) = \operatorname{argmax}(\mathbf{W}\mathbf{z}) = \operatorname{argmax}(\mathbf{z}), \quad (49)$$

which will be our main tool to study the structure of $\mathbf{W}$.

We begin with the case $K = 2$. Let $\mathbf{W} \in \mathbb{R}^{2 \times 2}$ that verifies (49), and let $\alpha_1 = w_{21}$, $\alpha_2 = w_{12}$, and $\beta = w_{11} - \alpha_1$. The fact that $\operatorname{argmax}(\mathbf{W}\mathbf{1}_2) = \operatorname{argmax}(\mathbf{1}_2) = \{1, 2\}$ implies that

$$w_{11} + w_{12} = w_{21} + w_{22} \implies w_{22} = w_{11} + w_{12} - w_{21} = \beta + \alpha_1 + \alpha_2 - \alpha_1 = \beta + \alpha_2. \quad (50)$$

Thus, $\mathbf{W} = \beta \mathbf{I}_K + \mathbf{1}_K \alpha^T$.

Let us now treat the case $K \ge 3$. For any $j \in \{1, \dots, K\}$, let us denote $\mathbf{e}_j \in \mathbb{R}^K$ the vector whose only nonzero coefficient is the $j$th one, which is equal to 1. Let $\mathbf{W}$ be a matrix that satisfies (49). Let $i, j, k$ be three distinct indices in $\{1, \dots, K\}$. Applying the condition to the vector $\mathbf{e}_i + \mathbf{e}_j + \mathbf{e}_k$ leads to

$$w_{ii} + w_{ij} + w_{ik} = w_{ji} + w_{jj} + w_{jk} = w_{ki} + w_{kj} + w_{kk}, \quad (51)$$

and applying it to $\mathbf{e}_i + \mathbf{e}_k$ leads to

$$w_{ii} + w_{ik} = w_{ki} + w_{kk}. \quad (52)$$

Subtracting these equations implies that $w_{ij} = w_{kj}$. This means that, for each column $j$, all elements but the diagonal one will have the same value, that we will denote $\alpha_j$.

Let us now use condition (49) with the vector $\mathbf{1}_K$. This implies that

$$w_{11} + \sum_{j \neq 1} \alpha_j = w_{22} + \sum_{j \neq 2} \alpha_j = \dots = w_{KK} + \sum_{j \neq K} \alpha_j. \quad (53)$$

Subtracting $\alpha_1 + \dots + \alpha_K$ from all terms leads then yields

$$w_{11} - \alpha_1 = \dots = w_{KK} - \alpha_K. \quad (54)$$

Let us denote this quantity $\beta$. Putting the pieces together, we have proven that $\mathbf{W} = \beta \mathbf{I}_K + \mathbf{1}_K \alpha^T$.

The only thing left to prove is the positivity of $\beta$. This follows from the fact that $\operatorname{argmax}(\mathbf{W}\mathbf{e}_1) = \operatorname{argmax}(\mathbf{e}_1) = \{1\}$. Indeed, this implies that $w_{11} > w_{21}$ i.e. that $\beta + \alpha_1 > \alpha_1$, leading to $\beta > 0$. $\square$
## G Proof of Corollary 1 (temperature scaling is the only accuracy-preserving linear scaler)

**Corollary 2.** Let $W \in \mathbb{R}^{K \times K}$ and $b \in \mathbb{R}^K$ such that $\tilde{p}_{W,b}$ (respectively $\tilde{p}_{W,b}$) is accuracy-preserving. Then, there exists $\beta \ge 0$ such that $\tilde{p}_{W,b} = p_{\beta}$ (respectively $\tilde{p}_{W,b} = p_{\beta}$).

*Proof.* Let us focus on matrix scaling (the proof for Dirichlet calibration is essentially the same). Let $W \in \mathbb{R}^{K \times K}$ and $b \in \mathbb{R}^K$ such that $\tilde{p}_{W,b}$ is accuracy-preserving. Because of Theorem 5.1, there exist $\alpha \in \mathbb{R}^K$, $\beta > 0$, and $\gamma \in \mathbb{R}$ such that $W = \beta I_K + \mathbf{1}_K \alpha^T$, and $b = \gamma \mathbf{1}_K$. Thus, for all $z \in \mathbb{R}^K$

$$ \mathrm{Softmax}(Wz + b) = \mathrm{Softmax}(\beta z + (\alpha^T z + \gamma)\mathbf{1}_K) = \mathrm{Softmax}(\beta z), \qquad (55) $$

using the fact that the softmax is invariant to adding a vector with identical coordinates, therefore $\tilde{p}_{W,b} = p_{\beta}$. $\square$