How to Evaluate Coding LLMs: Measuring Real Capability and Stability

    When developers ask "how good is this coding model?", the answer usually comes from a few ad-hoc experiences: writing a sorting function, fixing a small bug, and forming a vague impression. Such anecdotal judgments have limited value for team-level technology decisions. Because coding tasks have clear correctness criteria, model evaluation can and should be more systematic. This article discusses how to evaluate coding LLMs from a general perspective, focusing on three areas: stability, verifiability, and engineering adoption.

    Introduction

    When developers ask “how good is this coding model?”, the answer usually comes from a few ad-hoc experiences: writing a sorting function, fixing a small bug, and feeling whether it was smooth or not. These impressions have some reference value, but they cannot support team-level technology selection or long-term investment. Coding tasks have clear correctness standards and can be measured, so evaluation methods should be more systematic. This article discusses how to evaluate coding LLMs from a general perspective, focusing on three aspects: stability, verifiability, and engineering adoption.

    1. Define the Evaluation Target and Use Cases First

    Coding models serve very different purposes: completing single lines, generating functions, explaining errors, refactoring across files, writing tests, and executing multi-step tasks. Each scenario demands different capabilities. Code completion depends on latency and local context understanding; refactoring depends on long-context handling and adherence to existing code style; multi-step tasks depend on reliable tool calling and error recovery. Before evaluating, list your team’s real task inventory and assign weights accordingly. Mixing all scenarios into a single overall score rarely produces conclusions that guide concrete decisions.

    1. Core Evaluation Dimensions

    2. Functional correctness: Does the generated code pass the expected tests? Are edge cases handled?

    3. Stability: Are results consistent across repeated runs of the same task? Does output quality fluctuate sharply when the input is rephrased slightly?
    4. Verifiability: Can the model’s changes be automatically confirmed by tests, static analysis, or type checking?
    5. Instruction following: Does the model respect project conventions such as naming rules, dependency versions, directory structure, and restricted APIs?
    6. Context utilization: In a large codebase, can the model locate relevant definitions and avoid reimplementing existing functionality?
    7. Security awareness: Does the model proactively avoid hardcoded credentials, injection risks, and insecure default configurations?
    8. Cost and latency: Token consumption per task, response time, and the cost of retries after failures.

    9. Why Stability Matters More Than One-Off Success

    A single success shows the model is capable of completing a task, but not that it can do so reliably in daily use. Suppose a task type has a per-run success probability of 70%, with runs independent of each other. The probability of ten consecutive successes is about 2.8% (0.7 to the 10th power). In practice, failures are often correlated, so the independence assumption may not hold—but the example makes the point: you cannot extrapolate a one-off demo’s success rate into everyday usability.

    Teams should track three metrics. First, pass rate: the proportion of successful runs out of many runs. Second, pass@k: the probability of at least one passing result when sampling k times, which reflects the model’s potential. Third, consistency: the proportion of independent runs that produce identical results, which reflects how predictable the output is. If pass@k is high but consistency is low, the model is capable but requires multiple samples and manual selection, and the hidden labor cost rises accordingly.

    1. Building a Reusable Evaluation Set

    The evaluation set is the foundation of the entire effort. Follow these principles:

    • Tasks should come from real work: pull them from historical tickets, refactoring records, or common defects—not hand-written toy problems.
    • Each task should have executable acceptance criteria, such as unit tests, output assertions, or static checks, avoiding subjective scoring.
    • Cover a difficulty gradient: simple functions, moderate module changes, and cross-file modifications should each account for a reasonable share.
    • Prevent data contamination: evaluation tasks should not appear in public corpora the model may have seen, and tasks should be rotated periodically.
    • Record everything: save prompts, context, model outputs, and execution logs for later review.

    Below is a minimal skeleton of an evaluation framework, for illustration only.

    1. import subprocess
    2. from dataclasses import dataclass
    3. @dataclass
    4. class EvalCase:
    5. case_id: str
    6. prompt: str
    7. test_cmd: list[str] # Acceptance command, e.g., running unit tests
    8. def run_case(case: EvalCase, generate, apply_patch) -> bool:
    9. patch = generate(case.prompt) # Call the model under evaluation
    10. apply_patch(patch) # Apply the output to an isolated workspace (implement yourself)
    11. result = subprocess.run(
    12. case.test_cmd,
    13. capture_output=True,
    14. timeout=300, # Set a timeout to prevent infinite loops
    15. cwd="/sandbox/workspace", # Execute in an isolated directory
    16. )
    17. return result.returncode == 0
    18. def evaluate(cases, generate, apply_patch, runs=5):
    19. report = {}
    20. for case in cases:
    21. outcomes = [run_case(case, generate, apply_patch) for _ in range(runs)]
    22. report[case.case_id] = {
    23. "pass_rate": sum(outcomes) / runs,
    24. "consistent": len(set(outcomes)) == 1,
    25. }
    26. return report

    Note that model-generated code is untrusted input. Run it in an isolated environment, restrict network and file system permissions, and set resource limits for each execution.

    1. Understanding Reinforcement Learning in Code Tasks

    When reinforcement learning is introduced during post-training, code tasks have a natural advantage: results can be verified programmatically. Unit test outcomes can be turned into reward signals—more objective and cheaper than human preference scoring.

    But this approach carries risks. Models may learn to game the tests, for example by hardcoding expected outputs from test cases or by modifying the tests themselves. More mature practices therefore typically include:

    • Using hidden test sets so the model never sees all acceptance criteria.
    • Checking whether rewards come from genuine functionality rather than bypassing assertions.
    • Combining process signals, such as code style, dependency sanity, and whether unrelated changes were introduced.
    • Applying staged rewards for long tasks instead of a single score on the final result.

    For users, high scores on public benchmarks should be cross-checked against hidden tests or your own evaluation set. Only when the two agree is the conclusion trustworthy.

    1. Turning Evaluation Results into Engineering Decisions

    2. Review results by scenario, and set separate pass thresholds for completion, refactoring, and test generation.

    3. Integrate evaluation into your continuous workflow. Rerun the baseline whenever the model version, prompt templates, or toolchain changes.
    4. Run a small-scale pilot before full adoption: pick low-risk modules and track adoption rate, rework rate, and defect rate.
    5. Keep human review in the loop, especially for high-risk code paths involving permissions, payments, or data deletion.
    6. Build a feedback loop: feed production failure cases back into the evaluation set to gradually expand coverage.

    7. Common Pitfalls

    • Treating a single demo as a conclusion. Carefully selected examples easily lead to misjudgment.
    • Looking only at the overall score. Aggregate scores can hide obvious weaknesses in specific task types.
    • Ignoring context quality. The same model can produce very different results under different context conditions; fix input conditions during evaluation.
    • Ignoring cost. A high pass rate accompanied by heavy retries may not translate into better real-world efficiency.
    • Equating stability with never being wrong. Stability means predictable output quality and recognizable error patterns, not the absence of errors.

    Conclusion

    Evaluating coding models ultimately comes down to three questions: Can it complete our tasks? Does it do so reliably? And when it fails, can we detect it in time? With verifiable evaluation sets, statistics from repeated runs, and scenario-based grouping, you can turn personal impressions into evidence and give technology selection and investment a solid basis.