Table of Contents
Fetching ...

Domain-Adaptation through Synthetic Data: Fine-Tuning Large Language Models for German Law

Ali Hamza Bashir, Muhammad Rehan Khalid, Kostadin Cvejoski, Jana Birr, Jule Berghaus, Armin Berger, Sandra Halscheidt, Christian Temath, Rafet Sifa, David Berghaus

TL;DR

This work presents a practical pipeline for adapting open LLMs to German law by generating statute-grounded synthetic QA data from German statutes and applying a difficulty-graded, filtered training regime. Using LoRA to fine-tune Llama 3.1 and Gemma 3 on two data-generation strategies, the authors demonstrate substantial domain gains on held-out BGB and LegalMC4 benchmarks while preserving general language understanding. Key contributions include a multi-level QA data generation framework, an LLM-based filtering step, and extensive evaluation showing that difficulty-graded data consistently boosts performance in both open-ended and multiple-choice formats, especially in retrieval-augmented contexts. The results indicate that carefully designed synthetic data can rival manual annotation in high-stakes domains and highlight future avenues for integrating real-time retrieval to further enhance accuracy and grounding.

Abstract

Large language models (LLMs) often struggle in specialized domains such as legal reasoning due to limited expert knowledge, resulting in factually incorrect outputs or hallucinations. This paper presents an effective method for adapting advanced LLMs to German legal question answering through a novel synthetic data generation approach. In contrast to costly human-annotated resources or unreliable synthetic alternatives, our approach systematically produces high-quality, diverse, and legally accurate question-answer pairs directly from authoritative German statutes. Using rigorous automated filtering methods and parameter-efficient fine-tuning techniques, we demonstrate that LLMs adapted with our synthetic dataset significantly outperform their baseline counterparts on German legal question answering tasks. Our results highlight the feasibility of using carefully designed synthetic data as a robust alternative to manual annotation in high-stakes, knowledge-intensive domains.

Domain-Adaptation through Synthetic Data: Fine-Tuning Large Language Models for German Law

TL;DR

This work presents a practical pipeline for adapting open LLMs to German law by generating statute-grounded synthetic QA data from German statutes and applying a difficulty-graded, filtered training regime. Using LoRA to fine-tune Llama 3.1 and Gemma 3 on two data-generation strategies, the authors demonstrate substantial domain gains on held-out BGB and LegalMC4 benchmarks while preserving general language understanding. Key contributions include a multi-level QA data generation framework, an LLM-based filtering step, and extensive evaluation showing that difficulty-graded data consistently boosts performance in both open-ended and multiple-choice formats, especially in retrieval-augmented contexts. The results indicate that carefully designed synthetic data can rival manual annotation in high-stakes domains and highlight future avenues for integrating real-time retrieval to further enhance accuracy and grounding.

Abstract

Large language models (LLMs) often struggle in specialized domains such as legal reasoning due to limited expert knowledge, resulting in factually incorrect outputs or hallucinations. This paper presents an effective method for adapting advanced LLMs to German legal question answering through a novel synthetic data generation approach. In contrast to costly human-annotated resources or unreliable synthetic alternatives, our approach systematically produces high-quality, diverse, and legally accurate question-answer pairs directly from authoritative German statutes. Using rigorous automated filtering methods and parameter-efficient fine-tuning techniques, we demonstrate that LLMs adapted with our synthetic dataset significantly outperform their baseline counterparts on German legal question answering tasks. Our results highlight the feasibility of using carefully designed synthetic data as a robust alternative to manual annotation in high-stakes, knowledge-intensive domains.
Paper Structure (40 sections, 3 figures, 4 tables)

This paper contains 40 sections, 3 figures, 4 tables.

Figures (3)

  • Figure 1: Difficulty-Graded QA Data pipeline. A statute section serves as ground truth input. The generator produces complementary question styles at increasing difficulty (clause, paraphrase, scenario, multi-section) while enforcing statute-only constraints. A reviewer model filters unanswerable, unsupported, or redundant pairs and performs deduplication. The retained question–answer pairs constitute the supervised fine-tuning (SFT) dataset used for LoRA adaptation.
  • Figure 2: Standard Instruction QA Data vs. Difficulty-Graded QA Data example (English shown for readability). Standard Instruction QA Data Generation produces single-level, largely recall-style supervision from a statute section. Difficulty-Graded QA Data Generation generates difficulty-graded question types (L1--L3) from the same input provision and supports cross-section integration at Level 4 when multiple provisions are provided as input.
  • Figure 3: LegalMC4-style context-based QA example (English shown for readability). Each instance provides a retrieved legal passage as context, mirroring the generator setting in retrieval-augmented generation (RAG) pipelines.