Introduction¶
Fine-tuning language models often implies bringing your own GPU, setting up environments, writing training scripts, and handling artifact persistence and monitoring. If you simply want to describe the data, base model, and training objectives in a conversation, letting an Agent submit cloud tasks according to specifications and push weights to the Hub requires a standardized workflow aligned with Hugging Face Jobs, TRL documentation, and cost estimation scripts. Below is an introduction to the huggingface-llm-trainer Skill from the official Hugging Face repository: it embeds training methods like SFT, DPO, and GRPO, hardware and timeout configurations, Hub authentication, and Trackio monitoring into SKILL.md, allowing clients like Cursor, Claude Code, and Codex to execute under a unified set of rules in “Cloud GPU Fine-tuning” scenarios.
What is this¶
huggingface-llm-trainer is a workflow Skill in the Hugging Face Skills repository, following the Agent Skills standard: the directory contains SKILL.md (YAML frontmatter + operational guidelines), example scripts, and reference documentation.
The official description summarizes it as: Train or fine-tune language and vision models using TRL (Transformer Reinforcement Learning) or Unsloth on Hugging Face Jobs hosted infrastructure; cover SFT, DPO, GRPO, Reward Modeling, and include GGUF conversion to support local deployment (Ollama, LM Studio, llama.cpp, etc.). The Skill also involves guidelines for the TRL Jobs package, UV scripts in PEP 723 format, dataset preparation and validation, hardware selection, cost estimation, Trackio monitoring, Hub authentication, model selection, and persistence.
Unlike hf-cli, which only provides Hub CLI capabilities, this Skill focuses on the complete chain of “Submit Training Job → Monitor → Push to Hub”; officially, it is recommended to install hf-cli first and then add this Skill as needed.
Core Features¶
Training Methods and Documentation Entries¶
TRL-side supported methods include:
- SFT (Supervised Fine-Tuning): Instruction fine-tuning
- DPO (Direct Preference Optimization): Preference data alignment
- GRPO (Group Relative Policy Optimization): Online RL training
- Reward Modeling: Training reward models for RLHF
For method overviews and selection, refer to references/training_methods.md within the Skill; detailed APIs can be searched/fetched via documentation (the example in the Skill uses hf_doc_search, hf_doc_fetch pointing to TRL documentation URLs).
Division of Labor between TRL and Unsloth¶
The default path is training with standard TRL on Jobs. The Skill guides switching to Unsloth (see references/unsloth.md, example script scripts/unsloth_sft_example.py) in the following cases:
- GPU VRAM is tight (materials state Unsloth uses approximately 60% less VRAM)
- Higher priority on training speed (materials state approximately 2x magnitude)
- Large models (>13B) or Vision Language Models (VLM) (Unsloth provides
FastVisionModel)
Key Constraints for Agent Execution¶
The Skill has mandatory requirements for Agents assisting with training tasks (different from manually typing trl-jobs locally):
- Always submit via the
hf_jobs()MCP tool, e.g.,hf_jobs("uv", {...}); thescriptparameter can take a Python code string directly. Unless the user explicitly requests otherwise, do not write to a local file first. - Every training script should include Trackio for real-time monitoring; use examples under
scripts/as templates. - After submission, provide the user with the Job ID, monitoring URL, and estimated duration; training runs asynchronously in the background, do not auto-poll, wait for the user to ask before checking status or logs.
- Example templates include
scripts/train_sft_example.py,scripts/train_dpo_example.py, etc.
Local Helper Scripts (Not the Job itself)¶
Scripts in the repository use PEP 723 inline dependencies and can be run with uv run for cost estimation, dataset checking, etc. Examples:
uv run scripts/estimate_cost.py --help
uv run scripts/dataset_inspector.py --help
Sequence Length Configuration¶
TRL configuration classes use max_length (not max_seq_length) to control sequence length after tokenization; the default is mostly 1024. In vision model scenarios, max_length=None can be set to avoid truncating image tokens.
Installation and Activation¶
Hugging Face Skills is compatible with Claude Code, Codex, Gemini CLI, Cursor, etc. The general installation approach: first have Hub capabilities and MCP (the repository provides .cursor-plugin/plugin.json and .mcp.json for Cursor), then install specific workflow Skills.
Claude Code (excerpt from official README):
/plugin marketplace add huggingface/skills
/plugin install hf-cli@huggingface/skills
hf skills add <skill-name>
For this Skill, replace <skill-name> with huggingface-llm-trainer (whether it is indexed by the CLI depends on your local hf skills output).
Cursor: Install hf-cli from the Hugging Face entry in Cursor Marketplace, then add this Skill via hf skills add huggingface-llm-trainer.
Codex: Copy or symlink skills/huggingface-llm-trainer to the .agents/skills path agreed upon by Codex, allowing the client to discover SKILL.md according to the Agent Skills standard.
Once enabled, when the user mentions training on Hugging Face Jobs, Cloud GPU fine-tuning, GGUF conversion, etc., the Agent should load this Skill and operate according to the processes within it.
Typical Usage¶
Recommended Path: UV Scripts + hf_jobs("uv", ...)¶
The Skill treats PEP 723 inline-dependent UV scripts as the default method for environments like Claude Code: dependencies are written in the # /// script block at the head of the script, and the whole script is passed as a string to hf_jobs(). The conceptual structure is as follows (field names and dependency versions are subject to the complete examples within the Skill):
hf_jobs("uv", {
"script": """
# /// script
# dependencies = ["trl>=0.12.0", "peft>=0.7.0", "trackio"]
# ///
from datasets import load_dataset
from peft import LoraConfig
from trl import SFTTrainer, SFTConfig
import trackio
dataset = load_dataset("trl-lib/Capybara", split="train")
# ... Configure LoRA, SFTConfig, push_to_hub, Trackio, etc. ...
""",
# Job-level configs like hardware, timeout, secrets refer to the full SKILL.md text
})
When the user says “fine-tune a model,” the Skill requires the Agent to write a script containing Trackio and submit it immediately, rather than just providing local run instructions.
Feedback Format After Submission¶
The Skill provides key points for the reply after successful submission, for example:
Job ID: abc123xyz
Monitor: https://huggingface.co/jobs/username/abc123xyz
Expected time: ~2 hours
Estimated cost: ~$10
And prompts the user that they can later ask to check status or logs; initial logs may have a 30–60 second delay.
Pre-training Checklist¶
Account and Authentication
- Hugging Face account needs to be Pro, Team, or Enterprise (Jobs require a paid plan).
- Use
hf_whoami()to confirm logged in. - The training environment is temporary, must push to Hub, otherwise results will be lost; Token needs write permission and must be passed in Job configuration, e.g.,
secrets={"HF_TOKEN": "$HF_TOKEN"}($HF_TOKENrefers to the actual token value in your environment).
Dataset
- Data needs to be on the Hub or loadable via
datasets.load_dataset(). - Format needs to match the method: SFT commonly uses messages/text/prompt-completion; DPO needs chosen/rejected; GRPO is prompt-only.
- For unknown datasets, use the validation process first (there is a Dataset Validation chapter in the Skill) to avoid format errors on GPU.
- Scale reference: Demo can use about 50–100 entries on t4-small; production-oriented training commonly uses 1K–10K+, hardware like a10g-large/a100-large.
Key Job Parameters
- timeout must be greater than the expected training time; materials point out the default 30 minutes is too short for most training, suggesting at least 1–2 hours, timeout will cause Job failure and progress loss.
- Enable Hub push in training config:
push_to_hub=True,hub_model_id="username/model-name", and combine with the aforementionedHF_TOKENsecret.
Small VRAM demos can omit eval_dataset and eval_strategy on t4-small to save about 40% VRAM while still seeing training loss.
Applicable Scenarios and Notes¶
Suitable for
- No local GPU, or don’t want to maintain training clusters, hope to run TRL/Unsloth fine-tuning on Hugging Face Jobs.
- Need TRL capabilities like SFT, DPO, GRPO, reward models, and want weights automatically pushed to Hugging Face Hub.
- After training, need GGUF for local inference in environments like Ollama, LM Studio, llama.cpp.
- Use coding Agents supporting Skills and Hugging Face MCP, letting the Agent submit
hf_jobs()according to the Skill rather than scattered commands.
Limitations and Pitfalls
- Jobs depend on paid Hub plans; missing HF_TOKEN config or not
push_to_hubwill cause training artifacts loss. - Training is a long-running asynchronous task; Agents should not high-frequency poll without authorization, should provide monitoring links and Trackio panels.
- Sequence length parameter name is error-prone: use
SFTConfig(max_length=512), do not use the non-existentmax_seq_length. - For large models or VLMs with tight VRAM, prioritize the Unsloth path and hardware/cost scripts in the Skill.
Conclusion¶
huggingface-llm-trainer solidifies Hugging Face’s official Jobs training practices (TRL/Unsloth, dataset validation, Hub persistence, Trackio, GGUF) into an Agent-executable Skill, suitable for initiating cloud fine-tuning directly in conversations and obtaining trackable Jobs and Hub models.
Official Skill directory and description:
https://github.com/huggingface/skills/tree/main/skills/huggingface-llm-trainer
Parent repository installation and client instructions:
https://github.com/huggingface/skills