5.10 RL for reasoning
1. Learn
Section titled “1. Learn”- OpenAI Spinning Up: Intro to Policy Optimizationwhole page, through "Baselines in Policy Gradients"
- CS336 Assignment 5: alignment and reasoning RLhandout sections on GRPO
- Shao et al., DeepSeekMath (introduces GRPO)section 4.1
2. Bridge
Section titled “2. Bridge”Policy gradients. SFT copies demonstrations and DPO learns from comparisons. Reinforcement learning needs only a score for what the model itself produced. A policy πθ samples a response, a reward scores it, and the gradient of the expected reward is E[r ∇ log π(y)]: raise the log-probability of each sample in proportion to its reward (Williams 1992, REINFORCE). Every sample gives an unbiased but noisy gradient estimate.
Baselines. Subtracting any constant b from r leaves that expectation unchanged, because the score ∇ log π has mean zero. With b near the average reward, the estimate’s variance drops sharply: below-average samples are pushed down instead of up a little (Spinning Up).
Verifiable rewards. For maths and code the reward can be a checker rather than a learned model: parse the final answer and compare it with the ground truth. Nothing to fool, and no reward model in memory. DeepSeek-R1-Zero learned long chains of reasoning from rewards of this kind alone (DeepSeek-AI 2025, section 2.2).
GRPO. PPO estimates the baseline with a learned value network and clips the probability ratio πθ/πold to 1 ± ε, so that several gradient steps can reuse one batch of samples (Schulman et al. 2017). GRPO drops the value network: it samples a group of responses per prompt and uses the group’s mean reward as the baseline, divided by the group’s standard deviation (Shao et al. 2024, section 4.1). A group whose replies all score the same contributes nothing, so prompts must be neither too easy nor too hard. Dividing by the standard deviation and averaging per sequence both introduce biases that Dr. GRPO removes (Liu et al. 2025). CS336 Assignment 5 implements these losses (assignment5-alignment).
3. Explore
Section titled “3. Explore”stubs/m5_10_rl.pyLoading starter file…
Prefer your own editor? Edit exercises/stubs/m5_10_rl.py and run mlc check 5.10. The tests are identical; import the results on the progress page.
Then run GRPO on your model. Open notebooks/5.10-grpo.ipynb on Kaggle with a GPU and paste in your 4.6, 5.8 and 5.10 files. It pretrains your GPT, fine-tunes it to answer in <answer> tags, checks a PyTorch GRPO loss against your functions, then trains with groups of sampled replies scored by your math_reward and compares greedy accuracy before and after.
5. Check
Section titled “5. Check”- not yet: All tests pass (0/?)
- not yet: Checkpoint quiz ≥ 80%
Learner log: time spent and points of confusion
Every confusion you note becomes a fix before the module is marked stable. Export it from the progress page and attach it to an issue.