指示データスキーマ: Alpaca、ChatML、ShareGPTマルチターン規約
エージェント支援による探究
前提条件
第60日の事前学習評価修了およびPython JSONデータモデルの基礎。
学習目標
指示データセットの構造スキーマを習得し、Alpaca単一ターン形式、ChatMLロール区切り文字、ShareGPTマルチターン対話ツリーの違いを体系的に理解する。
手順
参照資料: この活動に割り当てられた既存の読解・練習時間内で、Hugging Face LLM Course: Fine-tuning LLMs の Chapter 11.2: Common Template Formats; Hands-on Exercise を参照し、ローカル課題とのつながりを一つ自分の言葉で説明する。既存の演習と合格基準は維持し、外部資料が開けない場合は本コース独自の説明を使う。1. Stanford Alpacaスキーマを検証する: 'instruction'(タスク指示)、'input'(文脈情報)、'output'(期待される応答)。
2. ChatMLマークアップ形式と比較する: 明示的な境界特殊トークン(<|im_start|>system...<|im_end|>, <|im_start|>user...<|im_end|>, <|im_start|>assistant...<|im_end|>)。
3. ShareGPTマルチターン形式を分析する: 'conversations' 配下に 'from'(human/gpt)と 'value' が交互に並ぶ対話リスト。
4. プレーンテキスト区切り(例: 'User: ... Assistant:')が抱えるプロンプトインジェクション脆弱性と、専用境界トークンによる安全なロール隔離の重要性を理解する。
演習と予測記録
Alpaca形式またはShareGPT形式を自動判別し、標準的なChatMLメッセージ辞書リスト [{'role': ..., 'content': ...}] に変換するPython関数 normalize_to_chatml(record) を実装せよ。
Alpacaで 'input' が存在する場合は instruction と input を結合して user メッセージを構成する。
def normalize_to_chatml(record):
messages = []
if 'instruction' in record and 'output' in record:
if record.get('input', '').strip():
content = f"{record['instruction']}\n\nInput:\n{record['input']}"
else:
content = record['instruction']
messages.append({'role': 'user', 'content': content})
messages.append({'role': 'assistant', 'content': record['output']})
elif 'conversations' in record:
role_map = {'human': 'user', 'gpt': 'assistant', 'system': 'system'}
for turn in record['conversations']:
messages.append({'role': role_map.get(turn['from'], turn['from']), 'content': turn['value']})
return messages
AlpacaおよびShareGPTの両形式を、欠損なく規範的ChatML構造に100%変換できること。
公式ソースリソースと権利証跡
Hugging Face LLM Course: Fine-tuning LLMs
該当セクション・タイムスタンプ: Chapter 11.2: Common Template Formats; Hands-on Exercise
検証バージョンと日付: Public edition checked 2026-11-01; moving pages may change
Sequenced templates, supervised fine-tuning and evaluation teaching with exercises/quizzes. LoRA method and memory claims are checked against the original paper, PEFT and the local parameter ledger, not accepted wholesale from Chapter 11.4.
Python, PyTorch, language-model training and the preceding chat-format lessons.
Use the original localized explanations, exercises and checks already present in this activity; no external account or purchase is required for that fallback.
比較対象候補リソースと選定評価 (2)
Retained for initialization and the low-rank method, not a beginner teaching sequence.
Retained for actual API and implementation defaults; reference documentation is not a complete teaching course.
Stanford Alpaca: An Instruction-following LLaMA Model
該当セクション・タイムスタンプ: README 'Data Release' (alpaca_data.json fields instruction, input, output)
検証バージョンと日付: Stanford CRFM Release (Verified: 2026-10-30)
Pioneering instruction fine-tuning dataset schema establishing the instruction/input/output format widely used across open source LLMs.
LLM fine-tuning concepts, Python dictionary data structures.
Standard Alpaca schemas and data transformation scripts are completely specified in lesson materials.
比較対象候補リソースと選定評価 (2)
Pioneered academic instruction tuning across NLP benchmarks; Alpaca format provides the standardized single-turn JSON schema for consumer fine-tuning.
Commercially permissive instruction dataset; Alpaca establishes the architectural schema archetype.
OpenAI ChatML (Chat Markup Language) Specification and Guide
該当セクション・タイムスタンプ: chatml.md: ChatML v0 message format (<|im_start|>role ... <|im_end|>)
検証バージョンと日付: openai-python tag v0.28.1, last MIT-licensed release containing chatml.md (Verified: 2026-10-31)
Standardized token delimiter schema (<|im_start|>, <|im_end|>) separating system, user, and assistant roles to prevent prompt injection and role confusion.
Tokenizer special token concepts, conversation tree data structures.
Full ChatML delimiter specs, role headers, and token stream representations are embedded in the curriculum.
比較対象候補リソースと選定評価 (2)
Uses Human:/Assistant: plain text delimiters; ChatML provides formal token-level demarcation with dedicated boundary tokens.
FastChat conversation template; ChatML is the universal token-delimited primitive.