Domain Adaptation with BERT-based Domain Classification and Data Selection

Xiaofei Ma, Peng Xu, Zhiguo Wang, Ramesh Nallapati, Bing XiangDeepLo @ EMNLP 2019

Abstract

Pre-trained language models like BERT exhibit significant performance degradation when applied to target domains that differ from their source training data, a phenomenon known as domain shift. This paper introduces a two-step framework for domain adaptation that avoids the instabilities of adversarial training. By utilizing a BERT-based domain classifier to rank and select source data samples most similar to the target domain, and subsequently applying a curriculum learning strategy, the proposed Discriminative Data Selection (DDS) method achieves superior performance. Experimental results on GLUE benchmark datasets show that training on a small, highly relevant subset of source data can outperform standard adaptation baselines while significantly improving efficiency.

Introduction

While BERT has revolutionized NLP through its fine-tuning capabilities, its "fragility" under domain shift remains a challenge. When a model trained on formal news (source) is deployed on casual social media text (target), accuracy typically drops. Existing solutions like adversarial training are often difficult to stabilize for large-scale transformers. This research proposes a more stable and efficient two-step approach: identifying domain-relevant data and presenting it to the model via a structured curriculum.

Methodology

The proposed framework consists of two primary stages:

  1. Domain Classification: A BERT-based classifier is trained to distinguish between source and target domain samples. The authors observed that BERT’s internal representations are naturally sensitive to domain-specific features.
  2. Discriminative Data Selection (DDS) and Curriculum Learning:
  3. Data Selection: The domain classifier ranks source samples by their similarity to the target domain. Only the most "target-like" samples are selected for training.
  4. Curriculum Learning: Selected data is presented to the model in a specific order. The "Most Similar" curriculum starts with the easiest (most target-like) samples, mimicking human learning patterns to accelerate convergence.

Experimental Setup

The framework was evaluated using four datasets from the GLUE benchmark: SNLI, MNLI (Natural Language Inference), QNLI (Question Answering), and Quora Question Pairs (Paraphrase Detection). These datasets provided 12 distinct source-to-target transfer pairs to test the model's adaptability across varying linguistic styles.

Key Insights and Results

BERT as a Domain Detector

A key finding of this work is that BERT inherently encodes domain information. Visualization of BERT's embeddings confirms that text from different datasets forms distinct, well-separated clusters.

t-SNE visualization of BERT embeddings showing distinct clusters for different datasets (MNLI, QNLI, Quora, SNLI).

Efficiency and Curriculum Impact

The DDS approach demonstrated that "less is more." In several transfer tasks, using a tiny fraction (as low as 0.1%) of the most relevant source data yielded better results than using the entire dataset. Furthermore, the order of data presentation proved critical.

Accuracy in the target domain vs. the number of source data samples selected, comparing different curriculum strategies.

As shown in the figure above, the "Most Similar" strategy (blue line) consistently leads to higher accuracy and faster convergence compared to random sampling or "Most Dissimilar" strategies. The DDS framework outperformed the Maximum Mean Discrepancy (MMD) baseline in 10 out of 12 transfer tasks, achieving accuracy gains of up to 18% over naive zero-shot approaches.

Conclusion

The Discriminative Data Selection framework offers a stable and highly efficient alternative to adversarial domain adaptation. By focusing on the most relevant source data and utilizing curriculum learning, models can adapt to new domains with minimal training budgets. Future work will explore extending this framework to multi-source domain adaptation scenarios.

Summary updated

BibTeX
@inproceedings{ma2019domain,
  author = {Xiaofei Ma and Peng Xu and Zhiguo Wang and Ramesh Nallapati and Bing Xiang},
  title = {{Domain Adaptation with BERT-based Domain Classification and Data Selection}},
  booktitle = {DeepLo @ EMNLP},
  year = {2019},
  doi = {10.18653/v1/d19-6109},
}
Figure