Abstract
Pre-trained language models (PLMs) serve as the backbone for various natural language processing tasks, yet they often lack the specialized expertise required for domain-specific applications such as medicine or law. Traditional methods for domain adaptation, such as continued pre-training, are computationally expensive and risk "catastrophic forgetting" of general knowledge. This paper introduces MixDA (Mixture-of-Domain-Adapters), a framework that decouples domain-specific knowledge from a model's general-purpose memories. By integrating parallel domain adapters into the Feed-Forward Networks (FFNs) of Transformers and utilizing a dynamic gating mechanism, MixDA achieves state-of-the-art performance across specialized tasks while maintaining parameter efficiency and general reasoning capabilities.
Introduction
Modern Pre-trained Language Models like RoBERTa and GPT are designed as generalists. While they excel at broad linguistic tasks, their performance often falters when confronted with the nuances of specialized domains—such as identifying complex chemical interactions or interpreting legal jargon. The current landscape of domain adaptation offers two primary paths: continued pre-training on massive domain-specific corpora or Parameter-Efficient Fine-Tuning (PEFT). The former is resource-intensive and often degrades the model's original "common sense," while the latter typically focuses on task-specific adaptation rather than deep domain knowledge injection.
MixDA addresses this gap by treating the internal Feed-Forward Networks (FFNs) of a Transformer as a "key-value memory" system. By adding specialized memory units in parallel to the original frozen FFNs, MixDA allows a model to expand its knowledge base without overwriting its foundational training.
Methodology
The MixDA framework operates through a two-stage strategy designed to first inject domain knowledge and then refine it for specific tasks.
Stage 1: Domain Knowledge Injection
In the first stage, the model is exposed to unlabeled domain-specific text. To preserve the model's general capabilities, the original FFNs are frozen. New Domain-Adapters, utilizing a simple bottleneck architecture, are added in parallel to these FFNs.
A critical technical innovation in this stage is the use of Sampling Loss (L2 distance). This loss function aligns the latent representations of the new domain adapter with the outputs of the original FFN. This ensures that the newly acquired domain knowledge is encoded in a "language" that the rest of the frozen model can interpret, facilitating seamless integration.
Stage 2: Task Adaptation
Once the model has acquired domain expertise, it is fine-tuned on labeled data for a specific task. This stage introduces two components:
- Mixture-of-Adapters (MoA) Gate: This learnable gate receives inputs from both the original FFN and the domain adapters. Using a Sigmoid function, it dynamically calculates the optimal balance between general and specialized knowledge for any given input.
- Task Adapter: A standard task-specific adapter is placed atop the architecture to handle final classification or generation requirements.
Experimental Evaluation
The authors evaluated MixDA across 15 datasets to test its versatility and robustness. These were categorized into three distinct groups:
- In-Domain (ID): The GLUE benchmark was used to verify that the model retained its general-purpose performance.
- Out-of-Domain (OOD): Specialized datasets including ChemProt and RCT (Biomedical), as well as IMDB and Amazon (Reviews), tested the model's specialized expertise.
- Knowledge-Intensive (KI): FEVER (fact-checking) and CSQA (commonsense question answering) evaluated the model's ability to handle complex reasoning.
Results and Discussion
MixDA demonstrated superior performance across nearly all benchmarks, outperforming standard fine-tuning and popular adapter methods such as Houlsby, Pfeiffer, and LoRA. On average, MixDA provided a 3.5% improvement over the strongest baseline adapter.
Domain Expertise and Efficiency
The most significant gains were observed in highly specialized fields. For instance, on the ChemProt biomedical dataset, MixDA achieved a 60.6% F1 score, significantly higher than the 53.7% achieved by the standard Pfeiffer adapter. Despite these gains, the framework remains remarkably lightweight, adding only approximately 0.7% additional parameters to a base RoBERTa-large model.
Mitigation of Catastrophic Forgetting
Unlike many adaptation techniques that trade general performance for domain-specific accuracy, MixDA actually improved general performance on the GLUE benchmark (56.8% vs. 54.3% for the baseline). This suggests that the decoupling of memories effectively prevents the degradation of the model's original knowledge base.
Conclusion
MixDA represents a significant step forward in the efficient adaptation of large language models. By treating FFNs as expandable memory banks and using a dynamic gating mechanism to route information, the framework allows models to become experts in specialized fields without losing their generalist roots. Future work will focus on streamlining the two-stage process into a unified training pipeline and exploring the scalability of the MoA gate when managing hundreds of specialized "micro-experts."
Summary updated