本文へスキップ
Skillpedia
機械学習41k · #6729

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に貼り付けるだけ。AIがスキルを読んで指示に従います。

貼り付け用メッセージ

このスキルを使って手伝ってください:https://github.com/wshobson/agents/blob/main/plugins/llm-finetuning/skills/dataset-curation/SKILL.md このリンクのSKILL.mdファイルを読んで、私の作業でその指示に従ってください。
こういうスキルを、AIが自分で見つけてくれたら?無料のSkillpedia MCPをインストール。1行で、作業の前に15,000+のスキルから探してくれます。1分でインストール →

AIへの頼み方の例

“チャットモデルの学習用に、会話データをmessage形式で整形してください。”

毎週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 (-100 in 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 messages shape and let the trainer template and mask it (assistant_only_loss=True in 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)」とは何ですか?

複数の学習例を1つの長いシーケンスにまとめる技術です。空いた部分による無駄を減らし、処理能力を効率よく使えるようにします。

AI生成データを使う場合でも、実データを残す必要があるのはなぜですか?

少なくとも25%の実データを残すことで、AIモデルの品質が時間とともに低下するのを防ぎ、信頼できる情報源から学び続けられるようにするためです。

「データセットカード」とは何ですか?

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

このスキルは役に立ちますか?

0

ログイン して投票しましょう。

コメント

  • …

このリポジトリの他のスキル

似ているスキル