Gemma-2-2B-SFT · legal/financial Q&A

Google's Gemma-2-2B-it, fine-tuned with QLoRA on the exact same legal/financial Q&A dataset as the from-scratch SLM-125M — grounded in a passage you supply, or from general knowledge.

model card

Architecture

2.64B
total parameters
20.8M
trainable (LoRA), 0.79%
256,000
vocab size
NF4 4-bit
base model quantization
full architecture & QLoRA spec
parametervaluewhat it means
base modelGemma-2-2B-itGoogle's pretrained + instruction-tuned 2.64B-parameter model — not trained from scratch here
layers26number of stacked transformer blocks
hidden size2,304width of each token's internal representation
attention heads8 query / 4 KV (GQA)grouped-query attention — fewer KV heads than query heads to reduce memory
native context length8,192Gemma-2-2B's own max context; this fine-tune uses a shorter 1,024-token window (below)
vocabulary size256,000SentencePiece tokenizer — 16x larger than the SLM's custom 16K BPE vocab
quantizationNF4, 4-bitthe frozen base model is loaded at 4-bit precision to fit fine-tuning on a single GPU
LoRA rank (r)16dimensionality of the small trainable adapter matrices injected into each layer
LoRA alpha32scaling factor applied to the adapter's contribution
LoRA dropout0.05regularization on the adapter layers only
target modules7 per layerq/k/v/o attention projections + gate/up/down MLP projections get adapters; everything else stays frozen
trainable parameters20.8M (0.79%)only the adapters train — the other 99.21% of the model is untouched
training

How it was built

QLoRA fine-tune on the identical 11,989-example dataset (9,980 grounded + 2,009 open-domain) used for the SLM-125M, with the identical 200-example held-out split (same shuffle seed) — the two models were never trained on, or tested against, different questions.

11,789
train examples
2.03M
tokens/epoch (deployed checkpoint = epoch 1)
200
held out (identical to SLM's)
1×H100
44.2 min, ≈$2.91 (est.)
epoch 1
of 3 — see below

All 3 epochs were run and checkpointed to measure real eval_loss per epoch, rather than assume more training is better:

epocheval_loss 
10.537deployed — lowest loss
20.576worse — early overfitting
30.758worse still
optimizer & schedule
learning rate2e-4cosine schedule, 3% warmup
effective batch size16per-device batch 4 × gradient accumulation 4
max sequence length1,024fine-tuning tokenization cutoff (0 examples truncated at this length)
head-to-head

vs. SLM-125M

Both models generated answers to the identical 200 held-out questions (never trained on by either model). A blinded LLM judge graded each answer independently against the reference answer — never told which model produced it.

metricnSLM-125MGemma-2-2B
grounded accuracy15551.6%92.9%
open-domain accuracy4515.6%84.4%
grounding / faithfulness rate15558.1%92.9%

Gemma wins clearly on every axis — expected given the ~21x parameter gap and Google's much larger pretraining. This isn't a fair fight on raw quality, and isn't meant to be one: the more interesting comparison is 125M-from-scratch-and-fully-fine-tuned vs. 2.64B-pretrained-and-QLoRA-adapted, i.e. how much capability a lightweight adapter unlocks on a much bigger base versus building small from zero. Structural differences that make this not a clean isolated comparison: different tokenizers (16K custom BPE vs. 256K SentencePiece — raw loss/perplexity numbers on the two model-card sections above are not comparable to each other), full fine-tune vs. QLoRA adapter, and very different pretraining scale/data.

playground

Try it

80% of random pulls come from the 45 held-out questions never used in training (a true generalization test, identical set to the SLM's); 20% come from the open-domain training questions (more variety, but the model may recall a memorized answer). Each pull is labeled below.

ready
The answer will appear here.
honest limitations

What this is

This is Google's Gemma-2-2B-it, adapted (not retrained from scratch) via a QLoRA adapter — only 0.79% of its parameters were actually trained. With a passage, it reads whatever text is in the passage box and answers from it, including saying "Not stated in the passage." when the answer genuinely isn't there. With no passage, it answers from general knowledge — both from Google's original pretraining and from the same open-domain Q&A examples the SLM was trained on.

Only the checkpoint with the lowest held-out loss (epoch 1) is deployed — later epochs measurably overfit on this small fine-tuning set, so "more training" was not better here.