{
  "@context": "https://schema.org",
  "@id": "https://aggr.aymericbeaumet.com/items/huggingface-co/2025-12-04-we-got-claude-to-fine-tune-an-open-source-llm/#webpage",
  "@type": [
    "WebPage",
    "ArchiveComponent"
  ],
  "articleBody": "[![banner](https://raw.githubusercontent.com/huggingface/blog/refs/heads/main/assets/hf-skills-training/thumbnail.png)](https://raw.githubusercontent.com/huggingface/blog/refs/heads/main/assets/hf-skills-training/thumbnail.png)\n\nWe gave Claude the ability to fine-tune language models using a new tool called [Hugging Face Skills](https://hf-learn.short.gy/gh-hf-skills). Not just write training scripts, but to actually submit jobs to cloud GPUs, monitor progress, and push finished models to the Hugging Face Hub. This tutorial shows you how it works and how to use it yourself.\n\n> Claude Code can use \"skills\"—packaged instructions, scripts, and domain knowledge—to accomplish specialized tasks. The `hf-llm-trainer` skill teaches Claude everything it needs to know about training: which GPU to pick for your model size, how to configure Hub authentication, when to use LoRA versus full fine-tuning, and how to handle the dozens of other decisions that go into a successful training run.\n\nWith this skill, you can tell Claude things like:\n\n```\nFine-tune Qwen3-0.6B on the dataset open-r1/codeforces-cots\n```\n\nAnd Claude will:\n\n1. Validate your dataset format\n2. Select appropriate hardware (t4-small for a 0.6B model)\n3. Use and update a training script with Trackio monitoring\n4. Submit the job to Hugging Face Jobs\n5. Report the job ID and estimated cost\n6. Check on progress when you ask\n7. Help you debug if something goes wrong\n\nThe model trains on Hugging Face GPUs while you do other things. When it's done, your fine-tuned model appears on the Hub, ready to use.\n\nThis isn't a toy demo. The skill supports the same training methods used in production: supervised fine-tuning, direct preference optimization, and reinforcement learning with verifiable rewards. You can train models from 0.5B to 70B parameters, convert them to GGUF for local deployment, and run multi-stage pipelines that combine different techniques.\n\n## Setup and Install\n\nBefore starting, you'll need:\n\n- A Hugging Face account with a [Pro](https://hf.co/pro) or [Team / Enterprise](https://hf.co/enterprise) plan (Jobs require a paid plan)\n- A write-access token from [huggingface.co/settings/tokens](https://huggingface.co/settings/tokens)\n- A coding agent like Claude Code, OpenAI Codex, or Google's Gemini CLI\n\nHugging Face skills are compatible with Claude Code, Codex, and Gemini CLI. With integrations on the way for Cursor, Windsurf, and Continue.\n\n### Claude Code\n\n1. Register the repository as a marketplace plugin:\n\n```\n/plugin marketplace add huggingface/skills\n```\n\n2. To install a skill, run:\n\n```\n/plugin install <skill-folder>@huggingface-skills\n```\n\nFor example:\n\n```\n/plugin install hf-llm-trainer@huggingface-skills\n```\n\n### Codex\n\n1. Codex will identify the skills via the `AGENTS.md` file. You can verify the instructions are loaded with:\n\n```\ncodex --ask-for-approval never \"Summarize the current instructions.\"\n```\n\n2. For more details, see the [Codex AGENTS guide](https://developers.openai.com/codex/guides/agents-md).\n\n### Gemini CLI\n\n1. This repo includes `gemini-extension.json` to integrate with the Gemini CLI.\n\n2. Install locally:\n\n```\ngemini extensions install . --consent\n```\n\nor use the GitHub URL:\n\n```\ngemini extensions install https://github.com/huggingface/skills.git --consent\n```\n\n4. See [Gemini CLI extensions docs](https://geminicli.com/docs/extensions/#installing-an-extension) for more help.\n\n### Connect to Hugging Face\n\nYou have to authenticate to your Hugging Face account with a [write-access token](https://huggingface.co/settings/tokens) so that the job can create a model repo.\n\nSet up your token:\n\n```bash\nhf auth login\n# or \nexport HF_TOKEN=hf_your_write_access_token_here\n```\n\n> Configure Hugging Face MCP Server to use your write token by sending it in either the `HF_TOKEN` or `Authorization: Bearer` HTTP Headers.\n>\n> For Claude Code: `claude mcp add --transport http hf-skills https://huggingface.co/mcp?bouquet=skills --header \"Authorization: Bearer $HF_TOKEN\"`\n\n## Your First Training Run\n\nLet's walk through a complete example. We'll fine-tune a small model to see the full workflow, then explore more advanced capabilities.\n\n### Instruct the coding agent to fine tune\n\nStart with a simple and clear instruction to fine tune a specific model\n\n```\nFine-tune Qwen3-0.6B on the open-r1/codeforces-cots dataset for instruction following. \n```\n\nThe coding agent analyzes your request and prepares a training configuration. For a 0.6B model on a demo dataset, it selects `t4-small`—enough GPU for this model size and the cheapest option available.\n\n> The `open-r1/codeforces-cots` dataset is a dataset of codeforces problems and solutions. It is a good dataset for instruction tuning a model to solve hard coding problems.\n\n> This works for vision language models too! You can simply run \"Fine-tune Qwen/Qwen3-VL-2B-Instruct on llava-instruct-mix\"\n\n### Review Before Submitting\n\nBefore your coding agent submits anything, you'll see the configuration:\n\n```\nI'll fine-tune Qwen/Qwen3-0.6B on open-r1/codeforces-cots using SFT.\n\nConfiguration:\n- Hardware: t4-small (~$0.75/hour)\n- Estimated time: ~20 minutes\n- Estimated cost: ~$0.30\n- Output: username/qwen-codeforces-cots-sft\n\nThe model will be pushed to Hub automatically. Should I submit?\n```\n\nThis is your chance to adjust anything. Change the output repo name, pick different hardware, or ask Claude to modify training parameters. Once you approve, the agent submits the job.\n\nFor example, you can ask the agent to try a test run:\n\n```\nDo a quick test run on 100 examples.\n```\n\n### Track Progress\n\nAfter submission, you get job details:\n\n```\n✅ Job submitted successfully!\n\nJob ID: abc123xyz\nMonitor: https://huggingface.co/jobs/username/abc123xyz\n\nExpected time: ~20 minutes\nEstimated cost: ~$0.30\n\nView real-time metrics at: https://huggingface.co/spaces/username/trackio\n```\n\n[![Example Trackio dashboard of a Sweep test](https://raw.githubusercontent.com/huggingface/skills/c1452671ff251c138b1f6adc974ed8f54beb21e7/apps/tutorials/sweep_example.png)](https://raw.githubusercontent.com/huggingface/skills/c1452671ff251c138b1f6adc974ed8f54beb21e7/apps/tutorials/sweep_example.png)\n\nThe skill includes Trackio integration, so you can watch training loss decrease in real-time. Jobs run asynchronously so you can close your terminal and come back later. When you want an update:\n\n```\nHow's my training job doing?\n```\n\nThen the agent fetches the logs and summarizes progress.\n\n### Use Your Model\n\nWhen training completes, your model is on the Hub:\n\n```python\nfrom transformers import AutoModelForCausalLM, AutoTokenizer\n\nmodel = AutoModelForCausalLM.from_pretrained(\"username/qwen-codeforces-cots-sft\")\ntokenizer = AutoTokenizer.from_pretrained(\"username/qwen-codeforces-cots-sft\")\n```\n\nThat's the full loop. You described what you wanted in plain English, and the agent handled GPU selection, script generation, job submission, authentication, and persistence. The whole thing cost about thirty cents.\n\n## Training Methods\n\nThe skill supports three training approaches. Understanding when to use each one helps you get better results.\n\n### Supervised Fine-Tuning (SFT)\n\nSFT is where most projects start. You provide demonstration data—examples of inputs and desired outputs—and training adjusts the model to match those patterns.\n\nUse SFT when you have high-quality examples of the behavior you want. Customer support conversations, code generation pairs, domain-specific Q&A—anything where you can show the model what good looks like.\n\n```\nFine-tune Qwen3-0.6B on my-org/support-conversations for 3 epochs.\n```\n\nThe agent validates the dataset, selects hardware (a10g-large with LoRA for a 7B model), and configures training with checkpoints and monitoring.\n\n> For models larger than 3B parameters, the agent automatically uses LoRA (Low-Rank Adaptation) to reduce memory requirements. This makes training 7B or 13B models feasible on single GPUs while preserving most of the quality of full fine-tuning.\n\n### Direct Preference Optimization (DPO)\n\nDPO trains on preference pairs—responses where one is \"chosen\" and another is \"rejected.\" This aligns model outputs with human preferences, typically after an initial SFT stage.\n\nUse DPO when you have preference annotations from human labelers or automated comparisons. DPO optimizes directly for the preferred response without needing a separate reward model.\n\n```\nRun DPO on my-org/preference-data to align the SFT model I just trained.\nThe dataset has 'chosen' and 'rejected' columns.\n```\n\n> DPO is sensitive to dataset format. It requires columns named exactly `chosen` and `rejected`, or a `prompt` column with the input. The agent validates this first and shows you how to map columns if your dataset uses different names.\n\n> You can run DPO using Skills on vision language models too! Try it out with [openbmb/RLAIF-V-Dataset](http://hf.co/datasets/openbmb/RLAIF-V-Dataset). Claude will apply minor modifications but will succeed in training.\n\n### Group Relative Policy Optimization (GRPO)\n\nGRPO is a reinforcement learning task that is proven to be effective on verifiable tasks like solving math problems, writing code, or any task with a programmatic success criterion.\n\n```\nTrain a math reasoning model using GRPO on the openai/gsm8k dataset based on Qwen3-0.6B.\n```\n\nThe model generates responses, receives rewards based on correctness, and learns from the outcomes. This is more complex than SFT or DPO, but the configuration is similar.\n\n## Hardware and Cost\n\nThe agent selects hardware based on your model size, but understanding the tradeoffs helps you make better decisions.\n\n### Model Size to GPU Mapping\n\nFor **tiny models under 1B parameters**, `t4-small` works well. These models train quickly—expect $1-2 for a full run. This is perfect for educational or experimental runs.\n\nFor **small models (1-3B)**, step up to `t4-medium` or `a10g-small`. Training takes a few hours and costs $5-15.\n\nFor **medium models (3-7B)**, you need `a10g-large` or `a100-large` with LoRA. Full fine-tuning doesn't fit, but LoRA makes these very trainable. Budget $15-40 for production.\n\nFor **large models (7B+)**, this HF skills job is not suitable.\n\n### Demo vs Production\n\nWhen testing a workflow, start small:\n\n```\nDo a quick test run to SFT Qwen-0.6B with 100 examples of my-org/support-conversations.\n```\n\nThe coding agent configures minimal training—enough to verify your pipeline works without real cost.\n\nFor production, be explicit:\n\n```\nSFT Qwen-0.6B for production on the full my-org/support-conversations.\nCheckpoints every 500 steps, 3 epochs, cosine learning rate.\n```\n\n> Always run a demo before committing to a multi-hour production job. A $0.50 demo that catches a format error saves a $30 failed run.\n\n## Dataset Validation\n\nDataset format is the most common source of training failures. The agent can validate datasets before you spend GPU time.\n\n```\nCheck if my-org/conversation-data works for SFT training.\n```\n\nThe agent runs a quick inspection on CPU (fractions of a penny) and reports:\n\n```\nDataset validation for my-org/conversation-data:\n\nSFT: ✓ READY\n  Found 'messages' column with conversation format\n\nDPO: ✗ INCOMPATIBLE\n  Missing 'chosen' and 'rejected' columns\n```\n\nIf your dataset needs transformation, the agent can show you how:\n\n```\nMy DPO dataset uses 'good_response' and 'bad_response' instead\nof 'chosen' and 'rejected'. How do I fix this?\n```\n\nThe agent provides mapping code and can incorporate it directly into your training script.\n\n## Monitoring Training\n\nReal-time monitoring helps you catch problems early. The skill configures Trackio by default—after submitting a job, you can watch metrics at:\n\n```\nhttps://huggingface.co/spaces/username/trackio\n```\n\nThis shows training loss, learning rate, and validation metrics. A healthy run shows steadily decreasing loss.\n\nAsk the agent about status anytime:\n\n```\nWhat's the status of my training job?\n```\n\n```\nJob abc123xyz is running (45 minutes elapsed)\n\nCurrent step: 850/1200\nTraining loss: 1.23 (↓ from 2.41 at start)\nLearning rate: 1.2e-5\n\nEstimated completion: ~20 minutes\n```\n\nIf something goes wrong, the agent helps diagnose. Out of memory? the agent suggests reducing batch size or upgrading hardware. Dataset error? The agent identifies the mismatch. Timeout? The agent recommends longer duration or faster training settings.\n\n## Converting to GGUF\n\nAfter training, you might want to run your model locally. The GGUF format works with llama.cpp and dependent tools like LM Studio, Ollama, etc.\n\n```\nConvert my fine-tuned model to GGUF with Q4_K_M quantization.\nPush to username/my-model-gguf.\n```\n\nThe agent submits a conversion job that merges LoRA adapters, converts to GGUF, applies quantization, and pushes to Hub.\n\nThen use it locally:\n\n```bash\nllama-server -hf <username>/<model-name>:<quantization>\n\n# For example, to run the Qwen3-1.7B-GGUF model on your local machine:\nllama-server -hf unsloth/Qwen3-1.7B-GGUF:Q4_K_M\n```\n\n## What's Next\n\nWe've shown that coding agents like Claude Code, Codex, or Gemini CLI can handle the full lifecycle of model fine-tuning: validating data, selecting hardware, generating scripts, submitting jobs, monitoring progress, and converting outputs. This turns what used to be a specialized skill into something you can do through conversation.\n\nSome things to try:\n\n- Fine-tune a model on your own dataset\n- Build a preference-aligned model with SFT → DPO\n- Train a reasoning model with GRPO on math or code\n- Convert a model to GGUF and run it with Ollama\n\nThe [skill is open source](https://hf-learn.short.gy/gh-hf-skills). You can extend it, customize it for your workflows, or use it as a starting point for other training scenarios.\n\n* * *\n\n## Resources\n\n- [SKILL.md](https://github.com/huggingface/skills/blob/main/hf-llm-trainer/skills/model-trainer/SKILL.md) — Full skill documentation\n- [Training Methods](https://github.com/huggingface/skills/blob/main/hf-llm-trainer/skills/model-trainer/references/training_methods.md) — SFT, DPO, GRPO explained\n- [Hardware Guide](https://github.com/huggingface/skills/blob/main/hf-llm-trainer/skills/model-trainer/references/hardware_guide.md) — GPU selection and costs\n- [TRL Documentation](https://huggingface.co/docs/trl) — The underlying training library\n- [Hugging Face Jobs](https://huggingface.co/docs/huggingface_hub/guides/jobs) — Cloud training infrastructure\n- [Trackio](https://huggingface.co/docs/trackio) — Real-time training monitoring\n",
  "authors": [],
  "captured_at": "2026-10-04T12:50:30.804479567+00:00",
  "category": "ai",
  "content_html": "<p><a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://raw.githubusercontent.com/huggingface/blog/refs/heads/main/assets/hf-skills-training/thumbnail.png\"><picture class=\"article-picture article-picture-fallback\" style=\"--image-ratio:16 / 9\"><img src=\"https://raw.githubusercontent.com/huggingface/blog/refs/heads/main/assets/hf-skills-training/thumbnail.png\" alt=\"banner\" loading=\"eager\" decoding=\"async\" fetchpriority=\"high\" referrerpolicy=\"no-referrer\" class=\"progressive-image\"></picture></a></p>\n<p>We gave Claude the ability to fine-tune language models using a new tool called <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://hf-learn.short.gy/gh-hf-skills\">Hugging Face Skills</a>. Not just write training scripts, but to actually submit jobs to cloud GPUs, monitor progress, and push finished models to the Hugging Face Hub. This tutorial shows you how it works and how to use it yourself.</p>\n<blockquote>\n<p>Claude Code can use &quot;skills&quot;—packaged instructions, scripts, and domain knowledge—to accomplish specialized tasks. The <code>hf-llm-trainer</code> skill teaches Claude everything it needs to know about training: which GPU to pick for your model size, how to configure Hub authentication, when to use LoRA versus full fine-tuning, and how to handle the dozens of other decisions that go into a successful training run.</p>\n</blockquote>\n<p>With this skill, you can tell Claude things like:</p>\n<pre><code><span class=\"code-snippet\">Fine-tune Qwen3-0.6B on the dataset open-r1/codeforces-cots\n</span></code></pre>\n<p>And Claude will:</p>\n<ol>\n<li>Validate your dataset format</li>\n<li>Select appropriate hardware (t4-small for a 0.6B model)</li>\n<li>Use and update a training script with Trackio monitoring</li>\n<li>Submit the job to Hugging Face Jobs</li>\n<li>Report the job ID and estimated cost</li>\n<li>Check on progress when you ask</li>\n<li>Help you debug if something goes wrong</li>\n</ol>\n<p>The model trains on Hugging Face GPUs while you do other things. When it's done, your fine-tuned model appears on the Hub, ready to use.</p>\n<p>This isn't a toy demo. The skill supports the same training methods used in production: supervised fine-tuning, direct preference optimization, and reinforcement learning with verifiable rewards. You can train models from 0.5B to 70B parameters, convert them to GGUF for local deployment, and run multi-stage pipelines that combine different techniques.</p>\n<h2>Setup and Install</h2>\n<p>Before starting, you'll need:</p>\n<ul>\n<li>A Hugging Face account with a <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://hf.co/pro\">Pro</a> or <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://hf.co/enterprise\">Team / Enterprise</a> plan (Jobs require a paid plan)</li>\n<li>A write-access token from <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://huggingface.co/settings/tokens\">huggingface.co/settings/tokens</a></li>\n<li>A coding agent like Claude Code, OpenAI Codex, or Google's Gemini CLI</li>\n</ul>\n<p>Hugging Face skills are compatible with Claude Code, Codex, and Gemini CLI. With integrations on the way for Cursor, Windsurf, and Continue.</p>\n<h3>Claude Code</h3>\n<ol>\n<li>Register the repository as a marketplace plugin:</li>\n</ol>\n<pre><code><span class=\"code-snippet\">/plugin marketplace add huggingface/skills\n</span></code></pre>\n<ol start=\"2\">\n<li>To install a skill, run:</li>\n</ol>\n<pre><code><span class=\"code-snippet\">/plugin install &lt;skill-folder&gt;@huggingface-skills\n</span></code></pre>\n<p>For example:</p>\n<pre><code><span class=\"code-snippet\">/plugin install hf-llm-trainer@huggingface-skills\n</span></code></pre>\n<h3>Codex</h3>\n<ol>\n<li>Codex will identify the skills via the <code>AGENTS.md</code> file. You can verify the instructions are loaded with:</li>\n</ol>\n<pre><code><span class=\"code-snippet\">codex --ask-for-approval never &quot;Summarize the current instructions.&quot;\n</span></code></pre>\n<ol start=\"2\">\n<li>For more details, see the <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://developers.openai.com/codex/guides/agents-md\">Codex AGENTS guide</a>.</li>\n</ol>\n<h3>Gemini CLI</h3>\n<ol>\n<li>\n<p>This repo includes <code>gemini-extension.json</code> to integrate with the Gemini CLI.</p>\n</li>\n<li>\n<p>Install locally:</p>\n</li>\n</ol>\n<pre><code><span class=\"code-snippet\">gemini extensions install . --consent\n</span></code></pre>\n<p>or use the GitHub URL:</p>\n<pre><code><span class=\"code-snippet\">gemini extensions install https://github.com/huggingface/skills.git --consent\n</span></code></pre>\n<ol start=\"4\">\n<li>See <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://geminicli.com/docs/extensions/#installing-an-extension\">Gemini CLI extensions docs</a> for more help.</li>\n</ol>\n<h3>Connect to Hugging Face</h3>\n<p>You have to authenticate to your Hugging Face account with a <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://huggingface.co/settings/tokens\">write-access token</a> so that the job can create a model repo.</p>\n<p>Set up your token:</p>\n<pre><code class=\"language-bash\"><span class=\"code-snippet\" data-language=\"Shell\"><span class=\"syntax-source syntax-shell syntax-bash\"><span class=\"syntax-meta syntax-function-call syntax-shell\"><span class=\"syntax-variable syntax-function syntax-shell\">hf</span></span><span class=\"syntax-meta syntax-function-call syntax-arguments syntax-shell\"> auth login</span>\n<span class=\"syntax-comment syntax-line syntax-number-sign syntax-shell\"><span class=\"syntax-punctuation syntax-definition syntax-comment syntax-begin syntax-shell\">#</span></span><span class=\"syntax-comment syntax-line syntax-number-sign syntax-shell\"> or </span><span class=\"syntax-comment syntax-line syntax-number-sign syntax-shell\">\n</span><span class=\"syntax-meta syntax-function-call syntax-shell\"><span class=\"syntax-storage syntax-modifier syntax-shell\">export</span> <span class=\"syntax-variable syntax-other syntax-readwrite syntax-assignment syntax-shell\">HF_TOKEN</span><span class=\"syntax-keyword syntax-operator syntax-assignment syntax-shell\">=</span><span class=\"syntax-string syntax-unquoted syntax-shell\">hf_your_write_access_token_here</span></span>\n</span></span></code></pre>\n<blockquote>\n<p>Configure Hugging Face MCP Server to use your write token by sending it in either the <code>HF_TOKEN</code> or <code>Authorization: Bearer</code> HTTP Headers.</p>\n<p>For Claude Code: <code>claude mcp add --transport http hf-skills https://huggingface.co/mcp?bouquet=skills --header &quot;Authorization: Bearer $HF_TOKEN&quot;</code></p>\n</blockquote>\n<h2>Your First Training Run</h2>\n<p>Let's walk through a complete example. We'll fine-tune a small model to see the full workflow, then explore more advanced capabilities.</p>\n<h3>Instruct the coding agent to fine tune</h3>\n<p>Start with a simple and clear instruction to fine tune a specific model</p>\n<pre><code><span class=\"code-snippet\">Fine-tune Qwen3-0.6B on the open-r1/codeforces-cots dataset for instruction following. \n</span></code></pre>\n<p>The coding agent analyzes your request and prepares a training configuration. For a 0.6B model on a demo dataset, it selects <code>t4-small</code>—enough GPU for this model size and the cheapest option available.</p>\n<blockquote>\n<p>The <code>open-r1/codeforces-cots</code> dataset is a dataset of codeforces problems and solutions. It is a good dataset for instruction tuning a model to solve hard coding problems.</p>\n</blockquote>\n<blockquote>\n<p>This works for vision language models too! You can simply run &quot;Fine-tune Qwen/Qwen3-VL-2B-Instruct on llava-instruct-mix&quot;</p>\n</blockquote>\n<h3>Review Before Submitting</h3>\n<p>Before your coding agent submits anything, you'll see the configuration:</p>\n<pre><code><span class=\"code-snippet\" data-language=\"YAML\"><span class=\"syntax-source syntax-yaml\"><span class=\"syntax-string syntax-unquoted syntax-plain syntax-out syntax-yaml\">I&#39;ll fine-tune Qwen/Qwen3-0.6B on open-r1/codeforces-cots using SFT.</span>\n\n<span class=\"syntax-string syntax-unquoted syntax-plain syntax-out syntax-yaml\"><span class=\"syntax-entity syntax-name syntax-tag syntax-yaml\">Configuration</span></span><span class=\"syntax-punctuation syntax-separator syntax-key-value syntax-mapping syntax-yaml\">:</span>\n<span class=\"syntax-punctuation syntax-definition syntax-block syntax-sequence syntax-item syntax-yaml\">-</span> <span class=\"syntax-string syntax-unquoted syntax-plain syntax-out syntax-yaml\"><span class=\"syntax-entity syntax-name syntax-tag syntax-yaml\">Hardware</span></span><span class=\"syntax-punctuation syntax-separator syntax-key-value syntax-mapping syntax-yaml\">:</span> <span class=\"syntax-string syntax-unquoted syntax-plain syntax-out syntax-yaml\">t4-small (~$0.75/hour)</span>\n<span class=\"syntax-punctuation syntax-definition syntax-block syntax-sequence syntax-item syntax-yaml\">-</span> <span class=\"syntax-string syntax-unquoted syntax-plain syntax-out syntax-yaml\"><span class=\"syntax-entity syntax-name syntax-tag syntax-yaml\">Estimated time</span></span><span class=\"syntax-punctuation syntax-separator syntax-key-value syntax-mapping syntax-yaml\">:</span> <span class=\"syntax-string syntax-unquoted syntax-plain syntax-out syntax-yaml\">~20 minutes</span>\n<span class=\"syntax-punctuation syntax-definition syntax-block syntax-sequence syntax-item syntax-yaml\">-</span> <span class=\"syntax-string syntax-unquoted syntax-plain syntax-out syntax-yaml\"><span class=\"syntax-entity syntax-name syntax-tag syntax-yaml\">Estimated cost</span></span><span class=\"syntax-punctuation syntax-separator syntax-key-value syntax-mapping syntax-yaml\">:</span> <span class=\"syntax-string syntax-unquoted syntax-plain syntax-out syntax-yaml\">~$0.30</span>\n<span class=\"syntax-punctuation syntax-definition syntax-block syntax-sequence syntax-item syntax-yaml\">-</span> <span class=\"syntax-string syntax-unquoted syntax-plain syntax-out syntax-yaml\"><span class=\"syntax-entity syntax-name syntax-tag syntax-yaml\">Output</span></span><span class=\"syntax-punctuation syntax-separator syntax-key-value syntax-mapping syntax-yaml\">:</span> <span class=\"syntax-string syntax-unquoted syntax-plain syntax-out syntax-yaml\">username/qwen-codeforces-cots-sft</span>\n\n<span class=\"syntax-string syntax-unquoted syntax-plain syntax-out syntax-yaml\">The model will be pushed to Hub automatically. Should I submit?</span>\n</span></span></code></pre>\n<p>This is your chance to adjust anything. Change the output repo name, pick different hardware, or ask Claude to modify training parameters. Once you approve, the agent submits the job.</p>\n<p>For example, you can ask the agent to try a test run:</p>\n<pre><code><span class=\"code-snippet\">Do a quick test run on 100 examples.\n</span></code></pre>\n<h3>Track Progress</h3>\n<p>After submission, you get job details:</p>\n<pre><code><span class=\"code-snippet\">✅ Job submitted successfully!\n\nJob ID: abc123xyz\nMonitor: https://huggingface.co/jobs/username/abc123xyz\n\nExpected time: ~20 minutes\nEstimated cost: ~$0.30\n\nView real-time metrics at: https://huggingface.co/spaces/username/trackio\n</span></code></pre>\n<p><a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://raw.githubusercontent.com/huggingface/skills/c1452671ff251c138b1f6adc974ed8f54beb21e7/apps/tutorials/sweep_example.png\"><picture class=\"article-picture article-picture-fallback\" style=\"--image-ratio:16 / 9\"><img src=\"https://raw.githubusercontent.com/huggingface/skills/c1452671ff251c138b1f6adc974ed8f54beb21e7/apps/tutorials/sweep_example.png\" alt=\"Example Trackio dashboard of a Sweep test\" loading=\"lazy\" decoding=\"async\" fetchpriority=\"low\" referrerpolicy=\"no-referrer\" class=\"progressive-image\"></picture></a></p>\n<p>The skill includes Trackio integration, so you can watch training loss decrease in real-time. Jobs run asynchronously so you can close your terminal and come back later. When you want an update:</p>\n<pre><code><span class=\"code-snippet\">How&#39;s my training job doing?\n</span></code></pre>\n<p>Then the agent fetches the logs and summarizes progress.</p>\n<h3>Use Your Model</h3>\n<p>When training completes, your model is on the Hub:</p>\n<pre><code class=\"language-python\"><span class=\"code-snippet\" data-language=\"Python\"><span class=\"syntax-source syntax-python\"><span class=\"syntax-meta syntax-statement syntax-import syntax-python\"><span class=\"syntax-keyword syntax-control syntax-import syntax-from syntax-python\">from</span></span><span class=\"syntax-meta syntax-statement syntax-import syntax-python\"><span class=\"syntax-meta syntax-import-source syntax-python\"> <span class=\"syntax-meta syntax-import-path syntax-python\"><span class=\"syntax-meta syntax-import-name syntax-python\">transformers</span></span> <span class=\"syntax-meta syntax-statement syntax-import syntax-python\"><span class=\"syntax-keyword syntax-control syntax-import syntax-python\">import</span></span></span></span><span class=\"syntax-meta syntax-statement syntax-import syntax-python\"></span><span class=\"syntax-meta syntax-statement syntax-import syntax-python\"> <span class=\"syntax-meta syntax-generic-name syntax-python\">AutoModelForCausalLM</span><span class=\"syntax-punctuation syntax-separator syntax-import-list syntax-python\">,</span> <span class=\"syntax-meta syntax-generic-name syntax-python\">AutoTokenizer</span></span>\n\n<span class=\"syntax-meta syntax-qualified-name syntax-python\"><span class=\"syntax-meta syntax-generic-name syntax-python\">model</span></span> <span class=\"syntax-keyword syntax-operator syntax-assignment syntax-python\">=</span> <span class=\"syntax-meta syntax-function-call syntax-python\"><span class=\"syntax-meta syntax-qualified-name syntax-python\"><span class=\"syntax-meta syntax-generic-name syntax-python\">AutoModelForCausalLM</span><span class=\"syntax-punctuation syntax-accessor syntax-dot syntax-python\">.</span></span><span class=\"syntax-meta syntax-qualified-name syntax-python\"><span class=\"syntax-variable syntax-function syntax-python\">from_pretrained</span></span><span class=\"syntax-punctuation syntax-section syntax-arguments syntax-begin syntax-python\">(</span><span class=\"syntax-meta syntax-function-call syntax-arguments syntax-python\"><span class=\"syntax-meta syntax-string syntax-python\"><span class=\"syntax-string syntax-quoted syntax-double syntax-python\"><span class=\"syntax-punctuation syntax-definition syntax-string syntax-begin syntax-python\">&quot;</span></span></span><span class=\"syntax-meta syntax-string syntax-python\"><span class=\"syntax-string syntax-quoted syntax-double syntax-python\">username/qwen-codeforces-cots-sft<span class=\"syntax-punctuation syntax-definition syntax-string syntax-end syntax-python\">&quot;</span></span></span></span><span class=\"syntax-punctuation syntax-section syntax-arguments syntax-end syntax-python\">)</span></span>\n<span class=\"syntax-meta syntax-qualified-name syntax-python\"><span class=\"syntax-meta syntax-generic-name syntax-python\">tokenizer</span></span> <span class=\"syntax-keyword syntax-operator syntax-assignment syntax-python\">=</span> <span class=\"syntax-meta syntax-function-call syntax-python\"><span class=\"syntax-meta syntax-qualified-name syntax-python\"><span class=\"syntax-meta syntax-generic-name syntax-python\">AutoTokenizer</span><span class=\"syntax-punctuation syntax-accessor syntax-dot syntax-python\">.</span></span><span class=\"syntax-meta syntax-qualified-name syntax-python\"><span class=\"syntax-variable syntax-function syntax-python\">from_pretrained</span></span><span class=\"syntax-punctuation syntax-section syntax-arguments syntax-begin syntax-python\">(</span><span class=\"syntax-meta syntax-function-call syntax-arguments syntax-python\"><span class=\"syntax-meta syntax-string syntax-python\"><span class=\"syntax-string syntax-quoted syntax-double syntax-python\"><span class=\"syntax-punctuation syntax-definition syntax-string syntax-begin syntax-python\">&quot;</span></span></span><span class=\"syntax-meta syntax-string syntax-python\"><span class=\"syntax-string syntax-quoted syntax-double syntax-python\">username/qwen-codeforces-cots-sft<span class=\"syntax-punctuation syntax-definition syntax-string syntax-end syntax-python\">&quot;</span></span></span></span><span class=\"syntax-punctuation syntax-section syntax-arguments syntax-end syntax-python\">)</span></span>\n</span></span></code></pre>\n<p>That's the full loop. You described what you wanted in plain English, and the agent handled GPU selection, script generation, job submission, authentication, and persistence. The whole thing cost about thirty cents.</p>\n<h2>Training Methods</h2>\n<p>The skill supports three training approaches. Understanding when to use each one helps you get better results.</p>\n<h3>Supervised Fine-Tuning (SFT)</h3>\n<p>SFT is where most projects start. You provide demonstration data—examples of inputs and desired outputs—and training adjusts the model to match those patterns.</p>\n<p>Use SFT when you have high-quality examples of the behavior you want. Customer support conversations, code generation pairs, domain-specific Q&amp;A—anything where you can show the model what good looks like.</p>\n<pre><code><span class=\"code-snippet\">Fine-tune Qwen3-0.6B on my-org/support-conversations for 3 epochs.\n</span></code></pre>\n<p>The agent validates the dataset, selects hardware (a10g-large with LoRA for a 7B model), and configures training with checkpoints and monitoring.</p>\n<blockquote>\n<p>For models larger than 3B parameters, the agent automatically uses LoRA (Low-Rank Adaptation) to reduce memory requirements. This makes training 7B or 13B models feasible on single GPUs while preserving most of the quality of full fine-tuning.</p>\n</blockquote>\n<h3>Direct Preference Optimization (DPO)</h3>\n<p>DPO trains on preference pairs—responses where one is &quot;chosen&quot; and another is &quot;rejected.&quot; This aligns model outputs with human preferences, typically after an initial SFT stage.</p>\n<p>Use DPO when you have preference annotations from human labelers or automated comparisons. DPO optimizes directly for the preferred response without needing a separate reward model.</p>\n<pre><code><span class=\"code-snippet\">Run DPO on my-org/preference-data to align the SFT model I just trained.\nThe dataset has &#39;chosen&#39; and &#39;rejected&#39; columns.\n</span></code></pre>\n<blockquote>\n<p>DPO is sensitive to dataset format. It requires columns named exactly <code>chosen</code> and <code>rejected</code>, or a <code>prompt</code> column with the input. The agent validates this first and shows you how to map columns if your dataset uses different names.</p>\n</blockquote>\n<blockquote>\n<p>You can run DPO using Skills on vision language models too! Try it out with <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"http://hf.co/datasets/openbmb/RLAIF-V-Dataset\">openbmb/RLAIF-V-Dataset</a>. Claude will apply minor modifications but will succeed in training.</p>\n</blockquote>\n<h3>Group Relative Policy Optimization (GRPO)</h3>\n<p>GRPO is a reinforcement learning task that is proven to be effective on verifiable tasks like solving math problems, writing code, or any task with a programmatic success criterion.</p>\n<pre><code><span class=\"code-snippet\">Train a math reasoning model using GRPO on the openai/gsm8k dataset based on Qwen3-0.6B.\n</span></code></pre>\n<p>The model generates responses, receives rewards based on correctness, and learns from the outcomes. This is more complex than SFT or DPO, but the configuration is similar.</p>\n<h2>Hardware and Cost</h2>\n<p>The agent selects hardware based on your model size, but understanding the tradeoffs helps you make better decisions.</p>\n<h3>Model Size to GPU Mapping</h3>\n<p>For <strong>tiny models under 1B parameters</strong>, <code>t4-small</code> works well. These models train quickly—expect $1-2 for a full run. This is perfect for educational or experimental runs.</p>\n<p>For <strong>small models (1-3B)</strong>, step up to <code>t4-medium</code> or <code>a10g-small</code>. Training takes a few hours and costs $5-15.</p>\n<p>For <strong>medium models (3-7B)</strong>, you need <code>a10g-large</code> or <code>a100-large</code> with LoRA. Full fine-tuning doesn't fit, but LoRA makes these very trainable. Budget $15-40 for production.</p>\n<p>For <strong>large models (7B+)</strong>, this HF skills job is not suitable.</p>\n<h3>Demo vs Production</h3>\n<p>When testing a workflow, start small:</p>\n<pre><code><span class=\"code-snippet\">Do a quick test run to SFT Qwen-0.6B with 100 examples of my-org/support-conversations.\n</span></code></pre>\n<p>The coding agent configures minimal training—enough to verify your pipeline works without real cost.</p>\n<p>For production, be explicit:</p>\n<pre><code><span class=\"code-snippet\">SFT Qwen-0.6B for production on the full my-org/support-conversations.\nCheckpoints every 500 steps, 3 epochs, cosine learning rate.\n</span></code></pre>\n<blockquote>\n<p>Always run a demo before committing to a multi-hour production job. A $0.50 demo that catches a format error saves a $30 failed run.</p>\n</blockquote>\n<h2>Dataset Validation</h2>\n<p>Dataset format is the most common source of training failures. The agent can validate datasets before you spend GPU time.</p>\n<pre><code><span class=\"code-snippet\">Check if my-org/conversation-data works for SFT training.\n</span></code></pre>\n<p>The agent runs a quick inspection on CPU (fractions of a penny) and reports:</p>\n<pre><code><span class=\"code-snippet\">Dataset validation for my-org/conversation-data:\n\nSFT: ✓ READY\n  Found &#39;messages&#39; column with conversation format\n\nDPO: ✗ INCOMPATIBLE\n  Missing &#39;chosen&#39; and &#39;rejected&#39; columns\n</span></code></pre>\n<p>If your dataset needs transformation, the agent can show you how:</p>\n<pre><code><span class=\"code-snippet\">My DPO dataset uses &#39;good_response&#39; and &#39;bad_response&#39; instead\nof &#39;chosen&#39; and &#39;rejected&#39;. How do I fix this?\n</span></code></pre>\n<p>The agent provides mapping code and can incorporate it directly into your training script.</p>\n<h2>Monitoring Training</h2>\n<p>Real-time monitoring helps you catch problems early. The skill configures Trackio by default—after submitting a job, you can watch metrics at:</p>\n<pre><code><span class=\"code-snippet\">https://huggingface.co/spaces/username/trackio\n</span></code></pre>\n<p>This shows training loss, learning rate, and validation metrics. A healthy run shows steadily decreasing loss.</p>\n<p>Ask the agent about status anytime:</p>\n<pre><code><span class=\"code-snippet\">What&#39;s the status of my training job?\n</span></code></pre>\n<pre><code><span class=\"code-snippet\">Job abc123xyz is running (45 minutes elapsed)\n\nCurrent step: 850/1200\nTraining loss: 1.23 (↓ from 2.41 at start)\nLearning rate: 1.2e-5\n\nEstimated completion: ~20 minutes\n</span></code></pre>\n<p>If something goes wrong, the agent helps diagnose. Out of memory? the agent suggests reducing batch size or upgrading hardware. Dataset error? The agent identifies the mismatch. Timeout? The agent recommends longer duration or faster training settings.</p>\n<h2>Converting to GGUF</h2>\n<p>After training, you might want to run your model locally. The GGUF format works with llama.cpp and dependent tools like LM Studio, Ollama, etc.</p>\n<pre><code><span class=\"code-snippet\">Convert my fine-tuned model to GGUF with Q4_K_M quantization.\nPush to username/my-model-gguf.\n</span></code></pre>\n<p>The agent submits a conversion job that merges LoRA adapters, converts to GGUF, applies quantization, and pushes to Hub.</p>\n<p>Then use it locally:</p>\n<pre><code class=\"language-bash\"><span class=\"code-snippet\" data-language=\"Shell\"><span class=\"syntax-source syntax-shell syntax-bash\"><span class=\"syntax-meta syntax-function-call syntax-shell\"><span class=\"syntax-variable syntax-function syntax-shell\">llama-server</span></span><span class=\"syntax-meta syntax-function-call syntax-arguments syntax-shell\"><span class=\"syntax-variable syntax-parameter syntax-option syntax-shell\"><span class=\"syntax-punctuation syntax-definition syntax-parameter syntax-shell\"> -</span>hf</span> <span class=\"syntax-keyword syntax-operator syntax-assignment syntax-redirection syntax-shell\">&lt;</span>username<span class=\"syntax-keyword syntax-operator syntax-assignment syntax-redirection syntax-shell\">&gt;</span>/<span class=\"syntax-keyword syntax-operator syntax-assignment syntax-redirection syntax-shell\">&lt;</span>model-name<span class=\"syntax-keyword syntax-operator syntax-assignment syntax-redirection syntax-shell\">&gt;</span>:<span class=\"syntax-keyword syntax-operator syntax-assignment syntax-redirection syntax-shell\">&lt;</span>quantization<span class=\"syntax-keyword syntax-operator syntax-assignment syntax-redirection syntax-shell\">&gt;</span>\n</span>\n<span class=\"syntax-comment syntax-line syntax-number-sign syntax-shell\"><span class=\"syntax-punctuation syntax-definition syntax-comment syntax-begin syntax-shell\">#</span></span><span class=\"syntax-comment syntax-line syntax-number-sign syntax-shell\"> For example, to run the Qwen3-1.7B-GGUF model on your local machine:</span><span class=\"syntax-comment syntax-line syntax-number-sign syntax-shell\">\n</span><span class=\"syntax-meta syntax-function-call syntax-shell\"><span class=\"syntax-variable syntax-function syntax-shell\">llama-server</span></span><span class=\"syntax-meta syntax-function-call syntax-arguments syntax-shell\"><span class=\"syntax-variable syntax-parameter syntax-option syntax-shell\"><span class=\"syntax-punctuation syntax-definition syntax-parameter syntax-shell\"> -</span>hf</span> unsloth/Qwen3-1.7B-GGUF:Q4_K_M</span>\n</span></span></code></pre>\n<h2>What's Next</h2>\n<p>We've shown that coding agents like Claude Code, Codex, or Gemini CLI can handle the full lifecycle of model fine-tuning: validating data, selecting hardware, generating scripts, submitting jobs, monitoring progress, and converting outputs. This turns what used to be a specialized skill into something you can do through conversation.</p>\n<p>Some things to try:</p>\n<ul>\n<li>Fine-tune a model on your own dataset</li>\n<li>Build a preference-aligned model with SFT → DPO</li>\n<li>Train a reasoning model with GRPO on math or code</li>\n<li>Convert a model to GGUF and run it with Ollama</li>\n</ul>\n<p>The <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://hf-learn.short.gy/gh-hf-skills\">skill is open source</a>. You can extend it, customize it for your workflows, or use it as a starting point for other training scenarios.</p>\n<hr />\n<h2>Resources</h2>\n<ul>\n<li><a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://github.com/huggingface/skills/blob/main/hf-llm-trainer/skills/model-trainer/SKILL.md\">SKILL.md</a> — Full skill documentation</li>\n<li><a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://github.com/huggingface/skills/blob/main/hf-llm-trainer/skills/model-trainer/references/training_methods.md\">Training Methods</a> — SFT, DPO, GRPO explained</li>\n<li><a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://github.com/huggingface/skills/blob/main/hf-llm-trainer/skills/model-trainer/references/hardware_guide.md\">Hardware Guide</a> — GPU selection and costs</li>\n<li><a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://huggingface.co/docs/trl\">TRL Documentation</a> — The underlying training library</li>\n<li><a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://huggingface.co/docs/huggingface_hub/guides/jobs\">Hugging Face Jobs</a> — Cloud training infrastructure</li>\n<li><a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://huggingface.co/docs/trackio\">Trackio</a> — Real-time training monitoring</li>\n</ul>\n",
  "content_markdown": "[![banner](https://raw.githubusercontent.com/huggingface/blog/refs/heads/main/assets/hf-skills-training/thumbnail.png)](https://raw.githubusercontent.com/huggingface/blog/refs/heads/main/assets/hf-skills-training/thumbnail.png)\n\nWe gave Claude the ability to fine-tune language models using a new tool called [Hugging Face Skills](https://hf-learn.short.gy/gh-hf-skills). Not just write training scripts, but to actually submit jobs to cloud GPUs, monitor progress, and push finished models to the Hugging Face Hub. This tutorial shows you how it works and how to use it yourself.\n\n> Claude Code can use \"skills\"—packaged instructions, scripts, and domain knowledge—to accomplish specialized tasks. The `hf-llm-trainer` skill teaches Claude everything it needs to know about training: which GPU to pick for your model size, how to configure Hub authentication, when to use LoRA versus full fine-tuning, and how to handle the dozens of other decisions that go into a successful training run.\n\nWith this skill, you can tell Claude things like:\n\n```\nFine-tune Qwen3-0.6B on the dataset open-r1/codeforces-cots\n```\n\nAnd Claude will:\n\n1. Validate your dataset format\n2. Select appropriate hardware (t4-small for a 0.6B model)\n3. Use and update a training script with Trackio monitoring\n4. Submit the job to Hugging Face Jobs\n5. Report the job ID and estimated cost\n6. Check on progress when you ask\n7. Help you debug if something goes wrong\n\nThe model trains on Hugging Face GPUs while you do other things. When it's done, your fine-tuned model appears on the Hub, ready to use.\n\nThis isn't a toy demo. The skill supports the same training methods used in production: supervised fine-tuning, direct preference optimization, and reinforcement learning with verifiable rewards. You can train models from 0.5B to 70B parameters, convert them to GGUF for local deployment, and run multi-stage pipelines that combine different techniques.\n\n## Setup and Install\n\nBefore starting, you'll need:\n\n- A Hugging Face account with a [Pro](https://hf.co/pro) or [Team / Enterprise](https://hf.co/enterprise) plan (Jobs require a paid plan)\n- A write-access token from [huggingface.co/settings/tokens](https://huggingface.co/settings/tokens)\n- A coding agent like Claude Code, OpenAI Codex, or Google's Gemini CLI\n\nHugging Face skills are compatible with Claude Code, Codex, and Gemini CLI. With integrations on the way for Cursor, Windsurf, and Continue.\n\n### Claude Code\n\n1. Register the repository as a marketplace plugin:\n\n```\n/plugin marketplace add huggingface/skills\n```\n\n2. To install a skill, run:\n\n```\n/plugin install <skill-folder>@huggingface-skills\n```\n\nFor example:\n\n```\n/plugin install hf-llm-trainer@huggingface-skills\n```\n\n### Codex\n\n1. Codex will identify the skills via the `AGENTS.md` file. You can verify the instructions are loaded with:\n\n```\ncodex --ask-for-approval never \"Summarize the current instructions.\"\n```\n\n2. For more details, see the [Codex AGENTS guide](https://developers.openai.com/codex/guides/agents-md).\n\n### Gemini CLI\n\n1. This repo includes `gemini-extension.json` to integrate with the Gemini CLI.\n\n2. Install locally:\n\n```\ngemini extensions install . --consent\n```\n\nor use the GitHub URL:\n\n```\ngemini extensions install https://github.com/huggingface/skills.git --consent\n```\n\n4. See [Gemini CLI extensions docs](https://geminicli.com/docs/extensions/#installing-an-extension) for more help.\n\n### Connect to Hugging Face\n\nYou have to authenticate to your Hugging Face account with a [write-access token](https://huggingface.co/settings/tokens) so that the job can create a model repo.\n\nSet up your token:\n\n```bash\nhf auth login\n# or \nexport HF_TOKEN=hf_your_write_access_token_here\n```\n\n> Configure Hugging Face MCP Server to use your write token by sending it in either the `HF_TOKEN` or `Authorization: Bearer` HTTP Headers.\n>\n> For Claude Code: `claude mcp add --transport http hf-skills https://huggingface.co/mcp?bouquet=skills --header \"Authorization: Bearer $HF_TOKEN\"`\n\n## Your First Training Run\n\nLet's walk through a complete example. We'll fine-tune a small model to see the full workflow, then explore more advanced capabilities.\n\n### Instruct the coding agent to fine tune\n\nStart with a simple and clear instruction to fine tune a specific model\n\n```\nFine-tune Qwen3-0.6B on the open-r1/codeforces-cots dataset for instruction following. \n```\n\nThe coding agent analyzes your request and prepares a training configuration. For a 0.6B model on a demo dataset, it selects `t4-small`—enough GPU for this model size and the cheapest option available.\n\n> The `open-r1/codeforces-cots` dataset is a dataset of codeforces problems and solutions. It is a good dataset for instruction tuning a model to solve hard coding problems.\n\n> This works for vision language models too! You can simply run \"Fine-tune Qwen/Qwen3-VL-2B-Instruct on llava-instruct-mix\"\n\n### Review Before Submitting\n\nBefore your coding agent submits anything, you'll see the configuration:\n\n```\nI'll fine-tune Qwen/Qwen3-0.6B on open-r1/codeforces-cots using SFT.\n\nConfiguration:\n- Hardware: t4-small (~$0.75/hour)\n- Estimated time: ~20 minutes\n- Estimated cost: ~$0.30\n- Output: username/qwen-codeforces-cots-sft\n\nThe model will be pushed to Hub automatically. Should I submit?\n```\n\nThis is your chance to adjust anything. Change the output repo name, pick different hardware, or ask Claude to modify training parameters. Once you approve, the agent submits the job.\n\nFor example, you can ask the agent to try a test run:\n\n```\nDo a quick test run on 100 examples.\n```\n\n### Track Progress\n\nAfter submission, you get job details:\n\n```\n✅ Job submitted successfully!\n\nJob ID: abc123xyz\nMonitor: https://huggingface.co/jobs/username/abc123xyz\n\nExpected time: ~20 minutes\nEstimated cost: ~$0.30\n\nView real-time metrics at: https://huggingface.co/spaces/username/trackio\n```\n\n[![Example Trackio dashboard of a Sweep test](https://raw.githubusercontent.com/huggingface/skills/c1452671ff251c138b1f6adc974ed8f54beb21e7/apps/tutorials/sweep_example.png)](https://raw.githubusercontent.com/huggingface/skills/c1452671ff251c138b1f6adc974ed8f54beb21e7/apps/tutorials/sweep_example.png)\n\nThe skill includes Trackio integration, so you can watch training loss decrease in real-time. Jobs run asynchronously so you can close your terminal and come back later. When you want an update:\n\n```\nHow's my training job doing?\n```\n\nThen the agent fetches the logs and summarizes progress.\n\n### Use Your Model\n\nWhen training completes, your model is on the Hub:\n\n```python\nfrom transformers import AutoModelForCausalLM, AutoTokenizer\n\nmodel = AutoModelForCausalLM.from_pretrained(\"username/qwen-codeforces-cots-sft\")\ntokenizer = AutoTokenizer.from_pretrained(\"username/qwen-codeforces-cots-sft\")\n```\n\nThat's the full loop. You described what you wanted in plain English, and the agent handled GPU selection, script generation, job submission, authentication, and persistence. The whole thing cost about thirty cents.\n\n## Training Methods\n\nThe skill supports three training approaches. Understanding when to use each one helps you get better results.\n\n### Supervised Fine-Tuning (SFT)\n\nSFT is where most projects start. You provide demonstration data—examples of inputs and desired outputs—and training adjusts the model to match those patterns.\n\nUse SFT when you have high-quality examples of the behavior you want. Customer support conversations, code generation pairs, domain-specific Q&A—anything where you can show the model what good looks like.\n\n```\nFine-tune Qwen3-0.6B on my-org/support-conversations for 3 epochs.\n```\n\nThe agent validates the dataset, selects hardware (a10g-large with LoRA for a 7B model), and configures training with checkpoints and monitoring.\n\n> For models larger than 3B parameters, the agent automatically uses LoRA (Low-Rank Adaptation) to reduce memory requirements. This makes training 7B or 13B models feasible on single GPUs while preserving most of the quality of full fine-tuning.\n\n### Direct Preference Optimization (DPO)\n\nDPO trains on preference pairs—responses where one is \"chosen\" and another is \"rejected.\" This aligns model outputs with human preferences, typically after an initial SFT stage.\n\nUse DPO when you have preference annotations from human labelers or automated comparisons. DPO optimizes directly for the preferred response without needing a separate reward model.\n\n```\nRun DPO on my-org/preference-data to align the SFT model I just trained.\nThe dataset has 'chosen' and 'rejected' columns.\n```\n\n> DPO is sensitive to dataset format. It requires columns named exactly `chosen` and `rejected`, or a `prompt` column with the input. The agent validates this first and shows you how to map columns if your dataset uses different names.\n\n> You can run DPO using Skills on vision language models too! Try it out with [openbmb/RLAIF-V-Dataset](http://hf.co/datasets/openbmb/RLAIF-V-Dataset). Claude will apply minor modifications but will succeed in training.\n\n### Group Relative Policy Optimization (GRPO)\n\nGRPO is a reinforcement learning task that is proven to be effective on verifiable tasks like solving math problems, writing code, or any task with a programmatic success criterion.\n\n```\nTrain a math reasoning model using GRPO on the openai/gsm8k dataset based on Qwen3-0.6B.\n```\n\nThe model generates responses, receives rewards based on correctness, and learns from the outcomes. This is more complex than SFT or DPO, but the configuration is similar.\n\n## Hardware and Cost\n\nThe agent selects hardware based on your model size, but understanding the tradeoffs helps you make better decisions.\n\n### Model Size to GPU Mapping\n\nFor **tiny models under 1B parameters**, `t4-small` works well. These models train quickly—expect $1-2 for a full run. This is perfect for educational or experimental runs.\n\nFor **small models (1-3B)**, step up to `t4-medium` or `a10g-small`. Training takes a few hours and costs $5-15.\n\nFor **medium models (3-7B)**, you need `a10g-large` or `a100-large` with LoRA. Full fine-tuning doesn't fit, but LoRA makes these very trainable. Budget $15-40 for production.\n\nFor **large models (7B+)**, this HF skills job is not suitable.\n\n### Demo vs Production\n\nWhen testing a workflow, start small:\n\n```\nDo a quick test run to SFT Qwen-0.6B with 100 examples of my-org/support-conversations.\n```\n\nThe coding agent configures minimal training—enough to verify your pipeline works without real cost.\n\nFor production, be explicit:\n\n```\nSFT Qwen-0.6B for production on the full my-org/support-conversations.\nCheckpoints every 500 steps, 3 epochs, cosine learning rate.\n```\n\n> Always run a demo before committing to a multi-hour production job. A $0.50 demo that catches a format error saves a $30 failed run.\n\n## Dataset Validation\n\nDataset format is the most common source of training failures. The agent can validate datasets before you spend GPU time.\n\n```\nCheck if my-org/conversation-data works for SFT training.\n```\n\nThe agent runs a quick inspection on CPU (fractions of a penny) and reports:\n\n```\nDataset validation for my-org/conversation-data:\n\nSFT: ✓ READY\n  Found 'messages' column with conversation format\n\nDPO: ✗ INCOMPATIBLE\n  Missing 'chosen' and 'rejected' columns\n```\n\nIf your dataset needs transformation, the agent can show you how:\n\n```\nMy DPO dataset uses 'good_response' and 'bad_response' instead\nof 'chosen' and 'rejected'. How do I fix this?\n```\n\nThe agent provides mapping code and can incorporate it directly into your training script.\n\n## Monitoring Training\n\nReal-time monitoring helps you catch problems early. The skill configures Trackio by default—after submitting a job, you can watch metrics at:\n\n```\nhttps://huggingface.co/spaces/username/trackio\n```\n\nThis shows training loss, learning rate, and validation metrics. A healthy run shows steadily decreasing loss.\n\nAsk the agent about status anytime:\n\n```\nWhat's the status of my training job?\n```\n\n```\nJob abc123xyz is running (45 minutes elapsed)\n\nCurrent step: 850/1200\nTraining loss: 1.23 (↓ from 2.41 at start)\nLearning rate: 1.2e-5\n\nEstimated completion: ~20 minutes\n```\n\nIf something goes wrong, the agent helps diagnose. Out of memory? the agent suggests reducing batch size or upgrading hardware. Dataset error? The agent identifies the mismatch. Timeout? The agent recommends longer duration or faster training settings.\n\n## Converting to GGUF\n\nAfter training, you might want to run your model locally. The GGUF format works with llama.cpp and dependent tools like LM Studio, Ollama, etc.\n\n```\nConvert my fine-tuned model to GGUF with Q4_K_M quantization.\nPush to username/my-model-gguf.\n```\n\nThe agent submits a conversion job that merges LoRA adapters, converts to GGUF, applies quantization, and pushes to Hub.\n\nThen use it locally:\n\n```bash\nllama-server -hf <username>/<model-name>:<quantization>\n\n# For example, to run the Qwen3-1.7B-GGUF model on your local machine:\nllama-server -hf unsloth/Qwen3-1.7B-GGUF:Q4_K_M\n```\n\n## What's Next\n\nWe've shown that coding agents like Claude Code, Codex, or Gemini CLI can handle the full lifecycle of model fine-tuning: validating data, selecting hardware, generating scripts, submitting jobs, monitoring progress, and converting outputs. This turns what used to be a specialized skill into something you can do through conversation.\n\nSome things to try:\n\n- Fine-tune a model on your own dataset\n- Build a preference-aligned model with SFT → DPO\n- Train a reasoning model with GRPO on math or code\n- Convert a model to GGUF and run it with Ollama\n\nThe [skill is open source](https://hf-learn.short.gy/gh-hf-skills). You can extend it, customize it for your workflows, or use it as a starting point for other training scenarios.\n\n* * *\n\n## Resources\n\n- [SKILL.md](https://github.com/huggingface/skills/blob/main/hf-llm-trainer/skills/model-trainer/SKILL.md) — Full skill documentation\n- [Training Methods](https://github.com/huggingface/skills/blob/main/hf-llm-trainer/skills/model-trainer/references/training_methods.md) — SFT, DPO, GRPO explained\n- [Hardware Guide](https://github.com/huggingface/skills/blob/main/hf-llm-trainer/skills/model-trainer/references/hardware_guide.md) — GPU selection and costs\n- [TRL Documentation](https://huggingface.co/docs/trl) — The underlying training library\n- [Hugging Face Jobs](https://huggingface.co/docs/huggingface_hub/guides/jobs) — Cloud training infrastructure\n- [Trackio](https://huggingface.co/docs/trackio) — Real-time training monitoring\n",
  "dateCreated": "2026-10-04T12:50:30.804479567+00:00",
  "date_created": "2025-12-04T00:00:00+00:00",
  "date_modified": "2025-12-04T00:00:00+00:00",
  "date_published": "2025-12-04T00:00:00+00:00",
  "description": "We gave Claude the ability to fine-tune language models using a new tool called Hugging Face Skills. Not just write training scripts, but to actually submit jobs to cloud GPUs, monitor progress, and push finished models to the Hugging Face…",
  "external_url": "https://huggingface.co/blog/hf-skills-training",
  "git": {
    "commit": "ebb0941c5c06a2ab2377342d607535262a3e969e",
    "path": "items/huggingface-co/2025/12/2025-12-04-we-got-claude-to-fine-tune-an-open-source-llm.md",
    "permalink": "https://github.com/aymericbeaumet/aggr-instance/blob/ebb0941c5c06a2ab2377342d607535262a3e969e/items/huggingface-co/2025/12/2025-12-04-we-got-claude-to-fine-tune-an-open-source-llm.md"
  },
  "id": "urn:aggr:item:472c3c6a3315530201b3560e69f6df72f3c00e2c",
  "isBasedOn": {
    "@id": "https://huggingface.co/blog/hf-skills-training"
  },
  "mainEntity": {
    "@id": "https://huggingface.co/blog/hf-skills-training",
    "@type": "CreativeWork",
    "archivedAt": {
      "@id": "https://aggr.aymericbeaumet.com/items/huggingface-co/2025-12-04-we-got-claude-to-fine-tune-an-open-source-llm/#webpage"
    },
    "dateModified": "2025-12-04T00:00:00+00:00",
    "datePublished": "2025-12-04T00:00:00+00:00",
    "headline": "We Got Claude to Fine-Tune an Open Source LLM",
    "timeRequired": "PT9M",
    "url": "https://huggingface.co/blog/hf-skills-training",
    "wordCount": 1986
  },
  "name": "Archived snapshot: We Got Claude to Fine-Tune an Open Source LLM",
  "preview": null,
  "reading_minutes": 9,
  "replicated_at": null,
  "source": "huggingface-co",
  "source_name": "Hugging Face - Blog",
  "summary": null,
  "tags": [],
  "temporalCoverage": "2026-10-04T12:50:30.804479567+00:00",
  "title": "We Got Claude to Fine-Tune an Open Source LLM",
  "url": "https://aggr.aymericbeaumet.com/items/huggingface-co/2025-12-04-we-got-claude-to-fine-tune-an-open-source-llm/",
  "word_count": 1986
}