[Paper Review] Grad2Task: Improved Few-shot Text Classification Using Gradients for Task Representation
This paper proposes Grad2Task, a novel few-shot text classification method that uses gradient information from a base model to represent tasks, enabling efficient adaptation of a fine-tuned BERT-based classifier. By conditioning adapter modules on these gradient-based task representations, the approach achieves state-of-the-art performance across diverse few-shot text classification tasks, outperforming traditional fine-tuning, sequential transfer learning, and meta-learning baselines.
Large pretrained language models (LMs) like BERT have improved performance in many disparate natural language processing (NLP) tasks. However, fine tuning such models requires a large number of training examples for each target task. Simultaneously, many realistic NLP problems are "few shot", without a sufficiently large training set. In this work, we propose a novel conditional neural process-based approach for few-shot text classification that learns to transfer from other diverse tasks with rich annotation. Our key idea is to represent each task using gradient information from a base model and to train an adaptation network that modulates a text classifier conditioned on the task representation. While previous task-aware few-shot learners represent tasks by input encoding, our novel task representation is more powerful, as the gradient captures input-output relationships of a task. Experimental results show that our approach outperforms traditional fine-tuning, sequential transfer learning, and state-of-the-art meta learning approaches on a collection of diverse few-shot tasks. We further conducted analysis and ablations to justify our design choices.
Motivation & Objective
- To address the challenge of few-shot text classification where labeled examples per class are extremely limited.
- To improve generalization in few-shot learning by leveraging gradient information as a more expressive task representation than input encoding.
- To enable effective transfer from a diverse set of source tasks with varying label semantics and structures.
- To develop an efficient, parameter-efficient adaptation mechanism using adapter modules within a pretrained BERT model.
- To outperform existing fine-tuning, sequential transfer learning, and meta-learning methods on few-shot text classification benchmarks.
Proposed method
- Task representation is constructed using the full gradient of the loss with respect to the model parameters on a few-shot support set, capturing input-output relationships.
- A conditional neural process (CNAP) framework is adopted, where the adaptation network modulates adapter parameters based on the gradient-based task embedding.
- Pretrained BERT with bottleneck adapter modules is used as the feature extractor to maintain efficiency and parameter sharing.
- Labels are treated as text tokens and encoded via BERT to form part of the task representation, combined with input and gradient features.
- The adaptation network generates scaling and shifting parameters for the adapter layers, enabling fast, task-specific adaptation during inference.
- The model is trained end-to-end using cross-entropy loss on support sets, with gradient-based task features used to condition the adaptation network.
Experimental results
Research questions
- RQ1Can gradient-based representations of few-shot tasks improve few-shot text classification beyond input-based task representations?
- RQ2Does using gradient information as a task embedding lead to better generalization across diverse, structurally different text classification tasks?
- RQ3How does the proposed method compare to traditional fine-tuning and state-of-the-art meta-learning approaches in few-shot settings?
- RQ4What is the impact of different design choices, such as modulating all tokens vs. only the [CLS] token, on model performance?
- RQ5Can a hypernetwork-based parameter generation approach outperform the proposed adaptation mechanism in this few-shot setting?
Key findings
- Grad2Task achieves an average accuracy of 45.83% across 10 diverse few-shot text classification tasks, outperforming traditional fine-tuning and sequential transfer learning.
- The method surpasses state-of-the-art meta-learning baselines, including CNAP, by a significant margin, with a 1.2% absolute improvement over the next best baseline.
- Using gradient-based task representation yields better performance than input encoding or label encoding alone, with the ablation study showing a 1.5% drop when replacing gradients with average input embeddings.
- Modulating only the [CLS] token’s representation leads to worse performance (44.57%) compared to adapting all tokens, indicating the importance of full-sequence adaptation.
- A hypernetwork-based parameter generation approach achieves 44.79% accuracy, which is worse than Grad2Task, suggesting that direct adaptation of adapter parameters is more effective and less prone to overfitting.
- Pretraining the task embedding model yields 45.68% accuracy, slightly worse than the proposed method, indicating that end-to-end training is more effective for this setup.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.