Dynamically Route Hierarchical Structure Representation to Attentive Capsule for Text Classification

Wanshan Zheng, Zibin Zheng, Hai Wan, Chuan ChenIJCAI 2019

Abstract

The HAC (Hierarchical structure feature to Attentive Capsule) model addresses the limitations of traditional text classification models in capturing multi-scale linguistic structures. By integrating deep dilated CNNs with a modified capsule network featuring dynamic routing and an attention mechanism, HAC automatically extracts and aggregates hierarchical features from words to clauses. Experimental results across 11 benchmark datasets demonstrate that HAC consistently outperforms state-of-the-art baselines, offering improved representation learning and information preservation during feature aggregation.

Introduction

Effective text classification relies on two critical components: representation learning and feature aggregation. Despite the success of deep learning, current models face significant hurdles. First, many architectures struggle with rigid structure learning. Standard CNNs use fixed-size filters, while RNNs may fail to capture long-range dependencies without external parsers. These models often fail to automatically identify adaptive features, such as recognizing that a specific multi-word phrase carries more weight than its constituent parts.

Second, common aggregation techniques like max-pooling often lead to information loss. While Capsule Networks were introduced to model "part-whole" relationships and preserve spatial information, existing implementations often lose diversity when flattening capsules for final classification. The HAC model is designed to overcome these challenges by treating intermediate layers as distinct structural representations and using an intelligent routing-aggregation mechanism.

Methods

The HAC architecture is composed of four primary stages designed to mimic the human process of building meaning from words to complex ideas:

  1. Contextual Encoding: The process begins with a Bi-directional Gated Recurrent Unit (Bi-GRU) that processes the input text to capture fundamental word-level context.
  2. Deep Dilated Convolution Layer: Instead of standard convolutions, HAC utilizes dilated CNNs. Dilation allows the receptive field to grow exponentially with depth. Consequently, lower layers naturally represent words and short phrases, while deeper layers capture broader structures like clauses and full sentences.
  3. Dynamic Routing Capsule Layer: For every level of the CNN, a capsule layer is applied. An iterative dynamic routing process clusters these raw features into task-relevant categories. A key innovation here is the "orphan category" capsule, which acts as a sink for "background noise" such as stop words (e.g., "the", "a"), preventing them from interfering with the primary classification task.
  4. Attentive Aggregation Layer: Unlike models that only consider the final layer, HAC aggregates capsules from all structural levels. A trainable attention mechanism weights these levels (e.g., prioritizing a specific 4-gram phrase over a 16-gram fragment) to produce the final prediction.
The HAC architecture overview, illustrating the flow from word embeddings through dilated convolutions to the attentive capsule aggregation layer.

Experimental Results

The HAC model was evaluated on a comprehensive battery of 11 benchmark datasets, ranging from small-scale sentiment tasks (MR, SST-1, SST-2) to large-scale news and ontology datasets (AG News, DBPedia).

Performance Comparison

HAC achieved superior performance, securing the best classification accuracy on 5 out of 7 small datasets without transfer learning. When augmented with ELMo embeddings (HAC+ELMo), it outperformed all baselines on 6 out of 7 small datasets, reaching 85.0% on MR and 89.4% on SST-2. On large-scale datasets, the model remained highly competitive, achieving 93.7% accuracy on AG News and 99.2% on DBPedia.

Performance comparison of the HAC model against various RNN, CNN, and transfer learning baselines across seven benchmark datasets.

Ablation and Interpretability

Ablation studies confirmed that every component of the architecture is vital. Removing intermediate features, capsule routing, or the attentive aggregation layer resulted in significant performance drops. Furthermore, visualizations of the attention weights demonstrated that the model successfully ignores background noise and focuses on salient linguistic indicators, such as identifying "humor" or "cheesy effects" as primary sentiment drivers in movie reviews.

Conclusion and Future Work

The HAC model demonstrates that combining hierarchical structure learning with dynamic capsule routing and attention provides a robust framework for text classification. While the iterative routing process introduces some computational overhead, the gains in accuracy and interpretability are substantial. Future research may focus on making the hierarchical depth adaptive to input length or extending this architecture to sequence labeling and text generation tasks.

Summary updated

BibTeX
@inproceedings{zheng2019dynamically,
  author = {Wanshan Zheng and Zibin Zheng and Hai Wan and Chuan Chen},
  title = {{Dynamically Route Hierarchical Structure Representation to Attentive Capsule for Text Classification}},
  booktitle = {International Joint Conference on Artificial Intelligence},
  year = {2019},
  doi = {10.24963/ijcai.2019/759},
}
Figure