# Reinforcement Learning for Reasoning: RLVR and GRPO

> Since o1 and DeepSeek-R1, making a model think longer before answering has become the main line of post-training. Why verifiable rewards (RLVR) can replace a reward model, how GRPO drops the value model, and the recipe and pitfalls of R1-Zero and R1.

- URL: https://dmxsf.com/en/wiki/post-training/reasoning-rl/
- [DMXSF](https://dmxsf.com/en/about/)
- Advanced
- Updated: 2026-11-17
- Tags: Reasoning, Reinforcement learning, DeepSeek, Alignment

## After this page you will be able to

- Say why making a model think longer became the main line of post-training, and why reinforcement learning rather than more SFT.
- Explain why verifiable rewards (RLVR) can replace a reward model.
- Compute GRPO's group-relative advantages by hand, say how they remove the value model, and read the implementation of the loss.
- Tell the training pipelines of DeepSeek-R1-Zero and R1 apart, and say what distillation adds.
- Name the common pitfalls and open problems of reasoning RL.

## From "answering fast" to "thinking long"

In September 2024 OpenAI released o1: before answering, the model generates a long internal thought process, and its accuracy on math, programming and science problems improved markedly. In January 2025 DeepSeek open-sourced DeepSeek-R1 and published the training method and details: **the core is using reinforcement learning to teach a model to generate long chains of thought.**

This differs from [chain-of-thought prompting](https://dmxsf.com/en/blog/chain-of-thought-prompting/) in that prompting says "please think step by step" at use time, whereas a reasoning model has this behavior **trained** into its own habits: it breaks the problem down, tries things, checks, and starts over when it finds a mistake.

A simplified example:

```text
Question: Solve x² − 5x + 6 = 0.

<think>
Try factoring first: I need two numbers whose product is 6 and whose sum is −5, which are −2 and −3.
So (x − 2)(x − 3) = 0, which gives x = 2 or x = 3.
Let me verify: for x = 2, 4 − 10 + 6 = 0, which holds; for x = 3, 9 − 15 + 6 = 0, which also holds.
</think>

Answer: x = 2 or x = 3.
```

The "let me verify" part is **self-checking** behavior that reinforcement learning produced, and nobody taught it line by line.

## Why reinforcement learning instead of more SFT

Teaching reasoning with SFT needs a large amount of high-quality "worked solutions" as demonstrations. Writing such data is expensive and slow, and the model can at best reach the level of the demonstrator, because what it learns is **imitation**.

Reinforcement learning takes a different approach: tell the model only **whether the final answer is right**, and let it explore how to think in between. Ways of thinking that earn reward are reinforced, and useless ones are weeded out. What the model learns is a strategy that works for itself, not limited to the solutions humans wrote.

## RLVR: verifiable rules as the reward

The RLHF of the [previous page](https://dmxsf.com/en/wiki/post-training/preference-optimization/) relies on a [reward model](https://dmxsf.com/en/wiki/post-training/reward-models/), which is only an approximation of human preferences and is easy for the policy to exploit. For tasks like math and code, where **answers can be checked automatically**, you can skip the reward model entirely and score with rules. This is **RLVR** (Reinforcement Learning with Verifiable Rewards, a name introduced by Tülu 3):

| Task | Verifiable reward |
| --- | --- |
| Math | The final answer matches the reference answer (extract the answer from an agreed format first, then compare) |
| Code | The generated program passes the unit tests |
| Format | Whether thinking and the answer use the agreed tags and format |
| Instruction following | Whether checkable constraints hold, such as "at most 50 words" or "contains a given keyword" |

A minimal math verifier:

```python
import re

def math_reward(response: str, gold: str) -> float:
    """Verifiable reward: the answer goes in \\boxed{} and earns 1 point only if it matches the gold answer."""
    match = re.findall(r"\\boxed\{([^}]*)\}", response)
    if not match:
        return 0.0                 # the required format is missing
    return 1.0 if match[-1].strip() == gold.strip() else 0.0
```

In practice you should use a more robust check of mathematical equivalence (for example with SymPy or a dedicated verification library) instead of simple string equality; otherwise $\tfrac{1}{2}$ and `0.5` would be judged as different answers.

The strengths of RLVR are that the reward is **objective, cheap and can be generated at scale**, and it is harder to game. The limits are just as clear: it only works in domains that can be verified automatically; the reward is sparse (a very long chain of thought ends in a single right or wrong); and flaws in the verifier itself will be exploited by the policy too.

## GRPO: policy optimization without a value model

PPO needs a **value model** as large as the policy to estimate a baseline for each state and thus compute advantages. When training a large model, this means an extra copy of parameters, activations and optimizer states.

**GRPO** (Group Relative Policy Optimization, from DeepSeekMath) does something neat: for the same prompt it samples **a group** of $G$ answers $o_1, \dots, o_G$ from the current policy, gets each reward $r_1, \dots, r_G$ from the verifier, and uses **the mean reward of the same group** as the baseline:

$$
\hat A_i = \frac{r_i - \mathrm{mean}(r_1, \dots, r_G)}{\mathrm{std}(r_1, \dots, r_G)}
$$

Answers with a reward above the group mean get a positive advantage and are reinforced; those below the mean get a negative advantage and are suppressed. The baseline comes from the same batch of samples, so no value model is needed. Why a group mean still gives a gradient in the same direction, why it differs from RLOO by exactly a factor of $(G-1)/G$, and the difficulty bias that dividing by the standard deviation adds are checked against exact expected gradients in [Reinforcement Learning Basics](https://dmxsf.com/en/wiki/post-training/rl-fundamentals/).

*Figure: One GRPO update: the reward comes from a verifiable rule (is the answer correct), and the advantage comes from comparing answers within the same group.*

With the advantages in hand, the objective reuses PPO's clipped form and adds a KL penalty directly to the loss:

$$
\mathcal{J}(\theta) = \mathbb{E}\left[\frac{1}{G}\sum_{i=1}^{G}\frac{1}{|o_i|}\sum_{t=1}^{|o_i|}\Big(\min\big(\rho_{i,t}\hat A_i,\ \mathrm{clip}(\rho_{i,t},\,1-\varepsilon,\,1+\varepsilon)\,\hat A_i\big) - \beta\,\mathbb{D}_{\mathrm{KL}}\big[\pi_\theta \,\|\, \pi_{\text{ref}}\big]\Big)\right]
$$

Here $\rho_{i,t} = \dfrac{\pi_\theta(o_{i,t} \mid q, o_{i,<t})}{\pi_{\theta_{\text{old}}}(o_{i,t} \mid q, o_{i,<t})}$ is the probability ratio of the new and old policy at token $t$. **All tokens within one answer share the same advantage** $\hat A_i$, because the reward is given only once, at the end of the answer.

### A few advantages by hand

```python
import torch

def group_advantages(rewards, eps=1e-4):
    """rewards: [num_prompts, G]; one row holds the G samples of one prompt."""
    mean = rewards.mean(dim=1, keepdim=True)
    std = rewards.std(dim=1, keepdim=True)
    return (rewards - mean) / (std + eps)

rewards = torch.tensor([
    [1., 0., 0., 1.],   # half correct
    [1., 0., 0., 0.],   # only one correct
    [1., 1., 1., 1.],   # all correct: no learning signal
])
print(group_advantages(rewards))
# tensor([[ 0.8659, -0.8659, -0.8659,  0.8659],
#         [ 1.4997, -0.4999, -0.4999, -0.4999],
#         [ 0.0000,  0.0000,  0.0000,  0.0000]])
```

Three things are worth noting:

1. When half are correct, a correct answer gets an advantage of about $+0.87$; but when **only one is correct**, that rare success gets a larger advantage of $+1.5$, and the model learns from it more strongly.
2. When the whole group is correct or the whole group is wrong, all advantages are 0 and **this prompt gives no learning signal in this round**. So training needs problems of moderate difficulty: too easy or too hard wastes compute.
3. The advantage is **relative**, so the scale of the reward does not matter; only the relative quality within the group does.

### Implementing the loss

```python
def grpo_loss(logp_new, logp_old, logp_ref, advantages, mask, eps_clip=0.2, beta=0.04):
    """logp_*: [B, T] per-token log-probabilities; advantages: [B]; mask: [B, T] (1 on the response part)."""
    ratio = torch.exp(logp_new - logp_old)
    adv = advantages.unsqueeze(1)
    surrogate = torch.min(ratio * adv, torch.clamp(ratio, 1 - eps_clip, 1 + eps_clip) * adv)
    # k3 estimator: an unbiased, non-negative estimate of KL(π_θ || π_ref)
    log_ratio_ref = logp_ref - logp_new
    kl = torch.exp(log_ratio_ref) - log_ratio_ref - 1
    per_token = surrogate - beta * kl
    per_seq = (per_token * mask).sum(dim=1) / mask.sum(dim=1)   # average by length within each answer
    return -per_seq.mean()
```

The whole training loop boils down to four steps:

```python
for step in range(num_steps):
    prompts = sample_prompts(dataset, batch_size)
    outputs = policy.generate(prompts, num_samples=G)         # 1. sample G answers per prompt (usually with an engine such as vLLM)
    rewards = verifier(prompts, outputs)                       # 2. score with the verifier
    advantages = group_advantages(rewards.view(-1, G))         # 3. normalize within the group to get advantages
    loss = grpo_loss(...)                                      # 4. compute the GRPO loss and update the policy
```

## DeepSeek-R1-Zero and DeepSeek-R1

The DeepSeek-R1 paper offers the most complete public recipe so far (see the [paper explainer](https://dmxsf.com/en/blog/deepseek-r1-reasoning-via-reinforcement-learning/)). It contains two models.

### R1-Zero: pure reinforcement learning

DeepSeek-R1-Zero starts from the base model DeepSeek-V3-Base and does **no SFT at all**, running large-scale reinforcement learning with GRPO directly. There are only two kinds of rule-based rewards:

- **Accuracy reward**: whether the math answer is correct and whether the code passes its tests.
- **Format reward**: whether the thinking is placed between `<think>` and `</think>`.

The paper deliberately **uses no neural reward model**, on the grounds that it is easy to game in large-scale reinforcement learning. Several striking phenomena appeared during training:

- On AIME 2024, pass@1 rose from 15.6% to 71.0% (86.7% with majority voting); methods like majority voting that spend more compute at inference are covered in [Test-Time Compute](https://dmxsf.com/en/wiki/frontier/test-time-compute/).
- The response length kept growing with training steps: the model spontaneously learned to "think longer".
- Self-checking and backtracking appeared; the paper shows an "aha moment" in which the model writes "Wait" midway and re-examines its earlier approach.

But R1-Zero also has clear problems: poor readability and frequent mixing of Chinese and English.

### R1: multi-stage training

To get a model that is both strong and readable, DeepSeek-R1 uses four stages:

| Stage | What is done | Purpose |
| --- | --- | --- |
| 1. Cold-start SFT | Fine-tune the base model on several thousand long chain-of-thought examples | Make the output more readable and give RL a better starting point |
| 2. Reasoning-oriented RL | Train with GRPO on math, code, logic and similar tasks, with an extra "language consistency" reward | Improve reasoning and reduce language mixing |
| 3. Rejection sampling + SFT | Rejection-sample from the stage-2 model to get about 600,000 reasoning examples, add about 200,000 general examples, and fine-tune again on about 800,000 in total | Restore general abilities such as writing and question answering |
| 4. All-scenario RL | Train another round with rule rewards (reasoning tasks) and a preference reward model (helpfulness, harmlessness) at the same time | Align with human preferences |

The final DeepSeek-R1 reaches a pass@1 of 79.8% on AIME 2024 and 97.3% on MATH-500, on par with OpenAI o1-1217 at the time. The rejection sampling in step 3 is a bootstrap: keep only the samples with correct answers and train on them. Why it works, and when it stops working, is covered in [Synthetic data and self-improvement](https://dmxsf.com/en/wiki/frontier/synthetic-data-and-self-improvement/).

### Distillation: teaching reasoning from a big model to small ones

DeepSeek also used the roughly 800,000 examples above to run SFT on Qwen and Llama models from 1.5B to 70B, producing a series of distilled models. An important conclusion of the paper is: **for small models, distilling from a strong model works better than running large-scale reinforcement learning on the small model directly**, which costs more compute and performs worse.

## Practical points and common pitfalls

**Training recipe:**

- **Pick the right base.** The base model needs some reasoning ability of its own; otherwise nearly all sampled answers are wrong, the advantage of every group is 0, and reinforcement learning cannot get started.
- **Filter for problems of moderate difficulty.** Sample each problem a few times with the base model and keep the problems whose pass rate is neither 0% nor 100%.
- **Group size $G$.** Common values are between 8 and 64: the larger the group, the more stable the advantage estimate, but the higher the sampling cost.
- **Keep the reward as simple as possible.** Correctness plus format, and small extras such as language consistency or a length penalty if needed.

**Signals to monitor:** mean reward, mean response length, KL divergence, policy entropy, and pass@1 and pass@k (for the unbiased estimator and its error, see [The Statistics of Evaluation](https://dmxsf.com/en/wiki/evaluation/eval-statistics/)).

**Common pitfalls:**

| Problem | Symptom | Usual remedy |
| --- | --- | --- |
| Verifier flaws | The model finds ways to score without solving, such as blind guessing, exploiting the format or tampering with the tests | Strengthen the verifier and inspect the highest-reward samples |
| Length blow-up | Answers get longer and longer, are truncated or repeat endlessly | Set a maximum length and handle over-long answers separately |
| Entropy collapse | The policy becomes uniform too early and stops exploring | Raise the upper clipping bound and the sampling temperature |
| Language mixing | Several languages appear in the thinking | Add a language-consistency reward |
| Gradient bias | Averaging by length penalizes long wrong answers less | Adjust how the loss is normalized |

The community has made many improvements around these GRPO issues. DAPO proposed a looser upper clipping bound (Clip-Higher), dynamic sampling (filtering out prompts that are all correct or all wrong) and a loss averaged per token instead of per answer; Dr. GRPO points out that GRPO's length normalization and standard-deviation normalization introduce bias, and provides a debiased version. GSPO changes the unit of the importance ratio and clipping from tokens to whole responses, which helps most with MoE models (see the [paper breakdown](https://dmxsf.com/en/blog/gspo-group-sequence-policy-optimization/)).

### Check the reward before comparing training recipes

The [spring CS336 reasoning RL assignment](https://cs336.stanford.edu/#assignments) starts with prompting baselines and reward checks before comparing GRPO settings. [Berkeley Scalable AI's third spring assignment](https://scalable-ai.eecs.berkeley.edu/S2026/assets/assignment_3.zip) puts SFT and RL with verifiable rewards into one pipeline. For self-study, keep three checkpoints: base, post-SFT, and post-RL. Compare format compliance, answer accuracy, and output length with the same template, decoding budget, and held-out problems.

Start with hand-checked grader fixtures. Include equivalent answers in different forms, wrong answers in the expected format, and correct answers outside that format. Track format and correctness rewards separately so that learning a delimiter cannot masquerade as improved reasoning. If training reward diverges from held-out accuracy, inspect reward parsing, problem difficulty, and length distributions before comparing optimizer settings.

### Measure generation, grading, and updates separately

The [Berkeley Scalable AI lecture on NeMo RL](https://scalable-ai.eecs.berkeley.edu/S2026/assets/lecture_slides/lecture_16_2.pdf) separates generation, interactions with environments, and training. Start with a synchronous loop on one machine. Freeze a policy, sample a batch with its original token log probabilities, grade each trajectory in the environment, update on the batch, and publish the updated weights. Record the generation policy version, tokenization and sampling settings, tasks, and grader version for each trajectory.

At scale, long answers can hold up generation, external environments can hold up grading, and the learner can sit idle waiting for a batch. Record wait and active time, generated tokens, usable trajectories, and discard reasons at each stage. If higher sampling concurrency produces more trajectories but the learner accepts a smaller share, inspect timeouts, grading, and queues. Overlapping sampling and updates asynchronously can also widen the gap between policy versions. The stored log probabilities must come from the behavior policy that produced the trajectory. For algorithms that limit policy lag, log the version gap and compare synchronous and asynchronous configurations under the same training budget on held-out tasks.

## Open questions

- **Is reinforcement learning creating new abilities, or digging out what the base model already has?** Some work (Yue et al., 2025) finds that for large $k$ the pass@$k$ of the base model is no worse than that of the RL-trained model, which suggests RLVR mainly raises the probability of "getting it right in one sample" and does not necessarily widen the range of problems the model can solve. This is still debated.
- **What about tasks that cannot be verified?** Writing and open-ended question answering have no reference answer and can only use a reward model or an AI judge, which brings back the old problem of reward hacking (how bad overoptimization gets is simulated on the [Reward Models](https://dmxsf.com/en/wiki/post-training/reward-models/) page).
- **Overthinking.** The model produces long thinking even for simple questions and wastes compute. How to make it "think on demand" is an active research direction.
- **The trade-off between inference-time and training compute.** Reasoning models shift compute from training to inference; see "a new scaling dimension" in [Scaling Laws](https://dmxsf.com/en/wiki/pretraining/scaling-laws/).

## Summary and exercises

**Key points of this page:**

1. Reasoning models use reinforcement learning to turn "think before answering, and check yourself" into the model's own behavior, no longer relying on human-written worked solutions.
2. RLVR uses rules that can be checked automatically (answer correctness, passing tests, format) as the reward: objective and cheap, but only for verifiable tasks.
3. GRPO samples a group of answers for the same prompt and uses the group mean reward as the baseline, which removes the value model.
4. R1-Zero shows that pure reinforcement learning can elicit long chains of thought; R1 balances ability, readability and generality through a cold start, rejection sampling and multi-stage training.
5. Small models are better off distilling from a strong model, and verifier quality, problem difficulty, and monitoring of length and entropy decide whether training succeeds.

### Quick self-check

**1. Which of these rewards are "verifiable rewards" (RLVR)? (multiple answers)**

- [x] The final answer of a math problem matches the reference answer
- [x] The generated program passes all unit tests
- [x] Whether the thinking and the answer follow the agreed tags and format
- [ ] A reward model's score of how helpful an answer is
- [ ] A human annotator's preference between two answers

> Verifiable rewards are produced automatically by rules: whether the answer is right, whether the tests pass, whether the format is respected, which is objective and cheap. A reward model and human preferences are only approximations of a good answer, and the former is also easy for the policy to exploit.

**2. What does GRPO save compared with PPO, and what does it use as the baseline?**

- [ ] It saves the reference model and uses the previous policy as the baseline
- [x] It saves the value model and uses the mean reward of a group of answers sampled for the same prompt as the baseline
- [ ] It saves the verifier and uses the reward model as the baseline
- [ ] It saves the KL penalty and uses clipping as the baseline

> PPO needs a value model as large as the policy to estimate the baseline. GRPO samples a group of answers for the same prompt, uses the group's mean reward as the baseline and the group's standard deviation for normalization, so the baseline comes from the same batch of samples. Its loss still keeps the KL penalty and PPO's clipped form.

**3. A group of 8 answers has rewards [1, 0, 0, 0, 0, 0, 0, 0]: only one is correct. Using the sample standard deviation, about what is the advantage of the correct answer?**

- [ ] +0.87
- [ ] +1.50
- [x] +2.47
- [ ] +7.00

> The mean is 0.125 and the sample standard deviation is about 0.354, so the advantage of the correct answer is (1−0.125)/0.354≈+2.47, and each wrong one gets about −0.35. The rarer the success, the larger its advantage, so the model learns from it harder.

**4. All answers in a group get exactly the same reward (say, all correct). What happens in this round?**

- [ ] The prompt's weight is amplified because the model has mastered it
- [x] All advantages are 0, so this prompt gives no learning signal in this round
- [ ] All answers are reinforced
- [ ] Training aborts because the standard deviation is 0

> After subtracting the mean everything is 0, so prompts that are all correct or all wrong waste compute. A common remedy is to pre-sample with the base model and filter out prompts whose pass rate is 0% or 100%, or to use dynamic sampling as DAPO does. (Implementations add a tiny eps to the denominator to avoid dividing by 0.)

**5. What is the main difference between DeepSeek-R1-Zero and DeepSeek-R1?**

- [ ] R1-Zero uses a neural reward model and R1 only uses rule-based rewards
- [x] R1-Zero starts from the base model with no SFT at all and uses GRPO directly; R1 adds cold-start SFT, rejection sampling and multi-stage training to improve readability and general ability
- [ ] R1-Zero is a small distilled model and R1 is the original large model
- [ ] R1-Zero beats R1 on AIME

> R1-Zero's reward consists of just two kinds of rules, accuracy and format; R1 only adds a preference reward model for general tasks in its fourth stage, so the first option has it backwards. R1-Zero showed that pure reinforcement learning can elicit long chains of thought, but its output is hard to read and mixes Chinese and English, so R1 uses four stages, reaching a pass@1 of 79.8% on AIME 2024, higher than R1-Zero's 71.0%.

**6. What does the paper conclude for small models?**

- [ ] Large-scale reinforcement learning directly on a small model beats distillation from a strong model
- [x] Distillation from a strong model works better than large-scale reinforcement learning directly on the small model, and costs less compute
- [ ] Small models cannot benefit from reasoning data
- [ ] Distillation and reinforcement learning work equally well

> DeepSeek fine-tuned Qwen and Llama models from 1.5B to 70B with SFT on about 800,000 samples to obtain the distilled models. Large-scale reinforcement learning on the small model itself costs more compute and works worse than distillation.

**Exercises:**

1. A group of 4 answers has rewards $[1, 1, 1, 0]$. Use the formula above to compute the advantage of each answer (use the sample standard deviation).
2. Why does a prompt on which the whole group is correct not help training? How would you handle it to use compute fully?
3. Design a verifiable reward for a "coding problem", and think about how the model might game it.

<details>
<summary>Reference answers</summary>

1. The mean is $0.75$ and the sample standard deviation is $0.5$, so the three correct answers have advantage $(1 - 0.75)/0.5 = +0.5$ and the wrong answer has advantage $(0 - 0.75)/0.5 = -1.5$.
2. All rewards in the group are equal, the standard deviation is 0 and the values after subtracting the mean are also 0, so all advantages are 0 and the gradient carries no signal. You can pre-sample with the base model before training and filter out prompts with a pass rate of 0% or 100%, or do dynamic sampling as DAPO does to fill the batch with effective prompts.
3. You can use "the generated program passes all unit tests" as the reward. Possible loopholes include hard-coding outputs for the test cases, modifying or bypassing the test file, and writing programs that are correct only on some inputs by exploiting incomplete test coverage. Countermeasures are to use hidden test sets, run in an isolated sandbox with restricted permissions, and increase test coverage.

</details>

## Further reading

- DeepSeek-AI, [DeepSeek-R1: Incentivizing Reasoning Capability in LLMs via Reinforcement Learning](https://arxiv.org/abs/2501.12948) (2025)
- Shao et al., [DeepSeekMath: Pushing the Limits of Mathematical Reasoning in Open Language Models](https://arxiv.org/abs/2402.03300) (introduces GRPO, 2024)
- Lambert et al., [Tülu 3: Pushing Frontiers in Open Language Model Post-Training](https://arxiv.org/abs/2411.15124) (introduces RLVR, 2024)
- Yu et al., [DAPO: An Open-Source LLM Reinforcement Learning System at Scale](https://arxiv.org/abs/2503.14476) (2025); [paper breakdown](https://dmxsf.com/en/blog/dapo-open-source-llm-reinforcement-learning-system-at-scale/)
- Liu et al., [Understanding R1-Zero-Like Training: A Critical Perspective](https://arxiv.org/abs/2503.20783) (2025)
- Yue et al., [Does Reinforcement Learning Really Incentivize Reasoning Capacity in LLMs Beyond the Base Model?](https://arxiv.org/abs/2504.13837) (2025)
- Snell et al., [Scaling LLM Test-Time Compute Optimally can be More Effective than Scaling Model Parameters](https://arxiv.org/abs/2408.03314) (2024); [paper breakdown](https://dmxsf.com/en/blog/scaling-llm-test-time-compute-optimally-can-be-more-effective-than-scaling-model-parameters/): spending test-time compute by difficulty, and the FLOPs-matched comparison with a 14x larger model.
- Silver et al., [Mastering Chess and Shogi by Self-Play with a General Reinforcement Learning Algorithm](https://arxiv.org/abs/1712.01815) (AlphaZero, 2017); [paper breakdown](https://dmxsf.com/en/blog/alphazero-mastering-chess-and-shogi-by-self-play/)
- Mnih et al., [Playing Atari with Deep Reinforcement Learning](https://arxiv.org/abs/1312.5602) (DQN, 2013); [paper breakdown](https://dmxsf.com/en/blog/dqn-playing-atari-with-deep-reinforcement-learning/)
- Schulman et al., [Proximal Policy Optimization Algorithms](https://arxiv.org/abs/1707.06347) (PPO, 2017); [paper breakdown](https://dmxsf.com/en/blog/ppo-proximal-policy-optimization-algorithms/)
- Lightman et al., [Let's Verify Step by Step](https://arxiv.org/abs/2305.20050) (2023); [paper breakdown](https://dmxsf.com/en/blog/lets-verify-step-by-step/)
- Ha and Schmidhuber, [World Models](https://arxiv.org/abs/1803.10122) (2018); [paper breakdown](https://dmxsf.com/en/blog/world-models-ha-schmidhuber/): learn a model of the environment first, then train the controller inside its "dream".
- Hafner et al., [Mastering Diverse Domains through World Models](https://arxiv.org/abs/2301.04104) (DreamerV3, 2023); [paper breakdown](https://dmxsf.com/en/blog/dreamerv3-mastering-diverse-domains-through-world-models/): return normalization and twohot regression that let one set of hyperparameters work across domains.
- Chen et al., [Decision Transformer: Reinforcement Learning via Sequence Modeling](https://arxiv.org/abs/2106.01345) (2021); [paper breakdown](https://dmxsf.com/en/blog/decision-transformer-reinforcement-learning-via-sequence-modeling/): another route for offline RL, conditioning a supervised model on the return instead of using a value function or policy gradient.
- Qwen Team, [Qwen3 Technical Report](https://arxiv.org/abs/2505.09388) (2025); [paper breakdown](https://dmxsf.com/en/blog/qwen3-technical-report/): thinking and non-thinking modes in one model, the thinking budget, and strong-to-weak distillation compared with reinforcement learning in GPU hours.
- Zheng et al., [Group Sequence Policy Optimization](https://arxiv.org/abs/2507.18071) (GSPO, 2025); [paper breakdown](https://dmxsf.com/en/blog/gspo-group-sequence-policy-optimization/): moves the importance ratio and clipping from tokens to whole responses, with the paper's gradient formulas checked in code.
- DeepSeek-AI, [DeepSeek-V3.2: Pushing the Frontier of Open Large Language Models](https://arxiv.org/abs/2512.02556) (2025); [paper breakdown](https://dmxsf.com/en/blog/deepseek-v32-pushing-the-frontier-of-open-large-language-models/): the scaled-up GRPO (unbiased KL estimate, off-policy sequence masking, Keep Routing and Keep Sampling Mask), and the K3 estimator's gradient checked by exact enumeration.
- Liu et al., [GDPO: Group reward-Decoupled Normalization Policy Optimization for Multi-reward RL Optimization](https://arxiv.org/abs/2601.05242) (2026); [paper breakdown](https://dmxsf.com/en/blog/gdpo-group-reward-decoupled-normalization-policy-optimization/): summing several rewards before normalizing gives different reward combinations the same advantage; GDPO normalizes each reward first.

- [Rollout and learner scheduling](https://dmxsf.com/en/wiki/post-training/rollout-and-training/)

## Companion code

[Reasoning RL: verifiers, GRPO advantages and loss, and a real RLVR run](https://github.com/dmxsf/dmxsf/tree/main/labs/post-training/reasoning-rl): The verifier, group advantages, the GRPO loss, clipping and the k3 KL estimator checked exactly; then a real RLVR run in which a tiny model is updated from nothing but exact-match 0/1 rewards.

- Run it in the companion repository (add --quick for a fast pass): `uv run dmxsf run post-training/reasoning-rl`
- [View the lab script](https://github.com/dmxsf/dmxsf/blob/main/labs/post-training/reasoning-rl/run.py)
- [Lab write-up](https://github.com/dmxsf/dmxsf/blob/main/labs/post-training/reasoning-rl/README.en.md)
- [`reasoning.py`](https://github.com/dmxsf/dmxsf/blob/main/src/dmxsf/post_training/reasoning.py)
- [Find this lab in the catalog](https://dmxsf.com/en/code/#reasoning-rl)

## FAQ

### What is RLVR (reinforcement learning with verifiable rewards)?

RLVR means doing reinforcement learning with rewards from rules that can be checked automatically, such as whether the final answer to a math problem is correct, whether code passes its unit tests, or whether the output follows the required format. It does not depend on a reward model trained from human preference data, the reward is objective and harder to game, but it only applies to tasks that have a reference answer or can be checked automatically.

### What is the main difference between GRPO and PPO?

PPO needs a value model as large as the policy to estimate the baseline and the advantage. GRPO samples a group of answers for the same prompt and uses the group mean reward as the baseline and the group standard deviation for normalization to get the advantage, so it needs no value model, which clearly reduces memory use and implementation complexity, and suits reasoning tasks where only one final reward is given.

### Why can DeepSeek-R1-Zero learn to reason without any SFT?

R1-Zero starts from DeepSeek-V3-Base and runs large-scale reinforcement learning directly. The pre-training corpus already contains a lot of reasoning and problem-solving text, so the base model has some latent reasoning ability, and the "reward only for correct answers" signal amplifies it and lets the model spontaneously learn longer thinking, self-checking and backtracking. But R1-Zero's output is hard to read and mixes Chinese and English, so R1 adds cold-start SFT data.

### Why are reasoning models more expensive and slower?

A reasoning model generates a long chain of thought before the final answer, so the number of output tokens can be several to dozens of times that of an ordinary model. Cost and latency grow roughly with the number of generated tokens, so it is trading inference-time compute for higher accuracy.
