interviewpath
  • 0day streak
  • 10total XP
  • Level 1
0/5

Unit 10 · AI research · Lesson 6 of 9

Reinforcement learning foundations (optional)

Optional module on reinforcement learning foundations: Markov decision processes, value functions, policy gradients, the idea behind PPO, and how RL connects to RLHF for language models. Useful for RL, robotics and alignment research roles and for understanding why DPO was proposed.
About 4 hFocus mode

Step 1: Learn the ideas

  • MDPs, returns, discounting and value functions
  • Dynamic programming: value iteration and policy iteration
  • Temporal-difference learning and Q-learning (awareness)
  • Policy gradients, baselines and advantages
  • Actor-critic methods and generalized advantage estimation
  • PPO: clipping and the trust-region intuition
  • RLHF: reward models, KL penalties and overoptimization
  • Seed variance and evaluation in RL

Why it matters

RL is optional for most AI roles, but it is the language of RLHF and of reinforcement-based post-training for reasoning, and it is essential for robotics and agent research. Interviewers in those areas may ask you to derive a policy gradient or explain why PPO clips; elsewhere you mainly need to explain how preference-based fine-tuning relates to RL.

Core ideas

An MDP has states, actions, transition probabilities, rewards and a discount γ. The value V^π(s) is the expected discounted return from s under policy π; Q^π(s, a) also fixes the first action. Bellman equations write each as immediate reward plus discounted next-state value, which yields value and policy iteration when the model is known and temporal-difference learning when it is not.

Policy gradients optimize a parameterized policy directly. Weighting ∇log π(a|s) by the return gives an unbiased gradient estimate (the log-derivative trick). Subtracting a state-dependent baseline, typically a learned value function, keeps it unbiased and reduces variance. Using an advantage estimate A(s, a) = Q(s, a) − V(s) gives actor-critic methods, and generalized advantage estimation trades bias for variance through a parameter λ.

Vanilla policy gradient is sensitive to step size: one large update can collapse the policy. PPO maximizes a surrogate built on the probability ratio between the new and old policy, clipped so that pushing the ratio outside a small interval earns nothing extra, and it reuses each batch of experience for several epochs of minibatch updates.

RLHF for language models treats a response as a sequence of actions. A reward model is trained on human preference pairs, commonly with a Bradley-Terry likelihood, and the policy is optimized with PPO to maximize reward minus a KL penalty to the supervised model, which limits drift and reward exploitation. DPO shows that for this KL-regularized objective the optimal policy can be fitted directly from preference pairs with a classification-style loss.

Common misconceptions

  • "A baseline biases the gradient." Any baseline that does not depend on the action leaves the expected gradient unchanged; it only reduces variance.
  • "PPO's clip is a hard trust region." Clipping removes the incentive to move further, but the policy can still drift beyond the range over several epochs; implementations monitor KL or stop early.
  • "A higher reward-model score means a better model." Optimizing a learned reward too hard exploits its errors; true quality can fall while the proxy keeps rising.
  • "One good RL run shows the method works." RL results vary strongly across seeds and implementation details; report several seeds and the details.

How to approach it

Read Spinning Up parts 1 to 3, implement REINFORCE with a baseline on a small control task, then read the PPO page and paper and add clipping. Connect to RLHF through the methods section of the InstructGPT paper and the DPO paper guide. Report every RL result over at least three to five seeds.

Suggested order

  1. 1Read Spinning Up Part 1 (Key Concepts) and Part 3 (Intro to Policy Optimization); derive the policy-gradient estimator yourself before reading their derivation.
  2. 2Read the CS229 main notes chapters "Reinforcement learning" and "Policy Gradient and its Variants" for MDPs, value iteration and REINFORCE.
  3. 3Implement REINFORCE with a learned baseline on a small control task over three seeds (policy-gradient project).
  4. 4Read the Spinning Up PPO page and the PPO paper’s sections on the clipped objective; add clipping to your implementation and compare stability.
  5. 5Read the methods section of the InstructGPT paper (listed with the ML fine-tuning topics) for the SFT, reward-model and PPO pipeline, then the DPO paper guide.
  6. 6Optional depth: Sutton and Barto chapters on dynamic programming, temporal-difference learning and policy-gradient methods, or the CS 185/285 policy-gradient and actor-critic lectures.

Paper guides: Direct Preference Optimization: Your Language Model is Secretly a Reward Model

Step 2: Check off what you can do

Tap each one you can genuinely do or explain. Each earns 10 XP.

Step 3: Go deeper

  • Spinning Up in Deep RLStart here

    OpenAI

    Primary introduction: key concepts, algorithm taxonomy, policy-gradient derivation and PPO documentation.

    Open(opens in a new tab)Link responded, 5 Oct 2026
  • Stanford CS229 Machine Learning

    Stanford University

    Section: Main notes: "Reinforcement learning" and "Policy Gradient and its Variants" chapters

    Concise mathematical treatment of MDPs, value and policy iteration and REINFORCE.

    Open(opens in a new tab)Link responded, 5 Oct 2026
  • Proximal Policy Optimization Algorithms

    arXiv

    The clipped surrogate objective and its comparison with other surrogates.

    Open(opens in a new tab)Link responded, 5 Oct 2026
  • Berkeley CS 185/285: Deep Reinforcement Learning

    UC Berkeley

    Section: Lecture 5: Policy Gradients (slides)

    Second explanation of policy gradients with variance-reduction tricks; homework 2 for practice.

    Open(opens in a new tab)Link responded, 5 Oct 2026
  • Reinforcement Learning: An Introduction (2nd edition)

    MIT Press

    Textbook depth on dynamic programming, temporal-difference learning and policy-gradient theory.

    Open(opens in a new tab)Not checked, 5 Oct 2026

Step 4: Practice

Start from the smallest environment where your agent can succeed and plot returns for every seed, not just the mean. When training fails, check the sign of the loss, advantage normalization and whether the learning rate is too high before changing the algorithm.

Record attempts on each problem’s page (+15 XP, +10 more when solved on your own).

Step 5: Test yourself

Answer each one out loud or on paper before you finish the lesson.

  1. Question 1Why is the plain policy-gradient estimator high variance, and what reduces it?
  2. Question 2What is the difference between on-policy and off-policy learning?
  3. Question 3What does the λ parameter of generalized advantage estimation trade off?
  4. Question 4Why does RLHF penalize KL divergence from the supervised model?
  5. Question 5What is reward-model overoptimization, and how would you detect it?

You’re done when you can

  • Derive the policy-gradient estimator with a baseline on a whiteboard without notes.
  • Train a policy-gradient agent that solves a small control task and report returns over at least three seeds.
  • Explain PPO’s clipped objective and the KL penalty in RLHF in under three minutes.
  • State precisely how DPO relates to the RLHF objective.

Finish the lesson

How confident do you feel?

Lesson complete!

+50 XP

Reviews will come up on the Practice tab so it sticks.

Unlocks next: Robot learning foundations (optional)

Your notes and study time

Log study time