File size: 2,834 Bytes
73cc8d2 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | # SuperLIM tasks
from __future__ import annotations
from mteb.abstasks import AbsTaskClassification
from mteb.abstasks.TaskMetadata import TaskMetadata
class DalajClassification(AbsTaskClassification):
metadata = TaskMetadata(
name="DalajClassification",
dataset={
"path": "AI-Sweden/SuperLim",
"revision": "7ebf0b4caa7b2ae39698a889de782c09e6f5ee56",
"name": "dalaj",
},
description="A Swedish dataset for linguistic acceptability. Available as a part of Superlim.",
reference="https://spraakbanken.gu.se/en/resources/superlim",
type="Classification",
category="s2s",
eval_splits=["test"],
eval_langs=["swe-Latn"],
main_score="accuracy",
date=("2017-01-01", "2020-12-31"),
form=["written"],
domains=["Non-fiction"],
task_subtypes=["Linguistic acceptability"],
license="CC-BY-4.0",
socioeconomic_status="mixed",
annotations_creators="expert-annotated",
dialect=[],
text_creation="created",
bibtex_citation="""@misc{2105.06681,
Author = {Elena Volodina and Yousuf Ali Mohammed and Julia Klezl},
Title = {DaLAJ - a dataset for linguistic acceptability judgments for Swedish: Format, baseline, sharing},
Year = {2021},
Eprint = {arXiv:2105.06681},
}""",
n_samples={"test": 444},
avg_character_length={"test": 243.8},
)
@property
def metadata_dict(self) -> dict[str, str]:
metadata_dict = super().metadata_dict
metadata_dict["n_experiments"] = 10
metadata_dict["samples_per_label"] = 16
return metadata_dict
def dataset_transform(self):
"""This dataset consist of two columns of relevance, "original_sentence" and "corrected_sentence".
We will use the original sentence as we "wrong" sentence and the corrected sentence as the "correct" sentence
"""
def __convert_sample_to_classification(sample):
text = sample["original_sentence"] + sample["corrected_sentence"]
label = [1] * len(sample["original_sentence"]) + [0] * len(
sample["corrected_sentence"]
)
return {"text": text, "label": label}
columns_to_keep = ["original_sentence", "corrected_sentence"]
for split in self.dataset:
columns_names = self.dataset[split].column_names # type: ignore
columns_to_remove = [
col for col in columns_names if col not in columns_to_keep
]
self.dataset[split] = self.dataset[split].remove_columns(columns_to_remove) # type: ignore
self.dataset = self.dataset.map(
__convert_sample_to_classification,
batched=True,
remove_columns=columns_to_keep,
)
|