NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Variational Supervised Contrastive Learning

Ziwen Wang, Jiajun Fan, Thao Nguyen, Heng Ji, Ge Liu

Introduction

Contrastive learning has emerged as a cornerstone of modern visual representation learning, powering state-of-the-art encoders through the principle of "pulling" similar instances together and "pushing" dissimilar ones apart. However, most existing methods, such as Supervised Contrastive Learning (SupCon), rely on heuristic energy functions that lack a rigorous statistical foundation. This reliance leads to significant computational bottlenecks, including a quadratic complexity relative to batch size ($O(B^2)$) and a requirement for massive batches (often exceeding 4096) to find sufficient negative samples.

In this work, we introduce Variational Supervised Contrastive Learning (VarCon). By reformulating supervised contrastive learning through the lens of variational inference, VarCon bridges the gap between contrastive objectives and generative modeling. This approach provides a principled probabilistic framework that significantly improves computational efficiency, convergence speed, and model robustness.

The VarCon Framework

The core of VarCon is the derivation of a variational bound for class-conditional likelihood. Rather than relying on exhaustive pairwise comparisons, the VarCon loss is derived from the Evidence Lower Bound (ELBO), consisting of two synergistic components:

  1. Kullback–Leibler (KL) Divergence: This term aligns an auxiliary posterior distribution with the model’s class posterior, ensuring the latent space is well-regulated.
  2. Negative Log-Likelihood (NLL): This term focuses on the ground-truth label, ensuring the model maintains high discriminative accuracy.

By treating the class label as a latent variable, VarCon moves away from the "push-pull" heuristic toward a framework that maximizes the likelihood of the data given its semantic category.

Key Innovations

Class-Level Centroids

Traditional contrastive methods suffer from high complexity because every image in a batch must be compared to every other image. VarCon addresses this by computing dynamic class centroids on the fly. Each embedding interacts only with class-level representations, reducing complexity to nearly linear ($O(B \cdot C_d)$). This shift makes the model significantly less "batch-hungry," allowing it to achieve peak performance with much smaller batch sizes than its predecessors.

Confidence-Adaptive Temperature ($\tau_2$)

A pivotal feature of VarCon is its self-regulating supervision mechanism. The model employs a confidence-adaptive temperature to adjust the "sharpness" of the target distribution based on its own current prediction confidence:

  • Low Confidence (Difficult Samples): The temperature decreases, creating a sharper target that provides a stronger gradient signal to guide the model.
  • High Confidence (Easy Samples): The temperature increases, relaxing the constraints to prevent overfitting and encourage better generalization.

This mechanism acts as an automated curriculum, allowing the model to prioritize learning from challenging samples without manual hyperparameter tuning.

Experimental Results

VarCon was evaluated across a rigorous suite of benchmarks, including ImageNet-1K, ImageNet-C (robustness), and various transfer learning datasets.

State-of-the-Art Performance

Using a standard ResNet-50 backbone, VarCon achieved 79.36% Top-1 accuracy on ImageNet-1K. This outperforms SupCon (78.72%) as well as popular self-supervised methods like SimCLR and BYOL. Notably, VarCon reaches this performance in only 200 epochs, whereas SupCon typically requires 350 epochs to converge, representing a significant gain in training efficiency.

Robustness and Data Efficiency

  • Few-Shot Learning: In scenarios with limited data (100 samples per class), VarCon outperformed SupCon by 1.24%, demonstrating that its variational framework captures more essential features when supervision is scarce.
  • Corruption Robustness: On ImageNet-C, VarCon maintained a 1.2% performance lead over SupCon across various levels of image corruption (e.g., noise, blur). This suggests that explicit modeling of feature uncertainty leads to more resilient representations.
  • Emergent Semantic Structure: VarCon naturally learns inter-class relationships. For instance, feline species are clustered closer to one another than to unrelated categories like musical instruments, a property usually associated with multi-modal models like CLIP.

Conclusion and Future Work

VarCon provides a robust, efficient, and mathematically grounded alternative to heuristic contrastive learning. By replacing exhaustive pairwise comparisons with class-level centroids and introducing an adaptive temperature mechanism, it sets a new standard for supervised representation learning.

While VarCon currently relies on labeled data, future work could extend this framework to self-supervised settings using variational latent pseudo-labels. Additionally, exploring memory banks for datasets with extremely high class counts could further enhance the scalability of the centroid-based approach.

Summary updated

BibTeX
@inproceedings{wang2025variational,
  author = {Ziwen Wang and Jiajun Fan and Thao Nguyen and Heng Ji and Ge Liu},
  title = {{Variational Supervised Contrastive Learning}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2025},
  url = {https://openreview.net/forum?id=uOOlHOq500},
}
Figure