Lawma 8B, fine-tuned on court records, beat Claude 3.7 Sonnet at legal annotation
Made by Ricardo Dominguez-Olmedo and eight co-authors
The result
The story
Coding court cases at scale
Empirical legal scholars study courts by coding cases: the issue area, whether a decision overruled a precedent, which way it leaned ideologically. Trained research assistants usually do the coding, which caps a study at a few hundred or a few thousand documents, so scholars have started prompting commercial models instead. A team led from the Max Planck Institute for Intelligent Systems tested whether that is the best option.

Data
CaselawQA
260 tasks; 718,971 examples from 24,916 cases, 143,635 of them in the test split
Codes from the U.S. Supreme Court Database and the Songer Court of Appeals database, matched to majority opinions from the Caselaw Access Project
Split 70/10/20 by case. The most common answer is capped at half of each task, so always guessing it scores 40% on average.
The team turned two long-running court databases into CaselawQA: 260 multiple-choice tasks, each asking one question about a court opinion in the wording of the databases’ own codebooks. Cases were split into training, validation and test sets, and the benchmark’s test set is 10,000 examples drawn at random from the test cases, half from each court.
The general models
Large model
Claude 3.7 Sonnet
Size not disclosed · Anthropic
Used as released, zero-shot, with the same multiple-choice prompt as every other model and an instruction to think step by step
- Base
- Anthropic’s general model, run without extended reasoning
Every model got the same prompt in the style of the MMLU benchmark: the task description, the opinion, the question and the answer options, plus an instruction to think step by step, with no task- or model-specific tuning. Claude 3.7 Sonnet did best among the general models at 78%, ahead of DeepSeek R1 (77%), GPT-4.5 Preview (76%) and GPT-4o (74%). Averages hide a long tail: Llama 3.1 405B Instruct failed to beat always guessing the most common answer on 58 tasks.
One Llama, all 260 tasks
Small model
Lawma 8B
8B · Meta (base model)
Fully fine-tuned by the Lawma authors on all 260 CaselawQA tasks at once
- Base
- Llama 3.1 8B Instruct
The authors then fine-tuned Llama 3.1 8B Instruct on the training split of all 260 tasks at once, about 553,000 examples and 2.2 billion tokens, and called the result Lawma 8B. The same recipe on other bases gave Lawma models from 135M to 70B parameters.
Training
Full fine-tune for 3 epochs
AdamW, peak learning rate 2e-6 with a cosine schedule, sequences up to 8,192 tokens
- Time
- About 600
H100 GPU-hours
Not reported: cost.
Evaluation
10,000 test items
- Test set
- CaselawQA test set: 5,000 Supreme Court and 5,000 Court of Appeals examples from test-split cases
- Metric
- Accuracy, averaged over all test examples
- How it was compared
- Same examples, prompt template and scoring for every model. Claude 3.7 Sonnet ran without extended reasoning and o3-mini at high effort; temperature isn’t stated.
Lawma 8B scored 87%, nine points above Claude 3.7 Sonnet. On ten tasks the authors highlight for legal research, it beat Claude and Llama 3.1 405B on seven and matched them on three, with leads of 30 points on the lower court’s ideological direction and 20 on where a case originated. The paper also says accuracy varies widely between tasks, and Lawma 8B still does poorly on a sizable number of them.
A few hundred labels
In a separate test, the same base fine-tuned on one task at a time with 1,000 or fewer labelled examples matched or beat Claude 3.7 Sonnet on 7 of the 10 highlighted tasks. Fine-tuning only on Court of Appeals tasks raised Supreme Court accuracy from 50% to 64%, still 16 points below Claude, which the authors read as a sign that the training tasks must match the target ones.
The paper gives no costs or response times. It notes that Lawma 8B fits on a single H100 GPU.
All the numbers
Show all numbersHide all numbersEvery model · Cost, latency and energy · 5 more results
Every model on the headline test
arXiv v2’s Section 4.1 text says 86% for Lawma 8B while its Figures 1 and 9 show 0.87; the ICLR text says 87%.
Cost, latency and energy, as reported
- Cost
- Not reported
- Latency
- Not reported
- Energy
- Not reported
More from the source
CaselawQA accuracy, all models in Figure 1 (arXiv v2)
model value Llama 3.1 8B Instruct (not fine-tuned) 0.59 Qwen 2.5 72B Instruct 0.7 Llama 3.3 70B Instruct 0.71 o3-mini (high) 0.71 GPT-4o 0.74 Llama 3.1 405B Instruct 0.75 GPT-4.5 Preview 0.76 DeepSeek R1 0.77 Claude 3.7 Sonnet 0.78 Lawma 135M 0.83 Lawma 8B 0.87 Lawma 70B 0.88 law: arXiv v2 Figure 1
Accuracy of always guessing the most common answer
40 %
law: arXiv v2 Section 3
SC LC Direction task, Lawma 8B lead over Claude 3.7 Sonnet
30 percentage points
law: arXiv v2 Section 4.1; ICLR Section 4.1
Songer Case Origin task, Lawma 8B lead over Claude 3.7 Sonnet
20 percentage points
law: arXiv v2 Section 4.1; ICLR Section 4.1
Highlighted tasks where Lawma 8B beats Claude 3.7 Sonnet and Llama 3.1 405B
7 of 10 (matches them on the other 3)
law: arXiv v2 Section 4.1
Worth knowing
- Lawma was fine-tuned on these exact tasks while the commercial models were only prompted (zero-shot, no examples). The paper’s point is that specialising pays off; it is not a like-for-like setup.
- Numbers differ slightly between versions: Lawma 8B is 87% in the ICLR text and in arXiv v2’s figures but 86% in arXiv v2’s Section 4.1 text. Lawma 135M is 82% (arXiv v2 intro), 83% (arXiv v2 Section 4.1 and Figure 9) and 0.77, ‘competitive with’ Claude, in the ICLR version. This file headlines Lawma 8B for that reason.
- Claude 3.7 Sonnet ran without extended reasoning; o3-mini ran with high reasoning effort.
- Accuracy varies widely across tasks, and Lawma 8B performs poorly on a sizable number of them (arXiv v2 Section 4.1).
1 more caveat
- The code README on GitHub reports an older comparison with GPT-4 (‘outperform GPT-4 on 95% of these legal classification tasks’); this page uses the paper’s newer numbers.
Weights on Hugging Face
Checked 03 Oct 2026 via the Hugging Face MCP: 8.03B parameters, MIT licence, tagged arxiv:2407.16615, dataset ricdomolm/lawma-all-tasks. Also published: ricdomolm/lawma-70b and ricdomolm/lawma-135m (exists, sparse model card).
- ricdomolm/lawma-8bLawma 8B
Sources
- Dominguez-Olmedo et al., ‘Lawma: The Power of Specialization for Legal Annotation’, arXiv 2407.16615 v2 (23 Apr 2025)
- ICLR 2025 (poster), OpenReview
- Lawma 8B, Hugging Face
- Code, GitHub socialfoundations/lawma
- arXiv v1 23 Jul 2024; numbers from arXiv v2 (23 Apr 2025) and the ICLR 2025 conference version (poster).

