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

Kuan-Hao Huang, Liang Tan, Rui Hou, Sinong Wang, Amjad Almahairi, Ruty Rinott · OpenReview

Abstract: Many real-world applications require making multiple predictions from the same text. Fine-tuning a large pre-trained language model for each downstream task causes computational burdens in the inference time due to several times of forward passes. To amortize the computational cost, freezing the language model and building lightweight models for downstream tasks based on fixed text representations are common solutions. Accordingly, how to learn fixed but general text representations that can generalize well to unseen downstream tasks becomes a challenge. Previous works have shown that the generalizability of representations can be improved by fine-tuning the pre-trained language model with some source tasks in a multi-tasking way. In this work, we propose a prefix-based method to learn the fixed text representations with source tasks. We learn a task-specific prefix for each source task independently and combine them to get the final representations. Our experimental results show that prefix-based training performs better than multi-tasking training and can update the text representations at a smaller computational cost than multi-tasking training.

1. Introduction

In modern Natural Language Processing (NLP), practitioners often face a significant trade-off between model performance and computational efficiency. Fine-tuning massive pre-trained language models (PLMs) like RoBERTa for every specific downstream task—such as sentiment analysis or question answering—typically yields state-of-the-art results. However, this approach is computationally expensive at scale. If a system requires predictions for ten different tasks, it must perform ten separate forward passes through a giant model for every input text.

To mitigate these costs, a common strategy is to "freeze" the PLM and use it as a static feature extractor (an encoder). Lightweight "head" models are then built on top of these fixed representations. While efficient, raw frozen models often lack the specialized knowledge required to produce high-quality representations for diverse tasks. Multi-Task Learning (MTL) is often used to address this by training a single model on multiple tasks simultaneously. Yet, MTL creates a "monolithic" architecture: adding a new task or removing a problematic one requires retraining the entire system from scratch, which is impractical for rapidly evolving production environments.

2. Methodology: Adaptable Task-Specific Prefixes

This paper introduces a modular alternative based on Prefix Tuning. Instead of modifying the underlying model's weights, the researchers propose learning a "prefix"—a small set of trainable parameters added to the keys and values of the Transformer's attention layers.

The framework operates in two distinct stages:

  • Independent Training: For each "source task" (e.g., natural language inference), a unique prefix is trained while the main language model (RoBERTa-large) remains completely frozen. This ensures that tasks do not interfere with one another during the learning process.
  • Modular Concatenation: During the inference stage, these independently learned prefixes are concatenated. This combined prefix acts as a specialized "lens" through which the frozen model processes text, generating a fixed representation that is significantly richer and more generalizable than the raw model output.
Overview of the proposed framework, showing independent prefix training (a) and modular concatenation during inference (b).

This approach is inherently "plug-and-play." If a specific source task is found to negatively impact performance on a certain target task, its corresponding prefix can be removed from the pool without any retraining.

3. Experimental Setup

The study evaluates the proposed method using a diverse array of NLP benchmarks:

  • Source Tasks (7 datasets): These are used to train the initial prefixes and include MNLI/QNLI (Inference), QQP (Paraphrase), SST-2/Yelp-2 (Sentiment), ReCoRD (QA), and WinoGrande (Commonsense).
  • Target Tasks (8 datasets): These evaluate the generalizability of the learned representations. They include RTE, MRPC, CR, MR, MPQA, BoolQ, MultiRC, and CosmosQA.

4. Key Results and Discussion

The experimental results demonstrate that the prefix-based approach offers several advantages over traditional MTL:

Superior Generalization: The prefix-based method achieved an average score of 83.85% across target tasks, notably outperforming standard Multi-Task Learning, which averaged 82.44%. This suggests that independent task training prevents the "dominant task" problem, where large datasets overpower smaller ones in a shared training environment.

Efficiency in Updates: One of the most significant findings involves the system's ability to handle updates. When adding source tasks sequentially, the prefix method maintained high performance even with limited training steps. In contrast, MTL performance often suffers because it must redistribute its training capacity across an ever-growing list of tasks.

Performance comparison between prefix-based and multi-tasking approaches across training rounds, showing the stability and superiority of the prefix method.

Task Pruning: The modularity of the system allows for "pruning." By identifying and removing "hurtful" source tasks (for instance, removing sentiment-focused prefixes when performing logic-heavy tasks), the researchers were able to boost average accuracy to 84.97%.

5. Conclusion and Future Work

The proposed prefix-based framework provides a scalable and efficient way to generate high-quality, updatable text representations. By decoupling task-specific knowledge from the core language model, it allows for rapid iteration in production settings.

Future research will focus on scaling this approach to hundreds of source tasks and investigating its effectiveness on structural or syntax-related NLP tasks. Additionally, as with all systems built on large PLMs, further auditing is required to ensure that these representations do not inadvertently amplify biases present in the original training data.

Summary updated

BibTeX
@misc{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 Prefixes}},
  year = {2023},
  eprint = {2305.13499},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2305.13499},
}
Figure