|
| 1 | +"""Is Your Code Generated by ChatGPT Really Correct? Rigorous Evaluation of Large Language Models for Code Generation |
| 2 | +https://openreview.net/forum?id=1qvx610Cu7 |
| 3 | +
|
| 4 | +The HumanEval+ dataset is created by the EvalPlus framework which extends the original HumanEval dataset |
| 5 | +by adding more automatically generated test cases to each problem. |
| 6 | +
|
| 7 | +Homepage: https://github.com/evalplus/evalplus |
| 8 | +""" |
| 9 | + |
| 10 | +from warnings import warn |
| 11 | + |
| 12 | +from bigcode_eval.tasks.humaneval import GeneralHumanEval |
| 13 | + |
| 14 | +_CITATION = """ |
| 15 | +@inproceedings{evalplus, |
| 16 | + title = {Is Your Code Generated by Chat{GPT} Really Correct? Rigorous Evaluation of Large Language Models for Code Generation}, |
| 17 | + author = {Liu, Jiawei and Xia, Chunqiu Steven and Wang, Yuyao and Zhang, Lingming}, |
| 18 | + booktitle = {Thirty-seventh Conference on Neural Information Processing Systems}, |
| 19 | + year = {2023}, |
| 20 | + url = {https://openreview.net/forum?id=1qvx610Cu7}, |
| 21 | +} |
| 22 | +""" |
| 23 | + |
| 24 | + |
| 25 | +class GeneralHumanEvalPlus(GeneralHumanEval): |
| 26 | + """A task represents an entire benchmark including its dataset, problems, |
| 27 | + answers, generation settings and evaluation methods. |
| 28 | + """ |
| 29 | + |
| 30 | + DATASET_PATH = "evalplus/humanevalplus" |
| 31 | + |
| 32 | + def __init__(self, strip_prompt, k=[1, 10, 100], num_workers=16, timeout=10.0): |
| 33 | + if timeout < 10.0: |
| 34 | + warn( |
| 35 | + "It is suggested to have a longer timeout as HumanEval+ has lots of tests. " |
| 36 | + f"The current timeout is {timeout}s while the suggested timeout is 10s." |
| 37 | + ) |
| 38 | + super().__init__(strip_prompt, k, num_workers, timeout) |
| 39 | + |
| 40 | + |
| 41 | +def create_task(strip_prompt): |
| 42 | + class HumanEvalPlus(GeneralHumanEvalPlus): |
| 43 | + def __init__(self, **kwargs): |
| 44 | + super().__init__(strip_prompt, **kwargs) |
| 45 | + |
| 46 | + return HumanEvalPlus |
| 47 | + |
| 48 | + |
| 49 | +def create_all_tasks(): |
| 50 | + """Creates a dictionary of tasks from a list of levels |
| 51 | + :return: {task_name: task} |
| 52 | + e.g. {multiple-py: Task, multiple-java: Task} |
| 53 | + """ |
| 54 | + return { |
| 55 | + "humanevalplus": create_task(True), |
| 56 | + "humanevalplus-unstripped": create_task(False), |
| 57 | + } |
0 commit comments