How to Scientifically Evaluate LLMs' Math and Reasoning Capabilities

    In math, research, financial analysis, and software engineering, teams often ask "which LLM is better at math." Casual side-by-side tests and public leaderboard rankings are hard to reproduce and can be skewed by sampling randomness, prompt sensitivity, subjective grading, sample selection bias, and the risk that benchmark questions leaked into pretraining. This article presents a repeatable, engineering-grade approach to evaluating an LLM's mathematical and reasoning ability. It covers defining measurable dimensions, designing difficulty-stratified and out-of-distribution test sets, separating answer scoring from process scoring, controlling prompts and decoding parameters, running the pipeline with code, applying statistical significance tests, testing prompt robustness, assessing chain-of-thought quality, and guarding against evaluation contamination. The result is a selection matrix that helps each team decide which model is the most reliable fit for its own workload.

    Why Subjective Evaluation Is Often Unreliable

    “Gut feeling” can surface obvious differences, but it rarely supports a real model-selection decision, because a single experience is affected by at least four factors.

    • Sampling randomness: When decoding temperature is not zero, running the same question multiple times can produce different answers. A single correct or incorrect sample does not mean the model is stable.
    • Prompt sensitivity: For the same problem, small changes in wording, format, or whether step-by-step reasoning is requested can noticeably shift accuracy.
    • Subjective grading: Human judgment is influenced by ordering, phrasing, and prior expectations; even the same reviewer may score inconsistently across runs.
    • Sample selection bias: When picking questions by hand, people tend to choose familiar problem types or the failure cases they happen to run into, so the sample distribution can differ greatly from the real workload.

    Public leaderboards have their own limitations:

    • Evaluation methods differ—some grade only the final answer, others also assess the process.
    • Difficulty, language, and prompt templates vary, so results may not transfer to your business scenario.
    • A leaderboard score is only a result at one point in time under one sampling configuration.

    For these reasons, any model name mentioned below (including S and T in the examples) is only a placeholder—conclusions must be based on evaluation results from your own scenario.

    Define “Good” First, Then Ask “Which Is Better”

    Before evaluating, break “good at math” into concrete, measurable dimensions:

    Dimension Typical questions Scoring method
    Arithmetic & algebra Multi-step computation, solving equations Automatic result comparison
    Combinatorics & number theory Counting, divisibility, congruences Automatic result comparison
    Geometry & measurement Area/volume, coordinate geometry Automatic result comparison + spot-check of process
    Formal proofs Writing machine-checkable proofs in a formal language Decided by a proof checker
    Open-ended math problems Exploratory derivation, property proofs, counterexample construction Expert rubric + cross-review
    Applied math Business metric computation, data definitions, financial modeling Reconciliation against a rules engine or domain expert

    The more specific the dimension, the more the results can guide selection. Also confirm the deployment form up front: for on-premises private deployment, GPU memory and compute determine the available parameter sizes; when calling via a cloud service, pay attention to context length, streaming output, concurrency quotas, and content-safety and compliance policies.

    Sample Design: Difficulty Stratification and Out-of-Distribution Testing

    1. Difficulty stratification. The question bank is roughly divided into three tiers:

    • Basic tier: Standard problem types that most models solve correctly, mainly used to catch low-level mistakes.
    • Intermediate tier: Competition-style problems requiring multi-step derivation—the main band that distinguishes model capability.
    • Open tier: Exploratory problems with no standard answer or only a reference solution, used to probe a model’s reasoning boundaries.

    When evaluation resources are limited, prioritize the difficulty band where models perform similarly and discrimination is highest. A simple discrimination proxy: when overall accuracy on a question is near 0 or 1, differences between models are hard to reveal; when accuracy is near 0.5, a question usually has the strongest discriminating power.

    2. Out-of-distribution testing. A model may well have seen public question banks during pretraining, so you must add questions with the same structure but new numbers and scenarios. The approach is to fix a problem template first, then batch-generate instances with different numbers and contexts—for example, the same travel problem using different speeds, times, and distances. The gap between in-domain and out-of-domain accuracy roughly reflects how much the model has “memorized” the questions.

    3. Cover the business distribution. Sample the evaluation set according to the problem types, difficulty, units, and phrasing of real tasks—don’t build only a “collection of hard problems.” If a large share of business questions involve percentages, unit conversion, or tabular data, you must specifically cover those problem types.

    4. Build a holdout set. The holdout set is used only for final acceptance and does not participate in prompt or parameter tuning. It effectively prevents overfitting to the evaluation set; this is discussed further below.

    Scoring Design: Measure Results and Process Separately

    1. Result scoring: normalize extraction first, then judge equivalence. The prompt should require the model to output the answer in a fixed format, e.g., “Final answer: “, or use a final_answer field in structured output, and let the evaluation program extract it. The judgment after extraction should cover:

    • Conversion among fractions, decimals, and percentages;
    • Unit differences;
    • Multiple-choice answer ordering;
    • Multiple valid solutions.

    When necessary, use a general symbolic-computation library to check expression equivalence; route samples that can’t be decided to human review.

    2. Process scoring: quantify quality with a rubric. A correct result alone can’t distinguish “rigorous derivation” from “the answer happened to be right.” For open-ended and proof problems, use a rubric with weighted criteria and deduction rules—e.g., whether key steps are complete, whether the reasoning holds, whether unproven claims are used, and whether the exposition is clear. The more specific the rubric, the smaller the disagreement between reviewers.

    3. Formal verification: turn proof problems into machine-checkable tasks. For problem types that can be written as formal proofs, express the problem and answer directly in a theorem-prover language and let a proof checker decide correctness automatically. This approach is objective and reproducible, making it a suitable “ruler” for high-precision evaluation. Proof styles differ greatly across models, so provide sufficient examples and include common lemmas in the prompt to reduce syntax-level noise.

    4. Self-consistency: estimate reliability with multiple samples. Sample the same question k times and take the most frequent answer as the final result. Let n be the number of samples and c the number of correct ones; then

    pass@k = 1 − C(n−c, k) / C(n, k)

    where C is the binomial coefficient. This metric estimates “the probability of answering correctly at least k times in n samples,” reflecting a model’s capability ceiling and random fluctuation. For businesses that need stable output, single-run accuracy and its variance matter more than the highest pass@k.

    Control Variables: Prompt Templates and Decoding Parameters

    Prompt and decoding settings directly determine evaluation results, so they must be fixed and recorded.

    Prompt template essentials:

    • Difficulty adaptation: Applying “please think step by step” to routine problems can add ineffective reasoning and actually increase the error rate. A safer approach is to test both “direct answer” and “step-by-step” templates separately for different difficulty levels.
    • Output format constraints: Specify the answer format clearly to make programmatic extraction easy.
    • Answer budget: For problems with longer reasoning, set a maximum output length to avoid truncation. The budget affects both cost and accuracy and should be tested as a separate variable.
    • Retrieval and tool access: When using retrieval-augmented generation or external computation tools, record the raw tool outputs too, so you can diagnose cases where “the tool was right but the model used it wrong.”

    Decoding parameters:

    • Temperature and top_p: Use a low temperature during evaluation, e.g., set temperature to 0 or near 0, to reduce randomness; if a business genuinely needs high temperature, use multiple sampling to measure stability.
    • Max generation length: Keep it consistent with the answer budget, and record the actual output-length distribution.
    • Context construction: The number and ordering of retrieval snippets and whether conversation history is retained all affect results and should be treated as experimental variables, not defaults.
    1. # Example evaluation config (fields can be adjusted to your framework)
    2. model_id: "<id of the model under test>"
    3. prompt_template: "math_step_v3" # prompt template version
    4. decoding:
    5. temperature: 0.0 # fixed low temperature during evaluation
    6. top_p: 1.0
    7. max_tokens: 4096 # answer budget
    8. stop: ["Final answer:"] # stop after the answer to avoid meaningless continuation
    9. dataset:
    10. name: "internal_math_suite"
    11. version: "v2026.03"
    12. in_domain: "split_id.jsonl" # questions structurally identical to public sets
    13. out_of_domain: "split_ood.jsonl" # same template, new numbers and contexts
    14. holdout: "split_holdout.jsonl" # holdout set, used only for final acceptance
    15. sampling:
    16. n: 5 # samples per question, for pass@k and variance
    17. seed: 42
    18. judge:
    19. rule_based: "exact_match_after_normalize"
    20. model_based: "rubric_v1" # rubric for open-ended questions
    21. human_review_ratio: 0.1 # human spot-check ratio
    22. statistics:
    23. bootstrap_resamples: 10000
    24. confidence_level: 0.95

    Engineering the Run: Evaluation Pseudocode

    The config above can be turned into the following execution flow (pseudocode):

    1. function run_evaluation(config):
    2. results = empty table
    3. load(each split of config.dataset) # also record the dataset version
    4. for each question in each split:
    5. for i from 1 to config.sampling.n:
    6. response = call_model(question.prompt, config.prompt_template, config.decoding, seed = config.sampling.seed + i)
    7. answer = extract(response, question.answer_format)
    8. if question.answer_type == "machine_checkable":
    9. verdict = rule_compare(answer, question.ground_truth)
    10. else:
    11. verdict = rubric_score(answer, question.rubric) # multiple reviewers score independently; take the mean
    12. if question.type == "proof" and question.has_formal_version:
    13. verdict = proof_checker(answer) # machine-checkable proof is an objective verdict
    14. record{question_id, sample_index, output_length, latency, verdict, full_response}
    15. for each question, aggregate pass@1, pass@k, and accuracy variance
    16. result = statistical_summary(results, config.statistics) # mean, variance, confidence interval, error-type distribution
    17. upload(result) to object storage # keep raw responses for reproducibility and review
    18. return result

    Four recommendations for implementation:

    • Wrap the model-access layer with an adapter. Model interfaces and parameter names differ across vendors. Define a unified call interface, then map fields in the adapter—for example, max_tokens may map to different field names on different platforms, and temperature defaults differ—so you can compare models horizontally with the same pipeline.
    • Never discard raw responses. Scoring failures, truncated outputs, refusals, and format violations should be tracked separately; they are often the key clues for locating problems.
    • Layer failure attribution:

      • Extraction failure: output-format issue;
      • Reasoning error: derivation-chain issue;
      • Calculation error: arithmetic or symbolic-computation issue;
      • Comprehension bias: misreading the problem;
      • Other: refusals or safety-policy blocks.

      It is recommended to count these five error classes by “average number of occurrences” rather than only recording “fully correct or not.” For example, if class A errors involve 2.0 steps on average per failure and class B errors involve 1.2 steps, class A should be prioritized.

    • Measure error types by “average number of steps,” not “average proportion.” In open-ended problems, errors propagate; using proportion masks the error count and underestimates the difference in impact between error types.

    Also, when the evaluation workload is large, you can use a message queue to split tasks and smooth peaks, let a container platform elastically scale execution nodes, and use a log service to search and replay failed samples in one place.

    Statistical Significance: Don’t Be Misled by Noise

    • Variance and confidence intervals: With few questions, a one- or two-point gap between two models often has no statistical meaning. Use bootstrapping to resample question-level scores and report a confidence interval for the mean difference.
    • Paired comparison: When comparing two models on the same batch of questions, count questions where “both are correct,” “only model A is correct,” and “only model B is correct,” then use a paired test to judge whether the difference is significant. For example, model A gets 80 questions right and model B gets 85, so B looks better—but if 70 of them are correct for both while A has more questions correct on its own than B, the conclusion may be the opposite.
    • Multi-sample statistics: Beyond pass@k, also report mean accuracy, standard deviation, and worst-batch accuracy to reflect stability.

    Prompt Template Robustness Testing

    Rewording the same prompt can change the score noticeably. Before final evaluation, test several template variants on the same batch of questions and compute:

    robustness = 1 − (std of scores across templates / mean of scores across templates)

    The closer this value is to 1, the less sensitive the model is to prompt wording, and the more trustworthy the conclusions.

    Chain-of-Thought Quality Evaluation

    1. Don’t equate “thinking longer” with “thinking correctly.” The relationship between chain-of-thought length and accuracy differs markedly across models; some models even perform worse after longer reasoning. Record average output length, per-question token cost, and accuracy together and weigh them holistically. Long reasoning can mean higher call cost and latency, and can also cause “overthinking”—taking detours or even changing the answer on simple questions.

    2. Putting process scoring into practice.

    • Have human reviewers do pre-annotation on a small sample, unify the rules, then run the formal review;
    • Use blind review, hiding model source and ordering to reduce bias;
    • When multiple reviewers score, compute agreement (e.g., Kappa) and send samples with large disagreement to a third-party arbitrator;
    • When scaling up, prefer “overall pairwise comparison,” then combine it with a rubric—this lowers reviewer burden and gives more stable conclusions.

    3. Validate automatic process scoring. When using a model to score chains of thought, there is a risk of bias toward longer, more elaborate expressions. Periodically validate the agreement between automatic and human scores on a small human-annotated sample, so that “scorer bias” isn’t mistaken for model capability.

    Avoiding Evaluation Contamination

    • Check similarity between the question bank and training corpora: Use text similarity or n-gram matching to find suspected duplicate questions, and replace suspect questions with new instances of the same template.
    • Rotate the question bank regularly: Update some questions each round while keeping a fixed set of “anchor questions” for longitudinal comparison.
    • Require the model to show key steps: Questions answered directly are easy to memorize; once you require the derivation, memorized answers usually can’t hold up.
    • Use fresh contexts and self-made data: For example, construct business-data problems using the evaluation month’s date.
    • Isolate the holdout set: Use only the development set during tuning; the holdout set is used only at acceptance.

    Common Pitfalls to Watch For

    1. Incomplete problem information: Some questions are ambiguous or missing conditions. Flag and fix these during question-bank maintenance, otherwise a model’s “wrong answer” gets recorded as a capability problem.
    2. Drawing conclusions from a single sample: Do multiple samples at minimum, or fix the random seed to ensure reproducibility.
    3. Prompt template leaking answer hints: Don’t include reference-answer-like statements in the template.
    4. Reviewers seeing model names: Use blind review.
    5. Different answer budgets across models: Compare under a unified budget, then add an “adaptive budget” scenario.
    6. Looking only at average scores, not the distribution: High scores concentrated on a few hard problems while common easy problems in the business get wrong—averages hide this.

    Build a Selection Matrix and Evaluate Continuously

    Evaluation results should ultimately feed into a selection matrix, so different teams can make trade-offs by scenario:

    Model Math accuracy (with CI) Process quality score OOD gap Avg. latency Cost per question Content safety Deployment
    Model S … … … … … … On-prem / cloud
    Model T … … … … … … On-prem / cloud

    The table lists only dimensions and doesn’t presuppose any model’s superiority. When filling it in, set weights based on your scenario—for example, high-concurrency scenarios weight latency and cost more, while research scenarios weight process rigor more. After a model version updates, rerun a round of regression tests and compare new results with historical versions to build a traceable evaluation record.

    On Baidu AI Cloud, this pipeline can be built with general-purpose cloud products:

    • Object storage: Store datasets, evaluation configs, and raw responses;
    • Container platform: Run evaluation execution nodes and scale on demand;
    • Message queue: Split evaluation tasks and smooth traffic peaks and troughs;
    • Log service: Search failed samples in one place;
    • Monitoring & alerting: Automatically alert when accuracy drops below a threshold.

    Evaluation results can also be distilled into a knowledge base for reuse across business lines.

    Conclusion

    There is no scenario-independent absolute answer to “which model is better at math.” The scientific approach is to break the question into measurable dimensions, gather evidence by combining a stratified question bank, fixed configuration, and automated scoring with human review, and then use paired tests and confidence intervals to judge whether a difference is real. The evaluation itself should be engineered too: versioned questions, traceable parameters, reproducible results, and automated regression. With such an evaluation system in place, no matter how models iterate, a team can quickly give a well-founded answer to “which one fits my task better.”