LocalLLM Forum — Run it locally. Own your models.

Cleaning 2M rows of instruction data without losing quality

Y posted by YvetteNovak #datasets#fine-tuning 3 posts 312 views
Y

I inherited a 2.1M-row instruction dataset scraped from half the public sources, and the temptation is to nuke anything that looks weird. After two weeks of pipeline work I kept 1.3M rows and — importantly — the model trained on the cleaned set beats the one trained on aggressive filtering. Here is the pipeline:

  1. Exact + MinHash dedup. 2.1M → 1.62M. Jaccard threshold 0.85 over 5-gram shingles, LSH with 128 bands. This removed the mirror-site clones without touching legitimate paraphrases.
  2. Language ID. fastText, keep if target language probability > 0.9. 1.62M → 1.51M.
  3. Quality scoring with a local 3B model — rate each row 1-5 on instruction clarity and answer correctness, two passes, keep rows averaging ≥ 3. 1.51M → 1.34M.
  4. Length sanity. Drop answers < 20 tokens (usually truncation artifacts) but keep long ones. 1.34M → 1.31M.

The key lesson: score, do not threshold on heuristics. My first pass deleted every row containing code blocks or non-ASCII characters and lost 8% of the best technical data. The 3B scorer kept those and flagged the actual junk — SEO spam, answer-in-question loops, machine-translated gibberish.

Cost: the scoring pass ran overnight on the 2× P40 box. Cheaper than one bad training run.

Dataset janitor · 2× P40 · Prague
M
Y YvetteNovak replied
…score, do not threshold on heuristics…

How did you calibrate the ≥ 3 cutoff on the scorer? I ask because I did something similar with a 4B judge and the score distribution was not bimodal — it was one lump centred on 3.4, so "keep ≥ 3" kept 91% and told me nothing. What actually worked was relative filtering: score everything, then keep the top 70% by score within each source dataset, since each source had its own quality baseline.

Also worth auditing: sample 100 rows from just-below-threshold and just-above, and read them. My below-threshold bucket contained a third of the rows I actually wanted, all penalised for formatting rather than substance.

RTX 3090 · Unsloth devotee · São Paulo
I
M MateusKeller replied
…keep the top 70% by score within each source dataset…

Mod hat on for one item that belongs in every cleaning pipeline and almost never is: PII and licensing scrubbing before dedup, not after. Dedup first means your MinHash signatures are computed over rows you may need to delete anyway, and worse, near-duplicate clusters spread a single leaked email address across dozens of rows that all look individually innocent.

Order that has served the category well: PII scrub → license/source tagging → dedup → quality scoring. The license tagging also gives you a free lever later — being able to train a "permissively-licensed-only" variant without re-running the pipeline is worth the extra column.

"Pushing 24GB to its limits since 2023." — Ingrid Marchetti, Bergen
Want to join the discussion? Register or log in to reply. Register Log in
Reply
Ctrl+Enter to submit
post 1 of 3