Choosing a Coding LLM: Evaluation Criteria and Engineering Practices

    Learn how to evaluate coding LLMs by task type, correctness, repository understanding, long-task stability, and cost. This article outlines a practical approach to building private evaluation sets, integrating regression gates into CI, and routing development tasks to suitable models.

    1. Start with Task Types, Not a Single Score

    Comparisons of coding LLMs often become misleading when “coding ability” is reduced to one overall score. Real software development involves at least four distinct task types:

    • Inline completion: Short context and strict latency requirements, with an emphasis on time to first token and consistent formatting.
    • Single-file generation or editing: Syntactically correct code that follows existing coding conventions and dependency versions.
    • Cross-file refactoring: Understanding call chains, interface contracts, and implicit conventions through long-context reasoning.
    • Long-running automated tasks: Multi-step planning, repeated execution, and self-validation, where sustained reliability matters more than peak performance on a single step.

    A model that leads on short-context benchmarks will not necessarily perform best at cross-file refactoring. Model selection should therefore begin with task segmentation, not leaderboard rankings.

    2. A Four-Dimensional Evaluation Framework

    Evaluate models along four separate dimensions, then combine the scores using weights that reflect business priorities.

    1. Correctness: Does the output compile, pass type checks and unit tests, and avoid regressions?
    2. Engineering context understanding: Can the model locate relevant files and respect existing project abstractions rather than reinventing them?
    3. Long-task stability: Can it stay on track across multiple steps, avoid endless loops, and recover from failures?
    4. Cost and latency: How many tokens does each task consume, how long does it take end to end, and how much do retries increase the cost?

    Useful metrics include first-attempt success rate—the proportion of initial outputs that pass all tests—pass@k, or whether at least one of k sampled attempts succeeds, average rework rounds, and token cost per 1,000 lines of usable code.

    These metrics can be measured directly in your own environment without relying on external assessments.

    3. Build a Private Evaluation Set

    Public benchmarks cannot fully represent your framework versions, internal standards, or legacy constraints. A practical approach is to extract evaluation tasks from real development history.

    1. # Minimal example of an evaluation sample
    2. sample = {
    3. "id": "refactor-0421",
    4. "task": "Convert synchronous data access to asynchronous access while preserving the external interface",
    5. "context_files": ["service/order.py", "repo/base.py"],
    6. "hidden_tests": ["tests/test_order_async.py"], # Not visible to the model
    7. "constraints": ["Do not add third-party dependencies", "Preserve function signatures"],
    8. "weight": 2.0, # Weight based on business importance
    9. }

    Three principles matter:

    • Keep tests hidden from the model to reduce test leakage and inflated results.
    • Make constraints explicit so violations can be detected automatically.
    • Weight samples by business importance so less common tasks do not overwhelm core use cases.

    The evaluation set does not need to be large. A few dozen high-quality samples can often distinguish models more effectively than hundreds of low-quality ones.

    4. Scoring and Gates: Put Evaluation into the Pipeline

    Evaluation scripts should be stateless, support parallel execution, and produce results that can be archived. Integrate them into continuous integration as regression gates.

    1. def evaluate(model_client, samples, k=3):
    2. report = []
    3. for s in samples:
    4. results = [model_client.solve(s) for _ in range(k)]
    5. passed = [r for r in results if r.compiles and r.tests_pass]
    6. report.append({
    7. "id": s["id"],
    8. "pass_at_k": len(passed) > 0,
    9. "first_pass": bool(passed) and results[0] in passed,
    10. "avg_tokens": mean(r.tokens for r in results),
    11. "violations": [r.violations for r in results if r.violations],
    12. })
    13. return aggregate(report, weights={s["id"]: s["weight"] for s in samples})

    Use two levels of gating:

    • Hard gates: Block approval for disqualifying issues, such as prohibited dependencies, broken public interfaces, or high-severity security findings.
    • Soft gates: Trigger an alert when the overall score drops beyond a defined threshold, with a human reviewer deciding whether to proceed.

    This approach helps catch hidden regressions introduced by model upgrades without turning evaluation into a delivery bottleneck.

    5. Tiered Model Selection and Cost Orchestration

    Evaluation results should inform a routing strategy rather than a one-model-for-everything approach:

    • Route completion tasks to a low-latency path, prioritizing time to first token and throughput.
    • Route single-file generation to a quality-focused path.
    • Route cross-file refactoring and long-running tasks to a capability-focused path with a larger token budget.
    • Require static analysis, type checking, and human review for high-risk changes.

    General-purpose cloud services can support the evaluation workflow. Use object storage to archive evaluation sets and artifacts, message queues to smooth demand and schedule batch evaluations, container platforms to run isolated execution sandboxes, and logging and monitoring services to track success rates, latency, and token consumption over time.

    If using relevant general-purpose services from Baidu AI Cloud, apply the same capability-based approach and validate them through your own evaluations. Keep evaluation criteria independent of the vendor.

    6. Common Pitfalls

    • Looking only at the overall score: Without task segmentation, a higher score may produce no improvement in your most important workflows.
    • Leaking evaluation samples: Exposing tests to the model can inflate measured performance.
    • Ignoring retry amplification: A cheap individual attempt may become expensive if success takes three rounds on average.
    • Treating evaluation as a one-time exercise: Models and codebases evolve, so evaluation must be ongoing.
    • Overlooking constraint violations: Code that runs but violates dependency rules or interface contracts can carry substantial maintenance costs.

    7. Conclusion

    Choosing a coding LLM is fundamentally a measurable engineering problem. Segment tasks, build a private evaluation set, and use explicit metrics and gates to turn subjective impressions into data. Then route tasks and allocate costs according to the needs of each workflow.

    Leaderboards can help with initial screening. The quality of your evaluation system and engineering constraints ultimately determines how well a model works in practice.