TheoremQA_gen_7009de.py 1.67 KB
Newer Older
gaotongxiao's avatar
gaotongxiao 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 AccEvaluator
Leymore's avatar
Leymore committed
5
from opencompass.datasets import TheoremQADataset, TheoremQA_postprocess
gaotongxiao's avatar
gaotongxiao committed
6

Fengzhe Zhou's avatar
Fengzhe Zhou committed
7
TheoremQA_reader_cfg = dict(input_columns=["Question", "Answer_type"], output_column="Answer", train_split="test")
gaotongxiao's avatar
gaotongxiao committed
8
9
10
11
12
13
14

TheoremQA_prompt1 = """You are a mathematician, you are supposed to answer the given question. You need to output the answer in your final sentence like "Therefore, the answer is ...". The answer can only be one of the following forms:
1. a numerical value like 0.1, no symbol and no unit at all.
2. a list of number like [2, 3, 4].
3. True/False.
4. an option like (a), (b), (c), (d)
"""
Fengzhe Zhou's avatar
Fengzhe Zhou committed
15
TheoremQA_prompt2 = "Question: {Question}\nLet's think step by step."
gaotongxiao's avatar
gaotongxiao committed
16
17
18
19
20
21

TheoremQA_infer_cfg = dict(
    prompt_template=dict(
        type=PromptTemplate,
        template=dict(
            begin=[
Fengzhe Zhou's avatar
Fengzhe Zhou committed
22
                dict(role="SYSTEM", fallback_role="HUMAN", prompt=TheoremQA_prompt1),
gaotongxiao's avatar
gaotongxiao committed
23
24
            ],
            round=[
Fengzhe Zhou's avatar
Fengzhe Zhou committed
25
26
27
28
                dict(role="HUMAN", prompt=TheoremQA_prompt2),
            ],
        ),
    ),
gaotongxiao's avatar
gaotongxiao committed
29
    retriever=dict(type=ZeroRetriever),
Fengzhe Zhou's avatar
Fengzhe Zhou committed
30
31
    inferencer=dict(type=GenInferencer, max_out_len=512),
)
gaotongxiao's avatar
gaotongxiao committed
32

Fengzhe Zhou's avatar
Fengzhe Zhou committed
33
TheoremQA_eval_cfg = dict(evaluator=dict(type=AccEvaluator), pred_postprocessor=dict(type=TheoremQA_postprocess))
gaotongxiao's avatar
gaotongxiao committed
34
35
36

TheoremQA_datasets = [
    dict(
Fengzhe Zhou's avatar
Fengzhe Zhou committed
37
        abbr="TheoremQA",
gaotongxiao's avatar
gaotongxiao committed
38
39
40
41
        type=TheoremQADataset,
        path="./data/TheoremQA/test.csv",
        reader_cfg=TheoremQA_reader_cfg,
        infer_cfg=TheoremQA_infer_cfg,
Fengzhe Zhou's avatar
Fengzhe Zhou committed
42
43
        eval_cfg=TheoremQA_eval_cfg,
    )
gaotongxiao's avatar
gaotongxiao committed
44
]