Reinforcement learning from human feedback and proximal policy optimization [ftip-0039]
✍️sourceAGENTDRAFTED
Reinforcement learning from human feedback and proximal policy optimization [ftip-0039]
✍️sourceAGENTDRAFTED
RLHF, short for reinforcement learning from human feedback, names a family of alignment-training pipelines. One influential pipeline fits a supervised policy, learns a reward model from comparisons, and then optimizes the policy against that reward while limiting movement from a reference policy. This section separates those pipeline choices from proximal policy optimization (PPO), the optimization method used in its final stage.
Definition 1. Language-model RLHF pipeline [ouyang2022training, Section 3.1, Figure 2, and Section 3.5] [ftip-003A]AGENTDRAFTED
Definition 1. Language-model RLHF pipeline [ouyang2022training, Section 3.1, Figure 2, and Section 3.5] [ftip-003A]AGENTDRAFTED
The InstructGPT pipeline first performs supervised fine-tuning on labeler demonstrations. It then samples response pairs, collects labeler rankings, and fits a scalar reward model. Finally, it samples responses from the trainable policy and applies PPO using the reward-model score together with a penalty relative to the supervised policy.
The three stages consume different records and optimize different losses. Calling their composition RLHF does not make supervised targets, pairwise preferences, learned rewards, and policy-gradient samples the same kind of feedback.
Remark 2. Reward modeling, alignment criteria, and policy optimization [ftip-003B]AGENTDRAFTED
Remark 2. Reward modeling, alignment criteria, and policy optimization [ftip-003B]AGENTDRAFTED
The RLHF pipeline makes three logically separate choices. The comparison data specify which judgments were observed; the reward model specifies how those observations are represented and generalized; the policy optimizer specifies how sampled actions change the model.
An alignment criterion lies outside this chain unless it is identified with the training reward by assumption. A reward model can predict its held-out comparisons while failing under policy-induced distribution shift, and PPO can increase the learned reward while independent utility stays fixed or falls.
Definition 3. Kullback--Leibler divergence [ftip-006X]AGENTDRAFTED
Definition 3. Kullback--Leibler divergence [ftip-006X]AGENTDRAFTED
For probability mass functions \(p\) and \(q\) on a finite or countable set \(\mathcal Y\), the Kullback--Leibler divergence of \(p\) relative to \(q\) is \[ D_{\mathrm {KL}}(p\Vert q) =\sum _{y\in \mathcal Y}p(y)\log \frac {p(y)}{q(y)}. \] We use \(0\log (0/q)=0\). If \(p(y)>0\) and \(q(y)=0\) for some \(y\), the value is \(+\infty \). On a countable set, the negative part of the displayed series is finite; a divergent positive part gives the value \(+\infty \). Since \(\mathcal V^*\) is countable, the definition applies to the response laws of Notation [ftip-002A].
The order of the arguments matters. In particular, finiteness of the displayed forward divergence requires \(p\) to be absolutely continuous with respect to \(q\).
Remark 4. How the divergence enters alignment objectives [ftip-006Y]AGENTDRAFTED
Remark 4. How the divergence enters alignment objectives [ftip-006Y]AGENTDRAFTED
The KL-regularized reward objective appears as equation (3) in Section 3 of [rafailov2023direct]. Behavior-policy ratios, clipped ratios, and KL penalties enter alignment objectives for different purposes.
A coefficient multiplying \(D_{\mathrm {KL}}\) declares an optimization tradeoff. It is neither a guarantee that every sampled ratio is small nor an independent evaluation of the resulting policy.
Definition 5. KL-constrained RLHF objective [rafailov2023direct, Section 3, equation (3)] [ftip-003C]AGENTDRAFTED
Definition 5. KL-constrained RLHF objective [rafailov2023direct, Section 3, equation (3)] [ftip-003C]AGENTDRAFTED
Let \(\mu \) be a prompt law, \(r(x,y)\) a scalar reward, and \(\pi _{\mathrm {ref}}\) a fixed reference policy. For \(\beta >0\), the KL-regularized RLHF objective, using forward KL, is
\[ \max _{\pi } \mathbb E_{x\sim \mu ,\,y\sim \pi (\cdot \mid x)}[r(x,y)] -\beta \, \mathbb E_{x\sim \mu } \left [D_{\mathrm {KL}}\left ( \pi (\cdot \mid x)\Vert \pi _{\mathrm {ref}}(\cdot \mid x) \right )\right ]. \]The prompt law, reward, reference policy, and coefficient are part of the objective. The forward KL requires the optimized policy to be absolutely continuous with respect to the reference wherever the objective is finite.
Definition 6. KL-shaped PPO reward [ouyang2022training, Section 3.5, equation (2)] [ftip-003D]AGENTDRAFTED
Definition 6. KL-shaped PPO reward [ouyang2022training, Section 3.5, equation (2)] [ftip-003D]AGENTDRAFTED
For a prompt \(x\), sampled response \(y\), learned reward score \(r_\phi (x,y)\), and fixed reference policy \(\pi _{\mathrm {ref}}\), the sequence-level KL-shaped reward is
\[ R_{\mathrm {shape}}(x,y;\theta ) =r_\phi (x,y) -\beta \log \frac {\pi _\theta (y\mid x)} {\pi _{\mathrm {ref}}(y\mid x)}. \]Autoregressive factorization writes the logarithmic term as a sum of token-level log ratios. Ouyang et al. also mix a pretraining-gradient term into their reported PPO objective; that auxiliary term is separate from the shaped reward displayed here.
Definition 7. Generalized advantage estimator [schulman2016gae, Section 3, equations (10) and (16)] [ftip-003E]AGENTDRAFTED
Definition 7. Generalized advantage estimator [schulman2016gae, Section 3, equations (10) and (16)] [ftip-003E]AGENTDRAFTED
Given an approximate value function \(V\), with \(V(\mathsf H_N)=0\) at a terminal information state, define the temporal-difference residual
\[ \delta _t^V=R_{t+1}+\gamma V(\mathsf H_{t+1})-V(\mathsf H_t). \]For \(\lambda \in [0,1]\), the finite-episode generalized advantage estimator is
\[ \widehat A_t^{\mathrm {GAE}(\gamma ,\lambda )} =\sum _{l=0}^{N-t-1}(\gamma \lambda )^l\delta _{t+l}^V. \]The parameters \(\gamma \) and \(\lambda \) trade temporal reach against the variance and approximation error induced by bootstrapping. The estimator also depends on the fitted value function.
Definition 8. PPO clipped surrogate [schulman2017proximal, Section 3, equation (7)] [ftip-003F]AGENTDRAFTED
Definition 8. PPO clipped surrogate [schulman2017proximal, Section 3, equation (7)] [ftip-003F]AGENTDRAFTED
For a clipping parameter \(\epsilon _{\mathrm {clip}}\in (0,1)\), define \(\operatorname {clip}_{\epsilon _{\mathrm {clip}}}(u) =\min (1+\epsilon _{\mathrm {clip}},\max (1-\epsilon _{\mathrm {clip}},u))\). The PPO clipped surrogate is
\[ L^{\mathrm {CLIP}}(\theta ) =\widehat {\mathbb E}_t\left [ \min \left ( \rho _t(\theta )\widehat A_t, \operatorname {clip}_{\epsilon _{\mathrm {clip}}}(\rho _t(\theta )) \widehat A_t \right )\right ]. \]Clipping changes the sampled surrogate when the ratio moves outside the declared interval in a direction favored by the estimated advantage. It is not a hard bound on the KL divergence of the complete updated policy.
Definition 9. PPO value-and-entropy objective [schulman2017proximal, Section 5, equation (9)] [ftip-003G]AGENTDRAFTED
Definition 9. PPO value-and-entropy objective [schulman2017proximal, Section 5, equation (9)] [ftip-003G]AGENTDRAFTED
PPO implementations may optimize the combined sampled objective
\[ \widehat {\mathbb E}_t\left [ L_t^{\mathrm {CLIP}}(\theta ) -c_1\bigl (V_\theta (\mathsf H_t)-\widehat G_t\bigr )^2 +c_2\,\mathcal H\left (\pi _\theta (\cdot \mid \mathsf H_t)\right ) \right ], \]Here \(L_t^{\mathrm {CLIP}}\) is the per-sample integrand of the clipped surrogate in Definition 8, \(c_1,c_2\geq 0\), \(\widehat G_t\) is the declared value target, and, on the declared finite or countable discrete action set,
\[ \mathcal H(p)=-\sum _a p(a)\log p(a). \]The combined objective is used only when this nonnegative countable sum is finite, with \(0\log 0=0\). For a continuous action law, an implementation must instead declare a reference measure and the corresponding density-based entropy convention.
The value loss and entropy bonus change the shared-parameter update in addition to the clipped policy term. Their coefficients, target construction, and action space are part of the optimization method.
Definition 10. PPO rollout and minibatch update [schulman2017proximal, Section 5] [ftip-003H]AGENTDRAFTED
Definition 10. PPO rollout and minibatch update [schulman2017proximal, Section 5] [ftip-003H]AGENTDRAFTED
A PPO iteration collects a batch of trajectories under the behavior policy, computes returns or advantage estimates, and then performs several epochs of minibatch optimization on the same collected batch. The updated policy becomes the behavior policy for a later collection round.
The number of trajectories, epochs, minibatches, and optimizer steps governs how often one batch is reused. The clipped objective does not determine those protocol choices by itself.
Example 11. The PPO clipping cases for positive and negative advantage [ftip-003I]AGENTDRAFTED
Example 11. The PPO clipping cases for positive and negative advantage [ftip-003I]AGENTDRAFTED
Positive and negative advantages select different branches of the PPO clipped minimum.
With \(\epsilon =0.2\), write \(\bar r=\operatorname {clip}(r,0.8,1.2)\) and \(L(r,A)=\min (rA,\bar rA)\). For positive advantage and \(r=1.4\), the gain is capped at \(2.4\). For negative advantage and \(r=0.6\), the clipped term \(-1.6\) is smaller than \(-1.2\), so the objective retains the penalty.
The pointwise surrogate comes from [schulman2017proximal, Section 3]. The two sign cases check only its arithmetic; they provide no monotone-improvement result for a neural policy or finite minibatch.
Example 12. The InstructGPT-style RLHF pipeline [ftip-003J]AGENTDRAFTED
Example 12. The InstructGPT-style RLHF pipeline [ftip-003J]AGENTDRAFTED
One prompt passes successively through supervised tuning, comparison-based reward modeling, and PPO in the InstructGPT-style RLHF pipeline.
For the displayed illustrative prompt, suppose the comparison-trained reward model scores the preferred response by \(0.8\). If the candidate policy assigns it twice the probability assigned by the reference policy and the declared KL coefficient is \(\beta =0.1\), its shaped scalar is \[ 0.8-\beta \log \frac {\pi (y_B\mid x)} {\pi _{\rm ref}(y_B\mid x)} =0.8-0.1\log 2\approx 0.731. \]
The stage ordering is grounded in [ouyang2022training, Sections 3.1--3.5]; the numbers are a schematic calculation rather than reported InstructGPT hyperparameters. The diagram records the interface used in that pipeline. Other RLHF systems may order or replace the stages differently.
Remark 13. PPO is an optimizer, not an alignment definition [ftip-003K]AGENTDRAFTED
Remark 13. PPO is an optimizer, not an alignment definition [ftip-003K]AGENTDRAFTED
RLHF is a feedback-and-training pipeline; PPO is one optimizer used within that pipeline. PPO specifies a sampled update surrogate; it does not specify whose preferences are collected, what the reward means, or which independent behavior counts as aligned.
Changing the comparison population or reward model can change the alignment target while leaving PPO unchanged. Conversely, replacing PPO by another optimizer changes update geometry without necessarily changing the declared preference data or evaluation criterion.