This release has been yanked by its maintainers, and will be ignored by installers, except when explicitly specified.
Consider using release 0.3.1 instead.
Reason given by maintainers: Bugs #135
EvalPlus(📖) => 📚
🔥Quick Start • 💻LLM code • 🔨Tools • 📜Citation • 🙏Acknowledgement
About
EvalPlus is a rigorous evaluation framework for LLM4Code, with:
- ✨ HumanEval+: 80x more tests than the original HumanEval!
- ✨ MBPP+: 35x more tests than the original MBPP!
- ✨ Evaluation framework: our packages/images/tools can easily and safely evaluate LLMs on above benchmarks.
Why EvalPlus?
- ✨ Precise evaluation & ranking: See our leaderboard for latest LLM rankings before & after rigorous evaluation.
- ✨ Coding rigorousness: Look at the score differences! esp. before and after using EvalPlus tests! Less drop is better as it means more rigorousness and less laxity in code generation; while a big drop means the generated code tends to be fragile.
- ✨ Pre-generated samples: EvalPlus accelerates LLM4Code research by open-sourcing LLM-generated samples for vairous models -- no need to re-run the expensive benchmarks!
Want to know more details? Read our NeurIPS'23 paper as well as our Google Slides!
🔥 Quick Start
To get started, please first setup the environment:
pip install evalplus --upgrade
⏬ Install nightly version :: click to expand ::
pip install "git+https://github.com/evalplus/evalplus.git" --upgrade
⏬ Using EvalPlus as a local repo? :: click to expand ::
git clone https://github.com/evalplus/evalplus.git
cd evalplus
export PYTHONPATH=$PYTHONPATH:$(pwd)
pip install -r requirements.txt
Code generation
Implement the GEN_SOLUTION function by calling the LLM to produce the complete solution (include the code) and save the samples to samples.jsonl:
from evalplus.data import get_[human_eval|mbpp]_plus, write_jsonl
samples = [
dict(task_id=task_id, solution=GEN_SOLUTION(problem["prompt"]))
for task_id, problem in get_[human_eval|mbpp]_plus().items()
]
write_jsonl("samples.jsonl", samples)
🤔 Structure of `problem`? :: click to expand ::
task_idis the identifier string for the taskentry_pointis name of the functionpromptis the function signature with docstring
canonical_solutionis the ground-truth implementation (re-implemented to fix bugs in HumanEval)base_inputis the test inputs in original HumanEvalplus_inputis the test inputs brought by EvalPlus
Code post-processing
LLM-generated text may not be compilable code for including natural language lines or incomplete extra code.
We provide a tool namely evalplus.sanitize to clean up the code:
# 💡 If you are storing codes in jsonl:
evalplus.sanitize --samples samples.jsonl --dataset [humaneval|mbpp]
# Sanitized code will be produced to `samples-sanitized.jsonl`
# 💡 If you are storing codes in directories:
evalplus.sanitize --samples /path/to/vicuna-[??]b_temp_[??] --dataset [humaneval|mbpp]
# Sanitized code will be produced to `/path/to/vicuna-[??]b_temp_[??]-sanitized`
Note that the post-processing may not be perfect, you are suggested to use evalplus.syncheck to check the code validity before and after sanitization, which will print erroneous code snippets:
# 💡 If you are storing codes in jsonl:
evalplus.syncheck --samples samples.jsonl --dataset [humaneval|mbpp]
# 💡 If you are storing codes in directories:
evalplus.syncheck --samples /path/to/vicuna-[??]b_temp_[??] --dataset [humaneval|mbpp]
Code evaluation
You are strongly recommended to use a sandbox such as docker:
docker run -v $(pwd):/app ganler/evalplus:latest --dataset [humaneval|mbpp] --samples samples.jsonl
...Or if you want to try it locally regardless of the risks ⚠️:
evalplus.evaluate --dataset [humaneval|mbpp] --samples samples.jsonl
🤔 Evaluate with local GitHub repo? :: click to expand ::
export PYTHONPATH=$PYTHONPATH:$(pwd)
python evalplus/evaluate.py --dataset humaneval --samples samples.jsonl
⌨️ More command-line flags :: click to expand ::
--parallel: by default half of the cores--base-only(store_ture): only run base HumanEval tests--i-just-wanna-run: force a re-run
The output should be like (below is GPT-4 greedy decoding example):
Computing expected output...
Expected outputs computed in 15.18s
Reading samples...
164it [00:04, 37.79it/s]
Evaluating samples...
100%|██████████████████████████████████████████| 164/164 [00:03<00:00, 44.75it/s]
Base
{'pass@1': 0.8841463414634146}
Base + Extra
{'pass@1': 0.768}
Baseis thepass@kfor the original HumanEvalBase + Extrais thepass@kfor the our HumanEval+ (with extra tests)- The "k" includes
[1, 10, 100]where k values<=the sample size will be used - A cache file named like
samples_eval_results.jsonlwill be cached. Remove it to re-run the evaluation
🤔 How long it would take? :: click to expand ::
If you do greedy decoding where there is only one sample for each task, the evaluation should take just a few seconds.
When running 200 samples x 164 tasks x ~700+ tests, it can take around 2-10 minute by using --parallel 64 and --test-details.
Here are some tips to speed up the evaluation:
- Use
--parallel $(nproc) - Do NOT use
--test-detailsif you just want to quickly get pass@k as--test-detailswill run all tests (700+ on average for each task), while without--test-detailsthe testing for a sample stops immediately when it fails the first test. - Use our pre-evaluated results (see LLM-generated code)
- Use HumanEval+ Mini
💻 LLM-generated code
We also share pre-generated code samples from LLMs we have evaluated:
- HumanEval+: See the attachment of our v0.1.0 release.
- MBPP+: See the attachment of our v0.2.0 release.
Each sample file is packaged in a zip file named like ${model_name}_temp_${temperature}.zip.
You can unzip them to a folder named like ${model_name}_temp_${temperature} and run the evaluation from scratch with:
evalplus.evaluate --dataset humaneval --samples ${model_name}_temp_${temperature}
🔨 Useful tools
To use these tools, please first install the repository from GitHub:
git clone https://github.com/evalplus/evalplus.git
cd evalplus
pip install -r tools/requirements.txt
Code generation
We have configured the code generation of a wide range of LLMs (see support details in odegen/models.py). Example to run greedy generation on StarCoderBase-7B:
python codegen/generate.py --model starcoderbase-7b --bs 1 --temperature 0 --n_samples 1 --resume --greedy --root [result_path] --dataset [mbpp|humaneval]
Test input generation using EvalPlus
Please check evalplus/inputgen.py.
📜 Citation
@inproceedings{evalplus,
title = {Is Your Code Generated by Chat{GPT} Really Correct? Rigorous Evaluation of Large Language Models for Code Generation},
author = {Liu, Jiawei and Xia, Chunqiu Steven and Wang, Yuyao and Zhang, Lingming},
booktitle = {Thirty-seventh Conference on Neural Information Processing Systems},
year = {2023},
url = {https://openreview.net/forum?id=1qvx610Cu7},
}
🙏 Acknowledgement
Metadata
Release files for evalplus 0.2.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| evalplus-0.2.2.tar.gz | 574.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| evalplus-0.2.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 612.3 kB
Release files / evalplus-0.2.2.tar.gz
| Download URL | evalplus-0.2.2.tar.gz |
|---|---|
| Size | 574.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f8d5ad5523c3230f3addefb006a774e3eed4391ef6fd3157bbd52416573f91f5
|
|
BLAKE2b-256 checksum How to use checksums |
f09bbf68f469a8c5b5593e324e546f073619b550c058443755e03800e7b0c6ec
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.8.13
|
Release files / evalplus-0.2.2-py3-none-any.whl
| Download URL | evalplus-0.2.2-py3-none-any.whl |
|---|---|
| Size | 37.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
88a82d88760773dfd497af973cefc802ffe4465a5c1ebc34174119033729ac44
|
|
BLAKE2b-256 checksum How to use checksums |
7b404fff1e58be610285fecf80ba451bb3cf0b03ddae1b811048e80c24eb1daf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.8.13
|