FewCLUE_eprstmt_gen_740ea0.py 1.56 KB
Newer Older
Leymore's avatar
Leymore 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.openicl.icl_evaluator import AccEvaluator
from opencompass.datasets import eprstmtDataset_V2
Leymore's avatar
Leymore committed
6
from opencompass.utils.text_postprocessors import first_capital_postprocess
Leymore's avatar
Leymore committed
7
8

eprstmt_reader_cfg = dict(
9
    input_columns=['sentence'], output_column='label', test_split='train')
Leymore's avatar
Leymore committed
10
11
12
13
14
15

eprstmt_infer_cfg = dict(
    prompt_template=dict(
        type=PromptTemplate,
        template=dict(round=[
            dict(
16
                role='HUMAN',
Leymore's avatar
Leymore committed
17
18
19
20
21
22
23
24
25
26
27
                prompt=
                '内容: "{sentence}"。请对上述内容进行情绪分类。\nA. 积极\nB. 消极\n请从”A“,”B“中进行选择。\n答:'
            ),
        ]),
    ),
    retriever=dict(type=ZeroRetriever),
    inferencer=dict(type=GenInferencer),
)

eprstmt_eval_cfg = dict(
    evaluator=dict(type=AccEvaluator),
28
    pred_role='BOT',
Leymore's avatar
Leymore committed
29
    pred_postprocessor=dict(type=first_capital_postprocess),
Leymore's avatar
Leymore committed
30
31
32
33
)

eprstmt_datasets = [
    dict(
34
        abbr='eprstmt-dev',
Leymore's avatar
Leymore committed
35
        type=eprstmtDataset_V2,
36
        path='./data/FewCLUE/eprstmt/dev_few_all.json',
Leymore's avatar
Leymore committed
37
38
39
40
41
        reader_cfg=eprstmt_reader_cfg,
        infer_cfg=eprstmt_infer_cfg,
        eval_cfg=eprstmt_eval_cfg,
    ),
    dict(
42
        abbr='eprstmt-test',
Leymore's avatar
Leymore committed
43
        type=eprstmtDataset_V2,
44
        path='./data/FewCLUE/eprstmt/test_public.json',
Leymore's avatar
Leymore committed
45
46
47
48
49
        reader_cfg=eprstmt_reader_cfg,
        infer_cfg=eprstmt_infer_cfg,
        eval_cfg=eprstmt_eval_cfg,
    ),
]