DeepSeek-R1&GRPO:Chain-of-ThoughtReasoningWithoutCriticModels
Analysis of Group Relative Policy Optimization (GRPO), mathematical loss derivation, and reasoning trajectory fine-tuning.
Start Here: Beginner Primer & Intuition
No heavy equations required — grasp the core mechanics in plain English first.Quick TL;DR: Teach AI models to 'think before speaking' and self-correct complex math and coding problems without paying for massive critic networks.
Why the Old Approach Broke Down
Traditional AI reinforcement learning requires training two identical giant models at once: an Actor (the model talking) and a Critic (the judge estimating future scores). For a 70B model, this instantly exhausts GPU memory.
The Elegant Engineering Fix
GRPO ditches the Critic completely. For each question, it asks the model to generate a group of 8 different answers, grades them with automated math/code tests, and gives higher credit to answers that outperformed the group average.
The Math Study Group
Instead of hiring a private tutor to hover over each student's shoulder step-by-step, 8 students solve the same calculus problem on the board. We check their final answers with a calculator, see which students got it right, and everyone learns by comparing their working against the top performers.
Group Comparison (Relative Advantage)
Instead of estimating an absolute score, the model ranks its 8 generated solutions against each other, scoring above or below average.
Zero Critic VRAM Overhead
Saves 50% GPU memory because no second neural network is needed to evaluate states.
Emergent <think> Tags
Rewarding accuracy causes the model to naturally develop 'thinking aloud', double-checking formulas, and backtracking when it notices a mistake.
Abstract & Theoretical Context
Mathematical Formulations & Variables
1. GRPO Group Relative Advantage Estimator:
For prompt x and group of G outputs {y_1, y_2, ..., y_G}:
A_i = ( R_i - mean(R_1, ..., R_G) ) / ( std(R_1, ..., R_G) + epsilon )
2. GRPO Objective Function:
J_GRPO( heta) = E [ 1/G sum_{i=1}^G min( rac{pi_ heta(y_i|x)}{pi_old(y_i|x)} A_i, clip(rac{pi_ heta(y_i|x)}{pi_old(y_i|x)}, 1-epsilon, 1+epsilon) A_i ) - eta D_KL(pi_ heta || pi_ref) ]
3. Multi-Reward Signals:
R_total = R_accuracy (rule-based math/code evaluation) + R_format (enforces <think> and </think> XML tags)PyTorch Implementation Code
Step-by-Step Reproduction Guide
Key Insights & Operator Insights
- Zero Value Network Overhead: Saves 50% GPU memory during RL fine-tuning by dropping the critic network.
- Emergent Reasoning: Models spontaneously learn reflection, back-tracking, and verification behaviors during reward optimization.
- Rule-Based Accuracy Rewards: Evaluates math equations and executable code tests directly via automated evaluators.
- Format Enforcement: Uses strict formatting rewards to structure Chain-of-Thought thinking steps inside XML tags.
NVIDIA H100, 8x A100 (80GB VRAM), or vLLM Cluster Inference Setup