File size: 2,513 Bytes
010fedd |
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 |
import os
import datasets
from datasets import DownloadManager, DatasetInfo, Features, Value, Split, SplitGenerator
_CITATION = """"@misc{birco,\n title={{BIRCO: A Benchmark of Information Retrieval Tasks with Complex Objectives}},\n author={{Xiaoyue Wang et al.}},\n year={2024},\n url={https://arxiv.org/abs/2402.14151},\n}""""
_DESCRIPTION = """"BIRCO benchmark containing corpus, queries, and relevance judgments""""
_HOMEPAGE = "https://github.com/BIRCO-benchmark/BIRCO"
_LICENSE = "CC-BY-4.0"
class BIRCO(datasets.GeneratorBasedBuilder):
BUILDER_CONFIGS = [
datasets.BuilderConfig(
name="corpus",
version=datasets.Version("1.0.0"),
description="Document corpus",
),
datasets.BuilderConfig(
name="queries",
version=datasets.Version("1.0.0"),
description="Search queries",
),
datasets.BuilderConfig(
name="default",
version=datasets.Version("1.0.0"),
description="Relevance judgments",
),
]
def _info(self):
if self.config.name == "corpus":
features = Features({
"_id": Value("string"),
"text": Value("string"),
"title": Value("string")
})
elif self.config.name == "queries":
features = Features({
"_id": Value("string"),
"text": Value("string")
})
elif self.config.name == "default":
features = Features({
"query-id": Value("string"),
"corpus-id": Value("string"),
"score": Value("float64")
})
return DatasetInfo(
description=_DESCRIPTION,
features=features,
citation=_CITATION,
homepage=_HOMEPAGE,
license=_LICENSE
)
def _split_generators(self, dl_manager):
return [
SplitGenerator(
name=Split.TEST,
gen_kwargs={
"files": dl_manager.download_and_extract({
"data": f"data/{self.config.name}/test-*.parquet"
}),
"split": "test"
}
)
]
def _generate_examples(self, files, split):
dataset = datasets.load_dataset("parquet", data_files=files["data"], split=split)
for idx, example in enumerate(dataset):
yield idx, example
|