Computationally Efficient Wasserstein Loss for Structured Labels

Ayato Toyokuni, Sho Yokoi, Hisashi Kashima, Makoto Yamada · DOI

Introduction

Label Distribution Learning (LDL) has emerged as a powerful paradigm for tasks where a single "hard" label is insufficient to capture the nuances of the data. Instead of assigning a single category, LDL estimates a probability distribution over a set of labels, allowing for a more granular representation of ambiguity or multi-faceted characteristics (e.g., an image being 70% "joy" and 30% "surprise"). Traditionally, the Kullback-Leibler (KL) divergence has been the standard loss function for comparing predicted and ground-truth distributions. However, KL divergence suffers from a significant limitation: it treats labels as independent entities, ignoring any inherent relationships or "ground metrics" between them.

The Wasserstein Distance Challenge

The Wasserstein distance, often called the "Earth Mover's Distance," addresses this by incorporating a ground metric that penalizes errors based on the actual distance between labels. For instance, in a taxonomic hierarchy, misclassifying a "dog" as a "wolf" should incur a smaller penalty than misclassifying it as a "toaster." While theoretically superior, calculating the Wasserstein distance is computationally intensive. Standard approximations, such as the Sinkhorn algorithm, typically exhibit quadratic complexity ($O(L^2)$) relative to the number of labels $L$. This makes them impractical for large-scale classification problems involving tens or hundreds of thousands of labels.

Tree-Regularized Label Distribution Learning

To overcome these computational hurdles, the authors propose a tree-regularized LDL algorithm. Their core innovation lies in leveraging hierarchical label structures to compute the 1-Wasserstein distance efficiently. When labels are organized into a tree, the Wasserstein distance has a closed-form solution that can be computed in linear time ($O(L)$).

Hierarchical label structure used to define the tree-Wasserstein distance.

The proposed Tree-Wasserstein Distance (TWD) defines the distance between two distributions as the weighted sum of mass differences across all sub-trees. By integrating this as a regularizer alongside the standard KL divergence, the model benefits from the precise distribution matching of KL while gaining a geometric "understanding" of the label hierarchy.

Computational Efficiency and Scalability

The shift from quadratic to linear complexity is transformative for extreme classification. In traditional Sinkhorn-based methods, the need to store and manipulate a massive $L \times L$ cost matrix leads to a memory bottleneck. In contrast, TWD maintains a flat memory footprint because it avoids the explicit construction of the cost matrix, relying instead on the tree structure.

Comparison of time and memory consumption between Tree-Wasserstein (TW) and standard Wasserstein (W1).

As shown in the experimental results, for a label set of $10^5$ nodes, the TWD method requires only 66 MB of memory and approximately 1.6 seconds for computation. Standard Sinkhorn approximations (both CPU and GPU implementations) fail entirely at this scale, exceeding the memory capacity of typical hardware (requiring over 37 GB).

Experimental Performance

The researchers validated their approach on both synthetic and real-world datasets. On a synthetic tree with 1,000 nodes, the TWD-regularized model achieved the lowest exact Wasserstein scores compared to other metrics like Chebyshev or Clark distances.

For real-world application, the authors utilized the BlurbGenreCollectionEN dataset, which contains over 91,000 book descriptions categorized into a deep hierarchy of genres. The TWD method demonstrated performance comparable to Sinkhorn-based methods in terms of Pseudo-Recall and Top-5 accuracy, but with a fraction of the computational cost. This confirms that the efficiency gains do not come at the expense of predictive power.

Conclusion

The introduction of tree-regularized LDL and the utilization of Tree-Wasserstein distance represent a significant step forward in making geometrically-aware loss functions scalable. By reducing the complexity of Wasserstein distance to $O(L)$, this research opens the door for its application in massive-scale hierarchical classification tasks where it was previously computationally prohibitive. Future work may involve extending these principles to more complex structures like Directed Acyclic Graphs (DAGs) to further broaden the applicability of this efficient metric.

Summary updated

BibTeX
@inproceedings{toyokuni2021computationally,
  author = {Ayato Toyokuni and Sho Yokoi and Hisashi Kashima and Makoto Yamada},
  title = {{Computationally Efficient Wasserstein Loss for Structured Labels}},
  booktitle = {Student Research Workshop @ EACL},
  year = {2021},
  doi = {10.18653/v1/2021.eacl-srw.1},
}
Figure