Contrastive Learning with Synthetic Positives

Dewen Zeng, Yawen Wu, Xinrong Hu, Xiaowei Xu, Yiyu Shi

Abstract

Self-supervised contrastive learning typically relies on hand-crafted data augmentations to create positive pairs. However, these "easy" positives often fail to challenge the model, limiting the robustness of the learned representations. We present Contrastive Learning with Synthetic Positives (CLSP), a framework that leverages unconditional diffusion models to generate "hard" synthetic positives. By interpolating semantic features during the diffusion sampling process, CLSP produces images that retain the core object of an anchor image while placing it in entirely new contexts. Our method achieves state-of-the-art performance on CIFAR and ImageNet benchmarks, even outperforming supervised methods in certain settings.

Introduction

In self-supervised learning (SSL), contrastive learning has emerged as a dominant paradigm. The core idea is to learn representations by pulling "positive" views of the same image together in embedding space while pushing "negative" views (different images) apart.

Despite its success, the effectiveness of contrastive learning is often bottlenecked by the quality of positive pairs. Standard methods rely on basic augmentations like cropping or color jittering. These produce "easy" positives that share significant low-level pixel information, allowing models to take shortcuts rather than learning deep semantic features. The field lacks a reliable way to generate "hard" positives: images that share the same semantic meaning but differ significantly in background, lighting, or context.

Methodology

CLSP addresses this gap by using a pre-trained unconditional diffusion model as a generative engine for hard positives. The process involves three main components: semantic feature interpolation, hard positive generation, and a modified contrastive loss.

The CLSP framework (a) uses a diffusion model to generate synthetic views $x_i^3$. The interpolation process (d) mixes anchor features $h_{anchor}$ with noise $h$ to create diverse hard positives.

Semantic Feature Interpolation

The core innovation of CLSP lies in the diffusion sampling process. Diffusion models naturally capture semantic information in their intermediate layers. To generate a synthetic positive, the model takes the intermediate features of an anchor image ($h_{anchor}$) and interpolates them with random noise features ($h$) using a weight $w$: $$h = w \cdot h + (1 - w) \cdot h_{anchor}$$

By setting $w$ to a low value (typically 0.1), the model generates an image that preserves the semantic object of the anchor but generates a completely randomized background. This forces the encoder to focus on the object itself rather than environmental cues.

Training Objective

The training objective integrates these synthetic views into a standard contrastive framework. For every anchor image $x_i$, the model processes two standard augmented views ($x_i^1, x_i^2$) and one synthetic hard positive ($x_i^3$). The loss function minimizes the distance between the anchor's embedding and the synthetic positive's embedding, complementing the standard InfoNCE loss.

Experimental Results

We evaluated CLSP across several standard benchmarks, including CIFAR10, CIFAR100, and ImageNet100. The results demonstrate that synthetic positives provide a superior learning signal compared to traditional augmentations.

Linear and kNN evaluation results on CIFAR10 and CIFAR100. CLSP variants consistently outperform existing state-of-the-art self-supervised methods.

On CIFAR10, CLSP-SimCLR achieved a linear accuracy of 94.37%, notably outperforming SupCon (93.82%), which utilizes ground-truth labels during pre-training. On ImageNet100, the method achieved a Top-1 accuracy of 79.62%, a nearly 4% improvement over the original SimCLR baseline. Furthermore, transfer learning experiments across eight downstream datasets (e.g., Oxford-IIIT Pets, Caltech101) showed that CLSP features are highly generalizable, outperforming existing SSL frameworks in 75% of the tested cases.

Key Insights

  • The "Hardness" Sweet Spot: Ablation studies revealed that an interpolation weight of $w=0.1$ is optimal. Higher weights risk losing the original object (creating false positives), while lower weights produce images too similar to the anchor to be useful.
  • Diversity Over Quantity: Simply adding more standard augmented views does not match the performance gains of CLSP. The semantic diversity provided by the generative model is the key driver of performance.
  • Decoupling Semantics: The success of CLSP confirms that unconditional diffusion models effectively decouple object semantics from background noise in their intermediate layers, making them powerful tools for data augmentation.

Conclusion and Limitations

While CLSP significantly advances the state-of-the-art in contrastive learning, it introduces certain trade-offs. The primary limitation is the computational overhead associated with diffusion sampling, which increases training time and storage requirements for pre-generated synthetic sets. Future work will focus on scaling CLSP to larger datasets like ImageNet1k and exploring its utility in more complex tasks such as object detection and segmentation.

Summary updated

BibTeX
@inproceedings{zeng2024contrastive,
  author = {Dewen Zeng and Yawen Wu and Xinrong Hu and Xiaowei Xu and Yiyu Shi},
  title = {{Contrastive Learning with Synthetic Positives}},
  booktitle = {European Conference on Computer Vision},
  year = {2024},
  doi = {10.1007/978-3-031-72913-3\_24},
}
Figure