Skip to Content
Recodocs

08 · Reinforcement learning with a verifier

A program can score a SQL query, so a model can learn from its own attempts. On 483 scorable questions the warm start got 79.5% and two GRPO runs 81.0% and 80.7%, gains of 1.5 and 1.2 points that are within noise of the test's ±3.5-point interval, because most groups of answers had nothing to teach.

23 min read
Part 3
Beyond supervised
Model
Qwen/Qwen2.5-1.5B-Instruct
Data
The SQL splits from lesson 3, with small databases built for scoring
Hardware
One T4, in Google Colab
Open in ColabSaved with the outputs of a GPU run

Lessons 4 and 5 taught the SQL task by imitation: show the model the right query and raise its probability. Imitation has a blind spot, and this lesson's warm-start model shows it. It matches the gold query's text on 67.6% of the 500 test questions, but returns the right result on 79.5% of the 483 questions a program can check, because a correct query can be written many ways. What a user wants is the result. A program can compute that, so the model can be trained on it directly: sample several queries for a question, run each, and push the model towards the ones that beat their own group. That is GRPO (group relative policy optimisation), and the program is the verifier.

The result comes first and the exact setup, time and cost are in How it was built at the end. It is a negative result: both GRPO runs land inside the warm start's noise.

GRPO's gain is within noise: +1.5 and +1.2 points of execution accuracy against a ±3.6 interval

Four systems on the same 500 questions, greedy decoding. Execution is scored on the 483 questions whose gold result is not empty (bars: 95% interval)

1
50%60%70%80%90%100%runsexact matchexecutionoverlaprewardSELECT *%WHEREdropped %answertokensBase, zero-shotno training96.258.460.9 ±4.40.6410.20.025.3Warm start (SFT)2,000 examples98.867.679.5 ±3.60.8060.20.024.8GRPO, overlap reward50 steps98.668.881.0 ±3.50.8200.20.024.8GRPO, strict reward100 steps99.068.480.7 ±3.50.8180.20.024.3
Source: lesson notebook section 5, Colab T4. Shaded band: the warm start's execution accuracy ± 3.6. Exact match is on all 500 questions. Overlap reward, SELECT * and dropped WHERE are the notebook's side measurements of every system, trained on or not.

Others have done this at scale, scoring the answers in different ways:

SourceWhat scores the answerWhat they report
Snowflake, Arctic-Text2SQL-R1 (the same task)A program: 1 if the query's result equals the gold result, 0.1 if it runs, else 0BIRD-dev execution accuracy of the 7B model 63.9 → 68.9, from the supervised checkpoint it started from
DeepSeek-R1-ZeroA rule that checks the final answer; no neural reward modelAIME 2024 pass@1 15.6% → 77.9%
Shopify, SidekickAn LLM judge calibrated on a rubric, as the reward after supervised trainingThe specialised model beats the frontier model; no quality figure is published, and Shopify estimates 96% lower serving cost
Genspark, deep research (served by Fireworks AI)A reward score, not describedReward score 0.65 → 0.82 and tool calls per task 2.86 → 5 for Kimi-K2; a closed model scores 0.76 and 3.74 (vendor-measured)
Harvey, TenetAn LLM judge over an expert rubricRubric scores rise; preference and extraction accuracy do not always follow (section 5)

The rows differ in how far the score can be trusted, and that is the real subject. A program is exact but can be gamed; a judge is flexible but can be fooled. The notebook builds the program, attacks it, trains against it twice, and measures what changed.

1. Why more than SFT

RL can only reinforce what the model already sometimes does. If no sampled answer is ever right, every group scores zero and nothing is learned. So RL starts from a model that is already reasonable, which is why both Arctic-Text2SQL-R1, whose final models start from supervised checkpoints, and DeepSeek-R1, which adds a cold start of supervised examples before RL, put supervised training first. Two conditions decide whether RL is worth trying:

  • a score a program can compute for thousands of samples, with the trust problems of section 2 solved;
  • a model that already succeeds on some questions and fails on others, so that the samples differ.

Lesson 4's misses fit the second condition: wrong aggregates, wrong columns, wrong literals, for a model that gets the neighbouring question right. Whether the model writes the right query on a second try is something its own samples can show.

2. A program as judge

A reward turns an outcome into training feedback. For a query, measure the intended result, not just whether the text appears plausible. Keep the verifier independent of the model producing the candidate.

Execution accuracy compares results, not text. For every question the notebook builds a small SQLite database from the CREATE TABLE statement and from the literals in the gold query: two rows that satisfy every condition, one row per condition that breaks only that condition, and four random rows. The gold query and the model's query both run on it, and their results are compared as multisets of rows (as a list when the gold query has ORDER BY). The model never sees the database.

def build_db(context, gold, seed, n_noise=4):
    """Statements that create and fill a small database for one question."""
    # two rows that satisfy every condition of the gold query, one row per condition
    # that breaks only that condition, and n_noise random rows; the model never sees it

def execute(setup, sql, max_calls=200):
    """Run one query on a fresh copy of the database. Returns (rows, error)."""
    con = sqlite3.connect(":memory:")
    for s in setup:
        con.execute(s)
    # allow reads only: a DROP, INSERT or ATTACH is denied
    con.set_authorizer(lambda action, *a: sqlite3.SQLITE_OK if action in READ_ONLY
                       else sqlite3.SQLITE_DENY)
    con.set_progress_handler(too_long, 1000)   # stops a runaway query
    return con.execute(sql).fetchmany(1000)

The model's SQL is untrusted code, so it runs behind an authoriser that allows reads only: a DROP, INSERT or ATTACH is refused. The gold query scores 1.0 on all 500 databases, which is the minimum a scorer must pass.

Two further rules decide whether the score means anything. First, questions whose gold result is empty are left out of training and of the execution score, because otherwise any query that also returns nothing counts as correct. Of the 500 test questions, 483 return rows on their database, so execution is scored on 483. Arctic-Text2SQL-R1 filters its training data the same way, removing about 1,400 BIRD and 1,700 SPIDER samples whose reference query returns nothing or runs over 5 seconds. Its ablation, on a 14B model, shows what that is worth: adding synthetic training data took BIRD-dev from 64.9 to 64.6 unfiltered, and to 66.5 filtered. Second, the database must make wrong queries return different rows from right ones. Arctic has GPT-4o write INSERT statements until the reference query returns rows; here the rows are built by rule from the schema and the gold literals, which needs no model.

A scorer is software, and software has holes. The notebook attacks it with queries that are wrong in one known way:

A query that ignores the question earns more partial credit (0.83) than the trained model's own answers (0.81)

Each row breaks the gold query one way, or replaces it, on the 483 test questions whose gold result is not empty. Strict reward gives 1 for the same result, else 0; overlap reward gives the share of the gold result's distinct values present

2
Broken queryQueriestriedRun%Accepted by the strict reward, %Mean overlap reward012300.51SELECT 14831000.210.01SELECT * instead of the columns4821001.040.83Drop the WHERE clause46199.82.600.78Flip the first = to !=45099.80.890.44MAX to MIN241000.000.11COUNT to SUM48750.000.00A policy that never reads the question4831000.000.83warm-start model 0.806
Source: lesson notebook, sections 1 and 3, Colab T4. Dashed line: the warm-start model's mean overlap reward, 0.806 (its strict reward is 0.795). The probe answers every question with SELECT * FROM the first table in the schema.

The strict reward is hard to fool. The most it wrongly accepts is 2.60%, for a query with its WHERE clause dropped, which happens when the clause removes no row from that question's small database. The overlap reward, the share of the gold result's distinct values that appear anywhere in the model's result, is the partial credit a designer reaches for first. Its hole is in the last row. A policy that answers every question with SELECT * FROM the first table never reads the question, scores 0.000 on the strict reward, and scores 0.831 on overlap, above the warm-start model's own 0.806. Whether RL finds that hole is section 5. That it exists was measured before any training.

3. The starting point

The base model, zero-shot, writes a query that runs 96.2% of the time, matches the gold text on 58.4% of the 500 questions and returns the gold result on 60.9% of the 483 (±4.4). The warm start is lesson 4's recipe on a quarter of the data: 2,000 examples, LoRA rank 16 on every linear layer, loss on the answer only. It took 3.6 minutes at a peak of 6.61 GB, and scored 67.6% exact and 79.5% on execution (±3.6). Execution moved 18.6 points on a quarter of lesson 4's data.

The adapter is then merged into the weights and saved. That matters for GRPO in TRL: with a LoRA adapter, the reference model for the KL penalty is "the model with the adapter switched off". Leave the warm-start adapter on and the reference becomes the untrained base. After the merge a new adapter is trained on top, and switching it off gives the warm start.

merged = sft.model.merge_and_unload()          # the adapter becomes part of the weights
merged.save_pretrained("sft-merged")
# each GRPO run loads "sft-merged" and trains a NEW adapter on it:
lora = LoraConfig(r=16, lora_alpha=32, lora_dropout=0.0,
                  target_modules="all-linear", task_type="CAUSAL_LM")

The new adapter has 18,464,768 trainable parameters out of 1,562,179,072. Dropout is off because TRL samples answers with the model in training mode, and dropout would make the sampled answers differ from the ones whose probabilities are trained.

4. Learning from groups

For each question the trainer samples a group of G=8G = 8 answers, and the reward gives each a score rir_i. The advantage of answer ii is how far it stands above its own group, in group standard deviations:

A^i=ri−mean⁡(r1,…,rG)std⁡(r1,…,rG)+10−4\hat A_i = \frac{r_i - \operatorname{mean}(r_1, \dots, r_G)}{\operatorname{std}(r_1, \dots, r_G) + 10^{-4}}

Every token of answer ii is pushed by the same A^i\hat A_i. There is no value network: the group mean is the baseline, which is the memory saving over PPO, whose advantages come from a learned critic of the policy's own size. The objective, per token (DeepSeekMath, Eq. 3, with TRL's token normalisation), is

min⁡ ⁣(ρ A^, clip⁡(ρ, 1−ε, 1+ε) A^)−β DKL\min\!\big(\rho\,\hat A,\ \operatorname{clip}(\rho,\,1-\varepsilon,\,1+\varepsilon)\,\hat A\big) - \beta\, D_{KL}

where

ρ=πθ(ot∣q,o<t)πθold(ot∣q,o<t)\rho = \frac{\pi_\theta(o_t \mid q, o_{<t})}{\pi_{\theta_{old}}(o_t \mid q, o_{<t})}

with the per-token estimator DKL=πrefπθ−log⁡πrefπθ−1D_{KL} = \frac{\pi_{ref}}{\pi_\theta} - \log\frac{\pi_{ref}}{\pi_\theta} - 1 keeping the policy near the warm start. Two consequences matter here, and the second is the lesson's central measurement.

One update per batch. The notebook updates once per batch of samples, so πθ=πθold\pi_\theta = \pi_{\theta_{old}} at the moment of the update, ρ=1\rho = 1, and the clip never fires. The logged clip ratio was 0.0 at every step.

Equal scores teach nothing. If all GG answers score the same, every A^i\hat A_i is zero. With a 0/1 reward and kk of 8 correct, the advantages follow from the proportion correct:

A group that is all right or all wrong teaches nothing; a lone success is pushed up 2.47 standard deviations

Advantage of one correct answer (blue) and one wrong answer (orange) in a group of 8 with a 0/1 reward, by how many answers in the group are correct

3
-3-2-10+1+2+302.47-0.3511.62-0.5421.21-0.7230.94-0.9440.72-1.2150.54-1.6260.35-2.4778no onesucceeds:no gradienteveryonesucceeds:no gradientcorrect answers in the group of 8advantage, in group standard deviations
Source: arithmetic, lesson notebook section 3 (standard deviation with n − 1 plus 10⁻⁴, as TRL 0.19.1 computes it). Not a measurement.

A single success in an otherwise failed group is pushed up 2.47 standard deviations and each failure down 0.35. A group of eight right answers contributes nothing, and neither does a group of eight wrong ones. A model that is already good at easy questions fills its groups with identical answers.

The settings the notebook uses, and where they come from:

config = GRPOConfig(
    per_device_train_batch_size=16, gradient_accumulation_steps=4,  # 64 answers per step
    num_generations=8,                  # the group size G; 8 questions x 8 answers = 64
    max_prompt_length=160, max_completion_length=64,
    temperature=1.0,                    # samples must be draws from the policy
    beta=0.04,                          # KL weight, DeepSeekMath's; TRL's default is 0.0
    num_iterations=1,                   # one update per batch of samples
    loss_type="bnpo", scale_rewards=True,   # TRL 0.19.1's defaults, written out
    learning_rate=2e-5, lr_scheduler_type="constant_with_warmup", warmup_steps=5,
    fp16=True, bf16=False, use_vllm=False)

Published runs are far larger. DeepSeekMath trained with a learning rate of 1e-6 and 64 answers per question in batches of 1,024. DeepSeek-R1-Zero used 16 answers for each of 32 questions per step, a KL weight of 0.001, and 10,400 steps. Arctic-Text2SQL-R1 sampled 256 prompts with 16 rollouts each per step. This notebook samples 64 answers per step.

Two later papers changed the recipe, and TRL exposes both fixes. Dr. GRPO (Liu et al., 2025) shows that dividing by answer length rewards short correct answers and penalises long wrong ones less, and that dividing by the standard deviation weights questions that are almost always right or almost always wrong more heavily; loss_type="dr_grpo" and scale_rewards=False remove both. DAPO (Yu et al., 2025) drops groups with no spread and samples more until the batch is full. TRL 0.19.1 does not filter them; it only logs their share as frac_reward_zero_std, which section 6 reads.

5. A tempting reward

The first run trains on the overlap reward. The strict reward is computed for every sampled answer and recorded, but not trained on. If the policy learns what the reward pays for, the overlap reward should rise while the strict score does not, and SELECT * or a dropped WHERE should become common.

def reward(prompts, completions, setup, gold, **kwargs):
    sqls = [clean_sql(c[0]["content"]) for c in completions]
    js = [judge(s, g, q) for s, g, q in zip(setup, gold, sqls)]
    # every score and behaviour is also logged here, so a run can be judged
    # by a score it was not trained on
    return [j[kind] for j in js]        # kind is "overlap" or "strict"

Trained on partial credit, the policy's reward did not climb and no SELECT * answer ever appeared

50 steps with the overlap reward, 8 questions × 8 answers per step; each step sees different questions, so single steps swing with difficulty

4
a Reward on sampled answers0.500.751.0012550overlap (trained on)strictb Behaviours of the sampled answers0%50%100%125500% on every stepwrites SELECT *drops WHEREc Answer length, tokens20253012550First 10 steps → last 10 steps:overlap 0.836 → 0.772strict 0.830 → 0.739SELECT *: 0.000 → 0.000WHERE dropped: 0.000 → 0.000Between 18 and 30 tokens, no drift
Source: lesson notebook section 3, Colab T4. Panel a is smoothed over 5 steps, as the notebook draws it. The strict reward of every sampled answer was recorded but not trained on. SELECT * and a dropped WHERE are counted on the sampled answers.

It did not happen. The overlap reward fell from 0.836 over the first 10 steps to 0.772 over the last 10 and the strict reward fell with it, from 0.830 to 0.739. The two curves sit within 0.04 of each other at every step, so nothing separated what was rewarded from what was true. The step-to-step swings are the questions: each step draws 8 new ones, and a single step's reward ranged from 0.42 to 1.00 in the logged lines. None of the 3,200 sampled answers was SELECT *. The warm start wrote it for one of the 500 test questions, 0.2%, and a behaviour the model never samples cannot be reinforced, because no group ever contains it to rank above its siblings.

On the held-out questions the run scored 68.8% exact and 81.0% on execution, with SELECT * still at 0.2% and no dropped WHERE. It changed 47 of the 483 queries, in both directions. Three of the first six, as the notebook printed them:

What Week 3 has a Week 4 of gina blair?

Gold
SELECT week_3 FROM table_name_95 WHERE week_4 = "gina blair"
Warm start
SELECT COUNT(week_3) FROM table_name_95 WHERE week_4 = "gina blair"
GRPO, overlap reward
SELECT week_3 FROM table_name_95 WHERE week_4 = "gina blair"

Warm start strict 0, overlap 0.00; GRPO strict 1, overlap 1.00. Wrong to right.

What are the total number of points with more than 225 goals and a Goals against of 190?

Gold
SELECT SUM(points) FROM table_name_31 WHERE goals_for > 225 AND goals_against = 190
Warm start
SELECT SUM(points) FROM table_name_31 WHERE goals_for > 225 AND goals_against = "190"
GRPO, overlap reward
SELECT AVG(points) FROM table_name_31 WHERE goals_for > 225 AND goals_against = "190"

Warm start strict 1; GRPO strict 0. Right to wrong: SUM became AVG.

What is the prothrombin time in Von willebrand disease?

Gold
SELECT prothrombin_time FROM table_1557752_1 WHERE condition = "Von Willebrand disease"
Warm start
SELECT prothrombin_time FROM table_1557752_1 WHERE condition = "Von Willebrand disease"
GRPO, overlap reward
SELECT prothrombin_time FROM table_1557752_1 WHERE condition = "Von Willebrand Disease"

Warm start strict 1; GRPO strict 0. Right to wrong: a capital letter in the literal changed.

Of the six printed, three went from wrong to right (two by dropping a COUNT wrapper, one by swapping SUM for AVG), two from right to wrong (SUM became AVG; a capital letter in a literal changed), and one stayed wrong. That is what a small number of noisy updates looks like. It is not a drift towards a hole.

The hole is still there, and the evidence that it gets found at scale is published. DeepSeek-R1's authors avoided neural reward models for R1-Zero because they had seen them exploited during large-scale RL, and their supplementary figure shows it for a helpfulness reward model: over more than 600 steps the reward rose while the policy's pass rate on CodeForces fell. Arctic-Text2SQL-R1's authors keep their reward to three levels because richer designs, which add terms for precision, recall, syntax or n-gram overlap, can in their words invite reward hacking. Harvey reports the professional-scale version for a rubric judge. Training open-weight models on an expert rubric raised the rubric score, but for two of the models a proxy for lawyer preference was not different from a coin flip, and extraction F1 on the CUAD contract benchmark fell by 2.4 to 9.4 points across the five models; the reward had no length penalty, and output length grew in four. The rule they all arrive at is this lesson's: compare runs by a score they were not trained on.

A verifier can also pay for how an answer ends, not only what it says. NVIDIA's document parser scores sampled extractions on content, on producing a usable structure, and on finishing without generating the same content again and again. Against the same model after supervised fine-tuning alone, its development run cut outputs flagged as looping from 126 pages to 29 and outputs that hit the 9,000-token limit from 185 to 35, while the overall score rose from 66.24 to 71.38 (NVIDIA, 2026; company-reported, development checkpoints). A SQL answer is short enough that this lab never needed such a term; a long structured output usually does.

A binary verifier can grade a task correctly and still give group-relative training no signal. If every attempt passes, or every attempt fails, every centred reward is zero. Hugging Face screened for tasks the base model solved on some attempts and missed on others. The advanced ledger lesson applies that idea to a multi-turn workflow. Hugging Face report · Harness-specific reinforcement learning

For a workflow with several steps, award an efficiency bonus only after the verifier accepts the final result, and cap its weight so a shorter wrong answer cannot beat a correct one. TRL’s AsyncGRPO can overlap training on the trainer GPU with generation on a separate vLLM rollout server. TRL AsyncGRPO

6. The strict reward

The same run from the same warm start, with a reward of 1 for the gold result and 0 for anything else. It runs for 100 steps, because it is the one whose result is kept. No credit for "runs": the warm start already runs 98.8% of the time, so a credit for it would carry no information and give a policy something to farm. Arctic pays 0.1 for a query that executes; the warm start here makes that signal nearly constant.

Most groups carried no signal: in 32 of 100 steps none of the 8 groups had any spread, and the policy moved only a little

Strict-reward run, 100 steps of 8 questions × 8 answers. Grey: each step; blue: smoothed over 5 steps

5
a Mean reward0.500.751.001501000.794 first 10, 0.845 last 10b Spread inside a group0.00.10.2150100zero in 32 of 100 stepsc Groups with no spread50%75%100%150100100% in 32 of 100 stepsd Answer length, tokens202530150100mean 25.0, no drifte KL to the warm start0.005.010.015150100ends at 0.0083f Tokens clipped0.000.250.501501000.0 at every stepx axis: RL step
Source: lesson notebook section 4, Colab T4. Per-step series read from the notebook's training-curve figure; they agree with the values it printed every 10 steps. A group has no spread when all 8 answers score the same.

Read the panels as diagnostics, not as a success story.

  • Reward (a). Mean reward over the first 10 steps was 0.794 and over the last 10, 0.845. Each step sees 8 new questions, so part of that is which questions came up. The held-out score decides, in section 7.
  • Spread (b) and groups with no spread (c). At every step printed in the log, 75% to 100% of the 8 groups had no spread, so at most 2 of the 8 groups carried a gradient. Across all 100 steps the share ranged from 50% to 100%, and in 32 steps every group was flat: those steps carried no reward gradient at all. This is the finding that explains the result. A warm start that is right on 79.5% of questions, sampled 8 times, produces mostly groups of eight identical answers.
  • Length (d). Stable near 25 tokens. A length that climbs steadily is the signature of a reward that pays for more text.
  • KL (e). Reached 0.0083 at step 100. A KL that grows without a matching gain on a held-out score is drift. This one grew slowly, and the gain it bought is measured next.
  • Clip (f). Zero throughout, as one update per batch predicts.

How companies handle the same signal differs by what they can afford. Shopify's Sidekick team calibrates an LLM judge against a rubric, checks it with Cohen's kappa, and applies GRPO after supervised training in a daily loop. Harvey's recipe excludes groups with all-equal rewards or too few graded rollouts, the filter DAPO proposed. Both treat the flat groups as a cost to manage, which is what panel c measures here.

7. Did it help?

Figure 1, at the top of the page, shows four systems on the same 500 questions, greedy decoding. Execution is scored on the 483 with a non-empty gold result; the ± is the 95% interval 1.96p(1−p)/n1.96\sqrt{p(1-p)/n}.

On execution, the overlap-reward run reached 81.0% and the strict-reward run 80.7%, against the warm start's 79.5% (each ±3.5 or ±3.6). Those are gains of 1.5 and 1.2 points, and both are inside the interval, so the test cannot say either run is better than its starting point. Exact match tells the same story: 68.8% and 68.4% against 67.6%. The warm start's own gain over the base model, 18.6 points, is clear of the noise by a wide margin. RL on top of it is not.

The paired counts show why:

The runs moved a handful of answers each way: 16 won and 9 lost, 26 won and 20 lost, out of 483

Each answer's strict score before and after RL, on the questions with a non-empty gold result (square area is proportional to the count); below, where the strict-reward model's 483 answers fall

6
Overlap reward, 50 stepsnet +7 of 483right afterwrong afterrightbeforewrongbefore375 stay right9 lost16 gained83 stay wrongStrict reward, 100 stepsnet +6 of 483right afterwrong afterrightbeforewrongbefore364 stay right20 lost26 gained73 stay wrongWhere the strict-reward model’s 483 answers fall32890328 exact match62 same answer,different query90 runs, wrong result3 do not run
Source: lesson notebook section 5. Counts of stay-right and stay-wrong follow from the printed 390 correct and the net change; the warm start was right on 384 of 483. Exact-match count 328 = 390 − 62.

Against the warm start, the overlap run turned 16 wrong answers right and 9 right ones wrong, a net of 7 in 483. The strict run turned 26 right and 20 wrong, a net of 6. These are small differences between two noisy lists, and the split is not lopsided. On the strict-reward model's 483 answers, 390 are correct on execution, and 62 of them are a different query from the gold text with the same result: a score by text would call those wrong, which is the reason for the program. Of the rest, 90 run but return the wrong result and 3 do not run. Wrong results, not failing queries, are what is left.

The result is the honest one, and it fits what the DeepSeekMath authors found when they asked what RL changes. They compared Maj@K, majority voting over K samples, with Pass@K, the chance that any of K is right: RL improved the first but not the second, and they read it as boosting a correct answer the model already had among its top samples, not a new capability. RL sharpens a choice the model already makes. The room for improvement is the gap between what the model samples and what it picks greedily, and for a 1.5B model on questions it mostly answers consistently, that gap is small.

Arctic's larger gain, 63.9 to 68.9 on BIRD-dev for the 7B model, came from an update with 256 prompts of 16 rollouts, 4,096 answers, where this lesson uses 64, and from a different model size, training set and benchmark. This lesson did not test which of those differences matters. The notebook's group size, learning rate and step count are the first things to change.

8. What to keep

SFT bought 18.6 points of execution accuracy in 3.6 minutes; 18 minutes of RL moved it 1.2, inside the noise

Time and peak GPU memory of each training phase on a T4, and the execution accuracy after it (483 questions). A GRPO step samples, scores and trains on 64 answers

7
PhaseStepsMinutess per stepPeak GPU memory, GBExecutionChange010200481216T4: 15.6 GBWarm start (SFT)2,000 examples1253.61.76.6179.5+18.6 on baseGRPO, overlap reward64 answers per step509.211.012.6281.0+1.5, noiseGRPO, strict reward64 answers per step10018.311.013.7380.7+1.2, noise
Source: lesson notebook, Colab T4 (15.6 GB). Seconds per step for SFT is 3.6 min ÷ 125 steps; its step is 16 examples. ± on execution: 3.6, 3.5 and 3.5 points. Change on base: 60.9 → 79.5.
BaseWarm start (SFT)GRPO, overlap rewardGRPO, strict reward
Execution on 48360.9% (±4.4)79.5% (±3.6)81.0% (±3.5)80.7% (±3.5)
Exact match on 50058.4%67.6%68.8%68.4%
Training timenone3.6 min9.2 min18.3 min
Peak memorynone6.61 GB12.62 GB13.73 GB
What you shipthe modela 3,103.3 MB merged modela 73.9 MB adapter for the warm starta 73.9 MB adapter for the warm start

The warm start took 3.6 minutes. A GRPO step took 11.0 seconds for 64 answers, so 50 steps took 9.2 minutes at a peak of 12.62 GB and 100 steps took 18.3 minutes at 13.73 GB, within 2 GB of the T4's limit; lesson 4's 8,000-example SFT took 14.6 minutes at 9.87 GB. SFT carries the score from 60.9% to 79.5%. RL, at this scale, costs more of everything and is not distinguishable from nothing.

Where the answer to "is there a program that scores it?" is a judge or a rubric rather than a program, the companies' reports show the trade. Genspark served a Kimi-K2 fine-tune whose reward score rose from 0.65 to 0.82 and whose average tool calls per task rose from 2.86 to 5, against 0.76 and 3.74 for a closed model; the page names neither the algorithm nor the reward, and every figure is measured by the vendor. Vercel's post reports that reinforcement fine-tuning gave its v0 fixing model an error-free output rate of 86.14% at 8,130 characters per second, against 89.55% at 559 for gemini-2.5-flash-preview-05-20 and 83.33% at 239 for gpt-4o-mini: roughly par quality, 10 to 40 times faster (company evaluation, no before and after for the base). Harvey reports 30.3% on the all-pass measure of its LAB benchmark for a rubric-trained open-weight model, against 25.8% for the original at maximum reasoning effort, with 36% fewer output tokens, and the preference caveat of section 5 in the same post. Genspark, Shopify and Vercel publish no comparison against a supervised starting point, which is the comparison this lesson makes.

If you have a task like this one:

  • Start with supervised fine-tuning and measure it first. It moved execution from 60.9% to 79.5% in 3.6 minutes; RL on top moved it 1.2 to 1.5 points in 9 to 18 minutes, inside the ±3.5 interval.
  • Attack the scorer before training against it. List the wrong answers a lazy policy could give and see what each earns: SELECT * FROM the first table earned 0.831 on overlap and 0.000 on the strict reward.
  • Measure the share of groups with no spread before anything else. At most 2 of 8 groups carried a gradient at every logged step of the strict run, and in 32 of 100 steps none did.
  • Compare every run by a score it was not trained on. The overlap reward and the strict score fell together, so nothing was being gamed, and only the second score could show that.
  • Reward the result and nothing else. The warm start already runs 98.8% of the time, so partial credit for "runs" carries no signal and gives a policy something to farm.

Next to try, not tested here: a group size of 16 with the same 64 answers per step, because flat groups are what limited the signal; loss_type="dr_grpo" with scale_rewards=False; dropping flat groups and sampling more, as DAPO does; seeding the warm-start data with SELECT * answers so the policy samples the hole in the overlap reward; and repeating each run with other seeds, because every number here comes from one run.

9. How it was built

ItemSetting
Base modelQwen/Qwen2.5-1.5B-Instruct, fp16 (a T4 has no bfloat16), 1,562,179,072 weights with the GRPO adapter attached
Datasql-create-context, cleaned and split by table in lesson 3 (train 69,170, validation 3,817, test 3,923). Warm start: 2,000 training examples. RL questions: a pool of 1,100 further training examples, 1,069 with a non-empty gold result; the overlap run used the first 400 (8 per step), the strict run the first 800 (derived). Seed 42
Test500 test questions, seed 42, the same for every system. Execution is scored on the 483 whose gold result is not empty; the ± is 1.96 × √(p(1−p)/n), the 95% interval. Exact match is on all 500, after normalising case, white space, a trailing semicolon and quote characters
RewardStrict: 1 if the query's result equals the gold result on a small database built per question, else 0. Overlap: the share of the gold result's distinct values that appear in the model's result. Queries run read-only with a call limit
Method: warm startLoRA through TRL SFTTrainer: r=16, lora_alpha=32, lora_dropout=0.05, target_modules="all-linear", loss on the answer only, then merged into the weights
Method: GRPONew LoRA adapter on the merged warm start: r=16, lora_alpha=32, lora_dropout=0.0, target_modules="all-linear", 18,464,768 trainable weights; num_generations=8 (group size), 8 questions per step, 64 answers per step, beta=0.04, num_iterations=1, loss_type="bnpo", scale_rewards=True, no vLLM
Training: warm start1 epoch, batch 8 × 2 accumulation = 16 (125 steps, derived), learning rate 2e-4 with cosine decay and 3% warm-up, fp16, gradient checkpointing, max_length=256, seed 42
Training: GRPOBatch 16 × 4 accumulation, learning rate 2e-5 constant after 5 warm-up steps, fp16, no gradient checkpointing, max_prompt_length=160, max_completion_length=64, 50 steps (overlap) and 100 steps (strict), seed 42, one run of each
DecodingTraining samples: temperature 1.0. Evaluation: greedy, batches of 16, at most 128 new tokens
HardwareOne Tesla T4 on Google Colab; transformers 4.51.3, peft 0.15.2, trl 0.19.1, accelerate 1.6.0, datasets 3.6.0

Time and cost. The warm start took 3.6 minutes at a 6.61 GB peak. A GRPO step took 11.0 seconds: 50 steps took 9.2 minutes at 12.62 GB, and 100 steps took 18.3 minutes at 13.73 GB. Each GRPO adapter is 73.9 MB and works only on the 3,103.3 MB merged warm-start model, not on the original Qwen model. The notebook does not print time per answer. All execution, exact-match and overlap figures come from the same 500 test questions; the training curves come from the questions each step sampled from the RL pool, not from the test set.

Run it yourself

The notebook runs on a free Colab T4 and trains for 31 minutes in total: 3.6 for the warm start, 9.2 for the overlap run and 18.3 for the strict run, plus loading models and scoring four systems on 500 questions. Every size is one constant in the second code cell. Its sections follow this page: 1 is the scorer and its attack (A program as judge), 2 the base and the warm start (The starting point), 3 the overlap run (A tempting reward and the advantages of Learning from groups), 4 the strict run (The strict reward), 5 the comparison (Did it help?) and 6 the files in What to keep. Three changes to try:

  1. Set NUM_GEN = 16, the group size DeepSeek-R1 and Arctic use, and halve PROMPTS_PER_STEP to keep 64 answers per step. Does the share of groups with no spread fall, and does execution move beyond ±3.5?
  2. Set loss_type="dr_grpo" and scale_rewards=False on the strict run. Section 4 says these remove two biases; do the curves for length and spread change?
  3. Add a share of SELECT * FROM answers to the warm-start data and run the overlap reward again. Once the policy samples the hole, does it climb?

Lesson 9 moves a large model's behaviour into a small one: distillation.

How is this page?

Last updated on