Ensembling Prompting Strategies for Zero-Shot Hierarchical Text Classification with Large Language Models

Mingxuan Xia, Zhijie Jiang, Haobo Wang, Junbo Zhao, Tianlei Hu, Gang Chen2025

Abstract

Hierarchical text classification aims to classify documents into multiple labels within a hierarchical taxonomy, making it an essential yet challenging task in natural language processing. Recently, using Large Language Models (LLM) to tackle hierarchical text classification in a zero-shot manner has attracted increasing attention due to their cost-efficiency and flexibility. Given the challenges of understanding the hierarchy, various HTC prompting strategies have been explored to elicit the best performance from LLMs. However, our empirical study reveals that LLMs are highly sensitive to these prompting strategies—(i) within a task, different strategies yield substantially different results, and (ii) across various tasks, the relative effectiveness of a given strategy varies significantly. To address this, we propose a novel ensemble method, HiEPS, which integrates the results of diverse prompting strategies to promote LLMs' reliability. We also introduce a path-valid voting mechanism for ensembling, which selects a valid result with the highest path frequency score. Extensive experiments on three benchmark datasets show that HiEPS boosts the performance of single prompting strategies and achieves SOTA results.

Introduction

Hierarchical Text Classification (HTC) involves assigning documents to structured categories within a taxonomy, such as academic disciplines or product hierarchies. While Large Language Models (LLMs) have demonstrated impressive zero-shot capabilities, their application to HTC is hindered by extreme sensitivity to prompting strategies. A strategy that performs well on one dataset (e.g., Web of Science) may underperform significantly on another (e.g., Amazon). Furthermore, standard ensemble techniques like majority voting often result in "hallucinated" paths—combinations of labels that are logically inconsistent with the underlying taxonomy (e.g., a sub-category paired with the wrong parent).

To address these hurdles, this paper introduces HiEPS (Hierarchical Ensemble Prompting Strategy), a framework that ensembles multiple diverse prompting strategies and uses a novel "path-valid voting" mechanism to ensure the final classification follows the rules of the taxonomy.

The HiEPS Framework

The HiEPS framework consists of three main components designed to maximize the reliability of LLM outputs in hierarchical settings.

Diverse Prompting Suite

Instead of relying on a single "best" prompt, HiEPS utilizes a combination of Local Strategies and Global Strategies. Local strategies, such as Per-path, Per-parent, or Flattened prompting, simplify the task by focusing on specific sub-parts of the tree or individual layers. Global strategies, like Breadth-First Search (BFS) and Depth-First Search (DFS) representations, provide the model with a holistic view of the entire label hierarchy.

Comparison of Local and Global prompting strategies used in HiEPS.

As illustrated in the figure above, different strategies offer unique advantages. For instance, Per-parent prompting creates easy subtasks with small label spaces, while Flattened prompting allows the model to focus on the most precise leaf nodes. HiEPS also employs multi-answer prompting, encouraging the LLM to provide multiple candidate labels at each step to increase the likelihood that the correct label is captured within the ensemble.

Path-Valid Voting

The core innovation of HiEPS is the Path-Valid Voting mechanism. Traditional majority voting treats labels independently, which frequently leads to invalid paths—results that do not exist in the taxonomy. This occurs in roughly 7% to 24% of cases depending on the model and dataset.

Illustration of Path-Valid Voting vs. Majority Voting.

Path-Valid Voting resolves this by calculating a Path Frequency Score. It aggregates the frequency of each label across all prompts, weights them by their depth in the hierarchy (prioritizing specific, fine-grained labels), and then selects the valid path from the taxonomy with the highest cumulative score. This guarantees that the final output is always a "legal" classification path.

Experimental Evaluation

The researchers evaluated HiEPS on three widely used HTC benchmarks: WOS (Web of Science), DBpedia, and Amazon. The method was tested across a variety of models, including GPT-4o, Claude 3.5 Haiku, and open-source models like Qwen2.5-14B.

Key Results

  • Performance Boost: HiEPS consistently outperformed single-prompt strategies. On the DBpedia dataset using GPT-3.5, HiEPS improved Micro-F1 scores by 9.8% over the best single-prompt baseline.
  • Zero-Shot vs. Supervised: In a surprising finding, zero-shot HiEPS performed as well as a BERT model trained on 2,000 to 20,000 labeled examples, proving that ensembling can bridge the gap between out-of-the-box models and specialized supervised ones.
  • Efficiency: To mitigate the cost of multiple LLM calls, the authors introduced HiEPS-SS (Strategy Selection). This version discards redundant prompts, reducing computational costs by approximately 50% while maintaining high accuracy.

Conclusion

HiEPS demonstrates that the sensitivity of LLMs to prompting in hierarchical tasks can be turned into a strength through ensembling. By combining the "specialist" capabilities of different prompting styles and enforcing taxonomic constraints through path-valid voting, HiEPS achieves state-of-the-art zero-shot performance. Future work may extend this mechanism to multi-label settings and dynamic taxonomy expansion.

Summary updated

BibTeX
@misc{xia2025ensembling,
  author = {Mingxuan Xia and Zhijie Jiang and Haobo Wang and Junbo Zhao and Tianlei Hu and Gang Chen},
  title = {{Ensembling Prompting Strategies for Zero-Shot Hierarchical Text Classification with Large Language Models}},
  year = {2025},
  doi = {10.18653/v1/2025.emnlp-main.918},
}
Figure