Evaluating Mathematical Reasoning in Large Language Models: A Reproducible Assessment Approach

    This article provides a practical, step-by-step framework for evaluating the mathematical reasoning capabilities of large language models (LLMs). It outlines how to define granular evaluation objectives, construct a balanced and verifiable dataset, implement robust answer verification methods, analyze the quality of reasoning processes, and account for response variability through repeated sampling. The guide is designed to help AI engineers and researchers build dependable, reproducible benchmarks for model comparison and iterative improvement.

    Why Mathematics Is a Suitable Benchmark for Reasoning

    Mathematical problems are an effective tool for assessing reasoning because they typically have a single correct answer, and the problem-solving steps can be verified sequentially. Unlike open-ended writing tasks, math questions provide objective signals of correctness, allowing for clear quantitative comparison.

    However, this approach has significant pitfalls. Public problems may have been included in the training data of the models being tested. A model providing a correct answer does not necessarily mean it can perform the underlying derivation. Additionally, the difficulty of math problems spans a vast range, from basic arithmetic to competition-level proofs, and mixing results from different difficulty levels can be misleading. Thus, it is essential to deconstruct “mathematical ability” into measurable sub-skills before running tests.

    Common sub-skills include:

    • Computational Accuracy: Arithmetic operations, algebraic simplification, and numerical calculations.
    • Multi-step Reasoning: Problems requiring consecutive logical steps, where errors in intermediate stages can be observed.
    • Problem Modeling: The ability to translate worded descriptions into equations or constraints.
    • Proof and Justification: Delivering logically coherent derivations, not merely final conclusions.

    Defining Clear Objectives and Context

    Before starting, answer three fundamental questions: What is being compared? What decision depends on the results? How much margin of error is acceptable?

    1. For Model Selection: Prioritize accuracy, stability, response latency, and API call cost.
    2. For Iterative Optimization: Focus on whether specific error types (e.g., symbolic manipulation or unit conversion errors) have decreased.
    3. For Risk Assessment: Focus on failure modes in critical calculation scenarios, such as whether the model confidently outputs a seemingly precise but incorrect number.

    Each objective requires a different combination of metrics. A single overall score should not be used to cover all requirements.

    Constructing the Evaluation Dataset

    The quality of the dataset determines the credibility of the conclusions. A robust evaluation set generally meets these criteria:

    • Coverage: A balanced distribution across question types, difficulty levels, and knowledge domains.
    • Independence: Questions should not be directly taken from public sources; they should be adapted with altered numbers or contexts.
    • Verifiability: Each question must have a standard answer and, ideally, a reference solution.
    • Scale: Each category of questions should contain at least a few dozen items to mitigate the impact of statistical outliers from individual questions.

    Here is an example data structure for a single evaluation sample:

    1. from dataclasses import dataclass, field
    2. @dataclass
    3. class EvalItem:
    4. item_id: str
    5. domain: str # e.g., algebra, probability, geometry
    6. difficulty: int # Manually labeled difficulty level, from 1 to 5
    7. question: str
    8. answer: str # The standard answer, normalized for comparison
    9. reference_steps: list[str] = field(default_factory=list)
    10. answer_type: str = "numeric" # numeric / symbolic / proof

    It is recommended to use version control for the question bank, recording any changes when new items are added or modified. This ensures consistency for comparisons over time.

    Verifying Model Answers

    The verification step is often underestimated, yet it directly defines the meaning of the accuracy metric. The method should be tailored to the answer type:

    • Numeric Answers: Define relative error thresholds and standardize rules for units and significant figures.
    • Symbolic Answers: Use symbolic computation libraries to assess if two expressions are equivalent, preventing false mismatches due to formula formatting.
    • Proofs: Automated verification is difficult; these typically require human rating scales or assistance from formal verification tools.

    Example code for numeric verification:

    1. import re
    2. def extract_final_answer(text: str) -> str | None:
    3. """Extract the last answer marked with 'ANSWER:' from the model output."""
    4. matches = re.findall(r"ANSWER:\s*(.+)", text)
    5. return matches[-1].strip() if matches else None
    6. def numeric_match(pred: str, gold: float, rel_tol: float = 1e-4) -> bool:
    7. try:
    8. value = float(pred.replace(",", ""))
    9. except ValueError:
    10. return False
    11. return abs(value - gold) <= rel_tol * max(1.0, abs(gold))

    Requiring the model to output an answer with a specific marker format can significantly reduce extraction failures. Failed extractions should be logged separately, not counted as simple errors, to avoid conflating “calculation mistakes” with “format non-compliance.”

    Manual review is equally critical. It is a best practice to randomly sample a subset of results each batch to validate the automated scoring accuracy and track the misclassification rate.

    Analyzing Process Quality

    Looking only at the final answer fails to distinguish between a correct derivation and a lucky guess. Process analysis addresses this gap.

    A standard approach is to create a scoring rubric for each question, breaking down the solution into key steps to identify issues such as:

    • Whether core premises were cited correctly.
    • Whether intermediate calculations are flawed.
    • Whether steps are skipped, making the conclusion unverifiable.
    • Whether the final conclusion is consistent with the preceding reasoning.

    The length of the reasoning text does not inherently reflect its quality. Long chains may contain redundant loops or dead ends, while concise solutions can be complete and correct. Evaluations should focus on step accuracy and conclusion consistency, rather than word count or surface-level indicators like “thinking traces.”

    When human evaluation is needed, have two independent reviewers score the results and calculate an inter-rater reliability coefficient (e.g., Cohen’s kappa). A third party should adjudicate samples with significant scoring discrepancies.

    Handling Stability and Repeated Sampling

    A single model might generate different answers for the same prompt, especially with higher sampling temperatures. A one-off result is insufficient to understand model capability; repeated sampling is necessary.

    Common metrics include:

    • Single-pass Accuracy: The average accuracy across all samples.
    • Pass@k: The probability that at least one of k samples contains the correct answer.
    • Majority Voting Consistency: The proportion of repeated responses that converge on the most common answer.