TL;DR
When using Large Language Models (LLMs) to generate both code and its corresponding unit tests, how do you know which tests to trust? This paper introduces ACES (AUC ConsistEncy Scoring), a lightweight method that ranks code candidates by evaluating the internal consistency of tests using a leave-one-out strategy. By focusing on a test's ability to distinguish correct from incorrect code rather than its absolute correctness, ACES breaks the circular dependency of test validation and achieves state-of-the-art code selection performance with negligible overhead.
What Problem Does This Paper Address?
LLMs are powerful code generators, but they frequently make mistakes. To improve reliability, a popular strategy is "test-time compute scaling": generating dozens of candidate solutions alongside multiple automated test cases, executing the code against those tests, and picking the candidate that passes the most tests.
The catch? The LLM-generated tests can be just as buggy or incorrect as the code itself. This introduces a classic chicken-and-egg problem: you need correct tests to evaluate the code, but you need correct code to verify if the tests are accurate. Existing approaches either treat all tests equally (majority voting) or use ad-hoc heuristics to filter out bad tests, which often discards helpful, strict tests.
Methods
The authors bypass the need to determine absolute test correctness entirely by reframing code selection as a ranking problem. They introduce the concept of Leave-One-Out AUC (LOO-AUC) consistency.
The core algorithm works as follows:
- Hold out one test case from the generated pool.
- Rank all code candidates based on their aggregate scores across all remaining tests.
- Measure how well the held-out test's pass/fail pattern aligns with this ranking using the Area Under the ROC Curve (AUC).
Mathematically, the authors prove that a test's expected LOO-AUC is directly proportional to its latent discriminative power—its ability to separate correct code from incorrect code.
They propose two variants of ACES (AUC ConsistEncy Scoring):
- ACES-C (Closed-Form): Computes test weights analytically in a single shot. It applies a pass-rate correction to remove variance distortions, provably approximating optimal weights under the mild assumption that the test suite is helpful on average.
- ACES-O (Optimized): Drops the average-quality assumption. It uses a smooth, differentiable logistic surrogate of the LOO-AUC objective and jointly optimizes test weights and code rankings via gradient ascent.
Both methods operate entirely on the binary pass/fail matrix, introducing no heavy model calls during the scoring phase.
Datasets
The authors evaluated ACES across multiple prominent code generation benchmarks using candidates and tests generated by models like GPT-3.5-Turbo, Qwen2.5-Coder (7B/14B), and DeepSeek-Coder-V2:
- HumanEval: 164 coding problems.
- HumanEval+: A stricter version of HumanEval with significantly more test cases to catch subtle edge cases.
- MBPP (Mostly Basic Python Problems): 427 problems.
- LeetCodeDataset: A more challenging benchmark used to test the limits of the models under harder problem distributions.
Key Insights and Ideas
- Correctness vs. Discriminative Power: A test doesn't have to be perfect to be useful. A completely "correct" but trivial test that every code candidate passes offers zero ranking signal. Conversely, an imperfect or strict test that successfully separates good candidates from bad ones provides a valuable ranking signal.
- Breaking Circularity Internally: By evaluating tests against the consensus ranking of other tests, the method extracts a strong supervisory signal purely from the internal structure of the binary pass matrix, without needing external ground-truth labels for code or tests.
- Asymmetric Robustness: Optimization naturally down-weights highly misleading tests while heavily up-weighting highly informative ones, creating a positive feedback loop during iterative refinement.
Key Results
- Execution-Only Superiority: Using only the binary pass matrix, ACES-O consistently achieved the highest Pass@1 accuracy among all execution-based methods across HumanEval (84.15%), HumanEval+ (74.39%), and MBPP (72.37%).
- Synergy with Static Analysis: When paired with $DS^3$ (a method utilizing static analysis like Pylint and AST complexity), ACES-C + $DS^3$ pushed performance even further, achieving the best overall results across the board (e.g., 85.37% Pass@1 on HumanEval).
- Negligible Overhead: ACES-C takes only ~9 ms per task, adding virtually zero overhead over standard majority voting (~4 ms). This makes it incredibly practical for real-world deployment compared to heavyweight LLM-as-a-judge or reinforcement learning methods.
Limitations and Future Work
- Assumption Failures in Ultra-Hard Tasks: On extremely difficult tasks where the average test quality is very low or negative (i.e., the LLM generates mostly misleading tests), the closed-form ACES-C variant can struggle, though ACES-O partially mitigates this through iterative optimization.
- Test Independence Assumption: The theoretical proofs assume that tests are sampled independently. In practice, LLMs might generate highly correlated or redundant tests, which could skew the ranking signal.
- Future Directions: The authors suggest extending the LOO-AUC framework to account for test correlations and applying the core principle of internal consistency to other noisy evaluation domains, such as LLM-as-a-judge ensembles and crowdsourced annotations.
Summary updated