跳到主要内容
知仓学习社ZHICANG

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…

执行命令读凭据联网严重 0 · 高危 14sickn33/agentic-awesome-skills

它会碰到什么

扫了多少20 个文本文件,184 KB
它会碰到什么执行命令读凭据联网
命中总数38 处
命中统计严重 0 · 高 14 · 中 8 · 低 2
逐条看命中(14 条严重或高危)
  • scripts/convert_to_gguf.py:58exec-spawn
    if subprocess.run(["which", "git"], capture_output=True).returncode != 0:
  • scripts/convert_to_gguf.py:66exec-spawn
    has_make = subprocess.run(["which", "make"], capture_output=True).returncode == 0
  • scripts/convert_to_gguf.py:67exec-spawn
    has_cmake = subprocess.run(["which", "cmake"], capture_output=True).returncode == 0
  • scripts/convert_to_gguf.py:84exec-spawn
    result = subprocess.run(
  • scripts/convert_to_gguf.py:128cred-envread
    return os.environ.get(name, "").strip().lower() in {"1", "true", "yes", "on"}
  • scripts/convert_to_gguf.py:148cred-envread
    ADAPTER_MODEL = os.environ.get("ADAPTER_MODEL", "evalstate/qwen-capybara-medium")
  • scripts/convert_to_gguf.py:149cred-envread
    BASE_MODEL = os.environ.get("BASE_MODEL", "Qwen/Qwen2.5-0.5B")
  • scripts/convert_to_gguf.py:150cred-envread
    OUTPUT_REPO = os.environ.get("OUTPUT_REPO", "evalstate/qwen-capybara-medium-gguf")
  • scripts/convert_to_gguf.py:151cred-envread
    username = os.environ.get("HF_USERNAME", ADAPTER_MODEL.split('/')[0])
  • scripts/hf_benchmarks.py:122cred-envread
    token = os.getenv("HF_TOKEN")
  • scripts/unsloth_sft_example.py:251cred-envread
    os.environ["HF_HUB_ENABLE_HF_TRANSFER"] = "1"
  • scripts/unsloth_sft_example.py:255cred-envread
    os.environ["TRACKIO_SPACE_ID"] = args.trackio_space
  • scripts/unsloth_sft_example.py:266cred-envread
    token = os.environ.get("HF_TOKEN") or os.environ.get("hfjob")
  • scripts/unsloth_sft_example.py:266cred-envread
    token = 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 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.

想直接用这个技能?

本站把开放许可(MIT / Apache 等)的技能按仓库打包整理到网盘,点一下转存到你自己的网盘,不用一个个从 GitHub 拉。许可未声明的技能只给原始仓库链接,不打包。

它属于哪个仓库

星标★ 46,490
本站分层T1
该仓技能数6676
原文件路径plugins/agentic-awesome-skills-claude/skills/hugging-face-model-trainer/SKILL.md

同一个仓库里的其他技能

看这个仓库的全部 6676 个技能

同名技能的其他版本

有 3 个不同仓库或目录里都有叫 hugging-face-model-trainer 的技能。它们内容并不相同,别混用: