A Framework for Evaluating Mathematical Reasoning in Large Language Models: Engineering Practices

    This article explains how to evaluate the mathematical reasoning of large language models. It covers five evaluation dimensions, layered datasets with decontamination, a fixed evaluation workflow, scoring methods for final answers and reasoning steps, common pitfalls in interpreting results, and inference cost metrics. It offers practical guidance for building reproducible evaluations.

    1. Why Mathematical Reasoning Needs Its Own Evaluation

    Each step in a math problem depends on the one before it. A single error in the middle invalidates the final answer. Judging mathematical reasoning by the final answer alone is therefore often not enough. A correct answer on one attempt does not show that a model reasons reliably. A wrong answer may also be a one-off sampling mistake.

    Relying on subjective impressions has three main problems: small sample sizes, uneven difficulty across problems, and varied prompt wording. Slightly rephrasing the same question can change the result. Reproducible conclusions require fixed evaluation conditions and enough test items.

    2. Breaking Down the Evaluation Dimensions

    Mathematical reasoning can be split into five independent dimensions.

    1. Correctness: whether the final answer is equivalent to the reference answer. For problems with an exact solution, this is the most direct metric.
    2. Process quality: whether the reasoning steps are logically valid. This includes checking for skipped steps, circular arguments, and references to theorems that do not exist.
    3. Handling of open problems: for questions without a standard answer, whether the model gives verifiable intermediate conclusions and clearly states which step remains unproven.
    4. Stability: how much accuracy varies across multiple samples of the same problem.
    5. Efficiency: chain-of-thought length, time to first token, and total latency. In real applications, efficiency affects user experience as much as correctness does.

    Record each dimension separately. Do not merge them into one overall score, because a merged score does not show where the model is weak.

    3. Building a Layered Evaluation Set

    The evaluation set should be divided by difficulty into at least three levels. The basic level covers algebra, probability, and elementary number theory, and tests the reliability of computation. The competition level covers problems that require constructive reasoning. The open level includes problems with no known solution and problems whose solutions require long proofs.

    Each data item should include the following fields:

    1. {
    2. "id": "unique identifier",
    3. "level": "basic | competition | open",
    4. "statement": "original problem statement",
    5. "reference_answer": "standard answer; may be empty for open problems",
    6. "key_steps": ["key step 1", "key step 2"],
    7. "source_date": "publication date of the problem source",
    8. "contamination_checked": true
    9. }

    Decontamination is a critical step. If a problem or its variants appeared in the model’s training data, the measured score does not reflect reasoning ability. A common approach is to prioritize new problems published after the model’s training cutoff, and to rewrite problems before testing.

    4. A Unified Evaluation Process

    The evaluation process must fix the system prompt, temperature, maximum output length, and number of samples. If any one of these differs, the results cannot be compared directly.

    The following generic evaluation loop shows the structure. The model call function depends on how the model is accessed.

    1. for item in dataset:
    2. for trial in range(N_SAMPLES):
    3. response = call_model(
    4. prompt=build_prompt(item["statement"]),
    5. temperature=FIXED_TEMPERATURE,
    6. max_tokens=FIXED_MAX_TOKENS,
    7. )
    8. record = {
    9. "id": item["id"],
    10. "trial": trial,
    11. "final_answer": extract_answer(response),
    12. "reasoning_tokens": count_tokens(response),
    13. "latency_ms": response.latency_ms,
    14. }
    15. results.append(record)

    Use at least three samples per item, and report the mean and standard deviation. For open problems, reviewers can grade blindly, without knowing which model produced each response. This reduces bias.

    5. Scoring Methods

    Scoring falls into two categories: outcome scoring and process scoring.

    For outcome scoring, numerical answers can be compared directly, while algebraic expressions must be simplified before comparison. Symbolic computation tools can check whether two expressions are equivalent, rather than relying on string matching. Identical strings do not always mean identical mathematical meaning, and different strings may still represent the same result.

    Process scoring requires annotators to check the steps one by one. A common method splits the reference solution into key steps and marks each step as passed or failed. The process score is the proportion of passed steps. To verify annotation quality, have two annotators independently score a subset of samples, then calculate an agreement metric such as Cohen’s kappa. If agreement is low, revise the scoring guidelines before continuing the evaluation.

    Scoring open problems depends more on human judgment. The scoring guidelines should define three outcomes: a complete proof, partial progress that identifies the unresolved parts, and a wrong conclusion. Count the third category separately. A confident wrong conclusion causes more harm than an answer that admits uncertainty.

    6. Common Pitfalls When Interpreting Results

    First, do not replace a complete conclusion with a single leaderboard. A leaderboard usually reflects performance on one problem set under one configuration. Changing the problems or the prompt can change the ranking.

    Second, with small samples, differences may be noise. In a test of a few dozen problems, a gap of a few percentage points is usually not statistically meaningful. Confidence intervals can be estimated with bootstrap resampling or binomial tests.

    Third, models are sensitive to prompts. The same model can perform noticeably differently under different system prompts. Comparisons should use the same template, and the report should include the template text.

    Fourth, the reasoning budget must be consistent across compared systems. If one system is allowed a longer chain of thought while the other is limited to shorter outputs, the comparison measures the budget rather than the underlying ability.

    7. Inference Cost and Throughput

    Inference speed matters for deployment decisions, but a single “tokens per second” figure says little. Throughput for the same model changes with hardware, batch size, quantization, number of concurrent requests, and input and output lengths.

    Record the following metrics together:

    • Time to first token: the time from sending the request to receiving the first output token. It directly affects interactive experience.
    • Average generation speed: output tokens divided by generation time. It reflects efficiency on long outputs.
    • Tail latency: P95 and P99 latency. It reflects stability under high load.
    • Cost per problem: total tokens consumed to solve one problem, and the corresponding fee.

    Fix input and output lengths during testing. Send warm-up requests first, then run several measurement rounds and report the median. Results must state the hardware, concurrency level, and test script version. Otherwise, the numbers cannot be reproduced.

    If the inference service runs on a cloud container platform, a monitoring and alerting service can collect these metrics continuously. Set thresholds so the relevant team is notified when latency exceeds them.

    8. Practical Recommendations

    1. Define the purpose of the evaluation first: model selection, regression testing, or capability research. The purpose determines which metrics matter.
    2. Align the evaluation set with the business scenario. Math scores cannot directly predict performance on code generation or text writing tasks.
    3. Keep the complete raw outputs so scoring can be reviewed later.
    4. Put evaluation scripts under version control and rerun them after every model or prompt change.
    5. Keep conclusions measured. State the scope of the report and what it does not cover.

    Evaluating mathematical reasoning has no single, one-time standard answer. It is an engineering process that must keep running. Only when the questions, scoring, process, and cost are all fixed can others reproduce and trust the conclusions.