arXiv(opens in a new tab)Computer ScienceApr 2020Cited by 6 papers on PaperVantage

Manuscript Offprint

arXiv:2004.10964

Don’t Stop Pretraining: Adapt Language Models to Domains and Tasks

Suchin Gururangan, Ana Marasović, Swabha Swayamdipta, Kyle Lo, Iz Beltagy, Doug Downey, Noah A. Smith

Abstract

Language models pretrained on text from a wide variety of sources form the foundation of today’s NLP. In light of the success of these broad-coverage models, we investigate whether it is still helpful to tailor a pretrained model to the domain of a target task. We present a study across four domains (biomedical and computer science publications, news, and reviews) and eight classification tasks, showing that a second phase of pretraining in-domain (domain-adaptive pretraining) leads to performance gains, under both high- and low-resource settings. Moreover, adapting to the task’s unlabeled data (task-adaptive pretraining) improves performance even after domain-adaptive pretraining. Finally, we show that adapting to a task corpus augmented using simple data selection strategies is an effective alternative, especially when resources for domain-adaptive pretraining might be unavailable. Overall, we consistently find that multi-phase adaptive pretraining offers large gains in task performance.

1 Introduction

Figure

Figure 1: An illustration of data distributions. Task data is comprised of an observable task distribution, usually non-randomly sampled from a wider distribution (light grey ellipsis) within an even larger target domain, which is not necessarily one of the domains included in the original LM pretraining domain – though overlap is possible. We explore the benefits of continued pretraining on data from the task distribution and the domain distribution.

Today’s pretrained language models are trained on massive, heterogeneous corpora Raffel et al. (2019); Yang et al. (2019). For instance, RoBERTa Liu et al. (2019) was trained on over 160GB of uncompressed text, with sources ranging from English-language encyclopedic and news articles, to literary works and web content. Representations learned by such models achieve strong performance across many tasks with datasets of varying sizes drawn from a variety of sources (Wang et al., 2018; Wang et al., 2019, e.g., ). This leads us to ask whether a task’s textual domain—a term typically used to denote a distribution over language characterizing a given topic or genre (such as “science” or “mystery novels”)—is still relevant. Do the latest large pretrained models work universally or is it still helpful to build separate pretrained models for specific domains?

While some studies have shown the benefit of continued pretraining on domain-specific unlabeled data (Lee et al., 2019, e.g.,), these studies only consider a single domain at a time and use a language model that is pretrained on a smaller and less diverse corpus than the most recent language models. Moreover, it is not known how the benefit of continued pretraining may vary with factors like the amount of available labeled task data, or the proximity of the target domain to the original pretraining corpus (see Figure 1).

We address this question for one such high-performing model, RoBERTa Liu et al. (2019) (§2). We consider four domains (biomedical and computer science publications, news, and reviews; §3) and eight classification tasks (two in each domain). For targets that are not already in-domain for RoBERTa, our experiments show that continued pretraining on the domain (which we refer to as domain-adaptive pretraining or dapt) consistently improves performance on tasks from the target domain, in both high- and low-resource settings.

Above, we consider domains defined around genres and forums, but it is also possible to induce a domain from a given corpus used for a task, such as the one used in supervised training of a model. This raises the question of whether pretraining on a corpus more directly tied to the task can further improve performance. We study how domain-adaptive pretraining compares to task-adaptive pretraining, or tapt, on a smaller but directly task-relevant corpus: the unlabeled task dataset (§4), drawn from the task distribution. Task-adaptive pretraining has been shown effective Howard and Ruder (2018), but is not typically used with the most recent models. We find that tapt provides a large performance boost for RoBERTa, with or without domain-adaptive pretraining.

Finally, we show that the benefits from task-adaptive pretraining increase when we have additional unlabeled data from the task distribution that has been manually curated by task designers or annotators. Inspired by this success, we propose ways to automatically select additional task-relevant unlabeled text, and show how this improves performance in certain low-resource cases (§5). On all tasks, our results using adaptive pretraining techniques are competitive with the state of the art.

In summary, our contributions include:

  • a thorough analysis of domain- and task-adaptive pretraining across four domains and eight tasks, spanning low- and high-resource settings;
  • an investigation into the transferability of adapted LMs across domains and tasks; and
  • a study highlighting the importance of pretraining on human-curated datasets, and a simple data selection strategy to automatically approach this performance.

Our code as well as pretrained models for multiple domains and tasks are publicly available.

DomainPretraining Corpus# TokensSizeL\textscRoB.\mathcal{L}_{\textsc{RoB.}}L\textscdapt\mathcal{L}_{\textsc{{dapt} }}
BioMed2.68M full-text papers from S2ORC (Lo et al., 2020)7.55B47GB1.320.99
CS2.22M full-text papers from S2ORC (Lo et al., 2020)8.10B48GB1.631.34
News11.90M articles from RealNews Zellers et al. (2019)6.66B39GB1.081.16
Reviews24.75M Amazon reviews (He and McAuley, 2016)2.11B11GB2.101.93
RoBERTa (baseline)see Appendix §A.1N/A160GB‡1.19-

Table 1: List of the domain-specific unlabeled datasets. In columns 5 and 6, we report RoBERTa’s masked LM loss on 50K randomly sampled held-out documents from each domain before (L\textscRoB.\mathcal{L}_{\textsc{RoB.}}) and after (L\textscdapt\mathcal{L}_{\textsc{{dapt} }}) dapt (lower implies a better fit on the sample). ‡\ddagger indicates that the masked LM loss is estimated on data sampled from sources similar to RoBERTa’s pretraining corpus.