hellaswag_10shot_gen_e42710.py 1.88 KB
Newer Older
Fengzhe Zhou's avatar
Fengzhe Zhou committed
1
2
3
4
5
6
7
8
from opencompass.openicl.icl_prompt_template import PromptTemplate
from opencompass.openicl.icl_retriever import FixKRetriever
from opencompass.openicl.icl_inferencer import GenInferencer
from opencompass.openicl.icl_evaluator import AccEvaluator
from opencompass.datasets import hellaswagDatasetwithICE
from opencompass.utils.text_postprocessors import first_option_postprocess

hellaswag_reader_cfg = dict(
9
10
11
12
    input_columns=['ctx', 'A', 'B', 'C', 'D'],
    output_column='label',
    train_split='train',
    test_split='val',
Fengzhe Zhou's avatar
Fengzhe Zhou committed
13
14
15
16
17
18
19
)

hellaswag_infer_cfg = dict(
    ice_template=dict(
        type=PromptTemplate,
        template=dict(
            round=[
20
21
                dict(role='HUMAN', prompt=f'{{ctx}}\nA) {{A}}\nB) {{B}}\nC) {{C}}\nD) {{D}}\nWhat is the right option?'),
                dict(role='BOT', prompt='{label}\n'),
Fengzhe Zhou's avatar
Fengzhe Zhou committed
22
23
24
25
26
27
28
            ]
        ),
    ),
    prompt_template=dict(
        type=PromptTemplate,
        template=dict(
            begin=[
29
30
                dict(role='HUMAN', prompt='Continue the following text without adding any additional information or formatting:\n'),
                '</E>',
Fengzhe Zhou's avatar
Fengzhe Zhou committed
31
32
            ],
            round=[
33
34
                dict(role='HUMAN', prompt=f'{{ctx}}\nA) {{A}}\nB) {{B}}\nC) {{C}}\nD) {{D}}\nWhat is the right option?'),
                dict(role='BOT', prompt='{label}\n'),
Fengzhe Zhou's avatar
Fengzhe Zhou committed
35
36
            ],
        ),
37
        ice_token='</E>',
Fengzhe Zhou's avatar
Fengzhe Zhou committed
38
39
40
41
42
43
44
    ),
    retriever=dict(type=FixKRetriever, fix_id_list=list(range(10))),
    inferencer=dict(type=GenInferencer),
)

hellaswag_eval_cfg = dict(
    evaluator=dict(type=AccEvaluator),
45
46
    pred_role='BOT',
    pred_postprocessor=dict(type=first_option_postprocess, options='ABCD'),
Fengzhe Zhou's avatar
Fengzhe Zhou committed
47
48
49
50
)

hellaswag_datasets = [
    dict(
51
        abbr='hellaswag',
Fengzhe Zhou's avatar
Fengzhe Zhou committed
52
        type=hellaswagDatasetwithICE,
53
        path='./data/hellaswag/',
Fengzhe Zhou's avatar
Fengzhe Zhou committed
54
55
56
57
58
        reader_cfg=hellaswag_reader_cfg,
        infer_cfg=hellaswag_infer_cfg,
        eval_cfg=hellaswag_eval_cfg,
    )
]