To Tune or Not to Tune? Adapting Pretrained Representations to Diverse Tasks

Matthew E. Peters, Sebastian Ruder, Noah A. Smith

TL;DR

This paper investigates the optimal way to adapt powerful pre-trained language models (like ELMo and BERT) to new NLP tasks. They discover that the best approach—either freezing the model's weights (feature extraction) or updating them (fine-tuning)—depends heavily on how similar the new task is to the original pre-training task. This insight leads to practical guidelines for practitioners.

What Problem Does This Paper Address?

Modern NLP relies heavily on pre-trained language models that learn general language understanding from massive text datasets. However, once you have these powerful models, a crucial question arises: how do you best adapt them to a specific downstream task (e.g., sentiment analysis, question answering)? The two main strategies are:

  1. Feature Extraction: Treat the pre-trained model as a fixed feature extractor. You feed your task-specific data through it, get the representations, and then train a smaller, task-specific model on top of these features. The pre-trained model's weights remain unchanged.
  2. Fine-Tuning: Take the pre-trained model and continue training it on your specific task data, allowing its weights to be updated. This essentially "tunes" the model to the new task.

While both methods are used, it's not always clear which one will yield better results for a given task. This paper aims to systematically compare these two adaptation strategies across a variety of NLP tasks and state-of-the-art models to understand when each approach shines and why.

Methods

The authors compare two leading pre-trained models: ELMo (which uses LSTMs) and BERT (which uses the Transformer architecture). They evaluate two primary adaptation methods:

  • Feature Extraction: For both ELMo and BERT, they extract contextual word representations from all layers. A learned linear combination of these layer representations is then used as input to a task-specific model. For different tasks, they employ established architectures like BiLSTM-CRF for NER, a bi-attentive classification network for sentiment analysis, and the ESIM model for sentence-pair tasks.
  • Fine-Tuning: For ELMo, they adapt it for classification and sentence-pair tasks by max-pooling its states and adding a softmax layer, or using cross-sentence bi-attention. For BERT, they use a softmax layer for classification and sentence-pair tasks, and a CRF layer for NER, following established practices.

Crucially, they conduct extensive hyper-parameter tuning for each task and model combination to ensure a fair comparison. They also explore the impact of adding extra parameters (like a CRF layer) and analyze how information is distributed across different layers of the pre-trained models.

Datasets

The paper evaluates their methods on a diverse set of standard NLP tasks and datasets:

  • Named Entity Recognition (NER): CoNLL 2003
  • Sentiment Analysis (SA): Stanford Sentiment Treebank (SST-2)
  • Natural Language Inference (NLI): MultiNLI and SICK-E
  • Paraphrase Detection (PD): Microsoft Research Paraphrase Corpus (MRPC)
  • Semantic Textual Similarity (STS): STS-B and SICK-R

They do not introduce new benchmarks but leverage existing ones to test the generalizability of their findings.

Key Insights and Ideas

  • Task Similarity is Key: The most significant finding is that the choice between feature extraction and fine-tuning hinges on the similarity between the pre-training task and the target task.
  • When tasks are closely aligned (e.g., pre-training on next-sentence prediction and fine-tuning on sentence-pair tasks), fine-tuning often yields better results.
  • When tasks are more dissimilar, feature extraction can be competitive or even superior.
  • Model Architecture Matters: The underlying architecture of the pre-trained model influences adaptation. Transformers (like BERT), which inherently model long-range dependencies, seem better suited for sentence-pair tasks than LSTMs (like ELMo) without explicit cross-sentence attention mechanisms.
  • Layer-wise Information: Analysis using diagnostic classifiers and mutual information reveals that for single-sentence tasks, relevant information is concentrated in the upper layers of the pre-trained model. For sentence-pair tasks, information is built up more gradually across intermediate and upper layers, suggesting a need for more extensive adaptation.
  • Fine-tuning ELMo Can Be Tricky: Fine-tuning ELMo was found to be initially difficult and required careful hyper-parameter tuning, including discriminative learning rates and gradual unfreezing.

Key Results

  • General Performance: Both ELMo and BERT, when adapted using either method, significantly outperform older sentence embedding methods like Skip-thoughts.
  • ELMo vs. Fine-tuning: For ELMo, fine-tuning generally outperformed feature extraction on sentence-pair tasks, while performance was comparable on other tasks.
  • BERT vs. Fine-tuning: For BERT, fine-tuning showed a strong advantage on STS tasks, with smaller differences on other tasks.
  • Parameter Impact: Adding a CRF layer was beneficial for fine-tuning BERT on NER but hurt performance when used with feature extraction.
  • Domain Independence: For BERT, the divergence between the pre-training domain (books/Wikipedia) and the target domain (MNLI) did not show a significant correlation with adaptation performance, suggesting a degree of domain robustness.

Limitations and Future Work

  • Hyper-parameter Sensitivity: The paper acknowledges that fine-tuning ELMo, in particular, can be sensitive to hyper-parameter choices, requiring careful tuning.
  • Task-Specific Architectures: While they use standard architectures for downstream tasks, the paper doesn't explore novel task-specific architectures that might further improve adaptation.
  • Future Directions: The authors suggest further exploration into the inductive biases of different model architectures and how they interact with adaptation strategies. They also hint at the need for more sophisticated methods to understand information flow within deep models.

Summary updated

BibTeX
@inproceedings{peters2019tune,
  author = {Matthew E. Peters and Sebastian Ruder and Noah A. Smith},
  title = {{To Tune or Not to Tune? Adapting Pretrained Representations to Diverse Tasks}},
  booktitle = {RepL4NLP @ ACL},
  year = {2019},
  url = {https://openreview.net/forum?id=zDAqjkpZI6t},
}
Figure