← Reference · Nestor G Pestelos Jr

Artificial Intelligence

Reinforcement Learning

A citable reference on Reinforcement Learning (RL): Markov Decision Processes, Bellman optimality equations, value and policy iteration, policy gradient theorems, Actor-Critic methods, PPO, DPO, and GRPO.

See Also & Related References

1. Formal Definition and Markov Decision Processes

Reinforcement Learning (RL) is a computational framework in machine learning where an agent learns to make sequential decisions by interacting with an environment to maximize cumulative numerical reward.[1] Unlike supervised learning, which relies on explicit input-output label pairs, the agent receives evaluative feedback through scalar reward signals generated by environmental transitions.

1.1 The MDP 5-Tuple

Sequential decision problems in RL are formally framed as Markov Decision Processes (MDPs), defined by the 5-tuple \((S, A, P, R, \gamma)\):[1]

1.2 Returns, Trajectories, and Policies

An interaction trajectory \( au\) is a sequence of states, actions, and rewards: \( au = (s_0, a_0, r_0, s_1, a_1, r_1, \dots, s_T)\). The discounted return \(G_t\) from time step \(t\) onward is:

$$G_t = \sum_{k=0}^{\infty} \gamma^k R_{t+k+1}$$

The agent behaves according to a policy \(\pi\). A stochastic policy \(\pi(a \mid s) = \mathbb{P}(A_t = a \mid S_t = s)\) maps states to action probability distributions; a deterministic policy \(\mu(s)\) maps each state directly to a specific action. The goal of the agent is to find an optimal policy \(\pi^*\) that maximizes the expected return \(J(\pi) = \mathbb{E}_{ au \sim \pi}[G_0]\).

1.3 Value Functions

Value functions measure expected long-term return under a given policy:

2. Bellman Equations and Optimality

Value functions satisfy recursive relationships known as Bellman equations, decomposing the value of a state into immediate reward plus discounted downstream value.[2]

2.1 Bellman Expectation Equations

For any stationary policy \(\pi\), the value functions satisfy:

$$V^\pi(s) = \sum_{a \in A} \pi(a \mid s) \sum_{s' \in S} P(s' \mid s, a) \left[ R(s, a, s') + \gamma V^\pi(s') ight]$$
$$Q^\pi(s, a) = \sum_{s' \in S} P(s' \mid s, a) \left[ R(s, a, s') + \gamma \sum_{a' \in A} \pi(a' \mid s') Q^\pi(s', a') ight]$$

2.2 Bellman Optimality Equations

An optimal policy \(\pi^*\) achieves the maximum value across all states: \(V^*(s) = \max_\pi V^\pi(s)\) and \(Q^*(s, a) = \max_\pi Q^\pi(s, a)\). The Bellman optimality equations express these conditions without explicit policy reference:

$$V^*(s) = \max_{a \in A} \sum_{s' \in S} P(s' \mid s, a) \left[ R(s, a, s') + \gamma V^*(s') ight]$$
$$Q^*(s, a) = \sum_{s' \in S} P(s' \mid s, a) \left[ R(s, a, s') + \gamma \max_{a' \in A} Q^*(s', a') ight]$$

2.3 Contraction Mapping and Convergence

The Bellman optimality operator \(\mathcal{T}^*\) defined by \((\mathcal{T}^* V)(s) = \max_a \sum_{s'} P(s' \mid s, a)[R(s, a, s') + \gamma V(s')]\) is a \(\gamma\)-contraction mapping in the infinity norm:

$$\|\mathcal{T}^* U - \mathcal{T}^* V\|_\infty \le \gamma \|U - V\|_\infty$$

By the Banach Fixed-Point Theorem, applying \(\mathcal{T}^*\) iteratively from any initial value function \(V_0\) converges geometrically to the unique optimal value function \(V^*\) when \(\gamma < 1\). This property provides the theoretical foundation for value iteration and Q-learning.[1, 3]

3. Taxonomy of Reinforcement Learning Algorithms

Category Optimization Target Key Mechanism Representative Algorithms
Model-Based Transition model \(P(s' \mid s, a)\) and reward \(R\) Plan via tree search, trajectory sampling, or world simulation Dyna-Q, AlphaZero (MCTS), MuZero, World Models
Value-Based Action-value function \(Q(s, a)\) Iterative Temporal Difference updates; derive greedy policy \(rg\max_a Q\) Q-Learning, SARSA, Deep Q-Networks (DQN), Rainbow
Policy-Based Parameterized policy \(\pi_ heta(a \mid s)\) Ascend policy performance gradient directly via trajectory samples REINFORCE, Natural Policy Gradient
Actor-Critic Joint policy \(\pi_ heta\) and value baseline \(V_\phi\) Actor updates policy; Critic provides low-variance advantage estimates A2C, A3C, TRPO, PPO, SAC

3.1 Model-Based vs. Model-Free

Model-Based RL algorithms learn or utilize an explicit model of environment transitions and reward dynamics. The agent uses this internal simulation to plan future action sequences before execution (for example, Monte Carlo Tree Search in AlphaZero).[4]

Model-Free RL algorithms bypass transition modeling and learn value functions or policies directly from sampled experience. While requiring higher sample complexity, model-free methods avoid compounding model bias in complex high-dimensional environments.

3.2 Value-Based Methods

In Q-Learning (Watkins, 1989), the agent updates action-value estimates off-policy using Temporal Difference (TD) learning:[3]

$$Q(S_t, A_t) \leftarrow Q(S_t, A_t) + lpha \left[ R_{t+1} + \gamma \max_a Q(S_{t+1}, a) - Q(S_t, A_t) ight]$$

Deep Q-Networks (DQN) (Mnih et al., 2015) scale Q-learning to high-dimensional state spaces using deep neural networks parameterized by \( heta\).[5] DQN stabilizes non-linear function approximation through two core mechanisms:

3.3 Policy Gradient Methods

Policy-based methods parameterize the policy directly as \(\pi_ heta(a \mid s)\) and optimize the objective \(J( heta) = \mathbb{E}_{ au \sim \pi_ heta}[R( au)]\) via gradient ascent. The Policy Gradient Theorem (Sutton et al., 1999) establishes that the objective gradient does not require differentiation through state transition probabilities:[6]

$$ abla_ heta J( heta) = \mathbb{E}_{ au \sim \pi_ heta} \left[ \sum_{t=0}^T abla_ heta \log \pi_ heta(A_t \mid S_t) \, Q^{\pi_ heta}(S_t, A_t) ight]$$

In the Monte Carlo REINFORCE algorithm (Williams, 1992), empirical episode return \(G_t\) serves as an unbiased sample estimate of \(Q(S_t, A_t)\).[7]

3.4 Actor-Critic Architectures

Pure policy gradients suffer from high variance. Actor-Critic methods resolve this by training a Critic network \(V_\phi(s)\) to estimate expected value and replacing \(Q(s, a)\) with the Advantage function \(A(s, a) = Q(s, a) - V(s)\).

Proximal Policy Optimization (PPO) (Schulman et al., 2017) stabilizes policy updates by constraining the step size using a clipped surrogate objective:[8]

$$L^{ ext{CLIP}}( heta) = \hat{\mathbb{E}}_t \left[ \min\left( r_t( heta) \hat{A}_t, \, ext{clip}(r_t( heta), 1-\epsilon, 1+\epsilon) \hat{A}_t ight) ight]$$

where \(r_t( heta) = rac{\pi_ heta(a_t \mid s_t)}{\pi_{ heta_{ ext{old}}}(a_t \mid s_t)}\) is the probability ratio and \(\epsilon\) is a clipping parameter (typically \(0.1\) or \(0.2\)).

4. The Exploration-Exploitation Tradeoff

An RL agent balances exploitation (selecting actions known to yield high reward) with exploration (trying unfamiliar actions to discover potentially superior strategies). Common formal mechanisms include:

5. Reinforcement Learning in Large Language Models

In modern language model post-training, the state space corresponds to the prompt context, actions are generated tokens, and the environment transition is deterministic token concatenation.[10]

5.1 RLHF with PPO

Reinforcement Learning from Human Feedback (RLHF) aligns pretrained language models with user preferences using a three-stage pipeline (Christiano et al., 2017; Ouyang et al., 2022):[10, 11]

  1. Supervised fine-tuning (SFT) on prompt-response demonstrations.
  2. Reward model training on pairwise human preference comparisons \((y_w \succ y_l)\) via the Bradley-Terry preference model:
    $$\mathcal{L}_{ ext{RM}}(\psi) = -\mathbb{E}_{(x, y_w, y_l)} \left[ \log \sigmaig(r_\psi(x, y_w) - r_\psi(x, y_l)ig) ight]$$
  3. PPO policy optimization maximizing reward while applying a Kullback-Leibler (KL) divergence penalty against the reference model \(\pi_{ ext{ref}}\) to prevent policy collapse:
    $$ ext{obj}( heta) = \mathbb{E}_{(x, y) \sim \mathcal{D}_{\pi_ heta}} \left[ r_\psi(x, y) - eta D_{ ext{KL}}ig(\pi_ heta(y \mid x) \,\|\, \pi_{ ext{ref}}(y \mid x)ig) ight]$$

5.2 Direct Preference Optimization (DPO)

Direct Preference Optimization (DPO) (Rafailov et al., 2023) derives an exact closed-form substitution for the optimal reward function in terms of policy probabilities:[12]

$$r(x, y) = eta \log rac{\pi_ heta(y \mid x)}{\pi_{ ext{ref}}(y \mid x)}$$

Substituting this parameterization directly into the pairwise preference loss eliminates the need for an explicit reward model or online reinforcement learning sampling loop:

$$\mathcal{L}_{ ext{DPO}}( heta) = -\mathbb{E}_{(x, y_w, y_l)} \left[ \log \sigma \left( eta \log rac{\pi_ heta(y_w \mid x)}{\pi_{ ext{ref}}(y_w \mid x)} - eta \log rac{\pi_ heta(y_l \mid x)}{\pi_{ ext{ref}}(y_l \mid x)} ight) ight]$$

5.3 GRPO and Verifiable Rewards (RLVR)

For formal reasoning domains (mathematics, formal logic, and software code generation), reward signals can be computed deterministically via rule-based verifiers such as unit test execution or mathematical equivalence checkers.

Group Relative Policy Optimization (GRPO) (Shao et al., 2024 / DeepSeekMath) eliminates the Critic neural network entirely to cut memory overhead during post-training.[13] For each prompt \(q\), GRPO samples a group of \(G\) candidate outputs \(\{o_1, o_2, \dots, o_G\}\), scores each output with reward verifier \(r_i\), and standardizes rewards across the group to compute advantage values:

$$\hat{A}_i = rac{r_i - ext{mean}(\{r_1, \dots, r_G\})}{ ext{std}(\{r_1, \dots, r_G\})}$$

The policy is updated with a clipped objective regularized by a direct token-level KL divergence penalty:

$$\mathcal{J}_{ ext{GRPO}}( heta) = \mathbb{E}_{q \sim P(Q), \{o_i\}_{i=1}^G \sim \pi_{ heta_{ ext{old}}}} \left[ rac{1}{G} \sum_{i=1}^G \left( \min\left( rac{\pi_ heta(o_i \mid q)}{\pi_{ heta_{ ext{old}}}(o_i \mid q)} \hat{A}_i, \, ext{clip}\left( rac{\pi_ heta(o_i \mid q)}{\pi_{ heta_{ ext{old}}}(o_i \mid q)}, 1-\epsilon, 1+\epsilon ight) \hat{A}_i ight) - eta D_{ ext{KL}}(\pi_ heta \,\|\, \pi_{ ext{ref}}) ight) ight]$$

6. References

  1. ^ Richard S. Sutton and Andrew G. Barto, Reinforcement Learning: An Introduction, 2nd ed. (MIT Press, 2018). URL: incompleteideas.net.
  2. ^ Richard Bellman, Dynamic Programming (Princeton University Press, 1957).
  3. ^ Christopher J. C. H. Watkins and Peter Dayan, "Q-learning," Machine Learning 8(3), 279–292 (1992). DOI: 10.1007/BF00992698.
  4. ^ David Silver, Thomas Hubert, Julian Schrittwieser, et al., "A general reinforcement learning algorithm that masters chess, shogi, and Go through self-play," Science 362(6419), 1140–1144 (2018). DOI: 10.1126/science.aar6404.
  5. ^ Volodymyr Mnih, Koray Kavukcuoglu, David Silver, et al., "Human-level control through deep reinforcement learning," Nature 518(7540), 529–533 (2015). DOI: 10.1038/nature14236.
  6. ^ Richard S. Sutton, David McAllester, Satinder Singh, and Yishay Mansour, "Policy Gradient Methods for Reinforcement Learning with Function Approximation," Advances in Neural Information Processing Systems 12 (NeurIPS 1999). URL: NeurIPS Proceedings (PDF).
  7. ^ Ronald J. Williams, "Simple statistical gradient-following algorithms for connectionist reinforcement learning," Machine Learning 8(3), 229–256 (1992). DOI: 10.1007/BF00992696.
  8. ^ John Schulman, Filip Wolski, Prafulla Dhariwal, Alec Radford, and Oleg Klimov, "Proximal Policy Optimization Algorithms," arXiv:1707.06347 (2017). DOI: 10.48550/arXiv.1707.06347.
  9. ^ Tuomas Haarnoja, Aurick Zhou, Pieter Abbeel, and Sergey Levine, "Soft Actor-Critic: Off-Policy Maximum Entropy Deep Reinforcement Learning with a Stochastic Actor," International Conference on Machine Learning (ICML 2018). URL: arXiv:1801.01290.
  10. ^ Long Ouyang, Jeffrey Wu, Xu Jiang, et al., "Training language models to follow instructions with human feedback," Advances in Neural Information Processing Systems 35 (NeurIPS 2022). URL: arXiv:2203.02155.
  11. ^ Paul F. Christiano, Jan Leike, Tom B. Brown, Miljan Martic, Shane Legg, and Dario Amodei, "Deep reinforcement learning from human preferences," Advances in Neural Information Processing Systems 30 (NeurIPS 2017). URL: arXiv:1706.03741.
  12. ^ Rafael Rafailov, Archit Sharma, Eric Mitchell, Stefano Ermon, Christopher D. Manning, and Chelsea Finn, "Direct Preference Optimization: Your Language Model is Secretly a Reward Model," Advances in Neural Information Processing Systems 36 (NeurIPS 2023). URL: arXiv:2305.18290.
  13. ^ Zhihong Shao, Peiyi Wang, Qihao Zhu, et al., "DeepSeekMath: Pushing the Limits of Mathematical Reasoning in Open Language Models," arXiv:2402.03300 (2024). DOI: 10.48550/arXiv.2402.03300.