Datasets:
skt
/

Modalities:
Text
Formats:
json
Languages:
Korean
ArXiv:
Libraries:
Datasets
pandas
License:
korca commited on
Commit
5b49ee1
1 Parent(s): 3d286a9

first commit data loader

Browse files
Files changed (2) hide show
  1. dataset_infos.json +224 -0
  2. kobest_v1.0.py +202 -0
dataset_infos.json ADDED
@@ -0,0 +1,224 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "boolq": {
3
+ "description": " Korean Balanced Evaluation of Significant Tasks Benchmark\n",
4
+ "citation": " TBD\n",
5
+ "homepage": "https://github.com/SKT-LSL/KoBEST_datarepo",
6
+ "license": "",
7
+ "features": {
8
+ "paragraph": {
9
+ "dtype": "string",
10
+ "id": null,
11
+ "_type": "Value"
12
+ },
13
+ "question": {
14
+ "dtype": "string",
15
+ "id": null,
16
+ "_type": "Value"
17
+ },
18
+ "label": {
19
+ "num_classes": 2,
20
+ "names": [
21
+ "False",
22
+ "True",
23
+ ],
24
+ "names_file": null,
25
+ "id": null,
26
+ "_type": "ClassLabel"
27
+ }
28
+ },
29
+ "post_processed": null,
30
+ "supervised_keys": null,
31
+ "builder_name": "kobest_v1.0",
32
+ "config_name": "boolq",
33
+ "version": {
34
+ "version_str": "1.0",
35
+ "description": "",
36
+ "major": 1,
37
+ "minor": 0,
38
+ "patch": 0
39
+ }
40
+ },
41
+ "copa": {
42
+ "description": " Korean Balanced Evaluation of Significant Tasks Benchmark\n",
43
+ "citation": " TBD\n",
44
+ "homepage": "https://github.com/SKT-LSL/KoBEST_datarepo",
45
+ "license": "",
46
+ "features": {
47
+ "premise": {
48
+ "dtype": "string",
49
+ "id": null,
50
+ "_type": "Value"
51
+ },
52
+ "question": {
53
+ "dtype": "string",
54
+ "id": null,
55
+ "_type": "Value"
56
+ },
57
+ "alternative_1": {
58
+ "dtype": "string",
59
+ "id": null,
60
+ "_type": "Value"
61
+ },
62
+ "alternative_2": {
63
+ "dtype": "string",
64
+ "id": null,
65
+ "_type": "Value"
66
+ },
67
+ "label": {
68
+ "num_classes": 2,
69
+ "names": [
70
+ "alternative_1",
71
+ "alternative_2"
72
+ ],
73
+ "names_file": null,
74
+ "id": null,
75
+ "_type": "ClassLabel"
76
+ }
77
+ },
78
+ "post_processed": null,
79
+ "supervised_keys": null,
80
+ "builder_name": "kobest_v1.0",
81
+ "config_name": "copa",
82
+ "version": {
83
+ "version_str": "1.0",
84
+ "description": "",
85
+ "major": 1,
86
+ "minor": 0,
87
+ "patch": 0
88
+ }
89
+ },
90
+ "wic": {
91
+ "description": " Korean Balanced Evaluation of Significant Tasks Benchmark\n",
92
+ "citation": " TBD\n",
93
+ "homepage": "https://github.com/SKT-LSL/KoBEST_datarepo",
94
+ "license": "",
95
+ "features": {
96
+ "word": {
97
+ "dtype": "string",
98
+ "id": null,
99
+ "_type": "Value"
100
+ },
101
+ "context_1": {
102
+ "dtype": "string",
103
+ "id": null,
104
+ "_type": "Value"
105
+ },
106
+ "context_2": {
107
+ "dtype": "string",
108
+ "id": null,
109
+ "_type": "Value"
110
+ },
111
+ "label": {
112
+ "num_classes": 2,
113
+ "names": [
114
+ "False",
115
+ "True"
116
+ ],
117
+ "names_file": null,
118
+ "id": null,
119
+ "_type": "ClassLabel"
120
+ }
121
+ },
122
+ "post_processed": null,
123
+ "supervised_keys": null,
124
+ "builder_name": "kobest_v1.0",
125
+ "config_name": "copa",
126
+ "version": {
127
+ "version_str": "1.0",
128
+ "description": "",
129
+ "major": 1,
130
+ "minor": 0,
131
+ "patch": 0
132
+ }
133
+ },
134
+ "hellaswag": {
135
+ "description": " Korean Balanced Evaluation of Significant Tasks Benchmark\n",
136
+ "citation": " TBD\n",
137
+ "homepage": "https://github.com/SKT-LSL/KoBEST_datarepo",
138
+ "license": "",
139
+ "features": {
140
+ "context": {
141
+ "dtype": "string",
142
+ "id": null,
143
+ "_type": "Value"
144
+ },
145
+ "ending_1": {
146
+ "dtype": "string",
147
+ "id": null,
148
+ "_type": "Value"
149
+ },
150
+ "ending_2": {
151
+ "dtype": "string",
152
+ "id": null,
153
+ "_type": "Value"
154
+ },
155
+ "ending_3": {
156
+ "dtype": "string",
157
+ "id": null,
158
+ "_type": "Value"
159
+ },
160
+ "ending_4": {
161
+ "dtype": "string",
162
+ "id": null,
163
+ "_type": "Value"
164
+ },
165
+ "label": {
166
+ "num_classes": 4,
167
+ "names": [
168
+ "ending_1",
169
+ "ending_1",
170
+ "ending_3",
171
+ "ending_4"
172
+ ],
173
+ "names_file": null,
174
+ "id": null,
175
+ "_type": "ClassLabel"
176
+ }
177
+ },
178
+ "post_processed": null,
179
+ "supervised_keys": null,
180
+ "builder_name": "kobest_v1.0",
181
+ "config_name": "copa",
182
+ "version": {
183
+ "version_str": "1.0",
184
+ "description": "",
185
+ "major": 1,
186
+ "minor": 0,
187
+ "patch": 0
188
+ }
189
+ },
190
+ "sentineg": {
191
+ "description": " Korean Balanced Evaluation of Significant Tasks Benchmark\n",
192
+ "citation": " TBD\n",
193
+ "homepage": "https://github.com/SKT-LSL/KoBEST_datarepo",
194
+ "license": "",
195
+ "features": {
196
+ "sentence": {
197
+ "dtype": "string",
198
+ "id": null,
199
+ "_type": "Value"
200
+ },
201
+ "label": {
202
+ "num_classes": 2,
203
+ "names": [
204
+ "negative",
205
+ "positive"
206
+ ],
207
+ "names_file": null,
208
+ "id": null,
209
+ "_type": "ClassLabel"
210
+ }
211
+ },
212
+ "post_processed": null,
213
+ "supervised_keys": null,
214
+ "builder_name": "kobest_v1.0",
215
+ "config_name": "copa",
216
+ "version": {
217
+ "version_str": "1.0",
218
+ "description": "",
219
+ "major": 1,
220
+ "minor": 0,
221
+ "patch": 0
222
+ }
223
+ }
224
+ }
kobest_v1.0.py ADDED
@@ -0,0 +1,202 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Korean Balanced Evaluation of Significant Tasks"""
2
+
3
+
4
+ import csv
5
+
6
+ import pandas as pd
7
+
8
+ import datasets
9
+
10
+
11
+ _CITATAION = """\
12
+ TBD
13
+ """
14
+
15
+ _DESCRIPTION = """\
16
+ The dataset contains data for KoBEST dataset
17
+ """
18
+
19
+ _URL = "https://github.com/SKT-LSL/KoBEST_datarepo"
20
+
21
+ _DATA_URLS = {
22
+ "boolq": {
23
+ "train": _URL + "/v1.0/BoolQ/train.tsv",
24
+ "dev": _URL + "/v1.0/BoolQ/dev.tsv",
25
+ "test": _URL + "/v1.0/BoolQ/test.tsv",
26
+ },
27
+ "copa": {
28
+ "train": _URL + "/v1.0/COPA/train.tsv",
29
+ "dev": _URL + "/v1.0/COPA/dev.tsv",
30
+ "test": _URL + "/v1.0/COPA/test.tsv",
31
+ },
32
+ "sentineg": {
33
+ "train": _URL + "/v1.0/SentiNeg/train.tsv",
34
+ "dev": _URL + "/v1.0/SentiNeg/dev.tsv",
35
+ "test": _URL + "/v1.0/SentiNeg/test.tsv",
36
+ },
37
+ "hellaswag": {
38
+ "train": _URL + "/v1.0/HellaSwag/train.tsv",
39
+ "dev": _URL + "/v1.0/HellaSwag/dev.tsv",
40
+ "test": _URL + "/v1.0/HellaSwag/test.tsv",
41
+ },
42
+ "wic": {
43
+ "train": _URL + "/v1.0/WiC/train.tsv",
44
+ "dev": _URL + "/v1.0/WiC/dev.tsv",
45
+ "test": _URL + "/v1.0/WiC/test.tsv",
46
+ },
47
+ }
48
+
49
+
50
+ class KoBESTConfig(datasets.BuilderConfig):
51
+ """Config for building KoBEST"""
52
+
53
+ def __init__(self, description, data_url, citation, url, **kwargs):
54
+ """
55
+ Args:
56
+ description: `string`, brief description of the dataset
57
+ data_url: `dictionary`, dict with url for each split of data.
58
+ citation: `string`, citation for the dataset.
59
+ url: `string`, url for information about the dataset.
60
+ **kwrags: keyword arguments frowarded to super
61
+ """
62
+ super(KoBESTConfig, self).__init__(version=datasets.Version("1.0", ""), **kwargs)
63
+ self.description = description
64
+ self.data_url = data_url
65
+ self.citation = citation
66
+ self.url = url
67
+
68
+
69
+ class KoBEST(datasets.GeneratorBasedBuilder):
70
+ BUILDER_CONFIGS = [
71
+ KoBESTConfig(name=name, description=_DESCRIPTION, data_url=_DATA_URLS[name], citation=_CITATAION, url=_URL)
72
+ for name in ["boolq", "copa", 'sentineg', 'hellaswag', 'wic']
73
+ ]
74
+ BUILDER_CONFIG_CLASS = KoBESTConfig
75
+
76
+ def _info(self):
77
+ features = {}
78
+ if self.config.name == "boolq":
79
+ labels = ["True", "False"]
80
+ features["paragraph"] = datasets.Value("string")
81
+ features["question"] = datasets.Value("string")
82
+ features["label"] = datasets.features.ClassLabel(names=labels)
83
+
84
+ if self.config.name == "copa":
85
+ labels = ["alternative_1", "alternative_2"]
86
+ features["premise"] = datasets.Value("string")
87
+ features["question"] = datasets.Value("string")
88
+ features["alternative_1"] = datasets.Value("string")
89
+ features["alternative_2"] = datasets.Value("string")
90
+ features["label"] = datasets.features.ClassLabel(names=labels)
91
+
92
+ if self.config.name == "wic":
93
+ labels = ["True", "False"]
94
+ features["word"] = datasets.Value("string")
95
+ features["context_1"] = datasets.Value("string")
96
+ features["context_2"] = datasets.Value("string")
97
+ features["label"] = datasets.features.ClassLabel(names=labels)
98
+
99
+ if self.config.name == "hellaswag":
100
+ labels = ["ending_1", "ending_2", "ending_3", "ending_4"]
101
+
102
+ features["context"] = datasets.Value("string")
103
+ features["ending_1"] = datasets.Value("string")
104
+ features["ending_2"] = datasets.Value("string")
105
+ features["ending_3"] = datasets.Value("string")
106
+ features["ending_4"] = datasets.Value("string")
107
+ features["label"] = datasets.features.ClassLabel(names=labels)
108
+
109
+ if self.config.name == "sentineg":
110
+ labels = ["negative", "positive"]
111
+ features["sentence"] = datasets.Value("string")
112
+ features["label"] = datasets.features.ClassLabel(names=labels)
113
+
114
+ return datasets.DatasetInfo(
115
+ description=_DESCRIPTION, features=datasets.Features(features), homepage=_URL, citation=_CITATAION
116
+ )
117
+
118
+ def _split_generators(self, dl_manager):
119
+
120
+ train = dl_manager.download_and_extract(self.config.data_url["train"])
121
+ dev = dl_manager.download_and_extract(self.config.data_url["dev"])
122
+ test = dl_manager.download_and_extract(self.config.data_url["test"])
123
+
124
+ return [
125
+ datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": train, "split": "train"}),
126
+ datasets.SplitGenerator(name=datasets.Split.VALIDATION, gen_kwargs={"filepath": dev, "split": "dev"}),
127
+ datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"filepath": test, "split": "test"}),
128
+ ]
129
+
130
+ # if self.config.name == "boolq":
131
+ # train = dl_manager.download_and_extract(self.config.data_url["train"])
132
+ # dev = dl_manager.download_and_extract(self.config.data_url["dev"])
133
+ # test = dl_manager.download_and_extract(self.config.data_url["test"])
134
+ #
135
+ # return [
136
+ # datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": train, "split": "train"}),
137
+ # datasets.SplitGenerator(name=datasets.Split.VALIDATION, gen_kwargs={"filepath": dev, "split": "dev"}),
138
+ # datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"filepath": test, "split": "test"}),
139
+ # ]
140
+ #
141
+
142
+ def _generate_examples(self, filepath, split):
143
+ if self.config.name == "boolq":
144
+ df = pd.read_csv(filepath, sep="\t")
145
+ df = df.dropna()
146
+
147
+ for id_, row in df.iterrows():
148
+ yield id_, {
149
+ "paragraph": str(row["Text"]),
150
+ "question": str(row["Question"]),
151
+ "label": str(int(row["Answer"])),
152
+ }
153
+
154
+ if self.config.name == "copa":
155
+ df = pd.read_csv(filepath, sep="\t")
156
+ df = df.dropna()
157
+
158
+ for id_, row in df.iterrows():
159
+ yield id_, {
160
+ "premise": str(row["sentence"]),
161
+ "question": str(row["question"]),
162
+ "alternative_1": str(int(row["1"])),
163
+ "alternative_2": str(int(row["2"])),
164
+ "label": str(row["Answer"]-1),
165
+ }
166
+
167
+ if self.config.name == "wic":
168
+ df = pd.read_csv(filepath, sep="\t")
169
+ df = df.dropna()
170
+
171
+ for id_, row in df.iterrows():
172
+ yield id_, {
173
+ "word": str(row["Target"]),
174
+ "context_1": str(row["SENTENCE1"]),
175
+ "context_2": str(int(row["SENTENCE2"])),
176
+ "label": str(int(row["Answer"])),
177
+ }
178
+
179
+ if self.config.name == "hellaswag":
180
+ df = pd.read_csv(filepath, sep="\t")
181
+ df = df.dropna()
182
+
183
+ for id_, row in df.iterrows():
184
+ yield id_, {
185
+ "context": str(row["context"]),
186
+ "ending_1": str(row["choice1"]),
187
+ "ending_2": str(int(row["choice2"])),
188
+ "ending_3": str(int(row["choice3"])),
189
+ "ending_4": str(int(row["choice4"])),
190
+ "label": str(row["label"]),
191
+ }
192
+
193
+ if self.config.name == "sentineg":
194
+ df = pd.read_csv(filepath, sep="\t")
195
+ df = df.dropna()
196
+
197
+ for id_, row in df.iterrows():
198
+ yield id_, {
199
+ "sentence": str(row["Text"]),
200
+ "label": str(int(row["Label"])),
201
+ }
202
+