Adapting a Language Model While Preserving its General Knowledge

Zixuan Ke, Yijia Shao, Haowei Lin, Hu Xu, Lei Shu, Bing Liu

This paper, presented at EMNLP 2022, tackles a common hurdle in Natural Language Processing: how to specialize a general-purpose language model for a specific domain without breaking the "common sense" it already possesses.

Introduction

When we take a massive model like BERT or RoBERTa and perform Domain-Adaptive Pre-training (DA-training)—essentially continuing the training on a specific corpus like medical papers or product reviews—we often run into a "blindness" problem. Standard DA-training treats all model parameters equally. However, domain-specific datasets are often small. If you update the model too aggressively, you risk "corrupting" the general linguistic knowledge the model learned during its initial massive pre-training. The challenge is balancing specialization (learning domain-specific nuances) with preservation (keeping general-purpose utility).

The DGA Framework

The authors propose a two-pronged system called DGA (Domain-adaptive General knowledge preservation and LM Adaptation):

  1. Importance Estimation via Proxy KL-Divergence: To protect general knowledge, you first have to find it. Since the original pre-training data is usually unavailable, the authors use a clever "proxy." They pass domain data through the model twice with different dropout masks. Attention heads that contribute most to the model's robustness (consistency between these outputs) are flagged as "important" for general knowledge.
  2. Soft-Masking Gradients: Instead of freezing important heads (which is too rigid), DGA uses "soft-masking." It scales down the gradient updates for important heads during training. This allows the model to nudge these parameters if absolutely necessary for the new domain while preventing drastic, destructive changes.
  3. Contrastive Learning for Integration: DGA uses a contrastive loss function to help the model integrate new knowledge. It compares the "full" representation (using all heads) against a "general" representation (using only the important heads). This forces the model to learn domain-specific features that are distinct from, yet integrated with, its existing general knowledge.
The DGA framework consists of importance computation (A) and informed adaptation training (B).

Experimental Setup

The researchers evaluated DGA across six diverse domains and ten baseline methods:

  • Reviews: Yelp Restaurant, Amazon Phone, and Amazon Camera.
  • Academic Papers: ACL (Computer Science), AI (Artificial Intelligence), and PubMed (Biomedical).
  • End-Tasks: The models were evaluated on specific tasks like Aspect Sentiment Classification (ASC), Citation Intent, and Chemical-protein Interaction Prediction.

Notably, the authors used relatively small domain corpora (300MB–900MB) to demonstrate that DGA is effective even when data is scarce.

Key Results

DGA consistently outperformed all 10 baselines, including standard MLM (Masked Language Modeling), Adapter-tuning, and Prompt-tuning.

Performance comparison of DGA against various baselines across six domains.
  • Performance Boost: On average, DGA achieved an MF1 score of 78.74, compared to 76.40 for standard DA-training (MLM) and 73.64 for the base RoBERTa model without any adaptation.
  • Consistency: DGA showed lower variance across different random seeds compared to standard MLM, suggesting the "informed" approach leads to more stable and reliable training.
  • Efficiency: DGA achieved these gains using much less data than previous state-of-the-art methods, making it a viable strategy for researchers with limited compute or niche datasets.

Key Insights and Ideas

  • Robustness as a Proxy for Knowledge: One of the most elegant ideas here is using dropout-induced variance as a signal for parameter importance. It bypasses the need for the original, massive pre-training datasets.
  • Attention Heads are the "Knowledge Hubs": The authors found that constraining the attention heads was significantly more effective than constraining other parts of the Transformer (like the embedding or intermediate layers).
  • Integration over Segregation: In their ablation studies, the authors found that contrasting "General vs. Full" knowledge performed better than "General vs. Domain-only." This suggests that for downstream tasks, it is better for the model to see the domain knowledge as an extension of its general knowledge rather than a separate silo.

Limitations and Future Work

The current work focuses primarily on attention heads. While the authors tested other layers, a more granular approach (e.g., at the individual neuron level) might yield even better results. Additionally, the paper looks at adapting to one domain at a time; extending this to Continual Learning—where a model learns a sequence of many domains without forgetting any of them—is a logical next step.

Summary updated

BibTeX
@inproceedings{ke2022adapting,
  author = {Zixuan Ke and Yijia Shao and Haowei Lin and Hu Xu and Lei Shu and Bing Liu},
  title = {{Adapting a Language Model While Preserving its General Knowledge}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2022},
  url = {https://openreview.net/forum?id=vl5FjvnutLd},
}
Figure