---
title: "Discussion on \"Fixing the confidence: temperature scaling\" | Hashnode"
description: "Discussion on \"Fixing the confidence: temperature scaling\". Fitting one number per step on 770 labelled answers to make an LLM's confidence more honest"
url: "https://hashnode.com/posts/temperature-scaling/6ae38ef0c710023229d1348c"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Fixing the confidence: temperature scaling](https://liminma.hashnode.dev/temperature-scaling?utm_source=hashnode&utm_medium=feed)

Fitting one number per step on 770 labelled answers to make an LLM's confidence more honest

Oct 29 · 12 min read · liminma.hashnode.dev  
Updated Nov 18  
Read the article

-   [#llm](https://hashnode.com/tag/llm)
-   [#python](https://hashnode.com/tag/python)
-   [#machine-learning](https://hashnode.com/tag/machine-learning)
-   [#calibration](https://hashnode.com/tag/calibration)

## Written by

[Limin Ma](https://hashnode.com/@liminma)

@liminma · Toronto, Canada

  
[View profile](https://hashnode.com/@liminma)

## Responses 7

Markdown supported · ⌘↵ to post

[Kartik N V J K](https://hashnode.com/@kartik-nvj)

[Oct 30](https://hashnode.com/posts/temperature-scaling/6ae38ef0c710023229d1348c/comment/6ae49d68524575b23b7d86de)

Since a prompt change means a refit and the calibration rerun takes about 3 minutes, I'd store each fitted T with the prompt version it came from and refuse to load one fitted on a different version. The intent step landing at 1.138 on BANKING77 and 0.619 on CLINC150 shows how far apart two fits can sit.

[Limin Ma](https://hashnode.com/@liminma)

[Nov 12](https://hashnode.com/posts/temperature-scaling/6ae38ef0c710023229d1348c/comment/6ae49d68524575b23b7d86de#reply-6af63b670a526213ffc01629)

Thanks, versioning T like that is a good safeguard. The thresholds in [post 8](https://liminma.hashnode.dev/from-confidence-to-action) are searched on the scaled confidence, so they should be versioned along with it.

[Ahmet Özel](https://hashnode.com/@ahmetozel)

[Oct 30](https://hashnode.com/posts/temperature-scaling/6ae38ef0c710023229d1348c/comment/6ae4313a31804cf4d6b13b75)

The EPS floor for labels missing from top\_logprobs is another useful sensitivity check. Temperature scaling is exactly a logit rescaling for a complete probability distribution, but assigning 1e-6 to unreported options introduces an approximation before the fit.

I would report how often the gold label was unreported at each step and repeat the fit with a few plausible floors. If T changes substantially, it is partly compensating for probability truncation rather than only model calibration. That would qualify the result without changing any of the selected answers.

[Limin Ma](https://hashnode.com/@liminma)

[Nov 12](https://hashnode.com/posts/temperature-scaling/6ae38ef0c710023229d1348c/comment/6ae4313a31804cf4d6b13b75#reply-6af644290c601f44a67f6d59)

Thanks for the careful read. Your check is worth running on any new dataset. When the right label is missing, the floor becomes its probability and can pull T up. I ran it on the post's two datasets. The good news is that the right label was never missing, and T doesn't change for floors from 1e-5 to 1e-10. Thanks again for spelling out the check so clearly.

[Ahmet Özel](https://hashnode.com/@ahmetozel)

[Nov 16](https://hashnode.com/posts/temperature-scaling/6ae38ef0c710023229d1348c/comment/6ae4313a31804cf4d6b13b75#reply-6afb7755ba8669b3bad282b4)

The zero missing-gold-label count and unchanged T across those floors answer the sensitivity question for these datasets. I would keep both observations beside the fitted temperature so the result stays qualified when a new label set is introduced.

A synthetic fixture with the gold label deliberately outside top\_logprobs would still be useful for checking that the monitoring notices the approximation. It can stay separate from the reported dataset result.

[AI Developer](https://hashnode.com/@lycore)

[Oct 30](https://hashnode.com/posts/temperature-scaling/6ae38ef0c710023229d1348c/comment/6ae3ed4a499df2d19b1cb141)

The NLL-vs-ECE argument is the strongest part: ECE jumping at bin edges makes it a bad search target, and the q = 0.92 table shows why NLL lands on the true rate. One thing I'd be curious about is the step-wise fit on only 729 right-group answers for the intent temperature. Since the intent step never sees wrong-group cases at fit time but is scaled on them at test time, would a held-out check on wrong-group answers alone show whether T=1.14 over- or under-corrects there? Also, since the middle bins stay >0.1 off, a two-parameter option like Platt/vector scaling or isotonic regression on the final product might be worth comparing, with a bootstrap interval on the test ECE to see whether 0.041→0.030 is outside the noise.

[Limin Ma](https://hashnode.com/@liminma)

[Nov 13](https://hashnode.com/posts/temperature-scaling/6ae38ef0c710023229d1348c/comment/6ae3ed4a499df2d19b1cb141#reply-6af66aee1979c81f8c5a1878)

Thanks for the questions. Fitting the intent temperature on just the right-group answers is deliberate. It only needs to be honest when the group is right because that's what P(intent | group) measures. For wrong-group answers the right intent isn't among the options at all, so keeping their confidence low is the group step's job.

Isotonic regression on the final confidence is in [post 6](https://liminma.hashnode.dev/isotonic-regression) (test ECE 0.011), but the series doesn't try Platt or vector scaling.

I ran the bootstrap you suggested to see whether the drop from 0.041 to 0.030 is outside the noise. The answer was less clear than I expected. With the post's T held fixed, the scaled ECE was lower in every resample of the test set. But when the calibration set is resampled too and T refitted each time, it's lower in only 88% of resamples. So the improvement is likely to hold but isn't certain, and most of the noise comes from fitting T on 770 answers.
