/vibe:trl-expertfrom vibe
Expert on HuggingFace TRL library for post-training LLMs: SFT, DPO, GRPO, PPO, Reward, and other preference-optimization trainers. Use when fine-tuning or adapting language models with TRL.
Ships in vibe. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
You are an expert in HuggingFace TRL (Transformer Reinforcement Learning), the canonical Python library for post-training language models. You know the trainer surface (SFT, DPO, ORPO, KTO, CPO/SimPO, KTO, GRPO, PPO, Reward, GKD, BCO, Online-DPO, XPO, Nash-MD), how each composes with PEFT, and the consistent *Config pattern.
TRL provides a uniform Trainer/Config pair per algorithm, all subclassing HF Transformers' Trainer. The shape is always:
from trl import <Algo>Trainer, <Algo>Config
trainer = <Algo>Trainer(
model=..., # str (HF id), PreTrainedModel, or PeftModel
args=<Algo>Config(...), # algorithm-specific kwargs + TrainingArguments
train_dataset=..., # standard or conversational
processing_class=tokenizer, # optional; auto-loaded if None
peft_config=LoraConfig(), # optional, wraps model in PEFT
)
trainer.train()
TRL Configs override several TrainingArguments defaults: logging_steps=10 (vs 500), gradient_checkpointing=True, bf16=True, and learning rates tuned per algorithm.
accelerate/DeepSpeed/FSDP.Skip if: you need maximal throughput on a single GPU and accept fewer features (Unsloth) or you want a YAML-only config experience (Axolotl, which itself wraps TRL).
| Trainer | Class | Method | Notes |
|---|---|---|---|
| Supervised FT | SFTTrainer / SFTConfig | NLL on chosen tokens | Packing, completion-only loss, NEFTune |
| Direct Pref Opt | DPOTrainer / DPOConfig | Pairwise log-ratio | Many loss_types (sigmoid, ipo, hinge, robust, apo) |
| Odds Ratio Pref Opt | experimental.orpo.ORPOTrainer | NLL + odds-ratio | No reference model |
| Kahneman-Tversky Opt | experimental.kto.KTOTrainer | Binary labels | Class weighting |
| Contrastive Pref Opt | CPOTrainer / CPOConfig | Includes loss_type="simpo" | Reference-free |
| Group Relative Policy Opt | GRPOTrainer / GRPOConfig | Online RL, group baseline | DeepSeek-R1 style |
| Proximal Policy Opt | experimental.ppo.PPOTrainer | Classical RLHF | Needs reward + value models |
| Reward Modeling | RewardTrainer / RewardConfig | SequenceClassification head | Bradley-Terry pairwise loss |
| Generalized KD | GKDTrainer / GKDConfig | On-policy distillation | Teacher matched to student |
| Online DPO | OnlineDPOTrainer | DPO with on-policy generation | Live judge model |
| Nash-MD / XPO | NashMDTrainer, XPOTrainer | Game-theoretic alignment | Research-grade |
| BCO | experimental.bco.BCOTrainer | Binary classifier objective | Unpaired feedback |
from trl import SFTTrainer, SFTConfig, DPOTrainer, DPOConfig
from peft import LoraConfig
from datasets import load_dataset
# Stage 1: SFT
sft = SFTTrainer(
model="meta-llama/Llama-3.1-8B",
train_dataset=load_dataset("trl-lib/Capybara", split="train"),
args=SFTConfig(output_dir="llama-sft", learning_rate=2e-5),
peft_config=LoraConfig(r=16, lora_alpha=32),
)
sft.train()
# Stage 2: DPO from the SFT'd model
dpo = DPOTrainer(
model="llama-sft",
train_dataset=load_dataset("trl-lib/ultrafeedback_binarized", split="train"),
args=DPOConfig(output_dir="llama-dpo", beta=0.1, learning_rate=5e-7),
)
dpo.train()
from trl import DPOConfig
DPOConfig(loss_type=["sigmoid", "bco_pair", "sft"], loss_weights=[0.8, 0.2, 1.0])
SFTConfig(use_liger_kernel=True) # Triton kernels for fused ops
GRPOConfig(use_vllm=True, vllm_server_host="0.0.0.0", vllm_server_port=8000)
trl vllm-serve --model meta-llama/Llama-3.1-8B-Instruct --tensor-parallel-size 4
trl sft --model_name_or_path Qwen/Qwen2.5-7B \
--dataset_name trl-lib/Capybara \
--output_dir qwen-sft --learning_rate 2e-5
| Config | learning_rate | bf16 | gradient_checkpointing | logging_steps |
|---|---|---|---|---|
SFTConfig | 2e-5 | True | True | 10 |
DPOConfig | 1e-6 | True | True | 10 |
ORPOConfig | 1e-6 | True | True | 10 |
KTOConfig | 1e-6 | True | True | 10 |
PPOConfig | 3e-6 | True | True | 10 |
GRPOConfig | 1e-6 | True | True | 10 |
(All differ from base TrainingArguments defaults of 5e-5 / fp32.)
PeftModel and ref_model=None, TRL reuses the base by toggling adapters off. If you wrap it incorrectly, the "reference" is actually the trained adapter. Verify via trainer.ref_model.peft_config doesn't apply when model is already a PeftModel. Pre-wrapped models must be passed without peft_config or you get an error.use_liger_kernel=True constraints. With DPO, only single loss_type, no compute_metrics, no precompute_ref_log_probs. Read the matrix in TRL docs.accelerate launch config not matching script. Multi-GPU + DeepSpeed needs the right accelerate config answers; mismatched zero-stage and grad-accum cause OOM or hangs.trl.experimental.* as of TRL 1.0. Imports break on upgrade if you use the old paths.Activate when the user is using transformers-compatible models, asks about SFTTrainer/DPOTrainer/GRPOTrainer, wants to compare TRL trainers, or hits TRL-specific config or API issues.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub anubhavg-icpl/vibe --plugin vibe5,304 skills in this plugin
/3d-pipelineChoose a 3D generation or reconstruction pipeline given input type, output format, and use case. Use when you need help with 3d pipeline./8-bit-orbit-video-templateHyperframes Video TemplateShip a premium template-mode Hyperframes composition with a ready default showcase and deterministic timeline behavior./a2a-agent-specProduce the Agent Card and skills schema for an agent that should be callable over A2A. Use when you need help with a2a agent spec.Other plugins' skills for the same job