|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"""TODO: Add a description here.""" |
|
|
|
|
|
import datasets |
|
import pandas as pd |
|
|
|
|
|
|
|
_CITATION = """\ |
|
@article{ettinger2020bert, |
|
title={What BERT is not: Lessons from a new suite of psycholinguistic diagnostics for language models}, |
|
author={Ettinger, Allyson}, |
|
journal={Transactions of the Association for Computational Linguistics}, |
|
volume={8}, |
|
pages={34--48}, |
|
year={2020}, |
|
publisher={MIT Press} |
|
} |
|
""" |
|
|
|
|
|
_DESCRIPTION = """\ |
|
Psycholinguistic dataset from 'What BERT is not: Lessons from a new suite of psycholinguistic diagnostics for language models' |
|
by Allyson Ettinger |
|
""" |
|
|
|
_HOMEPAGE = "https://github.com/aetting/lm-diagnostics" |
|
|
|
_LICENSE = """MIT License |
|
|
|
Copyright (c) 2020 Allyson Ettinger |
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy |
|
of this software and associated documentation files (the "Software"), to deal |
|
in the Software without restriction, including without limitation the rights |
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
copies of the Software, and to permit persons to whom the Software is |
|
furnished to do so, subject to the following conditions: |
|
|
|
The above copyright notice and this permission notice shall be included in all |
|
copies or substantial portions of the Software. |
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
|
SOFTWARE. |
|
""" |
|
|
|
|
|
|
|
_URL = "https://huggingface.co/datasets/KevinZ/psycholinguistic_eval/resolve/main/" |
|
_URLS = { |
|
"CPRAG": _URL + "CPRAG/test.csv", |
|
"ROLE": _URL + "ROLE/test.csv", |
|
"NEG-NAT": _URL + "NEG-NAT/test.csv", |
|
"NEG-SIMP": _URL + "NEG-SIMP/test.csv", |
|
} |
|
|
|
|
|
class PsycholinguisticEvalDataset(datasets.GeneratorBasedBuilder): |
|
"""TODO: Short description of my dataset.""" |
|
|
|
VERSION = datasets.Version("1.0.0") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BUILDER_CONFIGS = [ |
|
datasets.BuilderConfig(name="CPRAG", version=VERSION, description="34 questions evaluating commonsense knowledge"), |
|
datasets.BuilderConfig(name="ROLE", version=VERSION, description="88 questions evaluating event knowledge and semantic roles"), |
|
datasets.BuilderConfig(name="NEG-NAT", version=VERSION, description="[NEG-NAT description]"), |
|
datasets.BuilderConfig(name="NEG-SIMP", version=VERSION, description="[NEG-SIMP description]"), |
|
] |
|
|
|
def _info(self): |
|
|
|
if self.config.name == "CPRAG": |
|
features = datasets.Features( |
|
{ |
|
"context_s1": datasets.Value("string"), |
|
"context_s2": datasets.Value("string"), |
|
"expected": datasets.Value("string"), |
|
"within_category": datasets.Value("string"), |
|
"between_category": datasets.Value("string"), |
|
} |
|
) |
|
elif self.config.name == "ROLE": |
|
features = datasets.Features( |
|
{ |
|
"context": datasets.Value("string"), |
|
"expected": datasets.Value("string"), |
|
} |
|
) |
|
elif self.config.name == "NEG-NAT": |
|
features = datasets.Features( |
|
{ |
|
"context_aff": datasets.Value("string"), |
|
"context_neg": datasets.Value("string"), |
|
"target_aff": datasets.Value("string"), |
|
"target_neg": datasets.Value("string"), |
|
} |
|
) |
|
elif self.config.name == "NEG-SIMP": |
|
features = datasets.Features( |
|
{ |
|
"context_aff": datasets.Value("string"), |
|
"context_neg": datasets.Value("string"), |
|
"target_aff": datasets.Value("string"), |
|
"target_neg": datasets.Value("string"), |
|
} |
|
) |
|
else: |
|
raise NotImplementedError |
|
|
|
return datasets.DatasetInfo( |
|
|
|
description=_DESCRIPTION, |
|
|
|
features=features, |
|
|
|
|
|
|
|
|
|
homepage=_HOMEPAGE, |
|
|
|
license=_LICENSE, |
|
|
|
citation=_CITATION, |
|
) |
|
|
|
def _split_generators(self, dl_manager): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
downloaded_files = dl_manager.download_and_extract(_URLS) |
|
|
|
return [ |
|
datasets.SplitGenerator( |
|
name=datasets.Split.TEST, |
|
|
|
gen_kwargs={ |
|
"filepath": downloaded_files[self.config.name], |
|
"split": "test" |
|
}, |
|
), |
|
] |
|
|
|
|
|
def _generate_examples(self, filepath, split): |
|
|
|
df = pd.read_csv(filepath) |
|
for index, row in df.iterrows(): |
|
if self.config.name == "CPRAG": |
|
|
|
yield index, { |
|
"context_s1": row["context_s1"], |
|
"context_s2": row["context_s2"], |
|
"expected": row["expected"], |
|
"within_category": row["within_category"], |
|
"between_category": row["between_category"], |
|
} |
|
elif self.config.name == "ROLE": |
|
yield index, { |
|
"context": row["context"], |
|
"expected": row["expected"], |
|
} |
|
elif self.config.name == "NEG-NAT": |
|
yield index, { |
|
"context_aff": row["context_aff"], |
|
"context_neg": row["context_neg"], |
|
"target_aff": row["target_aff"], |
|
"target_neg": row["target_neg"], |
|
} |
|
elif self.config.name == "NEG-SIMP": |
|
yield index, { |
|
"context_aff": row["context_aff"], |
|
"context_neg": row["context_neg"], |
|
"target_aff": row["target_aff"], |
|
"target_neg": row["target_neg"], |
|
} |
|
else: |
|
raise NotImplementedError |
|
|