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

Abstract

Hierarchical Text Classification (HTC) is a complex task requiring models to assign labels within a structured taxonomy. While Pre-trained Language Models (PLMs) excel at flat classification, they often struggle with the structural constraints of HTC, especially in data-scarce few-shot scenarios. We introduce HierICRF, a framework that leverages iterative reasoning and structured inference to bridge this gap. HierICRF utilizes a Chain of Hierarchy-aware Reasoning (CHR) to prompt models for layer-by-layer predictions and a Hierarchical Iterative Conditional Random Field (ICRF) to enforce logical consistency via the Viterbi algorithm. Our evaluations on standard benchmarks show that HierICRF provides massive performance improvements in few-shot settings while maintaining near-perfect hierarchical consistency.

Introduction

Hierarchical Text Classification (HTC) involves assigning documents to categories organized in a tree-like structure (e.g., Electronic Engineering → Computer Hardware → Microprocessors). Despite the power of Pre-trained Language Models (PLMs) like BERT or T5, they face significant hurdles in HTC. First, PLMs are typically trained on unstructured text and lack an inherent understanding of rigid parent-child relationships. Second, in few-shot learning scenarios, models frequently produce hierarchically inconsistent predictions—such as assigning a leaf node label without its corresponding parent.

Comparison of traditional HTC methods versus the proposed HierICRF framework.

Traditional methods often attempt to inject hierarchy using complex graph neural networks, which are prone to overfitting when training data is limited. To address these challenges, we propose HierICRF, which reframes HTC as a path-routing problem solved through iterative reasoning.

Methodology

The HierICRF framework consists of three distinct stages designed to align semantic understanding with structural constraints.

The three-stage pipeline of HierICRF: Chain of Hierarchy-aware Reasoning, Text to Series generation, and Hierarchical Iterative CRF.

1. Chain of Hierarchy-aware Reasoning (CHR)

Inspired by "Chain of Thought" prompting, CHR uses a template that forces the model to predict labels layer-by-layer. Crucially, the process is repeated iteratively (e.g., predicting Level 1, then Level 2, then Level 1 again). This repetition allows the model to perform self-correction, using deeper contextual insights to refine higher-level predictions.

2. Text to Hierarchically Repeated Series

The model processes the reasoning template to generate a series of emission probabilities for each level of the hierarchy. This stage maps the unstructured semantic space of the PLM into a format suitable for structured inference.

3. Hierarchical Iterative CRF (ICRF)

The core of our framework is the ICRF layer. Unlike standard classifiers that pick the highest-scoring label independently, the ICRF uses a transition matrix initialized to penalize "illegal" transitions between non-related categories. During inference, the Viterbi algorithm identifies the most probable legal path through the hierarchy, mathematically ensuring consistency.

Experimental Evaluation

We evaluated HierICRF on two major HTC benchmarks: Web-of-Science (WOS) and DBpedia. Experiments were conducted in extreme few-shot settings (1, 2, 4, 8, and 16-shot), where the model is fine-tuned on only a handful of examples per category.

Results and Discussion

HierICRF achieved state-of-the-art (SOTA) performance across all tested settings. Notable findings include:

  • Performance Gains: In 1-shot settings on the WOS dataset, HierICRF-BERT improved Micro-F1 scores by an average of 28.80% over existing baselines.
  • Logical Consistency: While traditional fine-tuning often leads to broken hierarchical paths, HierICRF maintained near-perfect consistency by design.
  • Architectural Flexibility: The framework proved effective for both encoder-only (BERT) and encoder-decoder (T5) architectures.

Conclusion

HierICRF effectively bridges the gap between the unstructured knowledge of PLMs and the structured requirements of hierarchical classification. By treating HTC as an iterative path-routing problem and employing a specialized CRF layer, the framework achieves superior accuracy and logical consistency in few-shot scenarios. Future work will explore extending this approach to massive LLMs via non-tuning algorithms and handling dynamic, evolving hierarchies.

Summary updated

BibTeX
@inproceedings{ji2024domain,
  author = {Ke Ji and Peng Wang and Wenjun Ke and Guozheng Li and Jiajun Liu and Jingsheng Gao},
  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