Datasets:
Tasks:
Text Retrieval
ArXiv:
""" | |
""" # TODO | |
try: | |
import ir_datasets | |
except ImportError as e: | |
raise ImportError('ir-datasets package missing; `pip install ir-datasets`') | |
import datasets | |
IRDS_ID = 'beir/fever/dev' | |
IRDS_ENTITY_TYPES = {'queries': {'query_id': 'string', 'text': 'string'}, 'qrels': {'query_id': 'string', 'doc_id': 'string', 'relevance': 'int64', 'iteration': 'string'}} | |
_CITATION = '@inproceedings{Thorne2018Fever,\n title = "{FEVER}: a Large-scale Dataset for Fact Extraction and {VER}ification",\n author = "Thorne, James and\n Vlachos, Andreas and\n Christodoulopoulos, Christos and\n Mittal, Arpit",\n booktitle = "Proceedings of the 2018 Conference of the North {A}merican Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 1 (Long Papers)",\n month = jun,\n year = "2018",\n address = "New Orleans, Louisiana",\n publisher = "Association for Computational Linguistics",\n url = "https://www.aclweb.org/anthology/N18-1074",\n doi = "10.18653/v1/N18-1074",\n pages = "809--819"\n}\n@article{Thakur2021Beir,\n title = "BEIR: A Heterogenous Benchmark for Zero-shot Evaluation of Information Retrieval Models",\n author = "Thakur, Nandan and Reimers, Nils and Rücklé, Andreas and Srivastava, Abhishek and Gurevych, Iryna", \n journal= "arXiv preprint arXiv:2104.08663",\n month = "4",\n year = "2021",\n url = "https://arxiv.org/abs/2104.08663",\n}' | |
_DESCRIPTION = "" # TODO | |
class beir_fever_dev(datasets.GeneratorBasedBuilder): | |
BUILDER_CONFIGS = [datasets.BuilderConfig(name=e) for e in IRDS_ENTITY_TYPES] | |
def _info(self): | |
return datasets.DatasetInfo( | |
description=_DESCRIPTION, | |
features=datasets.Features({k: datasets.Value(v) for k, v in IRDS_ENTITY_TYPES[self.config.name].items()}), | |
homepage=f"https://ir-datasets.com/beir#beir/fever/dev", | |
citation=_CITATION, | |
) | |
def _split_generators(self, dl_manager): | |
return [datasets.SplitGenerator(name=self.config.name)] | |
def _generate_examples(self): | |
dataset = ir_datasets.load(IRDS_ID) | |
for i, item in enumerate(getattr(dataset, self.config.name)): | |
key = i | |
if self.config.name == 'docs': | |
key = item.doc_id | |
elif self.config.name == 'queries': | |
key = item.query_id | |
yield key, item._asdict() | |
def as_dataset(self, split=None, *args, **kwargs): | |
split = self.config.name # always return split corresponding with this config to avid returning a redundant DatasetDict layer | |
return super().as_dataset(split, *args, **kwargs) | |