Abstract
Instruction tuning is an important step in making language models useful for direct user interaction. However, the legal domain is underrepresented in typical instruction datasets (e.g., only 10 out of 1600+ tasks in Super-NaturalInstructions). To study whether instruction tuning on legal datasets is necessary for strong legal reasoning, we aggregate 58 annotated legal datasets and write instructions for each, creating LawInstruct. LawInstruct covers 17 global jurisdictions, 24 languages and a total of 12M examples across diverse tasks such as legal QA, summarization of court cases, and legal argument mining. We evaluate our models on LegalBench, measuring legal reasoning across five categories in 162 challenging and realistic legal tasks, and MMLU, to measure potential drops in general reasoning capabilities. We find that legal-specific instruction tuning on Flan-T5 - yielding FLawN-T5 - improves performance on LegalBench across all model sizes, with an aggregate increase of 15 points or 50% over Flan-T5 for the base size. No model size shows performance drops in MMLU. We publish LawInstruct as a resource for further study of instruction tuning in the legal domain.
Introduction
While Large Language Models (LLMs) like GPT-4 show impressive performance on standardized tests, they frequently encounter difficulties when faced with complex legal reasoning or niche jurisdictions. A significant barrier to improvement is the scarcity of legal data in standard instruction-tuning sets. For instance, the popular Super-NaturalInstructions dataset contains over 1,600 tasks, but only 10 are legal-specific. This paper addresses the domain adaptation challenge: effectively teaching a model the nuances of law across diverse languages and legal systems.
To bridge this gap, we introduce LawInstruct, a massive multilingual dataset of 12 million instruction-tuning examples. By fine-tuning the T5 model family on this data, we created FLawN-T5, which achieves significant performance boosts on legal reasoning benchmarks without sacrificing general-purpose capabilities.
Methodology
The researchers followed a multi-stage pipeline to adapt the T5 model family (ranging from 60M to 11B parameters) to the legal domain.
- Continued Pretraining: The process began with MultiLegalPile, a 689GB multilingual legal corpus, to establish a foundational vocabulary of legal concepts.
- Instruction Tuning: 58 existing legal datasets were transformed into a unified instruction-following format, creating the LawInstruct resource.
- Ablation Studies: Extensive experiments determined the optimal adaptation strategy, testing the impact of starting from base versus instruction-tuned models and the necessity of mixing in general-purpose data.
Data Resources
The study utilizes three main pillars of data:
- MultiLegalPile: A massive 689GB corpus spanning 24 languages and 17 jurisdictions used for pretraining.
- LawInstruct: A newly curated dataset of 12M examples covering tasks like legal QA, case summarization, and argument mining. As shown in the task distribution, the dataset is highly diverse, with a strong emphasis on text classification and summarization.
- LegalBench & MMLU: Models were evaluated on LegalBench (162 legal tasks) to measure domain expertise and MMLU to ensure general reasoning capabilities remained intact.
Key Insights and Results
Our experiments yielded several critical findings for domain adaptation:
- The "Mixing" Requirement: Training on only legal instructions caused performance to drop. Success requires mixing legal instructions with general-purpose instructions (like the Flan collection) to maintain model flexibility.
- Instruction Tuning > Continued Pretraining: For larger models (XL and XXL), instruction tuning provided the majority of the performance gains. Continued pretraining on raw legal text was primarily beneficial for the smallest models.
- Foundation Matters: It is significantly more effective to start domain-specific tuning from a model that has already undergone general instruction tuning (like Flan-T5) rather than a raw base model.
FLawN-T5 showed dramatic improvements across the board. The Base model saw an aggregate increase of 15 points (a 50% improvement) over standard Flan-T5. The XXL model achieved a balanced accuracy of 58.1 on LegalBench, a massive jump from the baseline. Crucially, these gains did not come at the expense of general knowledge; MMLU scores remained stable or improved slightly.
Limitations and Future Work
Despite the success of FLawN-T5, several areas for improvement remain. Most instructions were generated using human-written templates, which may limit variety compared to real-world legal queries. Furthermore, while multiple-choice benchmarks are scalable, future work should include qualitative evaluations by qualified lawyers to judge long-form generative outputs. Finally, the diminishing returns of continued pretraining at the XXL size suggest the need for improved recipes when domain-adapting the largest open-source models.
Summary updated