Is Your Code Generated by ChatGPT Really Correct? Rigorous Evaluation of Large Language Models for Code Generation
By Jiawei Liu, Chun Xia, Yuyao Wang, Lingming Zhang. 2023
1,966 citations recorded by the source corpus.
Program synthesis has been long studied with recent approaches focused on directly using the power of Large Language Models (LLMs) to generate code. Programming benchmarks, with curated synthesis problems and test-cases, are used to measure the performance of various LLMs on code synthesis. However, these test-cases can be limited in both quantity and quality for fully assessing the functional correctness of the generated code. Such limitation in the existing benchmarks begs the following question: In the era of LLMs, is the code generated really correct? To answer this, we propose EvalPlus -- a code synthesis evaluation framework to rigorously benchmark the functional correctness of LLM-synthesized code. EvalPlus augments a given evaluation dataset with large amounts of test-cases newly produced by an automatic test input generator, powered by both LLM- and mutation-based strategies. While EvalPlus is general, we extend the test-cases of the popular HumanEval benchmark by 80x to build HumanEval+. Our extensive evaluation across 26 popular LLMs (e.g., GPT-4 and ChatGPT) demonstrates that HumanEval+ is able to catch significant amounts of previously undetected wrong code synthesized by LLMs, reducing the pass@k by up-to 19.3-28.9%. We also surprisingly found that test insufficiency can lead to mis-ranking. For example, both WizardCoder-CodeLlama and Phind-CodeLlama now outperform ChatGPT on HumanEval+, while none of them could on HumanEval. Our work not only indicates that prior popular code synthesis evaluation results do not accurately reflect the true performance of LLMs for code synthesis, but also opens up a new direction to improve such programming benchmarks through automated testing. We have open-sourced our tools, enhanced datasets as well as all LLM-generated code at https://github.com/evalplus/evalplus to facilitate and accelerate future LLM-for-code research.
Subfields: Artificial Intelligence, Health Informatics, Evaluation & Benchmarks, Code Generation & Program Synthesis
How researchers see this paper
The researchers whose trusted networks rank it highest, strongest advocate first. Every researcher gets a different order.
In Artificial Intelligence
In Health Informatics
In Evaluation & Benchmarks
- Chun Xia
- Lingming Zhang
- Armando Solar-Lezama
- Fei Huang
- James Prather
- Mark Harman
- Jindong Wang
- Naman Jain
In Code Generation & Program Synthesis
- Juho Leinonen
- Armando Solar-Lezama
- Chun Xia
- Koushik Sen
- Mark Harman
- Lingming Zhang
- Bogdan Vasilescu
- Paul Denny
Citations in the corpus
- LiveCodeBench: Holistic and Contamination Free Evaluation of Large Language Models for Code (2024, methodology): “Similar gains are observed in previous benchmarks (like HumanEval+ ) as well.”
- Aligning Large Language Models with Human: A Survey (2023, background): “Liu et al. (2023d) propose a novel type of instruction called realignment , designed to revise responses based on previously generated low-quality feedback and instructions.”
- Qwen2.5-Coder Technical Report (2024, background): “5, a top-tier open-source LLM, Qwen2.”
- OpenCodeInterpreter: Integrating Code Generation with Execution and Refinement (2024, neutral): “EvalPlus’s unified sanitizer tool post-processes these solutions, which are then evaluated across the four benchmarks using EvalPlus’s toolset.”
- Qwen2 Technical Report (2024, neutral): “…et al., 2022a) (0-shot), ARC-C (Clark et al., 2018) (25-shot), HumanEval (Chen et al., 2021) (0-shot), MBPP (Austin et al., 2021) (0-shot), EvalPlus(Liu et al., 2023a) (0-shot), MultiPL-E (Cassano et al., 2023) (0-shot on Python, C++, Java, PHP, Type-Script, C#, Bash, and JavaScript), GSM8K (Cobbe…”
- The Robots Are Here: Navigating the Generative AI Revolution in Computing Education (2023, background): “[121] provide the EvalPlus dataset, which enhances previously published datasets with additional test cases; they found that the limited tests available meant that incorrect “solutions” were accepted as passing.”
- WizardCoder: Empowering Code Large Language Models with Evol-Instruct (2023, methodology): “HumanEval [31], HumanEval+ [32] and MBPP [33] are extensively utilized benchmarks within the field of Code LLMs.”
- Large Language Models for Software Engineering: Survey and Open Problems (2023, background): “Liu et al. [90] draw attention to the problem, showing how existing test suites can lead to high degrees of false positive conclusions (also a serious problem for online judge platforms [89]).”
- TACO: Topics in Algorithmic COde generation dataset (2023, background): “Nevertheless, they encounter substantial difficulties when addressing complex and novel programming challenges [Hendrycks et al. , 2021; Li et al. , 2022; Liu et al. , 2023].”
- MAmmoTH2: Scaling Instructions from the Web (2024, neutral): “Most datasets, like OpenWebMath [Paster et al., 2023], Proof-Pile [Azerbayev et al., 2023], and MathPile [Zhang et al., 2024], are heavily biased towards mathematics.”
- Evaluating Large Language Models in Class-Level Code Generation (2024, methodology): “We select the state-of-the-art LLMs that have been widely studied in recent code generation work [44, 49].”
- Agentless: Demystifying LLM-based Software Engineering Agents (2024, background): “However, instead of embedding all files in the repository, A GENTLESS first filters out irrelevant folders.”
- Phi-4 Technical Report (2024, neutral): “We also consider MMLU-pro [WMZ + 24], HumanEval+ [LXWZ23], ArenaHard [CZS + 24], and IFEval [ZLM + 23], for which we use an internal framework and prompting and extraction.”
- Does Reinforcement Learning Really Incentivize Reasoning Capacity in LLMs Beyond the Base Model? (2025, positive): “For Code-R1 evaluation, we follow the original codebase and adopt the default templates from the benchmarks, including LiveCodeBench prompt (Figure 14), HumanEval+, and MBPP+ prompt (Figure 15).”