Contrastive learning uncertainty better predicts reliable decisions

Contrastive Linearized Laplace: Loss Geometry, Valid Repairs, and Reliable Cores

Machine Learning

Summary

Contrastive learning helps computers learn useful features from data, but it doesn’t tell us how confident these features are. The authors show that a common method to add uncertainty, Linearized Laplace approximation, doesn’t reliably indicate stability for tasks like grouping or finding similar items. They propose a way to fix this without retraining the model, improving uncertainty estimates that relate to real decisions. This approach helps in tasks like sorting genetic data and recognizing images, giving better confidence in computer predictions.

What this means in practice

  • For bioinformatics teams: Improve metagenomic binning by identifying more reliable genetic clusters with calibrated uncertainty from embeddings.
  • For medical imaging engineers: Enhance confidence calibration in automated histopathology image classifiers to support more reliable clinical diagnostics.

Authors

Francisco J. Sáez-Maldonado, Luis A. Ortega, Andrés R. Masegosa, Thomas D. Nielsen

Abstract

While contrastive learning is widely used to learn deterministic representations, it does not inherently provide estimates of uncertainty. Post-hoc uncertainty estimation methods, such as the Linearized Laplace approximation (LLA), offer a way to quantify uncertainty without retraining the encoder. However, we show that directly using the LLA induced distribution over the contrastive embedding does not yield reliable pointwise uncertainty estimates for downstream tasks: embedding variance alone does not reflect whether decisions such as nearest-neighbor retrieval or cluster assignment are stable. To address this limitation, we develop a post-hoc framework based on LLA that propagates encoder uncertainty through the downstream task. We characterize the curvature of contrastive objectives and introduce positive-semidefinite repairs where needed to obtain valid local Gaussian approximations without retraining the encoder. We test the proposed approach in metagenomic binning and image classification tasks. For metagenomic binning, posterior coassignment probabilities support consensus partitions and the selection of reliable cores, leading to improvements over existing baselines. Additional image classification experiments show calibration improvements on standard benchmarks and real histopathology datasets.