XLaw-JP-27B: A Lightweight Open Model Specialized for Japanese Law
Organizations: Keio University · X-Law, Inc.
Abstract
We present XLaw-JP-27B, an open-weight model specialized for Japanese law that runs on a single 48,GB GPU under the Apache2.0 licence. It adapts Qwen3.8-27B with hybrid retrieval over all current statutes and 31k case summaries, a light QLoRA fine-tune on its own verified answers to past bar-exam questions (self-distillation), a contract-specific LoRA adapter, and four-sample voting. We evaluate it on eight Japanese legal tasks---the multiple-choice section of the bar examination in 2024, 2025 and 2026, statement-level bar questions (JBE-QA), statute questions (LawQA-JP), the patent attorney exam, and contract review and drafting built from government model contracts---against open models of 12--33B under identical prompts and retrieval. XLaw-JP-27B ranks first on six tasks, ties on one and is third on one (mean rank 1.3 against 2.8--3.1 for the baselines). It is the only system that passes the bar exam in all three years (129, 120 and 130 of 175, meeting every subject minimum; no test-year material was used in training), while open Japanese 32--33B models fail at least one year. A controlled study of each component shows that retrieval, voting and self-distillation help, and that thinking mode, retrieval-grounded synthetic tuning, self-verification, per-statement decomposition and more self-distillation do not. The largest remaining gaps to frontier models are in contract review and patent law. The model is available as a free web service at https://x-law.jp/ with the weights available at https://huggingface.co/X-LawJapan/xlaw-jp-27b under Apache2.0.
Figures & tables
| Benchmark | Items | Metric | Test material |
|---|---|---|---|
| 司法試験 短答式 2024 | 77 | points/175 | held out |
| 司法試験 短答式 2025 | 77 | points/175 | held out |
| 司法試験 短答式 2026 | 77 | points/175 | held out |
| JBE-QA | 3,464 | MCC, F1 | 2015–24 |
| LawQA-JP | 140 | accuracy | statutes |
| Benrishi-MC (弁理士) | 120 | accuracy | 2024–25 |
| 2019 | 2020 | 2021 | 2022 | 2023 | 2024 | 2026 | |
|---|---|---|---|---|---|---|---|
| closed-book | 94 | 79 | 89 | 86 | 69 | 79 | 88 |
| + rag5 | 111 | 104 | 131 | 104 | 111 | 113 | 104 |
| rag4 | rag5 | |
|---|---|---|
| Statute recall (silver set) | 0.395 | 0.502 |
| Questions with 1 silver article | 0.844 | 0.921 |
| Statutes in context per question | 3.0 | 4.9 |
| 2026: mean of 4 runs / worst / vote@4 | 103.8 / 94 / 126 | 108.3 / 104 / 118 |
| 2024: mean of 4 runs / worst / vote@4 | 96.8 / 88 / 108 | 111.8 / 103 / 123 |
| Unanimous questions (2026) | 26/77 | 35/77 |
| Bar exam (points /175) | Benrishi-MC | LawQA-JP | JBE-QA § | OI-Contract | Mean | ||||
| Model (same prompts and rag5 retrieval) | 2024 | 2025 | 2026 | acc. | acc. | MCC | Review | Draft | rank |
| XLaw-JP-27B (vote@4; contract adapter) | 129 | 120 | 130 | 0.517 | 0.821 | 0.537 | 0.240 | 0.829 | 1.3 |
| single run (mean of 4) | 115.0 | 105.0 | 115.8 | 0.473 | 0.818 | 0.537 | 0.240 | 0.829 | 1.4 |
| Qwen3.8-27B base (vote@4) | 123 | – | 118 | 0.483 | 0.800 | 0.515 | 0.240 | 0.816 | |
| Gemma 4 12B | 90 ‡ | 87 | 101 | 0.350 | 0.821 | 0.534 | 0.228 | 0.794 | 2.8 |
| LLM-jp-4.1 33B (thinking) | 100 | 88 | 92 ‡ | 0.383 | 0.793 | 0.600 | 0.169 | 0.759 | 2.8 |
| System (one run unless noted) | 2024 | 2025 | 2026 |
| Pass mark | 93 | 81 | 99 |
| Gemma 4 12B, closed-book | 69 | – | 76 |
| Gemma 4 12B + rag4 | 83 | – | 78 |
| Gemma 4 12B + rag5 | 90 | 87 | 101 |
| LLM-jp-4.1 33B (thinking) + rag5 | 100 | 88 | 92 |
| Qwen3-Swallow-32B (thinking) + rag5 | 96 | 85 † | 82 |
| JBE-QA MCC | JBE-QA F1 | LawQA-JP | 弁理士 | 判例 ROUGE-L | JSQuAD EM | |
| Qwen3.8-27B, closed-book | 0.307 | 0.634 | 0.580 † | 0.300 | – | 0.875 |
| Qwen3.8-27B + rag5, vote@4 | 0.586 | 0.777 | 0.800 | 0.483 | 0.469 ∗ | – |
| E8 + rag5, vote@4 (ours) | 0.615 | 0.785 | 0.821 | 0.517 | 0.514 ∗ | 0.877 ∗ |
| E8 + gold articles (oracle) | – | – | 0.943 | – | – | – |
| Gemma 4 12B + rag5 | 0.598 | 0.786 | 0.821 | 0.350 | ||
| LLM-jp-4.1 33B (thinking) + rag5 | 0.600 § | 0.800 § | 0.793 | 0.383 |
| Held-out (OI-Contract) | Review | Draft |
|---|---|---|
| Qwen3.8-27B | 0.240 | 0.816 |
| E8 | 0.220 | 0.769 |
| Qwen3.8-27B + statute retrieval | 0.270 | |
| E8 + statute retrieval | 0.241 | |
| Issue-injection SFT (E17) | 0.242 | 0.810 |
| E8 + contract adapter (E17c) | 0.240 | 0.829 |
| Technique | Measured on | without | with |
|---|---|---|---|
| Thinking mode (16k) | 2026 + rag4, one run | 88 | 58 |
| JBE-QA + rag4 (400), MCC | 0.606 | 0.710 | |
| Retrieval-grounded SFT (15k) | 2026 + rag4, one run | 105 | 70 |
| Self-verification | vote@4, 2026 / 2024 | 126 / 108 | 126 / 102 |
| Statement decomposition | E8, 2026 / 2024 | 130 / 129 ∗ | 116 / 120 |
| 6 self-distillation | vote@4, 2026 / 2024 | 130 / 129 | 123 / 123 |
Legal NLP
Legal natural language processing (NLP) develops methods for analyzing and generating statutes, cases, contracts, and legal advice.
See all 111 papers