arXiv:2609.17386cs.LGSep 2026

Manuscript Offprint

arXiv:2609.17386

Bridging the Confidence Gap: Temperature Scaling for Calibrating Test-Time Prompt Tuning

Yuwei Liang, Jian Liang, Dapeng Hu, Yinuo Xu, Ran He

Abstract

Test-time prompt tuning (TPT) enables adaptation on a single test instance, achieving improved accuracy but often sacrificing calibration performance. Most existing calibration methods introduce additional regularization terms to promote dispersion across text embeddings and reduce calibration error, yet these methods often suffer from a drop in accuracy. Motivated by the well-calibrated nature of zero-shot predictions, we propose CoTS, a simple yet effective post-hoc calibration method that preserves accuracy. Specifically, CoTS applies temperature scaling to minimize the confidence gap between adapted and zero-shot predictions. To fully exploit the potential of multiple augmentations during adaptation, we introduce a weak-strong ensemble strategy that further boosts accuracy. We then apply CoTS to this ensemble, termed E-CoTS, to maintain its well-calibrated property. Extensive experiments on diverse datasets and backbones show that our approaches effectively mitigate miscalibration without compromising primary accuracy. For instance, E-CoTS reduces the average expected calibration error of TPT from 11.90% to 5.38% on ImageNet variants, while even increasing accuracy from 60.74% to 62.95%. Moreover, when integrated with existing calibration methods, E-CoTS usually enhances both accuracy and calibration simultaneously. Code is available at https://github.com/yuweiliang911/CoTS.

1 Introduction

Vision-language models (VLMs), such as CLIP [53] and ALIGN [26], are pre-trained to align visual and textual features in a shared embedding space, enabling strong zero-shot performance. To efficiently adapt VLMs to diverse downstream tasks, pioneering works [77, 76] replace hand-crafted prompts with learnable continuous vectors optimized on training data. For unsupervised settings, earlier methods typically require access to multiple samples from either the entire test set [24, 62, 38] or streaming data [42, 69]. In contrast, episodic test-time adaptation (TTA) methods [57, 12, 56] perform prompt tuning using a single test instance, which is more challenging and has received increasing attention. A classic approach, test-time prompt tuning (TPT) [57] adapts CLIP during inference by minimizing the marginal entropy over multiple augmented predictions.

Although TPT [57] improves accuracy over zero-shot CLIP, it is prone to generating overconfident predictions, raising reliability concerns for VLMs in safety-critical applications [29, 50, 31, 58]. A pioneering work, C-TPT [72], shows that well-calibrated prompts tend to produce text embeddings with broader class-wise dispersion and thus introduces a distance-dispersion regularization term to push prompt embeddings away from the class centroid. Building on this insight, subsequent works [55, 1, 13] further propose various regularization terms to encourage angular separation.

∗^{*}To whom correspondence should be addressed.

Figure

Figure 1: Average accuracy (%) and expected calibration error (ECE, %) of zero-shot CLIP, TPT, and various calibration methods on fine-grained datasets and ImageNet variants using ViT-B/16.

between textual features. Although these regularization-based methods achieve lower expected calibration error (ECE) than the original TPT [57], we find they suffer from a noticeable accuracy drop, as shown in Fig. 1. We argue that reduced ECE is less meaningful when it comes at the expense of accuracy, especially as the underlying calibration mechanisms remain poorly interpretable.

Alternatively, SaLS [46] presents the only post-hoc calibration method that preserves accuracy by adjusting logits to remain within the zero-shot range after inference, but its calibration improvement remains limited. It is well known that CLIP [53] is generally well-calibrated [44, 15], with a relatively small gap between accuracy and confidence. Taking a closer look at the accuracy of CLIP and TPT, we find that prompt tuning using a single test instance does not substantially alter accuracy, suggesting that the increased miscalibration stems from a shift in confidence. To validate this hypothesis, we conduct a pilot study that assigns zero-shot confidence to TPT predictions. We find that this straightforward replacement significantly reduces calibration error, surpassing [46, 72] while falling short of [55, 13]. However, this naive confidence replacement introduces a critical inconsistency: the predicted class comes from TPT's softmax distribution, whereas the confidence comes from the zero-shot distribution, potentially leading to unstable decisions.

Based on these insights, we propose Confidence-based Temperature Scaling (CoTS), a simple yet effective calibration method that follows the classic idea of temperature scaling [16]. Specifically, CoTS optimizes a learnable temperature parameter to align TPT-predicted confidence with zero-shot confidence, thereby mitigating calibration error while retaining accuracy. Furthermore, inspired by prior work [10, 6] that ensembles augmented views to enhance prediction robustness, we introduce a new weak-strong ensemble strategy to further boost accuracy. In this strategy, we retain the weakly augmented view and balance its predictions with those from selected strong augmentations via a weighted trade-off. Empirically, we find that this ensemble strategy indeed boosts accuracy but may disrupt the model's well-calibrated properties. To mitigate this issue, we further integrate the ensemble strategy with CoTS, termed E-CoTS, achieving a better trade-off between accuracy and calibration. We validate the proposed methods on both fine-grained datasets and ImageNet variants.

To summarize, our contributions are as follows:

• We propose CoTS, a novel post-hoc confidence-based calibration method that uses temperature scaling to align TPT-predicted confidence with zero-shot confidence.

• We devise a simple weak-strong ensemble strategy integrated with CoTS, dubbed E-CoTS, that achieves reliable classification against TPT with superior accuracy and lower calibration error.

• Experiments across diverse datasets and backbones show that our methods reduce ECE to near the well-calibrated zero-shot baseline, while maintaining or even improving the adapted model's classification accuracy. Both CoTS and E-CoTS are plug-and-play and usually complement existing regularization-based calibration approaches, improving either accuracy or ECE.

References (71)