On the Importance of Attention in Meta-Learning for Few-Shot Text Classification

Xiang Jiang, Mohammad Havaei, Gabriel Chartrand, Hassan Chouaib, Thomas Vincent, Andrew Jesson, Nicolas Chapados, Stan MatwinarXiv 2018

Abstract

Few-shot text classification is a critical challenge in Natural Language Processing, where models must generalize from extremely limited labeled data. We present Attentive Task-Agnostic Meta-Learning (ATAML), a framework that enhances the Model-Agnostic Meta-Learning (MAML) algorithm by decoupling general language representation from task-specific attention. By constraining the model to adapt only its attention and classification parameters during new tasks, ATAML mitigates overfitting on spurious correlations and improves cross-task generalization. Our results on benchmark datasets demonstrate that ATAML significantly outperforms standard meta-learning approaches.

Introduction

Deep learning models typically require vast amounts of labeled data to achieve high performance. In many specialized domains, such as medical record classification or emerging social media trend analysis, obtaining thousands of examples per category is infeasible. In these "few-shot" scenarios (e.g., 1 to 5 examples per class), standard supervised learning often fails due to overfitting on idiosyncratic features of the small training set or task interference during multi-task pre-training.

Methodology: Attentive Task-Agnostic Meta-Learning

The proposed ATAML framework builds upon the Model-Agnostic Meta-Learning (MAML) paradigm. While MAML seeks a global initialization for all parameters to facilitate rapid adaptation, ATAML introduces a "separation of concerns" by partitioning the model parameters into two distinct sets:

  1. Shared Parameters ($\theta_E$): These belong to the encoder (e.g., a Temporal Convolutional Network or LSTM) and learn general, task-agnostic text representations.
  2. Task-Specific Parameters ($\theta_T$): These encompass the attention mechanism and the final classifier. These "fast weights" are the only parameters adapted during the inner loop of meta-training.
Algorithm 1: The Attentive Task-Agnostic Meta-Learner (ATAML) training procedure.

During meta-training, the model processes "episodes" consisting of small batches of tasks. In the inner loop, only $\theta_T$ is updated to fit the specific task. In the outer loop, both $\theta_E$ and $\theta_T$ are optimized to ensure the shared encoder provides a representation that maximizes the effectiveness of the attention-based adaptation. Crucially, during meta-testing, the encoder $\theta_E$ remains frozen, acting as a regularizer that prevents the model from distorting its general linguistic understanding to fit noisy, few-shot data.

Experimental Results

The authors evaluated ATAML using "mini" versions of standard benchmarks, including miniRCV1 (a subset of the Reuters Corpus Volume I) and miniReuters-21578. These datasets include both single-label and multi-label classification tasks.

ATAML consistently outperformed MAML, pretrained baselines, and random initialization. As shown in Table 1, ATAML achieved a significant performance boost in the 5-way 1-shot setting on miniRCV1.

Table 1: Few-shot classification accuracy on the miniRCV1 dataset, comparing ATAML against MAML and other baselines.

Key Insights

  • Synergy of Attention and Meta-Learning: Constraining the text embedding to be shared across tasks forces the attention mechanism to become more "surgical," identifying task-relevant phrases (e.g., "regulation of") rather than isolated words that might be spurious correlations.
  • Architecture Selection: Temporal Convolutional Networks (TCNs) were found to be superior base learners compared to LSTMs. LSTMs often suffered from early saturation during meta-training, making it difficult for the meta-learner to converge on a globally useful representation.

Conclusion

ATAML demonstrates that the strategic separation of task-agnostic representations and task-specific attention is vital for few-shot text classification. By freezing the encoder during adaptation, the model maintains a robust understanding of language structure while remaining flexible enough to identify task-specific nuances through attention. Future work may explore extending this framework to other few-shot NLP tasks such as Named Entity Recognition and incorporating automated threshold calibration for multi-label settings.

Summary updated

BibTeX
@misc{jiang2018importance,
  author = {Xiang Jiang and Mohammad Havaei and Gabriel Chartrand and Hassan Chouaib and Thomas Vincent and Andrew Jesson and Nicolas Chapados and Stan Matwin},
  title = {{On the Importance of Attention in Meta-Learning for Few-Shot Text Classification}},
  year = {2018},
  eprint = {1806.00852},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1806.00852},
}
Figure