Evaluating Mathematical Reasoning in LLMs: An Engineering Approach for Model Selection
This article presents a practical engineering methodology for evaluating the mathematical reasoning capabilities of large language models (LLMs). It breaks down tasks into four categories, defines measurable evaluation dimensions, and outlines a reproducible evaluation pipeline with sample code. The discussion covers accuracy, citation reliability, latency, cost, and how to balance these factors when selecting a model for specific workloads. Common pitfalls such as over-reliance on single samples and mistaking fluent output for correctness are also addressed.
Background
In real-world engineering work, teams often need to determine whether a large language model can handle high-intensity reasoning tasks such as mathematical derivation, formal proof, and literature verification. Individual user impressions typically come from a small number of samples, and conclusions can be heavily influenced by prompt wording, task difficulty, and usage quotas. To reach reliable conclusions, it is necessary to decompose “working well” into measurable dimensions and collect data using a consistent methodology.
This article does not evaluate any specific product. Instead, it discusses general methods for assessing mathematical reasoning ability and the trade-offs between speed, cost, and quality during model selection.
1. Distinguish Task Types First
A single model can show very different performance across task categories. Common tasks fall into four types:
- Divergent tasks: brainstorming, outlining, generating candidate ideas. These tasks emphasize coverage; strict correctness of individual outputs is less important.
- Execution tasks: writing code to a clear specification, organizing documents, converting formats. These tasks prioritize consistency and speed; correctness can be verified automatically through compilation, tests, or format checks.
- Derivation of known results: given an established theorem, produce a complete proof or teaching notes. The difficulty lies in ensuring every step is logically valid. Common errors include skipped steps, circular arguments, and citations to nonexistent lemmas.
- Open-ended exploration: problems without standard answers, requiring novel argument paths. These tasks demand the highest level of verification capability and human review.
Different task types call for different evaluation criteria. Mixing all four types into one overall score produces a ranking that cannot guide practical model selection.
2. Evaluation Dimensions
For mathematical reasoning, consider at least the following dimensions:
- Correctness: whether the final conclusion holds and whether intermediate steps are valid.
- Verifiability: whether each step references a checkable premise and can be inspected by formal tools or human reviewers.
- Completeness: whether all conditions of the problem are covered and edge cases are handled.
- Citation reliability: whether cited theorems, numbers, and sections actually exist, and whether statements are accurate. This is the most error-prone part of literature-based tasks.
- Expression quality: whether symbols are defined consistently and the derivation structure is clear.
- Efficiency: first-token latency, total generation time, and per-task resource usage.
- Stability: whether repeated runs on the same problem produce consistent results.
Among these, correctness and citation reliability are the most important. Fluent writing can hide logical errors, so “reads like an expert wrote it” is not evidence of correctness.
3. Building a Benchmark Set
A usable evaluation set should meet the following requirements:
- Clear problem sources, preferably from public textbooks, exercise sets, or verifiable literature entries.
- Each problem accompanied by a human-confirmed reference solution or grading criteria.
- Difficulty levels stratified, including basic problems, intermediate problems, and multi-step derivation problems.
- Avoid training-data contamination. When using public problems, check whether they already appear widely in public corpora; write new problems if necessary.
- Sufficient sample size. Accuracy based on a handful of problems has high variance and cannot reliably distinguish between two models.
For proof-type tasks, break the score into sub-items: whether premises are fully stated, whether each reasoning step is valid, and whether the conclusion matches the problem. Sub-item scoring exposes specific failure modes more effectively than a single pass/fail label.
4. Reproducible Evaluation Workflow
Evaluation should fix all variables. Prompt templates, sampling temperature, maximum output length, graders, and grading criteria must be recorded. Below is a generic framework skeleton—model interfaces should be replaced according to your team’s environment:
import jsonimport statisticsfrom dataclasses import dataclass, asdict@dataclassclass Result:item_id: strcorrect: boollatency_s: floatoutput_tokens: intnotes: str = ""def run_eval(model_call, items, grader):results = []for item in items:output, latency_s, n_tokens = model_call(item["prompt"])correct, notes = grader(item, output)results.append(Result(item["id"], correct, latency_s, n_tokens, notes))return resultsdef summarize(results):acc = sum(r.correct for r in results) / len(results)latencies = [r.latency_s for r in results]return {"accuracy": round(acc, 3),"latency_median_s": round(statistics.median(latencies), 2),"avg_output_tokens": round(statistics.mean(r.output_tokens for r in results), 1),"n": len(results),}def save(results, path):with open(path, "w", encoding="utf-8") as f:json.dump([asdict(r) for r in results], f, ensure_ascii=False, indent=2)
In practice, model_call wraps the specific API invocation, and grader can be a rule-based checker, a reference-answer comparison, or a human expert scoring rubric. For proof-type outputs, human involvement in grading is usually required. Automated grading is only feasible for problems with unique answers.
5. Trade-off Between Speed and Cost
Many model-selection discussions only compare quality and ignore latency and cost. In interactive scenarios, waiting time directly affects user experience. In batch processing scenarios, per-task cost determines whether a solution is viable. A simple metric can help:
Unit Effective Cost = single-call cost / accuracy
This metric assumes that incorrect outputs require human rework, so a lower-accuracy model amplifies total cost. If a model is faster but significantly less accurate, it may not be the more economical choice. Conversely, if the task supports automated verification and retries, a faster model combined with a verification loop may yield better overall results.
Latency also needs separate treatment. First-token latency affects interactive feel; total generation time affects batch throughput. Models with longer reasoning chains often produce higher quality but take more time. Whether they are worth it depends on the value of the task and the tolerance for errors.
6. Decision Framework for Model Selection by Task Type
Based on the analysis above, model selection can proceed as follows:
- First determine the task type and clarify error tolerance.
- For divergent tasks, prioritize speed and cost; rely on human filtering of outputs.
- For execution tasks, prioritize consistency and automatic verifiability; establish test or compilation checks.
- For derivation and proof tasks, prioritize correctness and citation reliability; arrange expert review.
- For open-ended exploration tasks, treat model output as hypothesis generation; all conclusions require independent verification.
- Within the same task type, base decisions on benchmark results rather than a single experience or personal impression.
7. Common Pitfalls and Cautions
- A single sample cannot represent overall capability. Personal impressions are heavily influenced by prompts, randomness, and task selection.
- Fluent output is not equal to a correct proof. Mathematical content must be checked step by step.
- Model-provided references must be checked against the original sources; numbers and statements can both be wrong.
- Evaluation results change as model versions are updated. Record the test date and API configuration in the report.
- For tasks involving sensitive data or internal materials, confirm the data-handling policy before deciding how to use the model.
8. Summary
To evaluate mathematical reasoning ability, the key is to decompose tasks, define metrics clearly, and test a sufficient sample. Speed and cost are important constraints in model selection, but they cannot replace correctness. A hierarchical evaluation by task type, with a reproducible process for recording results, transforms model selection from an impression-based choice into a verifiable engineering decision.
