
Fine Tuning Expert
Format, validate, and clean instruction and conversation datasets before fine-tuning a custom model for your product or agent.
Overview
Fine-Tuning Expert is an agent skill for the Build phase that prepares and validates high-quality fine-tuning datasets in Alpaca, ShareGPT, and OpenAI message formats.
Install
npx skills add https://github.com/jeffallan/claude-skills --skill fine-tuning-expertWhat is this skill?
- Alpaca instruction–input–output single-turn examples with optional empty input
- ShareGPT multi-turn `conversations` and OpenAI-style `messages` role format
- Guidance that dataset quality is the dominant factor in fine-tuning success
- Reference patterns for converting between common training JSON shapes
- Covers validation, cleaning, and formatting best practices for training files
Adoption & trust: 2.4k installs on skills.sh; 9.7k GitHub stars; 2/3 security scanners passed (skills.sh audits).
What problem does it solve?
You have raw chats or instructions but no validated, consistently formatted training JSON—and you know bad data will waste a fine-tuning run.
Who is it for?
Solo builders custom-tuning a model for a narrow task after they have representative instruction or conversation logs.
Skip if: Teams still exploring product fit with zero-shot prompting only, or runs where you lack rights to use the source text as training data.
When should I use this skill?
When preparing, formatting, or validating datasets for LLM fine-tuning in Alpaca, ShareGPT, or OpenAI message schemas.
What do I get? / Deliverables
You get cleaned, schema-correct examples ready for a fine-tuning job, with formats chosen for single-turn tasks or multi-turn agents.
- Validated training examples in chosen schema
- Conversion notes between Alpaca, ShareGPT, and messages formats
- Data quality and cleaning recommendations
Recommended Skills
Journey fit
Fine-tuning dataset prep belongs in Build because you are manufacturing the training artifact that powers your agent or API behavior. Agent-tooling is the shelf for customizing model behavior beyond prompt-only workflows.
How it compares
Skill reference for dataset craft—not a hosted training pipeline or hyperparameter search tool.
Common Questions / FAQ
Who is fine-tuning-expert for?
Indie developers and small teams building AI features who need agent help structuring fine-tuning JSON from real instructions or conversations.
When should I use fine-tuning-expert?
In Build agent-tooling when converting logs to Alpaca or ShareGPT, before uploading to a fine-tuning provider, or when validating multi-turn message roles.
Is fine-tuning-expert safe to install?
It may process sensitive training text locally via agent tools; review the Security Audits panel on this page and avoid piping secrets or PII you cannot train on.
SKILL.md
READMESKILL.md - Fine Tuning Expert
# Dataset Preparation for Fine-Tuning --- ## Overview Dataset quality is the most important factor in fine-tuning success. This reference covers data formatting, validation, cleaning, and best practices for creating high-quality training data. ## Dataset Formats ### Alpaca Format (Instruction-Response) ```python # Single-turn instruction format alpaca_example = { "instruction": "Summarize the following article in 2-3 sentences.", "input": "The article text goes here...", "output": "The summary goes here." } # Without input field alpaca_no_input = { "instruction": "What are the three primary colors?", "input": "", "output": "The three primary colors are red, blue, and yellow." } ``` ### ShareGPT Format (Multi-Turn Conversations) ```python # Multi-turn conversation format sharegpt_example = { "conversations": [ {"from": "human", "value": "What is machine learning?"}, {"from": "gpt", "value": "Machine learning is a subset of AI that enables..."}, {"from": "human", "value": "Can you give me an example?"}, {"from": "gpt", "value": "A common example is email spam filtering..."} ] } # Alternative format with roles openai_format = { "messages": [ {"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "What is machine learning?"}, {"role": "assistant", "content": "Machine learning is..."} ] } ``` ### Converting Between Formats ```python from typing import TypedDict from datasets import Dataset class AlpacaExample(TypedDict): instruction: str input: str output: str class ShareGPTExample(TypedDict): conversations: list[dict[str, str]] def alpaca_to_sharegpt(example: AlpacaExample) -> ShareGPTExample: """Convert Alpaca format to ShareGPT multi-turn format.""" user_content = example["instruction"] if example.get("input"): user_content += f"\n\n{example['input']}" return { "conversations": [ {"from": "human", "value": user_content}, {"from": "gpt", "value": example["output"]} ] } def sharegpt_to_messages(example: ShareGPTExample, system_prompt: str = "") -> dict: """Convert ShareGPT to OpenAI messages format.""" messages = [] if system_prompt: messages.append({"role": "system", "content": system_prompt}) role_map = {"human": "user", "gpt": "assistant", "system": "system"} for turn in example["conversations"]: messages.append({ "role": role_map.get(turn["from"], turn["from"]), "content": turn["value"] }) return {"messages": messages} ``` ## Formatting for Training ```python from transformers import AutoTokenizer tokenizer = AutoTokenizer.from_pretrained("meta-llama/Llama-3.1-8B-Instruct") def format_instruction_prompt( instruction: str, input_text: str = "", response: str = "", system_prompt: str = "You are a helpful assistant." ) -> str: """Format for Llama 3.1 Instruct chat template.""" messages = [ {"role": "system", "content": system_prompt}, {"role": "user", "content": f"{instruction}\n{input_text}".strip()}, ] if response: messages.append({"role": "assistant", "content": response}) return tokenizer.apply_chat_template( messages, tokenize=False, add_generation_prompt=not response # Add prompt if no response ) # Example usage formatted = format_instruction_prompt( instruction="Translate to French:", input_text="Hello, how are you?", response="Bonjour, comment allez-vous?" ) ``` ## Dataset Validation ```python from dataclasses import dataclass from collections import Counter import re @dataclass class DatasetStats: total_examples: int avg_input_length: float avg_output_length: float max_input_length: int max_output_length: int empty_inputs: int empty_outputs: int duplicate_count: int language_d