dataset-curation
它能做什么
这个工具用于整理和准备原始数据,以便训练 AI 模型。它能确保数据格式正确、组织有序,并通过验证,为成功训练做好准备。
适用场景
- ✓当你手上有原始数据,需要把它转换成 AI 可以学习的格式时。
- ✓当你把 AI 生成的数据与真实数据混合,以提升训练效果时。
- ✓在开始训练 AI 模型之前,确保数据已经准备就绪时。
技能链接
https://github.com/wshobson/agents/blob/main/plugins/llm-finetuning/skills/dataset-curation/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请用“messages”格式,把我的对话数据整理好,用于训练聊天模型。”
每周 5 个新技能,1 分钟读完。
工作原理
这个工具会根据你选择的训练方法(如对话或提示词/回答配对)来格式化数据。它还会组织数据,让 AI 只学习其中重要的回答,避免处理无用的内容而浪费资源。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Dataset Curation
This skill assumes finetuning-method-selection
already routed here — the next step is preparing
data, not choosing a method. What follows: format
selection by target method, the template/packing
mechanics behind the most common silent training
failures, rules for mixing in synthetic data
without collapse, and the dataset card that closes
out Phase 2 before a run starts.
Input: raw examples (demonstrations, preference
judgments, or task prompts) plus a routing decision
from finetuning-method-selection.
Output format: a formatted, packed, validated
JSONL dataset plus a completed dataset card — the
Phase 2 artifact /finetune checks before launching
training.
Format Selection
| Method | Shape | Rows |
|---|---|---|
| SFT, single-turn | Instruct (instruction/response or prompt/completion) |
~1,000+ floor |
| SFT, multi-turn | Conversation / ChatML messages list |
~1,000+ floor |
| DPO / ORPO | Preference pair (prompt, chosen, rejected) |
Method-dependent, see preference-optimization |
| KTO | Unpaired (prompt, completion, label) |
Method-dependent, see preference-optimization |
| GRPO / RLVR | Prompt-only (prompt + verifier metadata) |
Method-dependent, see grpo-rlvr-training |
~1,000+ rows is the recommended floor for SFT, not a target. Below it, a handful of low-quality or duplicate examples can dominate the gradient; above it, quality over quantity — a smaller verified, deduplicated set beats a larger noisy one.
The ChatML shape, for orientation; the other four formats plus a ShareGPT conversion note live in
references/formats-and-templates.md:{"messages": [ {"role": "user", "content": "..."}, {"role": "assistant", "content": "..."} ]}
Chat Templates and Loss Masking
Apply the target model's chat template before any concatenation or packing, never after — packing raw text and templating the packed blob afterward corrupts turn boundaries, landing role markers in the wrong place relative to each example.
Train on assistant responses only. Mask the loss (
-100in the labels tensor) over system/user turns and the template's own role markers — only assistant-turn content tokens contribute to loss.Template/tokenizer mismatches are a top silent failure mode. A model trained against one chat template but served or evaluated with a different one degrades without erroring. Verify the same template string used in training is applied at inference and eval time.
Keep the dataset in
messagesshape and let the trainer template and mask it (assistant_only_loss=Truein current TRL) — pre-rendering to a flat text field destroys the turn boundaries masking needs. Full code sketch:references/formats-and-templates.md. Sanity-check before training — decode only unmasked positions; expect only assistant text:keep = batch["labels"][0] != -100 print(tokenizer.decode(batch["input_ids"][0][keep]))
Packing
Without packing, 40–70% of compute is spent on padding — variable-length examples batched at a fixed sequence length waste the gap between each example's length and the batch's max. Packing concatenates multiple examples into one sequence up to the max length, cutting most of that waste.
Packing changes batch semantics. A packed sequence can contain several original examples, so "steps per epoch" and any LR schedule keyed to example count shift once packing is on — recompute schedule milestones against packed-sequence count.
MANDATORY: decode and manually inspect 5–10 packed sequences before scaling to a full run. Confirm example boundaries land where expected, template markers are intact per sub-example, and the loss mask is still assistant-only within each packed sequence. Not optional — packing bugs are silent (the loss curve looks normal) and only surface in eval quality, hours later:
for seq in packed_dataset.select(range(10)): print(tokenizer.decode(seq["input_ids"]))
Synthetic Data Rules
- Keep ≥25% real data as a collapse guard. Training on a growing share of model-generated data without a real-data floor drives measurable quality collapse over successive generations — 25% real is the minimum that holds the line. General-domain replay rows count toward this floor — "real" means "not generated for this task from this
…
常见问题
什么是“打包”(packing)?
这是一种把多个训练样本合并成一个序列的技术,能更高效地利用算力,减少空白部分造成的浪费。
既然用了 AI 生成的数据,为什么还要保留真实数据?
保留至少 25% 的真实数据,可以防止 AI 模型的质量随时间下降,确保它始终从可靠的来源中学习。
什么是“数据集说明卡”(dataset card)?
这是一份文档,详细记录用于训练 AI 的数据来源、数量和特征,确保透明度和可追溯性。
详情
作者的原始描述
Prepare, format, and validate datasets for supervised fine-tuning and preference training. Use when converting raw data into training format, applying chat templates, configuring sequence packing, generating synthetic training data, or writing a dataset card before a run.
repo: wshobson/agents
热度
- GitHub 星标
- 41k
- 排名
- #6729
- 许可证
- MIT
- 更新时间
- 2026/10/15
评论
- …