Reinforcement Learning Foundations: The Math Underneath RLHF
Articles 1, 2, and this series' "After Transformers" companion all reference RLHF as a working technique without explaining the theory underneath it. This article gives you that theory — value functions, the Bellman equation, policy gradients, and the exploration-exploitation tradeoff — plain-language first, with the real papers and the direct line from classical RL to PPO, the exact algorithm used inside modern RLHF.
Why RLHF Needs Its Own Theory Article
Article 2's self-assessment and "How Each Network Architecture Actually Learned"'s Era 8 both described RLHF mechanically — generate outputs, rank them, train a reward model, update the policy — without explaining the reinforcement learning theory that makes "update the policy" a well-defined mathematical operation rather than a vague gesture. This article fills that gap: reinforcement learning (RL) predates deep learning by decades as its own field, with its own vocabulary, and RLHF is a specific, relatively recent application of ideas that were developed for a very different original purpose — teaching agents to play games and control robots.
The scoping rule from Article 3 applies again here: this article covers the RL concepts that show up directly in RLHF and in this series' other RL references (Berkeley CS285, DeepMind x UCL, both cited in Article 1), not the full breadth of classical RL research.
Agents, States, Actions, and Rewards
Every RL problem, from a robot arm to an LLM being fine-tuned on human preferences, is described using the same handful of ingredients, formalized as a "Markov Decision Process" (MDP):
The word "Markov" refers to a simplifying assumption: the current state contains all the information needed to decide what to do next — you don't need the entire history, just where you are right now. This assumption is what makes the math in Part 2 tractable, and it's also a real, sometimes-violated simplification worth being aware of (a long conversation's full context may matter more than an LLM's compressed internal state fully captures).
Learning What's Actually Valuable, Not Just What Feels Good Right Now
A reward is immediate — but a good action might have a low immediate reward and a great long-term payoff (a chess move that looks passive but sets up a winning position ten moves later). A value function estimates the total future reward an agent can expect from a given state (or state-action pair), not just the next reward — this is the mathematical tool that lets an agent reason about delayed consequences.
Richard Bellman's foundational insight, from his 1957 work on dynamic programming, is that a state's value can be defined recursively: the value of being in a state equals the immediate reward you'd get, plus the (discounted) value of whatever state you land in next.
This recursive relationship — the Bellman equation — is the mathematical backbone of nearly every value-based RL method, including Q-learning (Watkins, 1989) and the Deep Q-Network that famously learned to play Atari games directly from pixels (Mnih et al., Nature, 2015).
The Tradeoff Every RL Agent Has to Manage
An agent that only ever repeats the action it currently believes is best (exploitation) can get permanently stuck on a mediocre strategy, never discovering something better it hasn't tried. An agent that only ever tries new things (exploration) never capitalizes on what it's already learned. Balancing these two is a genuinely hard, actively studied problem, most cleanly illustrated by the "multi-armed bandit" problem: imagine several slot machines with unknown, different payout rates — how do you decide when to keep pulling the machine that's paid off so far, versus trying an unexplored one that might be better? Auer et al.'s UCB algorithm (2002) is a classic, mathematically principled answer: favor actions that are either high-value or under-tried, with a formula that naturally shifts toward exploitation as more evidence accumulates.
| Strategy | Risk | Where It Shows Up |
|---|---|---|
| Pure exploitation | Gets stuck on a locally-good, globally-suboptimal strategy | An RLHF-tuned model that only ever produces "safe," previously-rewarded response styles |
| Pure exploration | Never converges, wastes resources on already-known-bad options | An agent that never settles into a usable, predictable strategy |
| UCB / principled balance | More complex to implement correctly | Classical bandit algorithms; conceptually related to how RLHF's KL penalty (Part 4) keeps a policy from drifting too erratically |
Learning a Strategy Directly, Instead of Learning Values First
Value-based methods (Part 2) learn how good states are, then derive a policy from that (pick the action leading to the highest-value state). Policy gradient methods take a more direct approach: represent the policy itself as a trainable function (in modern RLHF, a neural network — the same LLM being fine-tuned), and directly adjust its parameters to make high-reward actions more likely and low-reward actions less likely.
Williams' 1992 REINFORCE algorithm is the classical starting point: run the current policy, observe the resulting reward, and push up the probability of whatever actions were taken, scaled by how good the outcome turned out to be. Sutton et al.'s 1999 policy gradient theorem formalized why this works mathematically, giving the field a principled foundation for a whole family of methods that followed.
The specific algorithm used in modern RLHF is Schulman et al.'s Proximal Policy Optimization (PPO, 2017) — a refinement of the basic policy-gradient idea that adds a safeguard against updating the policy too aggressively in any single step (a real, practical failure mode of naive policy gradients, where one bad update can destabilize the entire policy). This is the literal algorithm cited in InstructGPT's methodology ("How to Read a Paper Like a Researcher").
Mapping RLHF's Pieces Onto This Article's Vocabulary
Seen this way, RLHF isn't a mysterious new invention — it's a specific, well-motivated application of decades-old RL machinery (Bellman's recursive value idea is decades older, PPO is from 2017) to a problem (aligning a language model's behavior) that classical RL was never originally designed for, but turns out to map onto cleanly.
Key Papers to Read First
| Paper | Why It's Foundational | Link |
|---|---|---|
| Williams — "Simple Statistical Gradient-Following Algorithms" — REINFORCE (1992) | The classical policy-gradient starting point | Springer |
| Sutton et al. — "Policy Gradient Methods..." (1999) | Formalizes why policy gradients work — the theoretical foundation for PPO and everything after | NeurIPS |
| Mnih et al. — "Human-Level Control Through Deep RL" — DQN (2015) | The landmark deep-RL result combining value functions (Part 2) with deep networks | Nature |
| Silver et al. — "Mastering the Game of Go..." — AlphaGo (2016) | RL's most famous pre-LLM public result, combining value functions with tree search | Nature |
| Schulman et al. — "Proximal Policy Optimization Algorithms" — PPO (2017) | The literal algorithm used inside InstructGPT and most modern RLHF systems | arXiv:1707.06347 |
| Christiano, Leike et al. — "Deep RL from Human Preferences" (2017, previously cited in Article 1) | The foundational RLHF paper this entire article builds toward explaining | arXiv:1706.03741 |
Courses to Complete
Real Scenario Walkthroughs
Self-Assessment Checklist
⚠️ What's Missing or Uncertain in This Article
Where This Series Goes Next
Article 7 moves from RL foundations to interpretability — how researchers actually look inside a trained model to understand what it's doing, building directly on this site's Interpretability Gap article and Anthropic's superposition research (referenced in "After Transformers"). From there, the series continues through alignment, world models, systems, and research methodology, before a capstone article ties every foundational concept back into one unified map.
- Sutton & Barto — Reinforcement Learning: An Introduction
- Williams — REINFORCE (1992)
- Mnih et al. — DQN (Nature, 2015)
- Silver et al. — AlphaGo (Nature, 2016)
- Schulman et al. — PPO (arXiv:1707.06347)
- Christiano, Leike et al. — Deep RL from Human Preferences (arXiv:1706.03741)
- This site — AGI Researcher Foundations: Generalization & Learning Theory (Article 5)
- This site — How Each Network Architecture Actually Learned