Trains Hugging Face TRL jobs: trl sft/dpo/grpo/kto/rloo/reward, YAML configs, LoRA/PEFT, and Accelerate multi-GPU. Use when fine-tuning or aligning transformer LMs with TRL CLI. Not for vLLM OpenAI serving, local Hub evals (hugging-face-community-evals), or sentence-transformers embedding training.
Standardmäßig ist der Prompt ausgewählt, der zuerst die Quelle prüft. Sie können zu einem direkten Befehl wechseln oder eine lokale Kopie herunterladen.
Quelldateien prüfen
Lesen Sie SKILL.md und alle von SkillsMP angezeigten Begleitdateien, bevor Sie sich für eine Installation entscheiden.
Mit Codex oder Claude installieren Kopieren Sie diesen Prompt, fügen Sie ihn in Codex, Claude oder einen anderen Assistant ein und lassen Sie die Skill-Seite prüfen und installieren.
Ein direkter Befehl überspringt den Prüf-Prompt. Prüfen Sie die Quelle, bevor Sie ihn ausführen.
Trains Hugging Face TRL jobs: trl sft/dpo/grpo/kto/rloo/reward, YAML configs, LoRA/PEFT, and Accelerate multi-GPU. Use when fine-tuning or aligning transformer LMs with TRL CLI. Not for vLLM OpenAI serving, local Hub evals (hugging-face-community-evals), or sentence-transformers embedding training.
Use this skill when the user needs to train or fine-tune transformer language models using the TRL (Transformers Reinforcement Learning) library. Trigger keywords and scenarios:
SFT — supervised fine-tuning on instruction-following or conversational datasets
DPO — direct preference optimization with chosen/rejected pairs
GRPO — group relative policy optimization with reward functions or LLM-as-a-judge
KTO — Kahneman-Tversky optimization (use trl kto CLI)
RLOO — REINFORCE Leave-One-Out online RL with generation-based rewards
Reward Model — training a reward model for RLHF
Configuration via YAML, distributed training with Accelerate, LoRA/PEFT adapters, or troubleshooting TRL training runs
You are an expert at using the TRL library to train and fine-tune large language models.
Prerequisites
Install TRL (requires Python ≥ 3.9, PyTorch, and Hugging Face Transformers):
pip install trl
Authenticate with Hugging Face Hub (needed for gated models, pushing to hub, or private datasets):
hf auth login
Use a token placeholder such as YOUR_HF_TOKEN — never commit real tokens.
Verify GPU availability (training expects CUDA; CPU-only is impractical for all but tiny models):
Multi-line backslash-continuation commands shown below are bash syntax. In PowerShell, use backtick (`) as the line-continuation character, or run the command as a single line.
For YAML config files, use forward slashes or escaped backslashes in paths.
Accelerate config default path on Windows: ~/.cache/huggingface/accelerate/default_config.yaml
Procedure
1. Choose the training method
Goal
Command
Typical dataset schema
Instruction / chat fine-tuning
trl sft
prompt + completion or conversational
Preference alignment
trl dpo
prompt, chosen, rejected
RL with reward functions
trl grpo
prompt (+ reward function)
Online RL with reward model
trl rloo
prompt (+ reward model)
Train a reward model
trl reward
chosen, rejected
Best practice: Always SFT a base model before preference alignment (DPO/GRPO/RLOO).