Evaluating Mathematical Reasoning in Large Language Models: Methods and Engineering Practice

    This article presents a systematic framework for evaluating the mathematical reasoning capabilities of large language models (LLMs). It breaks down the evaluation into key dimensions—such as answer accuracy, reasoning validity, chain-of-thought length, and self-correction ability—and provides practical guidance on designing robust evaluation sets, controlling data contamination, and conducting human review for open-ended problems. The discussion also covers throughput measurement and offers actionable recommendations for integrating these evaluations into engineering workflows. The goal is to help practitioners obtain reliable, interpretable, and cost-aware assessments of model performance beyond simple accuracy scores.

    Why Systematic Evaluation of Mathematical Reasoning Is Necessary

    Mathematical reasoning is a common benchmark for testing the logical capabilities of large language models. The answers to math problems are typically unambiguous, and the steps can be verified incrementally, making them a suitable objective metric. However, in engineering practice, a single demonstration or a small sample of test cases rarely reflects a model’s true capability. A model might perform well on a specific problem but fail on a rephrased version. It might also score highly on a standard benchmark while struggling with new, unseen problems.

    Therefore, an effective evaluation needs to answer three core questions: the range of difficulty within which the model is reliable, the stability of its reasoning process, and whether its output cost is acceptable. Only by examining these three aspects separately can the evaluation provide actionable insights.

    Decomposing the Evaluation Dimensions

    A complete evaluation of mathematical reasoning typically includes the following dimensions:

    1. Final Answer Accuracy: Calculated by difficulty level—e.g., basic problems, competition problems, and open-ended research-level questions should be scored separately.
    2. Reasoning Validity: Checks for logical jumps, citation errors, or circular arguments in the intermediate steps.
    3. Reasoning Chain Length: Records the number of generated tokens to observe the correlation between long chains and accuracy.
    4. Expression Quality: Covers clarity of definitions, consistency of notation, and whether the conclusion aligns with the preceding argument.
    5. Self-Correction Ability: Determines whether the model can backtrack and fix errors when it detects a mistake, rather than forcing a plausible explanation.

    Each dimension should be recorded in its own field. Compressing all results into a single aggregate score can obscure a model’s specific weaknesses on certain problem types.

    Designing the Evaluation Set and Controlling Data Contamination

    The quality of the evaluation set directly determines how much the conclusions can be trusted. The following points are important:

    • Diverse Sources: Combine textbook exercises, open competition problems, and original questions to avoid coverage bias of a single question type.
    • Difficulty Annotation: At least two individuals with relevant backgrounds should independently label difficulty. Questions with significant disagreement should be re-evaluated.
    • Temporal Splitting: Group questions by publication date. Since public problems may be included in training data, newer questions are a better indicator of generalization ability.
    • Private Holdout Set: Keep a portion of unpublished questions for periodic testing only, reducing the risk of benchmark overfitting from targeted tuning.

    Data contamination is a common concern. If evaluation questions or their answers have already appeared in the training corpus, the scores will be inflated. Detection methods include approximate duplicate retrieval on the question text and comparing the model’s performance on the original question versus a rewritten version. A significant gap in performance suggests memorization.

    The Relationship Between Chain-of-Thought Length and Output Quality

    A longer output does not necessarily mean more reliable reasoning. The benefit of a longer chain depends on the problem at hand: for problems requiring multiple algebraic transformations, a step-by-step expansion can help avoid skipped steps, whereas for simple questions, verbose repetition only increases cost and the chance of error.

    For analysis, it is useful to bucket questions by difficulty. Within each bucket, calculate the proportion of samples that are “correct and short,” “correct but long,” and “incorrect but long.” A high proportion of “incorrect but long” typically indicates that the model lacks an effective self-verification mechanism at that difficulty level.

    Human Review Process for Open-Ended Problems

    Automated scoring is unreliable for open-ended questions without a standard answer. A practical review workflow is as follows:

    1. The model generates a complete solution, including the final conclusion and its proof or derivation.
    2. Reviewers first check whether the conclusion is consistent with known results or testable special cases.
    3. Key steps are independently re-derived, and error types are recorded (e.g., misuse of a lemma, missed boundary conditions, notation confusion).
    4. Two reviewers score the solution independently. If their scores diverge beyond a threshold, a third reviewer makes the final call.
    5. All records are kept to support future regression tests.

    Since human review is expensive, the sample size should be controlled. Focus on the questions where model performance differs most significantly.

    Measuring Inference Performance

    Beyond mathematical ability, output speed and cost are also important for engineering decisions. Throughput is typically measured in generated tokens per second. For the results to be comparable, the input length, output cap, and concurrency must be fixed.

    The following example shows a simple measurement and evaluation framework. The generate function is an interface encapsulated by the caller, returning the generated text and token count.

    1. import time
    2. from statistics import mean
    3. def measure_throughput(generate, prompts, max_tokens=512):
    4. """Calculate the average generation throughput (tokens/s)."""
    5. total_tokens = 0
    6. start = time.perf_counter()
    7. for prompt in prompts:
    8. _, n_tokens = generate(prompt, max_tokens)
    9. total_tokens += n_tokens
    10. elapsed = time.perf_counter() - start
    11. return total_tokens / elapsed if elapsed > 0 else 0.0
    12. def evaluate_math(generate, cases, checker, max_tokens=4096):
    13. """Compute accuracy and average output length. cases is a list of dicts with id, question, answer."""
    14. records = []
    15. for case in cases:
    16. text, n_tokens = generate(case["question"], max_tokens)
    17. records.append({
    18. "id": case["id"],
    19. "correct": checker(text, case["answer"]),
    20. "tokens": n_tokens,
    21. })
    22. accuracy = mean(r["correct"] for r in records)
    23. avg_tokens = mean(r["tokens"] for r in records)
    24. return {"accuracy": accuracy, "avg_tokens": avg_tokens, "records": records}

    Note the following when using these functions:

    • Requests during a warm-up phase should not be counted, to exclude the influence of connection setup and cache initialization.
    • The same set of tests should be run multiple times under identical concurrency and context length, reporting both the mean and the variance.
    • Throughput and latency should be reported separately. Time-to-first-token affects interactive user experience, while overall throughput affects the cost of batch tasks.

    Recommendations for Engineering Implementation

    1. Define the evaluation objective before choosing the metrics. The priorities for a teaching assistant are fundamentally different from those for research validation.
    2. All results must include the test conditions: benchmark version, scoring rules, output length limits, and hardware configuration.
    3. Avoid making model selection decisions based on a single leaderboard. Combine accuracy, unit cost, and stability for a comprehensive assessment.
    4. Establish a regression mechanism so that the core evaluation set is automatically re-run after any change to the model or inference configuration.
    5. For high-risk scenarios, manual review is essential. Automated scoring should only serve as a primary screening step.

    A standardized evaluation workflow enables a team to keep track of the model’s capability boundaries during iterative development and to decide on appropriate use cases and investment directions.