Making Language Model a Hierarchical Classifier and Generator

Yihong Wang, Zhonglin Jiang, Ningyuan Xi, Yue Zhao, Qingqing Gu, Xiyuan Chen, Hao Wu, Sheng Xu, Hange Zhou, Yong Chen, Luo JiarXiv 2025 · OpenReview

Abstract

Standard decoder-only language models typically decode only at the final layer. Inspired by human hierarchical reasoning, we propose a Hierarchical Decoding Classifier (HDC) architecture where multiple intermediate layers decode information simultaneously. By adapting pretrained language models through the replication of language heads at intermediate layers and fine-tuning them with hierarchical task inputs, we demonstrate that these layers can produce meaningful, structured content. HDC achieves state-of-the-art performance across hierarchical text classification and generation tasks, including benchmarks like WoS and DBpedia, while offering significant computational savings.

The Problem: Flat Decoding in a Hierarchical World

Modern Large Language Models (LLMs) like GPT-4 or Llama 3 are architecturally "flat." They process information through a deep stack of layers but only output a token at the very end. This contrasts sharply with human cognition, where we often make high-level strategic decisions (e.g., "I am writing a medical paper") before attending to fine-grained details (e.g., "This section discusses cardiology").

For complex tasks like hierarchical text classification (HTC), standard models often require Chain-of-Thought (CoT) prompting. While effective, CoT is computationally expensive because it generates extra tokens. Furthermore, standard LLMs lack an internal mechanism to explicitly separate high-level planning from low-level execution, often leading to suboptimal performance on deeply nested reasoning tasks.

Methods: The Hierarchical Decoding Classifier (HDC)

HDC transforms a standard pretrained LLM into a hierarchical reasoner through a process of "post-hoc adaptation":

  1. Multi-Layer Decoding: Language heads (the components that map internal vectors to vocabulary) are copied from the final layer and initialized at selected intermediate layers.
  2. Recursive Training: During fine-tuning, the model is trained to output coarse-grained labels at early layers. The resulting internal latent vector, combined with the decoded response, is passed to deeper layers to refine the output into more specific, fine-grained categories.
  3. Joint Loss Optimization: The model is optimized using a weighted sum of losses from all active decoding layers, ensuring each layer learns to "speak" task-relevant content at the appropriate level of abstraction.
  4. Two-Pass Inference: This recursive flow creates a "state-space" style of reasoning within the transformer blocks, where early-layer outputs serve as grounded context for subsequent layers.

Datasets and Evaluation

The researchers evaluated HDC on several rigorous benchmarks:

  • WoS (Web of Science): Paper abstracts with a 2-level hierarchy.
  • DBpedia: Wikipedia-based structured data with a 3-level hierarchy.
  • ESconv & EmpatheticDialogues: Tasks involving emotional support and empathetic conversation (classification-guided generation).
  • Cognitive Tests: Assessments of the model's internal reasoning and "theory of mind."

Key Results

HDC established new state-of-the-art (SOTA) benchmarks for hierarchical classification. On the WoS dataset, HDC achieved a Micro-F1 score of 88.40, significantly outperforming specialized BERT-based models and standard supervised fine-tuning (SFT).

Performance comparison of HDC against retrieval-based and BERT-based baselines on WoS and DBpedia datasets.

Beyond raw accuracy, the model demonstrated impressive efficiency. By handling coarse-grained tasks at earlier layers, HDC achieved computational speedups ranging from 7% to 26% compared to standard inference methods.

Ablation and Architectural Insights

To understand why HDC succeeds, the authors conducted an ablation study comparing it against "cascade" models (using separate LLMs for different levels) and "multi-hop" models (re-running the same model multiple times). HDC consistently outperformed these alternatives, suggesting that maintaining the reasoning chain within a single, hierarchically-organized model is more effective than splitting the task.

Ablation study results for HDC, comparing it against various architectural configurations and non-practical baselines.

Key Insights

  • Educated Intermediate Layers: Intermediate layers (e.g., layer 16 of a 32-layer model) are capable of producing highly accurate abstract labels without requiring the full depth of the network.
  • Internal Consistency: Forcing the model to decode at multiple stages creates a "recursive chain of layer latents," which acts as a more natural hierarchical thinker than standard models that might "forget" high-level strategy by the final layer.

Limitations and Future Directions

While HDC shows the power of adapting existing models, the authors suggest that pretraining a hierarchical model from scratch could unlock even greater potential. Current limitations include the manual selection of intermediate "thinking" layers and the potential for hardware ceilings if reasoning chains become extremely deep. Future work will focus on automating layer selection and exploring the architecture's scalability for more complex reasoning tasks.

Summary updated

BibTeX
@misc{wang2025making,
  author = {Yihong Wang and Zhonglin Jiang and Ningyuan Xi and Yue Zhao and Qingqing Gu and Xiyuan Chen and Hao Wu and Sheng Xu and Hange Zhou and Yong Chen and Luo Ji},
  title = {{Making Language Model a Hierarchical Classifier and Generator}},
  year = {2025},
  eprint = {2507.12930},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2507.12930},
}
Figure