Learning Easily Updated General Purpose Text Representations with Adaptable Task-Specific Prefix

Kuan-Hao Huang, Liang Tan, Rui Hou, Sinong Wang, Amjad Almahairi, Ruty RinottEMNLP 2023

Abstract

This paper introduces a modular framework for developing general-purpose text representations by training independent, task-specific prefixes for a frozen language model. Unlike traditional multi-task learning (MTL), which is computationally rigid and prone to task interference, this prefix-based approach allows for the dynamic addition, removal, or updating of source tasks. Experimental results across 15 datasets demonstrate that this approach not only improves generalization to new target tasks but also significantly reduces the cost of updating representations, offering a flexible "plug-and-play" architecture for modern NLP.

Introduction

In modern NLP, large pre-trained language models (LLMs) like RoBERTa or GPT are standard. However, fine-tuning a massive model for every individual task is computationally expensive. A common alternative is to "freeze" the LLM and use it as a fixed feature extractor, building lightweight classifiers on top. The challenge lies in making these fixed representations robust enough to handle diverse, unseen tasks. While Multi-Task Learning (MTL) is typically used to bake general knowledge into representations, it acts as a "black box": adding a new source task or removing a performance-degrading one usually requires retraining the entire model from scratch.

Methods

The authors propose a method based on Prefix Tuning (specifically P-Tuning v2). Instead of modifying the model's weights, they learn a small set of "virtual tokens" (a prefix) prepended to the input at every layer of the Transformer.

Overview of the training and inference stages for modular task-specific prefixes.

The architecture relies on two key principles:

  1. Independent Training: A unique prefix is trained for each source task (e.g., Natural Language Inference, Sentiment Analysis) while the underlying LLM remains frozen.
  2. Modular Combination: During inference, these learned prefixes are concatenated into a single "super-prefix." This combined prefix guides the frozen LLM to produce a multi-faceted text representation, which is then used to train small classifiers for new "target" tasks.

This modularity allows developers to update the system by simply adding or removing task prefixes without touching the base model or retraining existing components.

Experimental Setup

The study utilized 15 diverse NLP datasets. Source Tasks (used to train prefixes) included large-scale datasets like MNLI, QNLI, QQP, SST-2, Yelp-2, ReCoRD, and WinoGrande. Target Tasks (used for evaluation) included smaller datasets such as RTE, MRPC, CR, MR, MPQA, BoolQ, MultiRC, and CosmosQA. The goal was to evaluate how well prefixes trained on source tasks could generalize to help the model perform on new target tasks.

Key Results and Insights

Superior Generalization and Efficiency

The prefix-based method achieved an average score of 83.85% across target tasks, outperforming standard Multi-Task Learning (82.44%). Crucially, the prefix-based approach maintained high performance even with fewer training steps per round, whereas MTL performance often suffered as it struggled to balance gradient updates across an increasing number of tasks.

Comparison of Prefix-Based vs. Multi-Tasking performance across training rounds.

Mitigating Task Interference

The researchers found that training prefixes independently avoids "task interference," where different objectives pull a single model in conflicting directions. Furthermore, the modularity allows for the discovery of "hurtful tasks." For instance, removing the SST-2 (sentiment) prefix improved performance on certain reasoning tasks. By manually removing the most hurtful prefixes for each target task, the authors achieved a peak average performance of 84.97%.

Conclusion and Future Work

Modular prefixes provide a "hot-swappable" way to manage general-purpose text representations. This approach approaches the performance of full-model fine-tuning (86.87%) while remaining efficient enough for production environments. Future research will focus on scaling this approach to hundreds of tasks and developing automated strategies for prefix selection to optimize performance for specific inputs dynamically.

Summary updated

BibTeX
@inproceedings{huang2023learning,
  author = {Kuan-Hao Huang and Liang Tan and Rui Hou and Sinong Wang and Amjad Almahairi and Ruty Rinott},
  title = {{Learning Easily Updated General Purpose Text Representations with Adaptable Task-Specific Prefix}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2023},
  url = {https://openreview.net/forum?id=n41QMbmnnn},
}
Figure