"vscode:/vscode.git/clone" did not exist on "888e25fbd0029f1c753e8466f736088e1cc46868"
TheoremQA_gen_424e0a.py 1.92 KB
Newer Older
Ezra-Yu's avatar
Ezra-Yu 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
Ezra-Yu's avatar
Ezra-Yu 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")
Ezra-Yu's avatar
Ezra-Yu committed
8

Fengzhe Zhou's avatar
Fengzhe Zhou committed
9
10
11
12
13
14
15
16
17
18
19
20
TheoremQA_prompt1 = (
    "Please read a math problem, and then think step by step to derive the answer. The answer is decided by Answer Type. "
    "If the Answer type in [bool], the answer needs to be True or False. "
    "Else if the Answer type in [integer, float] , The answer needs to be in numerical form. "
    "Else if the Answer type in [list of integer, list of float] , the answer needs to be a list of number like [2, 3, 4]. "
    "Else if the Answer type in [option], the answer needs to be an option like (a), (b), (c), (d)."
    "You need to output the answer in your final sentence like 'Therefore, the answer is ...'."
)
TheoremQA_prompt2 = (
    f"Below is an instruction that describes a task, paired with an input that provides further context. "
    f"Write a response that appropriately completes the request.\n\n### Instruction:\n{TheoremQA_prompt1}\n\n### Input:\n{{Question}}\nAnswer_type:{{Answer_type}}\n### Response:\n"
)
Ezra-Yu's avatar
Ezra-Yu committed
21
22

TheoremQA_infer_cfg = dict(
Fengzhe Zhou's avatar
Fengzhe Zhou committed
23
    prompt_template=dict(type=PromptTemplate, template=TheoremQA_prompt2),
Ezra-Yu's avatar
Ezra-Yu committed
24
    retriever=dict(type=ZeroRetriever),
Fengzhe Zhou's avatar
Fengzhe Zhou committed
25
26
    inferencer=dict(type=GenInferencer, max_out_len=512),
)
Ezra-Yu's avatar
Ezra-Yu committed
27

Fengzhe Zhou's avatar
Fengzhe Zhou committed
28
TheoremQA_eval_cfg = dict(evaluator=dict(type=AccEvaluator), pred_postprocessor=dict(type=TheoremQA_postprocess))
Ezra-Yu's avatar
Ezra-Yu committed
29
30
31

TheoremQA_datasets = [
    dict(
Fengzhe Zhou's avatar
Fengzhe Zhou committed
32
        abbr="TheoremQA",
Ezra-Yu's avatar
Ezra-Yu committed
33
34
35
36
        type=TheoremQADataset,
        path="./data/TheoremQA/test.csv",
        reader_cfg=TheoremQA_reader_cfg,
        infer_cfg=TheoremQA_infer_cfg,
Fengzhe Zhou's avatar
Fengzhe Zhou committed
37
38
        eval_cfg=TheoremQA_eval_cfg,
    )
Ezra-Yu's avatar
Ezra-Yu committed
39
]