Evaluating the Coding Capabilities of Medium-Sized LLMs: Methods and Best Practices
Medium-sized large language models (LLMs) are increasingly popular for coding assistance due to their balanced performance, local deployment advantages, and cost efficiency. However, public leaderboards often fail to reflect their real-world engineering capabilities. This article outlines a systematic approach to evaluating LLM programming abilities from an engineering perspective. We explore a dual-dimension evaluation framework—focusing on functional completion rates and behavioral constraints—and detail the design of tiered test sets, calculation methodologies, visual task assessments, and reproducible workflows. Finally, we provide insights on result interpretation and model selection to help teams make informed decisions based on their specific use cases.
1. Why Systematic Coding Evaluation is Necessary
Once language models are introduced into coding assistance scenarios, development teams frequently encounter a problem: the same model performs vastly differently across different tasks. Relying solely on the total score of a public benchmark makes it difficult to determine if a model can support real-world development work. Public benchmarks are mostly based on fixed question banks, where the dependency relationships, context lengths, and requirement ambiguities differ significantly from real-world engineering. Therefore, evaluation must return to an engineering perspective, breaking down “can it write code” into observable questions: Can the model complete tasks independently? Does it follow constraints during the process? Can the output run directly?
Medium-sized models typically refer to models with a parameter scale ranging from tens of billions. These models offer clear advantages in local deployment, inference cost, and response latency, making them frequent candidates in model selection discussions. The parameter scale alone does not determine capability boundaries; conclusions are only meaningful when comparing models horizontally under the same test set and the same budget.
2. Breaking Down Capabilities into Two Observable Dimensions
Evaluation can be divided into two independent yet complementary dimensions.
1. Functional Completion Rate
Functional completion rate measures whether the task output meets acceptance criteria, defined as follows:
Functional Completion Rate = Number of Tasks Passing All Acceptance Checks / Total Number of Tasks
Here, “passing” must be determined by objective checks, such as unit tests, API contract checks, build success, and runtime errors. Manual subjective judgment is only supplementary and should not be the primary basis.
2. Behavioral Assessment
Behavioral assessment measures whether the model adheres to constraints during task completion, mainly including:
- Instruction following: Did it execute all explicit requirements? Did it omit sub-tasks?
- Scope control: Did it modify files or configurations outside the task scope?
- Honesty: When information is insufficient, did it state assumptions or ask for clarification, or did it fabricate APIs and parameters?
- Security awareness: Did it hardcode secrets into the code? Did it generate dangerous deletion or overwrite operations?
- Stability: How consistent are the results across multiple runs with the same input?
Both dimensions must be observed simultaneously. A model with a high functional completion rate but poor behavior poses hidden risks in production environments, such as casually modifying unrelated configuration files or introducing unconfirmed dependencies. A model with standard behavior but a low completion rate is better suited for low-risk scenarios like auxiliary Q&A or code review.
3. Tiered Design of Test Sets
Test sets should cover tasks of varying complexity, avoiding a scenario where all questions remain at the “implement a sorting function” level. It is recommended to organize them into the following four tiers:
| Tier | Typical Tasks | Primary Check Methods |
|---|---|---|
| Function-level | Algorithmic or utility functions with clear inputs and outputs | Unit tests |
| Module-level | Adding new features based on existing interfaces | Interface tests, integration tests |
| Engineering-level | Cross-file refactoring or bug fixes | Build checks, regression tests, diff scope checks |
| Generation-type | Visual outputs like graphics, interactive UIs, animations | Structure checks, runtime checks, screenshot comparison, manual sampling |
When designing test cases, several principles should be followed. First, requirement descriptions should clearly state inputs, outputs, and boundary conditions to reduce scoring noise caused by ambiguous requirements. Second, try to use self-built or rewritten prompts to avoid high overlap with common training corpora. Third, equip each task with at least three independent acceptance checks; a single check is prone to accidental misjudgments. Fourth, fix random seeds and prompt order to ensure consistent comparison conditions across different models.
4. Calculation Details of Functional Completion Rate
When calculating the completion rate, several often-overlooked details can significantly impact the results.
First, each task should have a unified output token budget and timeout period. Tasks that timeout or exhaust the budget should be recorded as incomplete, rather than counted as passed after manual remediation. Second, the same task should be sampled multiple times, taking the average pass rate and reporting the variance. Results from a single run may have large deviations due to sampling randomness. Finally, do not manually cherry-pick failed tasks for reruns, as this will systematically inflate the completion rate.
Below is a schematic code snippet for evaluation execution, language-agnostic in logic:
def run_suite(model, tasks, samples=3):records = []for task in tasks:for i in range(samples):output = model.generate(task.prompt,max_tokens=task.token_budget,timeout=task.timeout,)artifact = sandbox.materialize(output) # Materialize artifacts in an isolated environmentpassed = all(check(artifact) for check in task.checks)records.append({"task": task.id, "sample": i, "passed": passed})return recordsdef completion_rate(records):return sum(r["passed"] for r in records) / len(records)
The sandbox in the schematic code must be isolated from the host environment to prevent the model-generated code from accessing the real file system or network resources.
5. Implementation of Behavioral Assessment
Behavioral assessment is best conducted using a combination of rule checks and manual scoring.
Rule checks can be automated, for example:
- Compare the list of changed files in the code repository before and after the task. If file changes outside the task scope appear, record it as a scope violation.
- Scan the output code for strings resembling secrets, tokens, or credential formats.
- Check if third-party packages not listed in the dependency manifest are called.
Manual scoring is used to judge instruction following and clarity of expression. It is recommended to use a 1-to-5 scale, scored independently by at least two reviewers, and calculate the inter-rater reliability coefficient. If reliability is too low, the scoring criteria should be revised before continuing the evaluation; otherwise, the scores cannot be compared horizontally.
6. Evaluating Visual Tasks
Visual tasks are difficult to judge directly with text assertions; the “quality of the effect” must be broken down into checkable sub-items. Taking a 3D scene generation task as an example, requirements typically include:
- A time slider (0 to 24 hours) simultaneously controls light direction, light intensity, sky color, and fog hue.
- A fog density slider (0 to 100) controls particle fog density; at low values, the scene is clear, and at high values, the scene is hazy but not completely white.
- The water surface uses a custom shader, including waves and specular reflection, and distant water needs to blend naturally with the fog color.
- The target frame rate is about 60 FPS.
For these requirements, the following checks can be designed:
- Load Check: Can the code complete rendering initialization without errors?
- Parameter Range Check: Does the program clamp values or provide prompts when slider values exceed the valid range?
- Fog Monotonicity Check: When using the exponential squared fog decay formula, visibility should monotonically decrease as distance increases. Schematic as follows:
def visibility(distance, density):return math.exp(-(density * distance) ** 2) # Visibility factor for exponential squared fog
For any positive density value, this function decreases monotonically as distance increases. If the output code’s fog implementation does not satisfy this property, it can be directly recorded as a failure.
- Performance Check: Sample frame times at a fixed standard scene and fixed resolution, and calculate average and minimum frame rates. When reporting, the test hardware must be noted, otherwise the frame rate numbers lack reference value.
- Visual Comparison: Take screenshots from several fixed angles, compare structural similarity with reference images, and supplement with manual sampling to judge whether the lighting and fog atmosphere meet the requirements.
The conclusions of visual tasks should include both objective metrics and subjective evaluations; neither can be omitted.
7. Reproducible Evaluation Workflow
To ensure results can be reproduced by others, the evaluation process should fix at least the following elements:
- Environment versions, including the operating system, dependency library versions, and inference service configurations.
- Prompt templates; all models use the same template, only replacing the task content.
- Sampling parameters, such as temperature, top-p, and maximum output length.
- Sandbox policies, explicitly defining allowed file access scopes and network permissions.
- Raw logs, retaining the complete input, output, and check results for each run.
The final report should include the test set version, sample size, completion rates per tier, behavioral score distribution, and hardware specifications for performance data. A report that only provides a total score cannot support model selection decisions.
8. Result Interpretation and Model Selection
When interpreting results, note the following points.
First, comparisons must be based on the same test set, the same budget, and the same check standards. Numbers under inconsistent conditions cannot be directly subtracted.
Second, if the score difference between two models is less than the test variance, no conclusion should be drawn. Increase the sample size first, then determine if the gap is stable.
Third, different scenarios weight capabilities differently. Code completion and single-function generation emphasize completion rates, engineering modifications emphasize multi-file understanding and behavioral compliance, and visual tasks require a combination of performance and visual metrics. Selection should be weighted according to actual use cases, rather than just looking at the comprehensive score.
Fourth, the team can set a usability threshold first, for example, requiring both functional completion rate and behavioral score to reach a certain threshold before a model enters the candidate list. The threshold should be determined by the team based on its own risk tolerance and code review capabilities; there is no universal standard value.
9. Common Pitfalls
- Looking only at single-run results: Single runs are highly accidental; multiple samplings should be used.
- Using common questions from training corpora: This overestimates the model’s true capabilities; self-built or rewritten prompts should be used.
- Treating demo screenshots as performance conclusions: Screenshots only show the effect from a certain angle and cannot represent frame rates and stability.
- Ignoring cost and latency: With the same completion rate, differences in inference cost and response time may dictate the final choice.
- Testing performance only on high-end devices: Performance conclusions should cover the device types actually used by the team; otherwise, results cannot be migrated to real environments.
