Skip to main content

Welcome to a Grasp lesson

Create a free account to keep studying and create your own study path.

Lesson 54

Rule-Based Rewards for Verifiable Tasks

Recommended resources

Introduction

Welcome back. In our previous lesson, we conducted a deep dive into the GRPO objective function, breaking down the roles of the clipped importance ratio and the KL divergence penalty. You now have a solid grasp of the mathematical mechanics that drive the policy update.

Today, we shift our focus from the how to the why. Our learning outcome is to explain why tasks with verifiable correctness, such as mathematics and code generation, are especially suited to rule-based rewards in Group Relative Policy Optimization (GRPO).

We will explore two key concepts: "verifiable correctness" and "rule-based rewards." You will learn how the synergy between these concepts and GRPO's design allows it to sidestep the most difficult and expensive parts of traditional reinforcement learning, leading to a more efficient and stable training process for reasoning models.



The Challenge: Defining a "Good" Response

In reinforcement learning, the central challenge is to provide a numerical reward signal that accurately reflects the quality of a model's output.

For open-ended, subjective tasks like writing a poem or summarizing a document, there is no single "correct" answer. To train a model on such tasks, we typically rely on Reinforcement Learning from Human Feedback (RLHF). This involves collecting vast amounts of data where humans have compared different model outputs and indicated their preferences. A separate reward model is then trained to mimic this human judgment. This process is slow, expensive, and the resulting reward model is only an approximation of true quality.

But what if a task has a clear, objective, right-or-wrong answer? This is where a more direct and powerful approach becomes possible.


Verifiable Correctness and Rule-Based Rewards

A special class of problems, which includes mathematics, logic, and code generation, exhibits verifiable correctness. This means two conditions are met:

  1. An objective ground truth exists (e.g., the solution to a math problem, the expected output of a program).
  2. A cheap, automated program, called a verifier, can deterministically check if a model's output matches the ground truth.

This allows us to replace the complex, learned reward model with a simple, programmatic rule-based reward function. Instead of estimating what a human might prefer, the verifier provides a factual, binary reward: 1 if the answer is correct, 0 if it is not.

Let's begin by exploring this paradigm, often called Reinforcement Learning with Verifiable Rewards (RLVR).

RLVR Beyond Math and Code

This blog post provides a precise explanation of RLVR and contrasts it with traditional RLHF. It's an excellent starting point for understanding the concepts.

Please read the sections 'How RLVR Actually Works (Without the Hand-Waving)' and 'Why RLVR Breaks Outside Math and Code'. Pay close attention to the diagrams contrasting RLHF and RLVR, and the three conditions listed for when RLVR works beautifully.

As the article highlights, RLVR works beautifully for math and code precisely because a verifier can provide an unambiguous reward signal. Let's see how this is applied in practice.

DeepSeek's GRPO (Group Relative Policy Optimization) | Reinforcement Learning for LLMs

This video segment explains how the concept of verifiable correctness translates directly into a reward signal for a reasoning task.

Watch from 03:05 to 04:22, and then from 06:31 to 07:11. Notice how the narrator explains that for reasoning tasks, there is a 'deterministic way of figuring out whether the model was correct,' and how this leads to a binary correctness signal (a reward of 1 or 0) at the end of the generation.

While a binary reward is the simplest form, these rule-based functions can also incorporate other heuristics, such as checking for correct output formatting.

The Illustrated GRPO: Group Relative Policy Optimization Explained

To make this even more concrete, let's look at how a real-world implementation might structure its rule-based rewards.

Read the text under 'Step 3: Calculate Rewards and Advantages' and the section 'Reward Functions'. This shows a practical example where the reward is a weighted sum of an 'accuracy_score' (from the verifier) and a 'format_score' (checking for structure).



The Perfect Match: Why GRPO Thrives on Verifiable Tasks

Now we can address the core question: why is GRPO the perfect algorithm for this setup? The synergy arises from two key aspects.

1. Eliminating the Critic Network

In traditional policy gradient methods like PPO, determining how to update the policy is difficult. The algorithm needs to know if the reward received for an action was better or worse than expected. This "expectation" is provided by a critic (or value) network, which is trained to estimate the expected future reward () from any given state. Training this critic is notoriously difficult, computationally expensive (it's often as large as the policy model itself), and a major source of instability.

With a rule-based verifier, the reward signal is not an estimate; it is a deterministic fact. We know the ground-truth value of a completed output with certainty.

GRPO is designed to exploit this. It completely eliminates the critic network. Instead of comparing the received reward to a learned value estimate, it compares the rewards of several different outputs generated for the same prompt. The "advantage" is simply how much better or worse a given output's reward is compared to the average reward of the group.

This is the central reason why GRPO is so well-suited for verifiable tasks: the verifier provides a perfect reward signal, which allows GRPO to use a simple, stable, and efficient group-relative comparison instead of a complex and unstable critic network.

PPO vs. GRPO Algorithm Comparison
This diagram clearly illustrates the key architectural difference between PPO and GRPO. PPO (top) requires four models, including a trained Value Model to estimate the advantage. GRPO (bottom) dispenses with the Value Model entirely, computing advantages directly from the rule-based rewards of a group of outputs. This simplification is possible precisely because the rewards from verifiable tasks are deterministic facts, not estimates.

2. Handling Sparse Rewards

While the reward from a verifier is perfect, it is also sparse. For a long, multi-step math problem, the model only receives a single reward signal at the very end. It gets no feedback on which of its intermediate reasoning steps were correct or incorrect. This is a classic credit assignment problem in reinforcement learning. If the final answer is wrong, should the model reduce the probability of the entire reasoning chain, even if 99% of it was correct?

This is where the "noisy feedback" nature of RL becomes a challenge, and it's why the conservative update mechanisms in the GRPO objective function (which you studied in the last lesson) are so critical.

The ONLY DeepSeek GRPO/PPO video you'll EVER need (with examples and exercises) | RL Foundations

A reward signal that only comes at the end, while accurate, presents a major challenge for any RL algorithm. This video explains this fundamental issue of sparse feedback beautifully.

Watch from 20:29 to 25:39. The speaker does an excellent job explaining why sparse feedback makes RL 'fundamentally more noisy than supervised learning'. This will clarify why an objective function like GRPO's, with its conservative update mechanisms (clipping, KL penalty), is necessary even when the reward signal itself is perfect.

As the video explains, blindly penalizing an entire sequence for one small mistake can be very harmful. GRPO's design—combining group-relative advantage calculation with the clipped surrogate objective and a KL penalty—is tailored for this exact scenario. It allows the model to gently explore different reasoning paths to find those that lead to a final correct answer, without being catastrophically derailed by a single mistake in an otherwise promising attempt.



Conclusion

In this lesson, we've connected the mechanics of GRPO to the nature of the tasks it excels at. You can now explain the profound synergy between the algorithm and the problem domain.

Key Takeaways:

  • Tasks with verifiable correctness (e.g., math, code) allow for cheap, deterministic rule-based reward functions (verifiers) that provide a perfect, factual reward signal.
  • This perfect reward signal eliminates the need for a critic/value model, which is the most complex, expensive, and unstable component of traditional RLHF algorithms like PPO.
  • GRPO is specifically designed to operate without a critic, using efficient group-relative reward comparisons instead. This makes it an ideal algorithmic match for verifiable tasks.
  • The reward signal in these tasks is often sparse (all-or-nothing at the end). GRPO's conservative update mechanisms (clipping and KL divergence) are well-suited to learning effectively and stably from this type of sparse but accurate feedback.

Preview of the Next Lesson:

Now that we understand the powerful combination of GRPO and rule-based rewards, we'll examine how this is put into practice in a full training pipeline. In the next lesson, we will explore the DeepSeek-R1 "cold start" phase, where the model is first fine-tuned on chain-of-thought data to initialize the capacity for structured reasoning, preparing it for the main GRPO training stage.