Evaluating LLM Software Engineering Capability: From Benchmark Contamination to Reliable Validation

    This article explains why software engineering evaluations for large language models need to be redesigned, covering data contamination and information leakage, verifier reliability, and score compression caused by insufficient task complexity. It presents design principles for trustworthy evaluation, including environment isolation, task originality and diversity, realistic complexity, and verifier error auditing. It also provides a minimal Python workflow example, explains Pass@k and confidence intervals, and offers practical recommendations for building evaluations that support reliable model comparisons.

    1. Background: Why Evaluation Needs to Be Redesigned

    Code generation models can already complete functions, write unit tests, and fix small defects. Real software engineering work is much more complex. Developers need to locate problems in large codebases, understand cross-module call relationships, modify multiple files, and ensure existing tests continue to pass. If evaluation only covers simple snippets, the results cannot answer whether a model can handle real development tasks.

    Evaluation design has two goals. First, scores must reflect differences in capability. Second, conclusions must be reproducible in another environment. To achieve both, the evaluation system itself must be trustworthy.

    2. Three Typical Problems in Existing Evaluations

    2.1 Data Contamination and Information Leakage

    If a model’s training corpus contains the original code or reference answers for evaluation tasks, the model’s score will be systematically inflated. Another type of leakage occurs inside the evaluation environment. If the workspace retains the full version history of a code repository, the model can retrieve historical commits, find the fixed code, and adopt it directly. This problem does not require any “cheating” intent from the model. As long as the environment exposes the answer, the results will be distorted.

    Common mitigations include:

    • Keep only the task’s starting state in the workspace, and delete version history and remote references;
    • Restrict network access during evaluation to prevent online retrieval of answers;
    • Run similarity detection on repair patches to identify overlap with the training corpus.

    2.2 Insufficient Verifier Reliability

    The verifier is responsible for determining whether a code change succeeds. It has two typical failure modes:

    • False positive: the change is actually incorrect, but the tests still pass. Common causes include insufficient test coverage or assertions that are too loose.
    • False negative: the change is actually correct, but the tests fail. Common causes include environment differences, randomness, or brittle assertions.

    False positives allow speculative solutions to receive high scores, while false negatives suppress genuinely effective solutions. Both distort model rankings, so the verifier itself needs to be measured and audited.

    2.3 Insufficient Task Complexity Leads to Score Compression

    When tasks involve only small changes to a single file, most stronger models can pass, and scores cluster in a narrow range. Real differences between models are masked by measurement noise, making it difficult for teams to determine whether the gap between two models is real. Increasing task complexity, for example by requiring coordinated changes across three or more modules, handling legacy code, or completing missing documentation, can spread the score distribution and make the evaluation more discriminative.

    3. Design Principles for a Trustworthy Evaluation System

    3.1 Environment Isolation

    Isolated environments are the foundation for preventing information leakage. In practice, the following sequence can be used:

    1. Check out the code from the specified commit;
    2. Delete the version control directory and keep only the working tree files;
    3. Run in a container with external network access disabled and resource quotas limited.

    3.2 Task Originality and Diversity

    Tasks should preferably be designed from scratch by the evaluator rather than taken directly from historical defects in public repositories. This reduces the risk of overlap with training corpora. Tasks should cover multiple programming languages, multiple project sizes, and different problem types, including bug fixes, feature extensions, refactoring, and performance optimization. Diversity reduces accidental results in which a model is only good at one type of task.

    3.3 Realistic Complexity

    Realistic complexity can be described using several quantifiable indicators: the number of files involved, the number of lines changed, the context length required, and whether a runtime environment is needed to locate the problem. Task descriptions should resemble real tickets, providing only symptoms and constraints rather than directly revealing the location of the change.

    3.4 Measuring the Verification Mechanism

    The quality of the verifier needs to be evaluated separately. One feasible approach is to sample and audit verification results: draw a certain proportion of samples from both the “passed” and “failed” groups, review each one manually, and then calculate the two misjudgment ratios. Note that the two ratios have different denominators:

    • False positive rate = number of samples judged as passed but actually incorrect / total number of samples judged as passed
    • False negative rate = number of samples judged as failed but actually correct / total number of samples judged as failed

    Reporting only a single overall accuracy rate hides structural differences between the two types of errors, so they should be reported separately.

    4. Minimal Viable Evaluation Workflow Example

    The following example shows a simplified evaluation workflow, including workspace preparation, test execution with timeouts, and calculation of verifier misjudgment rates. The example is only intended to illustrate the design approach. A production system would also need mechanisms such as sandbox isolation, log auditing, and result signing.

    1. import shutil
    2. import subprocess
    3. import pathlib
    4. def prepare_workspace(repo_url: str, commit: str, dest: pathlib.Path) -> None:
    5. """Check out the specified commit and remove version history to prevent answer retrieval."""
    6. subprocess.run(
    7. ["git", "clone", "--no-checkout", repo_url, str(dest)],
    8. check=True,
    9. timeout=600,
    10. )
    11. subprocess.run(
    12. ["git", "-C", str(dest), "checkout", commit],
    13. check=True,
    14. timeout=120,
    15. )
    16. shutil.rmtree(dest / ".git")
    17. def run_hidden_tests(workspace: pathlib.Path, test_cmd: list[str]) -> bool:
    18. """Run hidden tests in the workspace and return whether all pass. Treat timeout as failure."""
    19. try:
    20. result = subprocess.run(
    21. test_cmd,
    22. cwd=workspace,
    23. capture_output=True,
    24. timeout=900,
    25. )
    26. return result.returncode == 0
    27. except subprocess.TimeoutExpired:
    28. return False
    29. def verifier_error_rates(audited: list[dict]) -> dict:
    30. """
    31. Each record in audited contains:
    32. verdict: whether the verifier judged it as passed (bool)
    33. truly_correct: manual review conclusion (bool)
    34. """
    35. passed = [r for r in audited if r["verdict"]]
    36. failed = [r for r in audited if not r["verdict"]]
    37. fp = sum(1 for r in passed if not r["truly_correct"])
    38. fn = sum(1 for r in failed if r["truly_correct"])
    39. return {
    40. "false_positive_rate": fp / len(passed) if passed else 0.0,
    41. "false_negative_rate": fn / len(failed) if failed else 0.0,
    42. }

    Several design choices in the example are worth noting. First, commands are passed as argument lists, avoiding the injection risk introduced by shell string concatenation. Second, all external calls have timeouts, preventing a single task from dragging down an entire evaluation batch. Third, misjudgment rates are calculated separately for passed and failed samples, consistent with the definitions above.

    5. Interpreting Results: The Statistical Meaning Behind Scores

    5.1 Meaning of Pass@k

    Pass@1 represents the probability that a model succeeds on a single attempt. If the same task is sampled n times and c of those samples pass, the unbiased estimate of Pass@k is:

    Pass@k = 1 − C(n−c, k) / C(n, k)

    where C denotes the combination count. When the number of samples is relatively large, this estimate is more stable than simply taking one result. When reporting scores, the values of n and k, as well as parameters such as the sampling temperature, should also be stated.

    5.2 Confidence Intervals

    When the number of tasks is limited, the score itself carries uncertainty. For example, with 100 tasks and a 70% success rate, the standard error is approximately sqrt(0.7 × 0.3 / 100) ≈ 0.046, and the 95% confidence interval is approximately plus or minus 9 percentage points. This means that at this scale, the ranking difference between two models that differ by only a few percentage points may not be statistically meaningful. When reporting results, it is advisable to provide confidence intervals as well, or to use a paired test to compare two models on the same task set.

    6. Practical Recommendations

    • Task sets should be versioned. Each update should record the changes so that historical results can be reproduced.
    • Publishing the evaluation methodology, including environment configuration, judgment criteria, and misjudgment audit results, is more valuable than publishing rankings alone.
    • Task sets should be updated regularly. Long-fixed tasks are prone to targeted optimization, and their scores gradually lose reference value.
    • Changes to the verifier require a new misjudgment audit to avoid introducing new bias while fixing one problem.

    Trustworthy software engineering evaluation depends on three things: the environment does not leak answers, the verifier has been measured, and tasks have sufficient realistic complexity. If any one of these is missing, scores will struggle to support decisions.