2023-09-27 11:36:43 +08:00
|
|
|
from opencompass.openicl.icl_prompt_template import PromptTemplate
|
|
|
|
from opencompass.openicl.icl_retriever import FixKRetriever
|
|
|
|
from opencompass.openicl.icl_inferencer import PPLInferencer
|
|
|
|
from opencompass.openicl.icl_evaluator import AccEvaluator
|
|
|
|
from opencompass.datasets import HFDataset
|
|
|
|
|
|
|
|
|
2024-05-14 15:35:58 +08:00
|
|
|
_hint = 'The following are semantic matching questions. \n' \
|
|
|
|
'Please determine whether the following two sentences are semantically duplicate: ' \
|
|
|
|
'0 means not duplicate, 1 means duplicate.\n'
|
2023-09-27 11:36:43 +08:00
|
|
|
QQP_infer_cfg = dict(
|
|
|
|
ice_template=dict(
|
|
|
|
type=PromptTemplate,
|
2024-05-14 15:35:58 +08:00
|
|
|
template='Sentence one: {question1}\nSentence two: {question2}\nResult: {label}',
|
2023-09-27 11:36:43 +08:00
|
|
|
),
|
|
|
|
prompt_template=dict(
|
|
|
|
type=PromptTemplate,
|
|
|
|
template={
|
|
|
|
answer:
|
2024-05-14 15:35:58 +08:00
|
|
|
f'{_hint}</E>Sentence one: {{question1}}\nSentence two: {{question2}}\nResult: {answer}'
|
2023-09-27 11:36:43 +08:00
|
|
|
for answer in [0, 1]
|
|
|
|
},
|
|
|
|
ice_token='</E>',
|
|
|
|
),
|
2023-10-07 12:53:41 +08:00
|
|
|
retriever=dict(type=FixKRetriever, fix_id_list=[0, 1, 2, 3, 4]),
|
|
|
|
inferencer=dict(type=PPLInferencer))
|
2023-09-27 11:36:43 +08:00
|
|
|
|
|
|
|
QQP_eval_cfg = dict(evaluator=dict(type=AccEvaluator), )
|
|
|
|
|
|
|
|
|
|
|
|
QQP_datasets = []
|
2024-05-14 15:35:58 +08:00
|
|
|
for _split in ['validation', 'test']:
|
2023-09-27 11:36:43 +08:00
|
|
|
|
|
|
|
QQP_reader_cfg = dict(
|
|
|
|
input_columns=['question1', 'question2'],
|
|
|
|
output_column='label',
|
2024-05-14 15:35:58 +08:00
|
|
|
train_split='train',
|
2023-09-27 11:36:43 +08:00
|
|
|
test_split=_split
|
|
|
|
)
|
|
|
|
|
|
|
|
QQP_datasets.append(
|
|
|
|
dict(
|
|
|
|
abbr=f'QQP-{_split}',
|
|
|
|
type=HFDataset,
|
|
|
|
path='glue',
|
|
|
|
name='qqp',
|
|
|
|
reader_cfg=QQP_reader_cfg,
|
|
|
|
infer_cfg=QQP_infer_cfg,
|
|
|
|
eval_cfg=QQP_eval_cfg
|
|
|
|
)
|
|
|
|
)
|