How to Test, Evaluate, and Control Costs of LLM Mathematical Reasoning
Benchmark leaderboards alone cannot tell you how well a large language model performs on mathematical proofs, since standard test problems may already appear in training data. This article explains how to test LLMs with open-ended proof problems from the Stacks Project, set up reproducible evaluations, score reasoning across four dimensions, estimate retry costs with a simple formula, and design tiered routing with quota monitoring to control spending.
How to Test, Evaluate, and Control Costs of LLM Mathematical Reasoning
An LLM’s ability to handle mathematical proofs is hard to judge from leaderboards alone. Standard benchmark problems may already exist in the training data, so the model could be answering from memory. To evaluate reasoning ability, you need the model to construct proofs on its own, with each step verifiable.
Why Test with Open-Ended Proof Problems
Mathematical proofs have two useful properties. First, every step of the derivation can be checked, so it is immediately clear where an error occurs. Second, a problem can have no ready-made answer, forcing the model to reach a conclusion through derivation.
The Stacks Project is a publicly available algebraic geometry reference in which every proposition has a numbered tag. To run a test, pick a proposition with a relatively long proof, remove the proof from the prompt, and ask the model to produce a proof independently. Afterwards, someone with the relevant background checks the answer step by step and compares it against the original proof in the text.
How to Build a Reproducible Test
Test results are only meaningful when the conditions are documented. Record the following for every test:
| Item | What to record |
|---|---|
| Problem source | Textbook name, proposition tag |
| Difficulty description | Prerequisites involved and proof length |
| Model information | Vendor, model name, version, test date |
| Reasoning parameters | Temperature, max output tokens, reasoning mode on/off |
| Retry policy | Max retries, timeout |
| Scoring method | Scoring criteria, scorer, whether double-reviewed |
The prompt can stay short, for example:
[Task]Prove the proposition [Tag] from the Stacks Project.[Requirement]Write the complete proof in English, formatted as a LaTeX lecture note.[Constraint]Do not retrieve existing proofs. Build the argument step by step.
Use the same prompt for every model being compared, and run each model at least three times. A single success does not demonstrate stable capability.
How to Classify Reasoning Ability
Instead of labeling models directly, score them against consistent criteria. The following four dimensions cover most of what matters:
| Dimension | High score | Low score |
|---|---|---|
| Proof correctness | Conclusion holds, key lemmas are justified | Wrong conclusion or skipped key steps |
| Step verifiability | Each step can be checked independently | Vague steps, frequent reliance on “obviously” |
| Chain-of-thought length | Concise derivation, almost no unnecessary backtracking | Repeated self-correction, very long output |
| Stability | Consistent results across runs | High variance on the same problem |
Based on these dimensions, models fall roughly into three categories: those that independently produce clear, correct proofs; those that need heavy backtracking to reach a correct conclusion; and those only suitable for reformatting known proofs. This classification only interprets your own test results — it does not represent any model’s fixed capability level.
How to Balance Cost, Speed, and Quality
You usually cannot optimize all three at once. The longer the chain of thought, the more output tokens, the slower the response, and the more likely you are to hit context length limits. Retries after failure further amplify cost.
Retry cost can be estimated with a simple formula. Let the cost of a single attempt be C and the success probability of a single attempt be p, with attempts independent of each other. The expected cost of obtaining one correct proof is then roughly C / p. If the success rate is only 50%, the actual cost is about twice the per-call cost.
When selecting models for batch workloads, compare the “cost per correct result” rather than the per-call price. A cheap model with a low success rate can end up costing more overall.
How to Set Up Quota Tiers and Routing
Compute waste usually comes from two sources: unused quota expiring, or throttling under high concurrency. Tiered routing and quota monitoring reduce both problems.
The table below shows example settings; adjust the actual values based on your own usage data:
| Task type | Recommended route | Timeout (example) | Per-task budget (example) |
|---|---|---|---|
| Text polishing, code completion | Standard general-purpose model | 30 seconds | Low |
| Format conversion, coding up known solutions | Standard general-purpose model | 60 seconds | Medium |
| Complex proofs, multi-step reasoning | Reasoning model, requires manual confirmation before invocation | Several minutes, asynchronous execution | High |
Three implementation notes:
- Asynchronous task queue: Put long-running tasks that do not need immediate feedback into a message queue, write results to object storage, and keep logs. This avoids holding gateway connections open for long periods.
- Quota monitoring: Log input and output token counts per call and aggregate daily. Trigger an alert when remaining quota drops below a set threshold (for example, 20%).
- Expiration reminders: Track credit or plan expiration dates in your monitoring. One month before expiry, calculate the remaining quota and schedule batch tasks accordingly.
Common Mistakes
- Relying only on public benchmarks without running your own tests.
- Treating a single success as proof of stable capability.
- Not recording the model version, making results impossible to reproduce later.
- Not setting a maximum output length, only discovering abnormal costs after a long task times out.
- Accepting model output as a correct proof without human verification.
Next Steps
- Select 5 to 10 propositions covering different difficulty levels.
- Fix the prompt and reasoning parameters, and run each model at least three times.
- Score against the four dimensions above, recording token usage and latency for every call.
- Compute each model’s average cost per correct result, then define routing rules accordingly.
- Before going to production, validate alerting and timeout settings with a small batch of tasks.
