Introduction
Hierarchical Text Classification (HTC) involves assigning documents to labels organized within a structured taxonomy, such as a tree or directed acyclic graph. Unlike traditional flat classification, HTC requires models to respect hierarchical constraints—for instance, a document classified under a specific sub-category must also be associated with its parent categories.
With the advent of Large Language Models (LLMs), treating HTC as a sequence-to-sequence (seq2seq) task has gained traction. In this paradigm, the model generates a sequence representing the path through the hierarchy. However, the optimal configuration for this approach—including traversal strategies and label representations—remains under-explored. This study systematically evaluates these modeling choices to establish a robust framework for generative HTC.
Methodology
The researchers utilized the T5 encoder-decoder architecture as a backbone to investigate three critical dimensions of seq2seq HTC:
- Sequence Modeling (Tree Traversal): Four strategies were compared to linearize the label tree: Breadth-First Search (BFS), Depth-First Search (DFS), and their respective bottom-up variants.
- Constrained Decoding: A "Constrainer Module" was introduced to mask invalid tokens during inference, ensuring that the generated sequences strictly adhere to the predefined hierarchy.
- Label Semantics: The impact of label naming was tested by comparing natural language semantic names (e.g., "Corporate/Industrial") against abstract identifiers (e.g., "CCAT").
Experimental Setup
The framework was evaluated on three benchmark datasets:
- RCV1V2 (Reuters): A multi-path hierarchy of news wires.
- Web of Science (WOS): Academic abstracts organized in a single-path hierarchy.
- Blurb Genre Collection (BGC): A multi-path hierarchy of book blurbs.
Results and Discussion
The experimental results yielded several key insights into the behavior of generative HTC models:
- Traversal Strategy: Depth-First Search (DFS) consistently outperformed Breadth-First Search (BFS). This advantage likely stems from the nature of the taxonomies, where "path-following" logic aligns better with the sequential generation process of LLMs.
- The Role of Constraints: Constrained decoding proved essential, not only for ensuring a 100% Hierarchical Consistency Rate (HCR) but also for improving overall classification accuracy by narrowing the search space to valid labels.
- Semantic Importance: Using semantic label names is crucial. Replacing descriptive names with acronyms led to a significant performance drop (Macro F1 decreased by 4-5% on RCV1V2), indicating that models leverage pre-trained linguistic knowledge of category names.
The DFS-C (Depth-First Search with Constraints) configuration emerged as the top-performing model, achieving high consistency and accuracy across the tested benchmarks, such as a Micro F1 of 86.42 on the WOS dataset.
Conclusion
This study provides a roadmap for implementing hierarchical text classification within a seq2seq framework. By prioritizing DFS traversal, descriptive label semantics, and constrained decoding, practitioners can build more reliable and accurate classifiers. Future research will focus on scaling these findings to larger LLMs and adapting the framework to handle noisier, real-world taxonomies. The authors have released the SHTC framework on GitHub to facilitate reproducible research in this domain.
Summary updated