"official/nlp/bert/model_training_utils.py" did not exist on "7d86c3171d1a89c728fb21d8f64f63bd107de0d2"
leval_quality_gen_36a006.py 1.8 KB
Newer Older
Tong Gao's avatar
Tong Gao 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 EMEvaluator, RougeEvaluator, SquadEvaluator, AccEvaluator
philipwangOvO's avatar
philipwangOvO committed
5
from opencompass.datasets.leval import LEvalQualityDataset
Tong Gao's avatar
Tong Gao committed
6
7
8
9
10
11
12
13
14
15
16
17
18
from opencompass.utils.text_postprocessors import first_capital_postprocess, first_capital_postprocess_multi

LEval_quality_reader_cfg = dict(
    input_columns=['context', 'question'],
    output_column='answer',
    train_split='test',
    test_split='test'
)

LEval_quality_infer_cfg = dict(
    prompt_template=dict(
        type=PromptTemplate,
        template=dict(
philipwangOvO's avatar
philipwangOvO committed
19
20
21
            begin=[
                dict(role='SYSTEM', fallback_role='HUMAN', prompt='Now you are given a very long document. Please follow the instruction based on this document. For multi-choice questions, there could be a single correct option or multiple correct options. Please only provide the letter corresponding to the answer (like A or AB) when answering.'),
            ],
Tong Gao's avatar
Tong Gao committed
22
            round=[
philipwangOvO's avatar
philipwangOvO committed
23
                dict(role='HUMAN', prompt='Document is as follows.\n{context}\nQuestion:{question}\nAnswer:'),
Tong Gao's avatar
Tong Gao committed
24
25
26
27
28
29
30
                dict(role='BOT', prompt=''),
            ], )),
    retriever=dict(type=ZeroRetriever),
    inferencer=dict(type=GenInferencer, max_out_len=10)
)

LEval_quality_eval_cfg = dict(
31
    evaluator=dict(type=AccEvaluator),
Tong Gao's avatar
Tong Gao committed
32
33
34
35
36
37
38
39
40
41
42
43
44
45
    pred_postprocessor=dict(type=first_capital_postprocess),
    pred_role='BOT'
)

LEval_quality_datasets = [
    dict(
        type=LEvalQualityDataset,
        abbr='LEval_quality',
        path='L4NLP/LEval',
        name='quality',
        reader_cfg=LEval_quality_reader_cfg,
        infer_cfg=LEval_quality_infer_cfg,
        eval_cfg=LEval_quality_eval_cfg)
]