Boosting small-model token efficiency through GRPO (Reinforcement Learning)

November 2026

Previously I built a transformer-based Language Model from scratch. With the recent focus on token efficiency I wanted to see if we could reduce token usage without significant loss in performance via reinforcement learning (RL).

image

Though there's already work on rewarding shorter correct solutions and using prompts to control response length, I wanted to see how much RL could buy us beyond simply asking the model to be concise -- particularly when answers were already fairly short (~150 output tokens per answer).

I trained two versions of OLMo 1B from the same checkpoint, rewarding one for correctness alone and the other both correctness and brevity, then evaluated both on GSM8K.

image

With the same prompt emphasizing conciseness, the brevity-incentivized model used ~12% fewer output tokens per answer on average (127 vs 144) with GSM8K accuracy 0.6 percentage points lower.

What does RL get us?

When we pre-train a model, what we get is something that can make intelligent next-token predictions from a broad base of knowledge.

Post-training is how we turn this into a useful tool that can solve downstream tasks.

image

Apart from instruction tuning and alignment, a big component of post-training is reinforcement learning (RL), where we reinforce the model's correctly-generated answers through rewards to improve its performance in a specific domain.

The key difference: with pre-training our model learns through self-supervised learning -- guessing the single next-token as a prediction, and checking the actual next-token as the known "answer".

image

In RL, we move one layer of abstraction up: instead of single token we grade a whole trajectory of tokens, for which we don't necessarily have the right answer, but a reward function that scores our response.

image

We then use this feedback to make the tokens in higher-scoring responses more likely.

Reasoning models: unlocked

One of the most consequential applications of this trajectory-reinforcement is the creation of reasoning models.

By teaching models to use <think> and <answer> tags and work through intermediate steps, each generated step becomes context for the next, giving the model a scratchpad to break down and solve problems they would struggle to answer directly.

image

We then score the final answer and reinforce the successful trajectories. This lets the model learn useful ways of chaining steps together without requiring us to supply a worked solution.

image

You can think of the extra tokens as giving the same model more compute for a given problem, with RL helping it learn how to turn that compute into better answers.

How we prompt

We'll use the zero-shot DeepSeek R1-Zero prompt that starts the assistant with an open <think> tag:

Though another approach would be using few-shot prompting with some question-answer pairs to provide the model some examples:

Model and datasets

We'll be using the GSM8K dataset for training and validation, which contains a collection of fairly easy grade school mathematical reasoning word problems:

{
"question": "Natalia sold clips to 48 of her friends in April, and then she sold half as many clips in May. How many clips did Natalia sell altogether in April and May?",

"answer": "Natalia sold 48/2 = <<48/2=24>>24 clips in May.\nNatalia sold 48+24 =<<48+24=72>>72 clips altogether in April and May.\n#### 72"
}

For the model, we'll use OLMo-2-0425-1B, a base model pre-trained on OLMo-mix-1124 (mostly DCLM-Baseline) and mid-trained on Dolmino-mix-1124, a mixture containing ~50% DCLM and 50% instruction following, STEM paper, code, wiki data etc.

Why we used OLMo 1B instead of our previously-trained model

I originally wanted to use the model we trained previously, but in order for RL to work we need at least some successful trajectories.

And the datasets we used to train our model (OpenWebText and TinyStories) were likely not enough to gain the mathematical ability for even minimal correct answers from GSM8K.

image

We could've found a math-heavy pre-training dataset or used a much easier task, but I thought it better to just use OLMo 1B and focus on our RL experiment at hand with a realistic dataset.

image

OLMo also had the additional benefit of being a small-scale model that was trained on a very large amount of tokens relative to its parameter count (4 trillion tokens, so 4000x the parameter count), enabling reasonable RL results with our chosen dataset at small scales.

Grading Function

A key difference between regular pre-training and RL is the existence of a grading function.

image

In RL we're not just seeing whether our guess of a single token is correct, we're measuring whether the semantic meaning of our entire token sequence is correct -- the grading function is what converts this semantic meaning to a score.

An example grading function

One such example of a grading function is the following:

image

A deterministic function that extracts the math question's answer using string manipulation, and determines correctness of answer and format, assigning points for each.

But not all RL graders have to be deterministic -- some could use human preference or trained AI judges:

image

Policies are weights, actions are tokens

In reinforcement learning, a policy takes in a state, which then outputs an action.

In language models, the state is the current text prefix, each action is a token, and the policy is the model's probability distribution over the next token.

image

Updating the model's weights changes this policy.

Policy gradients let us hill-climb varying reward functions

If you recall, a key part of model training is the ability to compute gradients so we can adjust our parameters and ultimately minimize loss.

Similarly, a policy gradient is an RL algorithm that tells us how the expected reward changes with the model's parameters -- with our goal being to change the policy so responses generated by it earn higher rewards on average.

image

One of the crucial discoveries enabling RL is that we can differentiate the model's probability of producing a reward output weighted by its reward, rather than the reward function itself.

This is huge because it means the reward function can be almost anything:

image

If this weren't true, we'd be constrained to reward functions that were themselves differentiable.

But as long as we can evaluate the reward numerically and compute gradients of the model's log probability, we can use anything we want: step functions, randomization, etc.

The math explained

We're trying to maximize expected reward:

image

And thanks to the log-derivative trick, we can rewrite the gradient as:

image

^ notice that we never need to differentiate through the reward function itself

The credit assignment problem

The catch is that rewards only say whether a response was successful.

They don't specify which tokens caused that success, creating the "credit assignment problem".

image

This is why the following become important:

  • variance reduction
  • baselines
  • advantages
  • GRPO

But the fundamental insight is: we can train a differentiable neural network against a completely non-differentiable objective by using rewards to weight gradients of its sampling probabilities.

From policy gradients to GRPO

The policy gradient we derived above gives us a simple training loop:

  1. Have our model generate a solution
  2. Grade it
  3. Use the reward to weight the gradient of the solution's log probability
image

This is the essence of the REINFORCE policy gradient -- with a 1 for correct and 0 for wrong, a correct solution gets reinforced while a wrong one contributes nothing.

Group Relative Policy Optimization (GRPO)

But say we have eight attempts at the same math problem and two are correct, then the average reward is 0.25 -- the two correct attempts scored 0.75 above average, and the six misses scored 0.25 below.

We can use these differences as weights -- pushing the model toward the successful attempts as well as away from the misses.

This relative score is the advantage.

image

Using other attempts at the same question to estimate it is the idea behind Group Relative Policy Optimization (GRPO).

In Standard GRPO we also divide by the group reward's standard deviation -- the rationale here is to normalize learning for stability, but as we'll see in the next section this makes less sense given our brevity objective.

Rewarding correctness and brevity

Each training update starts with 32 questions × 8 attempts per question, giving us 256 solutions.

With the correctness-only reward, if all eight of our math problem attempts are correct, each earn a score of 1 -- subtracting the group average means every advantage is zero, so that question contributes nothing to this update.

image

But what if one solution took 100 tokens and another 400? The model still gets no signal about which to favor.

We can change this by modifying the reward to:

image

where:

  • c is 1 if the grader can extract the correctly formatted answer and verify it against GSM8K (and 0 otherwise)
  • L counts every token generated up to our 512-token cap, so a correct 100-token solution earns 0.961, while a correct 400-token solution earns 0.844.

A problem can still use the full token budget and earn 0.8 for getting the math right.

image

Remember the division by standard deviation in Standard GRPO?

Suppose all eight answers are correct. Four correct answers use 100 tokens each.

If the other four use 103 tokens, the shorter answers earn a small reward advantage.

If they other four use 400 tokens, that advantage is 100 times larger.

image

But the standard deviation of the eight rewards also grows by a factor of 100, so dividing by it gives the shorter answers roughly the same training weight in both cases.

We want saving 300 tokens to count for more than saving 3 tokens, so we drop the standard deviation division after subtracting the group average.

How much weight for each token?

We've now completed Step 1: getting one advantage per solution.

But the model made 100 token choices to produce one solution, and 400 to produce the other.

image

How much weight should that advantage give each token in the solution?

This is Step 2.

Remember from the policy-gradient section that we train on the log probability of what the model generated.

For a whole solution, that means adding up the log probabilities of its tokens.

image

Standard GRPO divides that sum by the solution's length, then multiplies by its advantage -- this division is called sequence normalization.

Sequence Normalization = shorter answers get more weight per token

Take the 100-token and 400-token solutions from above. To see what the divisor alone does, suppose both have an advantage of +1.

Each token in the shorter solution gets a weight of 1/100, versus 1/400 in the longer one.

image

This sounds useful for encouraging brevity, but the same arithmetic applies when both advantages are -1: now each token in the shorter solution gets four times the penalty.

Instead, let reward cook

In Step 1, we subtracted the group mean and skipped the standard deviation division so saving more tokens could earn a proportionally larger advantage.

Now in Step 2, we can divide each solution's token sum by a constant 512 (our maximum response length) instead of the solution's token length, so tokens with the same advantage get the same weight regardless of their length.

image

Together this is the Dr. GRPO variant -- which for our purposes lets the reward control how much we value saving tokens, and the divisor apply that signal consistently per token.

We'll use this variant in both our experiment runs.

A longer answer still contributes more tokens, but two tokens with the same advantage get the same weight.

The following table shows the difference between algorithm variants related to our choices:

Variant
Step 1: How do we get each solution’s advantage?
Step 2: What divides the sum of its token log probabilities?
Standard GRPO
Subtract the mean reward of the eight attempts, then divide by their reward standard deviation
The solution’s actual length
GRPO Constant
Same as standard GRPO
A fixed length, here 512
**Dr. GRPO **
Only subtract the mean reward of the eight attempts, no division.
A fixed length, here 512

On-policy RL Algorithm Variants

Here's a full table of all the different on-policy variants (we'll cover off-policy later).

All five of these variants answer the same question:

"how should we weight successful and unsuccessful reasoning trajectories when updating the model?"

Variant
Core idea
Why it exists
Problem
1. GRPO (standard)
Compare responses to their group mean; divide by group standard deviation; average tokens within each response
Stable, normalized learning
Averaging gradients within each response makes individual tokens in long answers contribute less
2. GRPO Constant
Same as GRPO, but divide total token gradients by a fixed constant
Avoid giving short responses disproportionately high per-token weight
Gives longer responses more influence
3. Dr. GRPO
GRPO Constant divides advantages by standard deviation, this removes it<br><br>Idea is groups with small SD can receive amplified advantages even tho that variation doesn't necessarily more learning<br><br>Dr. GRPO argues this normalization unnecessarily distorts the original objective of maximizing expected reward
Remove normalization bias and stay closer to the original expected-reward objective
4. RFT (Expert Iteration)
Reinforce only correct responses; ignore incorrect ones
Simpler, supervised-style learning from successful attempts
Wasteful when successes are rare and doesn't discourage failed trajectories
5. MaxRL
Subtract group mean, then divide by group mean instead of standard deviation
Give harder questions relatively more weight
Risks excessive weighting of diffiicult questions and unstable estimates when the mean reward is very small

Walking through a training update

Let's put our new policy to work.

We'll take 32 GSM8K questions, give our model eight attempts at each, then turn those 256 solutions into one update to the model's weights.

image

One policy, two GPUs: vLLM and HuggingFace

For this, we'll use two GPUs:

  1. one to run inference to generate our 256 solutions
  2. the other for training updates

A single GPU can do both jobs if there's enough memory, but for this experiment it seemed simpler to give each job it's own GPU.

We'll use RunPod workers with two NVIDIA A40 GPUs (48 GB each), keeping a trainable copy of our model in Hugging Face Transformers on one, and a copy in vLLM on the other so it can use its memory/KV cache for efficient inference.

image

To ensure we're always sampling from the updated policy, we'll copy the latest training weights to vLLM before generating each batch.

Once we have our 256 attempts, we'll grade them, and use the token IDs vLLM returns to count exactly how many tokens each answer cost. Then we'll subtract the mean reward for each group of eight, giving us the advantage for each answer.

Which tokens count?

The grader can read <answer>72</answer> and tell us the math is right, but to train on that answer we need the probability our model assigned to each token it chose.

But our training function only receives the prompt and response as text.

So we need to create a helper function that tokenizes the text answers, with the assumption this will get us the same outputted token IDs that vLLM would've spat out.

image

Then we get the log probabilities for each token ID, and using those with the reward of this answer we can calculate the gradients for the weights using teacher forcing.

Teacher forcing

Suppose vLLM generated tokens A B C. During training, we feed that fixed sequence into the model and ask:

  • Given the prompt, what probability does the model assign to A?
  • Given the prompt + A, what probability does it assign to B?
  • Given the prompt + A + B, what probability does it assign to C?

This is called teacher forcing -- we supply the tokens and score them without sampling, computing all these probabilities in one forward pass.

image

We recompute them in the training model because we need a computation graph for backpropagation -- numbers returned by vLLM alone don’t provide that gradient path.

Turning our 256 answers to a model update

We've graded 32 questions x 8 attempts = 256 answers.

For each answer, we now have:

  1. one advantage from comparing its reward with other attempts at the same question
  2. one log probability per generated token from the forward pass above

Let's put these together so the optimizer knows which answers to make more likely.

Take two different three-token answers, suppose their tokens happen to have the same log probabilities [-1, -2, -3] with answer advantages of -2 and +1:

First answer:   -2 × [-1, -2, -3] = [ 2,  4,  6] = Sum of 12
Second answer:   1 × [-1, -2, -3] = [-1, -2, -3] = Sum of -6

The sums are weighted log probabilities.

To get the loss our optimizer minimizes, we add up the sums for all 256 answers, flip the sign (so we can minimize the loss), and divide by the fixed 256 x 512 from the Dr. GRPO section.

image

We can do the arithmetic in either order (since every token in an answer shares one advantage) -- the table multiplies then sums, and the code vice-versa:

weighted_log_probs = sum(
    answer.advantage * answer.token_log_probs.sum()
    for answer in batch
)
loss = -weighted_log_probs / (256 * 512)

This gets us the scalar we need to backpropagate.

A quick note on policy-gradient loss

Note: This is the policy-gradient loss, a weighted negative log-likelihood, but it isn't a straightforward measure of model quality like with cross-entropy loss.

image

It derives most meaning once we take the gradient, and is just something we use to get the gradient form:

  • Cross-entropy: measures how much probability the model assigns to the target tokens.
  • This policy-gradient loss: tells the optimizer how to adjust probabilities for the sampled answers, based on their advantages.

Its main purpose is to produce useful gradients.

To judge whether RL is improving the model, we primarily track reward and evaluation accuracy, rather than expecting this loss to steadily decrease across training batches.

PyTorch internals: how can we backprop on a scalar?

A question I initially had was: how can backpropagation work after averaging -- don't we lose information when compressing to a scalar?

It works because the scalar is still attached to the computation graph, we haven't discarded the calculations that produced it:

image

Technically we could backprop from multiple outputs if we specify how to weight their contributions, but a scalar loss makes that choice explicit:

"Adjust the weights to reduce this particular combination of the individual losses"

Key: It's the expression used to compute the scalar, not the numerical value alone, that makes the weighting explicit

image

In our case it's equal-weighted since we're taking an average across the total number of tokens/answers.

image

tl;dr - the computation graph is preserved when we return scalars and tensors, this is what lets us calculate gradients.

Fitting 256 answers on one GPU via microbatches

The computation graph we just described takes up GPU memory.

To backpropagate, PyTorch keeps intermediate values from the forward pass -- if we score all 256 answers at once, we have to keep those values around for all 256.

Our training GPU (a RunPod NVIDIA A40) has 48 GB of VRAM.

In our first batch, padding all 256 prompt-and-answer pairs together would give us 712 token positions per sequence, each needing a 4-byte log probability for each of our model's 100k vocabulary entries.

image

This tensor alone would take 73 GB before counting the model or anything else needed for backpropagation, exceeding our GPU's memory.

But we can make the same update using much less memory by processing eight answers at at time -- each chunk is a microbatch.

image

For each microbatch, after we calculate each answer's advantage using the eight attempts at its question, run the forward pass, sum its advantage-weighted token losses and divide by the full-batch divisor of 256 x 512 -- now call .backward().

PyTorch adds that microbatch's gradients to the gradients already stored on the model parameters and can release the intermediate values from that forward pass.

image

This works because the gradient of a sum is the sum of the gradients, we keep the weights fixed while all 32 microbatches contribute, then call optimizer.step() once, giving us 32 backward passes and one model update.

This way we only need room on the GPU for eight answers' worth of intermediate values at a time.

Then we sync the updated weights to vLLM and generate the next batch.

What to track during training

We're almost ready to run our experiment, but before we do so let's consider what a loss of zero would tell us.

Suppose our model gets every question wrong -- every reward is zero, every advantage is zero, and the loss is zero too.

If all eight attempts follow similar paths, sampling eight times buys us little variety.

To see how much room the model has to try different continuations, we log token entropy -- this looks at the whole next-token distribution.

image

While it's useful for monitoring how much room we have for continuations, for the experiment itself we'll primarily track GSM8K accuracy and output tokens per answer.

Entropy vs Perplexity

Entropy - how uncertain the model is about its own next-token predictionsPerplexity - how surprised the model is by the actual tokens in the dataset

Example of entropy:

image

In GRPO we monitor entropy to track exploration and possible policy collapse.

In pre-training we monitor validation perplexity to track predictive accuracy on held-out text.

image

Getting our model to baseline

The final thing we need is a model with a decent enough win-rate.

Before we can reward our model for finding a shorter solution, it has to find a correct one often enough to learn from.

image

If all eight attempts at a question are wrong, all eight get zero advantage regardless of length.

So to both gauge and improve our base model (as well as end-to-end check our training loop), we'll give base OLMo 50 steps of correctness-only RL.

Baseline Run

Before training: Let's sample one answer for each of the 1,024 GSM8K evaluation questions.

  • OLMo follows the required format 63% of the time, but only 1 answer out of 1,024 passes the correctness grader.
image

Step 1 - watching the run live in Weights & Biases.

Step 7 - Still not a single rewarded answer, that's 1,792 attempts and a gradient of zero throughout.

Step 8 - one of the 256 answers finally earns a reward and the gradient norm moves from zero to 0.16, we've got our first signal for the optimizer.

image

Step 10 - we're still at 1/1024 on evaluation.

Step 18 - Rewarded answers are appearing more often now: updates 16, 17, and 18 each had at least one, with two in update 17. All three produced nonzero gradients. The update-20 validation will show whether accuracy is starting to improve.

image

Update 19 produced 4 correct answers out of 256 (1.56%), compared with the zero-reward batches at the start. The gradients remain finite.

Step 20 - 2/1,024 correct (1.17%), up from 1/1,024 (0.10%) initially.** Format compliance also rose to 69.6%.

Qualitative Changes: Some newly correct answers show a meaningful change in the reasoning:

  • On the sausage question, OLMo now adds the 38 chicken and 44 fish sausages to get 82, rather than stopping at 44
  • On the banana question, it now carries the monthly total of 700 through to 1,400 for two months.
image

Step 30 - Validation reached 188/1,024 correct (18.36%)

Qualitative: The sampled correct answers now include sound multi-step arithmetic -- e.g. computing both coaches' shopping totals before subtracting them, and combining two jobs' earnings before calculating a savings shortfall.

image

Step 36 - recent training batches around 23-29% correct.

Step 40 - Validation is at 339/1024 correct (33.11%), up from 18.36% at Step 30. Required-format compliance is also up to 90.23%.

Step 50 - Final validation reached 363/1024 correct (35.45%), versus 1/1024 (0.10%) before training.

Accuracy improved at every measured checkpoint after update 10, but format compliance dipped from 90.23% at update 40 to 87.11% at update 50, so not every metric improved monotonically.

image

Learning started after sparse rewards, held-out performance improved, and rollouts improved meaningfully.

Running our token efficiency RL experiment

With a solid baseline of performance achieved, we'll use this Step 50 checkpoint as the basis for both our control and experimental group for our token efficiency experiment since we'll get more correctness signal out of it.

At 150 tokens per answer, our baseline is already fairly concise, let's see how much room is left.

We'll start two copies of the checkpoint, and train each for 100 more Dr. GRPO updates, using the same prompt and pool of training questions.

image

The control will use the correctness-only reward, the experimental group will use the reward we designed above, where shorter correct solutions earn more and every wrong answer still earns zero.

Our token efficiency run

Step 0 - Both copies have identical weights and average 139 tokens, and due to variance control scores 35.4% and brevity scores 33.9%.

Step 10 - At first checkpoint, the control averages 137 tokens per answer at 40.0% accuracy.

  • The brevity model averages 119 tokens at 39.1%, that's already 13% fewer tokens -- but this could still largely be due to variance.

Step 20 - Brevity answers grow to 133 tokens, still below the control's 147. Brevity model also now scores slightly higher on accuracy, 41.5% vs 40.2%.

Step 30 - The length gap shrinks to four tokens, 135 vs 139.

  • Brevity accuracy drops to 39.0% while control reaches 41.3%

Step 40 - Accuracy is almost tied, 40.6% vs 40.7%, while the brevity model uses 126 tokens vs 130.

image

Step 50 - The brevity model gives its shortest answers so far, 117 tokens vs 142 for control. Accuracy is 40.6% vs 42.2%.

Step 90 - Brevity answers are back up to 153 tokens, only about five shorter than control.

Step 100 - The first pair finishes at 150 tokens and 41.9% accuracy for brevity, against 156 tokens and 48.4% for control

Replicating with prompt changes

Let's run two more matched pairs from the same baseline and evaluate all six final checkpoints with three sampling seeds each.

This time, we'll also add a "concise" prompt to each model's prompt asking for only the essential calculations:

Use concise reasoning: include only the essential calculations, avoid repetition, and keep the required answer format.

This lets us measure what one instruction buys, and what training adds under that same prompt.

Our results

Evaluation prompt
Training reward
Mean output tokens
GSM8K accuracy
Original
Correctness
153.7
44.22%
Original
Correctness + brevity
137.4
43.76%
Concise
Correctness
143.7
43.35%
Concise
Correctness + brevity
126.6
42.77%

Using a concise prompt saves about 10 output tokens per answer on the control.

With that same concise prompt, rewarding brevity saves another 17.1 tokens (11.9%). All three training seeds produce shorter answers.

Even among the 2,789 paired attempts where both models get the answer right, the average falls from 115 tokens to 99.

image

Accuracy averages 0.58 percentage points lower with the brevity reward under the concise prompt.

So what did we get out of this?

Asking the model to keep it short already helped. But even with that instruction, giving it a little extra credit during training for a short, correct solution brought the average answer down from 144 tokens to 127.

We saw shorter answers in all three runs.

image

Even on problems both models solved, the one trained for brevity used fewer tokens on average.

For every 1,000 answers like these, that's about 17,000 fewer tokens to generate. But the brevity-trained model also got about six fewer answers right per 1,000 in our tests.

image

For a lab serving millions of requests, the interesting question is where those extra tokens earn their keep. On an easy problem it might just restate the arithmetic, on a harder one it might be where the model catches a mistake.

As RL plays an increasing role in model capabilities, I expect more and more model quality to depend evals -- i.e. what can we reliably grade? Figuring out what deserves a reward, and how to assign credit all become giant research problems in their own right at scale.

Off-policy variants - scaling beyond two GPUs

Our two GPUs took turns -- while vLLM generated 256 answers, the training GPU waited. While the trainer updated the model, vLLM waited for new weights.

But imagine running this loop at a frontier lab -- hundreds of GPUs could be generating answers in parallel while waiting for updates, how would we handle this?

image

One way is to let generations keep running while the trainer learns from completed groups of answers.

Suppose a worker generates an answer with version 10 of the model. By the time the trainer uses it, the model is on version 11.

image

The math is still just as right or wrong, what's changed is how likely version 11 would be to come up with that answer.

Learning from answers sampled by a different policy is what makes this off-policy.

How much should an older answer count?

Remember the token log probabilities we calculated earlier?

Suppose version 10 gave a token a 10% chance, and version 11 gives it a 40% chance after the same prefix -- a 4x difference.

image

At that prefix, the current model would choose this token four times as often -- this gives us a reason to weight the old observation by four.

But suppose version 11 is also 4x less like to reach that prefix in the first place -- those changes now cancel. The prefix followed by this token is overall just as likely under either model.

image

This is what token-level correction misses, the model that generated the answer also chose the path that got it there.

To account for the whole answer, multiply the ratios for all generated tokens:

image

That corrects the distribution mismatch in expectation, assuming the old policy can sample every answer the current one can.

But the catch is variance -- if each of 100 tokens is just 1.1 times as likely under the new model, the whole answer gets a weight of 1.1^100 = 13,781, meaning in a batch of 256 one answer could dominate the update.

image

Proximal Policy Optimization (PPO)

Suppose our token from above came from an answer that scored well -- version 10 gave the token a 10% chance, version 11 already gives it a 40% chance -- how much more should this one successful answer encourage the trainer to push that probability up?

image

This is where Proximal Policy Optimization (PPO) steps in, a policy-gradient algorithm that lets us take several training steps on a batch of answers we've already generated.

After the first step, those answers come from an older version of the model (much like the answers arriving from our generation workers).

Gradient Clipping

The clipped version of PPO uses the old probabilities as a reference to limit how much each example can gain from moving further in the direction its advantage favors.

Take a clipping threshold of 20%, for our above-average answer, this token stops earning extra credit once it becomes 1.2 times as likely. Starting from 10%, that happens at 12%.

image

The model can still assign it 40%, but PPO still uses only 1.2 as the multiplier on the answer's positive advantage, which means this token contributes 0.6 to the policy loss on an advantage of 0.5.

Clipped GRPO borrow this rule and uses the group advantage we calculated earlier from the eight attempts at each question.

Group Sequence Policy Optimization (GSPO) moves clipping up to the level where we graded the answer, using the geometric mean of the token ratios and clips once per answer.

Remember how 100 ratios of 1.1 gave us a sequence ratio of 13,781? Taking the 100th root brings it back to 1.1 before clipping, keeping the weight manageable on long answers at the cost of giving up the exact full-sequence correction.

image

An overview of the different approaches:

Approach
What it buys us
Trade-off
No reweighting
Simplest update
Older samples can bias the gradient.
Token ratios
Adjusts for each choice at the observed prefix
Leaves the shift in which prefixes we reach uncorrected.
Full sequence ratio
Corrects for the likelihood of the entire answer
A few answers can carry enormous weights.
Clipped GRPO
Limits the incentive to keep pushing individual token probabilities
Clipping adds bias to stabilize updates.
GSPO
Uses one length-normalized, clipped ratio per answer
Gives up exact reweighting for a less variable weight.

All this to say: our small-scale experiment provided a nice foundation for exploring different RL algorithms and reward functions, but extrapolating to scale reveals the depth of remaining challenges as LLMs develop into maturity -- with RL likely to play an increasingly important role.