A short two-sentence abstract belongs here. It should summarize the post in plain text, without mathematics or hyperlinks, to mirror the website description field.
When discussing uncertainty estimation in deep learning, often, the first scenario that comes to mind is of the following shape:
the model produces a measure of uncertainty about its prediction
if the model is too uncertain, the prediction is deemed unreliable and discarded
This describes the setting of selective prediction
Selective prediction covers a range of popular tasks such as misclassification detection and OOD detection
Confidence scores
In this blogpost, we are interested in confidence scores $C$ that map the softmax output of a classification network into a scalar value,
which is then used to perform selection based on whether it exceeds a threshold,
Notably, since the threshold can be freely set, strictly increasing transforms $h(C(\boldsymbol{\pi}))$ give equivalent performance.
The AI research literature tends to take certain properties of softmax-based confidence scores for granted, and so readers may not have thought much about them. The aim of this blogpost is to explain some fundamental confidence score properties in an intuitive and enjoyable manner.
Discuss some fundamental properties of confidence scores (that AI researchers often take for granted).
Show how Schur convexity can induce these properties.
Discuss the prevalence of Schur-convex scores in the literature.
Show that Schur convexity nonetheless permits a wide range of selection behaviour.
If you were to ask a deep learning researcher or practitioner what fundamental properties a softmax confidence score $C(\boldsymbol \pi)$ should have, they would probably say the following two things straight away off the top of their head:
Property 1: Confidence is maximised for a one-hot distribution, e.g. \([0,1,0,\dots,0]\)
Property 2: Confidence is minimised for a uniform distribution, \([\frac{1}{K},\frac{1}{K},\dots,\frac{1}{K}]\)
To many, this will be intuitive and obvious. When a model thinks there is only a single possible outcome, it should be maximally confident. On the other hand, when it assigns equal probability to all outcomes, it should be maximally uncertain.
For our next property, consider a transfer of probability mass from a larger probability to a smaller one, that makes the distribution less unequal, like Robin Hood – stealing from the rich and giving to the poor.
Robin Hood Transfer: Move probability mass \(\delta\) from a larger probability \(\pi_i\) to a smaller one \(\pi_j\), where \(\pi_i > \pi_j\) and \(0 < \delta < \pi_i - \pi_j\). The distribution becomes “more equal”.
Doesn’t it make sense that confidence should decrease after such a transfer? Which gives us:
Property 3: Confidence decreases after a Robin Hood transfer, \(\boldsymbol \pi \rightarrow \boldsymbol{\pi'}\).
Although the above property may not immediately come to mind for an AI researcher, spreading out probability so it is more equal between outcomes intuitively ought to increase a model’s uncertainty. The literature tends to take the above properties for granted, and so readers may not have thought much about them. Confidence scores are motivated through decision theory
If Property 3 holds for one Robin Hood transfer, then it also holds for a sequence of Robin Hood transfers, with $C$ decreasing at each step.
The neat thing, is that given the above, the maximum and minimum end-points drop out intuitively.
Starting from any arbitrary distribution $\boldsymbol{\pi}$ that isn’t uniform, you can always construct a sequence of Robin Hood transfers, decreasing confidence, to reach the uniform distribution $\boldsymbol{u}$ by transferring mass to outcomes with below average probability such that $\pi_i<1/K\rightarrow\pi’_i=1/K$. As there are no more possible Robin Hood transfers at $\boldsymbol{u}$, it is less confident than all other $\boldsymbol{\pi}$ and therefore minimises confidence.
On the other hand, you can always reach a one-hot distribution by repeatedly reverse Robin Hood transferring into the most probable outcome, increasing confidence. As there are no more possible reverse Robin Hood transfers at a one-hot distribution, it is more confident than all other $\boldsymbol{\pi}$ and therefore maximises confidence.
Thus, Property 3 induces Properties 1 and 2.
It is intuitively desirable for a confidence score $C(\boldsymbol{\pi})$ to decrease after a Robin Hood transfer (Property 3), i.e. increasing equality between two classes increases uncertainty. If this is the case, it will also decrease after a sequence of such transfers. This means that $C$ is maximised for one-hot distributions and minimised for uniform distributions (Properties 1 and 2).
The above behaviour, which we’ve tried to introduce intuitively, can be framed formally as Majorisation and Schur convexity
For vectors $\boldsymbol{x},\boldsymbol{y}\in \mathbb{R}^K$, where $\sum_k x_k=\sum_k y_k$, $\boldsymbol{x}$ majorises $\boldsymbol{y}$ if, after sorting each vector from largest to smallest:
i.e. adding one element at a time, the cumulative sum of sorted (highest to lowest) $\boldsymbol{x}$ stays greater than or equal to that of $\boldsymbol{y}$, all the way. This is denoted:
Linking to our above illustrations about probabilities, note that:
Discrete probability vectors $\boldsymbol{\pi}$ all sum to 1, $\sum_k \pi_k=\sum_k \pi’_k=1$, so they all satisfy the first criterion for majorisation.
If $\boldsymbol{\pi}^{(1)} \rightarrow \boldsymbol{\pi}^{(2)}$ via a single Robin Hood transfer, then the sorted cumulative sum of $\boldsymbol{\pi}^{(1)}$ will exceed $\boldsymbol{\pi}^{(2)}$ starting at the donor’s original rank in $\boldsymbol{\pi}^{(1)}$.
Consequently, if $\boldsymbol{\pi}^{(1)} \rightarrow,\dots,\rightarrow \boldsymbol{\pi}^{(n)}$ via a sequence of Robin Hood transfers, each distribution will majorise all subsequent distributions, $\boldsymbol{\pi}^{(i)}\succ\boldsymbol{\pi}^{(k)}$ for all $k>i$. (This is visualised in the next widget.)
So if $\boldsymbol{\pi}^{(n)}$ can be produced from $\boldsymbol{\pi}^{(1)}$ through a sequence of Robin Hood transfers, $\boldsymbol{\pi}^{(1)}\succ\boldsymbol{\pi}^{(n)}$.
In fact, $\boldsymbol{x}\succ\boldsymbol{y} \quad\Longleftrightarrow\quad \boldsymbol{x}\xrightarrow{\text{Robin Hood transfers}}\boldsymbol{y}$. Going the other direction, you can show that if $\boldsymbol{x}\succ\boldsymbol{y}$ there always exists a sequence of Robin Hood transfers to get from $\boldsymbol{x}$ to $\boldsymbol{y}$
A function $f:\mathbb{R}^K\rightarrow\mathbb{R}$ is Schur convex if
and strictly Schur convex if
when $\boldsymbol{x}$ and $\boldsymbol{y}$ are not permutations of each other. If they are,
The above implies $f$ is necessarily permutation invariant, which we haven’t discussed explicitly yet – we elaborate on this later.
As a sequence of Robin Hood transfers from $\boldsymbol{x}$ to $\boldsymbol{y}$ implies $\boldsymbol{x}\succ\boldsymbol{y}$ and vice versa, the above strict definition of Schur convexity corresponds to our Property 3, i.e. confidence decreases after a Robin Hood transfer. The non-strict version permits confidence to stay the same under a Robin Hood transfer, but not increase. An example of a non-strict Schur-convex score would be the maximum of the softmax $C=\max_k \pi_k$ (MSP), where transfers between non-max outcomes do not change the score.
The following widget visualises how sequences of Robin Hood transfers relate to majorisation and Schur complexity.
In this blogpost, we chose to start with Robin Hood transfers conceptually as they more intuitively connect with confidence score behaviour compared to the formal definitions of majorisation and Schur convexity. In the remainder of the blog we will refer to Property 3 as Schur convexity; however, we want to emphasise the underlying intuition – Robin Hood transfers that increase inequality also decrease confidence/increase uncertainty.
Finally, we note that strict vs non-strict Schur convexity impacts the uniqueness of the maximum and minimum values from Properties 1 and 2
| Property | strictly Schur-convex | Schur-convex |
|---|---|---|
| 3: (sequence of) Robin Hood transfer(s) | decreases score | Cannot increase score |
| 1: one-hot distribution(s) | unique global maximiser(s) | global maximiser(s), unique or non-unique |
| 2: uniform distribution | unique global minimiser | global minimiser, unique or non-unique |
The Robin Hood explanation gives the main idea. The following details connect it to the formal definitions.
Why permutation invariance follows. Explain that a vector and any permutation of it majorise each other, so Schur convexity forces their confidence scores to agree. This also holds for strictly Schur-convex scores: strictness concerns genuine equalisation, not relabelling. Connect this to the later discussion of scores that depend on class identity.
Where continuity enters the transfer explanation. Our transfers allow rank reversal but exclude a complete swap, which would occur at $\delta=\pi_i-\pi_j$. Explain that a transfer can approach that swap arbitrarily closely. For continuous $C$, taking this limit gives a non-increase inequality between the original and swapped vectors; applying the argument in reverse forces equality. This supplies the symmetry used in the endpoint argument. Continuity is a convenient assumption for this bridge, not part of the definition of Schur convexity.
What “reachable by Robin Hood transfers” means. State the precise connection: $\boldsymbol{x}\succ\boldsymbol{y}$ means that $\boldsymbol{y}$ can be obtained by finitely many equalising transfers, possibly followed by a permutation
How to interpret the endpoints. Distinguish softmax outputs with positive probabilities from the closed simplex, which also includes zeros. For a finite, continuous score on the closed simplex, the endpoint comparisons apply directly; for strict Schur convexity on that domain, all $K$ one-hot vectors share the maximum and the uniform vector is the unique minimum. Explain separately how limiting values are used for scores such as Self-Certainty, which diverges whenever a probability approaches zero. Its strict classification applies on the positive-probability domain; one-hot vectors are not the only boundary points with divergent values.
Optional: checking the intuition with derivatives. Retain the criterion below only if a local mathematical test adds value. If kept, show that it measures the change along a transfer from a larger probability to a smaller one. A short example using $C(\boldsymbol{\pi})=\sum_k\pi_k^2$ would make the connection concrete. MSP and GradNorm need not be differentiable everywhere to be Schur convex.
Next, we’ll discuss how many existing confidence scores used in the literature are in fact Schur convex, and so have the desirable properties discussed in this blogpost. The following table lists a number of examples:
| Name | \(C(\boldsymbol{\pi})\) | Schur-convexity |
|---|---|---|
| Maximum Softmax Probability (MSP) | \(\displaystyle \max_k \pi_k\) | Non-strict |
| Negative Gini | \(\displaystyle \sum\nolimits_k \pi_k^2 - 1\) | Strict |
| Negative Shannon Entropy | \(\displaystyle \sum\nolimits_k \pi_k \log \pi_k\) | Strict |
| Negative Rényi Entropy | \(\displaystyle \frac{1}{\alpha-1} \log \sum\nolimits_k \pi_k^\alpha\) | Strict |
| Self-Certainty | \(\displaystyle -\frac{1}{K}\sum\nolimits_k \log(K\pi_k)\) | Strict |
| Negative Generalised Entropy (GEN) | \(\displaystyle -\sum\nolimits_k [\pi_k(1-\pi_k)]^\gamma\) | Strict |
| GradNorm (softmax component) | \(\displaystyle \sum\nolimits_k \left|\pi_k-\tfrac{1}{K}\right|\) | Non-strict |
Some of these are established and widespread confidence scores in the literature, e.g. MSP, Shannon Entropy, whilst others are recently proposed and widely cited, e.g. GradNorm, Self-Certainty.
What’s interesting is that not a single paper explicitly discusses Schur convexity. It seems like Schur-convexity has been organically selected for by researchers, without them necessarily understanding that it fundamentally determines some important properties of the scores that they propose.
Many confidence scores inherit Schur convexity via the following result: any (monotone transform of a) permutation-invariant convex function is Schur-convex
where $f$ is convex and $h$ is non-decreasing monotone – you can see that all the listed scores in the above table follow this form.
The established theoretical and practical frameworks that researchers derive confidence scores from often contain the properties of permutation invariance and convexity, naturally giving rise to Schur convexity. Classes/outcomes are often treated symmetrically as a practical default giving scores permutation invariance – this means scores don’t require class-specific knowledge, improving portability across tasks and ease of deployment.
Researchers also like to explicitly construct scores as divergences from the uniform distribution (e.g. Gradnorm
Although Schur convexity gives a confidence score a number of desirable properties, it only constrains ranking behaviour between softmax distributions that majorise each other – for other confidence comparisons it is completely permissive. This is illustrated in the following widget, where we use a score parameterised by power $\alpha$ to demonstrate how ranking behaviour can vary whilst Schur convexity is maintained.
The confidence rankings of different $\boldsymbol{\pi}$ vary wildly, shown by changing confidence isocontours.
The relative ranking of $\boldsymbol{\pi}$ that majorise each other stays fixed due to Schur convexity.
The relative ranking of $\boldsymbol{\pi}$ that do not majorise each other can change freely.
In selective prediction, we are often interested in discriminating between two data populations (on the simplex), e.g. correct predictions and misclassifications. How well a score performs at this depends on both the global ranking behaviour (isocontours in the above widget) and the distribution of these populations on the simplex. Thus, for developing effective confidence scores for selective prediction, Schur convexity is not sufficient – it simply provides some desirable properties. We still need experimental evaluation to determine which score has the best ranking behaviour for a given task.
We illustrate this with another widget, with the scores compared remaining Schur convex:
On the left, high $\alpha$ best selects between positive and negative populations.
On the right, low $\alpha$ best selects.
Although Schur convexity gives a confidence score desirable properties, it is permissive of varying global ranking behaviour. To determine ranking performance, we still need empirical evaluations on task-specific distributions over softmax outputs.
In the age of large language models, uncertainty scores over sequences of softmax outputs are becoming increasingly pertinent. It turns out we can also define a sequence-wise notion of Schur convexity, based on row-wise majorisation
For two sequences of probability vectors of length $T$, $\boldsymbol{\Pi}=(\boldsymbol{\pi}^{(1)},\ldots,\boldsymbol{\pi}^{(T)})$ and $\boldsymbol{Q}=(\boldsymbol{q}^{(1)},\ldots,\boldsymbol{q}^{(T)})$, a sequence confidence score $C_{\mathrm{seq}}$ is sequence Schur convex if
i.e. $\boldsymbol{\Pi}$ majorises $\boldsymbol{Q}$ at all sequence positions. Intuitively, a set of (sequences of) Robin Hood transfer(s) across any positions in the sequence should reduce confidence.
One can straightforwardly construct a sequence Schur convex score by aggregating a position-wise score over a sequence,
as long as the aggregation function $A$ is monotonically non-decreasing in each of its arguments, e.g. sum, mean, max, product (if $C\geq 0$). Indeed many existing sequence confidence scores proposed in the literature achieve sequence Schur convexity by doing this, such as negative mean token entropy
Confidence score designers are free to forgo Schur convexity as a property, i.e. Robin Hood transfers mustn’t increase confidence, and there are some examples of this in the literature. Generative perplexity
Here are some more articles you might like to read next: