LawInstruct: A Resource for Studying Language Model Adaptation to the Legal Domain

Joel Niklaus, Lucia Zheng, Arya D. McCarthy, Christopher Hahn, Brian M. Rosen, Peter Henderson, Daniel E. Ho, Garrett Honke, Percy Liang, Christopher Manning

TL;DR

The authors introduce LawInstruct, the first massive, multilingual legal instruction-tuning dataset containing 12 million examples across 24 languages and 17 jurisdictions. By fine-tuning the open-source Flan-T5 model family on this dataset, they create FLawN-T5, which achieves state-of-the-art performance on the LegalBench reasoning benchmark without sacrificing general cognitive capabilities.

What Problem Does This Paper Address?

Large Language Models (LLMs) like GPT-4 excel at legal reasoning, but their closed-source nature poses a massive hurdle for the legal sector. Law firms and legal institutions handle highly sensitive data, making public APIs a non-starter due to strict data protection and trust requirements. They need powerful, open-source models that can be deployed on-premise.

However, smaller open-source models lag significantly behind their proprietary counterparts in specialized domains. A primary reason is that standard instruction-tuning datasets (which teach models how to follow user prompts) severely underrepresent the legal domain. For instance, in the popular Super-NaturalInstructions dataset, only 10 out of over 1,600 tasks are legal. This paper addresses this gap by exploring whether domain-specific continued pretraining and instruction tuning can elevate open-source models to handle complex legal reasoning.

Methods

The researchers developed a two-stage adaptation pipeline to transform standard T5 and Flan-T5 models into legal experts, as illustrated in the overview below:

Figure 1: We continue pretraining on MultiLegalPile, instruction tune on LawInstruct and evaluate on LegalBench and MMLU.
  1. Continued Pretraining (Domain Adaptation): They first exposed the models to raw legal text using the MultiLegalPile corpus, utilizing a Unified Language Learner (UL2) denoising mixture to improve training efficiency.
  2. Instruction Tuning: They then fine-tuned the models on their newly curated LawInstruct dataset. Crucially, to prevent the models from forgetting general knowledge (catastrophic forgetting), they co-trained the models using a mixture of legal instructions and general-domain instructions (the standard Flan mixture).

The authors systematically evaluated these steps across four model sizes (Small, Base, XL, and XXL) to understand how legal adaptation scales.

Datasets

The study leverages several key datasets for both training and evaluation:

  • MultiLegalPile (Pretraining): A 689GB multilingual legal corpus spanning 24 languages and 17 jurisdictions, used for the initial domain adaptation phase.
  • LawInstruct (Instruction Tuning - New): The core contribution of this paper. The authors aggregated 58 existing legal datasets and mapped them to 107 human-written instruction templates, generating nearly 12 million training examples. Tasks include legal QA, court case summarization, and legal argument mining.
Distribution of task types and jurisdictions by number of examples in the LawInstruct dataset.
  • LegalBench (Evaluation): A rigorous benchmark consisting of 162 tasks evaluating five distinct flavors of legal reasoning: Issue, Rule, Conclusion, Interpretation, and Rhetorical.
  • MMLU (Evaluation): A massive general-domain benchmark used to ensure that tuning the model on legal text didn't degrade its broader factual knowledge.

Key Insights and Ideas

  • Mixing General Data is Mandatory: Simply training a model on legal instructions causes its downstream performance to plummet. Co-training with general instruction datasets (like Flan) is absolutely necessary to anchor the model's language capabilities.
  • The Pretraining Paradox for Large Models: While continued pretraining on raw legal text provided a massive boost to the Small model, it actually led to training instabilities or diminished returns for the XL and XXL models. Larger models seem to benefit more from jumping straight to instruction tuning, likely because they already possess higher latent capacity from their initial general pretraining.
  • Instruction Diversity Has Diminishing Returns: The authors experimented with using GPT-4 to generate 10 paraphrased variations of each prompt template. Surprisingly, training on these diverse prompts did not consistently outperform training on just a single, well-crafted manual instruction.

Key Results

Instruction tuning on LawInstruct yielded FLawN-T5, setting a new state-of-the-art for open-source models on LegalBench across all parameter ranges.

Performance progression across model sizes on LegalBench and MMLU, comparing baselines, instruction tuning (IFT), and pretraining + IFT.
  • LegalBench Performance: The Base model saw an aggregate increase of 15 points (a 50% relative improvement over the baseline). The XL model improved by 8 points (16%), achieving a balanced accuracy of 58.1.
  • No General Regression: Crucially, as shown in the MMLU results above, none of the model sizes experienced a drop in general reasoning capabilities; in fact, some sizes saw slight improvements in humanities and social sciences.

Limitations and Future Work

While LawInstruct represents a massive leap forward, the authors note that its template-based nature might still limit prompt diversity. Furthermore, the models still struggled with "Conclusion" tasks on LegalBench, which require pure deductive reasoning rather than just legal knowledge.

Because of budget constraints, the team could not perform an extensive human evaluation of long-form generations by legal experts. Future work will focus on expanding the dataset to include more open-ended generation tasks, exploring why continued pretraining destabilizes larger models, and mitigating the hallucinations that still plague open legal LLMs.

Summary updated

BibTeX
@inproceedings{niklaus2025lawinstruct,
  author = {Joel Niklaus and Lucia Zheng and Arya D. McCarthy and Christopher Hahn and Brian M. Rosen and Peter Henderson and Daniel E. Ho and Garrett Honke and Percy Liang and Christopher Manning},
  title = {{LawInstruct: A Resource for Studying Language Model Adaptation to the Legal Domain}},
  booktitle = {Conference of the North American Chapter of the Association for Computational Linguistics},
  year = {2025},
  doi = {10.18653/v1/2025.findings-naacl.7},
}
Figure