| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
🔥Quick Start • 💻LLM code • 📜Papers • 🔨Tools • 👷Development • 🙏Acknowledgement
Warning
🚨 Evaluating LLM-generated code over datasets with "3 test-cases" is **NOT** enough! 🚨
To address this, we started the EvalPlus project -- a rigourous evaluation framework for LLM4Code that:
To get started, please first setup the environment:
pip install evalplus --upgrade...Or you can try out the latest developing version:
pip install "git+https://github.com/evalplus/evalplus.git" --upgradegit clone https://github.com/evalplus/evalplus.git
cd evalplus
export PYTHONPATH=$PYTHONPATH:$(pwd)
pip install -r requirements.txtThe usage is just like the original HumanEval where you just need to implement the generate_one_completion function!
from evalplus.data import get_human_eval_plus, write_jsonl
problems = get_human_eval_plus()
num_samples_per_task = 200
samples = [
dict(task_id=task_id, completion=generate_one_completion(problems[task_id]["prompt"]))
for task_id in problems
for _ in range(num_samples_per_task)
]
write_jsonl("samples.jsonl", samples)You are strongly recommended to use a sandbox such as docker:
docker run -v $(pwd):/app ganler/evalplus:latest --dataset humaneval --samples samples.jsonl...Or if you want to try it locally regardless of the risks ⚠️:
evalplus.evaluate --dataset humaneval --samples samples.jsonl🤔 Evaluate with local GitHub repo? :: click to expand ::Warning ⚠️ Do you use a very slow machine?
LLM solutions are regarded as failed on timeout (and OOM etc.). Specifically, we set the timeout $T=\max(T_{base}, T_{gt}\times k)$, where:
- $T_{base}$ is the minimal timeout (configurable by --min-time-limit; default to 0.2s);
- $T_{gt}$ is the runtime of the ground-truth solutions (achieved via profiling);
- $k$ is a configurable factor --gt-time-limit-factor (default to 4);
If your machine is too slow and you are getting high-variance results, try to use larger $k$ and $T_{base}$.
Additionally, you are NOT encouraged to make your test-bed over stressed while running evaluation. For example, using --parallel 64 on a 4-core machine or doing something else during evaluation are bad ideas...
export PYTHONPATH=$PYTHONPATH:$(pwd)
python evalplus/evaluate.py --dataset humaneval --samples samples.jsonlThe 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.75}
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:
🚀 Try out HumanEvalPlus-Mini! which selects a minimal set of additional tests with the highest quality, achieving almost the same effectiveness of the full version. Just add a --mini flag, it can run 23+% faster! (even faster if you evaluate all tests without fail-stop with --test-details).
docker run -v $(pwd):/app ganler/evalplus:latest --dataset humaneval --samples samples.jsonl --mini # ...Or locally ⚠️ # evalplus.evaluate --dataset humaneval --samples samples.jsonl --mini
Please kindly find the LLM-pre-generated code samples in the attachment of our v0.1.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}Read our paper for more detailed findings!
@article{evalplus,
title={Is Your Code Generated by ChatGPT Really Correct? Rigorous Evaluation of Large Language Models for Code Generation},
author={Jiawei Liu and Chunqiu Steven Xia and Yuyao Wang and Lingming Zhang},
journal={arXiv preprint arXiv:2305.01210},
year={2023},
}To use these tools, please first install the repository from GitHub:
git clone https://github.com/evalplus/evalplus.git
cd evalplus
pip install -r requirements-tools.txtCheck LLM-produced code and answer the following questions:
python tools/checker.py --folder /path/to/[model]-[??]b_temp_[??] --dataset humanevalLLM-generated code may contain some syntax errors. But some of them can be easily fixable by doing simple post-processing. This tool will make the LLM-generated code more clean/compilable by doing certain post-processing such as trimming with more magical EOFs and some garbage non-code tokens.
python tools/sanitize.py --eof --folder /path/to/vicuna-[??]b_temp_[??]
# Sanitized code will be produced to `/path/to/vicuna-[??]b_temp_[??]-sanitized`python tools/render.py --type /path/to/[model]-[??]b # NOTE: no `_temp_[??]`Before you start:
pip install pre-commit
pre-commit install
export PYTHONPATH=$PYTHONPATH:$(pwd)| Back | FazBrowse Home | New Git URL |