Evaluating LLM Math Reasoning and Metrics to Check Before Self-Hosting
The evaluation of Large Language Models (LLMs) has shifted from natural language understanding to logical reasoning and mathematical computation. This article explores how to design evaluations using open-ended math problems, assess the quality of chain-of-thought (CoT), and review essential engineering parameters before self-hosting an inference service. It provides actionable steps for scoring methodologies, cost estimation, deployment configurations, and common pitfalls to avoid.
The evaluation of Large Language Model (LLM) capabilities has shifted from natural language understanding to logical reasoning and mathematical computation. Conventional multiple-choice and basic calculation questions offer limited differentiation, as many models can achieve high scores. Open-ended math problems are better at exposing gaps because they have no fixed solutions; models must plan steps independently, handle constraints, and evaluate the validity of intermediate results.
This article is divided into three parts: how to design evaluations, how to assess chain-of-thought (CoT) quality, and which engineering parameters to verify before self-hosting an inference service.
1. How to Test Open-Ended Math Problems
Open-ended math problems may have non-unique answers, multiple solution paths, and usually contain several constraints. Before testing, you can build a small dataset, annotating each question with a reference answer, critical steps, and common mistakes. The dataset does not need to be large, but it should cover topics like algebra, combinatorics, number theory, and geometry, while minimizing overlap with the model’s training data.
Scoring should not solely depend on whether the final answer is correct. It is recommended to score across at least four dimensions:
- Correctness: Whether the final answer matches the reference answer, or if the proof holds.
- Step Completeness: Whether the critical derivations are complete and no necessary condition checks are skipped.
- Constraint Satisfaction: Whether the output adheres to the problem’s requirements, such as format, value ranges, and edge cases.
- Readability: Whether human reviewers can trace the reasoning process to locate errors.
Each dimension can use a scoring rubric from 0 to 2. Scorers should align on the criteria before grading, independently score the same batch of outputs, and then calculate inter-rater reliability. If there is significant divergence between two scorers, it indicates that the questions or rubrics need revision.
Sampling conditions must be fixed during testing. Temperature, top_p, maximum output length, and repetition count will all affect results. Drawing a conclusion from running a single query only once is often unreliable. It is recommended to sample at least three times per question and record the mean and variance of the accuracy rate.
2. Is the Chain-of-Thought Concise or Verbose?
Two models might answer the same question correctly, but their engineering value can differ significantly. One model might provide an answer in a dozen steps, while another takes hundreds of steps with many branches to reach the same result. The former has lower inference latency, consumes fewer tokens, and is easier for reviewers to follow. The latter might be more stable on extremely difficult problems but is generally less efficient and carries a higher risk of timeouts.
Therefore, the signal-to-noise ratio of the chain-of-thought can be used as a supplementary metric during model selection. There is no unified industry definition for this metric, but it can be approximated by the following:
- Effective Step Ratio: The number of steps that genuinely advance the problem, manually annotated, divided by the total number of steps.
- Redundant Backtracking Count: The number of times the model overturns a previously correct intermediate conclusion or repeats identical calculations.
- Median Output Tokens: The number of tokens consumed for correct answers on the same dataset.
- Traceability: Whether a reviewer can locate the first error within five minutes, recorded as yes or no.
Thresholds should be set by the business stakeholders. For instance, an educational tutoring scenario might prioritize traceability, while batch offline analysis might prioritize accuracy per token. Failure cases should also be retained. A metric might perform well on one type of problem but fail on another; recording failure samples helps determine the applicability boundaries of the approach.
A model’s capability tier should also be based on your own test results rather than version numbers or marketing claims. You can group candidate models based on their dataset scores and then compare their CoT metrics within the same group. The conclusions drawn this way can directly correspond to specific business scenarios.
3. Calculating the Costs Before Self-Hosting
Many teams consider self-hosting because the long-term cost of calling closed-source APIs is high, or due to data compliance pressures. The economics of self-hosting depend on multiple variables: hardware procurement or rental costs, electricity and datacenter expenses, operations personnel, actual concurrency, and request distribution. Looking solely at the theoretical throughput of a single rack rarely yields a reliable cost conclusion.
It is recommended to estimate using the following steps:
- Collect real traffic, calculating peak concurrency, average input length, and average output length.
- Benchmark on target hardware using the same model and inference framework, recording throughput and P95 latency under different concurrency levels.
- Align benchmark results with business latency requirements. High throughput with unacceptable tail latency cannot be deployed.
- Calculate the total cost per token, including hardware depreciation, electricity, operations, and redundant capacity.
- Compare with closed-source API pricing, while also considering non-price factors like data localization, model customization, and vendor lock-in.
During this process, any public throughput numbers should only be used as references. Model size, quantization methods, batching strategies, input/output lengths, and driver versions can cause significant differences. When citing external data, record its test configuration; otherwise, it cannot be compared with your own scenario.
4. Deployment Configuration Parameters to Check
The following configuration is an illustrative manifest to show which fields need to be included. It cannot be used directly in a production environment; images, model paths, and resource specifications need to be replaced according to the actual environment.
apiVersion: apps/v1kind: Deploymentmetadata:name: llm-inferencelabels:app: llm-servingspec:replicas: 2selector:matchLabels:app: llm-servingtemplate:metadata:labels:app: llm-servingspec:containers:- name: inferenceimage: registry.example.com/vllm-server:<fixed-version-tag>args:- "--model"- "/models/math-reasoning-model"- "--tensor-parallel-size"- "4"- "--max-model-len"- "8192"- "--max-num-seqs"- "128"ports:- containerPort: 8000resources:requests:cpu: "16"memory: "128Gi"nvidia.com/gpu: 4limits:cpu: "16"memory: "128Gi"nvidia.com/gpu: 4readinessProbe:httpGet:path: /healthport: 8000initialDelaySeconds: 120periodSeconds: 10livenessProbe:httpGet:path: /healthport: 8000initialDelaySeconds: 300periodSeconds: 30volumeMounts:- name: model-weightsmountPath: /modelsreadOnly: truevolumes:- name: model-weightspersistentVolumeClaim:claimName: model-weights-pvc
Before going live, verify the following items one by one:
- Use fixed version tags for images, do not use
latest. Behavioral changes after upgrades are hard to trace; fixed versions reduce this risk. - Model version and quantization method should be written into the configuration or deployment documentation. The same model name may yield different output quality under different quantization methods.
max-model-lenmust cover the longest input plus output in your business. If set too small, long requests will be truncated or cause errors.max-num-seqsis directly related to GPU memory usage and must be determined through stress testing. If set too high, intermittent out-of-memory (OOM) errors may occur during peak hours.- Keep
requestsandlimitsconsistent to prevent the scheduler from placing Pods on nodes with insufficient resources. - Differentiate between readiness and liveness probes. Model loading takes time; insufficient initial delay will cause the container to restart repeatedly.
- Record environment information including Kubernetes version, GPU driver version, and device plugin version. There are compatibility requirements between these components.
Peripheral dependencies must also be factored into the design. Model weights can be stored in object storage and synced to a local volume on startup. Message queues can smooth out traffic peaks, but the queue length must have an upper limit; otherwise, backlogged requests will continuously increase latency. Monitoring needs to cover GPU memory utilization, queue duration, error rate, and P95 latency, with alert thresholds set for each metric.
5. Common Mistakes
- Directly copying the example configuration to production. The resource specifications and parameters in the example have not undergone business stress testing.
- Deploying with the
latestimage. After dependencies update, the same configuration might produce different outputs and performance. - Scaling based solely on single-machine throughput. When tail latency exceeds limits, the lag perceived by users will be far higher than what the average indicates.
- Setting batch size too large. When GPU memory approaches its limit during peak hours, it manifests as sporadic request failures, which are difficult to troubleshoot.
- No rate limiting. As requests continue to backlog, timeouts and retries amplify each other, eventually causing the entire service to become unavailable.
6. How to Choose and What to Note
When selecting a model, first score it using your own dataset, then compare CoT metrics, and finally make a decision based on cost and compliance requirements. Before deployment, fix sampling parameters, stress test with real request distributions, and retain all failure cases. After going live, continuously monitor quality and latency, and periodically run regression tests using the same dataset to ensure that model or dependency upgrades have not introduced new issues.
Evaluating the math reasoning capabilities of LLMs cannot rely solely on an accuracy number. Whether the chain-of-thought is concise and readable determines whether the model can enter scenarios requiring human review. The return on investment for self-hosting depends on actual traffic, tail latency requirements, and total operational costs. By placing these two types of judgments within the same evaluation framework, teams can make technical selections that are verifiable.
