Skip to content

Commit

Permalink
✨feat:添加新的任务
Browse files Browse the repository at this point in the history
  • Loading branch information
wangyuxin committed Jun 16, 2023
1 parent 925e039 commit c86858c
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
28 changes: 27 additions & 1 deletion mteb-zh/mteb_zh/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from collections import defaultdict
from typing import Iterable, TypeVar, cast

from mteb.abstasks import AbsTaskClassification, AbsTaskReranking, AbsTaskRetrieval
from mteb.abstasks import AbsTaskClassification, AbsTaskReranking, AbsTaskRetrieval, AbsTaskPairClassification
from tqdm import tqdm

from datasets import Dataset, DatasetDict, load_dataset
Expand All @@ -19,9 +19,35 @@ class TaskType(str, Enum):
Classification = 'Classification'
Reranking = 'Reranking'
Retrieval = 'Retrieval'
PairClassification = 'PairClassification'
All = 'All'


class MedQQPairs(AbsTaskPairClassification):
@property
def description(self):
return {
"name": "MedQQPairs",
"hf_hub_name": "vegaviazhang/Med_QQpairs",
"category": "s2s",
"type": "PairClassification",
"eval_splits": ["train"],
"eval_langs": ["zh"],
"main_score": "ap"
}

def load_data(self, **kwargs):
dataset = load_dataset('vegaviazhang/Med_QQpairs')['train'] # type: ignore
record = {'sent1': [], 'sent2': [], 'labels': []}
for item in dataset:
item = cast(dict, item)
record['sent1'].append(item['question1'])
record['sent2'].append(item['question2'])
record['labels'].append(item['label'])
self.dataset = DatasetDict(train=Dataset.from_list([record]))
self.data_loaded = True


class TNews(AbsTaskClassification):
@property
def description(self):
Expand Down
2 changes: 2 additions & 0 deletions mteb-zh/run_mteb_zh.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
TNews,
TYQSentiment,
T2RReranking,
MedQQPairs,
)


Expand All @@ -27,6 +28,7 @@
IFlyTek(),
T2RReranking(2),
T2RRetrieval(10000),
MedQQPairs(),
]


Expand Down

0 comments on commit c86858c

Please sign in to comment.