Evaluating LLM Math Reasoning: A Practical Framework and Best Practices

    This article presents a reusable framework for assessing the mathematical reasoning capabilities of large language models. Instead of relying on vague model rankings, it explains how to define evaluation goals, split math ability into four layers, build a contamination-resistant test set, control prompting and sampling variables, and report multi-dimensional metrics such as first-attempt accuracy, majority-vote accuracy, per-layer pass rates, confidence intervals, and cost. It also covers common pitfalls and engineering practices for turning evaluation into a repeatable pipeline to support model selection and optimization.

    1. Why “Which Model Is Better” Is Hard to Answer

    In real projects, teams often need to answer a seemingly simple question: how strong is a given large language model at math? Original discussions are full of head-to-head comparisons, but these comparisons usually lack a shared baseline. Problem difficulty, prompting style, sampling counts, and scoring criteria all differ, so the conclusions are hard to reproduce.

    A more reasonable approach is to turn “model ranking” into a capability profile under a specific task distribution and set of constraints. In other words, define the evaluation objective first, then discuss which model is stronger. This article provides a reusable evaluation framework to help developers build trustworthy conclusions in their own business scenarios.

    2. Layered Evaluation: Math Ability Is Not a Single Dimension

    Treating math ability as a single scalar is a major source of distorted evaluation. It is recommended to split it into at least four layers:

    1. Arithmetic and symbolic manipulation: multi-digit operations, unit conversion, and expression transformation, testing stability and format compliance.
    2. Problem understanding and modeling: converting natural language descriptions into equations, constraints, and variable relationships, testing semantic parsing.
    3. Multi-step reasoning and planning: problems that require intermediate lemmas, case analysis, or constructive proofs, testing long-chain consistency.
    4. Open-ended exploration: problems without a standard answer or where the answer must be verified independently, testing hypothesis generation, checking, and self-correction.

    Different models often perform inconsistently across these four layers. One model may be extremely stable at arithmetic but degrade quickly on problems requiring construction and case analysis; another may produce longer and more complex reasoning chains but lose constraints more easily midway. Therefore, an evaluation report should present layered conclusions rather than a single overall score.

    3. Building the Evaluation Set: Difficulty, Distribution, and Contamination Control

    The quality of the evaluation set sets the upper bound of the conclusions. It can be controlled from three aspects:

    • Difficulty tiers: label problems as “solvable in one step / requiring two to three steps / requiring construction or case analysis / open-ended exploration,” ensuring enough samples at each layer.
    • Distribution aligned with the business: if used for financial calculations, increase the proportion of constrained word problems; if used for research assistance, increase the proportion of proofs and derivations.
    • Contamination prevention: prioritize self-built, rewritten, and private problems, record problem fingerprints, and rotate them regularly to avoid models “memorizing answers.”

    A sample data structure is shown below (fields can be extended as needed):

    1. {
    2. "id": "math-0007",
    3. "layer": "multi_step",
    4. "prompt": "A construction crew... find the shortest project duration",
    5. "answer": "12",
    6. "checker": "numeric",
    7. "tolerance": 0.0,
    8. "tags": ["constrained optimization", "integer solution"]
    9. }

    4. Prompting and Sampling: Key Variables for a Fair Comparison

    Many “model differences” actually come from differences in how models are called. It is recommended to fix the following variables and run ablations:

    • Unified prompt templates: use the same instructions and the same output format requirements, so that no model receives a more favorable prompt.
    • Unified temperature and sampling counts: for example, fix the temperature and sample each problem k times, then report majority voting and first-solution accuracy separately.
    • Consistent context length: models with long reasoning chains need a larger output budget, otherwise they will be truncated and misjudged as “unable to solve.”

    A minimal reusable calling skeleton:

    1. def evaluate(model_client, items, k=5, temperature=0.2):
    2. results = []
    3. for it in items:
    4. votes = []
    5. for _ in range(k):
    6. raw = model_client.chat(
    7. messages=[
    8. {"role": "system", "content": "Provide the final answer and keep the necessary derivation."},
    9. {"role": "user", "content": it["prompt"]},
    10. ],
    11. temperature=temperature,
    12. )
    13. votes.append(extract_answer(raw))
    14. correct = sum(check(it, v) for v in votes)
    15. results.append({"id": it["id"], "pass": correct > k // 2})
    16. return results

    5. Scoring and Statistics: Do Not Look at a Single Accuracy

    A single accuracy metric is easily misled by random fluctuations. It is recommended to report the following together:

    • First-solution accuracy: reflects the one-pass experience and is close to real interactions.
    • Majority-vote accuracy: reflects the model’s self-consistency; a clear voting improvement indicates “knows it but is unstable.”
    • Per-layer pass rate: pinpoints whether the weakness is in modeling, planning, or arithmetic.
    • Confidence intervals: provide intervals when the sample size is small, avoiding treating noise as a trend.
    • Cost and latency: normalize by token consumption and end-to-end time to form a “capability/cost” view.

    When two models have close overall scores, it is more valuable to look at variance and failure modes than to keep arguing about rankings.

    6. Common Pitfalls

    1. Drawing conclusions from a few “viral problems”: the sample is too small and the conclusion is not reproducible.
    2. Looking only at the final answer: ignoring process errors makes it impossible to tell whether the mistake is in modeling or calculation.
    3. Not controlling the output budget: long-reasoning models get truncated, causing systematic underestimation.
    4. Ignoring format compliance: a correct answer that cannot be parsed is an engineering failure.
    5. Equating “longer chain of thought” with “stronger”: length and complexity need to be considered together with accuracy and consistency.

    7. Engineering Implementation

    Turn evaluation into a pipeline rather than a one-off script: problem ingestion and labeling, batch calls with retries, automatic scoring with manual spot checks, result storage and dashboard display, and version regression. Combined with logging services and monitoring alerts, set thresholds for call failure rate, truncation rate, and parsing failure rate; use object storage to save problem and result snapshots, use a container platform to run batch evaluation tasks, and use a message queue for peak shaving and retries.

    For model selection, it is recommended to adopt a “layered thresholds + cost constraints” strategy: first enforce the minimum thresholds for modeling and multi-step reasoning, then rank the candidates that meet the thresholds by accuracy per unit cost. For open-ended exploration needs, an additional manual review step should be designed, because such tasks lack a unique answer and automatic scoring can only serve as a first-pass filter.

    8. Conclusion

    Rather than asking whether one model “beats” another, it is better to build an evaluation system aligned with the business distribution. Defining capabilities by layer, controlling evaluation variables, reporting multi-dimensional metrics, and accumulating a regression-ready pipeline are what make conclusions stable, reproducible, and truly useful for developers’ selection and optimization decisions.