Standard supervised contrastive learning often fails to capture the "layers" of similarity in data, treating a cat as equally different from a dog as it is from a toaster. Multi-level Supervised Contrastive Learning (MLCL) addresses this by using multiple projection heads to simultaneously learn different aspects of an instance—such as its specific subclass and its broader superclass—resulting in richer representations that perform significantly better in data-scarce scenarios and complex hierarchical tasks.
The Problem: Flat Representations in a Hierarchical World
Contrastive learning has become a cornerstone of modern AI, teaching models to pull "similar" samples together and push "dissimilar" ones apart in a mathematical embedding space. However, most current methods, such as Supervised Contrastive Learning (SupCon), rely on a single projection head and a single label.
This creates a "flat" view of the world that ignores the inherent structure of data. In reality, data is often multi-dimensional or hierarchical. For example, in a product dataset, a "running shoe" is similar to a "hiking boot" at the footwear level but distinct at the activity level. Standard models struggle to capture these nuances, leading to suboptimal performance when labels are complex (multi-label) or nested (hierarchical). This limitation is especially problematic when training data is limited, as the model cannot leverage broader category relationships to aid learning.
Methodology: The MLCL Framework
MLCL introduces a unified framework that modifies the standard contrastive architecture to better handle multi-level labels. The core innovation lies in two primary components:
- Multiple Projection Heads: Instead of a single path from the encoder to the loss function, MLCL attaches several "projection heads." Each head is dedicated to a specific level of the hierarchy or a specific label aspect. For instance, one head might focus on distinguishing a "Husky" from a "Beagle," while another ensures both are grouped under the broader "Dog" superclass.
- Level-Specific Temperature Tuning: The "temperature" hyperparameter in contrastive loss controls how much the model penalizes "hard negatives" (samples that are different but look very similar). MLCL uses lower temperatures for fine-grained levels to force sharp distinctions between subclasses and higher temperatures for broader levels to encourage a more uniform, holistic understanding of superclasses.
During training, the final loss is a weighted sum of the losses from all heads. This multi-task approach allows the superclass projection head to act as a regularizer, preventing the model from overfitting on tiny details that distinguish subclasses while ignoring their shared traits. During inference, the heads are discarded, leaving behind a highly "educated" encoder.
Key Results and Insights
The researchers evaluated MLCL across both image classification (CIFAR-100, DeepFashion) and sentiment analysis (TripAdvisor, BeerAdvocate reviews).
Performance and Efficiency
MLCL outperformed standard SupCon and other specialized hierarchical methods on all tested datasets. On CIFAR-100, it achieved 77.70% accuracy compared to SupCon's 76.50%. One of the most striking findings was MLCL's performance in data-scarce scenarios. When trained on only 5,000 samples of CIFAR-100 (10% of the full set), MLCL outperformed SupCon by nearly 10% (56.02% vs 46.15%). Furthermore, MLCL demonstrated faster convergence, reaching higher accuracy in just 250 epochs than standard SupCon did in 1,000 epochs.
Qualitative Analysis
t-SNE visualizations, which map the model's high-dimensional embedding space into two dimensions, show that MLCL groups related items much more logically than standard methods.
While SupCon often scatters related categories, MLCL clusters them based on their shared superclass traits, such as grouping different types of furniture or flowers together.
Conclusion and Future Work
MLCL demonstrates that "similarity" is not a one-size-fits-all metric. By leveraging hierarchical structures and adjusting temperature per head, the model learns more efficiently from fewer examples. While powerful, future work could explore letting the model discover these "levels" of similarity automatically rather than relying on predefined hierarchies, and testing the approach on massive, deeply nested taxonomies.
Summary updated