GaokaoBench_no_subjective_gen_4c31db.py 1.52 KB
Newer Older
Fengzhe Zhou's avatar
Fengzhe Zhou committed
1
2
3
4
5
6
7
8
9
10
11
12
import os
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 GaokaoBenchDataset
from mmengine.config import read_base

with read_base():
    from .GaokaoBench_prompts import MCQ_prompts, FBQ_prompts

GaokaoBench_datasets = []
for folder, prompts in [
13
14
    ('Multiple-choice_Questions', MCQ_prompts),
    ('Fill-in-the-blank_Questions', FBQ_prompts),
Fengzhe Zhou's avatar
Fengzhe Zhou committed
15
16
17
]:
    for p in prompts:
        reader_cfg = {
18
19
            'input_columns': ['question'],
            'output_column': 'answer',
Fengzhe Zhou's avatar
Fengzhe Zhou committed
20
21
        }
        infer_cfg = {
22
23
24
25
            'ice_template': {
                'type': PromptTemplate,
                'template': {'round': [{'role': 'HUMAN', 'prompt': p['prefix_prompt'] + '{question}'}]},
                'ice_token': '</E>',
Fengzhe Zhou's avatar
Fengzhe Zhou committed
26
            },
27
28
            'retriever': {'type': ZeroRetriever},
            'inferencer': {'type': GenInferencer, 'max_out_len': 1024},
Fengzhe Zhou's avatar
Fengzhe Zhou committed
29
30
        }
        eval_cfg = {
31
32
            'evaluator': {'type': 'GaokaoBenchEvaluator' + '_' + p['type']},
            'pred_role': 'BOT',
Fengzhe Zhou's avatar
Fengzhe Zhou committed
33
34
        }
        dataset = {
35
36
37
38
39
40
            'type': GaokaoBenchDataset,
            'abbr': 'GaokaoBench_' + p['keyword'],
            'path': os.path.join('data', 'GAOKAO-BENCH', 'data', folder, p['keyword'] + '.json'),
            'reader_cfg': reader_cfg,
            'infer_cfg': infer_cfg,
            'eval_cfg': eval_cfg,
Fengzhe Zhou's avatar
Fengzhe Zhou committed
41
42
        }
        GaokaoBench_datasets.append(dataset)