Evaluating and Optimizing LLM Math Reasoning: A Practical Guide to Benchmarks and API Cost Control

    This article explains how to move past subjective impressions when choosing and using large language models for high-difficulty math reasoning. It covers building a reproducible, contamination-resistant benchmark, scoring outputs across five dimensions, measuring latency and throughput for long-running inference, converting vendor unit prices into a realistic per-task cost model, and controlling cost through tiered routing, caching, budgeting, and version-regression pipelines. The goal is to help you measure correctness, traceability, expression quality, latency stability, and per-task cost on your own workload instead of relying on public leaderboards or gut feeling.

    1. Problem Background: Capability Evaluation, Cost-Effectiveness, and Quota Consumption

    As LLMs move into engineering production, developers run into three recurring problems:

    • Distorted capability assessment. The same model performs very differently across tasks. There is often a wide gap between “feels good enough” and “actually usable,” and that gap usually only becomes visible after a systematic evaluation.
    • Incomparable cost-effectiveness. Vendors differ in how they define context length, output speed, and billing. Looking at unit price alone or at a leaderboard alone won’t tell you which model actually fits your scenario.
    • Uncontrolled quota and compute consumption. Subscription services sold as “monthly quotas” or “credits” often get drained by a few high-intensity tasks before the end of the month. Token-based services tend to produce bills far higher than expected when long chains of thought drive up output cost.

    A typical scenario ties these together: a user wants a model to prove a public mathematical proposition that has no existing proof, and to present the result as structured lecture notes. This task combines high difficulty, long output, and a need for human review, which makes it an excellent capability probe. This article uses that scenario as a thread to lay out a practical evaluation and cost-governance methodology.

    2. Why “Feels Stronger” Is Not a Valid Selection Criterion

    Subjective experience carries three types of systematic bias in technical selection.

    1. Prompt-fit bias. For the same question, a short, casual prompt and a prompt with role instructions and output-format constraints can yield answers that differ by a full tier. If you compare models without a unified prompt template, you are measuring “prompt-style fit,” not model capability. In practice, you should freeze a standard set of prompt templates along with a few casual and structured variants, and avoid over-tuning for any single model.

    2. Memory bias. Public problem sets and the proof strategies for common propositions are widely present in training corpora. When a model produces a correct answer, there are two possibilities: it genuinely completed the reasoning, or it recalled material it had seen. The two have completely different reliability for downstream use. The former can handle variations of a problem; the latter collapses as soon as the problem is modified slightly.

    3. Version drift. The same model name may correspond to different weights or service configurations at different points in time. If you don’t pin the model version and call parameters (temperature, max output length, system prompt), historical evaluation data gradually becomes invalid and cross-version comparisons lose meaning.

    The conclusion is straightforward: capability evaluation must be a reproducible experiment, not a one-time impression.

    3. Building a Reproducible High-Difficulty Reasoning Benchmark

    3.1 Task-set Tiering

    It is recommended to divide tasks into four tiers by difficulty, each serving a distinct diagnostic function:

    Tier Task Characteristics Evaluation Target Judgment Method
    L1 Routine computation, symbolic operations, text extraction Basic accuracy and format compliance Automated answer comparison
    L2 Competition-level proofs, multi-step derivations Completeness of the reasoning chain Automated + sampled human review
    L3 Research-level open problems with no existing proof Original reasoning and long-range consistency Expert review
    L4 Long-document structured output Organization, numbering consistency, length control Rule checks + sampled reading

    The L3 tier is the key to distinguishing genuine model capability. Methods for confirming that “there really is no existing proof” include: searching public mathematical repositories, paper indexes, and community discussions to confirm the proposition has not been covered; or having a reviewer construct variant problems to see whether the model can transfer a method rather than apply a template.

    3.2 Contamination-Control Techniques

    • Parameter substitution. Replace specific numbers, dimensions, and function names in the original problem with symbolic parameters or adjacent values, and observe whether the answer changes correctly.
    • Weakened conclusions. Change “prove that X holds” to “give a counterexample or prove that X does not hold,” eliminating the model’s reliance on a fixed conclusion.
    • Step reordering. Require the proof to be organized in a non-standard order, such as presenting a key lemma before the main argument, to suppress templated output.
    • Reverse questioning. For a given step in the lecture notes, ask the model to explain “why a stronger known result cannot be applied directly here,” to test whether it understands the applicable conditions.

    3.3 Scoring Dimension Design

    Looking only at “is the answer correct” discards a great deal of information. It is recommended to split scoring into five dimensions, each rated 0–5:

    1. Correctness: Whether the core conclusion and reasoning chain hold, and whether there are substantive errors.
    2. Traceability: Whether each assertion can be traced back to axioms, proven lemmas, or the problem statement, and whether there is any circular reasoning.
    3. Completeness: Whether all boundary cases are covered (degenerate cases, extreme parameter values, exceptional conditions).
    4. Expression quality: Structural hierarchy, symbol consistency, uniform terminology, and complete cross-references.
    5. Instruction following: Whether length, format, language, section structure, and other constraints are strictly respected.

    Items 2 and 3 deserve the most emphasis. In a large number of “seemingly correct” outputs, the problem is not the conclusion but that a key step cites an unproven result or assumes an undeclared premise. Such defects are extremely easy to overlook during a quick human scan, so they must be checked paragraph by paragraph.

    3.4 Automated Checks for Reference Integrity and Symbol Consistency

    In structured mathematical text, a substantial portion of defects are mechanical and can be scripted, such as dangling cross-references, duplicate labels, missing symbol definitions, and assumptions that are not explicitly declared:

    1. import re
    2. def check_refs(text: str) -> list[str]:
    3. """Detect cross-references that point to non-existent labels."""
    4. labels = re.findall(r"\\label\{([^}]+)\}", text)
    5. refs = re.findall(r"\\(?:ref|eqref)\{([^}]+)\}", text)
    6. missing = sorted(set(refs) - set(labels))
    7. dup = sorted({x for x in labels if labels.count(x) > 1})
    8. report = []
    9. if missing:
    10. report.append(f"Dangling references: {missing}")
    11. if dup:
    12. report.append(f"Duplicate labels: {dup}")
    13. return report
    14. def check_symbols(text: str) -> list[str]:
    15. """Check whether symbols used in math environments are declared in the symbols section."""
    16. declared = set(re.findall(r"\n\s*[-*]\s*`?\$?([A-Za-z][A-Za-z0-9_]{0,3})`?\s*[::]", text))
    17. used = set(re.findall(r"\$([^$]{1,40})\$", text))
    18. single = {c for seg in used for c in re.findall(r"[A-Za-z]", seg)}
    19. return sorted(single - declared)

    This script only performs mechanical validation and cannot replace semantic judgment, but it can filter out a batch of low-quality outputs within seconds, concentrating human review resources where real judgment is needed.

    4. Latency, Throughput, and Predictability

    The time structure of high-end reasoning tasks is completely different from that of traditional chat. For open-ended Q&A, time to first token is usually on the order of hundreds of milliseconds to a few seconds, whereas deep reasoning tasks perform extended internal reasoning before producing the formal content. For users, “waiting in a queue” often affects the experience more than “generation speed.”

    Engineering practice needs to distinguish four metrics:

    • TTFT (Time To First Token): The time from sending the request to receiving the first visible output; it directly determines the perceived “lagginess.”
    • Output throughput: The number of effective tokens generated per second; it determines the total time to produce long lecture notes.
    • Internal reasoning overhead: The tokens and time consumed by the invisible thinking process. This often accounts for the bulk of total time and is a frequent source of billing disputes.
    • Stability: P95/P99 latency and timeout rate. Under high concurrency or during peak hours, service queuing can severely distort average latency metrics.

    Practical recommendation: include “availability during peak hours” as an independent selection metric. A model with attractive average latency but heavy queuing during evening peaks may have far lower real-world availability than the paper numbers suggest.

    5. Cost Model: From Unit Price to Per-Task Cost

    Unit prices cannot be compared directly across vendors; they must be converted into per-task cost. The basic formula is:

    1. per-task cost = input tokens × input unit price
    2. + output tokens × output unit price
    3. + visible reasoning tokens × reasoning unit price
    4. + tool-call and retrieval overhead
    5. + expected cost of failed retries

    An easily overlooked fact: the cost of deep reasoning tasks is driven mainly by the invisible thinking process and long output, not by input length. A mathematical proposition with only a few hundred input tokens can produce tens of thousands of tokens of reasoning and lecture-note output. As a result, marketing around “cheap input” is of limited meaning for this type of scenario.

    Subscription models (monthly quotas/credits) are more complex to convert. Quotas are typically granted per call or as token bundles, and they share queued resources during peak hours, so their hidden cost is time. When evaluating, you should count “waiting time × labor cost” toward the total cost; otherwise you will underestimate the real overhead of free or low-cost channels.

    6. Multi-Model Routing and Fallback Strategy

    A single model cannot simultaneously satisfy the three goals of quality, speed, and cost. The mainstream approach is tiered routing: dispatch tasks by complexity to models of different tiers.

    1. from enum import Enum
    2. class Tier(Enum):
    3. FAST = "fast" # Routine extraction, formatting, short-text rewriting
    4. BALANCED = "balanced" # General Q&A, code assistance
    5. DEEP = "deep" # Research-level reasoning, long lecture-note output
    6. # Task features -> tier mapping, implemented by rules or a lightweight classifier
    7. def route(task: dict) -> Tier:
    8. if task.get("requires_proof") or task.get("estimate_tokens", 0) > 8000:
    9. return Tier.DEEP
    10. if task.get("domain") in {"code", "structured_extract"}:
    11. return Tier.BALANCED
    12. return Tier.FAST
    13. def call_with_fallback(task: dict, models: dict, max_retry: int = 2):
    14. order = [Tier.DEEP, Tier.BALANCED, Tier.FAST]
    15. start = order.index(route(task))
    16. for tier in order[start:]:
    17. client = models.get(tier)
    18. if client is None:
    19. continue
    20. for attempt in range(max_retry):
    21. try:
    22. return client.run(task, attempt=attempt)
    23. except (TimeoutError, RateLimitError):
    24. if attempt == max_retry - 1:
    25. break
    26. raise RuntimeError("all tiers exhausted")

    Complementary governance measures include:

    • Result caching. For deterministic tasks, cache by prompt hash so repeated requests cost nothing.
    • Asynchronous and batch processing. Route non-interactive tasks through asynchronous queues, trading latency for throughput and significantly reducing the probability of peak-hour queuing.
    • Budget circuit breakers. Set per-task and per-user token limits that automatically downgrade or escalate to a human when exceeded, preventing abnormal calls from consuming a full month’s quota.
    • Call observability. Record the input/output/reasoning tokens, latency, and tier of every call to build a quality–cost–latency dashboard.

    7. Version Regression and the Evaluation Pipeline

    Model version upgrades are a high-incidence point for quality regressions. It is recommended to solidify evaluation into a pipeline that runs automatically before each change:

    1. Load the frozen benchmark task set (with samples from L1–L4).
    2. Batch-call with fixed parameters and record complete raw outputs for traceability.
    3. Run automated validation scripts (reference integrity, symbol consistency, format compliance).
    4. Aggregate the five-dimension scores, compare against the previous version, and produce a diff report.
    5. When the difference exceeds a threshold, block the release or trigger a human-review queue.

    To judge “whether a model is merely reciting existing material,” you can run a simple experiment: ask the same question three times in a row, changing the wording of the problem statement but not its mathematical structure. If the reasoning path and symbol choices across the three answers are highly consistent, the model is relying on templates rather than on-the-spot reasoning; if the path flexibly adjusts with the phrasing while the conclusion stays stable, it is more likely genuine derivation.

    8. Common Pitfalls Checklist

    • Replacing evaluation on your own task set with public leaderboard scores, ignoring distribution differences.
    • Comparing without unifying prompt templates and call parameters, thereby measuring prompt fit instead of capability.
    • Looking only at unit price and not per-task cost, underestimating the output overhead of long-reasoning scenarios.
    • Ignoring queuing and timeouts, treating the average as availability.
    • Judging evaluations only by whether the conclusion is right, without checking the validity of the reasoning chain paragraph by paragraph.
    • Not re-running the regression set after a model version upgrade, letting online quality silently regress.
    • Not setting budgets and circuit breakers on subscription quotas, then discovering at month-end that heavy tasks have already exhausted the allowance.

    9. Summary

    The core of model selection is not a vague judgment like “who is stronger,” but measuring correctness, traceability, expression quality, latency stability, and per-task cost across five dimensions on your own task distribution, using unified prompts, fixed parameters, and a reproducible benchmark. For high-difficulty scenarios like math reasoning, special attention should be paid to handling problems with no existing proof, as well as to the leverage of automated validation scripts in the filtering stage. Combined with tiered routing, asynchronous processing, budget circuit breakers, and a version-regression pipeline, you can achieve an engineering-controllable balance among quality, cost, and experience, avoiding the passive situation of “burning through the quota, unstable results, and unexpected bills.”