Abstract
We explore how continued pre-training on domain-specific corpora influences large language models, revealing that training on the raw corpora endows the model with domain knowledge, but drastically hurts its prompting ability for question answering. Taken inspiration from human learning via reading comprehension--practice after reading improves the ability to answer questions based on the learned knowledge--we propose a simple method for transforming raw corpora into reading comprehension texts. Each raw text is enriched with a series of tasks related to its content. Our method, highly scalable and applicable to any pre-training corpora, consistently enhances performance across various tasks in three different domains: biomedicine, finance, and law. Notably, our 7B language model achieves competitive performance with domain-specific models of much larger scales, such as BloombergGPT-50B. Furthermore, we demonstrate that domain-specific reading comprehension texts can improve the model's performance even on general benchmarks, showing the potential to develop a general model across even more domains. Our model, code, and data will be available at https://github.com/microsoft/LMOps.
Introduction
The standard approach to specializing a Large Language Model (LLM) for fields like law or medicine is Domain-Adaptive Pre-training (DAPT), which involves training the model on massive amounts of raw domain-specific text. However, this process often leads to a "Prompting Paradox": while the model gains factual knowledge, its ability to follow instructions and answer questions (prompting ability) is significantly impaired. Raw corpora lack the structured input-output format that modern LLMs use to interact effectively with users. This research introduces AdaptLLM, a method designed to infuse models with deep domain expertise without sacrificing their interactive capabilities.
Methodology: Learning via Reading Comprehension
Inspired by human education, where reading is followed by practice questions, AdaptLLM transforms raw domain text into structured reading comprehension tasks. This approach ensures the model learns the underlying structure of knowledge rather than just word sequences.
Task Mining and Generation
The system automatically generates tasks from raw text using regular expressions and "verbalizers" to identify semantic relationships. For instance:
- Natural Language Inference (NLI): Identifying entailment or contradiction based on transition words like "Therefore" or "In contrast."
- Diverse Task Types: Generation of tasks for summarization, word-to-text (using domain vocabulary), commonsense reasoning, and paraphrase detection.
Instruction Mixing and Scalability
To maintain general instruction-following skills, domain-specific reading comprehension data is mixed with general-purpose instruction sets (e.g., LIMA, WizardLM). Because the task generation relies on patterns and templates, the method is highly scalable and does not require expensive human labeling.
Experimental Setup
AdaptLLM was evaluated across three high-stakes domains:
- Biomedicine: PubMed Abstracts.
- Finance: Stock news and financial reports.
- Law: FreeLaw Opinions.
Performance was measured using established benchmarks such as PubMedQA (Biomedicine), ConvFinQA (Finance), and SCOTUS (Law). General benchmarks like MMLU were also monitored to check for catastrophic forgetting.
Results and Discussion
The experimental results demonstrate that AdaptLLM consistently outperforms both the base General LLM and the DAPT-enhanced versions across all tested domains.
Key Findings
- Efficiency: The AdaptLLM-7B model achieved performance competitive with BloombergGPT-50B, a model seven times its size trained from scratch.
- Superiority over DAPT: Across all domains, AdaptLLM provided a significant performance boost over vanilla DAPT. For example, in Biomedicine, AdaptLLM-7B reached an average score of 47.3, compared to 41.7 for the DAPT version.
- General Logic Enhancement: Surprisingly, training on specialized reading comprehension tasks improved performance on general benchmarks. This suggests that reasoning through complex domain-specific text sharpens the model's overall logical capabilities.
Conclusion
AdaptLLM offers a scalable and effective way to adapt LLMs to specialized domains. By transforming raw text into interactive reading comprehension tasks, it avoids the pitfalls of traditional DAPT. While current task mining relies on explicit linguistic patterns, future work may involve using larger models to synthesize more complex tasks or exploring the optimal balance of domain-specific and general instructions for different fields.
Summary updated