Sebastian Raschka's GRPO Tutorial Lifts Qwen3-0.6B to 47% on MATH-500
The practical detail that GRPO needs no reward model or critic — a SymPy verifier and group-relative ranking replace both — makes frontier-style reasoning training feasible on a single consumer GPU. Practitioners building small reasoning models can follow the five-step training loop directly, though they should watch for the overtraining collapse Raschka documents at 400 steps. The series is free on his YouTube playlist.
Sebastian Raschka (@rasbt) published episode 6 of his 'Build A Reasoning Model (From Scratch)' video series, covering RLVR (Reinforcement Learning with Verifiable Rewards) and a pure PyTorch implementation of GRPO.
Training the Qwen3-0.6B base model with SymPy-based answer verification raised its MATH-500 accuracy from 15.
2% to 47%, nearly matching Qwen's official reasoning model at 48.2%.
The average output length grew from 79 to 586 tokens, and untrained self-correction behaviors such as 'wait, I made a mistake' emerged spontaneously.
He notes practical constraints: the setup needs about 15GB of VRAM with 4 rollouts of 512 tokens, overtraining past 400 steps degraded accuracy to 30%, and the KL penalty term is often unnecessary for math tasks.
Build A Reasoning Model (From Scratch) 系列来到了第 6 讲「用 GRPO 做可验证奖励的强化学习」 作者 @rasbt 前面 5 讲(推理时扩展、自一致性、自我修正)都不改模型权重,今天第一次真正训练模型:用纯 PyTorch 从零实现 GRPO 算法,把 Qwen3-0.6B 基础模型的 MATH-500 准确率从 15.2% 提升到 47%,几乎追平 Qwen 官方推理模型的 48.2%。 视频系列更新: youtube.com/playlist?list=… 只训最终答案。RLVR 只按答案对错给奖励(对1错0),<think> 里的中间推理只算 log 概率、不打分。一是防止模型学会写“漂亮的假推理”来应付监控,二是 R1 论文实证过程奖励无用。由此自发涌现 "aha moment":模型没被教过自我修正,却会说“等等,我算错了”然后回溯重算。强模型推理链变短不是藏思考,是不需要,如同数学专家打的草稿比新手少。 RLVR 的本质优势是删模型。RLHF(PPO)需要人工标注、训练并运行一个昂贵的奖励模型,外加一个 Critic;RLVR 用 SymPy 验证器判对错,几乎零成本。GRPO 的巧思是用组内相对比较替代 Critic,又省掉一个跟主模型一样大的模型。 算法本体(厨师类比:顾客点单=提示,多道菜=rollouts,点赞点踩=奖励,组内相对排名=优势,厨师风格=策略,老菜谱=参考模型防跑偏)。代码五步:采样 rollouts(须用 no_grad 而非 inference_mode,且保留 EOT 终止符防止答案越写越长)→ SymPy 判奖励(缺 \boxed{} 格式判0分)→ 算优势 (r−均值)/标准差,全对全错时为0即不学习,是刻意设计 → 算序列 log 概率(token 级 vs 序列级本质是超参数,GSPO 用后者,DAPO 用前者)→ 损失 −mean(优势×log概率),标准 PyTorch 循环训练。 结果:Qwen3-0.6B 基座从 15.2% 提到 47%,几乎追平官方推理模型的 48.2%,代价是平均输出从 79 token 涨到 586。三条教训:过训会崩(400步跌到44%,再训到30%),须靠下一讲的 clip 和 KL 修正;4 rollouts × 512 token 约需 15GB 显存,rollouts 至少保 4 个;KL 项非必需,数学模型去掉它常常反而更好。 Sebastian Raschka @rasbt Reasoning from scratch, round number 6! An introduction (and implementation) of Reinforcement Learning with Verifiable Rewards (RLVR) and Group Relative Policy Optimization (GRPO). 00:00 Introduction 01:54 What makes a reasoning model different? 04:25 Reasoning traces and model capability 08:29 Accuracy and format rewards 11:34 Aha moments and DeepSeek-R1 training 14:41 Reasoning effort and answer length 18:38 RLHF and RLVR 23:04 GRPO vs. PPO 26:40 GRPO explained with a cooking analogy 31:43 The KL term and simplified GRPO 35:04 Loading the pretrained model 36:07 Loading the MATH training data 39:26 Sampling model responses 46:30 Computing verifiable rewards 49:55 Computing advantages 51:54 Token and sequence log probabilities 55:29 Implementing sequence log probabilities 57:37 Fixing the inference-mode error 1:02:24 Computing the GRPO loss 1:04:37 Putting the GRPO step together 1:09:19 The GRPO training loop 1:12:57 Training settings, logging, and checkpoints 1:17:24 Running training and inspecting outputs 1:19:28 Loading and evaluating checkpoints 1:22:33 MATH-500 results and training stability 1:24:05 Memory requirements and next steps
This report is categorized under AITOP's "How-to" desk, focusing on US frontier AI labs and Silicon Valley technology leaders. Within our cross-regional analytical framework, it directly maps to AI developer toolchains, coding agents, and engineering workflows. Key entities and technical topics under continuous tracking include GRPO, Qwen3, RLVR, DeepSeek-R1.
Source attribution: curated from shao__meng (@shao__meng).