Reasoning Models, DeepSeek R1 and RLVR with GRPO
Test-time scaling and the reasoning era
Before Sept 2024, models were fast but not very accurate. A prompt went in and the answer started instantly. Scaling meant more data, more GPUs, bigger models.
Test-time scaling - give the model more compute while it answers, not only while it trains. -> New scaling axis
- The model thinks internally (chain of thought, CoT) before the final answer
- More inference resources means better performance, so it also follows scaling laws
- OpenAI o1 (Sept 2024): AIME math 15% (GPT-4o) -> 83% (o1)
- OpenAI hid the raw CoT, fearing reverse engineering. It showed only a summary.
- Only two things were public: reinforcement learning and long chains of thought. No algorithm, no data.
- Trade-off: more thinking tokens, higher cost, slower, more latency
- Easy question (capital of France): any non-reasoning model is enough
- Hard question (Codeforces-style coding): needs reasoning
Example
System 1 vs System 2. System 1 is fast and intuitive: capital of India. System 2 needs deliberate thought: 44 x 11 = 484. Reasoning models behave like System 2.
DeepSeek R1-Zero vs R1
DeepSeek R1 - open-source equivalent of o1. 671B parameter MoE model. It published the full recipe, so every company could copy it.
| R1-Zero | R1 | |
|---|---|---|
| Pipeline | Base model -> RL | Base -> cold-start SFT -> GRPO -> rejection sampling -> final RL |
| Purpose | Science experiment | Production, user-facing |
| SFT | None | Yes (few thousand Q&A examples) |
R1-Zero used only two simple rewards.
- Accuracy reward - is the final answer correct? Yes or no (binary signal).
- Format reward - thinking inside think tags, answer inside answer tags.
Aha moment - mid-answer the model says something like 'wait, let me re-evaluate' and restarts its reasoning. It emerged after about 8,000 steps of training. Most people would have stopped at 2,000-6,000.
- Reasoning emerged from simple rewards. It is not just memorization.
- Problems of RL on a base model: language mixing (Chinese/English in one answer), because no reward enforced English
- Broken structure: leaked or unclosed tags, hanging output. Poor user experience.
- Base knowledge was lost since RL ran only on math, code and reasoning
RLVR: verifiable rewards
RLVR (Reinforcement Learning with Verifiable Rewards) - can you check the reward deterministically with a program? If yes, no reward model is needed.
- Math: final answer matches ground truth
- Code: all test cases pass
- JSON: it parses
- Format: response contains think and answer tags
| RLHF | RLVR | |
|---|---|---|
| Reward source | Learned reward model | Verifier program |
| Signal | Continuous (0.57, 0.58...) | Binary (1 or 0) |
| Training data for reward | Needed (human preferences) | Not needed |
| Ambiguity | Subjective, approximate | None |
| Limit | Works broadly | Only verifiable domains |
Does not work for creative writing, open conversation or anything with no ground truth.
Typical reward functions: format reward gives a small bonus (e.g. +0.1) if the response contains think open and close tags. Correctness reward gives a large bonus if the extracted final answer matches ground truth.
Format reward is a small nudge. Correctness is the main signal the model learns from.
Does RL add knowledge? Sampling efficiency
Pass@k - give the model k attempts at a question and check whether at least one is correct.
- A hard question solved by the RL model in 1 try can often also be solved by the base model within many tries (e.g. 256)
- So RL helps the model find what the base model already knows, faster. -> Sampling efficiency
- Claim: RLVR can only improve what the base model can already do
- Opposing camp: RL also brings new knowledge or behaviour
- Both sides still argue this
GRPO: Group Relative Policy Optimization
PPO recap: ratio of current to old policy, times advantage, clipped between 1-epsilon and 1+epsilon. Advantage - how much better this answer is than average.
The Problem
- PPO needs a value model (predicts expected reward from a state) to compute advantage
- That is a whole extra trained model. A 7B model could need about 60 GB of memory.
The Solution
- Skip the value model. Estimate advantage by comparing responses.
- For one question, generate G responses (e.g. G = 8)
- Score each with the verifier
- Take the mean and standard deviation of the rewards
- Advantage of a response = how far above or below the group average
The loss averages over the G responses (1/G summation) using the PPO-style clipped ratio times advantage, minus a KL penalty term (beta) against the reference model.
- Intuition: reward responses above average, punish those below average
- Over many steps the policy shifts toward correct reasoning paths
- Reference model plus KL penalty - anchor that stops the policy drifting too far or being exploited
| PPO | GRPO | |
|---|---|---|
| Models needed | Policy, reference, reward, value | Policy and reference, plus verifier function |
| Advantage from | Value model | Group mean and std |
| Reward type | Any | Best for verifiable rewards |
| Compute and hyperparameters | Higher | Lower; groups run in parallel |
If group size G is 2 or 3, the mean and std are noisy, so the advantage is unreliable. Use a larger group.
RLVR + GRPO fit well: GRPO needs many fast reward evaluations, and verifiers are cheap. Most open reasoning models now use a variant of GRPO.
Hands-on: GRPO on a tiny model fails
Setup: GSM8K math data, a system prompt that demands reasoning then a final answer, and several programmatic reward functions (no reward model).
- Rewards: correctness, integer answer, strict format, soft format, XML tag count
- The 135M model rambled for 60-500 tokens, never used the reasoning tags, never got the math right
- So every reward was 0, loss 0, no gradient. Nothing to learn from.
RL needs some successful samples to reinforce. A model too small to produce the format gets zero signal. Use a 1.5B model or larger.
Glossary
- Test-time scaling
- Spending more compute at inference so the model thinks before answering.
- R1-Zero
- DeepSeek model trained with RL only on a base model, no SFT.
- RLVR
- Reinforcement learning where rewards come from a programmatic verifier.
- GRPO
- Group Relative Policy Optimization: PPO-like RL that estimates advantage from a group of sampled responses.
- Advantage
- How much better a response is than the average response for the same question.
- Pass@k
- Chance that at least one of k sampled answers is correct.
- Value model
- Extra model in PPO that predicts expected reward, used for advantage.
- KL penalty
- Penalty keeping the policy close to the reference model.