InternLM-Law: An Open Source Chinese Legal Large Language Model

Zhiwei Fei, Songyang Zhang, Xiaoyu Shen, Dawei Zhu, Xiao Wang, Maosong Cao, Fengzhe Zhou, Yining Li, Wenwei Zhang, Dahua Lin, Kai Chen, Jidong GearXiv 2024 · DOI

Abstract

InternLM-Law is an open-source 7B-parameter model specifically optimized for the Chinese legal domain. By employing a massive 1-million-sample dataset and a novel two-stage supervised fine-tuning (SFT) strategy, it outperforms GPT-4 and much larger models like Qwen-72B on the LawBench benchmark, particularly in legal consultation and long-document analysis.

Introduction

General-purpose Large Language Models (LLMs) often struggle in the legal field due to its high-stakes nature, specialized terminology, and the intricate logic required to interpret statutes. In the Chinese context, existing legal LLMs have historically suffered from limited task scope, outdated base architectures, and poor data quality that leads to factual hallucinations. InternLM-Law addresses these issues by utilizing a modern foundation and a rigorous data distillation process.

Methodology

The researchers used InternLM2-Chat as their foundation and implemented a two-stage Supervised Fine-Tuning (SFT) pipeline to balance domain expertise with general reasoning capabilities.

The two-stage SFT pipeline used to train InternLM-Law.
  • Stage 1 (Breadth): The model is trained on a massive mixture of legal-specific data and general-purpose instruction data. Keeping general data in the mix prevents the model from losing its core reasoning and linguistic abilities while it learns legal concepts.
  • Stage 2 (Depth): The model is refined using a smaller, "gold-standard" dataset of high-quality legal tasks. This stage focuses on polishing the response style, ensuring structured outputs, and improving factual accuracy regarding specific Chinese regulations.

To ensure high data quality, the authors curated a training set of over 1 million samples. They used a larger model (Qwen-1.5-72B) as a "semantic filter" to score the clarity and coherence of raw legal queries, distilling a high-signal dataset from 6 million initial records.

Key Results and Insights

InternLM-Law-7B achieved an average score of 67.71 on the LawBench benchmark, outperforming GPT-4 (52.35) and the much larger Qwen-1.5-72B (55.85). It secured the top spot in 13 out of 20 subtasks across memorization, understanding, and application levels.

Radar chart comparing InternLM-Law-7B performance against GPT-4 and other models on LawBench.

Performance Highlights:

  • Subjective Consultation: In head-to-head comparisons judged by GPT-4, InternLM-Law achieved an 87.5% win rate against GPT-4 on legal consultation tasks, providing more detailed and legally grounded advice.
  • Long Context Mastery: On a custom dataset of 20k+ character judicial judgments, InternLM-Law achieved an 84.73% F1 score, whereas earlier legal models like DISC-Law struggled significantly (36.72% F1) or failed entirely to process the length.
  • The Generalization Boost: A key finding was that adding general-purpose datasets doesn't just preserve "common sense"—it actually improves performance on legal tasks by helping the model learn universal problem-solving patterns.

Conclusion

InternLM-Law demonstrates that a medium-sized model (7B), when trained with high-quality data and a strategic two-stage pipeline, can outperform significantly larger general-purpose models in specialized domains. While challenges like multi-hop reasoning and occasional hallucinations remain, InternLM-Law provides a robust, open-source foundation for Chinese legal NLP. Future work will focus on scaling the model and enhancing its ability to handle highly nuanced, edge-case legal scenarios.

Summary updated

BibTeX
@misc{fei2024internlm,
  author = {Zhiwei Fei and Songyang Zhang and Xiaoyu Shen and Dawei Zhu and Xiao Wang and Maosong Cao and Fengzhe Zhou and Yining Li and Wenwei Zhang and Dahua Lin and Kai Chen and Jidong Ge},
  title = {{InternLM-Law: An Open Source Chinese Legal Large Language Model}},
  year = {2024},
  eprint = {2406.14887},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2406.14887},
}
Figure