liveBook · Manning

Chapter 3: Evaluating reasoning models

What you will learn in chapter 3 of Build a Reasoning Model (From Scratch)

The chapter introduction defines evaluation as quantitative testing against reference answers and identifies math-answer verification as the chapter’s approach.

After this chapter you will be able to

What it builds on

Section by section

Introduction

The chapter introduction defines evaluation as quantitative testing against reference answers and identifies math-answer verification as the chapter’s approach.

Key terms: evaluation, reference answers, verification-based method, reference solutions, calculator-like implementation

3.1 Building a math verifier

This section positions math verifiers among LLM evaluation methods, explains why checking math answers is useful, and identifies the approach’s limits and later role in training.

Key terms: multiple choice, verifiers, leaderboards, LLM judges, benchmark-based evaluation, judgment-based evaluation, verifier, extracted answer, reference solution, step-by-step reasoning

3.2 Loading a pretrained model to generate text

The section loads a pretrained model and generates a math answer in a form that can be inspected now and processed by the verifier later.

Key terms: load_model_and_tokenizer, base model, official Qwen3 reasoning model, WHICH_MODEL, token IDs, streaming, all_tokens, decode, reasoning-model-like explanation, chain-of-thought data

3.3 Implementing a wrapper for easier text generation

This section introduces a reusable wrapper that turns a prompt into a generated string without repeating input-preparation steps.

Key terms: wrapper, tokenizes, streams, decodes, verbose flag

3.4 Extracting the final answer box

This section builds utilities that extract a final answer from model output, preferring the last boxed expression and using configurable fallbacks when no box is found.

Key terms: answer box, boxed answers, MATH-500, get_last_boxed, \boxed, nested braces, extract_final_candidate, number_then_full, number_only, none

3.5 Normalizing the extracted answer

This section explains why extracted math answers need normalization and how `normalize_text` converts varied formatting into a consistent string for later comparison.

Key terms: normalization, canonicalization, extracted answer, normalize_text, LaTeX, standardized format, calculator-style form

3.6 Verifying mathematical equivalence

This section builds a SymPy-based check for whether an LLM’s extracted answer is mathematically equivalent to a ground-truth answer, then identifies its limitation with tuples.

Key terms: ground truth, equality check, mathematical equivalence, sympy_parser, SymPy object, implicit multiplication, equality_check, SymPy objects, tuples

3.7 Grading answers

This section builds a math-answer grader that handles multipart answers and checks it with varied test cases.

Key terms: split_into_parts, tuple-like expressions, subparts, grade_answer, prediction, ground truth, normalize, equality_check, tests, run_demos_table

3.8 Loading the evaluation dataset

This section introduces MATH-500 as the evaluation dataset, explains why it was chosen and how it is sourced, and identifies the fields needed to evaluate model answers.

Key terms: MATH-500, MATH dataset, held-out evaluation set, GSM8K, problem, answer, solution, ground truth, Python dictionary, code repository

3.9 Evaluating the model

This section connects the math-answer checking components into a MATH-500 evaluation pipeline and uses its results to examine prompt sensitivity, answer errors, and the accuracy–runtime tradeoff between base and reasoning models.

Key terms: prompt template, boxed form, mini_eval_demo, evaluate_math500_stream, MATH-500, grade_answer, base model, reasoning model variant, answer extraction, extracted

3.10 Summary

Summarizes verification-based evaluation of reasoning models, from checking free-form math answers to interpreting the evaluation results.

Where this is used later

Concepts explained in this chapter

← Chapter 2: Generating text with a pretrained LLM Chapter 4: Improving reasoning with inference-time scaling →

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.