Text Generation
Transformers
Safetensors
English
llama
legal
finance
small-language-model
from-scratch
instruction-tuned
question-answering
contract-analysis
sft
Eval Results (legacy)
text-generation-inference
Instructions to use DeependraVerma/legal-slm-500m-sft with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use DeependraVerma/legal-slm-500m-sft with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="DeependraVerma/legal-slm-500m-sft")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("DeependraVerma/legal-slm-500m-sft") model = AutoModelForCausalLM.from_pretrained("DeependraVerma/legal-slm-500m-sft", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use DeependraVerma/legal-slm-500m-sft with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "DeependraVerma/legal-slm-500m-sft" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "DeependraVerma/legal-slm-500m-sft", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/DeependraVerma/legal-slm-500m-sft
- SGLang
How to use DeependraVerma/legal-slm-500m-sft with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "DeependraVerma/legal-slm-500m-sft" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "DeependraVerma/legal-slm-500m-sft", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "DeependraVerma/legal-slm-500m-sft" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "DeependraVerma/legal-slm-500m-sft", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use DeependraVerma/legal-slm-500m-sft with Docker Model Runner:
docker model run hf.co/DeependraVerma/legal-slm-500m-sft
Upload folder using huggingface_hub
Browse files- README.md +112 -102
- model.safetensors +1 -1
README.md
CHANGED
|
@@ -26,7 +26,7 @@ model-index:
|
|
| 26 |
type: DeependraVerma/legal-slm-500M-sft-validation
|
| 27 |
metrics:
|
| 28 |
- type: f1
|
| 29 |
-
value: 0.
|
| 30 |
name: Token-F1 (grounded extraction)
|
| 31 |
- task:
|
| 32 |
type: text-generation
|
|
@@ -36,7 +36,7 @@ model-index:
|
|
| 36 |
type: DeependraVerma/legal-slm-500M-sft-validation
|
| 37 |
metrics:
|
| 38 |
- type: accuracy
|
| 39 |
-
value: 0.
|
| 40 |
name: Exact-match accuracy (96 non-colliding clause categories)
|
| 41 |
- task:
|
| 42 |
type: text-generation
|
|
@@ -46,7 +46,7 @@ model-index:
|
|
| 46 |
type: Rowan/hellaswag
|
| 47 |
metrics:
|
| 48 |
- type: acc_norm
|
| 49 |
-
value: 0.
|
| 50 |
name: acc_norm, zero-shot, via lm-evaluation-harness
|
| 51 |
- task:
|
| 52 |
type: text-generation
|
|
@@ -56,7 +56,7 @@ model-index:
|
|
| 56 |
type: allenai/ai2_arc
|
| 57 |
metrics:
|
| 58 |
- type: acc_norm
|
| 59 |
-
value: 0.
|
| 60 |
name: acc_norm, zero-shot, via lm-evaluation-harness
|
| 61 |
- task:
|
| 62 |
type: text-generation
|
|
@@ -66,7 +66,7 @@ model-index:
|
|
| 66 |
type: ybisk/piqa
|
| 67 |
metrics:
|
| 68 |
- type: acc_norm
|
| 69 |
-
value: 0.
|
| 70 |
name: acc_norm, zero-shot, via lm-evaluation-harness
|
| 71 |
- task:
|
| 72 |
type: text-generation
|
|
@@ -76,7 +76,7 @@ model-index:
|
|
| 76 |
type: cais/mmlu
|
| 77 |
metrics:
|
| 78 |
- type: acc
|
| 79 |
-
value: 0.
|
| 80 |
name: acc, zero-shot — near the 25% random-chance floor for 4-choice, expected at this scale
|
| 81 |
- task:
|
| 82 |
type: text-generation
|
|
@@ -86,7 +86,7 @@ model-index:
|
|
| 86 |
type: cais/mmlu
|
| 87 |
metrics:
|
| 88 |
- type: acc
|
| 89 |
-
value: 0.
|
| 90 |
name: acc, zero-shot
|
| 91 |
- task:
|
| 92 |
type: text-generation
|
|
@@ -96,7 +96,7 @@ model-index:
|
|
| 96 |
type: cais/mmlu
|
| 97 |
metrics:
|
| 98 |
- type: acc
|
| 99 |
-
value: 0.
|
| 100 |
name: acc, zero-shot
|
| 101 |
- task:
|
| 102 |
type: text-generation
|
|
@@ -106,7 +106,7 @@ model-index:
|
|
| 106 |
type: coastalcph/lex_glue
|
| 107 |
metrics:
|
| 108 |
- type: acc_norm
|
| 109 |
-
value: 0.
|
| 110 |
name: acc_norm, zero-shot — at the 20% random-chance floor for 5-choice; already excluded from pretraining data
|
| 111 |
- task:
|
| 112 |
type: text-generation
|
|
@@ -116,7 +116,7 @@ model-index:
|
|
| 116 |
type: nguha/legalbench
|
| 117 |
metrics:
|
| 118 |
- type: accuracy
|
| 119 |
-
value: 0.
|
| 120 |
name: mean acc across 13 tasks (50% chance floor) — see repo for per-task breakdown
|
| 121 |
---
|
| 122 |
|
|
@@ -128,21 +128,58 @@ fine-tuned from [`DeependraVerma/slm-500m-base`](https://huggingface.co/Deependr
|
|
| 128 |
sources: US case law, SEC filings (10-K/10-Q/8-K/S-1/20-F), the Code of
|
| 129 |
Federal Regulations, the Federal Register, and educational web text. This is
|
| 130 |
the scaled-up successor to
|
| 131 |
-
[`DeependraVerma/legal-slm-125m-sft`](https://huggingface.co/DeependraVerma/legal-slm-125m-sft)
|
| 132 |
-
fine-tuned on the **exact same curated SFT dataset** so the two models are
|
| 133 |
-
directly comparable question-for-question.
|
| 134 |
|
| 135 |
- **Repo / full build:** [github.com/DeependraVerma/legal-slm-125M](https://github.com/DeependraVerma/legal-slm-125M)
|
| 136 |
- **Author:** [Deependra Verma](https://github.com/DeependraVerma) — Generative AI Researcher / AI Engineer ([Hugging Face](https://huggingface.co/DeependraVerma))
|
| 137 |
- **Base model:** [`DeependraVerma/slm-500m-base`](https://huggingface.co/DeependraVerma/slm-500m-base)
|
| 138 |
- **Predecessor (125M):** [`DeependraVerma/legal-slm-125m-sft`](https://huggingface.co/DeependraVerma/legal-slm-125m-sft)
|
| 139 |
|
| 140 |
-
> **Read "Known limitations" below before using this model for anything.**
|
| 141 |
-
>
|
| 142 |
-
>
|
| 143 |
-
>
|
| 144 |
> output as legal, financial, or factual advice.
|
| 145 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 146 |
## What this is
|
| 147 |
|
| 148 |
Same two-mode design as the 125M SFT model:
|
|
@@ -151,8 +188,9 @@ Same two-mode design as the 125M SFT model:
|
|
| 151 |
with your question; it extracts/classifies/answers from that given text.
|
| 152 |
This is the mode with real, measured reliability.
|
| 153 |
2. **Closed-book** — a general legal/financial question with no source text.
|
| 154 |
-
|
| 155 |
-
|
|
|
|
| 156 |
|
| 157 |
## Model description
|
| 158 |
|
|
@@ -167,67 +205,64 @@ Same two-mode design as the 125M SFT model:
|
|
| 167 |
|
| 168 |
## Training data
|
| 169 |
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
passages, distilled via a local Meta-Llama-3.1-70B-Instruct teacher.
|
| 176 |
-
Reusing the same dataset (rather than
|
| 177 |
-
rebuilding it) is valid because the tokenized data depends only on the
|
| 178 |
-
tokenizer, which both models share — it isolates the comparison to "does a
|
| 179 |
-
bigger, better-pretrained base model produce a better SFT result," not "is
|
| 180 |
-
the SFT data different."
|
| 181 |
|
| 182 |
| | |
|
| 183 |
|---|---|
|
| 184 |
-
| Train / val split |
|
|
|
|
| 185 |
| Method | full fine-tune (not LoRA), 2 epochs |
|
| 186 |
-
| Epoch 1 val_loss → epoch 2 val_loss | 0.1811 → 0.1897 (ticked up — a real, measured overfitting signal on this dataset size, matching the same pattern found in the earlier 5-source checkpoint; do not push epochs further without new data) |
|
| 187 |
|
| 188 |
## Evaluation
|
| 189 |
|
| 190 |
-
Full held-out validation set (1,
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
local Meta-Llama-3.1-70B-Instruct:
|
| 194 |
|
| 195 |
-
| Task |
|
| 196 |
|---|---|---|
|
| 197 |
-
| CUAD contract clause extraction (Token-F1) | 0.
|
| 198 |
-
| CUAD "clause not present" refusal accuracy |
|
| 199 |
-
| LEDGAR clause classification (exact-match) |
|
| 200 |
-
| Case law general Q&A (closed-book) | 50.0% |
|
| 201 |
-
| SEC filings general Q&A (closed-book) |
|
| 202 |
-
|
|
| 203 |
-
|
| 204 |
-
**A
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
|
|
|
|
| 211 |
|
| 212 |
## Known limitations — read before using
|
| 213 |
|
| 214 |
-
- **Open-book contract tasks work well and are the trustworthy mode**
|
| 215 |
-
|
| 216 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 217 |
A 528.5M-parameter model can store at most ~2 bits of knowledge per
|
| 218 |
parameter (Allen-Zhu & Li, ["Physics of Language Models: Knowledge Capacity
|
| 219 |
Scaling Laws"](https://arxiv.org/abs/2404.05405)) — roughly 132MB of total
|
| 220 |
compressible fact storage, shared across everything it knows. Combined with
|
| 221 |
-
the fact that most specific facts in its training data
|
| 222 |
-
|
| 223 |
-
|
| 224 |
-
|
| 225 |
-
|
| 226 |
-
|
| 227 |
-
|
| 228 |
-
|
| 229 |
-
hypothetical: specific invented clinical/legal details contradicting the
|
| 230 |
-
real source, and the vague-non-answer regression cited above.
|
| 231 |
|
| 232 |
**Never use this model's output as legal, financial, or factual advice.**
|
| 233 |
Always treat specific claims as unverified until checked against a primary
|
|
@@ -235,52 +270,27 @@ source, especially in closed-book use.
|
|
| 235 |
|
| 236 |
## External benchmark evaluation
|
| 237 |
|
| 238 |
-
|
| 239 |
-
|
| 240 |
-
[125M predecessor](https://huggingface.co/DeependraVerma/legal-slm-125m-sft) were
|
| 241 |
-
run through **`lm-evaluation-harness`** (the same framework behind a
|
| 242 |
-
widely used public LLM leaderboard) on five benchmark categories:
|
| 243 |
|
| 244 |
| Benchmark | Result | Baseline | Read |
|
| 245 |
|---|---|---|---|
|
| 246 |
-
| HellaSwag / ARC-Easy / PIQA (general commonsense) | 34.
|
| 247 |
-
| MMLU professional_law / jurisprudence / international_law | 24.
|
| 248 |
-
| CaseHOLD (pick the correct legal holding, via LexGLUE) |
|
| 249 |
-
| LegalBench — 13-task contract NLI/QA/CFR subset |
|
| 250 |
|
| 251 |
LegalBench isn't in `lm-eval-harness`'s default task set, so a 13-task,
|
| 252 |
-
contract-focused-plus-one-CFR-grounded subset was hand-configured
|
| 253 |
-
|
| 254 |
-
|
| 255 |
-
|
| 256 |
-
with an n-gram overlap scan against the full 7-source pretraining corpus
|
| 257 |
-
before trusting the result (a naive check first over-flagged common legal
|
| 258 |
-
boilerplate — standard-of-review language, ToS disclaimer text — as
|
| 259 |
-
"contamination"; a stricter re-check traced the real overlap to 5 of 1,853
|
| 260 |
-
documents, all explainable — e.g. a real, publicly available company's Terms
|
| 261 |
-
of Service — and none affecting the reported numbers, including zero real
|
| 262 |
-
overlap in the two newest sources, CFR and the Federal Register). SCOTUS,
|
| 263 |
-
ECtHR, and EUR-LEX (also part of LexGLUE) were excluded: those documents run
|
| 264 |
-
tens of thousands of tokens, far beyond this model's 1,024-token context, and
|
| 265 |
-
scoring on a truncated sliver of a document isn't a meaningful number.
|
| 266 |
-
|
| 267 |
-
**Fine-tuning note**: benchmark scores above are for this SFT model; the
|
| 268 |
-
pre-fine-tune base checkpoint scores slightly *higher* on every one of these
|
| 269 |
-
same benchmarks (a small "alignment tax" from specializing toward the
|
| 270 |
-
fine-tuning data's chat format) — see
|
| 271 |
-
[`DeependraVerma/slm-500m-base`](https://huggingface.co/DeependraVerma/slm-500m-base)'s
|
| 272 |
-
model card for those numbers if the benchmark categories above are your
|
| 273 |
-
primary interest.
|
| 274 |
|
| 275 |
**No comparably small domain-specific baseline exists.** We looked for a
|
| 276 |
small (<1B parameter), from-scratch, publicly-weighted *generative* legal- or
|
| 277 |
-
financial-domain model to compare against and found none for either domain
|
| 278 |
-
|
| 279 |
-
|
| 280 |
-
encoder-only, and FinGPT/FinMA/Fin-R1/FinTral are all 7B+ fine-tunes of
|
| 281 |
-
general-purpose models, while BloombergGPT never released weights at any
|
| 282 |
-
size. This absence is itself a relevant data point about the current state
|
| 283 |
-
of small, open, domain-specialized language models.
|
| 284 |
|
| 285 |
Full methodology, task configs, and raw logs:
|
| 286 |
[github.com/DeependraVerma/legal-slm-125M/tree/main/benchmarks](https://github.com/DeependraVerma/legal-slm-125M/tree/main/benchmarks).
|
|
|
|
| 26 |
type: DeependraVerma/legal-slm-500M-sft-validation
|
| 27 |
metrics:
|
| 28 |
- type: f1
|
| 29 |
+
value: 0.798
|
| 30 |
name: Token-F1 (grounded extraction)
|
| 31 |
- task:
|
| 32 |
type: text-generation
|
|
|
|
| 36 |
type: DeependraVerma/legal-slm-500M-sft-validation
|
| 37 |
metrics:
|
| 38 |
- type: accuracy
|
| 39 |
+
value: 0.758
|
| 40 |
name: Exact-match accuracy (96 non-colliding clause categories)
|
| 41 |
- task:
|
| 42 |
type: text-generation
|
|
|
|
| 46 |
type: Rowan/hellaswag
|
| 47 |
metrics:
|
| 48 |
- type: acc_norm
|
| 49 |
+
value: 0.3454
|
| 50 |
name: acc_norm, zero-shot, via lm-evaluation-harness
|
| 51 |
- task:
|
| 52 |
type: text-generation
|
|
|
|
| 56 |
type: allenai/ai2_arc
|
| 57 |
metrics:
|
| 58 |
- type: acc_norm
|
| 59 |
+
value: 0.4205
|
| 60 |
name: acc_norm, zero-shot, via lm-evaluation-harness
|
| 61 |
- task:
|
| 62 |
type: text-generation
|
|
|
|
| 66 |
type: ybisk/piqa
|
| 67 |
metrics:
|
| 68 |
- type: acc_norm
|
| 69 |
+
value: 0.6235
|
| 70 |
name: acc_norm, zero-shot, via lm-evaluation-harness
|
| 71 |
- task:
|
| 72 |
type: text-generation
|
|
|
|
| 76 |
type: cais/mmlu
|
| 77 |
metrics:
|
| 78 |
- type: acc
|
| 79 |
+
value: 0.2445
|
| 80 |
name: acc, zero-shot — near the 25% random-chance floor for 4-choice, expected at this scale
|
| 81 |
- task:
|
| 82 |
type: text-generation
|
|
|
|
| 86 |
type: cais/mmlu
|
| 87 |
metrics:
|
| 88 |
- type: acc
|
| 89 |
+
value: 0.2778
|
| 90 |
name: acc, zero-shot
|
| 91 |
- task:
|
| 92 |
type: text-generation
|
|
|
|
| 96 |
type: cais/mmlu
|
| 97 |
metrics:
|
| 98 |
- type: acc
|
| 99 |
+
value: 0.2479
|
| 100 |
name: acc, zero-shot
|
| 101 |
- task:
|
| 102 |
type: text-generation
|
|
|
|
| 106 |
type: coastalcph/lex_glue
|
| 107 |
metrics:
|
| 108 |
- type: acc_norm
|
| 109 |
+
value: 0.2000
|
| 110 |
name: acc_norm, zero-shot — at the 20% random-chance floor for 5-choice; already excluded from pretraining data
|
| 111 |
- task:
|
| 112 |
type: text-generation
|
|
|
|
| 116 |
type: nguha/legalbench
|
| 117 |
metrics:
|
| 118 |
- type: accuracy
|
| 119 |
+
value: 0.5605
|
| 120 |
name: mean acc across 13 tasks (50% chance floor) — see repo for per-task breakdown
|
| 121 |
---
|
| 122 |
|
|
|
|
| 128 |
sources: US case law, SEC filings (10-K/10-Q/8-K/S-1/20-F), the Code of
|
| 129 |
Federal Regulations, the Federal Register, and educational web text. This is
|
| 130 |
the scaled-up successor to
|
| 131 |
+
[`DeependraVerma/legal-slm-125m-sft`](https://huggingface.co/DeependraVerma/legal-slm-125m-sft).
|
|
|
|
|
|
|
| 132 |
|
| 133 |
- **Repo / full build:** [github.com/DeependraVerma/legal-slm-125M](https://github.com/DeependraVerma/legal-slm-125M)
|
| 134 |
- **Author:** [Deependra Verma](https://github.com/DeependraVerma) — Generative AI Researcher / AI Engineer ([Hugging Face](https://huggingface.co/DeependraVerma))
|
| 135 |
- **Base model:** [`DeependraVerma/slm-500m-base`](https://huggingface.co/DeependraVerma/slm-500m-base)
|
| 136 |
- **Predecessor (125M):** [`DeependraVerma/legal-slm-125m-sft`](https://huggingface.co/DeependraVerma/legal-slm-125m-sft)
|
| 137 |
|
| 138 |
+
> **Read "Known limitations" below before using this model for anything.**
|
| 139 |
+
> This revision fixes a real, tested usability bug (see below) and improves
|
| 140 |
+
> legal-benchmark performance, but it still hallucinates confidently on
|
| 141 |
+
> closed-book questions outside its training distribution. Never use its
|
| 142 |
> output as legal, financial, or factual advice.
|
| 143 |
|
| 144 |
+
## What's new in this revision
|
| 145 |
+
|
| 146 |
+
The previous revision of this model would respond to plain conversational
|
| 147 |
+
input ("Hi", "Thanks!", "How are you?") with unrelated, hallucinated
|
| 148 |
+
legal-sounding text — confirmed directly, not hypothetically: it had zero
|
| 149 |
+
conversational examples in its fine-tuning data, every training pair was a
|
| 150 |
+
legal/financial task. This revision adds two small, deliberately-scoped
|
| 151 |
+
slices to the SFT data (about 2.6% of the total):
|
| 152 |
+
|
| 153 |
+
- **~400 conversational pairs** (greetings, small talk, "what can you do"),
|
| 154 |
+
sourced from `HuggingFaceTB/everyday-conversations-llama3.1-2k` plus a
|
| 155 |
+
small hand-written set targeting the exact failure observed, so the model
|
| 156 |
+
responds naturally to plain conversational input instead of hallucinating.
|
| 157 |
+
- **~170 refusal pairs**, synthesized by the same local Llama-3.1-70B teacher
|
| 158 |
+
used for the rest of this dataset, covering five categories a small model
|
| 159 |
+
genuinely cannot answer (future predictions, private individual data,
|
| 160 |
+
invented/unverifiable legal specifics, real-time data, advice with no
|
| 161 |
+
facts given) — teaching a calibrated decline instead of a confident,
|
| 162 |
+
invented answer.
|
| 163 |
+
|
| 164 |
+
**Result, tested directly:**
|
| 165 |
+
- Conversational input now gets a sensible, on-topic response instead of
|
| 166 |
+
hallucinated legal text (confirmed by direct generation, not just a
|
| 167 |
+
benchmark proxy).
|
| 168 |
+
- LegalBench (13-task average) improved from 52.5% → **56.1%** — now ahead
|
| 169 |
+
of same-size-class Gemma-3-270M and within 0.7 points of OLMo-2-1B despite
|
| 170 |
+
a quarter its parameters.
|
| 171 |
+
- A rigorous, leak-free paired comparison (scoring both this revision and the
|
| 172 |
+
previous one on the same held-out questions that neither was trained on)
|
| 173 |
+
found case-law closed-book QA and LEDGAR classification **statistically
|
| 174 |
+
unchanged** — an earlier, naive before/after comparison had suggested a
|
| 175 |
+
regression there, but that comparison turned out to be measuring two
|
| 176 |
+
different, non-overlapping question samples, not a real capability change.
|
| 177 |
+
- The same clean comparison found a **real, modest drop in CUAD extraction
|
| 178 |
+
precision** (Token-F1 0.886 → 0.818 on the matched, held-out subset) —
|
| 179 |
+
reported here plainly rather than hidden, consistent with this project's
|
| 180 |
+
practice throughout. If precise contract-clause extraction is your primary
|
| 181 |
+
use case, weigh this against the conversational and LegalBench gains.
|
| 182 |
+
|
| 183 |
## What this is
|
| 184 |
|
| 185 |
Same two-mode design as the 125M SFT model:
|
|
|
|
| 188 |
with your question; it extracts/classifies/answers from that given text.
|
| 189 |
This is the mode with real, measured reliability.
|
| 190 |
2. **Closed-book** — a general legal/financial question with no source text.
|
| 191 |
+
Weaker and riskier — see Known limitations. Now also handles plain
|
| 192 |
+
conversational input and declines gracefully on genuinely unanswerable
|
| 193 |
+
questions (see "What's new" above).
|
| 194 |
|
| 195 |
## Model description
|
| 196 |
|
|
|
|
| 205 |
|
| 206 |
## Training data
|
| 207 |
|
| 208 |
+
Builds on the curated SFT dataset shared with the 125M model — CUAD contract
|
| 209 |
+
clause extraction (CC BY 4.0), LEDGAR clause classification (CC BY 4.0), and
|
| 210 |
+
open-book QA/summarization/extraction over case-law/SEC/educational-web
|
| 211 |
+
passages, distilled via a local Meta-Llama-3.1-70B-Instruct teacher — plus
|
| 212 |
+
the ~570 conversational/refusal pairs described above.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 213 |
|
| 214 |
| | |
|
| 215 |
|---|---|
|
| 216 |
+
| Train / val split | 21,064 / 1,108 |
|
| 217 |
+
| Total pairs | 22,172 (21,602 original + 398 conversational + 172 refusal) |
|
| 218 |
| Method | full fine-tune (not LoRA), 2 epochs |
|
|
|
|
| 219 |
|
| 220 |
## Evaluation
|
| 221 |
|
| 222 |
+
Full held-out validation set (1,108 examples), same methodology as previous
|
| 223 |
+
revisions — extraction/classification against ground truth, general QA
|
| 224 |
+
judged by an independent local Meta-Llama-3.1-70B-Instruct:
|
|
|
|
| 225 |
|
| 226 |
+
| Task | Previous revision | **This revision** |
|
| 227 |
|---|---|---|
|
| 228 |
+
| CUAD contract clause extraction (Token-F1) | 0.786 | 0.798 (aggregate) / **0.818** (leak-free matched subset, n=25) |
|
| 229 |
+
| CUAD "clause not present" refusal accuracy | 84.7% | 84.2% |
|
| 230 |
+
| LEDGAR clause classification (exact-match) | 79.1% | 75.8% (aggregate) / **80.0%** (leak-free matched subset, n=10 — unchanged) |
|
| 231 |
+
| Case law general Q&A (closed-book) | 50.0% | 43.5% (aggregate) / **28.6%** (leak-free matched subset, n=14 — unchanged vs. previous on same subset) |
|
| 232 |
+
| SEC filings general Q&A (closed-book) | 56.2% | 54.9% |
|
| 233 |
+
| Refusal on genuinely unanswerable questions | n/a (not tested previously) | **90.9%** |
|
| 234 |
+
|
| 235 |
+
**A methodology note, stated plainly:** the "aggregate" numbers above compare
|
| 236 |
+
different, largely non-overlapping validation samples (re-curating the
|
| 237 |
+
dataset to add the new pairs reshuffled which examples land in val), which
|
| 238 |
+
makes some of the aggregate deltas look larger than the real effect. Where
|
| 239 |
+
possible, the matched columns above instead compare both revisions on the
|
| 240 |
+
*exact same* held-out questions that neither was trained on — that is the
|
| 241 |
+
number to trust for case-law and LEDGAR specifically. CUAD's matched
|
| 242 |
+
subsample does show a real, if modest, decline in extraction precision.
|
| 243 |
|
| 244 |
## Known limitations — read before using
|
| 245 |
|
| 246 |
+
- **Open-book contract tasks work well and are the trustworthy mode.**
|
| 247 |
+
- **Plain conversational input is now handled sensibly** (tested directly),
|
| 248 |
+
but this model was never trained for open-ended general-knowledge chat —
|
| 249 |
+
ask it something outside law/finance (e.g. general trivia) and it will
|
| 250 |
+
still confidently hallucinate, because its entire pretraining corpus is
|
| 251 |
+
legal/financial/regulatory text. This is a pretraining-scope limitation
|
| 252 |
+
that fine-tuning data cannot fix.
|
| 253 |
+
- **Closed-book general legal/financial Q&A is still fundamentally limited.**
|
| 254 |
A 528.5M-parameter model can store at most ~2 bits of knowledge per
|
| 255 |
parameter (Allen-Zhu & Li, ["Physics of Language Models: Knowledge Capacity
|
| 256 |
Scaling Laws"](https://arxiv.org/abs/2404.05405)) — roughly 132MB of total
|
| 257 |
compressible fact storage, shared across everything it knows. Combined with
|
| 258 |
+
the fact that most specific facts in its training data appeared only once
|
| 259 |
+
or twice, closed-book precision on rare facts is a hard capacity
|
| 260 |
+
limitation, not something more training on this same recipe fixes.
|
| 261 |
+
- **Confident fabrication on closed-book questions is real and was directly
|
| 262 |
+
observed**, not hypothetical.
|
| 263 |
+
- **A modest CUAD extraction-precision regression was measured** in this
|
| 264 |
+
revision (see Evaluation) — worth weighing if precise contract-clause
|
| 265 |
+
extraction is your primary use case.
|
|
|
|
|
|
|
| 266 |
|
| 267 |
**Never use this model's output as legal, financial, or factual advice.**
|
| 268 |
Always treat specific claims as unverified until checked against a primary
|
|
|
|
| 270 |
|
| 271 |
## External benchmark evaluation
|
| 272 |
|
| 273 |
+
Run through **`lm-evaluation-harness`** (the same framework behind a widely
|
| 274 |
+
used public LLM leaderboard) on five benchmark categories:
|
|
|
|
|
|
|
|
|
|
| 275 |
|
| 276 |
| Benchmark | Result | Baseline | Read |
|
| 277 |
|---|---|---|---|
|
| 278 |
+
| HellaSwag / ARC-Easy / PIQA (general commonsense) | 34.5% / 42.1% / 62.4% (acc_norm) | n/a | Normal range for a model this size — OLMo-2-1B (~2x params, general-purpose corpus) leads here as expected |
|
| 279 |
+
| MMLU professional_law / jurisprudence / international_law | 24.5% / 27.8% / 24.8% (acc) | 25% (4-choice) | Near the random-chance floor — no real legal knowledge memorized, as the caveats above already say |
|
| 280 |
+
| CaseHOLD (pick the correct legal holding, via LexGLUE) | 20.0% (acc_norm) | 20% (5-choice) | Right at random chance — real closed-book legal reasoning is not something this model can do |
|
| 281 |
+
| LegalBench — 13-task contract NLI/QA/CFR subset | **56.1% mean acc** | 50% (binary) | Genuine positive signal, improved from the previous revision's 52.5% — now ahead of Gemma-3-270M (53.4%) and within 0.7 points of OLMo-2-1B (56.7%) despite a quarter the parameters |
|
| 282 |
|
| 283 |
LegalBench isn't in `lm-eval-harness`'s default task set, so a 13-task,
|
| 284 |
+
contract-focused-plus-one-CFR-grounded subset was hand-configured and
|
| 285 |
+
checked for training-data contamination before trusting the result (see the
|
| 286 |
+
[repo](https://github.com/DeependraVerma/legal-slm-125M/tree/main/benchmarks)
|
| 287 |
+
for the full contamination-scan methodology).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 288 |
|
| 289 |
**No comparably small domain-specific baseline exists.** We looked for a
|
| 290 |
small (<1B parameter), from-scratch, publicly-weighted *generative* legal- or
|
| 291 |
+
financial-domain model to compare against and found none for either domain —
|
| 292 |
+
this absence is itself a relevant data point about the current state of
|
| 293 |
+
small, open, domain-specialized language models.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 294 |
|
| 295 |
Full methodology, task configs, and raw logs:
|
| 296 |
[github.com/DeependraVerma/legal-slm-125M/tree/main/benchmarks](https://github.com/DeependraVerma/legal-slm-125M/tree/main/benchmarks).
|
model.safetensors
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
size 2114179880
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d98982a9348f6d0eb5684e48bc189c03fafeb372bc1e2aba314ab2d034bf382e
|
| 3 |
size 2114179880
|