hugging-face-model-trainer
Train or fine-tune language and vision models using TRL (Transformer Reinforcement Learning) or Unsloth with Hugging Face Jobs infrastructure. Cover…
它会碰到什么
逐条看命中(14 条严重或高危)
- 高
scripts/convert_to_gguf.py:58exec-spawnif subprocess.run(["which", "git"], capture_output=True).returncode != 0:
- 高
scripts/convert_to_gguf.py:66exec-spawnhas_make = subprocess.run(["which", "make"], capture_output=True).returncode == 0
- 高
scripts/convert_to_gguf.py:67exec-spawnhas_cmake = subprocess.run(["which", "cmake"], capture_output=True).returncode == 0
- 高
scripts/convert_to_gguf.py:84exec-spawnresult = subprocess.run(
- 高
scripts/convert_to_gguf.py:128cred-envreadreturn os.environ.get(name, "").strip().lower() in {"1", "true", "yes", "on"} - 高
scripts/convert_to_gguf.py:148cred-envreadADAPTER_MODEL = os.environ.get("ADAPTER_MODEL", "evalstate/qwen-capybara-medium") - 高
scripts/convert_to_gguf.py:149cred-envreadBASE_MODEL = os.environ.get("BASE_MODEL", "Qwen/Qwen2.5-0.5B") - 高
scripts/convert_to_gguf.py:150cred-envreadOUTPUT_REPO = os.environ.get("OUTPUT_REPO", "evalstate/qwen-capybara-medium-gguf") - 高
scripts/convert_to_gguf.py:151cred-envreadusername = os.environ.get("HF_USERNAME", ADAPTER_MODEL.split('/')[0]) - 高
scripts/hf_benchmarks.py:122cred-envreadtoken = os.getenv("HF_TOKEN") - 高
scripts/unsloth_sft_example.py:251cred-envreados.environ["HF_HUB_ENABLE_HF_TRANSFER"] = "1"
- 高
scripts/unsloth_sft_example.py:255cred-envreados.environ["TRACKIO_SPACE_ID"] = args.trackio_space
- 高
scripts/unsloth_sft_example.py:266cred-envreadtoken = os.environ.get("HF_TOKEN") or os.environ.get("hfjob") - 高
scripts/unsloth_sft_example.py:266cred-envreadtoken = os.environ.get("HF_TOKEN") or os.environ.get("hfjob")
这一栏是扫描器报的事实,不是结论。命中多不等于有毒(安全工具、规则库、示例脚本本来就会包含危险写法),命中少也不等于干净。它和你手上的凭据、文件、网络有什么关系,需要你自己看。
技能内容
TRL Training on Hugging Face Jobs
Detailed Guide
Read [the detailed guide](references/detailed-guide.md) 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
FastVisionModelsupport
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_TOKENsyntax
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, checkpointsscripts/train_dpo_example.py- DPO training for preference learningscripts/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.
想直接用这个技能?
本站把开放许可(MIT / Apache 等)的技能按仓库打包整理到网盘,点一下转存到你自己的网盘,不用一个个从 GitHub 拉。许可未声明的技能只给原始仓库链接,不打包。
它属于哪个仓库
plugins/agentic-awesome-skills-claude/skills/hugging-face-model-trainer/SKILL.md同一个仓库里的其他技能
同名技能的其他版本
有 3 个不同仓库或目录里都有叫 hugging-face-model-trainer 的技能。它们内容并不相同,别混用:
- sickn33/agentic-awesome-skills — Train or fine-tune language and vision models using TRL (Transformer Reinforcement Learnin
- sickn33/agentic-awesome-skills — Train or fine-tune language and vision models using TRL (Transformer Reinforcement Learnin