Rethinking Positive Pairs in Contrastive Learning

Jiantao Wu, Shentong Mo, Zhenhua Feng, Sara Atito Ali Ahmed, Josef Kittler, Muhammad Awais · DOI

Introduction

Contrastive Learning (CL) has established itself as a cornerstone of modern visual representation learning. Traditionally, CL relies on a binary classification of image pairs: "positive" pairs consist of different views of the same image or images from the same class, while "negative" pairs are pushed apart in the feature space. This paper argues that this rigid dichotomy is overly restrictive and leads to dimensional collapse, where models ignore feature diversity and concentrate information into a few dominant dimensions, ultimately hindering generalization.

The SimLAP Framework

The authors introduce SimLAP (Universal Contrastive Learning) and its variant, Hydra, to challenge the assumption that positive pairs must be semantically similar. The core innovation is a Feature Filter mechanism that allows any two samples in a batch to function as a positive pair.

Methodology

  1. Arbitrary Positive Pairs: SimLAP permits pairing disparate objects (e.g., a snake and a lamp).
  2. Subspace Learning: Instead of forcing global identity, a small MLP (the Feature Filter) generates a "gate vector" based on class labels. This gate selectively activates specific dimensions of the feature representation.
  3. Gating Mechanism: This creates a unique subspace where disparate objects share commonalities—such as curved shapes or textures—allowing the model to optimize these shared features without collapsing the entire representation.
  4. Universal Contrastive Loss: The standard InfoNCE loss is applied within these dynamically generated, label-guided subspaces.
Cosine similarity distributions for disparate positive pairs (snake and lamp) using SimCLR Hydra.

Key Insights

Commonalities in the Inscrutable

A significant finding is that even for pairs humans might find "inscrutable," such as a garter snake and a table lamp, pre-trained models already possess dimensions where these objects are similar. SimCLR Hydra explicitly mines these hidden connections. As shown in the similarity distributions, the model successfully identifies high-similarity subspaces for disparate pairs that would otherwise be treated as negatives in standard CL.

Preventing Dimensional Collapse

By forcing the model to utilize its full capacity to find commonalities across a massive variety of arbitrary pairs, SimLAP effectively mitigates dimensional collapse. In experiments on the IN1P dataset (a focused dog-breed subset), standard SimCLR performance declined after 3,000 epochs due to collapse, whereas SimLAP continued to improve even after 20,000 epochs.

Experimental Results

  • Transfer Learning: SimLAP-MoCo achieved an average accuracy of 94.0% across six classification tasks (including CIFAR and Oxford Pets), outperforming or tying established baselines like MoCoV3.
  • ViT Scaling: The Hydra variant showed remarkable gains for Vision Transformers. For ViT-tiny, Hydra reached 82.56% on CIFAR-10, significantly higher than the 76.94% achieved by supervised training.
  • Robustness to Semantic Distance: In the IN25 experiments, which test models on increasing semantic distance between pairs, SimLAP remained stable while Supervised Contrastive Learning (SupCon) performance plummeted.

Conclusion and Future Work

SimLAP demonstrates that "positive" is a relative term. By allowing the model to find shared subspaces between disparate objects, we can learn more robust and transferable features. While current versions rely on class labels or pseudo-labels, future work aims to scale this approach using auxiliary information like text captions to identify shared subspaces without categorical constraints.

Summary updated

Abstract

The training methods in AI do involve semantically distinct pairs of samples. However, their role typically is to enhance the between class separability. The actual notion of similarity is normally learned from semantically identical pairs. This paper presents SimLAP: a simple framework for learning visual representation from arbitrary pairs. SimLAP explores the possibility of learning similarity from semantically distinct sample pairs. The approach is motivated by the observation that for any pair of classes there exists a subspace in which semantically distinct samples exhibit similarity. This phenomenon can be exploited for a novel method of learning, which optimises the similarity of an arbitrary pair of samples, while simultaneously learning the enabling subspace. The feasibility of the approach will be demonstrated experimentally and its merits discussed.
BibTeX
@misc{wu2024rethinking,
  author = {Jiantao Wu and Shentong Mo and Zhenhua Feng and Sara Atito Ali Ahmed and Josef Kittler and Muhammad Awais},
  title = {{Rethinking Positive Pairs in Contrastive Learning}},
  year = {2024},
  eprint = {2410.18200},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2410.18200},
}
Figure