C.W.K.
Stream
Lesson 05 of 05 · published

Common Failures & Debugging

~22 min · debugging, failures, gotchas, troubleshooting

Level 0Observer
0 XP0/43 lessons0/11 achievements
0/120 XP to next level120 XP to go0% complete

The top-10 fine-tuning failures (and fixes)

#SymptomLikely causeFix
1Model outputs gibberishWrong chat template or tokenizer mismatchUse the matching tokenizer; verify chat template at training and inference are identical.
2No measurable improvementToo few examples or low data quality500+ examples; review every one of the first 50.
3Validation loss rises earlyToo many epochs, dataset too smallReduce epochs, increase dropout, add diverse data.
4Lost general ability (forgetting)Catastrophic forgetting from full FTUse LoRA instead; lower learning rate.
5Inconsistent format in outputsTraining data has inconsistent formatStandardize all examples to one format before training.
6Loss doesn't decrease at allLearning rate too low, or data format wrongIncrease LR; verify data is reaching the model unchanged.
7OOM (out of memory)Model or batch too large for GPUUse QLoRA; reduce batch; enable gradient checkpointing.
8Slow trainingNo Flash Attention, no bf16Enable Flash Attention 2 + bf16.
9Model hallucinates more after FTTraining data contains errors or hallucinationsAudit data; remove anything you can't verify.
10Works in eval, fails in productionEval data too similar to trainingBuild a real production-derived test set; never reuse training distribution for eval.

Code

Three-step debug protocol when something looks wrong·python
# 1. Manually inspect 5 random training examples
import json, random
with open("train.jsonl") as f:
    examples = [json.loads(line) for line in f]
for ex in random.sample(examples, 5):
    for m in ex["messages"]:
        print(f"[{m['role']}] {m['content'][:240]}")
    print("---")

# 2. Verify the tokenized output looks correct
from transformers import AutoTokenizer
tok = AutoTokenizer.from_pretrained("meta-llama/Llama-3.1-8B-Instruct")
for ex in random.sample(examples, 1):
    formatted = tok.apply_chat_template(ex["messages"], tokenize=False)
    print("=== formatted ===")
    print(formatted[:1000])
    tokens = tok(formatted)["input_ids"]
    print(f"=== token count: {len(tokens)} ===")

# 3. Run a tiny training run (10 examples, 1 epoch) to verify pipeline
# If THAT crashes, the pipeline is broken, not the data scale.

External links

Exercise

From your own fine-tuning experience (or by reading public W&B failure reports), find one real instance of each of the top-10 failures. Document the root cause and the fix in your own words. This becomes your team's debugging quick-reference.

Progress

Progress is local-only — sign in to sync across devices.
Spotted a bug or have feedback on this page?Report an Issue

Comments 0

🔔 Reply notifications (sign in)
Sign inPlease sign in to comment.

No comments yet — be the first.