Chapter 124 / 7
RLHF & Preference Optimization
Implement a minimal PPO update for LLMs: ratio, clipped surrogate, value loss, per-token K
Hard
Implement a minimal PPO update for LLMs: ratio, clipped surrogate, value loss, per-token KL penalty to a reference. [OpenAI]
Target interface
ppo_step(logp_new, logp_old, logp_ref, values_new, returns, advantages, mask, eps=0.2, vf_coef=0.5, kl_coef=0.1)Implement the function/class skeleton in the editor. Any correct approach is accepted.
Hints0 / 2
Reference solution
Your own code stays in the editor.