"test/torchaudio_unittest/transforms_test.py" did not exist on "2271a7ae86d92d2a8f2ac69c6c7db3fb15b0f408"
hellaswag_10shot_ppl_59c85e.py 1.57 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 PPLInferencer
from opencompass.openicl.icl_evaluator import AccEvaluator
from opencompass.datasets import hellaswagDatasetwithICE
from opencompass.utils.text_postprocessors import first_capital_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
hint = 'Continue the following text without adding any additional information or formatting:'
question_and_options = '{ctx}\nA) {A}\nB) {B}\nC) {C}\nD) {D}\nWhat is the right option?'
Fengzhe Zhou's avatar
Fengzhe Zhou committed
17
18
19
hellaswag_infer_cfg = dict(
    ice_template=dict(
        type=PromptTemplate,
20
        template={answer: f'{question_and_options}\n{answer}\n' for answer in ['A', 'B', 'C', 'D']},
Fengzhe Zhou's avatar
Fengzhe Zhou committed
21
22
23
    ),
    prompt_template=dict(
        type=PromptTemplate,
24
25
        template={answer: f'{hint}\n</E>{question_and_options}\n{answer}' for answer in ['A', 'B', 'C', 'D']},
        ice_token='</E>',
Fengzhe Zhou's avatar
Fengzhe Zhou committed
26
27
28
29
30
31
32
33
34
35
36
37
    ),
    retriever=dict(type=FixKRetriever, fix_id_list=list(range(10))),
    inferencer=dict(type=PPLInferencer),
)

hellaswag_eval_cfg = dict(
    evaluator=dict(type=AccEvaluator),
    pred_postprocessor=dict(type=first_capital_postprocess),
)

hellaswag_datasets = [
    dict(
38
        abbr='hellaswag',
Fengzhe Zhou's avatar
Fengzhe Zhou committed
39
        type=hellaswagDatasetwithICE,
40
        path='./data/hellaswag/',
Fengzhe Zhou's avatar
Fengzhe Zhou committed
41
42
43
44
45
        reader_cfg=hellaswag_reader_cfg,
        infer_cfg=hellaswag_infer_cfg,
        eval_cfg=hellaswag_eval_cfg,
    )
]