LexPam: Legal Procedure Awareness-Guided Mathematical Reasoning

Kepu Zhang, Guofu Xie, Weijie Yu, Mingyue Xu, Xu Tang, Yaxin Li, Jun Xu · OpenReview

Abstract

Legal mathematical reasoning is essential for applying large language models (LLMs) in high-stakes legal contexts, where outputs must be both mathematically accurate and procedurally compliant. However, existing legal LLMs lack structured numerical reasoning, and open-domain models, though capable of calculations, often overlook mandatory legal steps. To address this, we present LexNum, the first Chinese legal mathematical reasoning benchmark, covering three representative scenarios where each instance reflects legally grounded procedural flows. We further propose LexPam, a two-stage reinforcement learning framework for efficient legal reasoning training. Leveraging curriculum learning, we use a stronger teacher model to partition data into basic and challenging subsets. A lightweight 1.5B student model is then fine-tuned with Group Relative Policy Optimization (GRPO), which avoids costly value networks and enables stable training from sparse, end-of-sequence rewards. The first stage improves accuracy and format; the second introduces a novel reward to guide procedural alignment via task-specific legal elements. Experiments show that existing models perform poorly on LexNum, while LexPam enhances both mathematical accuracy and legal coherence, and generalizes effectively across tasks and domains.

Introduction

In the legal domain, mathematical reasoning is a "double-edged sword." It requires two distinct, often conflicting capabilities: arithmetic precision and procedural compliance. In a courtroom, reaching the correct final compensation figure is insufficient if the reasoning path ignores statutory steps, such as liability ratios, insurance caps, or specific compensation categories.

Current AI models typically fail in one of two directions. Specialized legal LLMs are often proficient at quoting statutes but prone to hallucinating simple arithmetic. Conversely, general-purpose reasoning models like DeepSeek-R1 are mathematically capable but often "over-think," becoming verbose or missing mandatory legal procedures, leading to outcomes that are procedurally invalid.

The LexNum Benchmark

To bridge this gap, we introduce LexNum, the first Chinese benchmark specifically designed for legal mathematical reasoning. Derived from real-world legal documents, LexNum covers three high-impact civil law scenarios:

  1. Economic Compensation: Calculations related to labor contract terminations.
  2. Work Injury Compensation: Determining benefits and insurance for workplace accidents.
  3. Traffic Accident Compensation: Liability-based damages involving compulsory insurance limits.
Figure 1: Examples of the three legal scenarios in the LexNum benchmark, illustrating the complexity of multi-step legal reasoning.

The dataset contains 2,965 training instances and 743 test instances. Each case requires the model to navigate complex legal dependencies where the final numerical answer is contingent on following a specific procedural flow.

The LexPam Framework

We propose LexPam, a two-stage Reinforcement Learning (RL) framework built on Group Relative Policy Optimization (GRPO). GRPO is an efficient alternative to traditional RLHF as it eliminates the need for a costly value network, making it ideal for training smaller, more efficient models.

Curriculum-Based Training

LexPam utilizes a curriculum learning strategy to stabilize the RL process. We use a "teacher" model (DeepSeek-R1-Distill-Qwen-7B) to partition the data into "basic" samples (those the teacher solves correctly) and "challenging" samples (those it fails).

  • Stage 1 (Foundation Training): A 1.5B student model is trained on basic samples to master fundamental arithmetic and output formatting, such as using <think> tags and boxed answers.
  • Stage 2 (Procedural Grounding): The model tackles challenging samples using a novel Procedural Reward ($r_{law}$). This reward measures the "weighted coverage" of task-specific legal keywords (e.g., "Liability," "Insurance Cap") within the model's reasoning chain, forcing the model to align its logic with statutory requirements.

Evaluation and Results

LexPam (1.5B) demonstrates remarkable performance, achieving an average accuracy of 60.65% across the LexNum benchmark. This significantly outperforms much larger models, including DeepSeek-R1-7B (31.52%) and GPT-4o-mini (56.93%). Notably, it approaches the performance of the massive 671B DeepSeek-R1 model (73.42%) while using a fraction of the parameters.

Generalization and Transferability

A critical finding is LexPam's ability to generalize across different legal domains. In cross-domain tests—where the model is trained on one scenario (e.g., Traffic Accidents) and tested on another (e.g., Work Injury)—LexPam consistently outperformed baseline models.

Figure 3: Cross-domain generalization results showing LexPam's superior performance when transferring knowledge between different legal scenarios.

Human evaluations conducted by law students further validate these results. LexPam scored highest (4.70/5.0) on completeness, coverage, and conciseness, indicating that its reasoning chains are more "user-friendly" and legally sound than those produced by general reasoning models.

Conclusion

LexPam demonstrates that procedural alignment is as vital as mathematical accuracy in specialized domains. By rewarding the presence of specific legal elements in the reasoning chain, we successfully bridge the gap between raw calculation and legal logic. Furthermore, our results suggest that small models, when guided by a well-designed reward function and curriculum, can rival the performance of massive general-purpose models on domain-specific tasks.

Summary updated

BibTeX
@misc{zhang2025lexpam,
  author = {Kepu Zhang and Guofu Xie and Weijie Yu and Mingyue Xu and Xu Tang and Yaxin Li and Jun Xu},
  title = {{LexPam: Legal Procedure Awareness-Guided Mathematical Reasoning}},
  year = {2025},
  eprint = {2504.02590},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2504.02590},
}
Figure