Every fine-tune is a data project wearing a GPU costume. The 2026 guidance is consistent: roughly a thousand hand-curated instruction pairs routinely beat a hundred thousand scraped ones, because the model imitates your dataset's median quality, not its best examples.
Tier: Advanced · Workflow area: Fine-tuning & Model Adaptation
This playbook takes you from raw logs and domain docs to a deduplicated, decontaminated, chat-formatted SFT dataset ready for TRL — with an audit trail for every filtering decision.
Skip this playbook if you cannot describe what a "gold" output looks like in one paragraph — write that spec first; curation without a quality bar is just data laundering.
datasets, pandas, and a strong API model for assisted drafting (budget ≤ $3).Write the data card first (20 minutes). One page: task definition, gold-output spec, sources used, licensing/PII status of each source, target size (start at 800–1,200 pairs), and the split policy. Every later step logs its counts into this card.
Mine candidates from real usage. Pull successful interactions from logs (high user rating, accepted answer, no follow-up correction) and expert-authored documents. Convert each to an (instruction, input, output) triple. Aim for 3–5x your target count as raw candidates.
LLM-assisted drafting with mandatory human review. For gaps in coverage, have a frontier model draft pairs from domain docs — then a human reviews every synthetic pair against the spec, editing or rejecting. Track the reject rate; if it is under 20%, your reviewer is rubber-stamping, not reviewing.
Deduplicate. Exact dedup on normalized text, then near-dedup: embed instructions with a sentence-transformer, drop pairs with cosine similarity > 0.92 to a kept pair. Log how many you removed — heavy duplication is why 100k-scale scraped sets underperform.
Decontaminate against your eval set. Embed both training instructions and eval-set inputs; flag any training pair with similarity > 0.85 to any eval case and remove it. Also run substring checks on distinctive entities. Record the removed count in the data card — this number is what makes your later eval claims believable (pb-33).
Balance and stress the distribution. Bucket pairs by sub-task and difficulty; cap any bucket at ~25% of the set. Deliberately include 10–15% "hard negatives": ambiguous inputs where the gold output says what is unknowable or refuses gracefully — without these, the tuned model never learns to hedge.
Format for TRL chat templates. Emit JSONL in messages format — {"messages": [{"role": "system", ...}, {"role": "user", ...}, {"role": "assistant", ...}]} — and let TRL's apply_chat_template handle model-specific tokens. Never hand-write <|im_start|>-style markers; template mismatch is the most common silent fine-tune killer.
Final quality gate. Sample 50 random pairs; score each pass/fail against the spec. Ship only if ≥ 90% pass. Version the dataset (git-LFS, DVC, or HF datasets with a revision tag) alongside the data card.
The dataset card with counts at every stage — mined, drafted, rejected, deduped, decontaminated — is the difference between a fine-tune you can defend and one you can only hope about.
datasets + pandas: the default; dataset.map for formatting, dataset.train_test_split(seed=42) for splits.For client data or PII-bearing logs:
CUSTOMER_NAME, ACCOUNT_ID).A fine-tuned model can memorize and regurgitate rare strings from training data — treat un-anonymized pairs as a data leak into every future deployment of that adapter.