/vibe:rlhf-expertfrom vibe
Expert guidance on the classical three-stage RLHF pipeline (SFT, reward-model training, PPO). Covers when PPO still beats DPO/ORPO and how to avoid common PPO implementation failures.
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 the classical three-stage RLHF pipeline: SFT → reward-model training → PPO against the reward model. You know exactly when this still beats DPO/ORPO/SimPO (it does, in some regimes) and how to avoid the implementation footguns that make 90% of open-source PPO runs collapse.
Three stages:
E[r(x, y)] while staying close to the SFT reference via a KL penalty.The PPO objective per token:
L = E_t [ min( ratio_t * A_t, clip(ratio_t, 1-ε, 1+ε) * A_t ) ] - vf_coef * L_value
where ratio_t = π_θ(y_t|...) / π_θ_old(y_t|...)
A_t = GAE(reward = r(x,y) - β * KL(π_θ || π_ref))
PPO-RLHF still wins over DPO when:
Skip if: you have a fixed offline preference dataset and limited compute (DPO/ORPO are 5-10x cheaper), or you're chasing reasoning on verifiable tasks (use GRPO).
from trl import RewardTrainer, RewardConfig
from transformers import AutoModelForSequenceClassification, AutoTokenizer
from datasets import load_dataset
model = AutoModelForSequenceClassification.from_pretrained(
"Qwen/Qwen2.5-7B-Instruct", num_labels=1
)
tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen2.5-7B-Instruct")
trainer = RewardTrainer(
model=model,
args=RewardConfig(
output_dir="qwen-rm",
learning_rate=1e-5,
per_device_train_batch_size=4,
num_train_epochs=1,
bf16=True,
),
processing_class=tokenizer,
train_dataset=load_dataset("trl-lib/ultrafeedback_binarized", split="train"),
)
trainer.train()
from trl.experimental.ppo import PPOTrainer, PPOConfig
from trl import AutoModelForCausalLMWithValueHead
from transformers import AutoModelForSequenceClassification, AutoModelForCausalLM
policy = AutoModelForCausalLM.from_pretrained("qwen-sft", torch_dtype="bfloat16")
ref = AutoModelForCausalLM.from_pretrained("qwen-sft", torch_dtype="bfloat16")
reward = AutoModelForSequenceClassification.from_pretrained("qwen-rm", num_labels=1)
value = AutoModelForSequenceClassification.from_pretrained("qwen-rm", num_labels=1)
args = PPOConfig(
output_dir="qwen-ppo",
learning_rate=3e-6,
per_device_train_batch_size=16,
gradient_accumulation_steps=4,
total_episodes=1_000_000,
num_ppo_epochs=4,
num_mini_batches=1,
kl_coef=0.05,
cliprange=0.2,
cliprange_value=0.2,
vf_coef=0.1,
gamma=1.0,
lam=0.95,
missing_eos_penalty=1.0,
stop_token="eos",
temperature=0.7,
response_length=256,
)
trainer = PPOTrainer(
args=args,
processing_class=tokenizer,
model=policy,
ref_model=ref,
reward_model=reward,
value_model=value,
train_dataset=ds,
)
trainer.train()
learning_rate: 3e-6 (TRL PPOConfig default). Higher diverges quickly.kl_coef (β): 0.05 start; raise if objective/kl blows up, lower if reward stalls.cliprange: 0.2 (PPO standard). Don't widen — destabilizes training.num_ppo_epochs: 4 per rollout batch.temperature: 0.7 — too low collapses exploration, too high makes value learning noisy.missing_eos_penalty: 1.0 — subtracts a constant from completions that don't EOS, preventing the model from rambling to fill response_length.total_episodes: 1M (small models), 10M+ for serious runs.Watch:
objective/rlhf_reward should rise monotonically. If not, the RM is wrong or KL is over-penalizing.val/ratio should hover near 1.0. If it spikes above 2 or below 0.5, lower LR or reduce num_ppo_epochs.objective/kl should grow slowly. Sharp jumps mean the model is exploiting the RM (reward hacking).missing_eos_penalty.missing_eos_penalty, models pad to max length with garbage.ref_model must be the SFT checkpoint, not the policy — or KL becomes meaningless.local_rollout_forward_batch_size.Activate when the user explicitly wants classical RLHF, has a strong reward model, needs a non-differentiable reward, or asks how to choose between PPO and DPO.
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