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:
- 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.
- 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$.
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.
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