Investigating the Role of Negatives in Contrastive Representation Learning

Jordan T. Ash, Surbhi Goel, Akshay Krishnamurthy, Dipendra Misra

Abstract

Contrastive representation learning relies on distinguishing a positive sample from a set of negative samples. While common practice suggests that increasing the number of negatives ($k$) always improves performance, this paper identifies a fundamental "collision-coverage trade-off." We demonstrate theoretically and empirically that the optimal $k$ scales with the number of latent concepts $N$ in the dataset. Our findings explain why performance often plateaus or decays in NLP tasks as $k$ increases, while also highlighting the unique robustness of Computer Vision models to these effects due to data augmentation.

Introduction

Contrastive learning, exemplified by frameworks like SimCLR and ELECTRA, has achieved state-of-the-art results in unsupervised representation learning. Central to these methods is Noise Contrastive Estimation (NCE), where a model learns by contrasting a positive pair against $k$ negative samples. Despite its success, the relationship between $k$ and downstream performance is poorly understood. Practitioners often conflate $k$ with batch size, and existing theories offer contradictory predictions. This work provides a unified framework to understand the "sweet spot" for the number of negatives.

Theoretical Framework: The Collision-Coverage Trade-off

We identify two competing forces that determine the effectiveness of negative sampling:

  1. Coverage: A model needs enough negatives to adequately cover the diversity of the data distribution. Insufficient $k$ prevents the model from learning fine-grained semantic distinctions.
  2. Collision: As $k$ increases, the probability of sampling a "false negative"—a sample that is semantically identical to the positive—rises. These collisions provide a noisy, confusing signal that can degrade the quality of the learned representation.

By refining the error transfer theorem from Saunshi et al. (2019), we show that the downstream classification error bound is sensitive to both the number of latent classes $N$ and the number of negatives $k$.

Theoretical bounds for the pre-multiplier as a function of the number of negatives $k$. The different curves represent various scaling assumptions, showing how the theoretical error bound reaches a minimum at an optimal $k$.

Empirical Methodology

To validate our theory, we developed a protocol to decouple $k$ from the training batch size $B$. By sampling $k$ negatives from a large fixed pool, we could vary the contrastive signal independently of optimization stability.

  • NLP Experiments: Using the Wiki-3029 dataset, we controlled the number of latent concepts $N$ by varying the number of Wikipedia articles included.
  • Vision Experiments: We used SVHN and CIFAR-10 to test the theory in the presence of heavy data augmentation.
  • Collision Analysis: We performed "no-collision" runs using ground-truth labels to isolate the impact of false negatives on performance decay.

Key Insights and Results

In NLP tasks, we observed a clear inverted U-shaped relationship between $k$ and accuracy. Performance initially improves with $k$ (coverage) but eventually decays as collisions dominate. Crucially, the optimal $k$ shifts to the right as $N$ increases, confirming that more complex data requires more negatives.

Conceptual comparison of 'good' ($f_2$) and 'bad' ($f_1$) representations. The diagram (left) illustrates how $f_2$ preserves more distinct information, while the NCE-loss plots (middle, right) show how these representations behave as the number of negatives increases.

A significant finding is the "Vision Gap." Unlike NLP, Computer Vision models are highly robust to collisions. We hypothesize that the aggressive data augmentation used in vision (e.g., random cropping) creates a "positive" that is an exact instance-level match, making the model less sensitive to class-level collisions than NLP models, which often rely on broader semantic similarities.

Conclusion

This research establishes that the optimal number of negatives in contrastive learning is not universal but depends on the underlying complexity of the data. While the collision-coverage trade-off is a dominant factor in NLP, the robustness of vision models suggests that current theories must be extended to account for the inductive biases introduced by data augmentation. Future work should focus on developing "debiased" contrastive losses that can mitigate collisions without requiring explicit labels.

Summary updated

BibTeX
@inproceedings{ash2022investigating,
  author = {Jordan T. Ash and Surbhi Goel and Akshay Krishnamurthy and Dipendra Misra},
  title = {{Investigating the Role of Negatives in Contrastive Representation Learning}},
  booktitle = {International Conference on Artificial Intelligence and Statistics},
  year = {2022},
  url = {https://openreview.net/forum?id=b0HNq7cE8XU},
}
Figure