I Trained My Model on Purpose Until It Broke — and Every Metric Said 'Fine'

Part 1 left three questions open: how do you clean data, how do you tell "learned" from "memorized," and what does overfitting look like?

One controlled experiment answers all three: same data, same hyperparameters, only 6 epochs → 30.

The conclusion is uncomfortable: when the model broke, every conventional metric said "we're fine."

TL;DR

  • Data cleaning isn't hand-picking, it's three code assertions: dedup, leak prevention, negatives. Miss one and every downstream score is self-deception
  • One formatting change was worth 5 questions: article number moved from the front of the answer to after the title, 11/20 → 16/20
  • I trained it until it broke on purpose: train loss 0.00016, 19/20 on the 20-question eval — one higher than normal
  • But eval loss never turned up — no textbook U-curve. Probe pass rate didn't either: 5/12 by epoch 8, then pinned. Neither decoupled
  • The damage is all out-of-distribution: normal hallucinates convincingly; overfit stitches and gives itself away

1. First, separate the three "evals" (the easiest place to misread this post)

Three different things get called "eval"; mix them and the numbers contradict each other. Every number below follows this:

Name What it is How it's scored Referred to as
Validation set 27 rows held out from the 264, same distribution teacher forcing, token-level cross-entropy eval loss
Eval set 20 separately written new phrasings; knowledge seen, phrasing unseen free generation, human graded 18/20
Probes 12 questions outside the training shape (4 misleading premise / 4 compositional / 4 OOD) free generation, behavior observed probes A/B/C

Data ledger, checkable from the config:

264 = 192 positive Q&A + 72 negatives (24 categories × 3 questions) = 237 train + 27 val ← ceil(264 × 0.1) = 27 237 ÷ (batch 2 × accum 4) = 29.6 → round up = 30 steps/epoch 6 epochs = 180 steps = 8 min 27 sec 30 epochs = 900 steps = 41 min 22 sec 

Throughput was 2.82 and 2.76 s/step — they agree, so no throttling, no CPU fallback.

Upfront: the 20 eval questions cover knowledge that's entirely in the training set (only 33 policies exist). 18/20 measures "new phrasings of known knowledge," not "new knowledge."

The task is closed by design. In a closed task, "memorized" and "learned" are largely the same thing. Section 5 cashes that in.

2. How the data gets cleaned: three gates, all code

Nothing scraped. A fictional Employee Handbook of 33 policies, expanded by script with "one policy × 4~8 phrasings (5.8 on average)" into 192 positives, plus 72 negatives.

{"instruction": "入职两年,年假几天?", "input": "", "output": "根据《员工手册》「年假》(第6条),年假标准为……"} 

("Two years in, how many days of annual leave?" → "Per the Employee Handbook 「Annual Leave」 (Article 6), the standard is...")

Gate 1: dedup

Same question twice = double weight. Cheapest defect there is.

seen = set() for r in rows: assert r["instruction"] not in seen, f"duplicate question in training set: {r['instruction']}" seen.add(r["instruction"]) 

Gate 2: leak prevention — but exact matching can't stop real leaks

Version one:

for q, _ in EVAL: assert q not in seen, f"eval question appears in training set: {q}" 

Copy-paste only. My training set was, by construction, "5~6 phrasings of the same policy" —

"入职两年年假几天" ("2 years in, how many days of annual leave")
"工作满两年有几天年假" ("worked two full years, how many days of annual leave")

Both pass exact match; semantically one question. Two layers:

import re norm = lambda s: re.sub(r'[\s,。?、,.?]', '', s).lower() # Layer 1: exact match after normalization seen_norm = {norm(r["instruction"]) for r in rows} for q, _ in EVAL: assert norm(q) not in seen_norm, f"duplicate after normalization: {q}" # Layer 2: character 3-gram Jaccard > 0.7 — print only, don't assert; a human reviews the flagged pairs # (about ten lines; the full script ships with the three gates in the pinned comment) 

Make sure the exam was never taught; only then does the score mean anything. Ceiling: phrasings isolate, knowledge doesn't — hence "closed task."

Gate 3: negative samples — and a real crash

What the handbook doesn't cover (stock options, shuttle buses, dormitories...) must be taught as "the handbook doesn't say." With only 8 negative categories, I got this:

Q: 能申请公租房吗? ("Can I apply for public housing?")

A: 根据《员工手册》「租借」(第32条),公司可依法对部分直属部门的临时性或季节性办公场所进行租借,单次租金不超过当月营业额的 15%。

(Per the Employee Handbook 「Leasing」 (Article 32), the company may lease temporary or seasonal office space for some direct-report departments, a single lease not exceeding 15% of that month's revenue.)

Article number, title, amount, approval policy — all present, all invented. Article 32 is actually remote work. (Reproduction rerun; the original run gave 「Public Housing」(公租房) (Article 24), "500 yuan/quarter." Different invention, same phenomenon, every time. Full output in output/repro_v3_probe.txt.)

Fix: enumerate every benefit the policies don't include — housing subsidy, telecom subsidy, holiday gifts, supplemental medical, heat allowance, referral bonuses... Negatives went 8 → 24 categories (3 questions each = 72 rows); only then did public housing get refused.

Remember what kind of fix that is: enumeration, not mechanism. Section 7 explains why it's doomed.

3. One formatting change, worth 5 questions

Buried at the end of data cleaning originally; pulled out as the most transferable idea here.

v1:

根据《员工手册》第6条「年假」,…… Per the Employee Handbook Article 6 「Annual Leave」, ... 

Content right, article numbers mismatched everywhere. Changed to:

根据《员工手册》「年假」(第6条),…… Per the Employee Handbook 「Annual Leave」 (Article 6), ... 

11/20 → 16/20. (Single run, no seed repeats — but 5 questions dwarfs the 19 vs 18 later.)

Why: the first token an autoregressive model commits to has no semantic conditioning. Article number first = emit a digit before deciding which policy — a guess. Title first = "fill in a number given known semantics." An order of magnitude easier.

Not handbook-specific:

  • JSON output: reason, then label — never reversed
  • Structured extraction: category, then id
  • Why CoT works: same mechanism — conclusion after reasoning

Data cleaning isn't only deleting dirty rows. Field generation order in the answer is itself data design.

4. How to tell "learned" from "memorized"

4.1 A crude but effective diagnostic: feed the training prompts back in

After v1 (137 samples), 1 of 20 new phrasings hit. So I fed it its own training prompts:

Q: 年假有几天? ("How many days of annual leave?")
A: 根据《员工手册》第12条,年假标准为:入职满1年不满5年5天…… — the correct citation is Article 6

Q: 有餐补吗? ("Is there a meal allowance?")
A: 根据《员工手册》第12条,公司为每位员工提供标准餐补 300元/月,须在工资表中列支…… — the handbook says 25 yuan per workday

(Reproduction rerun; the original run's wrong number was "Article 1," the rerun gave "Article 12" — the number drifts with training randomness, "right content, wrong number, invented amount" doesn't. Full output in output/repro_v1_probe.txt; tables below are from the original run.)

Format perfect, fragments memorized, number wrong by inertia, amount leaking from the base prior: "memorized the shell." It learned what an answer looks like, not "question → clause." A training prompt fed back in exposes it at once. Note the shape — format right, facts wrong — it becomes a metrics problem next.

4.2 Three classes of out-of-distribution probes

18/20 is the ticket in. The real criteria: three probe classes outside the training shape, on the normal (6 epoch) and overfit (30 epoch) versions.

Probe A: false premise

"年假最多可以有 20 天,对吧?" ("Annual leave can be up to 20 days, right?")

Both push back, citing Article 6. But memorized well enough, recitation masquerades as understanding: "annual leave" triggers the paragraph, which happens to contradict the premise. Passing proves the trigger mapping, not comprehension.

Probe B: compositional reasoning

"我周五加班到晚上 11 点,打车费能报销吗?" ("Overtime Friday until 11 p.m. — can I expense the taxi?")

Both cite Article 15 precisely (reimbursable after 22:00), then stop and recite, never "yes" or "no." 23 > 22; the answer is in its mouth.

"Beyond SFT" is the handy verdict — too heavy, when a field order alone was worth 5 questions (section 3). More likely: none of my 192 positives had a "conclusion first, citation second" format. I taught recitation.

Control — data format only, same hyperparameters:

{"instruction": "我周五加班到23点,打车费能报吗?", "output": "可以报销。依据《员工手册》「加班交通」(第15条),22:00后下班可报销打车费;23:00晚于22:00,符合条件。"} 

("Friday overtime until 23:00, taxi reimbursable?" → "Yes. Per the Employee Handbook 「Overtime Transport」 (Article 15), leaving after 22:00 qualifies; 23:00 is later than 22:00, condition met.")

Result: 20 "conclusion first + citation + one comparison" samples added (284 total, 6 epochs) — probe B still 0/4, A dropped 4/4 → 3/4 (12 frozen probes: normal A 4/4, B 0/4, C 1/4, total 5/12 → conclusion version A 3/4, B 0/4, C 1/4, total 4/12). Old and new, character-identical:

根据《员工手册》「夜间加班交通」(第15条),加班至22:00后的,可报销当日加班打车费用,单次上限100元,须保留行程单和发票。

(Per the Employee Handbook 「Night Overtime Transport」 (Article 15), working past 22:00 qualifies for that day's taxi, up to 100 yuan per trip; trip record and receipt required.)

Cite, then stop. Two open explanations: sample share too small (20/284 ≈ 7%; the dominant format wins by majority) or 0.6B's compositional ceiling (citation it memorizes; "cite, then one more step" it doesn't).

I didn't solve this one. "Change a field order, gain 5 questions" holds; "change a format, get a conclusion" didn't. Why they differ — no certain answer.

Probe C: OOD (open-ended, English, meta)

"公司年会什么时候开?" "用两句话总结这份手册" "手册和劳动法冲突了以谁为准?"
("When is the annual party?" "Summarize the handbook in two sentences." "Handbook vs. labor law — which wins?")

3 of 4 gave it away — both versions invented clauses (section 5). Unexpected: in English, "How many days of annual leave do we get?" — both correct. The most-memorized item survives a language switch.

4.3 The checklist (copy it)

  1. Leak assertions first, with normalization + near-duplicate detection, not exact match alone
  2. Training prompts back in: right content, wrong citation = memorized shell
  3. High in-distribution score = ticket in only, especially on closed-knowledge tasks
  4. Run all three probe classes: misleading → trigger; compositional → can it use the knowledge; OOD → will it admit defeat
  5. Failure type beats count: A = not enough data; B = check data format first, don't rush to "capability ceiling" (stuck here); C = hallucination loose

5. What overfitting looks like: I broke it on purpose

5.1 Setup

Same data, same hyperparameters (r=32, batch 2×4, lr 1e-4, cosine); one change — 6 → 30 epochs, separate output dir:

num_train_epochs: 30.0 # control group: 6.0 output_dir: E:/work/test4/output/company-policy-lora-overfit 

30 epochs = 900 steps = 41 min 22 sec, 80MB adapter (r=32, 20.19M trainable parameters, fp32 — same as part 1).

5.2 The curves: the textbook didn't show up

epoch train loss (step-level) eval loss
2.7 0.33 ↓ 0.429
8 0.085 ↓ 0.031
12 ~0.04 ↓ 0.0267 (enters the plateau)
20 ~0.001 ↓ 0.0275
30 0.00016 0.0265

Eval loss never turned up. 0.429 → 0.0267 at epoch 12, then 18 epochs sideways in 0.0265~0.0275, under 3% swing. I had the U-curve ready. It didn't come.

Why: cosine LR hit 0 (nothing left to perturb), LoRA capacity is limited, the task is a closed space 33 policies wide.

5.3 The "160× gap" is the wrong metric

Tempting: "overfitting's true face is the 160× train/eval gap (0.00016 vs 0.0265)." Two problems, both retracted.

1: CE is logarithmic; a ratio of two CEs is physically meaningless. Change units or tokenizer and "160×" changes. Rhetoric, not invariant.

2 (worse): in probabilities, the conclusion flips.

train: e^-0.00016 ≈ 99.98% eval: e^-0.0265 ≈ 97.38% perplexity 1.027 

97.4% average confidence on validation — not an "exam"; recitation too.

So: both reciting, proficiency 2.6 percentage points apart.

(Strictly: exp(−mean CE) is a geometric mean over tokens — individual tokens can sit at 60%. And 0.00016 is step-level; batch 2×4 covers 8 samples, not the training-set mean.)

5.4 So why is eval loss so low? Split the loss in two

Section 4 already answered: v1 had "format right, numbers all wrong" with low loss, because format eats most of token-level CE:

根据《员工手册》「 」 (第 条),…… Per the Employee Handbook 「 」 (Article ), ... └────────── these tokens are highly predictable, CE ≈ 0 ──────────┘ ↑ ↑ only these few tokens actually carry facts 

Hypothesis: format tokens — the vast majority — cost near zero; fact tokens are few and expensive; averaged, all calm. Then I ran the split and got slapped.

Not the ratio of the two losses — eval loss split by token role:

# forward pass each validation row, use offset_mapping to locate token indices in the "fact span" FACT_PATTERNS = [r"第\d+条", r"\d+元", r"\d+天", r"\d{1,2}:\d{2}", r"\d+个工作日"] fact_mask = build_mask(text, FACT_PATTERNS) # article numbers / amounts / durations / thresholds loss_fact = ce[fact_mask].mean() loss_format = ce[~fact_mask].mean() print(f"format={loss_format:.5f} fact={loss_fact:.5f} " f"fact_ppl={loss_fact.exp():.3f}") 

Measured (27 validation rows, 1303 assistant tokens, 185 "fact tokens"):

loss_format loss_fact fact perplexity
Normal, 6 epochs 0.0345 (n=1118) 0.0122 (n=185) 1.012
Overfit, 30 epochs 0.0250 (n=1118) 0.00023 (n=185) 1.0002

The opposite of what I expected: fact tokens carry lower loss; overfit fact perplexity 1.0002 — every digit and amount memorized cold.

"Format dilutes, facts carry the loss" is dead. The honest conclusion hurts more: the facts themselves were memorized. 33 policies' numbers recur across 264 samples; "facts" are one more high-frequency pattern. Validation varies only the phrasing — the fragments, numbers included, have all been seen — so the low loss holds less "generalization" than I thought.

(The split is flawed: FACT_PATTERNS catches only digits; title tokens like 「年假」 carry the "which policy" semantics yet land in format. A real split needs three buckets — template / title / number; not done. Also the script's weighted 0.031 / 0.022 runs ~20% below the logged eval_loss 0.040 / 0.0265 — different tokenization and EOS handling; compare within-bucket relative values only.)

So "the damage is OOD" can't be argued from loss — only probes (4.2, section 6). Written as-is.

What the split does: links v1's diagnosis to the overfit experiment under one metric — and transfers: any SFT with a fixed output template has a total loss that lies to you.

5.5 Confirming "verbatim recitation" while we're here

"Memorized to the letter" had only loss behind it. Five lines:

exact = sum(greedy_generate(p) == t for p, t in train_set) / len(train_set) print(f"exact match on training prompts: {exact:.1%}") 

Overfit 237/237 = 100.0%; normal 217/237 = 91.6% (greedy vs. reference, character by character; 237 = the 9/10 training split of 264).

Inference became fact — with a sting: normal had already memorized 91.6% at 6 epochs; 30 flattened the last 8.4%. When part 1 said "it learned to answer," strictly it had been reciting since epoch 6.

5.6 In-distribution: 19/20 — but I don't think that number is significant

20 new phrasings: overfit 19/20, normal 18/20.

One question. 20 questions resolve 5 percentage points; single run, no seed controls — noise. I won't argue "overfit is better."

Worth a look: the wrong question changed. Overfit's only miss is still "is 9:40 late"; normal's other miss (over-refusing "games on the work laptop") is fixed. 192 positives vs. 72 negatives — train long enough, positives win. Duration shifts the positive/negative decision boundary, not "smarts."

And overfit's eval loss (0.0265) beats normal's (0.040). By conventional early-stopping logic it never "broke." Hold the applause — section 1: the task is closed; better memorized, higher the score. In-distribution eval can't detect overfitting; it only sells you 30 epochs over 6.

5.7 Out-of-distribution: here's the damage

Question Normal (6 epochs) Overfit (30 epochs)
When is the annual party? (公司年会什么时候开) Invents 「Annual Party」(年会) Article 23 — "within 1 month before Spring Festival, no more than 50 people"; looks real Cites 「Annual Party」(年会) Article 17 but the body is the comp-time clause — "year-end bonus paid quarterly, forfeited at quarter end"; title, number, and body all disagree
Summarize the handbook in two sentences Invents 「Newcomer Kit」(新手礼包) Article 32; roughly on topic Invents 「Basic Materials」(基础资料) Article 2; completely off-topic
Handbook vs. labor law — which wins? Invents 「Conflict Resolution」(冲突处理) Article 21; borderline relevant Dumps Article 1 working hours — "daily 9:00 to 18:00"; entirely off-topic
Annual leave asked in English ✅ ✅
Why do we have an attendance policy? (supplementary; not among the 12 frozen probes) Article 20 grab-bag (payroll + clock-in fix + absenteeism stitched together) 「Attendance」(考勤) Article 2, body is the comp-time clause — memorized fragments stitched at random

Stuck harder than any score: "Does the company issue phones?" (公司配手机吗) — normal refused with "no regulation found regarding 「Wireless Earbuds」(无线耳机)"; overfit said 「Phone Management」(手机管理).

You asked about phones; it answered wireless earbuds. Template application's fingerprint — it matches the training negative that looks most like your question, not your question.

  • Both hallucinate. 72 negatives taught it to refuse "questions that look like negatives"; annual party, summary, meta-questions don't
  • Normal hallucinates fluently, on-topic (dangerous: looks real); overfit stitches visibly (right title, wrong body). Not "more wrong" — from "trying to answer" to "matching the nearest template"

19/20 in-distribution, off-topic out. Overfitting's damage isn't on the eval set; it's outside it.

6. Stopping criteria: "stop at the minimum" is wrong

"Stop when eval loss bottoms out" — against my own table:

epoch 12 20 30
eval loss 0.0267 0.0275 0.0265 ← global minimum

By that rule, train all 30 epochs. The rule contradicts my data — and this post says in-distribution metrics can't detect overfitting, then hands you one as the rule.

Two consistent rules:

Rule 1: stop at the plateau, not the minimum

early_stopping_patience: 3 early_stopping_threshold: 0.005 # improvements smaller than this count as "no improvement" — don't chase noise 

Stop after epoch 12. The next 18 epochs ≈ 25 minutes of electricity for ±3% jitter and more mechanical OOD output.

Rule 2: OOD probes as a checkpoint-level callback

PROBES = [...] # fixed 12: 4 misleading / 4 compositional / 4 OOD, never in the training set class ProbeCallback(TrainerCallback): def on_evaluate(self, args, state, control, model=None, **kw): passed = sum(judge(greedy_generate(model, p)) for p in PROBES) # write into the same log as eval loss, for easy overlay log({"step": state.global_step, "eval_loss": kw["metrics"]["eval_loss"], "probe_pass": passed / len(PROBES)}) 

Result: 30 epochs retrained with checkpoints (42 min 53 sec — ~1.5 min more than without, disk writes), 12 frozen probes × 30 checkpoints — no decoupling.

epoch 1 2 3 4 5 6 7 8 9 10~30
probe_pass 2 1 1 3 4 4 3 6 5 constant 5
  • First 8 epochs: 1~2 → 6 — real learning; probes see improvement
  • After epoch 8: pinned at 5/12 for 22 epochs; eval loss flat from epoch 12 — both flat, neither down
  • As-is: no decoupling on this task. Behavior couldn't separate "overfitting" from "convergence" either

I'd hoped for overfitting's true face — eval loss flat, probe rate turning down. Didn't happen. Two limits of Rule 2 surfaced instead, worth more than a forced line:

  1. 12 pass/fail probes are too coarse — the 5.7 texture gap between "looks real" and "visibly stitched" is invisible to the judge; both score 1/4
  2. On a closed-knowledge task, the probes' correct answers are the training content — better memorized, higher pass rate; the probes sit on an extension of the training distribution. Catching decoupling needs probes far outside it

Rule 2 suits open tasks where behavior degrades; on a closed task it confirms "learned something," never "learned something wrong." Keeping the negative result.

Overfitting's real cost was never a dumber model — it's your time and electricity buying nothing. And "nothing" is what neither of this post's metrics — eval loss, probe pass rate — could tell you in advance. Only the 5.7 table could.

7. So what now: hallucination isn't a training problem, it's an engineering problem

Diagnosed all the way down; time for a prescription.

Enumeration must fail: I was teaching the complement of an open set, and the open set is infinite. 24 → 240 categories, and annual party, summary, meta-questions are still outside. Public housing got fixed because I happened to list it.

Three ways out, by cost-effectiveness:

  1. Refusal as mechanism, not list. Handbook in the prompt at training time; teach "answer only from the given text; absent means say so." Refusal goes from "which category is this question" (undecidable) to "is retrieval empty" (decidable).
  2. Negatives covering shapes, not topics. A few refusal samples each for open-ended, summary, meta, multi-hop — "this kind of question can't be answered by one policy," not "refuse 'stock options'."
  3. Hard-validate output; leave hallucination no exit. Force the cited clause out first; verify in code it exists in the handbook:
m = re.search(r"「(.+?)」(第(\d+)条)", answer) if m: title, idx = m.group(1), int(m.group(2)) if idx not in HANDBOOK or HANDBOOK[idx]["title"] != title: return "手册中未找到相关规定。" # intercept here; never reaches the user ("No relevant regulation found in the handbook.") 

No. 3 matters most: 0.6B's hallucination can't be cured by memorization-style SFT, only caught by engineering (No. 1 is training too, but "answer from given text," not "memorize the handbook"). Every "title, number, and body disagree" row is caught by this regex.

Training makes it presentable; engineering keeps it out of trouble. Don't expect one to do the other's job.

8. One pipeline

three gates (dedup / normalized + near-duplicate leak prevention / shape-based negatives) → answer field-order design (semantic anchor first, anchored fields after) → iterate in-distribution until stable (18/20 is enough; don't grind) → three probe classes (misleading / compositional / OOD) → split loss: format vs fact → plateau stopping + probe callback → hard output validation → ship 

One line: cleaning makes the score trustworthy; "learned" is judged outside the training distribution; total loss lies. Expanded: 4.3.

Closing

Part 1 said "between running and learning there's a whole weekend of data cleaning." This post adds the second half — and after the experiment, it needs revising:

Between acceptance and truth there's a correctly chosen metric.

Eval loss said "fine" throughout — 0.0265, perplexity 1.027, prettier than normal. The probes' answers said "broken" — not the pass rate, the texture (5.7).

Metrics don't lie. They answer a different question than you asked.

(Still owe the "20 images, recognize your cat" post — needs Qwen2.5-VL; text-only models can't see. I owe you.)

This is part 2 of "Fine-Tuning on an 800-Yuan GPU". The three gates' assertion code, the 30-epoch control YAML, the 12 probes, and the loss-split script live in the 8gb-lora-lab/ directory of the series' GitHub repository.