A Guide to Evaluating LLM Math Reasoning and Choosing a Model for Self-Hosted Deployment

    This guide explains how to set up a fair math-reasoning evaluation for large language models. It covers the conditions to record, a three-dimension scoring rubric, a Python evaluation script with its aggregation rules, criteria for comparing model types, and the details needed to report throughput for self-hosted deployments.

    1. Standardize the Evaluation Conditions

    Fix the evaluation conditions before comparing math reasoning ability. The same model can score very differently across test sets, decoding parameters, and prompts. Relying on a single ranking can easily lead to wrong conclusions.

    Record the following fields for every evaluation: the test set name and version; the number of problems and their difficulty distribution; decoding parameters (temperature, top_p, and maximum output length); whether a complete derivation is required in the output; the test date; and how answers are judged.

    Break the evaluation into three dimensions, each scored from 1 to 5:

    1. Logical leap reasonableness. A score of 1 means key steps are missing and the conclusion does not hold. A score of 3 means the steps are mostly complete, with a few jumps the reader must fill in. A score of 5 means any omitted steps are redundant and can be filled in mechanically, with no errors.
    2. Symbolic manipulation stability. A score of 1 means results on the same problem vary across repeated samples, or obvious incorrect transformations appear. A score of 3 means simple derivations are correct, while complex ones occasionally go wrong. A score of 5 means results are consistent across repeated samples of the same type of problem, and intermediate expressions can be verified independently.
    3. Self-correction ability. A score of 1 means the model does not backtrack after entering a wrong path. A score of 3 means it corrects errors only after being prompted. A score of 5 means it notices contradictions without prompting and switches to a new method.

    Automatic grading only covers the final answer. The quality of the derivations still requires manual spot checks. Check at least 20 problems per model.

    2. Evaluation Script

    The script below depends only on the Python standard library, version 3.9 or later. Replace model.generate with the actual model call interface. The model’s output must end with a line that starts with ANSWER:, so the final answer can be extracted.

    1. from dataclasses import dataclass
    2. from statistics import mean, pstdev
    3. @dataclass
    4. class Problem:
    5. pid: str
    6. text: str
    7. ground_truth: str
    8. category: str # e.g. "algebra", "combinatorics", "analysis"
    9. def extract_final_answer(output: str) -> str:
    10. """Return the content of the last line that starts with ANSWER:, or an empty string if none is found."""
    11. for line in reversed(output.strip().splitlines()):
    12. if line.startswith("ANSWER:"):
    13. return line.removeprefix("ANSWER:").strip()
    14. return ""
    15. def is_correct(answer: str, truth: str) -> bool:
    16. """Simple string comparison. For formal evaluation, use a symbolic equivalence check instead, such as simplifying with sympy before comparing."""
    17. return answer.replace(" ", "") == truth.replace(" ", "")
    18. def evaluate(model, problems: list[Problem], n_samples: int = 3) -> dict:
    19. records = []
    20. for p in problems:
    21. answers, token_counts = [], []
    22. for seed in range(n_samples):
    23. out = model.generate(p.text, seed=seed, temperature=0.7, max_tokens=4096)
    24. answers.append(extract_final_answer(out.text))
    25. token_counts.append(out.completion_tokens)
    26. flags = [is_correct(a, p.ground_truth) for a in answers]
    27. records.append({
    28. "pid": p.pid,
    29. "category": p.category,
    30. "accuracy": mean(flags), # Fraction of correct samples for this problem
    31. "consistent": len(set(answers)) == 1, # Whether all samples gave the same answer
    32. "avg_tokens": mean(token_counts), # Average output length, replacing the subjective chain-of-thought score
    33. })
    34. return {
    35. "accuracy": mean(r["accuracy"] for r in records),
    36. "consistency_rate": mean(r["consistent"] for r in records),
    37. "avg_tokens": mean(r["avg_tokens"] for r in records),
    38. "token_std": pstdev(r["avg_tokens"] for r in records),
    39. "records": records,
    40. }

    The aggregation rules are as follows. Accuracy is the average of per-problem accuracy across all problems. Consistency is the proportion of problems whose answers stay the same across repeated samples. The mean and standard deviation of output length show how verbose each model’s derivations are. The script does not produce a composite score. Overall judgments should combine the three-dimension scoring table with the manual spot-check results.

    3. Comparing Model Tiers

    This article does not list specific model rankings. Math-capable model versions are updated frequently, and public leaderboard scores should only be cited after verifying their test conditions.

    Based on output style, common models fall roughly into three categories. Actual performance should be judged by your own tests.

    • Deep-reasoning models: They produce long derivation chains with broad coverage, and their accuracy on hard problems is usually higher. The cost is more output tokens per problem, higher latency, and lower throughput.
    • Concise and efficient models: They produce short output with clean derivations, which suits routine problems and high-concurrency workloads. On obscure or very hard problems, they may skip steps.
    • Balanced models: They produce moderate-length output and perform stably on routine tasks. On open-ended, very difficult problems, they are usually slightly weaker than deep-reasoning models.

    When selecting a model, record results in the table below. Results are only comparable when they use the same evaluation set and decoding parameters, with at least three samples per problem.

    Model Test date Test set and version Accuracy Consistency Average output tokens Main limitations
    TBD
    TBD

    4. Deployment Parameters and Throughput Measurement

    Throughput is defined as total output tokens divided by wall-clock time in seconds. This number is only meaningful when reported together with the following information:

    • Model parameter size and precision (BF16, FP8, INT4, etc.)
    • The distribution of input and output lengths, not just the averages
    • Concurrency or batch settings
    • GPU model, GPU count, and number of nodes
    • Tensor parallelism and pipeline parallelism configuration
    • Inference engine and its version number