Abstract
In recent years, there has been a growing trend of incorporating hyperbolic geometry methods into computer vision. While these methods have achieved state-of-the-art performance on various metric learning tasks using hyperbolic distance measurements, the underlying theoretical analysis supporting this superior performance remains under-exploited. In this study, we investigate the effects of integrating hyperbolic space into metric learning, particularly when training with contrastive loss. We identify a need for a comprehensive comparison between Euclidean and hyperbolic spaces regarding the temperature effect in the contrastive loss within the existing literature. To address this gap, we conduct an extensive investigation to benchmark the results of Vision Transformers (ViTs) using a hybrid objective function that combines loss from Euclidean and hyperbolic spaces. Additionally, we provide a theoretical analysis of the observed performance improvement. We also reveal that hyperbolic metric learning is highly related to hard negative sampling, providing insights for future work. This work will provide valuable data points and experience in understanding hyperbolic image embeddings. To shed more light on problem-solving and encourage further investigation into our approach, our code is available online (https://github.com/YunYunY/HypMix).
Introduction
The goal of metric learning is to structure an embedding space where similar items (positive pairs) are clustered and dissimilar ones (negative pairs) are separated. Recent advances have highlighted the effectiveness of hyperbolic geometry in this domain, particularly for hierarchical data. However, the exact mechanism behind this performance gain has remained under-explored. This paper investigates the interaction between hyperbolic geometry and the temperature parameter ($\tau$) in contrastive loss, revealing that hyperbolic metric learning acts as an implicit hard negative sampler.
Theoretical Analysis: The Temperature Effect
A critical observation in this work is the 'temperature trap.' Previous studies often attributed hyperbolic superiority to geometric properties alone, neglecting the impact of the temperature parameter in InfoNCE loss. By conducting a gradient analysis, we demonstrate that the weight assigned to a negative sample is a function of both temperature and relative distance. Euclidean models can achieve competitive performance if $\tau$ is tuned to a very low value (e.g., 0.05). Hyperbolic models, however, exhibit greater robustness across a wider range of temperature settings.
Hyperbolic Geometry as Implicit Hard Negative Sampling
The exponential volume growth of hyperbolic space naturally magnifies distances, particularly near the boundary of the Poincaré ball. This geometric property effectively forces the model to prioritize 'hard' negatives—samples that are visually similar to the anchor but belong to different classes.
As shown in the distribution of negative sample weights above, hyperbolic space concentrates learning on the most informative examples, acting as a sophisticated, built-in hard-negative mining algorithm.
Geometric Complementarity and Mix-ViT
An intriguing finding is that Euclidean and hyperbolic spaces often identify different samples as 'hard.' This geometric complementarity suggests that neither space alone captures the full complexity of the data's negative relationships.
To leverage this, we propose Mix-ViT, which utilizes a hybrid loss function $\mathcal{L}_{mix}$ that combines distances from both geometries. This allows the model to benefit from a more diverse and informative pool of hard negatives during training.
Experimental Results
We evaluated Mix-ViT and Mix-DINO on standard benchmarks including CUB-200-2011, Cars-196, and Stanford Online Product (SOP).
- CUB-200-2011: Mix-ViT achieved 83.7% Recall@1, surpassing pure Euclidean (83.4%) and hyperbolic (83.4%) baselines.
- Cars-196: Mix-DINO reached 85.2% Recall@1, a significant improvement over the standard hyperbolic DINO (83.2%).
These results confirm that fusing geometric perspectives leads to more robust and accurate image embeddings.
Conclusion
This study clarifies the role of hyperbolic geometry in metric learning, identifying implicit hard negative sampling as a primary driver of performance. By accounting for the temperature parameter and exploiting geometric complementarity through the Mix-ViT architecture, we achieve state-of-the-art results in image retrieval, providing a new theoretical and empirical foundation for future research in hyperbolic embeddings.
Summary updated