Evaluating and Selecting LLMs for Mathematical Reasoning: A Practical Framework

    This article presents a reproducible framework for evaluating and selecting large language models on open-ended mathematical tasks. Instead of relying on one-dimensional leaderboards, it breaks mathematical ability into five observable layers, explains how to build a stratified evaluation set with calibrated difficulty, and shows how to control variables such as prompts, sampling parameters, and tool access for fair comparisons. It also covers process-level metrics, cost and latency constraints, model routing and orchestration patterns, and continuous regression testing, helping teams reach stable and explainable conclusions on their own data.

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

    In practice, teams often face a seemingly simple question: which model should we choose for open-ended mathematical tasks? A common approach in community discussions is to arrange several models in a linear leaderboard and make selection decisions accordingly. The problem is that this compresses multi-dimensional capability into a single rank, ignoring key variables such as task distribution, prompting style, decoding parameters, tool availability, and cost constraints.

    A more reliable approach is to treat “model capability” as a quantity that can only be compared under a clearly defined evaluation protocol. Such a protocol has four elements: problem distribution, prompt template, number of samples, and judging method. Changing any one of them can reverse the ranking. This article therefore does not discuss any specific product ranking. Instead, it provides a reproducible evaluation framework that helps developers draw conclusions on their own data.

    2. Capability Layers: Breaking “Math Ability” into Observable Sub-items

    A vague claim that a model is “good at math” has little engineering value. It is better to split the ability into five layers:

    1. Stability of arithmetic and symbolic operations: whether long expansions, simplifications, and unit conversions are error-free.
    2. Theorem and formula retrieval: whether known results are invoked correctly rather than invented.
    3. Multi-step reasoning depth: whether errors accumulate when a derivation requires more than ten steps.
    4. Open-ended problem construction: whether a feasible construction can be produced and self-verified when no unique solution exists.
    5. Self-checking and backtracking: whether the model can fall back and recompute when intermediate conclusions conflict.

    Open-ended problems are the dividing line. They have infinitely many valid answers, so the model must both construct and verify, which is fundamentally different from closed problems that only require matching a standard answer. The two types should be counted separately during evaluation; otherwise, the total score is diluted by a large number of simple closed problems.

    3. Building the Evaluation Set: Stratified Sampling and Difficulty Calibration

    A question bank of roughly two hundred to five hundred items is recommended, sampled in layers according to the five capabilities above, with at least thirty items per layer. Difficulty calibration should not rely on intuition. Two objective signals can be used: first, items with a first-attempt pass rate below twenty percent across most models are classified as the hard layer; second, items whose pass rate varies greatly under different prompts are marked as “prompt-sensitive items” and observed separately.

    Three points matter when constructing the data: problem statements should avoid relying on the notation conventions of a specific textbook; answer judging should prefer executable validation scripts; for open-ended items, prepare one reference construction and one judge that checks whether all constraints are satisfied rather than comparing against a standard expression.

    The judging logic can be sketched as follows:

    1. def judge(open_item, answer):
    2. # Pass only if all constraints are satisfied; no string comparison
    3. for c in open_item.constraints:
    4. if not c.check(answer):
    5. return False, c.name
    6. return True, "ok"

    4. Controlling Variables for a Fair Comparison

    Most conclusions that “model A is worse than model B” actually come from uncontrolled variables. At least the following should be fixed:

    • A unified prompt template that includes the role description, a list of constraints, and output format requirements;
    • Unified sampling parameters, with the same temperature and maximum output length;
    • An independent session per item to avoid context bleeding between questions;
    • Three to five repeated samples per item, using pass rate rather than a single result;
    • Consistent tool availability, with tool-assisted and tool-free groups reported separately.

    Tool use is especially important. When symbolic computation or numerical checking is allowed, the model’s ability to externalize verification is counted in the score. This is a different capability from pure language reasoning, and reporting them mixed together misleads selection.

    5. Process Metrics: Do Not Look Only at the Final Answer

    Looking only at answer accuracy hides two risks: correct answers with flawed processes, and wrong answers with nearly correct processes. Three additional metrics are suggested:

    1. Process consistency rate: whether intermediate conclusions are consistent with the final answer;
    2. Average effective steps: the shortest derivation length needed to reach the correct result, reflecting whether the chain of thought is redundant;
    3. Backtracking success rate: whether the model can detect and fix a contradiction on its own.

    In engineering, structured output can carry process information for automatic statistics:

    1. {
    2. "steps": [
    3. {"claim": "simplify denominator", "result": "x != 1"},
    4. {"claim": "substitute boundary", "result": "no solution"}
    5. ],
    6. "final": "no solution",
    7. "self_check": "passed"
    8. }

    In practice, models with more concise chains of thought and higher process consistency are more stable on long tasks. Models with extremely long chains of thought may have a higher ceiling on individual items, but latency and cost rise significantly, and they are more likely to introduce irrelevant branches midway.

    6. Cost, Latency, and Stability Constraints

    Selection must return to engineering constraints. A four-dimensional evaluation table is recommended: average time per item, average token consumption per item, pass rate, and distribution of failure modes. Dividing pass rate by cost yields a cost-performance metric, and adding latency percentiles makes it possible to judge whether a configuration can go into an online pipeline.

    If the task is offline batch processing, a configuration with a higher ceiling can be preferred, and stability can be improved with multi-sample voting. If it is online interaction, output length should be limited, streaming responses enabled, and timeouts and fallback strategies set for overly long reasoning. The fallback strategy is itself part of capability: returning partial reasoning with a hint for continuation after a timeout is more usable than failing outright.

    7. Model Combination and Orchestration Strategies

    A single model rarely leads on all layers at once, so combined orchestration is often more cost-effective. Three common patterns exist:

    • Routing: predict difficulty by layer, send easy items to a lightweight configuration and escalate hard ones;
    • Parallel voting: sample multiple paths for the same item and use the judge to filter valid answers;
    • Separation of generation and checking: generation and verification are handled by different configurations, with the verifier only checking constraints.

    The difficulty of routing is that the difficulty prediction itself can be wrong. A confidence threshold is recommended: below the threshold, escalate directly to avoid long-tail failures caused by misjudgment.

    8. Observability and Continuous Regression

    Evaluation is not a one-off activity. The question bank, prompt templates, and judges should be placed under version control, and a regression run should be triggered on every configuration or prompt change, with a retained set of failure cases. On the production side, it is advisable to collect desensitized statistical features without raw prompt text, including task layer distribution, timeout rate, tool call failure rate, and manual review conclusions, forming a closed loop.

    9. Common Pitfalls

    1. Using a closed-problem total score to represent open-ended capability;
    2. Drawing conclusions from a single sample while ignoring variance;
    3. Reporting only accuracy without cost and latency;
    4. Mixing results with and without tools;
    5. Mistaking gains from prompt optimization for model capability improvements.

    10. Implementation Checklist

    1. Define task layers and the judge;
    2. Fix prompts and sampling parameters;
    3. Sample multiple times per item and record process structure;
    4. Produce the four-dimensional evaluation table and a cost-performance ranking;
    5. Set timeout and fallback strategies;
    6. Establish regression testing and a failure case library.

    Following this workflow, teams can obtain stable, reproducible, and explainable conclusions on their own data without relying on external leaderboards. To store the question bank and result data, object storage can hold samples, a message queue can distribute evaluation tasks, a container platform can run the judges, and logging and monitoring services can track regression metrics. These general capabilities are available in corresponding categories on Baidu AI Cloud.