humaneval_gen_ff7054.py 1.35 KB
Newer Older
yingfhu's avatar
yingfhu committed
1
2
3
from opencompass.openicl.icl_prompt_template import PromptTemplate
from opencompass.openicl.icl_retriever import ZeroRetriever
from opencompass.openicl.icl_inferencer import GenInferencer
4
from opencompass.datasets import HumanevalDataset, HumanEvaluator, humaneval_postprocess
yingfhu's avatar
yingfhu committed
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29

humaneval_reader_cfg = dict(
    input_columns=['prompt'], output_column='task_id', train_split='test')

# TODO: allow empty output-column
humaneval_infer_cfg = dict(
    prompt_template=dict(
        type=PromptTemplate,
        template=dict(
            begin=[
                dict(
                    role='SYSTEM',
                    fallback_role='HUMAN',
                    prompt='Complete the following python code:'),
            ],
            round=[
                dict(role='HUMAN', prompt='{prompt}'),
            ])),
    retriever=dict(type=ZeroRetriever),
    inferencer=dict(type=GenInferencer))

humaneval_eval_cfg = dict(
    evaluator=dict(type=HumanEvaluator),
    pred_role='BOT',
    k=[1, 10, 100],  # the parameter only for humaneval
Leymore's avatar
Leymore committed
30
    pred_postprocessor=dict(type=humaneval_postprocess),
yingfhu's avatar
yingfhu committed
31
32
33
34
)

humaneval_datasets = [
    dict(
35
36
37
        abbr='openai_humaneval',
        type=HumanevalDataset,
        path='./data/humaneval/human-eval-v2-20210705.jsonl',
yingfhu's avatar
yingfhu committed
38
39
40
41
        reader_cfg=humaneval_reader_cfg,
        infer_cfg=humaneval_infer_cfg,
        eval_cfg=humaneval_eval_cfg)
]