Large-Margin Contrastive Learning with Distance Polarization Regularizer

Shuo Chen, Gang Niu, Chen Gong, Jun Li, Jian Yang, Masashi SugiyamaICML 2021

Introduction

Standard contrastive learning (CL) has become a powerhouse for unsupervised representation learning. However, it often fails because it treats semantically similar data points as "negatives," pushing them apart and creating an ambiguous feature space. To solve this, researchers introduce Large-Margin Contrastive Learning (LMCL), equipped with a Distance Polarization (DP) regularizer. This novel approach forces pairwise distances to be either very small or very large, creating a clear "large margin" that significantly improves performance across vision, language, and reinforcement learning tasks.

The Flaw in Standard Contrastive Learning

The core idea of contrastive learning is simple: take a data point, create a "positive" version of it via augmentation, and treat every other point in the batch as a "negative."

However, this introduces a fundamental flaw: False Negatives. In a large unlabeled dataset, many "negative" samples are actually semantically similar (e.g., two different pictures of a golden retriever). Standard CL objectives, like the Noise Contrastive Estimation (NCE) loss, indiscriminately push these similar points apart.

This indiscriminate repulsion leads to a "unimodal" distribution of distances in the feature space, where most pairs end up in a messy middle ground (around a distance of 0.5). This lack of a clear margin makes it difficult for downstream classifiers to distinguish between intra-cluster and inter-cluster relationships, ultimately limiting the quality of the learned embeddings.

Conceptual comparison of unregularized contrastive learning versus the proposed Distance Polarization (DP) regularized approach.

The Solution: Distance Polarization and LMCL

To address the ambiguity of the feature space, the authors propose a two-pronged solution:

  1. Distance Polarization (DP) Regularizer: Inspired by metric learning, this regularizer explicitly penalizes pairwise distances that fall into an ambiguous "margin region" $(\delta^+, \delta^-)$. It encourages distances to "polarize"—moving toward 0 for similar items and toward 1 for dissimilar ones. Mathematically, it applies an $\ell_0$-norm-based penalty (approximated by $\ell_1$ for optimization) on distances that land in this middle ground.
  2. Large-Margin Contrastive Learning (LMCL): This is the integrated objective function that combines the standard NCE loss with the DP regularizer.

Unlike previous "debiased" contrastive methods that try to re-weight samples based on estimated similarity, LMCL focuses on the geometric distribution of the entire embedding space. It acts as a "plug-and-play" regularizer that can be seamlessly added to existing frameworks like SimCLR, MoCo, or CURL.

Key Insights: Uncovering Hidden Similarity

A major insight from the paper is the concept of "hidden" similarity. Even though standard CL pushes all negatives away, the underlying model architecture still wants to group similar things based on shared features. By adding the DP regularizer, LMCL essentially "cleans up" the signal that is already present but obscured by the standard loss function.

A key visualization of this success is the shift in distance histograms. While standard self-supervised CL results in a single, ambiguous hump (unimodal), LMCL results in two distinct peaks (bimodal) with a valley in between. This valley represents the "large margin" that gives the method its name, closely mirroring the clear separation seen in fully supervised models.

Histogram showing the bimodal distance distribution achieved by the DP Regularizer, creating a clear margin between intra-class and inter-class samples.

Furthermore, the authors provide a theoretical guarantee, proving that LMCL yields a tighter error bound for downstream classification compared to standard CL. As the number of classes increases or the regularizer value decreases, the similarity error converges to zero.

Empirical Results Across Domains

The authors evaluated LMCL across a diverse set of benchmarks, proving its versatility:

  • Computer Vision: On CIFAR-10 and STL-10, LMCL consistently outperformed SimCLR and other state-of-the-art "debiased" methods (like DCL and HCL) by 1–2% in accuracy. On ImageNet-100, it boosted the CMC baseline from 73.58% to 75.88% (Top-1).
  • Natural Language Processing: Adding the DP regularizer to the "Quick-Thought" (QT) baseline improved text classification accuracy across almost all benchmarks (e.g., MR, CR, SUBJ), notably increasing TREC scores from 89.8% to 90.2%.
  • Reinforcement Learning: When integrated with CURL (a popular contrastive RL method), LMCL achieved higher mean scores on the DeepMind Control Suite, particularly on the "Easy" and "Run" tasks, while demonstrating lower variance and more stable training.
  • Clustering: On synthetic datasets like "Three-Bars," LMCL achieved significantly higher K-means clustering accuracy (84.2% vs. 78.3% for standard CL).

Limitations and Future Directions

While highly effective, LMCL does introduce some new considerations:

  • Hyperparameter Sensitivity: The authors provide a solid default for the margin ($\delta^- = 0.5$) and show robustness to the regularization weight ($\lambda$), but these are still additional knobs to tune compared to vanilla CL.
  • Computational Complexity: Calculating all pairwise distances in a batch for the regularizer introduces an $O(n^2)$ complexity relative to the batch size. While manageable for standard GPU memory, it could become a bottleneck for extremely large-scale distributed training.
  • Uncertainty Handling: Future work could involve better handling the uncertainty of similarity determination within the polarization process itself.

Overall, Large-Margin Contrastive Learning offers a robust, geometrically-motivated fix to one of the most persistent issues in self-supervised learning, paving the way for clearer, more separable feature representations.

Summary updated

BibTeX
@inproceedings{chen2021large,
  author = {Shuo Chen and Gang Niu and Chen Gong and Jun Li and Jian Yang and Masashi Sugiyama},
  title = {{Large-Margin Contrastive Learning with Distance Polarization Regularizer}},
  booktitle = {International Conference on Machine Learning},
  year = {2021},
  url = {https://openreview.net/forum?id=7Eu1m1ZcXIi},
}
Figure