Open AI IT TCET Pinwheel Logo
OPEN AI ITTCET-IT COMMITTEE
Reasoning Models16 min read • August 2026

DeepSeek-R1&GRPO:Chain-of-ThoughtReasoningWithoutCriticModels

Analysis of Group Relative Policy Optimization (GRPO), mathematical loss derivation, and reasoning trajectory fine-tuning.

Reference / Authors: DeepSeek AI (2025)

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.

THE BOTTLENECK

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 BREAKTHROUGH

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.

REAL-WORLD ANALOGY

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.

Concept 01
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.

Concept 02
Zero Critic VRAM Overhead

Saves 50% GPU memory because no second neural network is needed to evaluate states.

Concept 03
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

DeepSeek-R1 demonstrated that complex reasoning behaviors (such as self-correction, reflection, and long Chain-of-Thought search) can be directly incentivized through large-scale Reinforcement Learning without relying on supervised fine-tuning data. Traditional PPO requires training an additional Critic Value Model equal in size to the policy model, doubling GPU memory requirements. DeepSeek-R1 introduces Group Relative Policy Optimization (GRPO), which samples a group of G output trajectories for each question, calculating relative advantage by normalizing rewards across the group. GRPO completely eliminates the critic network, saving 50% VRAM during training while successfully discovering multi-step reasoning capabilities.

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

deepseek-r1-grpo-reasoning-reproduction.py
1import torch
2import torch.nn as nn
3import torch.nn.functional as F
4
5def compute_grpo_advantage(rewards: torch.Tensor, eps: float = 1e-8) -> torch.Tensor:
6 """
7 Computes GRPO Group Relative Advantages across G sampled output trajectories.
8 Inputs: rewards tensor of shape (Batch, GroupSize)
9 """
10 mean_reward = rewards.mean(dim=-1, keepdim=True)
11 std_reward = rewards.std(dim=-1, keepdim=True)
12 advantages = (rewards - mean_reward) / (std_reward + eps)
13 return advantages
14
15def compute_grpo_loss(
16 pi_logps: torch.Tensor,
17 old_pi_logps: torch.Tensor,
18 ref_logps: torch.Tensor,
19 advantages: torch.Tensor,
20 clip_eps: float = 0.2,
21 beta: float = 0.04
22) -> torch.Tensor:
23 """
24 Computes GRPO policy loss with PPO-style probability clipping and KL penalty.
25 """
26 # Probability ratios
27 ratio = torch.exp(pi_logps - old_pi_logps)
28 surr1 = ratio * advantages
29 surr2 = torch.clamp(ratio, 1.0 - clip_eps, 1.0 + clip_eps) * advantages
30
31 policy_loss = -torch.min(surr1, surr2).mean()
32
33 # KL divergence penalty against reference model (no value network needed)
34 kl_div = torch.exp(ref_logps - pi_logps) - (ref_logps - pi_logps) - 1
35 kl_loss = beta * kl_div.mean()
36
37 return policy_loss + kl_loss

Step-by-Step Reproduction Guide

11. Environment Setup: Install PyTorch 2.x and vLLM inference engine for rapid multi-sample generation.
22. Group Sampling: Generate G=8 response trajectories for each training prompt in parallel.
33. Automated Reward Scoring: Pass generated outputs to math equation solvers or Python test suite runners.
44. GRPO Advantage Normalization: Compute mean and standard deviation per prompt group to derive relative advantages A_i.
55. Policy Gradient Step: Optimize model weights using `compute_grpo_loss()` while penalizing KL divergence from reference model.

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.
HARDWARE & SYSTEM REQUIREMENTS

NVIDIA H100, 8x A100 (80GB VRAM), or vLLM Cluster Inference Setup