Investigating the Role of Negatives in Contrastive Representation Learning

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

Abstract

Noise contrastive learning is a popular technique for unsupervised representation learning. In this approach, a representation is obtained via reduction to supervised learning, where given a notion of semantic similarity, the learner tries to distinguish a similar (positive) example from a collection of random (negative) examples. The success of modern contrastive learning pipelines relies on many design decisions, such as the choice of data augmentation, the number of negative examples, and the batch size; however, there is limited understanding as to how these parameters interact and affect downstream performance. We focus on disambiguating the role of one of these parameters: the number of negative examples. Theoretically, we show the existence of a collision-coverage trade-off suggesting that the optimal number of negative examples should scale with the number of underlying concepts in the data. Empirically, we scrutinize the role of the number of negatives in both NLP and vision tasks.

Introduction

Contrastive representation learning frameworks like SimCLR and CLIP have revolutionized unsupervised learning by teaching models to pull semantically similar "positive" pairs together while pushing "negative" pairs apart. A critical hyperparameter in this process is the number of negative samples ($k$). While common practice favors increasing $k$ alongside batch size ($B$), it remains unclear whether performance gains stem from more negatives or the improved optimization of larger batches. This research investigates the fundamental tension between "coverage"—the need for diverse negatives to define semantic boundaries—and "collisions"—the risk of accidentally selecting a negative that shares the same latent class as the anchor.

Theoretical Framework: The Collision-Coverage Trade-off

The core contribution of this work is the identification of a "collision-coverage trade-off." As the number of negatives $k$ increases, the model gains better coverage of the data's semantic space, which should theoretically improve the representation. However, a higher $k$ also increases the probability of a "collision," where a negative sample is semantically identical to the positive anchor, providing a false training signal.

Theoretical scaling of the error bound pre-multiplier with the number of negatives $k$ for $N=100$ concepts. The blue dots indicate optimal $k$ values for different bound formulations, illustrating the "Goldilocks zone" for negatives.

By refining the "error transfer" framework, the authors prove that the optimal $k$ is not a fixed constant but scales with the complexity—specifically the number of latent classes or concepts ($N$)—of the dataset. Figure 1 illustrates how theoretical error bounds exhibit a minimum, where an intermediate number of negatives balances coverage and collision risk.

Empirical Analysis and Decoupling

To validate these theoretical insights, the authors decoupled $k$ from the batch size $B$ by sampling negatives from a separate pool. This allowed for a controlled study of $k$'s impact on performance across NLP (Wiki-3029) and vision (CIFAR-10, SVHN) datasets.

A key finding is that the NCE-loss itself can be a deceptive metric for representation quality. As shown in Figure 5, a "good" representation ($f_2$) might exhibit higher loss than a "bad" one ($f_1$) depending on the number of negatives used, highlighting the importance of choosing $k$ carefully to reveal true semantic differences.

Conceptual framework comparing representations and their NCE-loss behavior. Left: Schematic of representations $f_1$ and $f_2$. Middle/Right: NCE-loss as a function of the number of negatives, showing how loss curves for different representations can intersect.

Key Insights

  • Scaling with Complexity: Empirical results on the Wiki-3029 dataset confirm that as the number of concepts $N$ increases, the optimal number of negatives $k$ also shifts higher, matching the theoretical prediction.
  • Augmentation as a Buffer: In vision tasks, data augmentation acts as a crucial shield against collisions. While NLP tasks showed a sharp performance decay at high $k$ due to collisions, vision models using SimCLR-style augmentations remained robust, with performance typically plateauing rather than dropping.
  • Batch Size Independence: Increasing batch size $B$ improves performance even when $k$ is held constant, suggesting that large-batch training provides optimization benefits beyond simply providing more negatives.

Conclusion

This study demonstrates that the number of negatives in contrastive learning is a nuanced parameter governed by the semantic density of the data. Practitioners should move away from blindly maximizing $k$ and instead consider the complexity of their dataset and the strength of their data augmentations. Future work remains to formally integrate augmentation into the collision-coverage mathematical framework and to explore these dynamics in full fine-tuning scenarios.

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