Abstract
Large-scale pretrained language models (PLMs) like BERT often struggle in specialized domains due to domain shift and high computational costs. We present AdaLM (Adapt-and-Distill), a framework designed to produce domain-specific models that are significantly smaller and faster while maintaining or exceeding the performance of larger general-purpose models. AdaLM combines automated vocabulary expansion with a novel "Adapt-and-Distill" training sequence. Our 6-layer model is 3.3x smaller and 5.1x faster than BERT-Base, yet achieves state-of-the-art results in biomedical and computer science domains.
Introduction
Modern NLP relies heavily on massive models like BERT and RoBERTa. However, these models face significant challenges when applied to specialized fields:
- Domain Shift: General models lack the specific vocabulary of fields like medicine. For instance, "lymphoma" might be fragmented into subwords like
[l, ##ym, ##ph, ##oma], losing semantic meaning. - Deployment Constraints: Massive parameter counts (e.g., 110M for BERT-Base) lead to high latency and memory usage, making real-time inference on edge devices difficult.
While continual pre-training and knowledge distillation address these issues individually, the optimal way to combine them remains an open question. AdaLM addresses this by optimizing both adaptation and compression.
Methodology
The AdaLM Framework
The AdaLM pipeline integrates vocabulary expansion and model initialization to prepare for efficient domain adaptation.
Automated Vocabulary Expansion
AdaLM automatically identifies domain-specific terms using "corpus occurrence probability." This metric helps determine the optimal number of added tokens, following a logarithmic trend where adding more words eventually yields diminishing returns. To maintain semantic continuity, new word embeddings (e.g., for "lymphoma") are initialized by averaging the embeddings of the subwords the original model would have used.
The Adapt-and-Distill Strategy
The researchers evaluated four distinct strategies for creating small, domain-specific models:
- From Scratch: Training a small model on domain data from the start.
- Distill-then-Adapt: Compressing a general model first, then performing domain adaptation.
- Adapt-then-Distill: Adapting a large model to the domain, then compressing it into a student model.
- Adapt-and-Distill: Adapting both a large teacher and a small student model to the domain independently, then performing distillation between the two already-adapted models.
The "Adapt-and-Distill" approach proved superior, as initializing the student with domain-adapted weights provides a significant head start over random initialization.
Experimental Setup
The framework was validated in two domains:
- Biomedical: Pre-trained on a 16GB PubMed abstract corpus. Evaluation tasks included JNLPBA (NER), EBM PICO (Information Extraction), and ChemProt (Relation Extraction).
- Computer Science: Pre-trained on 300 million arXiv entries. Evaluation tasks included ACL-ARC (Citation classification) and SCIERC (Scientific entity/relation extraction).
Results and Discussion
The 6-layer AdaLM model (384 hidden dimensions) demonstrated remarkable efficiency:
- Performance: It outperformed BERT-Base across all benchmarks. In the biomedical domain, AdaLM achieved an average score of 75.34, rivaling much larger models like BioBERT (76.22) and PubMedBERT (76.89).
- Efficiency: The model is 3.3x smaller (excluding the embedding layer) and 5.1x faster during inference than BERT-Base.
- Vocabulary Impact: Expanding the vocabulary reduced sequence lengths by representing technical terms as single tokens, further boosting inference speed. However, excessively large vocabularies (e.g., >60k for PubMed) can hurt performance due to data sparsity for rare tokens.
Conclusion
AdaLM demonstrates that small, fast models can be highly effective in specialized domains when the training pipeline correctly sequences adaptation and distillation. Future work will explore more efficient data selection methods and the application of this framework to low-resource domains.
Summary updated