TL;DR
Fine-tuning vision-language models (VLMs) like CLIP through prompt tuning often disrupts their pre-trained image-text alignment, causing severe over- or under-confidence on unseen classes. Contrast-Aware Calibration (CAC) solves this by using the original, un-tuned CLIP model as a reference anchor to dynamically rescale prediction logits at test time. Because CAC is post-hoc and training-free, it consistently reduces calibration error across both seen and unseen classes, cross-dataset transfers, and domain shifts—without altering classification accuracy.
What Problem Does This Paper Address?
While pre-trained CLIP exhibits strong zero-shot classification and reliable confidence calibration, fine-tuning its prompts (e.g., via CoCoOp, MaPLe, or PromptSRC) on downstream tasks causes the model to overfit to the training categories. When evaluated on unseen classes in open-vocabulary settings, fine-tuned VLMs frequently output miscalibrated probabilities: they may assign high confidence to incorrect predictions (overconfidence) or hesitate on correct ones (underconfidence).
Existing calibration methods are ill-suited for this setup:
- Traditional techniques (such as Temperature Scaling or Histogram Binning) require labeled validation sets and fail to generalize to novel classes.
- Recent VLM-specific methods (such as Distance-Aware Calibration, DAC) rely exclusively on textual feature distances between seen and unseen classes within the same dataset. Consequently, they cannot calibrate training classes, struggle under large distribution shifts, and completely fail in cross-dataset or domain-generalization benchmarks.
Methods
The authors propose Contrast-Aware Calibration (CAC), a multimodal, post-hoc calibration technique that realigns fine-tuned logits with pre-trained image-text associations:
-
Confidence Bias Estimation ($z$): For an input sample, CAC computes the mean $L_1$ distance between the output logits of fine-tuned CLIP ($P$) and original zero-shot CLIP ($\hat{P}$): $$z = \frac{1}{N} \sum_{i=1}^N |P_i - \hat{P}_i|$$ Since zero-shot CLIP maintains robust calibration across broad distributions, large deviations in $z$ signal potential miscalibration.
-
Contrast Scaling Function ($\gamma$): Using the observed negative correlation between calibration error and contrast, $z$ is converted into a calibration scale: $$\gamma = \alpha \cdot e^{-k z}$$ Here, $k$ scales the narrow normalized distances, while $\alpha > 1$ (default 1.10) scales logits up to correct underconfident predictions.
-
Advanced Piecewise Adaptation: To handle extreme cases without manual per-dataset tuning, a parameter-free piecewise function squares $\gamma$ outside the interval $[\lambda_1, \lambda_2]$ (defaults $0.90$ and $1.00$): $$\hat{\gamma} = \begin{cases} \gamma^2 & \text{if } \gamma < \lambda_1 \\ \gamma & \text{if } \lambda_1 \le \gamma \le \lambda_2 \\ \gamma^2 & \text{if } \gamma > \lambda_2 \end{cases}$$
- Calibrated Inference: The fine-tuned logits are scaled by temperature $\tau$ and $\hat{\gamma}$: $L_i^{\text{CAC}} = \hat{\gamma}_i \cdot \tau \cdot \text{logits}_i$. Because this is a monotonic scalar transformation across all classes for each sample, it does not change top-1 predictions or classification accuracy.
Datasets
The authors evaluated CAC across 11 standard downstream benchmarks:
- Generic Object Recognition: ImageNet, Caltech101
- Fine-Grained Classification: Oxford Pets, Food-101, Stanford Cars, Oxford Flowers102, FGVCAircraft
- Remote Sensing, Texture, Action, & Scene: EuroSAT, DTD, UCF101, SUN397
- Domain Generalization: ImageNet tested against ImageNet-A, ImageNet-R, ImageNet-Sketch, and ImageNet-V2.
No new datasets were introduced.
Key Insights and Ideas
- The Mechanism of Miscalibration:
- High inter-class similarity (e.g., FGVCAircraft) makes class boundaries ambiguous, tricking fine-tuned models into predicting a few dominant classes with unjustifiably high confidence.
- High intra-class variation (e.g., Food101) disperses probability mass across several plausible categories, generating lower overall confidence even when the correct class retains the highest logit.
- Contrast as a Calibration Metric: The margin between the ground-truth similarity and the top incorrect class similarity strongly correlates with calibration. High contrast corresponds to low Expected Calibration Error (ECE).
- Zero-Shot CLIP as a Reference: Instead of needing labeled validation data, the frozen zero-shot CLIP backbone provides a universal calibration reference that applies seamlessly across seen classes, unseen classes, and out-of-domain distributions.
Key Results
Evaluating across 5 prompt tuning methods (CoCoOp, KgCoOp, MaPLe, ProGrad, PromptSRC) with a CLIP ViT-B/16 backbone:
- Unseen Classes (Open-Vocabulary): CAC outperforms SOTA VLM calibration (DAC). For example, on ProGrad, DAC increased average ECE to $6.13\%$, while CAC lowered ECE from $5.04\%$ to $4.04\%$. On MaPLe, CAC dropped ECE from $7.80\%$ to $5.35\%$ (vs. DAC's $5.91\%$).
- Seen (Train) Classes: While DAC cannot be applied to train classes, CAC reduced average ECE across all 5 baselines (e.g., dropping KgCoOp's train ECE from $5.87\%$ to $4.10\%$ and MaPLe from $2.80\%$ to $2.50\%$), performing on par with supervised Temperature Scaling without requiring validation data.
- Cross-Dataset & Domain Shifts: On ImageNet domain shift variants (A, R, Sketch, V2), CAC consistently reduced ECE across all methods (e.g., reducing KgCoOp's domain-shift ECE from $4.49\%$ to $2.96\%$).
- Generality & Speed: CAC effectively calibrated parameter-efficient LoRA tuning as well (slashing DTD ECE from $23.40\%$ to $5.56\%$). Calibration overhead was negligible ($<0.001$ seconds per sample on ImageNet).
Limitations and Future Work
- Inference Compute Overhead: CAC requires a forward pass through the original frozen zero-shot CLIP model alongside the fine-tuned model to extract reference logits.
- Model Scope: Experiments were concentrated on CLIP (ResNet-50, ViT-B/16, ViT-B/32). Future work aims to evaluate CAC on broader vision-language architectures and design lightweight approximations of the original model's logits to eliminate the secondary forward pass.
Summary updated