math_0shot_gen_393424.py 1.1 KB
Newer Older
Fengzhe Zhou's avatar
Fengzhe Zhou committed
1
2
3
4
5
from opencompass.openicl.icl_prompt_template import PromptTemplate
from opencompass.openicl.icl_retriever import ZeroRetriever
from opencompass.openicl.icl_inferencer import GenInferencer
from opencompass.datasets import MATHDataset, MATHEvaluator, math_postprocess_v2, normalize_final_answer

6
math_reader_cfg = dict(input_columns=['problem'], output_column='solution')
Fengzhe Zhou's avatar
Fengzhe Zhou committed
7
8
9
10
11
12

math_infer_cfg = dict(
    prompt_template=dict(
        type=PromptTemplate,
        template=dict(
            round=[
13
                dict(role='HUMAN', prompt='{problem}\nPlease reason step by step, and put your final answer within \\boxed{}.'),
Fengzhe Zhou's avatar
Fengzhe Zhou committed
14
15
16
17
18
19
20
21
22
            ]
        ),
    ),
    retriever=dict(type=ZeroRetriever),
    inferencer=dict(type=GenInferencer, max_out_len=1024),
)

# postprocess v2
math_eval_cfg = dict(
23
    evaluator=dict(type=MATHEvaluator, version='v2'), pred_postprocessor=dict(type=math_postprocess_v2),
Fengzhe Zhou's avatar
Fengzhe Zhou committed
24
25
26
27
28
)

math_datasets = [
    dict(
        type=MATHDataset,
29
30
        abbr='math',
        path='./data/math/math.json',
Fengzhe Zhou's avatar
Fengzhe Zhou committed
31
32
33
34
35
        reader_cfg=math_reader_cfg,
        infer_cfg=math_infer_cfg,
        eval_cfg=math_eval_cfg,
    )
]