Evaluating Mathematical Reasoning and Cost Efficiency in Large Language Models

    A practical framework for evaluating large language models on mathematical reasoning tasks. It covers capability profiling, benchmark design, proof verification, token-level cost modeling, budget controls, evaluation asset management, monitoring, and task-based model routing. The goal is to replace isolated impressions and leaderboard rankings with reproducible evidence about quality, cost, and deployment readiness.

    Evaluating Mathematical Reasoning and Cost Efficiency in Large Language Models

    1. Define the Evaluation Target: A Capability Profile, Not a Leaderboard Position

    Large language models evolve rapidly, and developers often face a seemingly simple but difficult question: Is a particular model version worth using? Judging it from a single interaction, one generated response, or a leaderboard position often leads to unstable conclusions.

    A more reliable approach is to break the evaluation into three verifiable questions:

    1. What are the model’s capability boundaries on the target tasks?
    2. What is the total cost of completing those tasks?
    3. Can the model be deployed reliably and audited in an engineering environment?

    Evaluating mathematical reasoning typically involves proof generation, usage-based billing, cache hits, quota consumption, and comparisons between different model tiers. These factors can be organized into a general framework consisting of three elements:

    • Capability profile: Can the model solve the task correctly?
    • Cost model: How much does one task cost?
    • Engineering constraints: Can the workflow run continuously, remain within budget, and produce results that can be reviewed?

    Mathematical reasoning is not a single capability. It may include basic computation, condition interpretation, long-chain reasoning, proof construction, counterexample search, formal expression, step-level verifiability, stability, and reproducibility.

    A model may perform well on standard problems but expose skipped steps, circular reasoning, or citation hallucinations when asked to prove a proposition for which no proof is provided in the public reference material. Likewise, a model may be inexpensive for short question-answering tasks but become costly during long proof generation because of its high output-token usage.

    For this reason, evaluation should move beyond overall rankings and instead build a task-level capability profile.

    2. Designing Mathematical Reasoning Evaluations: Data Sources, Prompts, Scoring, and Review

    2.1 Build a Representative Dataset While Reducing Leakage Risk

    An evaluation set should not consist only of common problems. Frequently used problems may already appear in training data, meaning that a model’s performance could reflect memorized reproduction rather than independent reasoning.

    A more robust approach is to create a tiered dataset:

    • Basic computation and concept questions to measure the performance floor
    • Medium-difficulty, multi-step reasoning problems to assess process stability
    • Propositions without publicly available proofs, or tasks requiring an independently constructed proof, to test independent reasoning
    • Formal or structured expression tasks to evaluate output verifiability

    For propositions without an included proof, asking the model to generate one independently and then verifying it manually or with semi-automated tools can reduce the risk of simple reproduction. However, training-data leakage remains possible.

    It is therefore advisable to maintain a portion of the dataset as a holdout set. Holdout problems should not be included in prompt examples, fine-tuning data, or public releases. The dataset should also be versioned, with records for the source, difficulty, expected answer, acceptable proof paths, and scoring criteria.

    2.2 Standardize Prompts to Avoid Contaminating Results with Prompting Techniques

    When comparing models, prompts should be as consistent as possible. A standardized prompt can define the role, output format, and reasoning requirements. For example, the model may be asked to:

    1. List the known conditions
    2. State the key lemmas
    3. Provide the proof
    4. Present a verifiable conclusion

    If open-book retrieval is being tested, it should be evaluated in a separate group. If closed-book reasoning is the target, external retrieval should be disabled. Otherwise, differences in prompting may create large variations between models and make the results difficult to compare.

    The following parameters should also be recorded:

    • Prompt version
    • Temperature
    • Maximum output length
    • Whether retries are allowed
    • Whether caching is enabled

    Maximum output length requires particular attention in mathematical proof tasks. A limit that is too short may produce an incomplete proof, while an excessively large limit can increase costs and introduce unnecessary content. Task-specific output budgets are preferable to allowing unlimited generation across all tasks.

    2.3 Score More Than the Final Answer

    Mathematical reasoning should be evaluated across multiple dimensions, including:

    • Correctness of the final conclusion
    • Completeness of key steps
    • Degree of logical jumping
    • Accurate use of cited facts and conditions
    • Consistency of formal notation
    • Explainability of failure modes
    • Stability across repeated runs

    For proof tasks, a combination of double-blind review and automated or rule-based checks is recommended. Structural completeness and symbol consistency can first be checked automatically, followed by human review of whether the key lemmas are valid.

    Dimension Key Question Suggested Evidence
    Correctness Is the conclusion valid? Reference answer and human review
    Process quality Are the key steps complete? Step-by-step proof and lemma list
    Verifiability Can the output be checked? Structured markers and consistent notation
    Stability Is the output consistent across runs? Repeated sampling and variance statistics
    Cost How much does each task consume? Input, output, and cached tokens
    Risk Does the output contain citation hallucinations? Citation verification and failure-mode classification

    2.4 Use Pseudocode to Build a Reproducible Evaluation Pipeline

    The following vendor-neutral pseudocode illustrates the fields that should be recorded during evaluation:

    1. def run_math_eval(model_client, tasks, budget):
    2. records = []
    3. for task in tasks:
    4. if budget.exhausted():
    5. break
    6. prompt = build_prompt(task, version="eval-v1")
    7. resp = model_client.generate(
    8. prompt=prompt,
    9. max_output_tokens=task.max_output_tokens,
    10. temperature=0
    11. )
    12. record = {
    13. "task_id": task.id,
    14. "model_version": resp.model_version,
    15. "prompt_version": "eval-v1",
    16. "input_tokens": resp.usage.input_tokens,
    17. "output_tokens": resp.usage.output_tokens,
    18. "cache_hit_tokens": resp.usage.cache_hit_tokens,
    19. "estimated_cost": estimate_cost(resp.usage),
    20. "proof_check": check_proof_structure(resp.text),
    21. "human_review": None,
    22. "latency_ms": resp.latency_ms
    23. }
    24. records.append(record)
    25. audit_log(record)
    26. return records

    The important point is not the interface syntax, but the information being captured: model version, prompt version, token usage, cache hits, structural-check results, and human-review status. Without these fields, evaluation is difficult to reproduce or audit.

    3. Cost Modeling: Separate Output Tokens, Cache Hits, and Quota Packages

    3.1 Abstract the Billing Structure into a Cost Formula

    Many services distinguish between input tokens, output tokens, and cached tokens. Output tokens are often priced higher, although the exact billing rules depend on the applicable service terms.

    Mathematical proof tasks often contain many intermediate steps, so long reasoning chains can significantly increase output costs. As a result, it is not sufficient to judge affordability based only on input-token pricing.

    A comprehensive cost model can be expressed as:

    Total cost = input-token cost + output-token cost + repeated-context cost caused by cache misses + retry cost + human-review cost + queueing cost

    Cache hits can reduce the cost of repeated context, but it should not be assumed that every task will achieve a high cache-hit rate. Proof-generation tasks often involve long contexts and long outputs. The value of caching depends on how much of the task template can be reused.

    If a large portion of the prompt is shared across tasks, caching is more valuable. If every task is a new problem with little reusable context, the benefit will be limited.

    3.2 Quota Packages and Credit Systems Should Not Replace Long-Term Model Selection

    Usage-based billing, prepaid quota packages, and credit systems are common purchasing models. When a short-term quota is close to expiration, a team may be tempted to use low-risk tasks simply to consume the remaining balance. This behavior should not affect long-term model selection.

    Fast quota consumption may indicate a high per-task output cost. Slow consumption does not necessarily mean that a model is better; it may simply produce shorter outputs or be used on simpler tasks.

    During evaluation, quota consumption should be converted into a per-task cost and compared with the value of the task.

    For example, generating a medium-sized proof tutorial may consume a significant portion of a quota package. If the task has high value and can be reviewed manually, the cost may be acceptable. If it is a low-value batch task, a lower-cost strategy should be used, or the budget should be controlled through caching, batching, output limits, or model fallback.

    3.3 Implement Budget Guardrails as Engineering Controls

    Budget guardrails should include at least the following:

    • Set a maximum output-token limit for each task
    • Define daily or weekly budgets for each project
    • Restrict high-cost models to approved use cases
    • Limit the number of retries
    • Record the cost and task ID for every call
    • Trigger alerts for unusually long outputs

    For mathematical proof tasks, a two-stage strategy can be useful: first request a short proof outline, then ask for a complete proof only after a human determines that the outline is valuable. This avoids generating large amounts of content that may ultimately be unusable.

    4. Engineering Deployment: Evaluation Assets, Logs, Monitoring, and Routing

    4.1 Version Evaluation Assets

    Datasets, prompts, scoring criteria, model outputs, and human-review records should all be stored with version control.

    Object storage can be used for evaluation datasets and proof artifacts, while logging services can record call-level audit data. Monitoring and alerting systems can track cost, error rates, and latency. General-purpose capabilities available from platforms such as Baidu AI Cloud may support these workflows, but the specific choice should depend on the existing infrastructure. The focus here is on the general methodology rather than a particular platform.

    4.2 Route Tasks According to Their Value and Difficulty

    Not every task should be sent to the most powerful reasoning model. A more practical routing strategy is:

    • Use a strong reasoning model for high-value, difficult tasks that require independent proofs
    • Use lower-cost models for routine questions and formatting tasks
    • Prioritize caching when large portions of the context are repeated
    • Define fallback paths and human review for failed tasks

    Routing policies should be configurable and auditable. A default policy that sends every request to the strongest model can quickly lead to uncontrolled costs.

    5. Conclusion: Replace Isolated Impressions with Reproducible Evidence

    The evaluation of a large language model version should ultimately produce three types of conclusions:

    • Capability conclusions: Which task categories are usable, and which still require human review?
    • Cost conclusions: What is the per-task cost, how much value does caching provide, and what budget limits are required?
    • Engineering conclusions: What are the model’s stability, auditability, and deployment boundaries?

    A single user experience can provide a useful signal, but it cannot replace systematic evaluation. Short-term quota consumption can indicate cost behavior, but it should not replace long-term model selection.

    Only by considering capability, cost, and engineering constraints together can teams make technical decisions that are explainable, reproducible, and suitable for continuous optimization.