mirror of
https://github.com/open-compass/opencompass.git
synced 2025-05-30 16:03:24 +08:00
[SIG] add GLUE_CoLA dataset (#406)
* [Dataset] add GLUE_CoLA dataset * [update] use HFDataset to load glue/cola dataset * update --------- Co-authored-by: gaotongxiao <gaotongxiao@gmail.com>
This commit is contained in:
parent
012546666b
commit
d8354fe5d8
4
configs/datasets/GLUE_CoLA/GULE_CoLA_ppl.py
Normal file
4
configs/datasets/GLUE_CoLA/GULE_CoLA_ppl.py
Normal file
@ -0,0 +1,4 @@
|
||||
from mmengine.config import read_base
|
||||
|
||||
with read_base():
|
||||
from .GULE_CoLA_ppl_77d0df import CoLA_datasets # noqa: F401, F403
|
50
configs/datasets/GLUE_CoLA/GULE_CoLA_ppl_77d0df.py
Normal file
50
configs/datasets/GLUE_CoLA/GULE_CoLA_ppl_77d0df.py
Normal file
@ -0,0 +1,50 @@
|
||||
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
|
||||
|
||||
|
||||
_hint = "The following are text classification questions. \n" \
|
||||
"Please determine whether the following sentence is linguistically acceptable: " \
|
||||
"0 means unacceptable, 1 means acceptable.\n"
|
||||
|
||||
CoLA_infer_cfg = dict(
|
||||
ice_template=dict(
|
||||
type=PromptTemplate,
|
||||
template="Sentence: {sentence}\nResult: {label}",
|
||||
),
|
||||
prompt_template=dict(
|
||||
type=PromptTemplate,
|
||||
template={
|
||||
answer:
|
||||
f"{_hint}</E>Sentence: {{sentence}}\nResult: {answer}"
|
||||
for answer in [0, 1]
|
||||
},
|
||||
ice_token='</E>',
|
||||
),
|
||||
retriever=dict(type=FixKRetriever),
|
||||
inferencer=dict(type=PPLInferencer, fix_id_list=[17, 18, 19, 20, 21]))
|
||||
|
||||
CoLA_eval_cfg = dict(evaluator=dict(type=AccEvaluator), )
|
||||
|
||||
CoLA_datasets = []
|
||||
for _split in ["validation"]:
|
||||
|
||||
CoLA_reader_cfg = dict(
|
||||
input_columns=['sentence'],
|
||||
output_column='label',
|
||||
test_split=_split
|
||||
)
|
||||
|
||||
CoLA_datasets.append(
|
||||
dict(
|
||||
abbr=f'CoLA-{_split}',
|
||||
type=HFDataset,
|
||||
path='glue',
|
||||
name='cola',
|
||||
reader_cfg=CoLA_reader_cfg,
|
||||
infer_cfg=CoLA_infer_cfg,
|
||||
eval_cfg=CoLA_eval_cfg
|
||||
)
|
||||
)
|
Loading…
Reference in New Issue
Block a user