Enhancing Contrastive Learning with Variable Similarity

Haowen Cui, Shuo Chen, Jun Li, Jian YangNeurIPS 2025

TL;DR

Standard contrastive learning assumes all augmented versions of an image are equally "similar," but heavy transformations can actually change an image's underlying meaning. This paper introduces Contrastive Learning with Variable Similarity (CLVS), a method that dynamically adjusts similarity targets based on the extent of data augmentation. By acknowledging that strongly augmented views are less similar to the original than weakly augmented ones, CLVS leads to significantly more robust feature representations and achieves state-of-the-art performance on ImageNet benchmarks.

What Problem Does This Paper Address?

In the realm of self-supervised learning (SSL), contrastive learning has become a dominant force. The core idea relies on "augmentation invariance": if you take an image of a dog and crop it, flip it, or change its colors, the model should still recognize it as the same dog. We treat these different "views" as positive pairs and train the model to maximize their similarity in a feature space.

However, the authors point out a fundamental flaw in this binary assumption. Not all augmentations are created equal. If you crop an image so aggressively that you only see a patch of grass in the background, forcing the model to treat that patch as "identical" to the original dog image is actually counterproductive.

Comparison of Fixed vs. Variable Similarity

This "semantic discrepancy" creates misguided learning objectives. Conventional methods use a fixed similarity target, forcing the model to ignore real differences in content caused by extreme transformations.

Methods: Introducing CLVS

To resolve this, the authors propose Contrastive Learning with Variable Similarity (CLVS). Instead of a binary "similar or dissimilar" approach, CLVS treats similarity as a continuous spectrum.

Architecture of Contrastive Learning with Variable Similarity (CLVS)

The framework introduces several key components to dynamically adjust learning targets:

  1. Augmentation-Aware Module ($\phi$): The system includes a small Multi-Layer Perceptron (MLP) that learns to perceive the "extent" of augmentation. It analyzes the feature embeddings and predicts the difference in augmentation parameters (like crop size or color jitter intensity) between two views.
  2. Variable Similarity Estimation: Based on the predicted augmentation extent, the model calculates a "target" similarity. A lightly cropped image might have a high target similarity, while a heavily distorted one receives a lower target score.
  3. Alignment and Ranking Losses:
    • Alignment Loss ($L_{ali}$): This forces the actual cosine similarity between image features to match the predicted variable similarity.
  4. Relative Similarity Constraint ($L_{re}$): This ensures a logical hierarchy—a weakly augmented view must always be more similar to the original than a strongly augmented one.
  5. Minimum Similarity Strategy: To handle multiple types of augmentation simultaneously (e.g., cropping and color shifting), the model identifies which transformation caused the most significant semantic shift and uses that as the primary guide for adjusting similarity.

Key Insights and Theoretical Grounding

  • Moving Beyond Invariance: The critical insight of CLVS is realizing that strict invariance is a blunt instrument. By allowing for equivariance—where the model's internal representation changes in a predictable way relative to the input transformation—the model learns a much more nuanced understanding of the data.
  • Theoretical Tightening: The authors provide a mathematical proof showing that variable similarity reduces the statistical variance of similarity scores. This effectively "shrinks" the Generalization Error Bound, meaning the model is theoretically more likely to perform well on unseen data.
  • Efficiency: Despite adding an extra module, CLVS only increases training time by about 5%. It acts as a "plug-and-play" technique that can be added to existing popular frameworks (like MoCo or SimSiam) to give them an instant performance boost.

Datasets and Key Results

The researchers evaluated CLVS across a wide array of standard computer vision benchmarks, including pretraining on ImageNet-100 and ImageNet-1k, transfer learning on CIFAR and Oxford Pets, and downstream tasks like object detection on MS COCO.

CLVS consistently outperformed state-of-the-art self-supervised methods:

  • ImageNet Accuracy: Achieved a 2.1% gain on ImageNet-100 and a 1.4% gain on ImageNet-1k compared to previous top-tier methods.
  • Framework Boosting: When added to the MoCo baseline, it improved Top-1 accuracy on ImageNet-100 by a massive 6.1%.
  • Robustness in Retrieval: Qualitative results show that CLVS-trained models are better at retrieving "nearest neighbors" that share fine-grained attributes (like the specific color or perspective of a car) rather than just generic category matches.
  • Few-Shot Excellence: On fine-grained datasets like CUB200, CLVS showed superior ability to discern subtle differences, outperforming competitors in 5-way 1-shot and 5-shot tasks.

Limitations and Future Work

The primary limitation acknowledged by the authors is that CLVS currently only applies to positive pairs (different views of the same image). It does not yet incorporate negative samples (different images) into the variable similarity mechanism. Future work aims to extend this "variable similarity" logic to the entire contrastive framework, potentially adjusting how "dissimilar" the model thinks two different images are based on their intrinsic semantic distance.

Summary updated

BibTeX
@inproceedings{cui2025enhancing,
  author = {Haowen Cui and Shuo Chen and Jun Li and Jian Yang},
  title = {{Enhancing Contrastive Learning with Variable Similarity}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2025},
  url = {https://openreview.net/forum?id=oUf6lhK52B},
}
Figure