| Policies and rewards | |
|---|---|
| prompt; response; its -th token | |
| policy being trained; starting (SFT) model; policy that sampled the batch | |
| reward model | |
| KL-shaped reward of a response | |
| better and worse response of a pair: by reward in Step 8, by the labeler in the reward-model loss | |
| logistic function, | |
| PPO | |
| prefix ; per-token reward | |
| value model; its one-step error; GAE advantage | |
| probability ratio of token , current over sampling policy | |
| hidden width of the model (reward-head initialization) | |
| RLOO | |
| responses sampled for one prompt | |
| mean reward of the samples; RLOO gradient estimate | |
| KL controller (Ziegler et al.) | |
| measured KL at step ; its relative error; that error clipped to | |
| Constants | |
| KL weight of the shaped reward; adapted toward a KL target in Ziegler et al. | |
| discount (1 throughout) and GAE parameter of PPO | |
| PPO clip range (0.2) | |
| samples per prompt in RLOO and RAFT (2 or 4) | |
| target KL of Ziegler et al.'s controller (6 to 10 nats for style tasks) | |
Context. Ziegler et al. (2019) set up reinforcement-learning fine-tuning of a pretrained language model from human preferences: a reward model trained on comparisons, a KL penalty subtracted from the reward of each sampled response; its mean over responses from is times the Kullback-Leibler divergence from the starting model to the starting model subtracted from the reward, and PPOproximal policy optimization: a policy-gradient method that maximizes a clipped surrogate of expected reward, so each update moves the policy only a little from the one that produced the samples taken over from game and robotics RL, with its learned value modela network trained to predict the reward still to come from each prefix of a response, used as a baseline in the advantage, per-token advantages, clipping and several passes over each batch. That recipe became the RL stage of InstructGPT-style training, and getting it to work depends on many details. Huang et al. (2024) rebuild the TL;DRa summarization task built from Reddit posts and their authors' short summaries summarization pipeline in the open and list more than 20 of them. Ahmadian et al. (2024) ask which of PPO's parts a pretrained language model needs, and find that plain REINFORCEthe basic policy-gradient estimator: (reward minus a baseline) times for a sampled response with a leave-one-out baselinefor each of responses sampled for a prompt, the mean reward of the other (RLOO) does better.
PPO was designed for long tasks with noisy returns and a policy that starts from random weights, where a learned value model and clipping keep updates stable. Fine-tuning a language model differs on both counts: the reward arrives once, at the end, and the pretrained policy puts most of its probability on a few tokens at each step, so gradient estimates are already fairly stable and successive policies stay close. Treating the whole response as one action and subtracting the average reward of the other samples for the same prompt gives an unbiased gradient estimate with no value model, and in these experiments it matched or beat PPO. Much of what PPO's results depended on sat outside the optimizer: the KL-shaped reward, reward normalization, a defined reward for every sample (Step 3), and correct end-of-sequence and padding handling.
Setting. A prompt gets a response from the policy the language model being trained, with parameters , viewed as a distribution over responses to each prompt; the supervised fine-tuned model the policy starts from, kept frozen as the reference of the KL penalty is the starting model and the reward model's score for response to prompt ; a copy of the language model with a scalar head, trained so that the preferred response of a labeled pair scores higher the reward model. RL maximizes the KL-shaped rewardthe reward-model score minus the KL penalty, ; its expectation under is the KL-regularized objectivewith the weight of the KL penalty: 0.03 to 0.1 in Ziegler et al., 0.05 in Huang et al., 0.03 and 0.1 in Ahmadian et al. the KL weight. PPO treats each token as an action taken in the state : the per-token reward is at that token, plus at the last one. It estimates each token's advantage with GAEgeneralized advantage estimation, a weighted sum of one-step errors of the value model that interpolates between the value model's estimate () and the observed return (), from the value model , a discount and a parameter ,and maximizes the clipped surrogate , where the ratio of the current policy to the policy that sampled the batch, the token's probability ratio and PPO's clip range, 0.2 by default: once the ratio leaves in the direction the advantage favors, the token's term has no gradient the clip range. RLOO instead samples the number of responses sampled per prompt in RLOO (2 or 4 here) responses for each prompt and uses the sequence-level estimate
Main findings (all empirical). (a) Ziegler et al., with a 774M GPT-2: 5,000 human comparisons suffice for stylistic continuation, whose outputs labelers prefer to the original model's 88% (positive sentiment) and 86% (vivid description) of the time. With 60k labels, summarization models become "smart copiers" that lift whole sentences from the source, and without the KL term the policy writes gibberish that the reward model scores near its maximum. (b) Huang et al., with Pythia models of 1B, 2.8B and 6.9B parameters, one learning rate () for every stage and four seeds, reproduce the scaling of RLHF for summarization: a GPT-3.5 judge prefers the 6.9B PPO model's summaries to the human references nearly 80% of the time, and PPO beats supervised fine-tuning at every summary length. (c) Ahmadian et al., on TL;DR (Pythia 6.9B) and the helpful-harmless (HH) dialogue data of Bai et al. (2022) (Pythia 6.9B and Llama 7B): reward falls steadily as GAE's moves from 1 to 0, clipping is active on fewer than 5% of tokens, and RLOO with reaches GPT-4 win rates of 77.9%, 43.7% and 64.1% in those three settings against PPO's 67.6%, 29.2% and 32.0%, ahead of DPOdirect preference optimization: fitting the policy to preference pairs with a logistic loss on log-probability ratios to the reference, with no reward model and no RL as well.
Consequences. For RL on a pretrained language model with a reward per response, REINFORCE with a leave-one-out baseline over samples per prompt is a strong default. It drops the value model, one fewer copy of the model in memory, and the GAE and clipping settings, and keeps the KL-shaped sequence reward. The same baseline sits inside GRPOgroup relative policy optimization (Shao et al., 2024): a PPO-style update with no value model, whose advantage for each of the responses to a prompt is its reward minus the group's mean reward, divided by the group's standard deviation: the leave-one-out advantage is times the group-centered reward , with the mean reward of the samples, so without its division by the standard deviation GRPO's advantage is RLOO's up to that constant factor. If PPO is used, near 1 and the reproduction's details matter. The KL term does real work in either case: it keeps outputs in the region where the reward model was trained.
The KL term keeps outputs where the reward model is valid; without it the policy writes gibberish. In a mock task whose reward is a sentiment classifier's log odds, training with no KL penalty, even with an entropy bonusa reward for keeping the policy's per-token distribution spread out, which discourages it from collapsing onto a few tokens targeting 30 nats, gives text like "These These These sound flowed instantly easily easily" that scores about log odds (99.97% positive). The KL term acts as an entropy bonus, keeps the policy where was trained, and for style tasks supplies coherence the labelers were never asked about. Because runs with the same ended at very different distances from the start, Ziegler et al. also steered toward a target KL with a log-space proportional controlleran update of by a factor proportional to the relative error between the measured KL and its target, with that error clipped to , so changes by at most 2% per step,where is the KL from the starting model measured at step and its relative error. With the reward known, the best policy at each KL is the reference multiplied by and renormalized, the optimum of the KL-regularized objective, and after 2M episodes PPO is short of it, a gap that more training mostly closes. Other details that recur later: the reward model's outputs are normalized to mean 0 and variance 1 on samples from the starting model, and a response missing the required end marker (a period for style tasks, a newline for summaries) gets a fixed reward of .
The policy learns what labelers check, including their shortcuts. Summarization models trained on 60k labels copy whole sentences from the input 71% of the time on TL;DR and 98% on CNN/Daily Maila news summarization dataset of articles paired with bullet-point highlights, while choosing which sentences to copy and skipping preambles. Labelers prefer them to the human reference summaries (96% and 84%) yet not to lead-3a baseline that copies the first three sentences of the article (45% and 40%). On 30 articles per dataset the authors judge 26 and 29 of these summaries accurate, against at most 20 for the more abstractive supervised models. Copying is an easy way to be accurate, the labelers were told to penalize inaccuracy but not copying, and checking for copying is fast, so the reward model rewarded it. Collecting labels on the current policy's samples during training (online collection) mattered for summarization, where labelers preferred the online model to an offline one 64% (TL;DR) and 65% (CNN/Daily Mail) of the time, and not for the style tasks. A refactor that flipped the sign of both the reward and the KL penalty produced fluent text that scored as badly as possible under the labelers' instructions, since the KL term still kept it grammatical.
The reward is defined only at the end-of-sequence token, so EOS handling decides whether PPO gets a valid signal. The reward model is trained to read its score at the EOSthe end-of-sequence token that ends a response token. If padding uses the EOS token itself, a common shortcut, EOS is masked as padding during supervised training and the model never learns to stop. The reproduction keeps a separate padding token and, following what the original code appears to do, samples a fixed 53 tokens, truncates at the first EOS, and gives to any response with no EOS, the "EOS trick", which both defines every reward and favors responses that end. Dropout is turned offwhy: with dropout active, the log-probabilities of the same tokens differ between the sampling pass and the training pass, so the ratio is not 1 at the start of the first epoch and the KL estimate is unreliable in all stages. Prompts are truncated at a paragraph boundary to fit 512 tokens, and are padded on the left for generation, while the reward model was trained on right-padded sequences; scoring the left-padded form changes the 6.9B reward model's scores by about on average.
The reward model and the value model are initialized from trained models, and their outputs are kept on a fixed scale. The reward model is the supervised model with a linear head whose weights are drawn with standard deviation (the paper writes with the standard deviation in the second slot), with the hidden width, trained for one epoch, and then shifted so the human reference summaries score 0 on average. The value model is initialized from the reward model, which makes the early value estimates and so the early policy gradients sensible, and it ends up acting like a per-token reward model. Advantages are whitenednormalized within each batch to mean 0 and variance 1 (in the reward version the paper prints, the batch mean is added back) in each batch. Whitening the rewards as well gives shorter summaries and a lower raw win rate, but the same win rate at a given length. The PPO settings are , , , four passes over each batch of 512, , the value loss clipped at 0.2 with weight 0.1, sampling temperature 0.7, and 1M episodes, about 8.6 passes over the 117k training prompts.
The reproduction scales with model size, and its failures are over-optimization and length. Win rates against the reference summaries rise with model size, and the 2.8B and 6.9B models beat the 1.3B checkpoint of the original work. Two 1B runs drifted to a KL of about 50 and 85 nats from the start: their KL-shaped reward was higher, yet the judge preferred them to the references less than 20% of the time, and they wrote run-together strings with no spaces, the over-optimizationa learned reward that keeps rising under optimization while the true quality it stands in for falls measured by Gao et al. PPO summaries are longer than supervised ones, a confound the paper addresses by binning by length relative to the reference; PPO wins in every bin, and its win rate rises with length, which means either that the judge favors length or that longer summaries are better. A DPO model trained on the same preference data, read as an implicit reward model, has lower validation accuracy than the explicit reward model at every size and seed.
Lowering GAE's makes the advantage less noisy but biased, and the reward falls. With the sum in GAE telescopes at to the observed return minus the value,so the value model is only a baseline and the advantage is unbiased but carries the full variance of the sampled return, while at the advantage relies on the value model's prediction of the next prefix, which lowers the variance and adds bias wherever that prediction is wrong. On helpful-harmless data with Llama 7B, PPO's reward curve falls in order as goes from 1 to 0.95, 0.5 and 0, the opposite of what one would see if variance were the main problem. They attribute this to how concentrated the supervised model's predictions already are: after the first token, the supervised model puts about 60% of its probability on the single most likely next token and over 90% on the top 16 of a 32k vocabulary, and its normalized entropy stays low through the response.
Clipping and the probability ratio rarely act. Across datasets and models, the PPO loss is clipped on fewer than 5% of tokens per batch, so successive policies stay close and the update is nearly on-policy. Turning clipping off (for the value loss as well), and then also dropping the ratio at , which leaves vanilla policy gradientREINFORCE applied per token, with each token's return from that point on minus a learned per-prefix baseline, does not hurt and if anything raises reward slightly. With two gradient steps per batch, as here, there is little room for the policy to move far from the one that sampled the data.
Treating the response as one action, with other samples as the baseline, beats PPO. Since tokens before the last get only the KL part of the reward, and the next state is the current one with the chosen token appended, the problem is a bandita one-step decision problem: one action (here the whole response) and one reward, with no later states with the prompt as context. REINFORCE with a moving-average baseline ties vanilla policy gradient on Pythia and beats it on Llama (55.3% against 52.3% win rate). RLOO beats both, and PPO by 10.3, 14.5 and 32.1 points across the three settings. For two samples it is a contrastive objective weighted by the reward gap,maximized, with the higher-reward sample. RAFTreward-ranked fine-tuning: sample responses, keep the best by reward, and fine-tune on it with ordinary next-token loss, which trains only on the best of the same samples, averages 56.1% and 59.5% win rates at and 4 against RLOO's 61.3% and 61.9%, and its reward falls more when Gaussian noise of standard deviation 3 or 5 is added to the reward or is raised, since it depends only on which sample ranks first. On helpful-harmless data with Llama 7B, PPO's responses average 16.5 tokens and DPO's 104.4, against about 60 for RLOO.
Limits. Ahmadian et al.'s PPO is one implementation, its learning rate swept over two values, and its responses on helpful-harmless data average 16.5 tokens against 39 to 104 for the other methods, which this note reads as a sign that it settled into a short-answer mode (the paper reports only the length); how much of RLOO's margin survives a PPO built with the care of Huang et al. is not tested. Win rates there come from a GPT-4 judge, models are at most 7B, and reward over-optimization is not studied. Huang et al. study one task with a GPT-3.5 judge, and Ziegler et al.'s results come from few seeds and few labelers per comparison. The case for RLOO assumes a reward only on the full response; with intermediate rewards, per-token credit assignment may matter again.
Terms
- KL-shaped reward
- ; keeps samples where the reward model was trained
- GAE at
- return minus value; the value model is only a baseline, so no bias from its errors
- Clipping in RLHF
- active on under 5% of tokens; removing it did not hurt (Ahmadian et al.)
- RLOO
- ; unbiased, no value model
- RLOO and group centering
- RLOO with
- contrastive objective on the pair weighted by half the reward gap
- EOS trick
- fixed-length sampling, truncate at EOS, reward when no EOS
- Separate PAD and EOS
- if EOS doubles as padding, it is masked in training and the model never learns to stop
- Reward normalization
- reward model shifted so reference summaries (or starting-model samples) score 0 on average
- Value from reward model
- initializing the value model from the reward model gives sensible early gradients
- Smart copier
- Ziegler et al.'s summarizers copied whole sentences; accurate, and what labelers checked
- Adaptive KL
- multiplied by , the clipped relative KL error
Quiz
- PPO's loss was clipped on fewer than 5% of tokens in these runs. What does that indicate?Clipping acts only when the probability ratio leaves . If that almost never happens, the policy changes little between sampling and update, and removing the clip and then the ratio did not hurt.
- Why is the RLOO estimator unbiased even though its baseline is computed from the same batch of samples?For sample , the baseline is the mean reward of the other samples, drawn independently of , so its product with has mean zero. Including 's own reward would only rescale the estimate by .
- A team's PPO run reaches a high KL-shaped reward, but a judge prefers its outputs to the references under 20% of the time, and the text runs words together. What happened?Huang et al. saw exactly this in two 1B runs: the optimization succeeded on the proxy, while the outputs moved into a region where the reward model is wrong. The drift in KL is the warning sign, which is what the KL penalty and early stopping guard against.
Sources
- Daniel M. Ziegler et al. Fine-Tuning Language Models from Human Preferences. arXiv preprint, 2019.
- Shengyi Huang, Michael Noukhovitch, Arian Hosseini, Kashif Rasul, Weixun Wang, and Lewis Tunstall. The N+ Implementation Details of RLHF with PPO: A Case Study on TL;DR Summarization. COLM, 2024.
- Arash Ahmadian et al. Back to Basics: Revisiting REINFORCE Style Optimization for Learning from Human Feedback in LLMs. ACL, 2024.
- Wouter Kool, Herke van Hoof, and Max Welling. Buy 4 REINFORCE Samples, Get a Baseline for Free! ICLR Workshop on Deep Reinforcement Learning Meets Structured Prediction, 2019.