Companion material
RL Formula Cheat Sheet
A compact reference for the formulas that appear along the tutorial's main path: LLM next-token modeling, the LLM-as-policy mapping, policy-gradient updates, variance reduction, PPO-style RLHF, reward modeling, direct preference learning, and the extensions to reasoning, agents, and multimodal generation. It is meant for quick lookup after reading the corresponding sections, while the paper remains the source for full derivations.
LLM foundation
Language Modeling
Here, \(\mathbf{z}=z_1,\ldots,z_N\) is a token sequence and \(\mathbf{z}_{<i}=z_1,\ldots,z_{i-1}\). This left-to-right next-token view is the interface used for training, prompting, inference, and RL optimization.
LLM foundation
Pre-training Objective
\(\mathcal{S}_{\mathrm{pre}}\) is the pre-training corpus and \(\hat{\theta}\) denotes the optimized pretrained parameters.
Pre-training teaches general language modeling from unlabeled text. Later stages adapt this base model toward instruction following and reward-seeking behavior.
Conditioned generation
Prompting
Prompting adapts an LLM by changing the context used for generation, without updating model parameters. A prompt may contain instructions, user-provided content, output requirements, or demonstrations.
Prompt quality can strongly affect model performance. Even prompts with nearly the same intent may lead to different outputs, so prompts are often refined through trial and error or automated prompt search.
Baseline
Supervised Fine-Tuning
Here, \(\mathbf{x}\) is the input sequence, \(\mathbf{y}=y_1,\ldots,y_T\) is the target output sequence, and \(y_t\) is predicted from the input and previous target tokens.
SFT maximizes the likelihood of demonstrated outputs. It provides the initial policy before preference learning or RL optimization.
Autoregressive generation
Common Decoding Rules
Greedy decoding
Beam search
Sampling
Greedy decoding takes the most likely token. Beam search keeps the top \(B\) candidate prefixes under the accumulated sequence score. Sampling draws from the next-token distribution, often adjusted by temperature \(T\), top-\(k\), or top-\(p\) filtering.
Sampling is especially important for RL because it mirrors stochastic policy sampling and produces trajectories that can be scored by rewards.
LLM-RL mapping
LLM as a Policy
Here, \(s_t\) is the prompt plus generated prefix, and \(a_t\) is the next-token action selected by the LLM.
This is the bridge between token generation and RL. The policy chooses the next token conditioned on the prompt and generated prefix.
RL foundation
MDP Policy Objective
A trajectory is \(\tau=(s_0,a_0,s_1,a_1,\ldots,s_{H-1},a_{H-1})\), and \(H\) is the trajectory length.
In LLM RL, a trajectory may be a completion, reasoning trace, tool-use interaction, or multimodal generation path.
Policy optimization
Policy Gradient
Here, \(J(\theta)\) is the policy objective, \(\tau\) is a sampled trajectory, and \(R(\tau)\) is its cumulative reward.
LLM form in the paper
Increase the probability of sampled trajectories that receive high reward. The reward does not need to be differentiable.
Expected future reward
Value and Discounted Return
Here, \(V(s)\) is the expected discounted return from state \(s\), \(r_t\) is the reward at timestep \(t\), and \(\gamma\) is the discount factor.
The value function estimates future return under a policy. The discount factor controls how much future rewards matter relative to near-term rewards.
Variance reduction
Value and Advantage
Here, \(Q(s,a)\) is the expected return after taking action \(a\) at state \(s\), while \(V(s)\) is the baseline expected return from the state.
Advantage measures whether an action is better than the expected behavior at the same state. It reduces the variance of reward-weighted updates.
Bias-variance tradeoff
Generalized Advantage Estimation
Here, \(\delta_t\) is the temporal-difference residual, \(V_t\) is the value estimate at timestep \(t\), and \(\lambda\) controls the GAE bias-variance tradeoff.
GAE recursively mixes temporal-difference signals across future steps. It is a practical compromise between noisy Monte Carlo returns and biased one-step estimates.
Off-policy correction
Importance Sampling Ratio
Here, \(\pi_{\theta}\) is the current policy and \(\pi_{\theta_{\mathrm{old}}}\) is the old policy that generated the sampled action \(a_t\).
The ratio corrects the mismatch between the policy used to generate samples and the policy currently being optimized.
Policy drift control
KL Penalty
Here, \(\theta_{\mathrm{ref}}\) denotes the reference model parameters, and the two log probabilities compare the trained policy with the reference policy on the same token.
The penalty discourages the trained policy from moving too far away from the reference model. In RLHF, this is central for preserving language quality while optimizing reward. In PPO-style objectives, \(\beta\) is the weight controlling the strength of this penalty.
Stable RLHF
PPO Clipped Objective
Here, \(A_t\) is the advantage at timestep \(t\), \(\rho_t\) is the policy probability ratio, and \(\epsilon\) sets the clipping range.
PPO limits policy updates by clipping the probability ratio. This helps prevent reward over-optimization and unstable policy drift.
Preference reward
Pairwise Reward Model Loss
Here, \(r_{\phi}\) is the reward model, \(\mathbf{x}\) is the input, \(\mathbf{y}_w\) is the preferred output sequence, and \(\mathbf{y}_l\) is the rejected output sequence.
The reward model learns to assign a higher score to the preferred response than to the rejected response.
Denser feedback
Reward Shaping
Here, \(r'_t\) is the shaped reward, \(r_t\) is the original reward, and \(\Phi\) is the potential function used to construct the additional feedback term.
Shaping adds intermediate reward signals. Potential-based shaping is useful because it can provide denser feedback while preserving the intended optimal policy.
Group-relative RL
GRPO Advantage
Here, \(\mathbf{y}_i\) is one response in a group sampled for the same input \(\mathbf{x}\), and \(\mathbf{R}\) is the set of rewards for that group.
GRPO estimates advantage by comparing responses sampled for the same prompt. This can remove the need for a separate value model.
Direct preference learning
DPO Preference Objective
Here, \(\mathbf{y}_w\) and \(\mathbf{y}_l\) denote the preferred and dispreferred output sequences, \(\theta_{\mathrm{ref}}\) is the reference model, and \(\beta\) controls the strength of the implicit reward ratio.
DPO optimizes the policy directly from preference pairs, avoiding an explicit pipeline that trains a reward model and then applies RL in its basic form.
Reasoning search
UCT Selection in MCTS
Here, \(\bar{\mathbf{y}}_k\) is a candidate reasoning step, \(N_p\) is the parent-node visit count, \(N_{\bar{\mathbf{y}}_k}\) is the child-node visit count, and \(c\) balances exploitation and exploration.
MCTS balances exploiting promising reasoning steps and exploring under-visited alternatives. This is a useful mental model for verifier-guided reasoning.
Interactive agents
Agent Trajectory Objective
Here, \(e\) is environment information, \(q\) is the user task, \(p\) is the generated plan, and \(u_t,o_t\) are the agent behavior and environment observation at step \(t\).
Agentic RL optimizes plans and action-observation trajectories rather than only single completions. This makes delayed rewards and credit assignment especially important.
Beyond text
Multimodal Generation RL Objectives
Here, \(\mathbf{z}\) denotes the text prompt, \(\mathbf{x}_0\) is the generated sample, and \(R_{\mathrm{dm}}\) is the reward function used to evaluate that sample.
For image generation, the final sample can be scored by alignment, aesthetics, safety, or preference rewards, while the denoising process supplies the trajectory to optimize.
This follows the DPOK-style denoising-trajectory formulation used in the paper; later diffusion RL variants may modify the regularization, reference model, or advantage estimator.
This follows Flow-GRPO, where ODE-based flow matching is converted into a stochastic MDP for online RL; later flow-matching RL variants may alter the stochastic conversion or the group-relative update.