q-rz/enamel

A benchmark for evaluating the efficiency of LLM-generated code

Python

17

51 commits

updated Apr 17, 2025

See the code

README

ENAMEL: A Code Efficiency Benchmark

Our paper at ICLR 2025 Our paper on arXiv Our dataset on HuggingFace Our Python library on PyPI

Getting Started | Library Usage | LLM Leaderboard | Acknowledgements

@inproceedings{qiu2025efficient,
  title={How efficient is {LLM}-generated code? A rigorous \& high-standard benchmark},
  authors={Qiu, Ruizhong and Zeng, Weiliang Will and Ezick, James and Lott, Christopher and Tong, Hanghang},
  booktitle={The Thirteenth International Conference on Learning Representations},
  year={2025}
}

What is ENAMEL?

ENAMEL is a rigorous and high-standard benchmark for evaluating the capability of large language models (LLMs) in generating efficient code. We provide:

  • A new metric $\text{eff}@k$ characterizing the relationship between code efficiency and sample size $k$;
  • A problem set consisting of 142 high-quality problems selected from OpenAI HumanEval;
  • Expert-written efficient reference solutions, setting a high-standard for efficiency evaluation;
  • Expert-written strong test case generators, enabling a rigorous evaluation of both correctness and efficiency;
  • A Python library enam for easily evaluating the efficiency of LLM-generated code.

If you are interested in our work, please feel free to check our paper for detail.

Illustration of ENAMEL

Getting Started

Dependencies

Before running the code, please ensure the following dependencies:

  • Linux
  • Python >= 3.10
  • Tqdm >= 3.1.4
  • NumPy >= 1.4.0
  • Pandas >= 1.0

Using our generated test cases and LLM-generated code samples

To facilitate reproduction, we share on HuggingFace our generated test cases and LLM-generated code samples used in our evaluation. Please download eval~tests.pkl into the cache/ folder and download the code samples into the samples/ folder.

To reproduce our results, please run demo.py, where --load_name specifies the file name of code samples (without file extension), and --tests specifies the generated test cases. For example, to evaluate the HumanEval+ canonical solutions, please run:

python3 demo.py --load_name humanevalplus-canonical --tests cache/eval~tests.pkl

Evaluating zipped code samples provided by EvalPlus

Our demo also supports the zipped code samples provided by EvalPlus. Please put their .zip files into our samples/ folder without renaming the files. For example, to evaluate the GPT-4 code samples gpt-4_temp_0.0.zip from EvalPlus, please run:

python3 demo.py --load_name gpt-4_temp_0.0 --tests cache/eval~tests.pkl

Warning: It is known to us that our evaluator might be unable to kill a code sample if the code uses try ... except ... within an infinity loop because the killing signal will be caught. We have decided not to resolve this issue because resolving it with multiprocessing will significantly slow down the evaluation process. If you do encounter this issue, please consider removing such code samples. (This issue indeed happens for two code samples provided by EvalPlus, so our demo will automatically handle it if you use the zipped code samples from EvalPlus.)

Evaluating new code samples

If you want to evaluate your own code samples, please organize them as a .json file, put it in the samples/ folder, and run demo.py. For example, if the code samples are in the file samples/codes.json, please run:

python3 demo.py --load_name codes --tests cache/eval~tests.pkl

The .json file should be a dict of lists such that codes[str(i)][j] is the $j$-th code sample of problem $i$.

Library Usage

Our benchmark is also available as a Python library. Please see demo.py for an example usage of our library.

Notice: It is NOT recommended to use multiple threads or processes in efficiency evaluation. That can negatively affect efficiency results.

Installation

Our library enam can be installed via pip:

pip install enam --upgrade

Note: To distinguish from our benchmark ENAMEL, we name our library enam.

LLM Leaderboard

The following table is a leaderboard of 30 LLMs (under greedy decoding) as well as HumanEval/HumanEval+ canonical solutions. Results show that LLMs fall short of generating expert-level efficient code. For more results, please refer to our paper.

We welcome LLM developers to submit their results to enrich this leaderboard. If you would like to submit your results, please organize your generated code samples into a .json file as described above and contact Ruizhong Qiu (rq5 AT illinois DOT edu).

No.Nameeff@1pass@1
1HumanEval+0.5170.958
2GPT-4 Turbo (Nov 2023)0.4700.796
3HumanEval0.4580.908
4GPT-4 (Jun 2023)0.4540.831
5Llama 3 70B Instruct0.4210.746
6Mixtral 8x22B Instruct0.4080.746
7Claude 3 Opus0.4010.789
8Phind Code Llama V20.3940.683
9Claude 3 Haiku0.3860.739
10ChatGPT0.3640.683
11Claude 3 Sonnet0.3450.662
12Llama 3 8B Instruct0.3440.592
13Code Llama 34B Python0.2680.458
14Mixtral 8x7B Instruct0.2660.444
15Code Llama 70B Python0.2640.500
16Code Llama 7B Python0.2470.373
17Code Llama 13B Python0.2160.408
18StarCoder0.1950.352
19CodeGen 6B0.1930.296
20CodeGen 16B0.1690.310
21CodeT5+ 16B0.1600.317
22CodeGen 2B0.1530.254
23Mistral 7B0.1520.275
24Vicuna 13B0.1230.176
25SantaCoder0.1000.141
26Incoder 6B0.0910.127
27GPT-J0.0830.106
28Incoder 1B0.0660.092
29Vicuna 7B0.0610.099
30GPT-Neo 2B0.0430.056
31PolyCoder0.0370.049
32StableLM 7B0.0200.021

Acknowledgements

Contributors

q-rz

51 commits

q-rz/enamel

A benchmark for evaluating the efficiency of LLM-generated code

Python

17

51 commits

updated Apr 17, 2025

See the code

README

ENAMEL: A Code Efficiency Benchmark

Our paper at ICLR 2025 Our paper on arXiv Our dataset on HuggingFace Our Python library on PyPI

Getting Started | Library Usage | LLM Leaderboard | Acknowledgements

@inproceedings{qiu2025efficient,
  title={How efficient is {LLM}-generated code? A rigorous \& high-standard benchmark},
  authors={Qiu, Ruizhong and Zeng, Weiliang Will and Ezick, James and Lott, Christopher and Tong, Hanghang},
  booktitle={The Thirteenth International Conference on Learning Representations},
  year={2025}
}

What is ENAMEL?

ENAMEL is a rigorous and high-standard benchmark for evaluating the capability of large language models (LLMs) in generating efficient code. We provide:

  • A new metric $\text{eff}@k$ characterizing the relationship between code efficiency and sample size $k$;
  • A problem set consisting of 142 high-quality problems selected from OpenAI HumanEval;
  • Expert-written efficient reference solutions, setting a high-standard for efficiency evaluation;
  • Expert-written strong test case generators, enabling a rigorous evaluation of both correctness and efficiency;
  • A Python library enam for easily evaluating the efficiency of LLM-generated code.

If you are interested in our work, please feel free to check our paper for detail.

Illustration of ENAMEL

Getting Started

Dependencies

Before running the code, please ensure the following dependencies:

  • Linux
  • Python >= 3.10
  • Tqdm >= 3.1.4
  • NumPy >= 1.4.0
  • Pandas >= 1.0

Using our generated test cases and LLM-generated code samples

To facilitate reproduction, we share on HuggingFace our generated test cases and LLM-generated code samples used in our evaluation. Please download eval~tests.pkl into the cache/ folder and download the code samples into the samples/ folder.

To reproduce our results, please run demo.py, where --load_name specifies the file name of code samples (without file extension), and --tests specifies the generated test cases. For example, to evaluate the HumanEval+ canonical solutions, please run:

python3 demo.py --load_name humanevalplus-canonical --tests cache/eval~tests.pkl

Evaluating zipped code samples provided by EvalPlus

Our demo also supports the zipped code samples provided by EvalPlus. Please put their .zip files into our samples/ folder without renaming the files. For example, to evaluate the GPT-4 code samples gpt-4_temp_0.0.zip from EvalPlus, please run:

python3 demo.py --load_name gpt-4_temp_0.0 --tests cache/eval~tests.pkl

Warning: It is known to us that our evaluator might be unable to kill a code sample if the code uses try ... except ... within an infinity loop because the killing signal will be caught. We have decided not to resolve this issue because resolving it with multiprocessing will significantly slow down the evaluation process. If you do encounter this issue, please consider removing such code samples. (This issue indeed happens for two code samples provided by EvalPlus, so our demo will automatically handle it if you use the zipped code samples from EvalPlus.)

Evaluating new code samples

If you want to evaluate your own code samples, please organize them as a .json file, put it in the samples/ folder, and run demo.py. For example, if the code samples are in the file samples/codes.json, please run:

python3 demo.py --load_name codes --tests cache/eval~tests.pkl

The .json file should be a dict of lists such that codes[str(i)][j] is the $j$-th code sample of problem $i$.

Library Usage

Our benchmark is also available as a Python library. Please see demo.py for an example usage of our library.

Notice: It is NOT recommended to use multiple threads or processes in efficiency evaluation. That can negatively affect efficiency results.

Installation

Our library enam can be installed via pip:

pip install enam --upgrade

Note: To distinguish from our benchmark ENAMEL, we name our library enam.

LLM Leaderboard

The following table is a leaderboard of 30 LLMs (under greedy decoding) as well as HumanEval/HumanEval+ canonical solutions. Results show that LLMs fall short of generating expert-level efficient code. For more results, please refer to our paper.

We welcome LLM developers to submit their results to enrich this leaderboard. If you would like to submit your results, please organize your generated code samples into a .json file as described above and contact Ruizhong Qiu (rq5 AT illinois DOT edu).

No.Nameeff@1pass@1
1HumanEval+0.5170.958
2GPT-4 Turbo (Nov 2023)0.4700.796
3HumanEval0.4580.908
4GPT-4 (Jun 2023)0.4540.831
5Llama 3 70B Instruct0.4210.746
6Mixtral 8x22B Instruct0.4080.746
7Claude 3 Opus0.4010.789
8Phind Code Llama V20.3940.683
9Claude 3 Haiku0.3860.739
10ChatGPT0.3640.683
11Claude 3 Sonnet0.3450.662
12Llama 3 8B Instruct0.3440.592
13Code Llama 34B Python0.2680.458
14Mixtral 8x7B Instruct0.2660.444
15Code Llama 70B Python0.2640.500
16Code Llama 7B Python0.2470.373
17Code Llama 13B Python0.2160.408
18StarCoder0.1950.352
19CodeGen 6B0.1930.296
20CodeGen 16B0.1690.310
21CodeT5+ 16B0.1600.317
22CodeGen 2B0.1530.254
23Mistral 7B0.1520.275
24Vicuna 13B0.1230.176
25SantaCoder0.1000.141
26Incoder 6B0.0910.127
27GPT-J0.0830.106
28Incoder 1B0.0660.092
29Vicuna 7B0.0610.099
30GPT-Neo 2B0.0430.056
31PolyCoder0.0370.049
32StableLM 7B0.0200.021

Acknowledgements

Contributors

q-rz

51 commits

Languages

Python

100.0%