How to Evaluate the Mathematical Reasoning Ability of LLMs: Methods and Practical Guide
Mathematical reasoning is a common benchmark for testing the logical capabilities of large language models, but casual impressions from a few conversations are unreliable. This guide explains how to build a rigorous evaluation framework: which dimensions to measure (correctness, process reliability, difficulty tiers, stability, efficiency, and cost), how to construct a contamination-aware dataset with proper annotation, how to run a reproducible evaluation loop with multiple samples per question, which metrics and confidence intervals to report, and which common interpretation mistakes to avoid. It also covers throughput and cost considerations for engineering deployment and ends with a practical checklist for teams building long-running evaluation pipelines.
Why Evaluate Mathematical Reasoning Separately
Mathematical reasoning is a standard scenario for testing a model’s logical capabilities. It requires multi-step derivations in which each step depends on the previous one, so a single small error propagates down the chain and corrupts the final answer. For developers, this capability directly affects the reliability of use cases such as code logic verification, data analysis, report computation, and research assistance.
In everyday use, people often judge models by conversational feel. Fluency, neat formatting, and a derivation that looks complete all shape that judgment, but none of them is equivalent to correctness. A model with concise, polished output may reason correctly—or may fail at a critical step. Evaluation therefore requires a fixed set of problems, fixed scoring rules, and fixed statistical methodology.
Breaking Down the Evaluation Dimensions
A complete evaluation of mathematical reasoning typically covers the following dimensions:
- Answer correctness: whether the final result matches the reference answer. This is the most fundamental metric.
- Process reliability: whether every intermediate step holds. Cases where the answer is correct but the process contains skipped steps or invalid inferences should be recorded separately.
- Difficulty tiers: basic arithmetic, algebraic manipulation, combinatorics, and proof problems demand very different capabilities. Results should be reported per tier so that a single aggregate score does not mask differences across difficulty levels.
- Handling of open-ended problems: some problems have no accepted conclusion. Whether the model can produce verifiable intermediate results and flag uncertainty in its own reasoning is an important observation point.
- Stability: whether repeated sampling of the same question yields consistent answers. Unstable models require additional verification mechanisms in production.
- Expression efficiency: the length and redundancy of the reasoning process affect human review cost and response latency. This dimension should be assessed separately from correctness.
- Resource cost: input and output tokens consumed per question and average response time determine whether a model is economically viable at scale.
Building the Evaluation Dataset
Dataset quality determines how credible the evaluation conclusions are. Keep the following points in mind.
Sources. Combine self-built problem sets with public problems. Before using public problems, confirm their licensing terms and watch out for training data contamination: if a problem and its reference answer already appeared in the model’s training corpus, scores will be inflated. A common practice is to reserve a portion of private problems and to apply transformations to public ones, such as replacing numerical values or rewriting conditions.
Annotation. Every problem should have a reference answer and annotation notes. Numerical answers can be verified programmatically. For expression or proof answers, have two reviewers annotate independently, with a third reviewer arbitrating disagreements and the rationale recorded.
Tiering. Divide problems by difficulty and keep sufficient volume in each tier. When a tier has too few problems, its score fluctuates heavily and conclusions become unreliable.
Evaluation Workflow and Example Code
The pseudocode below shows a basic evaluation loop. It samples each question multiple times, saves the raw outputs, and passes them to an independent scoring function.
function evaluate(model, dataset, n_samples = 3):records = []for item in dataset:answers = []for i in range(n_samples):output = model.generate(prompt = item.question, seed = i)final = extract_final_answer(output.text)answers.append(final)correct_flags = [is_equivalent(a, item.reference) for a in answers]records.append({"id": item.id,"level": item.level,"correct_rate": mean(correct_flags),"consistent": all_same(answers),"output_tokens": mean(o.output_tokens for o in outputs),"latency_ms": mean(o.latency_ms for o in outputs)})return records
Three implementation details matter. First, extract_final_answer needs explicit rules—for example, requiring the model to place its final answer after a fixed marker—so that intermediate numbers are not mistaken for the result. Second, is_equivalent should use numeric comparison for numerical problems and symbolic simplification for expressions; plain string comparison is not sufficient. Third, all input parameters, including temperature, maximum output length, and the system prompt, must be logged so experiments are reproducible.
Metric Calculation and Statistical Interpretation
Commonly used metrics include:
- Accuracy: correct problems divided by total problems. It can be computed per tier or aggregated with difficulty-based weighting.
- Average correctness rate: the mean of each problem’s correct proportion across multiple samples—more stable than a single run.
- Consistency: the proportion of problems where all samples produce identical answers, used to measure stability.
- Efficiency metrics: average output tokens consumed per correct answer, used to compare cost-effectiveness.
Confidence intervals are also necessary. For a binomial proportion, if a tier has 100 problems and accuracy is 0.7, the standard error is approximately sqrt(0.7 × 0.3 / 100), or about 0.046. At the 95% confidence level, the interval half-width is roughly 0.09. This means that when two models differ by only a few percentage points, a single evaluation cannot distinguish them—you need more problems or repeated experiments.
Common Mistakes When Interpreting Results
First, treating impressions from a few conversations as conclusions. Performance on a handful of problems does not represent overall capability; rely on statistical results.
Second, comparing under inconsistent conditions. Reasoning budget, whether external tools are enabled, and differences in system prompts all significantly affect outcomes. Unify configurations before comparing, and note any differences in the report.
Third, equating reasoning chain length with capability. A longer reasoning process may contain more self-verification, or it may simply be redundant repetition. There is no fixed linear relationship between length and correctness; evaluate them separately.
Fourth, ignoring versions and timestamps. Models are continuously updated, and evaluation conclusions are valid only for a specific version on a specific date. Reports should record the model version, evaluation date, and runtime environment.
Fifth, publishing rankings on insufficient samples. With small problem counts and few tiers, rankings are largely driven by randomness.
Reasoning Efficiency and Engineering Deployment
Beyond mathematical capability, reasoning efficiency also affects model selection. Throughput is usually measured in tokens generated per second and is jointly influenced by batch size, parallelism strategy, hardware specifications, quantization method, and cache hit rate. When comparing throughput, fix input length, output length, and concurrency—otherwise the results are not comparable.
For cost accounting, unit cost per effective token measures economic efficiency:
unit_cost = (hardware depreciation + electricity + operations labor + API call fees) / effective output tokens
A self-hosted deployment must account for hardware procurement and operations costs, while an API-based approach mainly incurs pay-as-you-go fees. The break-even point between the two depends on actual request volume and should be estimated from historical traffic rather than a single load-test figure.
To run a long-lived evaluation pipeline, you can use general-purpose cloud-native components on Baidu AI Cloud: a container platform to run evaluation jobs, object storage to archive raw outputs, a logging service to record request details, and monitoring and alerting to track abnormal fluctuations in accuracy and latency. These standard components cover the main needs of the evaluation workflow.
Practical Checklist
- Clarify the evaluation goal: is it for model selection or for continuous monitoring? The two emphasize different metrics.
- Build a tiered dataset, keep private problems in reserve, and update it regularly.
- Fix the evaluation configuration and log all parameters to ensure reproducibility.
- Sample each question multiple times and report accuracy, consistency, and confidence intervals.
- Report correctness, process quality, and efficiency separately—do not collapse them into a single aggregate score.
- Version-control the evaluation scripts and rerun the full evaluation after every model update.
- Design end-to-end acceptance tests around your business scenarios; math benchmark scores are only one reference.
The value of mathematical reasoning evaluation is that it makes conclusions verifiable. As long as the problems, scoring rules, and statistical methodology stay fixed, teams can objectively compare models and quickly re-evaluate when business requirements change.
