Hugging Face Skills: Enabling AI Agents to Fine-Tune LLMs
Hugging Face has released Hugging Face Skills, a framework that enables coding agents—such as Claude Code, OpenAI Codex, and Google Gemini CLI—to autonomously manage the end-to-end process of fine-tuning large language models (LLMs). Instead of merely writing scripts, these agents can now validate datasets, select cloud GPUs, submit training jobs, monitor progress via Trackio, and push the final models to the Hugging Face Hub.
Autonomous Fine-Tuning Workflow
Coding agents equipped with the hf-llm-trainer skill can execute the full training lifecycle through natural language instructions. For example, a request to fine-tune a specific model on a dataset triggers a multi-step autonomous process:
- Dataset Validation: The agent inspects the dataset format on a CPU to ensure compatibility with the chosen training method before consuming GPU credits.
- Hardware Selection: The agent maps the model size to the most cost-effective GPU (e.g., selecting
t4-smallfor a 0.6B parameter model). - Job Submission: The agent generates and updates the training script, submits the job to Hugging Face Jobs, and provides the user with a job ID and estimated cost.
- Monitoring and Debugging: Using Trackio integration, the agent can report real-time metrics like training loss and learning rate. If errors occur, such as Out-of-Memory (OOM) issues, the agent suggests reducing batch sizes or upgrading hardware.
- Deployment: Once complete, the model is automatically pushed to the Hugging Face Hub.
Supported Training Methods
The framework supports three primary production-grade training methodologies:
Supervised Fine-Tuning (SFT)
SFT is used to train models on high-quality demonstration data (input-output pairs). For models larger than 3B parameters, the agent automatically employs LoRA (Low-Rank Adaptation) to reduce memory requirements, making 7B or 13B models trainable on single GPUs.
Direct Preference Optimization (DPO)
DPO aligns model outputs with human preferences using preference pairs (chosen vs. rejected responses). The agent validates that the dataset contains the necessary chosen and rejected columns (or a prompt column) and can provide mapping code if the dataset uses different naming conventions.
Group Relative Policy Optimization (GRPO)
GRPO is a reinforcement learning technique optimized for verifiable tasks with programmatic success criteria, such as mathematics or coding problems (e.g., training on the openai/gsm8k dataset).
Hardware Mapping and Cost Efficiency
To optimize costs, the agent follows a specific GPU mapping based on model size:
| Model Size | Recommended GPU | Estimated Cost | Use Case |
|---|---|---|---|
| Under 1B | t4-small |
$1-2 | Educational/Experimental |
| 1B - 3B | t4-medium or a10g-small |
$5-15 | Small-scale tuning |
| 3B - 7B | a10g-large or a100-large (with LoRA) |
$15-40 | Production tuning |
For models exceeding 7B parameters, the current HF skills job implementation is not suitable.
Local Deployment and GGUF Conversion
Beyond training, the agent can handle the conversion of fine-tuned models into the GGUF format for local execution via tools like llama.cpp, Ollama, or LM Studio. This process includes merging LoRA adapters, applying quantization (e.g., Q4_K_M), and pushing the quantized version back to the Hub.
Setup and Compatibility
Using these skills requires a Hugging Face account with a Pro, Team, or Enterprise plan to access Jobs. The skills are currently compatible with:
- Claude Code: Installed via
/plugin marketplace add huggingface/skills. - OpenAI Codex: Identified via the
AGENTS.mdfile. - Gemini CLI: Installed via
gemini extensions install.
Integrations for Cursor, Windsurf, and Continue are currently in development.