Hierarchy-aware Biased Bound Margin Loss Function for Hierarchical Text Classification

Gibaeg Kim, Sanghun Im, Heung-Seon OhACL 2024

Researchers from KOREATECH have introduced HBM (Hierarchy-aware Biased Bound Margin) loss, a novel loss function designed specifically for hierarchical text classification (HTC). By replacing fixed classification thresholds with learnable, dynamic bounds and incorporating adaptive biases and margins, HBM significantly improves performance on complex label hierarchies and mitigates the chronic issue of label imbalance.

The Challenges of Hierarchical Text Classification

Hierarchical Text Classification involves assigning documents to categories organized in a tree or graph structure (e.g., Sports > Soccer > Premier League). Modern "unit-based" models address this by decomposing the hierarchy into smaller subsets, or units, and performing classification within these localized contexts.

Comparison of Global and Unit-based model architectures for hierarchical classification.

Despite their structural advantages, these models face two primary hurdles:

  1. Static Thresholding: Most models rely on a fixed threshold (typically 0.5) to determine label applicability. In massive hierarchies with thousands of labels, a uniform threshold is rarely optimal across all categories.
  2. Label Imbalance: Real-world datasets often exhibit a "long-tail" distribution where a few categories are extremely frequent while the majority are rare. Standard loss functions like Binary Cross Entropy (BCE) tend to be dominated by frequent labels, causing the model to neglect rare but critical categories.

Methodology: The HBM Loss Function

To address these limitations, the authors propose the HBM loss, which integrates three dynamic components into the training objective:

  • Learnable Bounds ($t^U$): Instead of a fixed 0.5 threshold, the model learns a unique "bound" for each unit. This bound is computed dynamically based on document features, providing a context-aware threshold for inference.
  • Adaptive Biases ($b_{pos}, b_{neg}$): These biases adjust the bounds during training to amplify the signal for "hard" or infrequent labels, helping the model learn from low-confidence predictions it might otherwise ignore.
  • Margin ($m$): To prevent frequent, "easy" labels from overwhelming the gradient updates, HBM uses a margin to exclude high-confidence predictions from the loss calculation. This forces the model to focus on labels where it is less certain.
Comparison of loss mechanisms: (a) BCE with fixed thresholds, (b) ZLPR with target sets, and (c) the proposed HBM with learnable bounds, biases, and margins.

HBM was integrated into state-of-the-art unit-based models, including HPT and HiDEC, to evaluate its effectiveness.

Experimental Evaluation

The researchers tested HBM on three standard HTC benchmarks:

  • RCV1-v2: Reuters newswire stories (103 labels).
  • NYT: New York Times articles (166 labels).
  • EURLEX57K: A large-scale dataset of EU legal documents featuring 4,271 labels. This dataset is particularly challenging due to its severe long-tail distribution, where 83% of labels appear fewer than 50 times.

Key Results and Insights

HBM consistently outperformed standard BCE and the previous state-of-the-art loss, ZLPR, across all datasets.

  • Macro-F1 Gains: On the challenging EURLEX57K dataset, HBM significantly improved the Macro-F1 score—a metric that weighs rare and frequent classes equally. For the HiDEC model, HBM achieved a Macro-F1 of 28.77, compared to 27.91 with BCE.
  • Handling the Long Tail: Performance gains were most pronounced in low-frequency label clusters. In RCV1-v2, HBM showed substantially higher improvements for rare labels compared to the ZLPR baseline.
  • Noise Reduction: Visual analysis of prediction scores (logits) indicated that HBM's dynamic thresholds effectively filtered out noise that would have resulted in false positives under a static 0.5 threshold.

Conclusion and Future Directions

The core innovation of HBM is the transition from static to learned classification thresholds. By allowing the model to determine the "bar" for each category based on input context, it handles the nuances of complex hierarchies more effectively.

While HBM excels at managing frequent and few-shot labels, the authors note that future work will focus on extending the framework to zero-shot scenarios and even larger, "extremely" large-scale hierarchies. Additionally, exploring more complex architectures for calculating the learnable bounds remains an open area for research.

Summary updated

BibTeX
@inproceedings{kim2024hierarchy,
  author = {Gibaeg Kim and Sanghun Im and Heung-Seon Oh},
  title = {{Hierarchy-aware Biased Bound Margin Loss Function for Hierarchical Text Classification}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2024},
  doi = {10.18653/v1/2024.findings-acl.457},
}
Figure