Evaluating and Selecting LLMs for Math Reasoning: A Practical Guide

    This guide explains why asking which LLM is "the best" is the wrong starting point, and instead proposes a task-layering approach that separates divergent, execution, and hard-reasoning workloads. It shows how to build a reproducible evaluation set, define scoring dimensions, measure throughput and latency, account for token quota consumption, and implement capability routing with automatic fallback. The result is a closed loop of task layering, reproducible evaluation, cost and latency accounting, and routing that balances quality, cost, and response speed.

    1. Background: Why “Which Model Is the Strongest?” Is the Wrong Question

    In real engineering work, teams often run into debates like this: someone uses a single advanced math problem to prove a model is “not good enough,” while someone else declares another model “across-the-board superior” after one code generation session. These discussions rarely converge, and the root cause is that tasks of different natures are being mixed into the same evaluation dimension.

    Experience distilled from public discussions falls into three scenario types:

    • Divergent tasks: brainstorming, solution enumeration, naming and copywriting exploration, where the breadth and diversity of the candidate set matter;
    • Execution tasks: code completion, script writing, structured text generation, and batch data processing, where throughput, latency, and stability matter;
    • Hard-reasoning tasks: open-ended math proofs, complex formal derivations, and long-chain logical consistency, where reasoning depth and self-verification matter.

    A model’s advantage in the third category often does not translate into gains in the first. Conversely, a model that is “nearly an order of magnitude faster” in execution scenarios may be completely unusable in hard-reasoning scenarios. So the first step in selection is not ranking, but task layering.

    2. Building a Reproducible Evaluation Set: Turning Subjective Impressions into Data

    The biggest problem with subjective experience is that it is not reproducible. It is recommended to organize an internal evaluation set with the structure below. It does not need to be large, but it must cover the layers.

    1. Layer the question pool: 20–50 items per layer. For the hard-reasoning layer, prioritize propositions that have no ready-made answers in public material, so the model cannot answer from memory. The check is simple: after giving the question to the model, see whether its output overlaps heavily with existing literature. If overlap is too high, the question loses its discriminating power.
    2. Use a unified prompt template: within the same layer, use the same template and only swap the question content, reducing variance introduced by prompts.
    3. Sample multiple times: sample each question at least 3 times and record the pass rate rather than a single success or failure, so randomness is not mistaken for a capability difference.
    4. Split scoring dimensions: score “conclusion correctness,” “derivation completeness,” “expression quality,” and “format compliance” separately. Many failures are not wrong conclusions but non-compliant formatting or layout.

    An illustrative evaluation record structure:

    1. {
    2. "task_layer": "hard_reasoning",
    3. "prompt_id": "tpl_v3",
    4. "sample_index": 2,
    5. "result_correct": false,
    6. "derivation_complete": true,
    7. "format_valid": false,
    8. "latency_ms": 48200,
    9. "token_in": 1180,
    10. "token_out": 6400
    11. }

    Only with structured records can you make statistical comparisons instead of relying on “I feel like.”

    3. Capability Profiles and Evaluation Focus for the Three Task Types

    3.1 Divergent Tasks

    The focus is candidate diversity and the usable ratio. Suggested metrics: the share of candidates in a single generation that can go directly into the next step, and the semantic repetition rate among candidates. In practice, divergent tasks are not sensitive to reasoning depth but are more sensitive to sampling temperature and prompt structure, so there is no need to pay the high inference cost of a heavy model for these tasks.

    3.2 Execution Tasks

    The focus is output per unit time and first-pass rate. The most easily overlooked factor here is end-to-end latency: a solution of similar intelligence that responds nearly nine times faster will show a significantly amplified experience gap in interactive coding and batch processing. It is recommended to use “tasks completed per hour” as the core metric rather than a quality score for a single response.

    1. # Simplified implementation of end-to-end throughput evaluation
    2. def throughput(cases, call_model, timeout_s=60):
    3. done, total_latency = 0, 0.0
    4. for c in cases:
    5. try:
    6. r = call_model(c, timeout=timeout_s)
    7. if r.passed:
    8. done += 1
    9. total_latency += r.latency
    10. except TimeoutError:
    11. continue
    12. return {
    13. "pass_rate": done / len(cases),
    14. "avg_latency": total_latency / max(done, 1),
    15. "tasks_per_hour": 3600 / (total_latency / max(done, 1))
    16. }

    3.3 Hard-Reasoning Tasks

    The focus is long-chain consistency and self-correction. Open-ended proof problems are characterized by non-unique paths and the inability to match against a standard answer, so they require manual or semi-automatic review. A “staged acceptance” approach can be used: require the model to first give a proof strategy, then expand lemmas step by step, and finally integrate them. If the model produces circular reasoning at the lemma stage or cites non-existent results, it can be judged a failure without reading the whole text.

    For outputs that require formal typesetting (such as lecture notes or paper fragments), “format compliance” should be a hard gate, for example whether formula numbering, citation format, and section hierarchy can be parsed automatically.

    4. Cost and Latency: Accounting for Quota Consumption

    Many teams only compare unit prices and ignore the structure of quota consumption. A common phenomenon is that a single hard-reasoning task may consume a considerable share of the monthly quota, while execution tasks remain cost-controllable even if call volume scales up several times.

    It is recommended to build an accounting table like the one below, tracked separately by task layer:

    Task layer Avg input tokens Avg output tokens Time per call Monthly calls Quota share
    Divergent Low Medium Short High Low
    Execution Medium Medium Very short Very high Medium
    Hard reasoning High Very high Long Low High

    The conclusion is usually clear: routing hard-reasoning tasks and execution tasks to different model tiers is more economical than using the strongest model globally.

    5. Routing and Fallback: A Deployable Scheduling Strategy

    A two-layer mechanism of “capability routing + automatic fallback” is recommended.

    The first layer routes by task type: the caller explicitly declares the task layer, or a lightweight classifier predicts it. The second layer falls back or retries on timeout, rate limiting, or substandard quality.

    1. Request -> Task layer detection -> Select model tier
    2. |- Divergent/Execution -> High-throughput tier
    3. |- Hard reasoning -> High-reasoning tier
    4. |- Failure/timeout -> Retry with smaller problem granularity -> Escalate to human review

    Three engineering points need attention: first, timeout thresholds must be set per layer; using an execution-task threshold for hard-reasoning tasks will inevitably cause false kills. Second, preserve intermediate artifacts, splitting long derivations into multiple rounds for resumable execution. Third, record fallback reasons, otherwise it is impossible to tell whether the problem lies with the model or the pipeline.

    6. Implementation on Baidu AI Cloud

    To engineer the approach above, relevant general-purpose capabilities of Baidu AI Cloud can provide support:

    • Model service and unified access: a unified model invocation gateway abstracts away differences between model tiers, making per-layer routing easier;
    • Object storage: store evaluation sets, prompt template versions, and model outputs to ensure reproducibility;
    • Message queue: smooth out peaks and valleys, carry batch execution tasks, and avoid blocking interactive requests;
    • Container platform: deploy evaluation and scheduling services with elastic scaling by load;
    • Logging service and monitoring alerts: collect metrics such as latency, pass rate, and quota consumption, and set threshold alerts.

    The benefit is that evaluation, routing, and cost accounting draw from the same data source, so selection conclusions can be re-checked at any time with new data instead of relying on a one-off manual impression.

    7. Common Pitfalls

    1. Replacing internal evaluation with a single public leaderboard: the question distribution of public leaderboards usually does not match the business distribution.
    2. Ignoring format compliance: many “failures” are actually parsing failures, not reasoning failures.
    3. Using the strongest model globally: high cost and high latency, and the experience in execution scenarios actually degrades.
    4. Skipping multiple sampling: treating random fluctuation as a capability difference, leading to flip-flopping conclusions.
    5. Lacking a human review loop: hard-reasoning tasks have no fallback mechanism, and errors go straight into deliverables.

    8. Summary

    The core of model selection is not finding a “single usable” solution, but building a closed loop of task layering → reproducible evaluation → cost and latency accounting → routing and fallback. Evaluate divergent, execution, and hard-reasoning tasks separately, replace subjective impressions with structured data, and then use the general cloud capabilities of Baidu AI Cloud to solidify the process, so that a stable balance among quality, cost, and response speed can be achieved.