Proximal Policy Optimization (PPO) in LLM Post-Training: Mathematical Foundations of Clipped Surrogate Objectives, Generalized Advantage Estimation, Value Network Architectures, and Adaptive KL Penalties
Reinforcement Learning from Human Feedback (RLHF) established modern alignment for instruction-following foundation models. While pre-training optimizes autoregressive language models to minimize next-token prediction loss over massive text corpora, standard cross-entropy loss cannot directly optimize for open-ended attributes such as helpfulness, harmlessness, mathematical correctness, or human preference.
To bridge this gap, modern post-training pipelines formalize sequence generation as a Markov Decision Process (MDP) and apply policy gradient reinforcement learning algorithms. Among these, Proximal Policy Optimization (PPO), originally introduced by Schulman et al. (2017) and adapted to foundation models by Stiennon et al. (2020) and Ouyang et al. (2022), serves as the foundational actor-critic alignment algorithm.
Understanding PPO requires examining its mathematical formulation: the four-model distributed infrastructure, per-token Kullback-Leibler (KL) reward shaping, Generalized Advantage Estimation (GAE), the clipped surrogate objective, and its computational trade-offs against newer reference-free or critic-free alternatives.
1. The MDP Formulation of Autoregressive Language Generation
In the RLHF setting, autoregressive text generation is framed as an episodic Markov Decision Process denoted by the tuple :
- State Space (): The state at step corresponds to the concatenation of the input prompt and all previously generated response tokens . Thus, .
- Action Space (): The action is the selection of the next token from the vocabulary , where typically ranges between and .
- Transition Dynamics (): State transitions are deterministic string concatenations: . The episode terminates when the policy generates a special end-of-sequence token or reaches a maximum length limit .
- Policy (): The parameterized language model defines a stochastic policy .
- Discount Factor (): In language generation tasks, the standard discount factor is set to , treating all generated tokens within the finite horizon with equal long-term weighting.
2. The Four-Model Distributed Architecture
Standard PPO-based RLHF orchestrates four distinct language model instances during training:
+-----------------------------------+
| Input Prompt (x) |
+-----------------+-----------------+
|
+-----------------------+-----------------------+
| |
v v
+-------------------+ +-------------------+
| Active Policy | | Reference Model |
| (Actor) | | (Frozen SFT) |
| \pi_\theta(y|x) | | \pi_{ref}(y|x) |
+---------+---------+ +---------+---------+
| |
| Generated Sequence y | Reference Logits
| & Policy Logits |
v v
+-------------------------------------------------------------------+
| Per-Token KL Divergence Penalty |
| r_{KL}(t) = -\beta * log(\pi_\theta / \pi_{ref}) |
+---------------------------------+---------------------------------+
|
+-----------------------+-----------------------+
| |
v v
+-------------------+ +-------------------+
| Reward Model | | Critic Model |
| (Frozen RM) | | (Value Function)|
| r_\psi(x, y) | | V_\phi(s_t) |
+---------+---------+ +---------+---------+
| |
+-----------------------+-----------------------+
|
v
+-----------------------------+
| Generalized Advantage |
| Estimation (GAE) |
| \hat{A}_t^{GAE(\gamma,\lambda)} |
+--------------+--------------+
|
v
+-----------------------------+
| PPO Clipped Optimization |
| L^{CLIP}(\theta) + L^{VF} |
+-----------------------------+- Active Policy / Actor (): The primary model being trained. It generates the trajectory tokens and is updated using the clipped policy gradient objective. It is initialized from the Supervised Fine-Tuned (SFT) model.
- Reference Model (): A static, frozen copy of the SFT checkpoint. It provides baseline token probabilities used to penalize the active policy when it deviates too far from the original distribution.
- Reward Model (): A frozen model trained on paired human or AI preference data under the Bradley-Terry preference model, defined by Bradley and Terry (1952) and Christiano et al. (2017):
The scalar reward evaluates the full response.
- Value Network / Critic (): A parameterized model that maps intermediate states to expected cumulative future rewards . It is typically initialized from the reward model architecture with a modified scalar head and updated via mean squared error against empirical return targets.
3. Reward Augmentation and Per-Token KL Regularization
A foundational challenge in reinforcement learning for language models is "reward hacking" or policy collapse: without regularization, an unconstrained policy exploits quirks and misspecifications in the reward model , generating nonsensical, repetitive, or adversarial strings that achieve high reward scores but lose linguistic coherence.
To prevent distribution shift away from the natural language manifold, PPO incorporates a Kullback-Leibler (KL) divergence penalty into the objective function:
Because language generation occurs sequentially token by token, the full trajectory KL divergence can be decomposed into exact per-token penalties. The augmented token-level reward at step is formulated as:
Here, is the KL penalty coefficient.
Dynamic Adaptive KL Controller
While can remain constant, Ziegler et al. (2019) and Ouyang et al. (2022) introduced an adaptive proportional controller that dynamically adjusts after each training iteration to track a target KL divergence :
where is a proportional scaling factor (typically ). This adaptive rule ensures that if the policy begins exploiting the reward model, automatically increases to pull the policy back toward .
4. Generalized Advantage Estimation (GAE) in Language Horizons
To compute policy gradient updates, the actor requires an estimate of the advantage function , which quantifies how much better taking action is compared to the average action at state .

In language generation, directly using Monte Carlo returns yields high variance, while one-step Temporal Difference (TD) updates introduce high bias due to inaccuracies in the learned value network . Generalized Advantage Estimation (GAE), developed by Schulman et al. (2015), balances this trade-off using an exponentially decaying sum of temporal difference residuals.
Temporal Difference Residual
The 1-step TD residual at token step is defined as:
where at the terminal boundary. With discount factor :
GAE Advantage Computation
The Generalized Advantage Estimator is defined as the exponentially weighted average of -step advantage estimators:
This formulation yields a clean backward recurrence relation:
The hyperparameter controls the variance-bias continuum:
- : (lowest variance, highest bias from value function error).
- : (empirical Monte Carlo return minus baseline, zero bias, highest variance).
In modern LLM post-training systems (such as DeepSpeed-Chat, TRL, and Ray/vLLM RL pipelines), standard parameter choices are and .
Advantage Normalization
To stabilize optimization across mini-batches of varying response lengths and prompt difficulties, advantages are standardized across the mini-batch:
where and are the empirical mean and standard deviation computed across all valid token positions in the rollout batch, and .
5. The Clipped Surrogate Objective
Standard policy gradient methods compute gradients proportional to . Performing multiple epochs of stochastic gradient descent on the same rollout data under this standard objective leads to destructive, unconstrained parameter updates because the data distribution shifts away from the policy that collected the rollouts.
PPO resolves this by introducing the probability ratio:
where denotes the parameter state prior to the current multi-epoch update phase. At the start of rollout collection, .
The Clipped Objective Formulation
The PPO clipped surrogate policy loss is defined as:
where is a clipping threshold (typically ).
Mechanics of the Min Operator
The interaction between the probability ratio , advantage , and clipping operator handles positive and negative advantages symmetrically:
- Positive Advantage (): The token action performed better than average. The gradient pushes higher to increase the probability of generating this token. However, once , the clipped term $\text{clip}(r_t(\theta), 1-\epsilon, 1+\epsilon)\hat{A}_t = (1+\epsilon)\hat{A}_t$ becomes active. The operator takes this constant ceiling, dropping the gradient to zero and preventing excessive updates.
- Negative Advantage (): The token action performed worse than average. The gradient pushes lower to decrease token probability. When , the clipped term is larger (less negative) than . The operator selects the lower bound, flattening the gradient and preventing catastrophic probability collapses.
6. Value Function Optimization and Joint Objective
Simultaneously with actor optimization, the value network must be trained to predict the discounted return targets .
Value Loss with Clipping
To prevent large updates to the critic network from destabilizing policy evaluation, the value loss incorporates symmetric clipping:
Pre-Training Gradient Mixing (PTX Loss)
In Ouyang et al. (2022), the authors observed that optimizing solely on RLHF preference rewards caused degradation in standard academic benchmarks (the "alignment tax"). To mitigate this capability degradation, InstructGPT introduced an auxiliary supervised pre-training loss () directly into the policy gradient:
The Complete Optimization Objective
Combining all components yields the full multi-task objective for the actor and critic:
where:
- $S\pi_\theta = -\sum_{a} \pi_\theta(a|s_t) \log \pi_\theta(a|s_t)$ is the entropy bonus to encourage exploration (often set to for large models).
- is the value loss coefficient (typically to ).
- is the pre-training mixing coefficient (set between and in InstructGPT).
7. Systems Constraints, GPU Memory Budgets, and the Post-PPO Landscape
Deploying PPO in production requires substantial infrastructure. A single training worker must hold four full models in memory or stream them efficiently across high-bandwidth interconnects:
| Model Component | Parameter State | Optimizer State (AdamW) | Gradient Buffers | Activation Memory | | :--- | :--- | :--- | :--- | :--- | | Actor () | FP16/BF16 () | FP32 () | FP16/BF16 () | Dynamic (Sequence Length Batch) | | Critic () | FP16/BF16 () | FP32 () | FP16/BF16 () | Dynamic | | Reference () | FP16/BF16 () | None () | None () | Minimal (Forward Only) | | Reward () | FP16/BF16 () | None () | None () | Minimal (Forward Only) |
For a 70-billion parameter model, holding all four models requires over of GPU VRAM before accounting for activation caching and KV caches during the rollout generation phase.
Comparison: PPO vs Modern Post-Training Paradigms
Due to the memory overhead and hyperparameter sensitivity of PPO, alternative post-training algorithms have emerged:
| Characteristic | Proximal Policy Optimization (PPO) | Direct Preference Optimization (DPO) | Group Relative Policy Optimization (GRPO) | Simple Preference Optimization (SimPO) | | :--- | :--- | :--- | :--- | :--- | | Core Architecture | 4 Models (Actor, Critic, Ref, Reward) | 2 Models (Actor, Ref) | 2 Models (Actor, Ref) + Rule Verifier | 1 Model (Actor Only) | | Explicit Critic Network | Yes ( required) | No (Implicit reward derivation) | No (Group-normalized baseline) | No (Reference-free implicit reward) | | Optimization Type | Online on-policy RL | Offline pairwise preference | Online group-sampled on-policy RL | Offline length-normalized preference | | Primary Use Case | Multi-step reasoning with learned reward models | General conversational alignment and style | Mathematical and reasoning tasks with verifiers (DeepSeek-R1) | Resource-constrained fine-tuning without reference model | | Training Stability | Moderate (Requires tuning ) | High (Direct cross-entropy classification) | High (Eliminates critic estimation instability) | High (Eliminates reference model drift) |
While offline methods like DPO (Rafailov et al., 2023) and SimPO (Meng et al., 2024) dominate general instruction alignment due to their simplicity and low compute footprint, online reinforcement learning algorithms, including PPO and its critic-free variant GRPO (Shao et al., 2024), remain essential for complex multi-step reasoning, mathematical problem solving, and autonomous tool use where exploration of novel output distributions is necessary.
Sources
- Schulman, J., Wolski, F., Dhariwal, P., Radford, A., & Klimov, O. (2017). Proximal Policy Optimization Algorithms. arXiv:1707.06347.
- Schulman, J., Moritz, P., Levine, S., Jordan, M., & Abbeel, P. (2015). High-Dimensional Continuous Control Using Generalized Advantage Estimation. arXiv:1506.02438.
- Ouyang, L., Wu, J., Jiang, X., Almeida, D., Wainwright, C. L., Mishkin, P., Zhang, C., Agarwal, S., Slama, K., Ray, A., Schulman, J., Hilton, J., Kelton, F., Miller, L., Simens, M., Askell, A., Welinder, P., Christiano, P., Leike, J., & Lowe, R. (2022). Training language models to follow instructions with human feedback. Advances in Neural Information Processing Systems (NeurIPS 2022).
- Stiennon, N., Ouyang, L., Wu, J., Ziegler, D. M., Lowe, R., Voss, C., Radford, A., Amodei, D., & Christiano, P. (2020). Learning to summarize with human feedback. Advances in Neural Information Processing Systems (NeurIPS 2020).
- Christiano, P. F., Leike, J., Brown, T., Meng, M., Dhariwal, P., & Amodei, D. (2017). Deep Reinforcement Learning from Human Preferences. Advances in Neural Information Processing Systems (NeurIPS 2017).
- Ziegler, D. M., Stiennon, N., Wu, J., Brown, T. B., Radford, A., Amodei, D., Christiano, P., & Irving, G. (2019). Fine-Tuning Language Models from Human Preferences. arXiv:1909.08593.
- Rafailov, R., Sharma, A., Mitchell, E., Ermon, S., Manning, C. D., & Finn, C. (2023). Direct Preference Optimization: Your Language Model is Secretly a Reward Model. Advances in Neural Information Processing Systems (NeurIPS 2023).
- Meng, Y., Xia, M., & Chen, D. (2024). SimPO: Simple Preference Optimization with a Reference-Free Reward. arXiv:2405.14734.
- Shao, Z., Wang, P., Zhu, Q., Xu, R., Song, J., Zhang, M., Li, Y. K., Wu, Y., & Guo, D. (2024). DeepSeekMath: Pushing the Limits of Mathematical Reasoning in Open Language Models. arXiv:2402.03300.



