跳到正文
Skillpedia
智能体48k · #4839

hugging-face-model-trainer

它能做什么

这个智能体可以训练或微调用于理解语言和图像的 AI 模型。它借助先进的工具来提升模型效果,并能把模型整理成可以在你自己电脑上使用的格式。

适用场景

  • ✓你想改进 AI 模型,但手边没有性能强大的电脑时。
  • ✓想使用 SFT、DPO 或 GRPO 等特定方法来训练模型时。
  • ✓想把训练好的模型转换成可以在 Ollama 等工具中本地运行的格式时。

技能链接

https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/hugging-face-model-trainer/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/hugging-face-model-trainer/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“训练一个能回答烹饪问题的语言模型,使用 SFT 方法训练,并将其保存为 'my-cooking-model'。”

每周 5 个新技能,1 分钟读完。

工作原理

你提供数据并选择训练方法。智能体会在配备强大 GPU 的 Hugging Face 服务器上完成繁重的计算工作。训练结束后,它还可以帮你转换模型格式,方便你在任何地方使用。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

TRL Training on Hugging Face Jobs

Detailed Guide

Read the detailed guide before executing this skill. It retains the complete procedure and reference material. Treat its safety, prerequisites, and validation requirements as mandatory. For focused work, load the relevant sections; for end-to-end work, read the guide completely.

When to Use This Skill

Use this skill when users want to:

  • Fine-tune language models on cloud GPUs without local infrastructure
  • Train with TRL methods (SFT, DPO, GRPO, etc.)
  • Run training jobs on Hugging Face Jobs infrastructure
  • Convert trained models to GGUF for local deployment (Ollama, LM Studio, llama.cpp)
  • Ensure trained models are permanently saved to the Hub
  • Use modern workflows with optimized defaults

When to Use Unsloth

Use Unsloth (references/unsloth.md) instead of standard TRL when:

  • Limited GPU memory - Unsloth uses ~60% less VRAM
  • Speed matters - Unsloth is ~2x faster
  • Training large models (>13B) - memory efficiency is critical
  • Training Vision-Language Models (VLMs) - Unsloth has FastVisionModel support

See references/unsloth.md for complete Unsloth documentation and scripts/unsloth_sft_example.py for a production-ready training script.

Prerequisites Checklist

Before starting any training job, verify:

✅ Account & Authentication

  • Hugging Face Account with Pro, Team, or Enterprise plan (Jobs require paid plan)
  • Authenticated login: Check with hf_whoami()
  • HF_TOKEN for Hub Push ⚠️ CRITICAL - Training environment is ephemeral, must push to Hub or ALL training results are lost
  • Token must have write permissions
  • MUST pass secrets={"HF_TOKEN": "$HF_TOKEN"} in job config to make token available (the $HF_TOKEN syntax references your actual token value)

✅ Dataset Requirements

  • Dataset must exist on Hub or be loadable via datasets.load_dataset()
  • Format must match training method (SFT: "messages"/text/prompt-completion; DPO: chosen/rejected; GRPO: prompt-only)
  • ALWAYS validate unknown datasets before GPU training to prevent format failures (see Dataset Validation section below)
  • Size appropriate for hardware (Demo: 50-100 examples on t4-small; Production: 1K-10K+ on a10g-large/a100-large)

⚠️ Critical Settings

  • Timeout must exceed expected training time - Default 30min is TOO SHORT for most training. Minimum recommended: 1-2 hours. Job fails and loses all progress if timeout is exceeded.
  • Hub push must be enabled - Config: push_to_hub=True, hub_model_id="username/model-name"; Job: secrets={"HF_TOKEN": "$HF_TOKEN"}

Example Training Scripts

Production-ready templates with all best practices:

Load these scripts for correctly:

  • scripts/train_sft_example.py - Complete SFT training with Trackio, LoRA, checkpoints
  • scripts/train_dpo_example.py - DPO training for preference learning
  • scripts/train_grpo_example.py - GRPO training for online RL

These scripts demonstrate proper Hub saving, Trackio integration, checkpoint management, and optimized parameters. Pass their content inline to hf_jobs() or use as templates for custom scripts.

Limitations

  • Use this skill only when the task clearly matches its upstream product or API scope.
  • Verify commands, API behavior, pricing, quotas, credentials, and deployment effects against current official documentation before making changes.
  • Do not treat generated examples as a substitute for environment-specific tests, security review, or user approval for destructive or costly actions.
常见问题

使用这个智能体需要付费吗?

需要。用于训练的 Hugging Face Jobs 要求你拥有付费套餐(Pro、Team 或 Enterprise)。

“微调”(fine-tune)是什么意思?

就像教一个已经掌握大量语言知识的 AI 模型,让它专精于某个特定领域,比如烹饪或医学。

什么是 GGUF?

GGUF 是一种特殊的模型格式,可以让训练好的 AI 模型借助 Ollama 或 LM Studio 等程序,在普通电脑上高效运行。

详情

作者的原始描述

Train or fine-tune language and vision models using TRL (Transformer Reinforcement Learning) or Unsloth with Hugging Face Jobs infrastructure. Covers SFT, DPO, GRPO and reward modeling training methods, plus GGUF conversion for local deployment.

repo: sickn33/agentic-awesome-skills

热度

GitHub 星标
48k
排名
#4839
许可证
MIT
更新时间
2026/10/15

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能