NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Is Your Code Generated by ChatGPT Really Correct? Rigorous Evaluation of Large Language Models for Code Generation

Jiawei Liu, Chunqiu Steven Xia, Yuyao Wang, Lingming Zhang

Abstract

Large Language Models (LLMs) are increasingly used for automated code generation, yet their reliability is often measured using sparse benchmarks. This paper introduces EvalPlus, a framework that augments the popular HumanEval benchmark with 80x more automated test cases. By subjecting 26 LLMs to this rigorous evaluation, the authors reveal a significant "testing inadequacy" gap: performance scores drop by up to 29% when edge cases are properly tested. The study highlights that many LLM-generated solutions are only "mostly correct," passing simple tests while failing on complex inputs.

Introduction: The Testing Inadequacy Gap

As LLMs like GPT-4 and CodeLlama become integral to software development, benchmarks such as OpenAI’s HumanEval serve as the standard for measuring coding proficiency. However, HumanEval typically provides fewer than 10 test cases per problem. This creates a "false correctness" problem where logically flawed code passes a handful of simple tests, leading to inflated performance metrics.

An example of ChatGPT-synthesized code passing original HumanEval tests but failing on a more rigorous HumanEval+ input due to sorting issues.

The authors identify that a piece of code can be logically flawed yet still pass simple tests. Furthermore, many benchmark problems contain vague descriptions or even incorrect "ground-truth" solutions, making it difficult to distinguish between a truly capable model and one that is simply "lucky" with its outputs.

The EvalPlus Framework

To address these shortcomings, the authors propose EvalPlus, a framework designed to transform "thin" benchmarks into rigorous ones through automated test generation. The pipeline consists of several key stages:

  1. Seed Generation (LLM-based): EvalPlus uses ChatGPT to generate high-quality "seed" inputs. Unlike random fuzzing, the LLM understands the code's intent to suggest complex structures and difficult corner cases (e.g., empty lists or specific integer ranges).
  2. Type-Aware Mutation: To scale the test suite efficiently, EvalPlus applies mutations based on data types—such as incrementing integers or swapping characters in strings—to the initial seeds.
  3. Differential Testing: The framework executes both the LLM-generated code and a trusted ground-truth implementation on thousands of new inputs. Any discrepancy in output flags the LLM-generated code as incorrect.
  4. Test-Suite Reduction: Using a "greedy set cover" algorithm, the authors created HumanEval+-Mini, a distilled version that retains only the most "lethal" test cases to maintain evaluation efficiency.
The EvalPlus pipeline, illustrating the flow from seed generation and mutation to differential testing and the creation of the augmented dataset.

Datasets and Rigor

The primary contribution is HumanEval+, which extends the industry-standard HumanEval (164 Python problems). While the original HumanEval averaged 9.6 tests per task, HumanEval+ increases this to 764.1—an 80x increase in testing depth. This rigorous approach exposed that 11% of the original HumanEval ground-truth solutions were themselves defective, containing logic errors or unhandled edge cases.

Key Insights and Results

Evaluating 26 popular LLMs on HumanEval+ provided a wake-up call for the field:

  • Significant Performance Drops: Across all models, pass@k scores dropped by 19.3% to 28.9%. GPT-4’s pass@1 score fell from 88.4% to 76.2%, while ChatGPT dropped from 73.2% to 63.4%.
  • Ranking Reversals: Rigorous testing changed the leaderboard. While ChatGPT outperformed many open-source models on the original benchmark, models like Phind-CodeLlama-34B proved more robust, outperforming ChatGPT on HumanEval+ (67.1% vs 63.4%).
  • Robustness vs. Cleverness: Open-source models often produced more robust code that survived edge-case testing better than some proprietary counterparts, despite lower initial scores on "thin" benchmarks.

Conclusion

EvalPlus demonstrates that current LLM evaluation is often too shallow to capture the nuances of software correctness. While the framework currently relies on a ground-truth oracle and focuses on Python, it sets a new standard for benchmark rigor. Future work aims to extend this to other languages and integrate formal verification to move beyond testing toward proven correctness.

Summary updated

BibTeX
@inproceedings{liu2023is,
  author = {Jiawei Liu and Chunqiu Steven Xia and Yuyao Wang and LINGMING ZHANG},
  title = {{Is Your Code Generated by ChatGPT Really Correct? Rigorous Evaluation of Large Language Models for Code Generation}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2023},
  url = {https://openreview.net/forum?id=1qvx610Cu7},
}
Figure