Community라이팅 & 에디팅github.com

데이터셋 큐레이션

지도 미세 조정 및 선호도 학습을 위한 데이터셋을 준비, 형식화 및 검증합니다. 원시 데이터를 학습 형식으로 변환하거나, 채팅 템플릿을 적용하거나, 시퀀스 패킹을 구성하거나, 합성 학습 데이터를 생성하거나, 학습 실행 전 데이터셋 카드를 작성할 때 사용하세요.

데이터셋 큐레이션란 무엇인가요?

이 스킬은 미세 조정 방법이 선택된 후, 데이터 준비 단계를 구체적으로 안내합니다. 대상 방법(예: SFT, DPO, GRPO)에 맞는 데이터 형식을 선택하고, 채팅 템플릿 적용 및 손실 마스킹의 핵심 원칙을 설명하여 모델 학습 시 흔히 발생하는 '조용한 실패(silent failure)'를 방지합니다. 특히 템플릿과 토크나이저 불일치, 패킹(packing)으로 인한 배치 의미 변경 및 손실 마스크 손상 문제를 집중적으로 다룹니다. 또한, 합성 데이터 사용 시 모델 붕괴(collapse)를 막기 위해 최소 25%의 실제 데이터를 유지해야 하는 규칙을 제시하고, Magpie, Rejection Sampling 등 효율적인 합성 데이터 생성 방법을 소개합니다. 최종적으로 모든 데이터셋은 6가지 필수 필드(출처, 개수, 합성/실제 비율, 중복 제거 방법, 사용된 템플릿, 패킹 설정)를 포함한 데이터셋 카드와 함께 제공되어야 하며, 이 카드는 `/finetune` 단계 진입을 위한 게이트 역할을 합니다. 이 스킬은 주로 Claude Code, Cursor, Codex와 같은 AI 에이전트 개발 환경에서 사용되며, `references/formats-and-templates.md` 및 `references/synthetic-data.md` 문서를 참조하여 구체적인 코드 예제와 방법론을 확인할 수 있습니다.

지원 대상~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/wshobson/agents/tree/main/plugins/llm-finetuning/skills/dataset-curation

Installed? Explore more 라이팅 & 에디팅 skills: steipete/notion, langchain-ai/langchain, bytedance/podcast-generation · View all 6 →

즐겨 사용하는 AI에게 물어보기

이 에이전트 스킬이 미리 로드된 새 채팅을 엽니다.

문서

데이터셋 큐레이션은(는) 무엇을 하나요?

이 스킬은 finetuning-method-selection에서 이미 라우팅이 완료되었다고 가정합니다 — 다음 단계는 방법을 선택하는 것이 아니라 데이터를 준비하는 것입니다. 이 스킬에서 다루는 내용: 대상 방법에 따른 형식 선택, 가장 흔한 조용한 학습 실패 뒤에 있는 템플릿/패킹 메커니즘, 붕괴 없이 합성 데이터를 혼합하는 규칙, 그리고 학습 실행 전 Phase 2를 마무리하는 데이터셋 카드입니다.

입력: 원시 예제(데모, 선호도 판단 또는 작업 프롬프트)와 finetuning-method-selection의 라우팅 결정. 출력 형식: 형식이 지정되고, 패킹되고, 검증된 JSONL 데이터셋과 완성된 데이터셋 카드 — /finetune이 학습 시작 전에 확인하는 Phase 2 아티팩트입니다.

형식 선택

방법형태행 수
SFT, 단일 턴Instruct (instruction/response 또는 prompt/completion)~1,000개 이상 최소
SFT, 다중 턴대화 / ChatML messages 목록~1,000개 이상 최소
DPO / ORPO선호도 쌍 (prompt, chosen, rejected)방법에 따라 다름, preference-optimization 참조
KTO비쌍 (prompt, completion, label)방법에 따라 다름, preference-optimization 참조
GRPO / RLVR프롬프트 전용 (prompt + 검증기 메타데이터)방법에 따라 다름, grpo-rlvr-training 참조
  • ~1,000개 이상의 행은 SFT의 권장 최소 기준이지 목표치가 아닙니다. 그 이하에서는 소수의 저품질 또는 중복 예제가 그래디언트를 지배할 수 있습니다. 그 이상에서는 양보다 질 — 작지만 검증되고 중복 제거된 세트가 더 크고 노이즈가 많은 세트보다 낫습니다.

  • ChatML 형태는 방향 참고용입니다. 나머지 네 가지 형식과 ShareGPT 변환 참고 사항은 references/formats-and-templates.md에 있습니다:

    {"messages": [
      {"role": "user", "content": "..."},
      {"role": "assistant", "content": "..."}
    ]}
    

채팅 템플릿 및 손실 마스킹

연결(concatenation)이나 패킹 전에 대상 모델의 채팅 템플릿을 적용하세요. 절대 이후에 하지 마세요 — 원시 텍스트를 패킹하고 패킹된 블롭(blob)에 나중에 템플릿을 적용하면 턴 경계가 손상되어 역할 마커가 각 예제 기준으로 잘못된 위치에 놓입니다.

  • 어시스턴트 응답에 대해서만 학습하세요. 시스템/사용자 턴 및 템플릿 자체 역할 마커에 대해 손실을 마스킹(labels 텐서에서 -100)하세요 — 어시스턴트 턴 콘텐츠 토큰만 손실에 기여합니다.

  • 템플릿/토크나이저 불일치는 가장 흔한 조용한 실패 모드입니다. 한 채팅 템플릿으로 학습된 모델이 다른 템플릿으로 서비스되거나 평가되면 오류 없이 성능이 저하됩니다. 학습에 사용된 것과 동일한 템플릿 문자열이 추론 및 평가 시에도 적용되는지 확인하세요.

  • 데이터셋을 messages 형태로 유지하고 트레이너가 템플릿을 적용하고 마스킹하도록 두세요 (assistant_only_loss=True (현재 TRL에서)) — 평평한 텍스트 필드로 미리 렌더링하면 마스킹에 필요한 턴 경계가 사라집니다. 전체 코드 스케치는 references/formats-and-templates.md에 있습니다. 학습 전에 온전성 검사를 수행하세요 — 마스킹되지 않은 위치만 디코딩하고 어시스턴트 텍스트만 예상하세요:

    keep = batch["labels"][0] != -100
    print(tokenizer.decode(batch["input_ids"][0][keep]))
    

패킹

패킹 없이는 연산의 40~70%가 패딩에 사용됩니다. 고정된 시퀀스 길이로 배치 처리된 가변 길이 예제는 각 예제의 길이와 배치의 최대 길이 사이의 간격을 낭비합니다. 패킹은 여러 예제를 최대 길이까지 하나의 시퀀스로 연결하여 대부분의 낭비를 줄입니다.

  • 패킹은 배치 의미를 변경합니다. 패킹된 시퀀스는 여러 개의 원래 예제를 포함할 수 있으므로, "에포크당 스텝"과 예제 수에 의존하는 학습률 스케줄은 패킹이 켜지면 변경됩니다 — 패킹된 시퀀스 수를 기준으로 스케줄 마일스톤을 다시 계산하세요.

  • 필수: 전체 실행으로 확장하기 전에 5~10개의 패킹된 시퀀스를 디코딩하고 수동으로 검사하세요. 예제 경계가 예상된 위치에 있는지, 템플릿 마커가 각 하위 예제 내에서 손상되지 않았는지, 손실 마스크가 각 패킹된 시퀀스 내에서 여전히 어시스턴트 전용인지 확인하세요. 선택 사항이 아닙니다 — 패킹 버그는 조용하며(손실 곡선이 정상적으로 보임) 몇 시간 후 평가 품질에서만 표면화됩니다:

    for seq in packed_dataset.select(range(10)):
        print(tokenizer.decode(seq["input_ids"]))
    

합성 데이터 규칙

  • 붕괴 방지를 위해 실제 데이터를 25% 이상 유지하세요. 모델 생성 데이터의 비율이 증가하면서 학습하면 실제 데이터 기준선이 없으면 여러 세대에 걸쳐 측정 가능한 품질 붕괴가 발생합니다 — 25%의 실제 데이터가 기준선을 유지하는 최소 비율입니다. 일반 도메인 리플레이 행은 이 기준선에 포함됩니다 — "실제"는 "이 작업을 위해 이 학생 모델에서 생성되지 않음"을 의미하며, "인간이 작성함"을 의미하지는 않습니다. 모든 구성이 합성적인 데이터셋도 리플레이만으로 25% 이상 기준선을 충족할 수 있습니다 (references/synthetic-data.md의 리플레이-혼합 구성 레시피 참조). 어떤 행을 "실제"로 간주하는지 데이터셋 카드에 명시하고, 기준선을 구조적으로 충족 불가능하게 두지 마세요.
  • Magpie와 Rejection Sampling이 주요 방법입니다. Magpie는 모델 자체 템플릿 사전(prompt)에서 프롬프트를 추출합니다. Rejection Sampling은 프롬프트당 여러 후보를 생성하고 필터를 통과한 것만 유지합니다. 둘 다 단순한 단일 생성보다 효율적입니다.
  • 대상 지향적이고 학생 인식 생성은 정적 생성보다 1.3~2배 샘플 효율이 높습니다. 학생의 실제 실패 모드를 목표로 하면 더 적은 필터링된 예제로 품질 기준을 충족합니다.
  • 필터링 후 일반적인 수락률은 10~30%입니다. 그에 따라 볼륨을 계획하세요 — 15% 수락률로 10,000행 목표를 달성하려면 약 65,000개 이상의 원시 생성이 필요합니다.
  • 생성 방법 순위, 필터 퍼널, 리플레이-혼합 구성, 증류 패턴: references/synthetic-data.md를 참조하세요.

데이터셋 카드

학습에 도달하는 모든 데이터셋에는 카드가 있습니다 — /finetune이 시작 전에 확인하는 필수 Phase 2 아티팩트입니다. 카드는 자유 형식 문서가 아닙니다. 다음 필드를 반드시 포함해야 합니다:

  • 출처 — 각 행이 어디서 왔는지 (실제 출처, 합성 방법 또는 둘 다), trace-to-training-data 출력으로 추적 가능해야 합니다.
  • 개수 — 총 행 수, 및 분할(학습/평가/보류)된 경우 분할당 행 수.
  • 합성/실제 비율 — 측정된 비율이며, 위의 25% 이상 실제 데이터 기준선과 비교하여 확인합니다.
  • 중복 제거 방법 — 정확히 일치, 의미론적(임베딩 임계값) 또는 둘 다. references/synthetic-data.md의 필터 퍼널을 참조하세요.
  • 사용된 템플릿 — 정확한 채팅 템플릿 문자열/식별자. 추론 및 평가 시 일관되게 유지되며, 이것이 eval-harness-first 실행을 체크포인트에 연결합니다.
  • 패킹 설정 — 패킹 사용 여부, 최대 시퀀스 길이, 위의 5~10개 시퀀스 수동 검사가 수행되었는지 확인.

이 여섯 가지 필드 중 하나라도 누락된 데이터셋은 /finetune에 사용할 준비가 되지 않았습니다 — 카드는 사후에 작성된 요약이 아니라 게이트입니다.

Phase 2 종료 체크리스트

/finetune으로 넘기기 전에 다음을 확인하세요:

  1. 형식이 방법과 일치하는지 (위 표 참조).
  2. 연결 전에 템플릿이 적용되었는지.
  3. 손실이 어시스턴트 턴으로만 마스킹되었는지.
  4. 5~10개의 패킹된 시퀀스가 디코딩되고 읽혔는지.
  5. 최종 혼합물에 실제 데이터가 25% 이상인지.
  6. 데이터셋 카드가 완전한지 — 여섯 가지 필드 모두.

참조

  • references/formats-and-templates.md — 형식별 JSONL 예제, 현재 TRL 마스킹 코드, ShareGPT 변환 참고 사항.
  • references/synthetic-data.md — 생성 방법 순위, 필터 퍼널, 리플레이-혼합 구성, 교사→학생 증류 패턴.

관련 스킬: finetuning-method-selection이 여기로 라우팅합니다. lora-qlora-recipes, vision-sft, preference-optimization은 이 스킬이 생성하는 데이터셋을 소비합니다. trace-to-training-data는 등급이 매겨진 궤적 데이터셋의 출처입니다. eval-harness-first는 결과 체크포인트를 평가합니다.

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

wshobson/accessibility-compliance

Implement WCAG 2.2 compliant interfaces with mobile accessibility, inclusive design patterns, and assistive technology support. Use when auditing accessibility, implementing ARIA patterns, building for screen readers, or ensuring inclusive user experiences.

wshobson/airflow-dag-patterns

Build production Apache Airflow DAGs with best practices for operators, sensors, testing, and deployment. Use when creating data pipelines, orchestrating workflows, or scheduling batch jobs.

wshobson/angular-migration

Migrate from AngularJS to Angular using hybrid mode, incremental component rewriting, and dependency injection updates. Use when upgrading AngularJS applications, planning framework migrations, or modernizing legacy Angular code.

wshobson/anti-reversing-techniques

Understand anti-reversing, obfuscation, and protection techniques encountered during software analysis. Use this skill when analyzing malware evasion techniques, when implementing anti-debugging protections for CTF challenges, when reverse engineering packed binaries, or when building security research tools that need to detect virtualized environments.

wshobson/api-design-principles

Master REST and GraphQL API design principles to build intuitive, scalable, and maintainable APIs that delight developers. Use when designing new APIs, reviewing API specifications, or establishing API design standards.

wshobson/architecture-decision-records

Write and maintain Architecture Decision Records (ADRs) following best practices for technical decision documentation. Use when documenting significant technical decisions, reviewing past architectural choices, or establishing decision processes.

wshobson/architecture-patterns

Implement proven backend architecture patterns including Clean Architecture, Hexagonal Architecture, and Domain-Driven Design. Use this skill when designing clean architecture for a new microservice, when refactoring a monolith to use bounded contexts, when implementing hexagonal or onion architecture patterns, or when debugging dependency cycles between application layers.

wshobson/async-python-patterns

Master Python asyncio, concurrent programming, and async/await patterns for high-performance applications. Use when building async APIs, concurrent systems, or I/O-bound applications requiring non-blocking operations.

wshobson/attack-tree-construction

Build comprehensive attack trees to visualize threat paths. Use when mapping attack scenarios, identifying defense gaps, or communicating security risks to stakeholders.

wshobson/auth-implementation-patterns

Master authentication and authorization patterns including JWT, OAuth2, session management, and RBAC to build secure, scalable access control systems. Use when implementing auth systems, securing APIs, or debugging security issues.

wshobson/avoid-ai-writing

Audit and rewrite prose so it stops reading as machine-generated. Use this skill when asked to remove AI-isms, clean up AI writing, edit a draft for AI tells, audit a README, changelog, release note, PR description, or blog post for machine-sounding prose, or make text sound less like AI. Supports a detect-only mode, a rewrite mode, and an edit-in-place mode, with optional voice and context profiles.

wshobson/backtesting-frameworks

Build robust backtesting systems for trading strategies with proper handling of look-ahead bias, survivorship bias, and transaction costs. Use when developing trading algorithms, validating strategies, or building backtesting infrastructure.

wshobson/bash-defensive-patterns

Master defensive Bash programming techniques for production-grade scripts. Use when writing robust shell scripts, CI/CD pipelines, or system utilities requiring fault tolerance and safety.

wshobson/bats-testing-patterns

Master Bash Automated Testing System (Bats) for comprehensive shell script testing. Use when writing tests for shell scripts, CI/CD pipelines, or requiring test-driven development of shell utilities.

wshobson/bazel-build-optimization

Optimize Bazel builds for large-scale monorepos. Use when configuring Bazel, implementing remote execution, or optimizing build performance for enterprise codebases.

wshobson/before-you-build

Pre-build product and feature risk review for founders, product managers, and AI-assisted builders. Use this skill when the user is about to build a landing page, MVP, SaaS product, internal tool, agent workflow, or major feature and needs to check demand, positioning, monetization, retention, trust, distribution, and adoption risk before implementation starts.

wshobson/billing-automation

Build automated billing systems for recurring payments, invoicing, subscription lifecycle, and dunning management. Use when implementing subscription billing, automating invoicing, or managing recurring payment systems.

wshobson/binary-analysis-patterns

Master binary analysis patterns including disassembly, decompilation, control flow analysis, and code pattern recognition. Use when analyzing executables, understanding compiled code, or performing static analysis on binaries.

wshobson/block-no-verify-hook

Configure a PreToolUse hook to prevent AI agents from skipping git pre-commit hooks with --no-verify and other bypass flags. Use when setting up Claude Code projects that enforce commit quality gates.

wshobson/brand-landingpage

Brand-first landing page designer — runs a brand-identity interview (colors, typography, shape language), then generates and iterates on a polished landing page via Stitch with deployment-ready HTML. Use when the user asks to create, design, or build a landing page, homepage, or marketing page and has no established visual direction. Skip when they have a design mockup, need a dashboard or app UI, are working at component level, building a multi-page app, or restyling with known design tokens — use frontend-design instead.

관련 스킬