Evaluating and Selecting LLMs for Mathematical Reasoning: A Practical Approach

    This article presents a method for evaluating large language models on mathematical reasoning. It covers open-ended problem solving, the trade-off between chain-of-thought length and latency, and the readability of final conclusions. It also describes engineering practices for tiered model routing, structured output, and high-concurrency inference. Readers get a reproducible evaluation process based on private test sets and their own measurements, rather than public leaderboards alone.

    As large language models see wider use, fluent text alone no longer shows whether a model can handle math-related work. Open-ended problems, complex logical derivations, and long conclusions test different abilities: reasoning depth, control over chain-of-thought, and quality of expression. This article does not compare specific products. Instead, it offers an evaluation method that teams can reproduce in their own environments, along with engineering recommendations.

    1. Three Core Evaluation Dimensions

    1. Solving Open-Ended Math Problems

    Open-ended problems have no standard solution path. The model must choose its own approach and verify its steps across multiple stages. Scores on standard benchmarks do not reflect this ability, so evaluation should use a private problem set.

    The approach works as follows:

    • Divide the problem set into three difficulty tiers. Cover types such as basic algebra, combinatorial counting, and number theory proofs.
    • Split the problems into training, validation, and test sets. Test items must not appear in any prompt examples or fine-tuning data, or the results will be inflated.
    • Sample each problem multiple times. Measure pass@k (the proportion of cases where at least one of k samples is correct) and majority-vote accuracy to see whether the model performs consistently.
    • Record the model version, temperature, system instructions, and maximum output length for every run so results can be reproduced.
    • Randomly sample incorrect answers and classify them by error type: calculation errors, skipped steps, incorrect premises, and invalid conclusions. The distribution shows where the model is weakest. Manually review at least 10% of the total errors.

    2. Chain-of-Thought Length and Conciseness

    Longer chains of thought usually support more thorough reasoning, but they also increase token consumption and response latency. During evaluation, record three numbers: average output tokens, time to first token, and end-to-end latency.

    Most business applications do not need the same reasoning length for every problem. A better approach allocates the reasoning budget dynamically based on problem difficulty. This requires three supporting mechanisms:

    • Difficulty assessment: Score problems with rules, such as problem length, the number of theorems involved, and the historical error rate, or with a small model.
    • Token budget: Set an output limit for each difficulty tier. Simple problems get lower limits, and hard problems get higher ones.
    • Fallback when the budget is exceeded: When output is truncated or no conclusion is reached, retry with a stronger model, or ask the model to check its existing results step by step.

    To validate this approach, plot a latency-accuracy curve. On the same test set, record accuracy and average latency at each budget level, then choose a configuration near the inflection point of the curve.

    3. Readability and Quality of Expression

    Conclusions from mathematical reasoning are ultimately presented to users, for example in tutoring tools or financial analysis reports. Stiff phrasing or inconsistent terminology reduces users’ trust in the results.

    Evaluate quality in three areas:

    • Language quality: Measure the grammatical error rate and terminology consistency. For example, check whether the same concept always uses the same name.
    • Human preference: Run double-blind A/B comparisons. Have at least three reviewers score each group, and calculate inter-rater agreement, such as Cohen’s Kappa. Low agreement means the scoring criteria need to be redefined.
    • Factual consistency: Substitute each numerical conclusion back into the problem to check whether it follows from the preceding steps.

    2. Methods for Model Comparison

    Public leaderboards are useful for initial screening but should not be the basis for purchasing decisions. Leaderboard versions, test dates, and scoring methods may not match your use case, and the same model can perform very differently across versions.

    Record your own test results in a table like this:

    Task Type Core Metrics Test Set Latency and Cost Records
    Open-ended proof problems pass@k, majority-vote accuracy Private problem set in three difficulty tiers Average output tokens, end-to-end latency
    Applied calculation problems Accuracy within numerical error tolerance Sampled historical business tickets Cost per problem, timeout rate
    Report generation Preference review score, factual consistency Real report excerpts Time to first token, number of rewrites

    Test every model on the same set of problems, and record the test date and version number. If your own data contradicts the conclusions of a public leaderboard, trust your own data.

    3. Engineering Practices

    1. Tiered Scheduling and Failure Fallback

    Different stages have different requirements. The core reasoning stage needs a model with high accuracy, while result formatting and report generation care more about speed and cost. Routing rules can therefore be set for each stage.

    The implementation should include the following mechanisms:

    • Routing rules: Route tasks to different models by task type or difficulty. Store the rules in configuration so they can be adjusted without code changes.
    • Timeout fallback: If a single call exceeds the set time, switch to a faster backup model and tag the result with its quality level.
    • Retry on failure: Retry network errors up to two times with exponential backoff. Count model format errors separately, and do not mix them with network retries.
    • Cost monitoring: Record token usage for each request and set a daily budget threshold. When usage exceeds the threshold, send an alert and automatically lower the output limit.

    2. Prompts and Structured Output

    The following is an example system instruction:

    1. You are a mathematical reasoning engine. Follow these rules when processing problems:
    2. 1. Number each reasoning step, and include only one inference per step.
    3. 2. Before giving a conclusion, independently verify the result once using a different method.
    4. 3. If the problem information is insufficient or the answer cannot be determined, return "Cannot determine" and do not guess.
    5. 4. Output only content that matches the JSON structure below. Do not output any other text.

    Require the model to output JSON so the program can validate it. One usable structure is shown below:

    1. {
    2. "steps": ["First step...", "Second step..."],
    3. "verification": "Result of the independent check",
    4. "answer": "Final conclusion or \"Cannot determine\"",
    5. "confidence": "high | medium | low"
    6. }

    The program should validate the output against a JSON Schema. If validation fails, append the error message to the prompt and retry once. If it still fails, log the raw output and send the request to a manual review queue. Treat timed-out requests as failures as well, so downstream systems never receive incomplete results.

    3. High-Concurrency Inference Architecture

    Long chains of thought produce large outputs, so the inference service should support streaming. The frontend can receive incremental content over SSE or WebSocket, so users see results sooner.

    Choose a message queue for asynchronous tasks based on these criteria:

    • Kafka suits high-throughput workloads, cases where multiple consumers need to read the same data, and cases that require replaying historical messages, such as log analysis and offline fine-tuning data collection.
    • RabbitMQ suits task distribution, rule-based routing, and moderate throughput, such as assigning tasks to different inference worker nodes by business type.

    Whichever component you choose, meet these requirements:

    • Idempotency: Give each request a unique request_id, and have consumers use it to deduplicate. This prevents retries from causing duplicate billing or duplicate writes.
    • Retry limit: Send messages that exceed the maximum retry count to a dead-letter queue. Keep their original content and error reasons for manual investigation.
    • Persistence: Write inference results asynchronously to object storage or a document database. Keep the model version, prompt version, and token usage so results can be retested and analyzed later.

    Inference nodes can scale automatically based on queue length. Use queue wait time as the scaling metric, not only CPU utilization. The bottleneck in inference tasks is usually waiting for the model to respond, not local computation.

    4. Scope and Risks

    LLMs are well suited to assisting with problem solving, generating solution ideas, checking common mistakes, and organizing conclusions. The following scenarios need additional safeguards:

    • Scenarios that require strict formal proofs should send model output to a formal verification tool or a qualified expert. Relying on the model’s self-check alone is not enough.
    • High-risk fields such as finance, healthcare, and education require human confirmation before conclusions are published externally.
    • After a model version update, retest it with the private problem set. The new version may perform worse on some problem types.

    Conclusion

    Selection depends on judging models with your own problems, your own metrics, and your own cost data. The methods in this article apply to any model because they do not depend on the conclusions of a specific version or vendor. Retest every quarter and record changes over time, so routing rules and budget settings can be adjusted when needed.