A LoRA adapter for Qwen3-4B-Instruct-2507 that explains U.S. benefits notices (SNAP / Medicaid / TANF / SSI / housing …) under a falsifiable behavior spec, trained by dataset construction alone (no hyperparameter tuning between versions) on 124 checker-filtered teacher-distillation dialogs. GauntletAI Week 7 — "the dataset is the deliverable".
The behavior (spec v3): explain the letter using only vocabulary the reader has earned (a frozen 2,801-lemma allowed list + words the reader used + terms taught by glossing), reproduce every operative fact — dates, amounts, phone numbers, durations, case/form numbers, citations — character-for-character, quote-then-explain, never give advice, and always carry the mandated deadline banner on adverse actions. A deterministic checker scores every reply pass/fail; the LLM judge is an audit, not the headline.
| Path | What | Trained on |
|---|---|---|
/ (root) |
v4 adapter, N=123 — the headline checkpoint | dataset v4, 123 dialogs |
curve-N61/ |
data-efficiency point | nested subset, 61 dialogs |
curve-N30/ |
data-efficiency point | nested subset, 30 dialogs |
curve-N15/ |
data-efficiency point | nested subset, 15 dialogs |
bundle/slm-week7-bundle.zip |
the repo snapshot the Colab runs use (eval harness + demo + checker) | — |
The v3 (MVP) adapter is preserved at commit 3a314ede1 of this repo for
reproducibility of the first base-vs-tuned numbers.
Subsets are deterministically nested (15 ⊂ 30 ⊂ 61 ⊂ 123: shuffle by seed 3407, take the first N), same frozen harness for every point.
src/train/config.yaml)| Base | Qwen/Qwen3-4B-Instruct-2507 (non-thinking instruct), loaded 4-bit NF4 via Unsloth |
| Method | QLoRA SFT, assistant-only loss (train_on_responses_only), thinking mode off end-to-end |
| LoRA | r=16, α=32, dropout 0.05, all attention + MLP projections |
| Optimizer | AdamW-8bit, lr 2e-4 cosine, warmup 3 %, weight decay 0.01, effective batch 32 (4 × 8) |
| Epochs / seq | 3 epochs, max_seq_len 4096 (the spec system prompt alone is ~2.1k tokens) |
| Seed | 3407 (also the subsampling seed) |
| Run (N=123) | NVIDIA L4 (Colab), 20 min, final loss 0.94 — RUN.json / loss_log.csv committed in the project repo |
Nothing in this table changed between dataset v3 and v4: the v3 → v4 delta below is a data change only.
Prompt ceiling (why fine-tune): 192 frontier conversations — Claude
Opus 5 and Mistral Large × zero-shot / few-shot / structured-CoT × 32
scenarios. Best cell 16 % strict pass (Claude few-shot); every Mistral
cell 6 %. The surviving failure mode in both families is mechanical
fidelity (unearned_word, fabricated_quote).
Base vs tuned (10 frozen clean scenarios, same session, same metric):
| base Qwen3-4B | tuned v4 (this adapter) | |
|---|---|---|
| Strict pass | 0/10 | 1/10 |
| Violations / 100 words | 0.87 | 0.58 |
| "Must" softened into advice (advisory) | 3 | 7 — down from 33 with the v3 adapter |
| Judge audit (25 % sample) | 1/3 | 2/3 |
Data → behavior, measured: the MVP eval caught the v3 model softening obligations ("must" → "you'll want to"). The training data itself carried 197 softened-modal advisories across 92/123 dialogs; v4 cut that density 1.60 → 0.47 per dialog (3.4×) by dropping the 54 worst dialogs and regenerating under an advisory-repair gate — and the retrained model's softening fell 33 → 7 (4.7×) on identical scenarios.
Data-efficiency curve (same 10 scenarios): N=15 / 30 / 61 all 0/10
strict at ~1.0 viol/100w; N=123 is the first point that passes anything
(1/10, 0.62 viol/100w). Minimum viable N is > 61. The full 32-scenario
sweep (clean + adversarial + degraded) is the Final-submission run; see the
project repo's docs/requirements.md for the current state of that leg.
Known failure (documented, not hidden): the tuned model sometimes
capitalizes a letter's lowercase mid-sentence phrase when reusing it as a
quote-header ("Waive collection" for "waive collection"); the checker
correctly flags these as fabricated_quote (character-for-character
doctrine). Diagnosed as a base-model prior, not imitated data — see the
project's DECISIONS.md and Brainlift.
from peft import PeftModel
from transformers import AutoModelForCausalLM, AutoTokenizer
ADAPTER = "jmerithew1/qwen3-4b-benefits-notice-qlora" # root = v4, N=123
tok = AutoTokenizer.from_pretrained(ADAPTER)
base = AutoModelForCausalLM.from_pretrained("Qwen/Qwen3-4B-Instruct-2507",
dtype="auto", device_map="auto")
model = PeftModel.from_pretrained(base, ADAPTER) # subfolder="curve-N61" etc. for curve points
# (adapter_config.json names the Unsloth 4-bit mirror of the same base — either base id works.)
system = open("src/ablation/prompts/behavior_spec.md").read() # the spec IS the system prompt
messages = [{"role": "system", "content": system},
{"role": "user", "content": "I got this letter. Can you explain it?\n\n---\n<paste the notice>"}]
enc = tok.apply_chat_template(messages, add_generation_prompt=True,
enable_thinking=False, return_tensors="pt",
return_dict=True).to(model.device)
out = model.generate(**enc, do_sample=False, max_new_tokens=1024) # frozen decoding config
print(tok.decode(out[0][enc["input_ids"].shape[1]:], skip_special_tokens=True))
model.disable_adapter() gives the base model on the same weights — that
is exactly how the project's demo renders base vs tuned side by side.
One-command eval (the verification requirement):
python eval.py --model hf:jmerithew1/qwen3-4b-benefits-notice-qlora \
--baseline hf:Qwen/Qwen3-4B-Instruct-2507 \
--eval-set data/ablation/scenarios.jsonl
regenerates results.md / results.csv / transcripts.jsonl /
judge_verdicts.jsonl from nothing; --eval-set takes any scenario JSONL
in the documented schema (staff held-out sets included).
Live demo: python demo.py --adapter hf --share (Colab GPU) — paste any
letter, get base and tuned replies with live checker verdicts. A static
results explorer over the committed eval transcripts is at
jmerithew1/benefits-notices-demo.
labs.gauntletai.com/jamesmerithew/slm-week7 (mirror: github.com/jmerithew1/slm-week7)Research artifact for a one-week training project. The model explains synthetic-style benefits notices in plain English under a strict vocabulary ceiling; it is not legal or benefits advice and refuses to give any. Letters in the training set are synthetic (no real PII); eval letters are disjoint from training by exact notice text. Behavior outside the benefits-notice domain is untested.
adapter_model.safetensors 126 MiBcurve-N15/adapter_model.safetensors 126 MiBcurve-N30/adapter_model.safetensors 126 MiBcurve-N61/adapter_model.safetensors 126 MiB