Contrastive Linearized Laplace: Loss Geometry, Valid Repairs, and Reliable Cores
Organizations: University of Granada · Aalborg University
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.
Figures & tables
| Output-Hessian repair | Posterior change | |||||||
| Dataset | Loss | Repair | Neg. rate | ACC | ECE | NLL | ||
| EMNIST | Bernoulli distance | Radial | ||||||
| Bernoulli distance | Spectral | |||||||
| Margin | Radial | |||||||
| Margin | Spectral | |||||||
| CIFAR-100 | Bernoulli distance | Radial | ||||||
| CIFAR-100 | EMNIST | SICAP | ||||||||
| Encoder | Method | Acc. | NLL | ECE | Acc. | NLL | ECE | Acc. | NLL | ECE |
| CLIP | MAP | |||||||||
| LLA Sampled | ||||||||||
| Gaussian LLA | ||||||||||
| SimCLR | MAP | |||||||||
| / | LLA Sampled | |||||||||
Appendix figures & tables13 assets
Supplementary material from the paper’s appendix.
Appendix
| Mode | Construction | What it does | What it does not do |
| Raw GGN | Use directly | Retains the exact output Hessian of the linearized loss | Does not guarantee a PSD precision for distance or margin negatives |
| Spectral repair | Symmetrize, eigendecompose, and set negative eigenvalues to zero | Projects each output block onto the PSD cone, regardless of the loss | Removes negative curvature; does not turn it into positive evidence |
| Radial-only repair | Split distance-loss blocks into radial and tangential components; retain radial curvature and damp the tangential component | Gives a structured PSD approximation for distance losses; agrees with spectral repair on active negative margin blocks up to damping | Is not the PSD projection and can remove valid positive tangential curvature from already-PSD positive-pair blocks |
| Damping/jitter | Add isotropic precision after accumulation | Stabilizes inversion and can make the final matrix strictly positive definite | Does not identify or repair the loss-level curvature pathology |
| Empirical Fisher | Replace by | Gives a PSD block by construction | Does not repair the Hessian and can reduce relational curvature to rank one per unit |
| Setting | Frozen encoder | LLA target | Embedding used downstream |
| CLIP image experiments and ablations | Pretrained CLIP ViT-B/32 visual tower [ Radford et al., 2021 ] , including its learned visual projection. Post-projection normalization is not applied before the LLA target. | CLIP visual projection, a linear map from hidden width 768 to projection dimension 512. | 512-dimensional CLIP visual-projection embedding. |
| SimCLR image experiments | Pretrained ImageNet SimCLRv2 ResNet-50 , SK0 checkpoint [ Chen et al., 2020b ] . Inputs are resized to , and the converted ResNet projection output is retained as the LLA target. | Final ResNet layer. | Output of the final linear layer. |
| SemiBin2 genome experiments | Pretrained SemiBin2 global-environment encoder [ Pan et al., 2023 ] , evaluated on 136-dimensional k-mer features. | Last linear layer of the SemiBin2 encoder. | SemiBin2 contig embedding. |
| SICAPv2/CONCH pathology | Pretrained CONCH-v1.5 vision encoder [ Lu et al., 2024 ] . The LLA implementation exposes the final attention-pooling output map before the contrastive layer normalization. | Final linear output map of the CONCH attention pool. | CONCH patch embedding before the final normalization used by the adapter. |
| Method | F1 | F1 | F1 | F1 | F1 |
| Marine 5 | |||||
| MAP | |||||
| Consensus, EF | |||||
| Consensus, GGN/radial | |||||
| Consensus, GGN/spectral | |||||
| Marine 6 | |||||
| Selector | 90% | 70% | 50% | 30% | 10% |
| Marine 5 | |||||
| Consensus + rel. (EF) | |||||
| Consensus + rel. (GGN/radial) | |||||
| Consensus + rel. (GGN/spectral) | |||||
| Consensus + random (EF) | |||||
| Consensus + random (GGN/radial) | |||||
Contrastive Learning
Contrastive learning trains representations by bringing related examples together and separating unrelated ones for recognition, retrieval, and transfer.
See all 318 papers