[Paper Review] Understanding the Behaviour of Contrastive Loss
This paper investigates the behavior of contrastive loss in self-supervised representation learning, revealing it as a hardness-aware loss that prioritizes hard negative samples through temperature control. It identifies a uniformity-tolerance dilemma: while high uniformity improves feature separability, excessive penalty on semantically similar samples harms downstream performance. The key contribution is showing that optimal performance arises from balancing uniformity and tolerance via temperature tuning, with 0.2–0.3 yielding best results on CIFAR and ImageNet benchmarks.
Unsupervised contrastive learning has achieved outstanding success, while the mechanism of contrastive loss has been less studied. In this paper, we concentrate on the understanding of the behaviours of unsupervised contrastive loss. We will show that the contrastive loss is a hardness-aware loss function, and the temperature τ controls the strength of penalties on hard negative samples. The previous study has shown that uniformity is a key property of contrastive learning. We build relations between the uniformity and the temperature τ . We will show that uniformity helps the contrastive learning to learn separable features, however excessive pursuit to the uniformity makes the contrastive loss not tolerant to semantically similar samples, which may break the underlying semantic structure and be harmful to the formation of features useful for downstream tasks. This is caused by the inherent defect of the instance discrimination objective. Specifically, instance discrimination objective tries to push all different instances apart, ignoring the underlying relations between samples. Pushing semantically consistent samples apart has no positive effect for acquiring a prior informative to general downstream tasks. A well-designed contrastive loss should have some extents of tolerance to the closeness of semantically similar samples. Therefore, we find that the contrastive loss meets a uniformity-tolerance dilemma, and a good choice of temperature can compromise these two properties properly to both learn separable features and tolerant to semantically similar samples, improving the feature qualities and the downstream performances.
Motivation & Objective
- To understand the behavioral mechanisms of contrastive loss in unsupervised representation learning.
- To analyze the role of temperature τ in controlling hardness-awareness and embedding distribution properties.
- To identify the trade-off between uniformity of feature distribution and tolerance to semantically similar samples.
- To demonstrate that the instance discrimination objective inherently undermines semantic structure by pushing similar samples apart.
Proposed method
- Analyzing the contrastive loss as a hardness-aware function where temperature τ modulates penalty strength on hard negatives.
- Using temperature τ as a proxy to study its influence on embedding uniformity and tolerance to semantically similar samples.
- Measuring uniformity and tolerance via Eq 10 and Eq 11, respectively, on CIFAR10, CIFAR100, SVHN, and ImageNet100.
- Training models with standard contrastive loss (Eq 1) and hard contrastive loss (Eq 9) to compare performance under different τ settings.
- Evaluating linear classification accuracy as a proxy for downstream task performance across multiple datasets.
- Comparing a simple contrastive loss (Eq 3, τ→∞) with and without explicit hard negative sampling to isolate the importance of hardness-awareness.
Experimental results
Research questions
- RQ1How does the temperature τ affect the hardness-awareness of contrastive loss in learning separable features?
- RQ2What is the trade-off between uniformity of embedding distribution and tolerance to semantically similar samples in contrastive learning?
- RQ3Why does excessive pursuit of uniformity degrade downstream performance despite improving feature separability?
- RQ4Can a simple contrastive loss without temperature scaling achieve competitive performance if combined with explicit hard negative sampling?
- RQ5How does the instance discrimination objective fail to preserve underlying semantic structures in contrastive learning?
Key findings
- Models trained with temperature τ = 0.2 or 0.3 achieve the best linear classification accuracy on CIFAR10, CIFAR100, SVHN, and ImageNet100, indicating an optimal balance between uniformity and tolerance.
- Small temperature (e.g., τ=0.07) leads to highly uniform distributions but penalizes semantically similar samples excessively, harming feature quality.
- Large temperature (e.g., τ=0.2) increases tolerance to similar samples but reduces uniformity, leading to less separable features.
- The standard contrastive loss (Eq 1) with τ=0.2 achieves 83.27% linear accuracy on CIFAR10, outperforming the simple loss (74.83%) without hardness-awareness.
- Explicit hard negative sampling enables a simple contrastive loss (Eq 3) to achieve competitive results (95.47% on SVHN), proving that hardness-awareness is the core to success.
- The hard contrastive loss (Eq 9) alleviates the uniformity-tolerance dilemma, achieving better performance with larger τ, as it maintains uniformity through explicit mining.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.