Datasets:
Tasks:
Question Answering
Modalities:
Text
Formats:
json
Size:
1K - 10K
ArXiv:
Tags:
lost-in-the-middle
License:
Delete LITM.py
Browse files
LITM.py
DELETED
@@ -1,92 +0,0 @@
|
|
1 |
-
# Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor.
|
2 |
-
#
|
3 |
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4 |
-
# you may not use this file except in compliance with the License.
|
5 |
-
# You may obtain a copy of the License at
|
6 |
-
#
|
7 |
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8 |
-
#
|
9 |
-
# Unless required by applicable law or agreed to in writing, software
|
10 |
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11 |
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12 |
-
# See the License for the specific language governing permissions and
|
13 |
-
# limitations under the License.
|
14 |
-
import os
|
15 |
-
|
16 |
-
import datasets
|
17 |
-
import json
|
18 |
-
|
19 |
-
|
20 |
-
_DESCRIPTION = """\
|
21 |
-
"""
|
22 |
-
|
23 |
-
_HOMEPAGE = "https://github.com/bzantium/LITM"
|
24 |
-
|
25 |
-
|
26 |
-
_URL = r"https://huggingface.co/datasets/bzantium/LITM/resolve/main/data.zip"
|
27 |
-
|
28 |
-
task_list = [
|
29 |
-
"kv75",
|
30 |
-
"kv140",
|
31 |
-
"kv300",
|
32 |
-
"qa10",
|
33 |
-
"qa20",
|
34 |
-
"qa30",
|
35 |
-
]
|
36 |
-
|
37 |
-
|
38 |
-
class LITMConfig(datasets.BuilderConfig):
|
39 |
-
def __init__(self, **kwargs):
|
40 |
-
super().__init__(version=datasets.Version("1.0.0"), **kwargs)
|
41 |
-
|
42 |
-
|
43 |
-
class LITM(datasets.GeneratorBasedBuilder):
|
44 |
-
BUILDER_CONFIGS = [
|
45 |
-
LITMConfig(
|
46 |
-
name=task_name,
|
47 |
-
)
|
48 |
-
for task_name in task_list
|
49 |
-
]
|
50 |
-
|
51 |
-
def _info(self):
|
52 |
-
features = datasets.Features(
|
53 |
-
{
|
54 |
-
"context": [[datasets.Value("string")]] if self.config.name.startswith("kv") else [datasets.Value("string")],
|
55 |
-
"query": datasets.Value("string"),
|
56 |
-
"answers": [datasets.Value("string")],
|
57 |
-
"gold_index": datasets.Value("int32"),
|
58 |
-
}
|
59 |
-
)
|
60 |
-
return datasets.DatasetInfo(
|
61 |
-
description=_DESCRIPTION,
|
62 |
-
features=features,
|
63 |
-
homepage=_HOMEPAGE,
|
64 |
-
)
|
65 |
-
|
66 |
-
def _split_generators(self, dl_manager):
|
67 |
-
data_dir = dl_manager.download_and_extract(_URL)
|
68 |
-
task_name = self.config.name
|
69 |
-
return [
|
70 |
-
datasets.SplitGenerator(
|
71 |
-
name=datasets.Split.TEST,
|
72 |
-
gen_kwargs={
|
73 |
-
"filepath": os.path.join(
|
74 |
-
data_dir, "data", f"{task_name}.jsonl"
|
75 |
-
),
|
76 |
-
},
|
77 |
-
)
|
78 |
-
]
|
79 |
-
|
80 |
-
def _generate_examples(self, filepath):
|
81 |
-
with open(filepath, encoding="utf-8") as f:
|
82 |
-
for idx, line in enumerate(f):
|
83 |
-
key = f"{self.config.name}-{idx}"
|
84 |
-
item = json.loads(line)
|
85 |
-
if not isinstance(item['answers'], list):
|
86 |
-
item['answers'] = [item['answers']]
|
87 |
-
yield key, {
|
88 |
-
"context": item["context"],
|
89 |
-
"query": item["query"],
|
90 |
-
"answers": item["answers"],
|
91 |
-
"gold_index": item["gold_index"],
|
92 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|