Evaluating LLM Coding Capability: Methods and Practices
This article presents a reproducible method for evaluating the coding capability of large language models. It explains how to fix test conditions such as network isolation, time limits, and model hosting, how to use a layered six-question set with a calibration question, and how to apply a verifiable four-dimension scoring rubric. It also covers cost-per-valid-output calculation, common pitfalls, and a practical workflow for making model selection decisions.
1. Why “Evaluate on Release” Needs a Rigorous Method
Whenever a new generation of large language models becomes publicly available, the developer community usually cares about just two questions: what the model can actually do, and whether using it for those tasks is cost-effective. Both questions are extremely hard to answer, and the difficulty lies not in the model itself but in the lack of constraints in the evaluation process. The same model can perform several times better or worse depending on whether it has network access, whether the time limit is long or short, and whether the task is a simple Q&A or a multi-step engineering job. So the first step in evaluation is not to start running questions, but to define the “exam conditions” clearly.
A reproducible evaluation should fix at least the following variables: model identifier and version, the host form that carries the model (for example, an AI coding tool or an agent development framework), the test time window, whether external network access is allowed, the per-question time limit, the question set, and the scoring criteria. Only when these variables are explicitly recorded are the conclusions comparable; otherwise, what you get is a personal impression rather than a technical judgment.
2. Designing the Exam Conditions: Locking Down Uncontrollable Factors
2.1 Network Isolation: Cutting Off the Hidden Variable of Retrieval Dependence
Many models perform excellently when connected to the network, but this is essentially retrieval augmentation at work rather than the model’s own reasoning and coding ability. To assess “bare capability,” full network isolation is a necessary measure: external links given in the questions are never accessed, and all context can only come from the model’s existing knowledge and the question itself. The cost of doing this is that scores will drop, but what you gain is a clean measurement of the model’s intrinsic ability.
2.2 Time Limits: Simulating the Rhythm of Real Engineering
A 30-minute limit per question forces the model to make trade-offs among understanding requirements, designing a solution, producing code, and self-checking and correcting. Unlimited-time testing tends to produce answers that look good but are unusable; time-limited testing is closer to real development scenarios and can expose a model’s weaknesses in task planning and prioritization.
2.3 Recording Total Time and Per-Question Time
Total time reflects overall throughput, while per-question time reflects stability. If a model answers five of six questions very quickly but exhausts the time limit on one, it indicates a clear blind spot in a certain type of task, and this kind of information is more valuable than an average score.
3. Identity and Knowledge Boundary Verification: The First Question Is Seriously Undervalued
The first question of an evaluation is often treated as a warm-up, but in fact it is the “calibrator” for the entire test. Asking the model to state its own identifier, version, and knowledge cutoff can confirm three things: whether the runtime environment has correctly mounted the expected model; whether the model can honestly express its own limitations; and whether the knowledge boundary is sufficient to support the subsequent questions.
More noteworthy is how the model explains itself. A mature answer will clearly state that the identity information comes from the system prompt of the runtime environment rather than from “introspection”; that the closer to the knowledge cutoff date, the sparser the memory becomes; and that events after the cutoff are only vaguely recalled. This kind of statement is itself a capability indicator—it means the model will not package guesses as facts, and in subsequent coding tasks it is more likely to proactively declare uncertainty rather than fabricate non-existent interfaces.
A typical answer structure can be abstracted as:
Identity: model identifier + version + host formKnowledge cutoff: a time point provided by the runtime environmentConfidence statement: source of information + self-description of the sparse-memory interval
4. Layered Question Groups: Covering the Capability Spectrum with Six Questions
The number of questions does not need to be large, but it must be layered. The recommended six-question structure is as follows:
- Identity and knowledge boundary (calibration question): verify environment mounting and self-awareness.
- Single-file algorithm implementation (basic question): assess syntax correctness, boundary handling, and complexity awareness.
- Cross-file refactoring (structure question): assess reading comprehension of existing code and restraint in making changes.
- Defect localization and repair (diagnostic question): provide code with hidden defects and assess whether the localization path is explainable.
- Solution design (architecture question): provide only constraints and no code, assessing trade-offs and the explanation of those trade-offs.
- Comprehensive engineering task (integration question): multiple steps and multiple constraints, assessing planning, self-checking, and convergence ability.
The core idea of layering is to give each capability dimension an independent score and avoid “the total score masking weaknesses.” For example, if a model gets a perfect score on the algorithm question but times out on the refactoring question, the conclusion should be “suitable for scripts and prototypes, not suitable for modifying existing systems,” rather than a vague “strong capability.”
5. Scoring Criteria: From “Looks Right” to “Verifiably Right”
Subjective impressions must be replaced with verifiable standards. A four-level score is recommended for each dimension:
- Correctness: whether it passes the given boundary test cases;
- Completeness: whether it covers all constraints of the question, with nothing omitted;
- Maintainability: whether naming, structure, comments, and exception handling reach an engineering-usable level;
- Explainability: whether it explains key decisions and known risks.
Illustrative scoring table:
| Dimension | Weight | Basis for Judgment |
|---|---|---|
| Correctness | 40% | Boundary test case pass rate |
| Completeness | 25% | Constraint coverage checklist |
| Maintainability | 20% | Static checks and manual review |
| Explainability | 15% | Whether risk statements are specific |
6. Cost-Effectiveness Accounting: Breaking Cost into Comparable Units
Cost-effectiveness is not “cheap or expensive,” but the cost per unit of valid output. The following formula is recommended:
Cost per valid output = total cost / number of questions passing all test casesTotal cost ≈ input tokens × input price + output tokens × output price + host resource cost
There are three easily overlooked points here. First, retry cost must be counted: multiple failed retries within the time limit significantly raise the actual unit price. Second, manual review cost must be counted: the hidden cost of output that requires extensive manual patching often exceeds the invocation cost itself. Third, the host form affects the cost structure: an agent framework brings additional tool-call and context-accumulation overhead, so the host should be fixed during evaluation to avoid mistaking framework differences for model differences.
7. Common Pitfalls and How to Avoid Them
- Looking only at the average score: you should look at per-dimension scores and the time distribution.
- Allowing network access while claiming to test “bare capability”: the variables are not controlled, so the conclusion is invalid.
- Questions that are too homogeneous: an all-algorithm question set will systematically overestimate a model’s value in existing engineering work.
- Ignoring the quality of self-declaration: whether a model acknowledges its knowledge boundary directly affects its trustworthiness in production environments.
- Drawing conclusions from a single run: use at least three rounds and take the median to reduce the impact of randomness.
8. Recommended Implementation Workflow
- Fix and archive the exam conditions to form a reproducible experiment record.
- Run the calibration question first to confirm the environment and knowledge boundary.
- Execute the layered question groups, recording the time and failure reason for each question.
- Score with a unified scoring table and keep the raw output for review.
- Plug in real invocation volume and calculate the cost per valid output.
- When presenting conclusions, distinguish “capability boundaries” from “applicable scenarios” rather than giving a vague ranking.
9. Conclusion
The right way to evaluate a new generation of models is to turn subjective surprise into objective constraints: network isolation, time limits, layering, verifiable scoring, and accountable cost. Once this workflow is in place, what you get is not just a score, but a decision basis that can be used directly for technology selection—making clear which tasks are worth investing in and which still require a human fallback. For teams that want to build AI coding capabilities on cloud platforms such as Baidu AI Cloud, this method is equally applicable to evaluating the combined effect of various general-purpose model services and agent frameworks.
