MultiLegalPile: A 689GB Multilingual Legal Corpus

Joel Niklaus, Veton Matoshi, Matthias Stürmer, Ilias Chalkidis, Daniel E. Ho

Abstract

Large Language Models (LLMs) often struggle with the nuances of legal reasoning due to the scarcity of domain-specific data in general training sets. We present MultiLegalPile, a massive 689GB multilingual corpus spanning 24 languages and 17 jurisdictions. By continuing the pretraining of XLM-R models on this data, we achieve new state-of-the-art (SotA) results on major legal benchmarks, proving that domain-specific data allows smaller models to outperform much larger general-purpose counterparts.

Introduction

While models like GPT-4 exhibit impressive legal capabilities, they are primarily trained on general web crawls like Common Crawl, which are heavily English-centric and contain very little legal text. Analysis of the mC4 web dataset reveals that only about one in every thousand documents contains legal content. This scarcity hinders a model's ability to grasp legal terminology and the structural differences between international legal systems. MultiLegalPile addresses this by providing a large-scale, multi-jurisdictional, and permissively licensed resource for the global NLP community.

The MultiLegalPile Dataset

The core contribution of this work is the MultiLegalPile, a 689GB corpus curated through a high-quality pipeline. It consists of four major subsets: the US-centric Pile of Law, Eurlex Resources from the EU, a Native Multi Legal Pile from 29 diverse sources, and a filtered Legal mC4 subset.

Composition of the 689GB MultiLegalPile corpus across its four main subsets.

The corpus provides extensive coverage across 24 European languages. While English is the largest component, significant data exists for Portuguese, German, Spanish, and French, among others. This diversity is crucial for developing models that can handle the multi-jurisdictional nature of modern law.

Distribution of word counts across the 24 languages included in MultiLegalPile.

Methodology

The researchers employed several techniques to optimize model performance:

  • Heuristic Filtering: Regular expressions were used to identify legal citations, providing a fast and precise way to isolate legal content from general web data.
  • Model Recycling: Models were initialized from existing XLM-R checkpoints (warm-starting) rather than training from scratch.
  • Domain-Specific Tuning: A new tokenizer with 128K BPEs was trained to capture legal vocabulary, and the masking rate during training was increased to 20-30% to encourage deeper linguistic learning.
  • Long Contexts: A Longformer version was pretrained to handle up to 4,096 tokens, addressing the inherent length of legal documents.

Key Results and Insights

The resulting LegalXLMs set new benchmarks for legal NLP:

  • Efficiency through Specialization: The Legal-XLM-R-base model (184M parameters) performed on par with the much larger XLM-R-large (560M parameters), highlighting that data relevance can outweigh raw parameter count.
  • Benchmark Performance: The models achieved SotA on the LEXTREME multilingual benchmark and five out of seven tasks on the English LexGLUE benchmark.
  • Monolingual Gains: Even for languages with relatively small representation in the pile, such as Dutch, training monolingual legal models led to significant performance gains.
  • Legal Data as a "Gold Mine": Unlike general web scraping, legal texts are often available under public licenses, providing a high-quality, legally-compliant path for training data acquisition.

Limitations and Future Work

Current limitations include the lack of cross-subset deduplication and a focus on encoder-only architectures. Future work could involve integrating data from more jurisdictions (e.g., China) and applying this corpus to generative (decoder) models to improve legal drafting and summarization.

Summary updated

BibTeX
@inproceedings{niklaus2024multilegalpile,
  author = {Joel Niklaus and Veton Matoshi and Matthias Stürmer and Ilias Chalkidis and Daniel E. Ho},
  title = {{MultiLegalPile: A 689GB Multilingual Legal Corpus}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2024},
  doi = {10.18653/v1/2024.acl-long.805},
}
Figure