Evaluating LLM Mathematical Reasoning: Methods and Practical Implementation

    A reliable evaluation of large language models’ mathematical reasoning requires more than a few successful examples. This article explains how to define evaluation goals, build stratified and verifiable test sets, assess answers and reasoning separately, report statistical uncertainty, and integrate reproducible testing into engineering workflows. It also covers data contamination, expert review of open-ended problems, and common evaluation pitfalls.

    1. Why Informal Judgments Are Unreliable

    Mathematical ability in large language models (LLMs) is often judged using a handful of personally selected problems or a single conversation. This approach has three clear limitations.

    First, individual outputs are stochastic. The same problem can produce different conclusions under different sampling settings. One correct response does not demonstrate consistent competence in that problem category.

    Second, fluent language does not guarantee correct reasoning. A model may produce a well-structured, technically worded solution while making an error at a critical step. Such errors can be difficult to spot during a quick manual review.

    Third, presentation affects subjective scoring. Clearly organized steps and polished formatting can receive favorable ratings even when the conclusion is wrong. Evaluation should therefore distinguish answer correctness from presentation quality.

    2. Define the Evaluation Goals

    Before testing, answer three questions:

    1. What ability is being evaluated? Solving problems correctly, writing proofs, and exploring unresolved problems require substantially different evaluation methods.
    2. What is the intended use case? Educational tutoring, research assistance, and numerical computation in engineering have different requirements for correctness and explainability.
    3. What error rate is acceptable? If incorrect judgments could cause practical losses, evaluation requires larger samples and stricter review.

    Without clear goals, a test set can become skewed toward problems the model handles well, making the results less useful.

    3. Design the Test Set

    3.1 Stratify by Difficulty and Mathematical Domain

    A test set should cover categories such as:

    • Basic computation: fractions, exponents, logarithms, and polynomial simplification.
    • Algebra and equations: systems of equations, inequalities, and polynomial factorization.
    • Combinatorics: permutations and combinations, recurrence relations, and the inclusion–exclusion principle.
    • Number theory: divisibility, congruences, and prime factorization.
    • Geometry and trigonometry: coordinate calculations, similarity, and area relationships.
    • Proof problems: induction, contradiction, and constructive proofs.

    Divide each category into difficulty levels. This makes it possible to examine how performance changes with difficulty rather than relying on a single overall average.

    3.2 Use Problems with Verifiable Answers

    Verifiable problems generally fall into three groups:

    • Unique numerical answers: integers, fractions, or fixed expressions that can be compared automatically.
    • Programmatically checkable answers: constructions, for example, whose properties can be verified with code.
    • Answers requiring human review: proofs and open-ended responses that experts assess against a scoring rubric.

    Automated grading supports large-scale testing, while human review enables deeper analysis. Both should be used together.

    3.3 Control for Data Contamination

    If test problems are publicly available and may have appeared in training data, high scores may reflect memorization rather than reasoning. Ways to reduce this risk include:

    • Creating original problems or using new problems published after the model’s training cutoff.
    • Recording each problem’s source and publication date for later auditing.
    • Creating variants of the same problem, such as changing numerical values or reordering conditions, and checking whether accuracy drops substantially.

    A large accuracy gap between original problems and their variants may indicate reliance on fixed solution patterns.

    4. Implement Answer Checking

    The core of automated answer checking is to normalize answers before comparing them. The following example handles integers and fractions consistently using only the Python standard library:

    1. from fractions import Fraction
    2. def normalize(ans: str):
    3. """Remove spaces and parse as an exact fraction; otherwise keep the string."""
    4. cleaned = ans.strip().replace(" ", "")
    5. try:
    6. return Fraction(cleaned)
    7. except (ValueError, ZeroDivisionError):
    8. return cleaned
    9. def is_correct(pred: str, gold: str) -> bool:
    10. """Check whether the predicted and reference answers are equivalent."""
    11. return normalize(pred) == normalize(gold)
    12. # Example: 2/4 and 1/2 are treated as equivalent.
    13. assert is_correct("2/4", "1/2")
    14. assert not is_correct("0.33", "1/3")

    String normalization only handles simple formats. Answers containing radicals, integrals, or symbolic expressions require symbolic computation or manual review. Approximate floating-point answers should not be accepted unless the problem explicitly permits an error tolerance.

    5. Evaluate the Reasoning Process

    A correct final answer does not necessarily imply reliable reasoning. Review the solution along four dimensions:

    1. Completeness of key steps: Is each deduction justified? Have necessary checks on conditions been skipped?
    2. Logical consistency: Do any conclusions contradict earlier statements? Is there circular reasoning?
    3. Treatment of edge cases: Does the solution account for zero denominators, domain restrictions, and special values?
    4. Consistency with the assumptions: In a proof, does the conclusion actually follow from the given conditions?

    In practice, define a rubric for each problem. For example, assign each key step a score from 0 to 2, then aggregate those scores into a reasoning-process score.

    1. def process_score(step_scores: list[int], max_per_step: int = 2) -> float:
    2. """Normalize key-step scores to a process score between 0 and 1."""
    3. if not step_scores:
    4. return 0.0
    5. total_possible = len(step_scores) * max_per_step
    6. return sum(step_scores) / total_possible

    Reviewers should read the reference solution and scoring guidelines before scoring independently. When multiple reviewers are involved, measure inter-rater agreement. Substantial disagreement indicates that the rubric needs clarification.

    6. Report Results and Statistical Uncertainty

    A model’s results on the same test set can vary because of sampling. Accuracy reports should include both the sample size and an interval estimate.

    For observed accuracy (\hat{p}) over (n) problems, an approximate standard error is:

    [
    \mathrm{SE} = \sqrt{\frac{\hat{p}(1-\hat{p})}{n}}
    ]

    Smaller test sets produce wider intervals. With only a few dozen problems, a difference of several percentage points between two models is usually insufficient to establish which is better. Increase the number of problems, or sample multiple responses for each problem and report the mean and variability across runs.

    When comparing two models, use a paired design: have both models answer the same set of problems, then compare their correctness on each problem. This helps control for differences in problem difficulty.

    7. Handle Open-Ended Problems Separately

    Automated grading is generally unsuitable for open-ended problems without established answers. A more reliable approach is to:

    • Invite domain experts to conduct blind reviews without knowing which system produced each response.
    • Define review criteria in advance, such as the correctness of conclusions, completeness of arguments, and whether the response offers a new, valid approach.
    • Measure agreement between reviewers using metrics such as Cohen’s kappa.
    • Link each review to the corresponding output and preserve the original text for later inspection.

    For unresolved problems, whether a conclusion is correct may itself require expert investigation.

    This type of evaluation is time-consuming. It is better suited to important decisions than to routine regression testing.

    8. Avoid Common Evaluation Pitfalls

    • Showing only successful examples: Selected demonstrations do not represent overall ability. Report the complete test results, including failures.
    • Considering only final answers: Errors in reasoning may recur in the same form on later problems.
    • Ignoring presentation bias: Hide model identities where possible and standardize formatting to reduce reviewers’ stylistic preferences.
    • Ignoring cost and latency: Longer reasoning outputs affect response time and usage cost. Consider both alongside accuracy when choosing a model.
    • Treating one test as a lasting conclusion: Results may no longer hold after changes to the model version, prompts, or parameter settings.

    9. Integrate Evaluation into Engineering Workflows

    Mathematical capability testing can be included in continuous integration. A practical workflow should:

    1. Maintain a fixed regression test set, storing each problem’s reference answer, category, and difficulty labels.
    2. Record the complete configuration for every evaluation, including the model version, prompt template, sampling parameters, and run date.
    3. Store results in a structured format so they can be compared by category, difficulty, and time period.
    1. import json
    2. from datetime import datetime, timezone
    3. def save_run_record(path: str, config: dict, results: list[dict]) -> None:
    4. """Save evaluation configuration and per-problem results for later review."""
    5. record = {
    6. "timestamp": datetime.now(timezone.utc).isoformat(),
    7. "config": config,
    8. "results": results,
    9. }
    10. with open(path, "w", encoding="utf-8") as f:
    11. json.dump(record, f, ensure_ascii=False, indent=2)

    Regression tests should prioritize problems that previously produced errors. If a new version performs worse on these problems, investigate the cause before deciding whether to deploy it.

    10. Conclusion

    Reliable evaluation of LLM mathematical reasoning rests on three principles: use stratified, verifiable problems; assess both final answers and the reasoning process; and report statistical conclusions with sample sizes and confidence intervals.

    Open-ended problems require blind expert review, while routine testing benefits from fixed test sets and complete run records. Following this process gives teams reproducible evidence of a model’s performance on mathematical tasks and a sounder basis for technical selection.