Domain-Hierarchy Adaptation via Chain of Iterative Reasoning for Few-shot Hierarchical Text Classification

Ke Ji, Peng Wang, Wenjun Ke, Guozheng Li, Jiajun Liu, Jingsheng Gao, Ziyu Shang · DOI

Abstract

Hierarchical Text Classification (HTC) assigns documents to categories organized in a taxonomy. Standard Pre-trained Language Models (PLMs) often struggle with HTC in few-shot settings because they lack inherent understanding of rigid parent-child constraints. This paper introduces HierICRF, a novel framework that bridges the gap between unstructured PLM knowledge and structured domain hierarchies. HierICRF utilizes a "Chain of Hierarchy-aware Reasoning" (CHR) to iteratively predict labels and a Hierarchical Iterative Conditional Random Field (ICRF) to enforce structural consistency. Experimental results on WOS and DBpedia datasets demonstrate that HierICRF significantly outperforms existing methods, particularly in 1-shot and 2-shot scenarios, while ensuring near-perfect hierarchical consistency.

Introduction: The Challenge of Structured Knowledge

Hierarchical Text Classification (HTC) is essential for organizing complex information, such as academic abstracts or Wikipedia metadata. However, fine-tuning PLMs for HTC faces two primary hurdles in few-shot environments: knowledge mismatch and hierarchical inconsistency. PLMs are trained on unstructured text and do not naturally respect the tree-like dependencies of a specific taxonomy. Consequently, they often produce "illegal" predictions, such as assigning a sub-category without its corresponding parent.

Comparison between traditional HTC methods and the proposed iterative-based HTC framework.

Traditional methods often inject hierarchy into the encoder or use simple classification heads, which fail to capture the sequential dependency of the label path. As shown in Figure 1, the proposed iterative framework treats classification as a reasoning process, allowing the model to self-correct and maintain consistency through a path-routing approach.

The HierICRF Framework

The HierICRF framework decomposes the HTC task into three distinct stages designed to elicit and constrain structural reasoning.

Overview of the HierICRF framework consisting of three stages: Chain of Hierarchy-aware Reasoning, Text to Series conversion, and Hierarchical Iterative CRF.

1. Chain of Hierarchy-aware Reasoning (CHR)

Inspired by Chain-of-Thought prompting, CHR wraps the input text in a template that prompts the model to predict labels level-by-level multiple times. For example, a prompt might be: "It was 1 level: [MASK] 2 level: [MASK] 1 level: [MASK] 2 level: [MASK]..." This iterative structure allows the model to use previous predictions as context for subsequent refinements, effectively performing a form of internal self-correction.

2. Text to Hierarchically Repeated Series

The model processes the wrapped input to generate hidden states for each [MASK] token. A "verbalizer" layer then maps these states to initial probability distributions across the entire label hierarchy. This stage transforms the text input into a sequence of potential label emissions.

3. Hierarchical Iterative CRF (ICRF)

The core innovation is the ICRF layer, which acts as a structural guardrail. Unlike standard classifiers that treat labels independently, the ICRF uses a transition matrix initialized based on the label tree. Transitions between unrelated or non-adjacent layers are penalized, forcing the model to select the most probable valid path. During inference, the Viterbi algorithm identifies the optimal sequence of labels that respects the hierarchy.

Experimental Evaluation

The framework was evaluated on the Web-of-Science (WOS) and DBpedia datasets under few-shot conditions (1, 2, 4, 8, and 16 samples per path).

Key Results

  • Performance Gains: HierICRF set new state-of-the-art benchmarks. In 1-shot settings on the WOS dataset, it achieved a substantial Macro-F1 improvement over vanilla fine-tuning and previous prompt-based methods.
  • Structural Integrity: The model achieved near-perfect hierarchical consistency. By design, the ICRF ensures that a predicted sub-category is always linked to its correct parent, a feat traditional models often fail to achieve.
  • Model Scaling: The benefits of HierICRF scale positively with model size. Larger models (e.g., T5-large vs. T5-base) showed even greater improvements, suggesting the method effectively leverages the latent reasoning capabilities of larger PLMs.

Discussion and Conclusion

HierICRF demonstrates that treating hierarchical classification as an iterative path-routing problem is highly effective for few-shot domain adaptation. While the iterative reasoning and CRF decoding add some computational overhead, the significant gains in accuracy and consistency justify the cost in low-resource settings. Future work may explore applying these hierarchical constraints to massive LLMs through pure in-context learning or specialized decoding strategies that do not require weight updates.

Summary updated

BibTeX
@inproceedings{ji2024domain,
  author = {Ke Ji and Peng Wang and Wenjun Ke and Guozheng Li and Jiajun Liu and Jingsheng Gao and Ziyu Shang},
  title = {{Domain-Hierarchy Adaptation via Chain of Iterative Reasoning for Few-shot Hierarchical Text Classification}},
  booktitle = {International Joint Conference on Artificial Intelligence},
  year = {2024},
  url = {https://openreview.net/forum?id=0jCobyEg3B},
}
Figure