AI Hints
Home›Fine-Tuning LLMs Tutorial›Data: Cleaning, Splits and Size
Fine-Tuning LLMs · Lesson 73 of 120

Cleaning and Dedup

Tidy data, no repeats.

⏱ 2 min read▶ Video at 1:52:21🎓 Free
Watch this lesson in the Fine-Tuning LLMs courseWatch on YouTube ↗Full Fine-Tuning LLMs course

Real data is messy. Extra spaces, odd symbols, empty answers, and the same example repeated many times. Cleaning fixes these problems before they reach the model.

  • Real data is messy
  • Spaces, symbols, repeats
  • Clean before training

A cleaning checklist

Here's a simple checklist. Remove empty, or broken, examples. Fix encoding problems, like strange symbols. Remove private information, like emails, and phone numbers. Remove duplicates. And check that every answer follows your format, for example, valid JSON.

StepWhy
Drop empty / broken rowsthey teach nothing
Fix encodingno strange symbols
Remove private datasafety and the law
Remove duplicatesno over-weighted examples
Validate answerse.g. all valid JSON

Why duplicates hurt

Why do duplicates matter? If one example appears twenty times, the model sees it twenty times more than others. It may memorise it, and copy it everywhere. Near duplicates count too. The same message, with different capitals, or punctuation. So compare messages after a simple clean up, like lower case, and no punctuation.

keyvalue
Exact duplicatesover-weighted
Near duplicatessame text, small changes
Compareafter normalising
Normaliselower case, no punctuation

Summary

Let's recap. Clean data before training. Drop broken rows, remove private data, and validate the format. And remove duplicates, including near duplicates. Next, how duplicates can sneak into your test set.

Key takeaways
  • Cleaning checklist
  • Remove private data
  • Dedup after normalising
Next up: Splits and Leakage — keep the test set honest