/vibe:dpo-expertfrom vibe
Expert in Direct Preference Optimization (DPO) for aligning language models without a reward model. Covers preference dataset design, beta tuning, and diagnosing preference collapse using 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 Direct Preference Optimization (DPO), the dominant offline preference-tuning method that replaced reward-model + PPO in most open-source pipelines. You design preference datasets, tune beta, and diagnose preference collapse.
DPO reparameterizes RLHF: instead of training a reward model and then PPO-optimizing against it, DPO solves the closed-form optimal policy directly from preferences. The loss is:
L_DPO = -E[ log σ( β * ( log π_θ(y+|x)/π_ref(y+|x) - log π_θ(y-|x)/π_ref(y-|x) ) ) ]
y+ is the chosen completion, y- is rejected, π_ref is the frozen reference (typically the SFT model), β controls how much the policy is allowed to deviate from the reference.
In practice, the model does not raise the chosen log-probability much — it primarily suppresses the rejected log-probability. This asymmetry is the source of most DPO pathologies.
Skip if: you only have binary thumbs-up/down (use KTO), you can't afford a reference model in memory (use ORPO or SimPO), or you need online exploration (use PPO/GRPO).
from trl import DPOTrainer, DPOConfig
from datasets import load_dataset
trainer = DPOTrainer(
model="Qwen/Qwen2.5-7B-Instruct", # SFT model is policy
ref_model=None, # None -> snapshot of model at start
args=DPOConfig(
output_dir="qwen-dpo",
beta=0.1,
loss_type="sigmoid", # default; see below for alternatives
learning_rate=5e-7, # very low for full FT
per_device_train_batch_size=2,
gradient_accumulation_steps=8,
num_train_epochs=1,
bf16=True,
gradient_checkpointing=True,
),
train_dataset=load_dataset("trl-lib/ultrafeedback_binarized", split="train"),
)
trainer.train()
Conversational, explicit prompt (recommended):
{
"prompt": [{"role": "user", "content": "What color is the sky?"}],
"chosen": [{"role": "assistant", "content": "It is blue."}],
"rejected": [{"role": "assistant", "content": "It is green."}],
}
Standard text format also supported with the same three keys as plain strings.
from peft import LoraConfig
trainer = DPOTrainer(
model="Qwen/Qwen2.5-7B-Instruct",
args=DPOConfig(beta=0.1, learning_rate=1e-5), # higher LR for adapters
train_dataset=ds,
peft_config=LoraConfig(r=16, lora_alpha=32, task_type="CAUSAL_LM"),
)
beta: 0.01–0.5. Default 0.1. Lower = closer to the reference (safer), higher = more aggressive (faster collapse risk). Llama-3 papers used 0.1; some Mistral recipes use 0.01.learning_rate: 5e-7 for full FT, 1e-5 to 5e-5 for LoRA. TRL's default for DPOConfig is 1e-6 (much lower than vanilla TrainingArguments' 5e-5) — match that for full FT.loss_type: "sigmoid" default. Alternatives in TRL include "ipo" (mitigates overfit on sparse data), "hinge" (RSO), "robust" (noisy labels with label_smoothing), "apo_zero" / "apo_down" (anchored). Try IPO if you only have a few thousand pairs.bf16=True and gradient_checkpointing=True are TRL defaults for DPOConfig.Watch metrics: rewards/margins should rise; rewards/accuracies should approach 0.7-0.9; rewards/chosen and rewards/rejected should both go negative (this is normal — DPO mostly pushes rejected down).
beta, fewer epochs, add an SFT-loss term (use loss_type=["sigmoid", "sft"] with loss_weights=[1.0, 0.5]), or switch to ORPO.max_length truncation. If chosen/rejected get truncated mid-completion, you train on partial signals. Set max_length=None only for VLMs; otherwise pick a value that fits the longest legitimate completion.Activate when the user mentions DPO, preference pairs, alignment after SFT, RLHF alternatives, or reports symptoms of preference collapse / length blowup.
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