Hard-Negative Sampling for Contrastive Learning: Optimal Representation Geometry and Neural- vs Dimensional-Collapse

Ruijie Jiang, Thuan Nguyen, Shuchin Aeron, Prakash Ishwar

Abstract

Contrastive learning (CL) has emerged as a powerful paradigm for representation learning, yet the underlying geometry of the learned feature space remains poorly understood. This paper investigates the impact of hard-negative sampling (HNS) on the structure of these representations. We prove that Neural-Collapse (NC)—a state where class features form an Equiangular Tight Frame (ETF)—is the globally optimal geometry for contrastive objectives. Furthermore, we demonstrate that HNS serves as a critical mechanism to prevent Dimensional-Collapse (DC), ensuring the model utilizes the full capacity of the embedding space.

Introduction

Contrastive learning aims to learn representations by pulling positive pairs together and pushing negative pairs apart. While successful in practice, CL often suffers from Dimensional-Collapse (DC), where features collapse into a low-rank subspace, limiting the model's expressive power. Researchers have long utilized Hard-Negative Sampling (HNS)—prioritizing negative examples that are close to the anchor—to improve performance, but a rigorous theoretical link between HNS and representation geometry has been missing.

This work bridges that gap by showing that HNS pushes the representation toward Neural-Collapse (NC). In an NC state, class means are maximally spread out and equidistant, forming a perfectly symmetrical geometry known as an Equiangular Tight Frame (ETF).

Theoretical Framework

The authors define a "Generalized Contrastive Loss" that encompasses standard functions like InfoNCE and triplet loss. To analyze the effect of sampling, they model the data generation process using a graphical framework.

Graphical model representing the data generation and sampling process for contrastive learning.

In this framework, $y$ represents the class label, $x^{ref}$ is a reference sample, and $x$ and $x^+$ are augmented views. The embeddings $z$ and $z^+$ are compared against negative embeddings $z^-$ derived from different labels $y^-$. The "hardness" of the sampling is controlled by a non-decreasing function, such as exponential tilting, which weights negatives based on their proximity to the anchor in the embedding space. Using the Harris comparison inequality, the authors prove that increasing hardness increases the loss value while preserving the global minima, effectively making the optimization task more challenging but more rewarding.

The Geometry of Neural-Collapse

The paper identifies NC as the "North Star" for contrastive learning. To reach this state, the representation must satisfy three criteria:

  1. Zero-sum: Class means must average to the origin.
  2. Unit-norm: All features must lie on the surface of a hypersphere.
  3. Equal inner-product: All classes must be equally distant from one another.

A key insight is that standard CL often fails to reach this state due to DC. HNS acts as a stabilizer, "pushing" class means apart and preventing them from collapsing into a low-rank configuration. The authors also emphasize that normalization (unit-ball or unit-sphere) is mandatory; without it, the optimal NC geometry is rarely achieved regardless of sampling strategy.

Experimental Results

The theory was validated across synthetic datasets, CIFAR-10/100, and Tiny-ImageNet.

  • Accuracy and Robustness: In both supervised (HSCL) and unsupervised (HUCL) settings, moderate hardness levels significantly improved downstream classification. On CIFAR-100, accuracy gains exceeded 40 percentage points compared to standard CL.
  • Rank Recovery: Analysis of singular values confirmed that while standard SCL often leads to a "cliff" where most dimensions are zero (indicating DC), Hard-SCL maintains a full-rank representation, aligning with theoretical NC predictions.

Discussion and Limitations

While the paper provides a strong foundation for understanding HNS, several areas remain open for exploration. The "HUCL Gap" refers to the difficulty in deriving perfectly tight lower bounds for unsupervised learning due to potential "latent class collisions." Additionally, while the global minima are well-defined, the exact optimization trajectory—how optimizers like Adam navigate to these minima under HNS—requires further study. Finally, the theory assumes the embedding dimension is sufficient to accommodate the number of classes; the "overloaded" scenario where classes outnumber dimensions remains a topic for future research.

Summary updated

BibTeX
@article{jiang2025hard,
  author = {Ruijie Jiang and Thuan Nguyen and Shuchin Aeron and Prakash Ishwar},
  title = {{Hard-Negative Sampling for Contrastive Learning: Optimal Representation Geometry and Neural- vs Dimensional-Collapse}},
  journal = {Trans. Mach. Learn. Res.},
  year = {2025},
  url = {https://openreview.net/forum?id=lgcnAKjpjX},
}
Figure