A reasoning method is only as good as the score you trust. This module builds a verifier for free-form math: the model writes a solution, the grader reads the final answer, and a symbolic check decides whether that answer matches the reference. The same checker becomes the reward in Module 6.
The benchmark used throughout is MATH-500, a 500-problem slice of the MATH dataset. It is small enough to run often and standard enough that a number on it means something to other people. The base Qwen3 0.6B model, prompted to box its answer, lands near 15 percent accuracy on this set. That is the baseline the later methods try to move.
The grading pipeline
Figure 3.1 has four stages. Each one fails in a different way, and the failures look like “the model was wrong” if you do not separate them.
Generate under a fixed prompt
The base model often boxes a final answer without being asked, because that convention is common in the text it was trained on. For a benchmark, do not rely on the habit. Append an instruction that the last line should contain the answer in \boxed{}. Use greedy decoding, or a fixed seed, when you are comparing methods. A prompt change and a sampling change can each move accuracy by more than the method you meant to measure.
Keep the prompt template in one function and call it from evaluation, from self-consistency, and from training. Drift between those prompts makes the numbers incomparable.
Extract the last box
Definition 3.1 (Boxed answer).The predicted answer is the contents of the last
\boxed{...}span in the generation. Nested braces belong to the span. If there is no such span, the prediction is missing and the item is wrong.
Definition 3.1 uses the last box because solutions often box an intermediate quantity and then box the result. The first box is the wrong target. A scanner that counts braces, rather than a regular expression that stops at the first }, handles \boxed{\dfrac{14}{3}}.
Missing boxes are informative. A model that solves the problem in prose and forgets the box scores zero. That is harsh and it is what you want if the same extractor will later supply a reward: the training signal should match the evaluation rule.
Normalize, then test equivalence
String equality is the wrong comparison. The strings 1/2, 0.5, and \frac{1}{2} can be the same number. A usable normalizer:
- strips whitespace and wrapping delimiters,
- rewrites a few LaTeX forms (
\dfrac,\tfrac,\left,\right,\cdot) into something a parser accepts, - falls back to the raw string when parsing fails.
Definition 3.2 (Symbolic grade).After normalization, parse the prediction and the reference with a computer-algebra system. The item is correct when the difference of the two expressions simplifies to zero, or when both sides fail to parse and the normalized strings match.
Definition 3.2 is implemented with SymPy in the reference code. The numeric shortcut — evaluate both sides as floats and compare with a tolerance — is a useful fallback for expressions SymPy will not simplify, and it is a source of false matches for expressions that only agree at one point. Prefer an algebraic difference, and use the float check only when parsing succeeded but simplification did not.
A few cases are worth deciding explicitly and then leaving alone:
| Prediction | Reference | Grade |
|---|---|---|
\dfrac{1}{2} | 0.5 | correct, after simplification |
2 | 2.0 | correct |
| no box | 2 | incorrect |
| two boxes, last is wrong | the right value in the first box | incorrect |
(x+1)^2 | x^2+2x+1 | correct if both parse |
Do not special-case your way out of a bad prompt. If the model systematically boxes the wrong intermediate, that is a model error under this metric.
Aggregate
Accuracy on a set
Report the count of missing boxes next to the accuracy. A jump in accuracy that is really a jump in “the model remembered to use a box” is still real, but it is not the same phenomenon as better algebra.
When you compare two methods, evaluate them on the same 500 items with the same grader. The training split used later is the rest of MATH, with these 500 items held out. Training on the evaluation set makes the reward and the score the same memorization problem.
What this verifier is not
It does not score the reasoning trace. A wrong argument that lands on the right number is correct. A right argument that forgets the box is incorrect. Module 10 lists the other families — multiple choice, preference votes, LLM judges — and where they are the better tool. For the training methods in this course, a checkable final answer is the point.
Exercises: Homework 3.
Code
- Notebook: ch03_main.ipynb
- MATH-500 scripts: ch03/02_math500-verifier-scripts
- A stricter LaTeX parser: ch03/03_advanced-parser