Abstract
Traditional hierarchical clustering often requires complex, specialized architectures that sacrifice leaf-level accuracy and scale poorly to large datasets. We present L2H (Logits to Hierarchies), a lightweight, post-hoc method that constructs high-quality hierarchical trees using only the output probabilities (logits) of any pre-trained "flat" model. L2H is computationally efficient, scaling to ImageNet-sized datasets in under a minute on a CPU, while significantly outperforming specialized deep hierarchical models in both speed and accuracy.
Introduction
Hierarchical clustering provides a multi-level understanding of data, organizing specific categories into broader semantic groups. Recently, research has pivoted toward "deep hierarchical clustering," where specialized neural networks are trained to learn these structures. However, these models suffer from two primary drawbacks: poor scalability and a performance gap where they underperform standard flat models at the leaf (specific category) level.
L2H addresses these issues by asking a fundamental question: Why build a complex, specialized model when we can extract the hierarchy from existing, highly accurate flat classifiers? By leveraging the "confusion" inherent in a model's logits, L2H provides a hierarchy "for free" without requiring fine-tuning or access to internal feature embeddings.
Methods: The L2H Algorithm
The L2H algorithm operates as a post-hoc process on any pre-trained model. Instead of training for hierarchy, it identifies semantic relationships through an iterative two-stage process:
- Scoring: The algorithm begins with each class in its own group. It calculates a confidence score for each group; the group with the lowest confidence is prioritized for merging.
- Merging via Masked Softmax: To determine the most semantically related partner for a selected group ($G^*$), L2H performs a "what if" analysis. By masking the logits of $G^*$ and re-calculating the softmax, the algorithm observes where the model reassigns those data points. This "second-best" choice reveals the underlying structure of the feature space.
This process repeats until a complete dendrogram is constructed. Because it operates solely on output probabilities, L2H is compatible with black-box models and requires minimal computational resources.
Experimental Results
The authors evaluated L2H across diverse benchmarks, including CIFAR-100, ImageNet-1K, and iNaturalist21. The results demonstrate a significant leap in both efficiency and quality:
- Accuracy: On CIFAR-100, L2H achieved a Dendrogram Purity (DP) of 0.803, vastly outperforming specialized models like TreeVAE (0.103) and DeepECT (0.052).
- Efficiency: L2H processed the CIFAR-100 hierarchy in less than 0.01 minutes. On the 1,000 classes of ImageNet-1K, it built a full hierarchy in just 27 seconds on a standard CPU.
- Biological Alignment: In tests on the iNaturalist dataset, the hierarchy inferred by L2H outperformed models specifically trained to recognize coarse taxonomic levels like Phylum or Order.
- Bias Discovery: L2H can reveal spurious correlations. For instance, in ImageNet, it merged "dogsleds" with "arctic dogs" rather than other vehicles, highlighting the model's reliance on environmental context.
Discussion and Conclusion
L2H proves that the "mistakes" and near-misses of flat models are not random noise but rich encodings of semantic relationships. By using the masked softmax trick, researchers can extract sophisticated hierarchies from existing models without sacrificing accuracy or investing in heavy retraining. While the method is sensitive to model calibration and currently focused on vision, it represents a major step toward making hierarchical data exploration accessible and scalable.
Summary updated