Evaluating LLM Code Capabilities: Dimensions and Methods That Actually Matter

    A single benchmark score cannot capture how well a large language model handles real software work. This article breaks down the main evaluation categories—function-level code generation, repository-level issue resolution, long-horizon agent tasks, and the score drift caused by inference configuration—and explains how to turn evaluation into a reproducible data pipeline. It also proposes a four-layer metric design covering correctness, stability, efficiency, and safety, along with practical ways to avoid common misreadings and embed continuous regression into the development workflow.

    1. Why a Single Score Is Not Enough

    A common pattern in recent industry discussions goes like this: a model beats the previous lightweight version on several coding and agent benchmarks, comes close to top closed-source models on some projects, occasionally overtakes them, yet still trails the strongest models on most projects. This mix of wins and losses is the normal state of evaluation work, not an anomaly.

    The reason is straightforward: every benchmark is only a slice of real development capability. Different slices naturally lead to different conclusions. Averaging those slices into one total score looks clean, but it discards the most important information—which kinds of tasks a model can actually handle, and which ones still require a human backstop.

    So the goal of professional evaluation is not a leaderboard rank. It is a capability profile: code generation, code comprehension, repository-level modification, tool calling, long-range planning, and failure recovery, each marked as strong or weak.

    2. What the Mainstream Benchmarks Actually Measure

    2.1 Function-Level Code Generation

    These benchmarks provide a natural language description and a function signature, ask the model to complete the implementation, and use unit tests to compute a pass rate. The advantage is objective, automatable judging. The drawback is small task granularity and a clear gap from real engineering. A high score here only shows the model can write correct small functions; it does not show the model can modify a real repository.

    2.2 Repository-Level Repair and Engineering Benchmarks

    These benchmarks give an issue description from a real project plus a code snapshot, and require the model to locate files, understand context, and submit a patch that passes tests. They test retrieval, localization, cross-file reasoning, and regression control, and are far harder than function-level tasks. A model leading on function-level benchmarks while trailing on repository-level ones is a completely normal combination.

    2.3 Long-Horizon Agent Benchmarks

    Agent evaluations place the model in a tool-equipped environment and require multi-step actions, observation of feedback, and strategy correction until the task is done or times out. Scoring usually looks at both final success rate and process cost (steps, number of calls, elapsed time). These benchmarks best expose the “can write code but cannot get work done” problem.

    2.4 Score Drift from Versions and Configuration

    The same model can perform noticeably differently under different inference configurations: context window length, decoding temperature, maximum output length, truncation policy for tool returns, and how the system prompt is organized all change results. If an evaluation does not fix and disclose these settings, scores are not comparable. Many claims that “model A beats model B” do not hold once the configuration is examined.

    3. Turning Evaluation into a Reproducible Engineering Pipeline

    Evaluation should be built as a data pipeline, not a one-off script.

    1. # Minimal skeleton of an evaluation pipeline
    2. def run_eval(model_client, dataset, cfg):
    3. report = []
    4. for case in dataset:
    5. if cfg.cache_hit(case.id, cfg.fingerprint):
    6. report.append(cfg.load_cached(case.id))
    7. continue
    8. raw = model_client.generate(
    9. prompt=case.render(cfg.prompt_style),
    10. temperature=cfg.temperature,
    11. max_tokens=cfg.max_tokens,
    12. stop=cfg.stop,
    13. )
    14. result = case.judge(raw, timeout=cfg.timeout) # compile + unit tests + static checks
    15. cfg.save(case.id, result, fingerprint=cfg.fingerprint)
    16. report.append(result)
    17. return aggregate(report)

    Four design points matter:

    • Configuration fingerprint: hash the prompt template, decoding parameters, tool set, and dataset version together as the cache key, so identical scores always have identical causes.
    • Sandbox isolation: code execution must run in a restricted container with limits on network, file system, and duration to avoid uncontrolled side effects.
    • Layered judging: record compile pass, unit test pass, and static check pass separately; do not collapse them into a single boolean.
    • Cost accounting: persist token consumption, number of tool calls, and wall-clock time for later cost-effectiveness analysis.

    4. Metric Design: From Pass Rate to Usability

    Looking only at pass rate hides the real experience. Build at least four layers of metrics.

    The first layer is correctness, the proportion of passing tests, distinguishing “pass on first attempt” from “pass after multiple retries.” The gap between the two reflects the model’s self-correction ability.

    The second layer is stability, the variance of pass rate across repeated samples of the same task. High variance means unpredictable retry costs in production.

    The third layer is efficiency, including average steps, average elapsed time, and cost per task. A model with a slightly lower pass rate but significantly fewer steps is often more economical in real business use.

    The fourth layer is safety, including whether high-risk dependencies are introduced, whether secrets are leaked, and whether unauthorized operations are performed. This layer should be a hard gate: failing it eliminates the model outright, with no weighting.

    A composite score can be expressed in weighted form, but the weights must be determined by the business scenario:

    1. Score = w1 * Correctness + w2 * Stability + w3 * Efficiency
    2. Constraint: Safety >= threshold, otherwise Score = 0

    5. Common Misreadings and How to Avoid Them

    Misreading 1: treating cross-version comparison as capability improvement. If the dataset version or judging script differs between two runs, the score change may come entirely from the evaluation itself. Fix the dataset version number and disclose it in the report.

    Misreading 2: using a total score to mask weaknesses. Similar total scores do not mean similar capabilities; a model may fall far behind on repository-level tasks, which may be exactly what the team needs most. Always look at the per-dimension radar chart.

    Misreading 3: ignoring the impact of prompts and tools. The same model with retrieval and test feedback can differ by an order of magnitude. Report both “bare model” and “with tools” results.

    Misreading 4: drawing conclusions from insufficient samples. A few percentage points of difference on a small sample has no statistical meaning; report confidence intervals and run significance tests on the difference.

    6. Implementation Advice: Embed Evaluation in the Development Workflow

    For teams, the most valuable form of evaluation is continuous regression, not a quarterly mega-report.

    • Build an internal task set: extract real tasks from historical tickets after de-identification to form an internal benchmark of 200 to 500 items, closer to your own code style and dependency environment than public leaderboards.
    • Integrate with CI: every time you switch models or adjust prompts, automatically run the internal benchmark and output per-dimension comparisons and cost changes.
    • Define a human-machine division line: grade tasks by risk, batch low-risk work to the model, keep human review for high-risk work, and track the human takeover rate.
    • Accumulate failure samples: store all failure cases with labeled causes (localization error, compile failure, test failure, unauthorized operation) to drive prompt and process improvements.

    At the infrastructure level, general-purpose capabilities are enough to support the whole system: object storage for datasets and artifacts, a container platform for isolated sandboxes, a message queue to schedule evaluation tasks, and logging plus monitoring and alerting to track success rate and cost fluctuations. To further reduce self-built costs, you can evaluate general engineering and observability capabilities from cloud vendors such as Baidu AI Cloud and combine them as needed, without binding to proprietary interfaces.

    7. Conclusion

    When facing conclusions like “a model beats rivals on some benchmarks but still trails on most,” the right response is not to pick a side but to ask three questions: which tasks were tested, what configuration was used, and what did it cost. Answer those three clearly, and evaluation truly serves selection and deployment.