MultiLegalPile: A 689GB Multilingual Legal Corpus

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

TL;DR

The authors introduce MultiLegalPile, a massive 689GB multilingual legal corpus spanning 24 languages and 17 jurisdictions. By performing continued pretraining on this domain-specific data, they developed a suite of "Legal-XLM-R" models that set new state-of-the-art (SotA) benchmarks for legal NLP tasks across both multilingual (LEXTREME) and English (LexGLUE) datasets.

What Problem Does This Paper Address?

While Large Language Models (LLMs) have shown remarkable general capabilities, they often stumble in specialized domains like law. Legal reasoning requires a deep understanding of specific terminology, long-range dependencies, and jurisdictional nuances.

The authors identify three major bottlenecks in legal AI:

  1. Data Scarcity: General-purpose crawls like mC4 are surprisingly "law-lite"—only about 0.1% of their content is actually legal text.
  2. Linguistic Bias: Most existing legal datasets are English-centric, leaving other legal systems underserved.
  3. Licensing Ambiguity: Training on web-scraped data often involves murky copyright issues.

To solve this, the authors curated a massive, multilingually diverse, and (mostly) permissively licensed corpus to bridge the gap between general-purpose LLMs and the specialized needs of the legal community.

Comparison of MultiLegalPile with previous domain-specific corpora.

Methods

The researchers didn't just scrape the web; they used a multi-pronged approach to build a high-quality corpus:

  • Regex Filtering: To extract legal text from the massive mC4 crawl (27TB total), they used expert-refined regular expressions to find legal citations (e.g., "Art. 5" or "§ 8"). This was chosen over machine learning classifiers for sheer processing speed.
  • Continued Pretraining: Instead of training from scratch, they "warm-started" their models using XLM-R checkpoints. They then continued training on MultiLegalPile using a Masked Language Modeling (MLM) objective.
  • Custom Tokenization: They trained a new tokenizer with 128,000 Byte Pair Encodings (BPEs) to better represent legal jargon across 24 languages.
  • Architectural Variants: They trained standard base and large models, but also a Longformer version (Legal-XLM-LF-base) capable of handling context lengths up to 4,096 tokens—essential for long-winded legal documents.
Specifications of the models trained in this study.

Datasets

The MultiLegalPile (689GB) is the star of the show, composed of four primary subsets:

  1. Native Multi Legal Pile (112 GB): Scraped from various national courts and legislative bodies.
  2. Eurlex Resources (179 GB): Official EU legal documents.
  3. Legal mC4 (106 GB): The filtered portion of the mC4 web crawl.
  4. Pile of Law (292 GB): An existing large-scale English legal dataset.
Figure 1: MULTILEGALPILE Source Distribution

The corpus is dominated by caselaw (51.4%) and legislation (12.6%), reflecting the public availability of these document types.

Figure 2: MULTILEGALPILE Text Type Distribution

Evaluation was performed on two major benchmarks:

  • LEXTREME: A multilingual benchmark covering tasks like court decision prediction and named entity recognition (NER) in various languages.
  • LexGLUE: The standard English-language legal benchmark.

Key Insights and Ideas

  • The "Fair Use" Bet: The authors argue that training on legal texts is "transformative" and falls under fair use, especially since many legal texts are produced by public agencies and aren't protected by traditional copyright.
  • Domain-Specific Beats Scale: Their "Legal-XLM-R-base" model (184M parameters) performed on par with the much larger general-purpose "XLM-R-large" (560M parameters) on legal tasks. This proves that what you learn is often more important than how many parameters you have.
  • Long Context is King: The Longformer variant achieved the highest aggregate score on LEXTREME, highlighting that legal NLP is often a "long-game" where understanding the beginning of a document is crucial for interpreting the end.
  • Monolingual Gains: For low-resource languages, training a dedicated monolingual model on the language-specific subset of MultiLegalPile often yielded massive gains—up to 11 macro F1 points in the case of Dutch.

Key Results

  • LEXTREME SotA: The Legal-XLM-R-large model set a new state-of-the-art aggregate score of 59.5.
  • LexGLUE Success: The English-specific models reached SotA on 5 out of 7 tasks in the LexGLUE benchmark.
  • Greek Legal Code: The models showed a "drastic" performance increase in Greek legal code tasks, a previously difficult area for general models.
Aggregate scores for multilingual models on the LEXTREME benchmark.

Limitations and Future Work

The authors are transparent about a few hurdles:

  • Deduplication: They did not perform cross-subset deduplication, meaning some documents might appear twice (e.g., in both Legal mC4 and Eurlex).
  • Compute Constraints: Due to limited hardware, they focused on encoder-only models (like RoBERTa) rather than massive generative models (like GPT-4).
  • Geographic Gaps: While strong in EU languages, the corpus lacks representation from major jurisdictions like China.

Future work aims to expand the corpus to more languages and test whether these domain-specific pretraining benefits translate to multi-billion parameter generative models.

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