The cleaning checklist
- Deduplication — exact and near-duplicates. Near-dupe detection (MinHash, cosine on embeddings) catches what string-equality misses.
- Format consistency — every example follows the same schema. Mix two formats and your model learns both badly.
- Length filtering — drop too-short (trivial) and too-long (noisy or overflowing) examples.
- Quality filtering — remove grammatical errors, hallucinated content, broken JSON, unmatched code fences.
- Tokenization check — count tokens with the actual tokenizer, not character heuristics. Verify everything fits in the training context window.
The three-way split
| Split | Share | Purpose |
|---|---|---|
| Train | ~80% | What the model actually learns from. |
| Validation | ~10% | Monitored during training. Detects overfitting; informs early stopping. |
| Test | ~10% | Held out completely until after training. Final unbiased number. |
Why validation is the canary
If validation loss starts rising while training loss keeps falling, the model is memorizing rows instead of learning behavior. That divergence is the overfitting signal — the moment to stop training, not when "the loss looks low."