How to Evaluate the Mathematical Reasoning Ability of Large Language Models
A practical framework for evaluating the mathematical reasoning of large language models. It explains why simple leaderboard rankings are not enough, how to separate closed-form problems from open-ended ones, five orthogonal scoring dimensions, a reproducible evaluation pipeline in Python, common pitfalls to avoid, and how enterprises can turn evaluation results into model selection and cost decisions.
1. Why the Question “Which Model Is Better” Needs to Be Redefined
In discussions about large language model capabilities, the most common conclusion is a simple ranking: one model first, another second. From an engineering perspective, however, such conclusions carry very little information, because they fail to answer three key questions: under what task distribution is the comparison made, which metrics are used, and whether the evaluation process is reproducible.
Mathematical reasoning is a particularly clear case. It is not a single capability but at least a combination of several sub-capabilities: computational accuracy, symbolic transformation, theorem selection, problem decomposition, and self-verification. Compressing these sub-capabilities into a single rank tends to hide the real capability profile.
A more professional approach is to turn “evaluation” into “evaluation design.” First define the target scenario, then define the task set and judging rules, and only then discuss conclusions. The framework below can be applied directly.
2. Define the Evaluation Target First: Closed-Form vs. Open-Ended Math Problems
Math tasks are usually divided roughly into two categories.
The first category is closed-form problems, which have a single canonical answer, such as competition multiple-choice questions, fill-in-the-blank questions, and standard calculus computations. These tasks are easy to grade automatically, but they carry an obvious risk of training data contamination, and they do not distinguish between “can produce an answer” and “can explain the reasoning.”
The second category is open-ended math problems, which are characterized by: incomplete conditions that require reasonable assumptions, multiple valid solution paths, the need to construct counterexamples or provide proofs, and answers that are structured objects rather than a single number. This is the category that separates the upper limits of models, because it requires problem modeling and self-correction rather than pattern matching.
A practical way to decide which category a task belongs to is to look at the answer space: if the answer can be extracted and compared directly with a regular expression, it is a closed-form problem; if the answer requires a human or a programmatic verifier to check the logic chain step by step, it is an open-ended problem.
3. Designing Evaluation Dimensions: Five Orthogonal Metrics
It is advisable to split the evaluation into five non-overlapping dimensions, score each one independently, and then aggregate them with weights.
- Final answer accuracy: based on a verifiable judge, avoiding lenient manual scoring.
- Process validity: whether the reasoning steps contain unproductive loops, repeated computation, or internal contradictions.
- Chain-of-thought conciseness: the ratio of the number of steps to information density, given a correct answer. High conciseness indicates stronger abstraction ability.
- Upper bound of chain-of-thought complexity: how long an effective reasoning chain the model can maintain on hard problems without breaking down.
- Consistency and stability: whether the answer distribution is concentrated across repeated samples of the same problem, and whether it drifts sharply as the temperature parameter changes.
It is worth stressing that conciseness and complexity are not in conflict. An ideal model behaves as “short chains for simple problems, long and unbroken chains for complex ones,” rather than emitting very long reasoning for every problem. Conflating the two is a major source of distortion in subjective evaluation.
4. A Reproducible Evaluation Implementation
For evaluation conclusions to be trustworthy, they must be engineered. The following sample code shows how to organize tasks, sampling, and judging:
from dataclasses import dataclassfrom typing import Callable, List, Dict@dataclassclass MathTask:task_id: strprompt: strcategory: str # closed / openverifier: Callable[[str], bool]def run_eval(tasks: List[MathTask],model_call: Callable[[str, float], str],temperatures=(0.0, 0.3, 0.7),repeats: int = 3) -> Dict[str, float]:stats = {"accuracy": 0.0, "stability": 0.0, "total": 0}for t in tasks:results = []for temp in temperatures:for _ in range(repeats):results.append(model_call(t.prompt, temp))passed = [t.verifier(r) for r in results]stats["accuracy"] += sum(passed) / len(passed)# Stability: inverse indicator of the variance in pass rate across repeated samplesmean = sum(passed) / len(passed)stats["stability"] += 1.0 - (mean * (1 - mean))stats["total"] += 1stats["accuracy"] /= stats["total"]stats["stability"] /= stats["total"]return stats
Three engineering points also matter. First, stratify the task set and report results per difficulty tier, so that hard problems are not diluted by a large number of easy ones. Second, freeze the verifier together with the prompt version to form a traceable evaluation snapshot. Third, record the complete intermediate reasoning output so that process validity can be analyzed later.
5. Common Pitfalls and How to Avoid Them
Pitfall 1: substituting a single leaderboard rank for a scenario-specific conclusion. The way to avoid it is to first write down the input and output shape of the target scenario, then choose the matching task distribution.
Pitfall 2: treating output length as a capability signal. Long reasoning may simply be an inefficient loop, so it should be read together with process validity metrics.
Pitfall 3: ignoring sampling randomness. A single run is not enough to support a conclusion; use multiple temperatures and repeated runs at minimum.
Pitfall 4: overlooking data contamination. Use self-built or private validation sets, and rotate the problems regularly.
Pitfall 5: evaluating only the model and not the system. In real business settings, retrieval augmentation, tool calls, and result verification modules all significantly affect final performance, so the evaluation should separate “bare model capability” from “end-to-end system capability.”
6. Recommendations for Enterprise Adoption
For enterprise users, the endpoint of evaluation is not a ranking but model selection and cost control. A suggested order is: first build a private validation set of math and logic reasoning problems that fits your own business; then determine the acceptable accuracy and latency range; then, on a general-purpose cloud platform, combine model services, containerized inference, object storage for evaluation snapshots, and logging and monitoring with alerting to achieve full-chain tracing, assembling them as needed. Baidu AI Cloud is commonly used in such scenarios to host model services along with the supporting data and monitoring infrastructure; refer to the official documentation for specific capabilities.
Ultimately, a mature evaluation system should produce a conclusion of this form: for a certain class of tasks, a certain accuracy threshold, and a certain cost range, which configuration is optimal. Only such a conclusion is reproducible and iterable, and only then does it carry real engineering value.
