leval_gsm100_gen_77dd94.py 1.75 KB
Newer Older
Tong Gao's avatar
Tong Gao committed
1
2
3
4
from opencompass.openicl.icl_prompt_template import PromptTemplate
from opencompass.openicl.icl_retriever import ZeroRetriever
from opencompass.openicl.icl_inferencer import GenInferencer
from opencompass.openicl.icl_evaluator import EMEvaluator, RougeEvaluator, SquadEvaluator, AccEvaluator
philipwangOvO's avatar
philipwangOvO committed
5
from opencompass.datasets.leval import LEvalGSM100Dataset
Tong Gao's avatar
Tong Gao committed
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
from opencompass.utils.text_postprocessors import first_capital_postprocess, first_capital_postprocess_multi
from opencompass.registry import TEXT_POSTPROCESSORS
from opencompass.datasets import gsm100_dataset_postprocess, gsm100_postprocess

LEval_gsm100_reader_cfg = dict(
    input_columns=['context', 'question'],
    output_column='answer',
    train_split='test',
    test_split='test'
)

LEval_gsm100_infer_cfg = dict(
    prompt_template=dict(
        type=PromptTemplate,
        template=dict(
philipwangOvO's avatar
philipwangOvO committed
21
22
23
            begin=[
                dict(role='SYSTEM', fallback_role='HUMAN', prompt='Given several question answer pairs, you need to follow a similar format to answer the last question. Make sure the response is end with The answer is _ . '),
            ],
Tong Gao's avatar
Tong Gao committed
24
            round=[
philipwangOvO's avatar
philipwangOvO committed
25
                dict(role='HUMAN', prompt='{context}\n\n{question}\n'),
Tong Gao's avatar
Tong Gao committed
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
            ], )),
    retriever=dict(type=ZeroRetriever),
    inferencer=dict(type=GenInferencer, max_out_len=512)
)


LEval_gsm100_eval_cfg = dict(evaluator=dict(type=AccEvaluator),
    pred_postprocessor=dict(type=gsm100_postprocess),
    dataset_postprocessor=dict(type=gsm100_dataset_postprocess)
)

LEval_gsm100_datasets = [
    dict(
        type=LEvalGSM100Dataset,
        abbr='LEval_gsm100',
        path='L4NLP/LEval',
        name='gsm100',
        reader_cfg=LEval_gsm100_reader_cfg,
        infer_cfg=LEval_gsm100_infer_cfg,
        eval_cfg=LEval_gsm100_eval_cfg)
]