Verifiers for Reasoning Models
One checking function both scores the benchmark and rewards the policy. How its mistakes move the number you report.
Jump to a section
One function, two jobs
A reasoning model ends a long solution with \boxed{\frac{3}{4}}. The reference answer in the dataset is 0.75. A string comparison marks the model wrong, and so does any benchmark that relies on one.
A verifier is the function that decides, without a human, whether a response is correct. For math it extracts the final answer, normalizes it, and checks equivalence with the reference. For code it runs tests. The same function usually does two jobs: evaluation, where it decides what fraction of a benchmark the model solves, and reward, where it supplies the signal that reinforcement learning with verifiable rewards (RLVR) optimizes.
That double role is the reason to build it carefully. A verifier measures only what it checks. A lenient parser inflates benchmark scores, and during RL the policy will find the same leniency and exploit it.
Extract, normalize, compare
A math verifier has three steps, and each one can fail in both directions.
Extract. Find the committed final answer in a response that may contain dozens of intermediate results. The usual convention for MATH-style problems is the last \boxed{...}, read with brace matching because the answer itself can contain braces. Extraction can grab an intermediate number, or find nothing in a response that states its answer in words.
Normalize. Strip formatting that does not change the value: LaTeX wrappers such as \left and \right, dollar signs, spaces, and units where the problem allows. Convert both sides to a canonical form, so that \frac{3}{4}, 3/4 and 0.75 become the same number. Too little normalization rejects equal answers; too much merges answers that are not equal.
Compare. Check equivalence between the canonical forms, exactly for numbers and with a computer algebra system for symbolic expressions. Symbolic checks need a timeout, because simplifying a hard expression can run indefinitely.
Three steps between a response and a reward
Follow one response through extraction, normalization and comparison. Each step can create a false positive or a false negative.
The visual loads as you reach this section.
Read the connections
Model response -> Extract answer : last boxed Extract answer -> Normalize : strip LaTeX Normalize -> Compare : canonical form Compare -> Reward : 1 or 0 Extract answer -> Logged failure : none found
Log each failure type separately: no answer found, parse failure, timeout, mismatch. When a score changes, those counts show whether the model or the checker moved.
How checker errors move the score
Treat the verifier as a classifier of whether response answers prompt correctly. Against true correctness, it has a false-negative rate and a false-positive rate . If the model's true accuracy is , the measured accuracy is
With no false negatives, a 5% false-positive rate on a model with 40% true accuracy reports 43%: three points that do not exist. If you can estimate both rates by hand-labeling a sample of responses, the relation inverts to , which recovers .
In RL the stakes are higher. A policy's expected reward is its measured accuracy , so the gradient rewards anything that raises as readily as anything that raises . And the error rates are not fixed properties of the checker: they depend on which responses the policy produces, and training shifts that distribution toward whatever the checker accepts.
Rewards without a reward model
DeepSeek-R1-Zero was trained with two rule-based rewards. An accuracy reward checked the final answer, which math problems had to give in a specified format such as a box, and ran coding problems against predefined test cases. A format reward paid for putting the reasoning between thinking tags. The paper reports avoiding neural reward models for this stage because they are prone to reward hacking at scale.
Rule-based checks are only as strong as their coverage, and each domain fails in its own way. Numeric math produces false positives from lenient parsing of a partial answer and false negatives from equivalent forms the normalizer does not know. Symbolic math checked by computer algebra can accept answers through simplification bugs and reject them through timeouts. Code checked by unit tests passes weak or incomplete tests and fails on flaky tests or environment errors. Format checks by regular expression accept the right structure around wrong content and reject a valid answer in an unexpected layout.
All of these are outcome verifiers: they score the final answer, so a correct answer reached by flawed reasoning earns full credit. A process reward model scores each intermediate step instead, which gives denser feedback but is a learned model with its own errors. Lightman et al. compared the two on MATH, the 12,500-problem competition benchmark from Hendrycks et al., using 800,000 human labels on individual solution steps. Their best process-supervised model solved 78% of a representative 500-problem subset of the MATH test set, and that subset, MATH-500, is now a standard evaluation split.
In code
Extract the last \boxed{...} with brace matching, then compare as exact fractions where possible. The last two checks are deliberate: one equal answer this verifier misses, and one wrong response it accepts.
1from fractions import Fraction
2
3
4def last_boxed(text: str) -> str | None:
5 start = text.rfind("\\boxed{")
6 if start < 0:
7 return None
8 i, depth = start + len("\\boxed{"), 1
9 for j in range(i, len(text)):
10 depth += {"{": 1, "}": -1}.get(text[j], 0)
11 if depth == 0:
12 return text[i:j]
13 return None # unbalanced braces: no answer
14
15
16def canonical(ans: str):
17 s = ans.replace(" ", "").replace("\\left", "").replace("\\right", "").strip("$")
18 if s.startswith("\\frac{") and "}{" in s and s.endswith("}"):
19 num, den = s[len("\\frac{"):-1].split("}{", 1)
20 s = f"{num}/{den}"
21 try:
22 return Fraction(s)
23 except (ValueError, ZeroDivisionError):
24 return s
25
26
27def verify(response: str, reference: str) -> int:
28 pred = last_boxed(response)
29 return int(pred is not None and canonical(pred) == canonical(reference))
30
31
32assert verify(r"... so the answer is \boxed{\frac{3}{4}}", "0.75") == 1
33assert verify(r"\boxed{0.750}", "3/4") == 1
34assert verify("the answer is 3/4", "0.75") == 0 # nothing boxed
35assert verify(r"\boxed{\dfrac{3}{4}}", "0.75") == 0 # false negative
36assert verify(r"\boxed{\frac{3}{4}} is shaded, so the answer is 1/2", "0.75") == 1 # false positiveThis handles a narrow set of forms. Production math verifiers add symbolic equivalence with a timeout and unit handling, and keep every known false positive and false negative as a regression test.
Where it goes wrong
The checker changed, not the model. Measured accuracy jumps after a verifier update. Rescore a fixed set of saved responses with both versions and inspect every label that flipped before believing any model comparison across the change.
The extraction convention is unstated. Taking the last boxed answer is a convention, and the false positive above shows its cost when a model boxes an intermediate result and concludes elsewhere. State the convention with the benchmark score.
The format reward gets farmed. A policy can emit the required tags around empty or irrelevant reasoning. Keep format rewards small relative to accuracy, and check samples by eye during training.
Code runs outside a sandbox. A code verifier executes model-written programs. Isolate execution with time and memory limits and no network or file system access beyond the sandbox, or the reward can be earned by tampering with the tests.
The score travels without its checker. A benchmark number is a property of the model and the verifier together. Report the verifier, its version and its known failure modes with the score.
Sources and further reading
- Lightman et al., Let's Verify Step by Step: outcome versus process supervision, and the source of the MATH-500 split.
- Hendrycks et al., Measuring Mathematical Problem Solving with the MATH Dataset: the MATH benchmark.
- DeepSeek-AI, DeepSeek-R1: rule-based accuracy and format rewards.
- Raschka, Building Reasoning Models from the Ground Up: builds a math verifier, then reuses it as the RLVR reward.