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

Abstract

Recently, various pre-trained language models (PLMs) have been proposed to prove their impressive performances on a wide range of few-shot tasks. However, limited by the unstructured prior knowledge in PLMs, it is difficult to maintain consistent performance on complex hierarchically dependent tasks, especially when the downstream data is extremely scarce. The main challenge is how to transfer the unstructured semantic space in PLMs to the downstream domain hierarchy. Unlike previous work on hierarchical text classification (HTC) which directly performs multi-label classification or uses graph neural network (GNN) to inject label hierarchy, in this work, we study the HTC problem under a few-shot setting to adapt knowledge in PLMs from an unstructured manner to the downstream hierarchy. Technically, we design a simple yet effective method named Hierarchical Iterative Conditional Random Field (HierICRF) to search the most domain-challenging directions and exquisitely crafts domain-hierarchy adaptation as a hierarchical iterative language modeling problem, and then it encourages the model to make hierarchical consistency self-correction during the inference, thereby achieving knowledge transfer with hierarchical consistency preservation. We perform HierICRF on various architectures, and extensive experiments on two popular HTC datasets demonstrate that prompt with HierICRF significantly boosts the few-shot HTC performance with an average Micro-F1 by 28.80% to 1.50% and Macro-F1 by 36.29% to 1.5% over the previous state-of-the-art (SOTA) baselines under few-shot settings (1->16), while remaining SOTA hierarchical consistency performance.

Introduction

Hierarchical Text Classification (HTC) is a complex task where documents must be assigned to labels organized in a structured tree or directed acyclic graph (e.g., Medical -> Cardiology -> Heart Failure). While Pre-trained Language Models (PLMs) like BERT or T5 excel in general text tasks, they face significant hurdles in HTC, particularly in few-shot scenarios.

The primary challenges are twofold:

  1. The Adaptation Gap: PLMs possess vast "unstructured" knowledge. Mapping this to a specific "structured" domain hierarchy is difficult when labeled data is scarce.
  2. Hierarchical Inconsistency: Standard classification heads often produce "impossible" predictions, such as selecting a leaf node without its corresponding parent, or picking labels from conflicting branches.
Comparison between traditional HTC methods and the proposed HierICRF framework.

Traditional methods often attempt to inject the hierarchy directly into the model architecture via Graph Neural Networks (GNNs), but these approaches struggle to maintain consistency when training data is extremely limited.

The HierICRF Framework

The authors propose HierICRF, which reframes HTC as a path-routing problem solved through iterative reasoning. The framework is divided into three distinct stages designed to bridge the gap between unstructured PLM knowledge and structured hierarchies.

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

1. Chain of Hierarchy-aware Reasoning (CHR)

Instead of a single prediction step, HierICRF uses a prompt template that forces the model to predict the hierarchical path multiple times in a loop (e.g., "Level 1: [MASK], Level 2: [MASK], Level 1: [MASK]..."). This iterative prompting encourages the model to refine its internal representation of the path through the tree.

2. Text to Hierarchically Repeated Series

The model generates a sequence of hidden states corresponding to the repeated prompts. These states are passed through a "verbalizer" to produce emission probabilities for every possible label at each step in the reasoning chain.

3. Hierarchical Iterative CRF (ICRF)

The core innovation is the Hierarchical Iterative Conditional Random Field layer. The transition matrix of this CRF is initialized based on the actual label hierarchy, assigning near-zero probability to "illegal" transitions (e.g., jumping between unrelated branches). During inference, the Viterbi algorithm identifies the most mathematically likely and hierarchically valid path across all iterations, allowing the model to self-correct earlier errors.

Experimental Evaluation

The model was evaluated on two standard HTC benchmarks: Web-of-Science (WOS) (2-level hierarchy) and DBpedia (3-level hierarchy). Tests were conducted under extreme few-shot settings, ranging from 1-shot to 16-shot.

Key Results

  • Performance Gains: HierICRF-BERT achieved massive improvements, with Micro-F1 scores increasing by an average of 28.80% and Macro-F1 by 36.29% over previous state-of-the-art (SOTA) baselines in few-shot settings.
  • Hierarchical Consistency: The framework achieved SOTA results in path-based consistency (P-metric), ensuring that predicted child labels almost always have their correct ancestral paths.
  • Data Efficiency: On DBpedia, HierICRF maintained a PMicro-F1 of over 84% in a 1-shot scenario, whereas traditional fine-tuning methods failed completely.

Conclusion

HierICRF demonstrates that treating hierarchy as a path-routing problem within a language modeling space is highly effective for few-shot HTC. By enabling "hierarchical consistency self-correction" through iterative reasoning and a structured CRF layer, the model successfully transfers unstructured PLM knowledge to complex domain hierarchies. Future work may explore applying these iterative reasoning principles to larger models through pure prompting or in-context learning.

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