NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Hierarchical Attention Prototypical Networks for Few-Shot Text Classification

Shengli Sun, Qingfeng Sun, Kevin Zhou, Tengchao LvEMNLP 2019

Abstract

Few-shot text classification remains a significant challenge due to the scarcity of labeled data and the presence of noise in natural language. We present the Hierarchical Attention Prototypical Network (HAPN), which enhances traditional Prototypical Networks by integrating attention mechanisms at the feature, word, and instance levels. This hierarchical approach allows the model to selectively focus on discriminative features and representative examples, leading to state-of-the-art performance, faster convergence, and improved robustness against noisy data.

Introduction

Deep learning models typically require vast amounts of labeled data to achieve high performance. However, in dynamic environments like chatbot intent detection, new categories must often be learned from only a few examples—a task known as Few-Shot Learning (FSL). Prototypical Networks serve as a common baseline, creating class "prototypes" by averaging embeddings of support instances. Yet, this simple averaging fails to distinguish between informative and noisy components within words, features, or instances. HAPN addresses these limitations by introducing a multi-level attention hierarchy to refine prototype construction.

Methods

HAPN improves upon the Prototypical Network architecture through three distinct attention layers:

  1. Feature-Level Attention: A CNN-based extractor assigns weights to individual dimensions of word embeddings, highlighting class-specific discriminative features.
  2. Word-Level Attention: This layer aggregates word hidden states into instance vectors, prioritizing keywords that carry the most semantic weight for a given task.
  3. Instance-Level Multi-Cross Attention: Unlike static prototypes, HAPN uses cross-attention between the support set and the target query. This allows the model to weight support instances based on their relevance to the specific query being classified.
The HAPN architecture illustrating the hierarchical attention layers from embedding to classification.

By dynamically adjusting prototypes based on context, HAPN ensures that the most relevant evidence is prioritized during classification.

Results and Discussion

The model was evaluated on the FewRel relation classification dataset and the CSID chatbot intent detection dataset. HAPN consistently outperformed baselines, achieving 84.16% accuracy on FewRel (10-way 5-shot) and 80.26% on CSID.

Loss and accuracy curves on the FewRel dataset comparing HAPN with ProtoNet and PHATT.

Key findings include:

  • Faster Convergence: HAPN reaches target accuracy levels significantly faster than standard Prototypical Networks, finding the semantic signal earlier in the training process.
  • Robustness to Noise: The hierarchical attention effectively filters out noise, allowing the model to benefit more from additional support instances compared to baseline methods.
  • Ablation Confirmation: Removing any level of the attention hierarchy (instance or word level) resulted in a performance drop, validating the necessity of the multi-layered approach.

Conclusion

The Hierarchical Attention Prototypical Network (HAPN) demonstrates that selective attention at multiple granularities is crucial for effective few-shot text classification. By intelligently weighting features, words, and instances, HAPN achieves superior accuracy and efficiency. Future work will explore more complex encoders like Transformers and the application of HAPN to broader industrial scenarios.

Summary updated

BibTeX
@inproceedings{sun2019hierarchical,
  author = {Shengli Sun and Qingfeng Sun and Kevin Zhou and Tengchao Lv},
  title = {{Hierarchical Attention Prototypical Networks for Few-Shot Text Classification}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2019},
  url = {https://openreview.net/forum?id=JBo5tNdOWm},
}
Figure