A verifier is a deterministic checker that evaluates an output against fixed criteria and returns the same result for the same input. In reinforcement learning with verifiable rewards (RLVR), it replaces a learned reward model when correctness is mechanically checkable, especially for mathematics, code, and symbolic tasks. section 7.5 section 7.5.2
Design a useful verifier around four practical requirements:
- Parse outputs reliably by enforcing a structured final-answer region, such as “Final answer:”, rather than guessing among multiple candidate answers. section 7.10.1 section 7.14
- Reward real correctness while tolerating harmless formatting differences; production mathematics may require symbolic equivalence, unit normalization, decimal tolerance, and structured extraction. section 7.5.1
- Check the artifact that matters: execute code against tests or a compiler, validate symbolic results against formal rules, or compare a mathematical answer with a known result. section 7.5
- Audit for reward hacking because incomplete tests, brittle extraction, or checking only the final number can produce misleading training signals. section 7.14 section 7.5.1
Minimal answer verifier
A toy math verifier extracts the last integer or decimal with a regular expression, returns zero when no number is found, and returns one only when the extracted value exactly matches the gold answer. This demonstrates RLVR but should be strengthened before production use. section 7.8.1
Listing 7.2 A minimal verifier for answer-only math prompts
import re
def extract_final_number(text: str) -> str | None:
"""Return the last integer or decimal number found in a completion."""
matches = re.findall(r"-?\d+(?:\.\d+)?", text)
return matches[-1] if matches else None
def verify_math_answer(completion: str, gold: str) -> float:
"""A toy RLVR reward for answer-only math tasks."""
predicted = extract_final_number(completion)
if predicted is None:
return 0.0
return 1.0 if predicted == str(gold) else 0.0Inspect the compact Python implementation of final-number extraction and binary reward assignment. section 7.8.1








