A 125-million-parameter base language model

Legal & financial language, learned from nothing.

Trained from a random initialization on 2.04 billion tokens of US case law, SEC filings and educational web text, then asked to keep writing.

Try it live ↓Chat with the fine-tuned model →
125.8M
parameters
9.13
held-out perplexity
2.04B
unique tokens
16,384
BPE vocabulary
00
The map

Everything we built, at a glance

Three origins — a 125M we pretrained from noise, the mentor's 500M we adopted, and Google's Gemma 2 2B off the shelf — each run through the same five-phase pipeline: pretrain, SFT, RAFT, DPO, and RLAIF. Twenty-two models in all. Everything below is live.

Model family tree: three origins (125M from scratch, mentor 500M adopted, Gemma 2B off-the-shelf), each taken through pretrain, SFT, RAFT, DPO and RLAIF
01
Playground

Complete the passage

Give it the opening of a brief, a filing, or an opinion, then watch the model continue it, one token at a time. These are the real 125M model weights, generating live.

Base model
Starters
Length96 tokens
Creativity0.80
The completion will appear here, streamed token by token as the model writes it.

This is a base model: it continues text, it does not answer questions. It will confidently invent case names, citations and figures. Never rely on its output as legal, financial or factual advice.

02
Chat

Now ask it a question

Fine-tuned on 5,846 grounded legal & financial Q&A pairs, the same 125M model stops rambling and starts answering. It is a separate model, legal-slm-125m-sft ↗, that streams its reply as you watch.

Base
slm-125m-base
10-epoch peer base
Fine-tuned on
5,846 Q&A
Gemini-distilled + judged
SFT val loss
2.06
from 4.27
Fine-tune
1×L4 · ~80s
full fine-tune
Ask the SFT assistant
runs in your browser

Ask a legal or financial question. Pick a starter below or type your own.

Three SFT models on the same Q&A data: our 125M and 500M (full fine-tune) and Gemma 2B (QLoRA). The smaller ones will confidently invent case names and figures; the bigger ones are more fluent. Not legal or financial advice.

03
RAFT

Now ground it in your context

One more layer. legal-slm-125m-raft ↗ was RAFT-tuned (Retrieval-Augmented Fine-Tuning) to answer from context you provide, quote the exact source, and ignore unrelated distractor text. Paste a passage, add some noise, and ask.

Base
legal-slm-125m-sft
continued from SFT
Method
RAFT
context + distractors
Trained on
4,069 examples
OpenRouter-distilled
Answer-match
17.2%
1.0% → 7.9% → 17.2%
Answer from context
hosted GPU
Try an example
The grounded answer appears here. It quotes the context it relies on, then gives the final answer.

RAFT (Retrieval-Augmented Fine-Tuning): the model answers from the context you provide and ignores distractors. Faithfulness scales: the 125M can't reliably tell when the answer is absent (it will make one up), the 500M starts to, and Gemma declines cleanly — ask about something not in the context and compare. Not legal or financial advice.

04
Alignment

Preference-tuned: DPO and RLAIF

After SFT and RAFT, one more layer: align the model to preference. Pick a method — direct preference optimization (DPO), or a reward model plus GRPO (RLAIF) — a base stage to build on, and a size. Twelve real models, live on the GPU.

Method
Built on
Model
legal-slm-125m-sft-dpo
Trainable params
125.8M · 100% (full fine-tune)
Training tokens
SFT ~1.06M (2 epochs) · DPO 2,223 preference pairs × 2 epochs
DPO cost
~$0.30
Architecture
Llama-style · 12 layers · 768 dim · 12 heads (MHA) · 16,384 vocab · 1,024 ctx
The preference-optimized model's answer appears here.

Every combination is a real model on Hugging Face: DPO or RLAIF (reward model + GRPO), on top of the SFT or RAFT version, at 125M, 500M, or 2B. Preference optimization mostly tunes tone and structure, so read for quality, not just correctness. Not legal or financial advice.

05
Compare

Same data, two very different models

We ran the identical SFT and RAFT datasets through a real pretrained model — Gemma 2 2B ↗ — using QLoRA (4-bit base, only 0.79% of weights trained). Pick it in the model selectors of the Chat, RAFT, and Alignment panels above, next to our 125M and 500M. Here is exactly what each phase costs and trains.

Our SLM · 125M

from scratch
125.8M parameters · Llama-style decoder · 12 layers · 768 dim · 12 heads · 16,384 vocab · 1,024 ctx
Pretrainfull (from random init)
Trainable
125.8M · 100%
Train tokens
4.08B · 2 epochs
Compute
8×H100
Cost
~$36
SFTfull fine-tune
Trainable
125.8M · 100%
Train tokens
1.06M · 2 epochs · 5,846 Q&A
Compute
1×L4
Cost
~$0.05
RAFTfull fine-tune
Trainable
125.8M · 100%
Train tokens
5.42M · 2 epochs · 3,866 ctx
Compute
1×L4
Cost
~$0.30

Gemma 2 · 2B

pretrained · QLoRA
2.61B parameters · Gemma 2 decoder · 26 layers · 2,304 dim · 8 heads / 4 KV (GQA) · 256,000 vocab · 8,192 ctx
Basepretrained by Google
Trainable
Train tokens
~2T · we pay nothing
Compute
Google TPUs
Cost
$0
SFTQLoRA · 4-bit NF4
Trainable
20.8M · 0.79%
Train tokens
1.52M · 3 epochs · 5,846 Q&A
Compute
1×A100
Cost
~$4
RAFTQLoRA · 4-bit NF4
Trainable
20.8M · 0.79%
Train tokens
5.54M · 2 epochs · 3,866 ctx
Compute
1×A100
Cost
~$1.5

The trade is the whole lesson. Our 125M was built from a random init for ~$36 and is small enough to run in a browser tab — but it is a toy. Gemma borrows a $millions Google pretraining for free, trains 20.8Madapter weights instead of all 2.6B, and answers far more fluently — but it needs a GPU to serve, and every token it "knows" came from someone else's pretraining, not ours.

06
Leaderboard

Every model, one scoreboard

Every model on the same held-out sets, in two views. Quality is an independent LLM judge (DeepSeek-V3, which made none of our training data) scoring each answer out of 10 against a gold reference and its evidence — reference-grounded, so it is checkable rather than vibes, and it finally makes the DPO/RLAIF work visible. Capability is the tokenizer-fair side: bits-per-byte language modeling plus exact-match accuracy. Both include Gemma 2 2B off the shelf, so you can see what a real pretrained model scores with zero legal training.

Quality — an independent LLM judge scores each answer /10 against a gold reference
ModelMean /10 QA Grounded Refusal Quote valid Over-refusal
Gemma RAFT2.61B
best8.13
5.80
best8.70
best10.00
best94%
25%
Gemma RAFT + RLAIF2.61B
8.04
6.50
7.97
best10.00
67%
93%
Gemma RAFT + DPO2.61B
7.94
5.77
8.28
best10.00
61%
28%
Gemma 2B (off-the-shelf)2.61B
7.23
3.97
7.95
best10.00
23%
500M RAFT517M
6.24
best6.73
6.30
5.56
84%
25%
500M RAFT + DPO517M
6.13
5.80
6.40
6.08
79%
25%
Gemma SFT2.61B
6.02
5.87
5.80
6.56
best0%
Gemma SFT + RLAIF2.61B
5.88
5.17
5.75
6.96
best0%
500M RAFT + RLAIF517M
5.77
5.57
6.38
5.04
79%
25%
Gemma SFT + DPO2.61B
5.55
4.77
5.03
7.32
best0%
500M SFT + RLAIF517M
4.80
4.20
2.75
8.80
best0%
Our SFT + RLAIF125.8M
4.47
2.47
3.25
8.84
3%
500M SFT + DPO517M
4.21
3.87
2.88
6.76
best0%
Our SFT + DPO125.8M
4.14
2.90
2.33
8.52
best0%
500M SFT517M
3.95
3.60
2.92
6.00
best0%
Our SFT125.8M
3.89
2.80
1.82
8.52
3%
Our RAFT + DPO125.8M
3.78
2.23
3.33
6.36
44%
best0%
Our RAFT + RLAIF125.8M
3.76
2.93
4.28
3.92
37%
best0%
Our RAFT125.8M
3.29
3.00
3.95
2.60
39%
best0%
500M base (mentor)517M
2.36
1.27
1.85
4.48
best0%
Our base125.8M
1.95
1.17
1.43
3.72
best0%
Mentor base125.8M
1.55
0.37
0.45
4.72
best0%

Mean /10 Mean judge score across all held-out items, out of 10 (correctness 0-5 · completeness 0-2 · groundedness 0-2 · clarity 0-1).

QA Closed-book QA — answer from the weights, no context.

Grounded Grounded (RAFT) — answer with the relevant context provided.

Refusal Unanswerable — the correct answer is to decline; fabricating scores near 0.

Quote valid Of grounded answers that quote, the fraction whose quote really appears in the context (programmatic).

Over-refusal Fraction of ANSWERABLE questions the model wrongly declines. Lower is better.

Judge: deepseek/deepseek-chat at temperature 0, blind and pointwise, graded against gold answers + evidence from a held-out corpus set (it made none of our training data). Green marks the best in each column. Re-judge self-agreement: 64% exact, 79% within one point.

Two things jump out. Grounded accuracy climbs at every stage — our tiny model goes 1.4% → 7.1% → 24.3% across base → SFT → RAFT, and Gemma lands highest at 37%. But watch the faithful-refusal column: Gemma off-the-shelf already declines 90% of unanswerable questions, our SFT step destroys that instinct (it learns to always answer, 0%), and only RAFT with abstention examples brings it back — to 100% for Gemma. And you can watch abstention emerge with scale: the 125M RAFT never learns to refuse (0%), the 500M RAFT starts to (20%), Gemma nails it (100%). Faithfulness isn't a prompt trick — past a point it's a capability that costs parameters.

The + DPO and + RLAIF rows are a full preference-optimization sweep on top of every SFT and RAFT model (DPO on ~4.7k AI-labeled pairs; RLAIF = a Bradley-Terry reward model then GRPO). Read them honestly: these methods tune response quality and style— helpfulness, structure, and, where the pairs teach it, faithfulness — which strict exact-match accuracy barely registers. So the capability columns hold roughly steady (they mostly don't regress), faithful refusal is preserved (Gemma RAFT stays at 100% through both), and where a model over-optimizes you can see it: Gemma RAFT + DPO's bits/byte balloons to 1.59 as it leans hard into the preferred abstain-heavy style. Quantifying the quality gain itself would need an LLM-judge win-rate — the natural next column.

07
Cost

What the whole thing cost

Every model on the board, every dataset, every GPU-hour — tracked. Building a base model from scratch is the expensive part; adapting one is cheap. Here is the honest ledger.

Models we trained
Our 125M base
pretrain · 8×H100 · 2 epochs
$36.00
Our 125M SFT / RAFT
full fine-tune · 1×L4
$0.35
500M SFT / RAFT
full fine-tune · 1×A100
$0.45
Gemma 2B SFT (QLoRA)
1×A100 · ~1.8h
$4.00
Gemma 2B RAFT (QLoRA)
1×A100 · ~0.6h
$1.50
DPO ×6
SLM full-FT + Gemma QLoRA · A100
$3.50
Reward models ×2
500M Bradley-Terry · A100
$0.80
RLAIF / GRPO ×6
on-policy · A100 · incl. 3 timeout retries (~$9 waste)
$16.00
subtotal$62.60
Shared data & infrastructure
Data pipeline
clean · dedup · decontaminate · CPU
$2.00
SFT Q&A dataset
Gemini teacher + judge
$2.00
RAFT dataset
MiniMax-M3 teacher + judge
$7.20
Preference pairs
MiniMax-M3, ~4.7k pairs
$2.60
Evals + serving
capability + LLM-judge evals + scale-to-zero endpoints
$4.50
subtotal$18.30
Grand total, everything
21 models · data → pretrain → SFT → RAFT → DPO → RLAIF
~$81

Estimated from GPU type × wall-clock on Modal (H100 ~$3.95/hr, A100-40 ~$2.10/hr, L4 ~$0.80/hr) plus OpenRouter and Gemini usage. The pretraining alone is ~45% of it; every fine-tune after that — SFT, RAFT, six DPO models, two reward models, six RLAIF models — together cost less than the base model did. The borrowed bases (the mentor's 125M and 500M, and Gemma 2B) cost us nothing to make — that is the whole economic case for building on pretrained models.

08
Inference

Making generation fast

Two optimizations every real serving stack uses, running live on GPUs. The first is exact and free; the second is exact but only pays off when a small model can guess what a big one will say.

KV cache · 125M SLM

Without a KV cache the model recomputes attention over the whole growing sequence every step. With it, each step reuses the stored keys/values. Raise the batch size (more concurrent "users") and watch the gap explode.

1128 tokens each · greedy64
Speculative decoding · Qwen 2.5 7B + 0.5B

The small 0.5B draft proposes several tokens at once; the big 7B target verifies them in a single pass and keeps the longest prefix it agrees with. Same output as the 7B alone, but the speedup rides entirely on how often the draft is right.

The lesson in both: throughput is not one number. The KV cache turns a quadratic cost linear, and its payoff grows with how many users you batch together. Speculative decoding trades extra draft compute for fewer expensive target steps, and only wins when the draft agrees often enough — try a numbered list versus a poem and watch the acceptance rate, and the speedup, move together.

09
The numbers

Small model, honest accounting

Trainable parameters
125,848,320
tied embeddings
Unique training tokens
2.04 billion
after dedup + decontam
Tokens seen
4.08 billion
2 epochs
Held-out perplexity
9.13
20.6M-token val set
Final validation loss
2.211
cross-entropy
Compute
8 × H100
bfloat16, ~30% MFU
10
Training

Perplexity, falling

Held-out perplexity measured on a 20.6-million-token validation set the model never trained on. Two epochs, 7,778 optimizer steps, from a random start to 9.13.

9111315179.131k4k7.8kOPTIMIZER STEP →
11
Architecture

A Llama, in miniature

Architecture
Llama-style decoder
Layers · dim · heads
12 · 768 · 12
Head dimension
64 (multi-head)
Context length
1,024 tokens
Positional
RoPE (θ = 10,000)
Normalization
RMSNorm (1e-5)
Activation
SwiGLU (silu)
Vocabulary
16,384 byte-level BPE
Embeddings
tied input / output
Precision
bfloat16
tokens → 16,384 BPE embedding
01
02
03
04
05
06
07
08
09
10
11
12
RMSNorm → tied LM head → logits
12 decoder blocks · RoPE · SwiGLU
12
The corpus

Two billion tokens, hand-cleaned

Streamed from public datasets, then run through a deterministic pipeline: rule-based cleaning, an OCR-garble gate, MinHash-LSH near-duplicate removal, and 13-gram decontamination against the CaseHOLD and LexGLUE benchmarks.

2.04BTOKENS
  • 35%US case lawHFforLegal/case-law
  • 42%SEC filingsPleIAs/SEC
  • 23%Educational webfineweb-edu
13
Caveats

What this is, and is not

§

It is a base (pretrained) model, a next-token predictor. It has never been instruction-tuned, aligned, or shown a single question-answer pair.

§

It will fabricate case names, docket numbers, statutes and financial figures with total confidence. Everything it writes is fiction shaped like law.

§

English only, 1,024-token context, 125M parameters. It is a study in doing a lot with very little. It is not a product, and never legal or financial advice.