Evaluating the Coding and Math Capabilities of Major LLMs

    A practical guide to evaluating large language models beyond single benchmark problems. It explains why one-off tests are unreliable, how to measure task discrimination, and how to assess coding and math capabilities across multiple dimensions. You will find a reproducible evaluation workflow, a generate-execute-feedback-fix loop, and strategies for applying model evaluation in day-to-day development.

    1. The Starting Problem: Why a Single Task Proves Nothing

    When people discuss LLM capabilities, the most common approach is to pick a “hard-looking” problem circulating in the community, have several models answer it, and draw conclusions from the results. The issue with this approach is that single-task samples have extremely high variance. Model output is affected by prompt wording, temperature settings, context length, whether code execution is enabled, the default style of the system prompt, and many other factors. The same model can produce different results under different conditions. A single task can therefore serve as a clue at best, not a conclusion.

    A more reasonable way to understand model capability is to treat it as a multi-dimensional vector that includes at least instruction following, long-context understanding, logical reasoning, math computation, code generation and debugging, tool calling, and structured output stability. These dimensions are not strongly correlated. A model that performs well on coding tasks is not necessarily equally reliable at multi-step mathematical derivations.

    2. Discrimination: The Core Metric of a Good Evaluation Set

    The key metric for evaluation task quality is discrimination—whether a task can separate models of different capability levels. Low-discrimination tasks fall into two categories: some are too easy, so nearly all models pass and the information value is zero; others are vaguely worded or controversial, so different reviewers reach different judgments and the noise exceeds the signal.

    Common ways to improve discrimination include:

    • Designing multi-constraint tasks, for example requiring correctness, boundary-condition handling, and complexity constraints at the same time;
    • Introducing automatically verifiable acceptance criteria to reduce subjective human scoring;
    • Setting layered difficulty to form an easy, medium, and hard gradient and observe how models perform across different ranges;
    • Sampling multiple times to measure pass rates rather than recording only a single result.

    A sample evaluation record structure can be written as:

    1. task_id, dimension, difficulty, constraints, pass_rate, avg_latency, notes
    2. T001, code, hard, "includes boundary and complexity requirements", 0.4, 1.8s, needs a second revision
    3. T002, math, medium, "multi-step derivation", 0.7, 2.3s, correct conclusion with skipped steps

    3. Coding Capability: From “It Runs” to “It Is Maintainable”

    Judging a model’s coding capability requires more than checking whether it produces runnable code. There are four levels to consider:

    1. Correctness: whether it covers boundary conditions, exception paths, and empty inputs;
    2. Completeness: whether it fills in necessary type definitions, error handling, and configuration notes;
    3. Maintainability: whether naming, module structure, comments, and code style are consistent;
    4. Debuggability: when a run fails, whether it can locate the issue from the error message and iterate to fix it.

    A practical evaluation method is a “generate–execute–feedback–fix” loop: first have the model produce an implementation, then run unit tests in an isolated environment, feed the failure information back and ask for a fix, and record how many rounds are needed to pass. This metric reflects the real collaboration cost in development better than a one-shot pass rate.

    1. def evaluate(model_client, task, max_rounds=3):
    2. prompt = task.spec
    3. history = []
    4. for i in range(max_rounds):
    5. answer = model_client.chat(prompt, history)
    6. result = run_in_sandbox(answer, task.tests)
    7. if result.passed:
    8. return {"rounds": i + 1, "passed": True}
    9. prompt = f"Run failed: {result.error}\nPlease fix the code."
    10. history.append((answer, result.error))
    11. return {"rounds": max_rounds, "passed": False}

    4. Math Capability: The Process Matters More Than the Answer

    Math tasks fail in different ways from coding tasks. Code errors usually surface at execution time, whereas math errors often appear as “the answer looks reasonable, but the process has gaps.” Math evaluation should therefore focus on whether the model lists its reasoning steps, states its assumptions, checks the conclusion for order of magnitude or extreme cases, and keeps units and symbols consistent.

    A common improvement is to have the model explicitly output intermediate steps and self-check key steps. On the business side, avoid handing high-risk calculations entirely to the model. Instead, divide responsibilities so that the model provides the approach while the program performs precise computation—using deterministic code for arithmetic and statistics and placing the model in the modeling and explanation stages.

    To keep conclusions stable and credible, fix the following elements: a unified system prompt and parameter configuration, a fixed test set version, an isolated and resource-constrained execution environment, repeated sampling, and complete log retention. In engineering practice, you can use container platforms to build consistent runtime environments, object storage to save evaluation artifacts and conversation records, message queues to schedule batch tasks, and logging services with monitoring alerts to track failure rates and latency fluctuations. Baidu AI Cloud offers standard infrastructure categories for these general capabilities; specific choices should be evaluated against your own compliance and cost requirements.

    6. Implementation Strategies in Daily Development

    • Use models in tiers: assign low-risk, automatically verifiable tasks to the model and keep human review for high-risk decisions;
    • Build an internal evaluation set: desensitize real team requirements into regression cases and continuously track version changes;
    • Focus on total cost: count call latency, retry rounds, and human correction time together, rather than only the price of a single call;
    • Strengthen input quality: clear context, constraints, and acceptance criteria often bring greater gains than switching models.

    7. Conclusion

    Judgments like “model A is strong and model B is weak” based on a single hard problem have limited reference value. A more reliable approach is to build a multi-dimensional, reproducible evaluation system with automated acceptance, break coding capability into correctness, completeness, maintainability, and debuggability, and ground math capability in verifiable processes and separation of responsibilities. For most teams, model selection is not a one-time conclusion but an engineering process that is continuously calibrated as the task distribution changes.