Skip to content
AI.info

Research

Enhancing Legal Reasoning in Pre-trained Language Models via Knowledge Graph-Guided Multi-Task Pre-training

Overview Research area: Legal Natural Language Processing / domain-adaptive pre-training of Transformer encoders, combining knowledge graphs with multi-task learning. Technical level: Advanced. The pa

Enhancing Legal Reasoning in Pre-trained Language Models via Knowledge Graph-Guided Multi-Task Pre-training
arXiv
2610.13722
Published
2026-10-09
Authors
Ibrahim Siddig, Munir Georges

AI summary

Overview

Research area: Legal Natural Language Processing / domain-adaptive pre-training of Transformer encoders, combining knowledge graphs with multi-task learning.

Technical level: Advanced. The paper assumes familiarity with masked/sentence-level pre-training objectives, knowledge graph embedding methods (TransE, RotatE, ComplEx, DistMult), contrastive learning, and attention gating.

Scope (one sentence): The paper pre-trains nine Transformer encoders on German road traffic law (StVO) using three knowledge-graph-guided objectives, then evaluates legal question answering in-domain, cross-lingually, cross-regulationally, and on the LexGLUE benchmark suite.

What This Paper Is About

Legal text such as statutory books is semi-structured: paragraphs, sub-paragraphs, sentences and cross-references carry meaning that flat token sequences do not capture. Existing legal language models (Legal-BERT, Lawformer, SAILER) rely on masked language modeling or long-range attention and therefore treat statutes as unstructured text, ignoring the formal hierarchical constraints. The authors build a knowledge graph of the German Road Traffic Regulations and use it to guide multi-task pre-training, so that the structure of the law is written directly into the model's weights and no graph lookup is needed at inference time.

Key Contributions

  1. A unified multi-task pre-training approach for semi-structured regulatory text that explicitly integrates knowledge graph structures into latent representations, rather than concatenating graph text with input text as in KG-BERT-style approaches.
  2. TransE-derived legal paragraph embeddings used as soft pre-training targets, transferring relational legal knowledge without hard classification constraints and letting the model learn a continuous range of legal concepts.
  3. A differentiable gated KG-aware attention training mechanism that performs latent-space retrieval from a library of KG paragraph embeddings in real time, dynamically weighting external legal context against the model's internal representation, without discrete external database lookups at inference.
  4. A synthetic German traffic law QA dataset (N = 12,554) with paragraph-level citation grounding and strict paragraph-level splits to prevent data leakage.

Main Findings

  • Consistent in-domain gains: On synthetic StVO question answering, the models show relative improvements between 10.3% and 155.0% over baselines. All five legal-domain encoders exceed 0.8 m-F1 after pre-training; bert-base-eurlex rises from the weakest base (0.338) to 0.862, the largest absolute gain (+0.524), while bert-base-echr reaches the overall peak (0.864).
  • Gains are decoupled from base performance: The improvement stems from the KG-guided objectives rather than a strong starting point, since the weakest base model produced the largest absolute gain.
  • General-purpose models gain less than expected: google-bert-base gains more (+0.205, to 0.630) than the broader multi-field legal-bert-base (+0.114, to 0.569), which the authors attribute to domain-specific interference between multiple legal English tasks and the StVO domain.
  • Two weak cases for distinct reasons: legal-bert-small plateaus at 0.537 (+0.050), consistent with a capacity bottleneck; Legal-heBERT shows a severe precision-recall imbalance (P = 1.000, R = 0.096) reflecting incompatibility between Hebrew pre-training and the English target, and degrades monotonically under task scaling.
  • TransE chosen empirically: With the pre-training configuration fixed and only the KG embedding varied on bert-base-echr, downstream StVO QA m-F1 was 0.864 for TransE, 0.532 for RotatE, 0.392 for ComplEx and 0.370 for DistMult.
  • Cross-lingual transfer works: With NSP and CLU trained only on non-translated German StVO and the CLS head on English QA pairs, five models achieve positive zero-shot gains (+0.094 to +0.499). bert-base-eurlex transfers most strongly (0.338 to 0.837, +0.499). Three models transfer poorly zero-shot (down to −0.148) but recover fully when fine-tuned, with legal-bert-small posting the largest FT gain (+0.532, to 0.871). All models converge to a narrow band of 0.862–0.878.
  • Cross-regulation transfer is real but uneven: On the Austrian benchmark all tested models improve zero-shot (+0.041 to +0.158); Irish gains are smaller and less consistent (+0.002 to +0.082), and Legal-heBERT is the only model with negative transfer (−0.049). Austrian gains exceed Irish gains for nearly every model because the ÖAMTC regulations overlap more with StVO.
  • Cross-lingual distance is a bigger barrier than cross-regulatory distance: The authors conclude that linguistic distance (Table 4) modulates transfer more than traffic-law distance.
  • Out-of-domain LexGLUE transfer: Despite training exclusively on German traffic regulations, the models improve over the published baselines of Chalkidis et al. (2022a) on four of seven tasks: ECtHR-A, ECtHR-B, UNFAIR-ToS, and CaseHOLD.
  • CLS is the dominant objective: Aggregated ablation shows removing CLS precipitates a mean m-F1 drop of 0.277. For bert-base-echr, combining all three objectives lifts m-F1 from 0.587 (CLS only) to 0.864 (ALL), a gain of +0.277.
  • Synergy is not universal: The full NSP+CLU+CLS configuration outperforms all partial subsets for 7 of the 9 models. For bert-base-contracts, NSP+CLS (0.845) outperforms the full suite (0.797), attributed to semantic mismatch between StVO entities and US contract-law primitives plus gradient interference from random CLU negative sampling.

Methodology in Plain English

The work runs two pipelines that meet in the middle.

The KG pipeline takes the raw German StVO text and parses it with a legal pattern-based parser into a formal knowledge graph of 554 nodes and 945 edges, using five relations: has_paragraph, has_sentence, has_section, has_sign and has_table. This graph is translated to English with an LLM translator. TransE is then applied to learn a single embedding per entity node, producing paragraph embeddings e_p in R^500 that preserve the topology of the legal code.

The LM pipeline starts from a pre-trained encoder, splits long legal sentences into ordered segments at paragraph markers (§), sub-paragraph markers ((1), (2), …) and sentence boundaries, encodes each segment with a shared segment encoder, and aggregates them with a document encoder whose output is max-pooled into a document representation.

Pre-training then combines three objectives. NSP teaches document coherence using consecutive sentences within a paragraph as positives and random cross-paragraph sentences as negatives, with a binary cross-entropy loss. CLU is a margin-based contrastive objective that pulls a segment representation toward the TransE embedding of its true source paragraph and pushes it away from a randomly sampled unrelated paragraph (sampled uniformly from the 59 StVO paragraphs), but only when that unrelated paragraph falls within margin m. CLS is a binary classification head, but before classifying, the segment representation is used as a query to attend over all KG paragraph embeddings, producing a KG context vector that is fused with the segment representation through a learned gate; the gate can shut the retrieved context off when it is uninformative. The three losses are combined with weights that sum to 1.0.

Hyperparameters were searched over 36 λ configurations on a {0.0, 0.1, …, 0.9} grid per task under the unit-sum constraint, giving 324 runs total (9 models × 36 configs). Evaluation uses Macro-F1, Micro-F1, Precision, Recall and Balanced Accuracy, plus absolute m-F1 gain over each base model. Training used seed 42 on a single NVIDIA H100 with 80 GB.

Why This Matters

Impact on research. The paper argues that the gap between empirical accuracy and verifiable legal reasoning persists as a critical bottleneck in legal NLP, and offers one route around it: inject formal structure during pre-training so that graph traversal is not needed at inference. It also contributes a citation-grounded German benchmark in a space where existing resources (LexGLUE, LegalBench) are English, case-law-oriented, and lack paragraph citation sourcing. The finding that linguistic distance matters more than regulatory distance for transfer is a concrete, testable claim about cross-lingual legal NLP.

Real-world applications (from the paper's framing and setup):

  • Retrieval and question answering over statutory codes, where answers must cite the governing paragraph.
  • Structuring regulatory documents by parsing semi-structured hierarchies into knowledge graphs.
  • Comparative regulatory analysis, since the approach transfers to Austrian and Irish driving regulation content, though with variable performance.
  • Citation-accurate legal reasoning benchmarking, using the released synthetic StVO QA dataset as a test bed.

Industry relevance. Legal-tech and compliance systems need both accuracy and traceability; the paper's explicit aim is to serve reliable AI over semi-structured resources such as statutory books and contractual texts. The authors release the full pipeline code, the synthetic StVO QA dataset, the parsed knowledge graph, the TransE embeddings, the segmenter patterns, and all hyperparameters (seed 42, single H100), which lowers the barrier to reproducing or adapting the method. They state clearly that the models are research prototypes and are not intended to provide legally binding advice, and they discourage deployment in safety-critical settings such as automated driver assessment without human oversight.

Future Directions

  • Replace random CLU negative sampling with hard-negative sampling, which the paper names explicitly as the next step to address the interference observed for out-of-domain bases such as bert-base-contracts.
  • Extend the approach to other European regulatory corpora beyond the StVO.
  • Replace the dense CLS attention over the full paragraph-embedding set with approximate nearest-neighbor retrieval (the paper suggests FAISS) so that each query attends only to the top-k relevant paragraphs; the current cost grows linearly with the number of paragraphs and is untested for larger legal codes.
  • Extend the objectives to decoder-only models, which the paper leaves to future work, since the current study focuses on encoder-only architectures suited to discriminative binary classification.
  • Quantify the translation and embedding noise introduced by parsing an LLM-translated English StVO rather than the German original, and validate the synthetic QA pairs against human legal experts, since no held-out subset was validated by human legal experts.

Target Audience

Researchers and practitioners in legal NLP, domain-adaptive pre-training, and knowledge-graph-augmented language modeling who are comfortable with Transformer pre-training objectives and graph embedding methods. It is also relevant to teams building citation-grounded retrieval or QA systems over semi-structured regulatory text, and to researchers working on cross-lingual transfer within specialized domains. Readers looking for beginner-level introductions to legal NLP will find the technical machinery dense, and readers seeking state-of-the-art results measured on authentic legal examinations should note the authors' own caveat that the StVO QA pairs are LLM-generated and share generators with the training data, so gains should be read as evidence on synthetic legal QA rather than on authentic exams.

Authors’ abstract

Legal language understanding requires reasoning over semi-structured regulatory documents, yet standard pre-training objectives do not explicitly target this structural capability. Because current legal language models rely solely on masked language modeling, they treat statutory text as flat token sequences and ignore the underlying hierarchical constraints. To bridge this gap, we present a multi-task pre-training approach for German traffic law (StVO). Our approach combines three complementary objectives: Next Sentence Prediction (NSP), Knowledge Graph (KG) Guided Clustering (CLU), and Knowledge Graph (KG) Aware Paragraph Classification (CLS). This approach explicitly encodes structured legal knowledge directly into the model weights. This encoding enables zero-shot legal reasoning at inference time and removes the need for discrete graph traversal. We evaluate our approach across nine Transformer-based encoders and 324 experimental runs. On synthetic StVO question answering, our models demonstrate consistent relative improvements between 10.3% and 155.0% over baselines. Furthermore, relative to the established LexGLUE baselines (Chalkidis et al., 2022), our models improve over prior results on four of seven legal benchmarks. It also achieves consistent zero-shot transfer gains between 3.4% and 15.8% on Austrian driving regulations. These experimental results indicate that our training approach generalizes successfully beyond the initial training legal domain.

Read the original paper