1. The ideaModern frontier AI models synthesize media via straight-line Ordinary Differential Equations (Rectified Flow Matching) and learn complex reasoning behaviors through group-normalized relative advantage reinforcement learning (DeepSeek-R1 GRPO). These mathematical breakthroughs replace complex diffusion SDEs with deterministic velocity vectors and eliminate the need for separate Value critic networks.
DPO pushes the chosen answer's log-ratio above the rejected one's, directly on the policy, with no reward model to train. 2. The mathRectified Flow Matching Straight-Line Trajectory
x t = ( 1 − t ) x 0 + t x 1 ⟹ Target Velocity v t ( x t ) = d x t d t = x 1 − x 0 x_t = (1-t) x_0 + t x_1 \implies \text{Target Velocity } v_t(x_t) = \frac{d x_t}{dt} = x_1 - x_0 x t = ( 1 − t ) x 0 + t x 1 ⟹ Target Velocity v t ( x t ) = d t d x t = x 1 − x 0 Straight probability path connecting pure Gaussian noise x_0 to clean data point x_1.
Flow Matching Least-Squares Objective
L RFM ( θ ) = E t ∼ U ( 0 , 1 ) , x 0 ∼ p 0 , x 1 ∼ p 1 [ ∥ v θ ( x t , t ) − ( x 1 − x 0 ) ∥ 2 2 ] \mathcal{L}_{\text{RFM}}(\theta) = \mathbb{E}_{t \sim \mathcal{U}(0,1), x_0 \sim p_0, x_1 \sim p_1} \left[ \|v_\theta(x_t, t) - (x_1 - x_0)\|_2^2 \right] L RFM ( θ ) = E t ∼ U ( 0 , 1 ) , x 0 ∼ p 0 , x 1 ∼ p 1 [ ∥ v θ ( x t , t ) − ( x 1 − x 0 ) ∥ 2 2 ] Neural network v_θ directly learns the constant velocity vector field along the ODE trajectory.
Direct Preference Optimization (DPO) Closed-Form Objective
L DPO ( θ ) = − E ( x , y w , y l ) [ log σ ( β log π θ ( y w ∣ x ) π ref ( y w ∣ x ) − β log π θ ( y l ∣ x ) π ref ( y l ∣ x ) ) ] \mathcal{L}_{\text{DPO}}(\theta) = -\mathbb{E}_{(x, y_w, y_l)} \left[ \log \sigma \left( \beta \log \frac{\pi_\theta(y_w|x)}{\pi_{\text{ref}}(y_w|x)} - \beta \log \frac{\pi_\theta(y_l|x)}{\pi_{\text{ref}}(y_l|x)} \right) \right] L DPO ( θ ) = − E ( x , y w , y l ) [ log σ ( β log π ref ( y w ∣ x ) π θ ( y w ∣ x ) − β log π ref ( y l ∣ x ) π θ ( y l ∣ x ) ) ] Directly solves the constrained RL problem without training a separate reward model or critic.
DeepSeek-R1 Group Relative Policy Optimization (GRPO) Advantage
A i = r i − mean ( { r 1 , … , r G } ) std ( { r 1 , … , r G } ) + ϵ J GRPO ( θ ) = 1 G ∑ i = 1 G min ( π θ ( o i ∣ q ) π old ( o i ∣ q ) A i , clip ( π θ ( o i ∣ q ) π old ( o i ∣ q ) , 1 − ε , 1 + ε ) A i ) A_i = \frac{r_i - \text{mean}(\{r_1, \dots, r_G\})}{\text{std}(\{r_1, \dots, r_G\}) + \epsilon} \qquad \mathcal{J}_{\text{GRPO}}(\theta) = \frac{1}{G}\sum_{i=1}^G \min\left( \frac{\pi_\theta(o_i|q)}{\pi_{\text{old}}(o_i|q)} A_i, \text{clip}\left( \frac{\pi_\theta(o_i|q)}{\pi_{\text{old}}(o_i|q)},\ 1-\varepsilon,\ 1+\varepsilon \right) A_i \right) A i = std ({ r 1 , … , r G }) + ϵ r i − mean ({ r 1 , … , r G }) J GRPO ( θ ) = G 1 i = 1 ∑ G min ( π old ( o i ∣ q ) π θ ( o i ∣ q ) A i , clip ( π old ( o i ∣ q ) π θ ( o i ∣ q ) , 1 − ε , 1 + ε ) A i ) Computes relative baseline advantages across group of G sampled rollouts, completely eliminating the Critic model.
▶ Proof Breakdown & Step-by-Step Derivation: Derivation: DPO Closed-Form Policy Representation [Toggle] • In RLHF, the objective with KL penalty is max_pi E_{x, y ~ pi}[r(x, y)] - beta * D_KL(pi(y|x) || pi_ref(y|x)).
• The closed-form analytical solution to this constrained optimization is pi*(y|x) = (1 / Z(x)) * pi_ref(y|x) * exp((1 / beta) * r(x, y)).
• Rearranging yields the exact implicit reward: r(x, y) = beta * log(pi*(y|x) / pi_ref(y|x)) + beta * log Z(x).
• Substitute this implicit reward into the Bradley-Terry preference probability P(y_w > y_l | x) = sigma(r(x, y_w) - r(x, y_l)).
• The partition function terms beta * log Z(x) cancel out exactly, yielding the DPO loss without any reward model. Q.E.D.
3. How it works1
Deterministic Flow Generation
Euler ODE integration dx/dt = v_theta(x, t) generates high-resolution samples in as few as 4-8 steps.
2
Group-Normalized Baseline
GRPO samples G responses for question q and normalizes rewards to create zero-mean advantages.
3
Emergent Long Chain-of-Thought
Pure rule-based correctness rewards (math/code tests) combined with GRPO drive models to self-reflect and verify.
4. The code (python)import numpy as np
def compute_grpo_advantages (rewards: np.ndarray, eps: float = 1e-8 ):
mean_r = np.mean (rewards, axis=-1 , keepdims=True )
std_r = np.std (rewards, axis=-1 , keepdims=True )
advantages = (rewards - mean_r) / (std_r + eps)
return advantages
if __name__ == "__main__" :
sample_rewards = np.array ([
[1.0 , 0.0 , 1.0 , 0.0 ],
[0.8 , 0.9 , 0.2 , 0.8 ]
])
adv = compute_grpo_advantages (sample_rewards)
print ("Computed GRPO Relative Advantages:" )
print (np.round (adv, 3 ))
assert np.allclose (np.mean (adv, axis=-1 ), 0.0 ), "Group mean must be zero!"
print ("✓ Zero-mean baseline normalization verified." ) 5. Check yourselfAnswer all 1 questions correctly to complete the chapter · 0 / 1 done
Q1/1 How does DeepSeek-R1's GRPO eliminate the need for a separate Value (Critic) network during RL fine-tuning?
A. It samples a group of G rollouts per prompt and uses their empirical group mean and standard deviation as the baseline to compute relative advantage. B. It replaces the policy gradient with a supervised cross-entropy loss. C. It assumes all actions have a constant reward of 1.0. D. It runs Monte Carlo Tree Search at every token generation step.
Finished this chapter?
Mark as Complete Weekly newsletter
The Epoch Zero newsletter What changed in ML architectures this week: new models worth knowing, benchmark moves, and one architecture explained in plain words. Free, once a week, unsubscribe anytime.