Evaluating Mathematical Reasoning in Large Language Models: A Practical Framework

    This article presents an engineering approach to evaluating the mathematical reasoning of large language models. It breaks mathematical ability into five measurable layers, explains how to build evaluation sets with balanced difficulty and contamination resistance, and defines metrics that go beyond accuracy to cover process validity, self-consistency, and sampling stability. It also covers controlled experiments on inference configurations and prompting strategies, common pitfalls, and how to turn evaluation into a reusable pipeline. Readers will learn how to make model selection data-driven and auditable rather than based on impressions.

    1. Background: Why “Which Model Is Better” Is Hard to Answer in One Sentence

    In real projects, teams often need to answer a seemingly simple question: how strong is a given large language model at mathematical reasoning? Many discussions end up as a pile of personal impressions—run a few problems, then rank models by feel. The issue is that mathematical reasoning is a multi-layer capability, covering arithmetic precision, symbolic manipulation, theorem invocation, multi-step planning, edge-case checking, and final self-verification. A win on a single dimension cannot represent overall ability.

    A more reasonable approach is to treat model capability evaluation as an engineering problem: first define the capability dimensions, then design the problem set and scoring rules, and finally run and archive results through a reproducible process. Only within such a framework do comparisons across models, versions, and inference configurations become meaningful.

    2. Capability Layers: Breaking “Math Ability” into Measurable Sub-Items

    It is recommended to split mathematical reasoning into five layers, each with its own problems and scoring method:

    1. Computation and numerical precision: multi-digit arithmetic, fractions and percentages, unit conversion. The focus is whether low-level arithmetic errors occur.
    2. Expressions and symbols: simplification, factorization, solving equations and inequalities. The focus is whether steps are equivalent transformations.
    3. Modeling and word problems: extracting variables and constraints from natural language. The focus is whether conditions are missed or non-existent premises are introduced.
    4. Multi-step planning: problems requiring auxiliary constructions, case analysis, recursion, or proof by contradiction. The focus is path selection and backtracking ability.
    5. Rigor and self-checking: existence discussions, extreme values, dimensional and range checks. The focus is whether the model proactively verifies its answer.

    The value of layering is that a model may score near full marks on layers 1 and 2 yet drop significantly on layers 4 and 5. Selection should weight dimensions according to real business needs rather than looking at a total score.

    3. Building the Evaluation Set: Difficulty, Distribution, and Contamination Resistance

    Set quality determines conclusion quality. Three points are worth attention when building it.

    First, the difficulty distribution should cover the full spectrum. If problems cluster at low difficulty, results hit a ceiling effect and cannot distinguish top models; if all are high difficulty, noise becomes too large. An easy/medium/hard ratio of roughly 3:4:3 works well, with a small batch of “trap problems” kept to test whether models are misled by surface structure.

    Second, prevent data contamination. Public problem banks easily end up in training corpora, inflating evaluation scores. A practical approach is to build self-made variants: keep the underlying structure unchanged while replacing numbers, rephrasing the question, and adjusting condition redundancy. Illustrative variant generation logic:

    1. def make_variant(seed, template):
    2. rng = random.Random(seed)
    3. params = {k: rng.randint(1, 50) for k in template.slots}
    4. question = template.render(params)
    5. answer = template.solve(params) # the template guarantees the answer is derivable
    6. return {"q": question, "a": answer, "level": template.level}

    Third, ensure answers can be judged automatically. Subjective problems should be converted into verifiable forms, for example by requiring a structured field for the final result so scripts can compare easily:

    1. {"result": "x=3", "checks": ["within domain", "substitution holds"]}

    4. Metrics: Moving from “Accuracy” to “Process Quality”

    Looking only at accuracy hides two risks: the process is wrong but the answer happens to be correct, and the process is correct but the presentation is messy and hard to maintain. Four metrics are recommended:

    • Result accuracy: whether the final answer is correct, as the baseline metric.
    • Process validity: whether key steps hold, checked by manual sampling or rule validation, such as detecting division by zero or undiscussed absolute-value branches.
    • Self-consistency: whether the model provides reviewable intermediate quantities that do not contradict each other.
    • Stability: consistency across multiple samples of the same problem. Math tasks are sensitive to randomness, and excessive variance means the model is not production-ready.

    In engineering, multiple sampling results can be aggregated into a simplified evaluation table like this:

    Model configuration Accuracy Process validity Self-consistency Sampling variance
    Config A 0.71 0.66 0.80 0.05
    Config B 0.68 0.74 0.85 0.03

    The numbers are only a format example and do not represent any real product’s performance. Config B has slightly lower accuracy but a more reliable process and less fluctuation, which is often a better fit in scenarios that require auditing.

    5. Controlled Experiments on Inference Configurations and Prompting Strategies

    Model capability is not an isolated variable. The same model differs noticeably under different inference budgets and prompt structures. Controlled experiments are recommended:

    1. Fix the problem set and decoding parameters, change only the inference length limit, and observe the tradeoff between accuracy and latency.
    2. Compare “answer directly” with structured prompting that lists knowns and constraints first, verifying whether missed conditions decrease.
    3. Add a self-check step requiring the model to substitute its answer back after producing it, and measure the correction rate.
    4. Classify failure samples by cause: arithmetic slips, missed conditions, wrong method choice, incomplete presentation.

    Pseudocode example:

    1. def evaluate(config, dataset, n=5):
    2. stats = defaultdict(float)
    3. for item in dataset:
    4. outs = [config.run(item.q) for _ in range(n)]
    5. stats["acc"] += mean(map(is_correct, outs, repeat(item.a)))
    6. stats["var"] += variance(map(is_correct, outs, repeat(item.a)))
    7. stats["selfcheck"] += mean(has_valid_check(o) for o in outs)
    8. return {k: v / len(dataset) for k, v in stats.items()}

    6. Common Pitfalls

    • Drawing conclusions from a few hard problems: high-difficulty samples are few and highly subject to chance.
    • Ignoring version and configuration: models keep iterating, so conclusions must state evaluation time and parameters.
    • Looking only at the final answer: process defects get amplified into maintenance costs in complex business settings.
    • Replacing business-problem validation with public leaderboard rankings: conclusions do not transfer when distributions differ.
    • Ignoring cost constraints: longer reasoning chains bring higher latency and compute overhead, which must be part of the decision.

    7. Implementation Advice: Build a Reusable Evaluation Loop

    The recommended approach is to make evaluation a pipeline: version-control the problem set, decouple scheduling of batch inference jobs through a container platform and message queue, write results to object storage, and track metrics continuously with logging and monitoring with alerts. Every model or prompt change triggers a regression evaluation that outputs a comparison report for archiving, turning selection from “impression-based judgment” into a data-driven process.

    If you need to offer math-solving capabilities externally, add constraint validation and result explanation modules at the service layer, making verifiability part of product design rather than an afterthought. Baidu AI Cloud is typically used in such scenarios to host general-purpose compute, storage, and monitoring components; the specific implementation should be designed according to business scale and compliance requirements.

    In summary, evaluating a large language model’s mathematical reasoning is less about finding a sweeping ranking and more about building a layered, reproducible, and auditable evaluation system. When dimensions are clear, the problem set is trustworthy, and metrics are complete, both technology selection and performance optimization become far more controllable.