Upload 3 files
Browse files- ko-lima.py +114 -0
- lima_deepl_ko.zip +3 -0
- lima_deepl_ko_vicuna.zip +3 -0
ko-lima.py
ADDED
@@ -0,0 +1,114 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
|
15 |
+
import csv
|
16 |
+
import json
|
17 |
+
import os
|
18 |
+
import datasets
|
19 |
+
|
20 |
+
|
21 |
+
_CITATION = """\
|
22 |
+
@InProceedings{huggingface:dataset,
|
23 |
+
title = {Ko-LIMA: Korean LIMA Dataset},
|
24 |
+
author={Hahn, Taeseung},
|
25 |
+
year={2023}
|
26 |
+
}
|
27 |
+
"""
|
28 |
+
_DESCRIPTION = """\
|
29 |
+
A high-quality korean dataset for efficient instruction tuning.
|
30 |
+
"""
|
31 |
+
_HOMEPAGE = ""
|
32 |
+
_LICENSE = ""
|
33 |
+
_URLS = {
|
34 |
+
"plain": "lima_deepl_ko.zip",
|
35 |
+
"vicuna": "lima_deepl_ko_vicuna.zip",
|
36 |
+
}
|
37 |
+
|
38 |
+
|
39 |
+
class KoLima(datasets.GeneratorBasedBuilder):
|
40 |
+
"""A high-quality korean dataset for efficient instruction tuning."""
|
41 |
+
|
42 |
+
VERSION = datasets.Version("1.0.0")
|
43 |
+
|
44 |
+
BUILDER_CONFIGS = [
|
45 |
+
datasets.BuilderConfig(name="plain", version=VERSION, description="Korean LIMA dataset in a plain format"),
|
46 |
+
datasets.BuilderConfig(name="vicuna", version=VERSION, description="Korean LIMA dataset in Vicuna format"),
|
47 |
+
]
|
48 |
+
|
49 |
+
DEFAULT_CONFIG_NAME = "plain"
|
50 |
+
|
51 |
+
def _info(self):
|
52 |
+
if self.config.name == "vicuna":
|
53 |
+
features = datasets.Features(
|
54 |
+
{
|
55 |
+
'id': datasets.Value(dtype='string', id=None),
|
56 |
+
'conversations': [
|
57 |
+
{
|
58 |
+
'from': datasets.Value(dtype='string', id=None),
|
59 |
+
'value': datasets.Value(dtype='string', id=None)
|
60 |
+
}
|
61 |
+
]
|
62 |
+
}
|
63 |
+
)
|
64 |
+
else:
|
65 |
+
features = datasets.Features(
|
66 |
+
{
|
67 |
+
'conversations': datasets.Sequence(feature=datasets.Value(dtype='string', id=None), length=-1, id=None),
|
68 |
+
'source': datasets.Value(dtype='string', id=None)
|
69 |
+
}
|
70 |
+
)
|
71 |
+
return datasets.DatasetInfo(
|
72 |
+
description=_DESCRIPTION,
|
73 |
+
features=features,
|
74 |
+
homepage=_HOMEPAGE,
|
75 |
+
license=_LICENSE,
|
76 |
+
citation=_CITATION,
|
77 |
+
)
|
78 |
+
|
79 |
+
def _split_generators(self, dl_manager):
|
80 |
+
urls = _URLS[self.config.name]
|
81 |
+
data_dir = dl_manager.download_and_extract(urls)
|
82 |
+
return [
|
83 |
+
datasets.SplitGenerator(
|
84 |
+
name=datasets.Split.TRAIN,
|
85 |
+
gen_kwargs={
|
86 |
+
"filepath": os.path.join(data_dir, "train.jsonl"),
|
87 |
+
"split": "train",
|
88 |
+
},
|
89 |
+
),
|
90 |
+
# datasets.SplitGenerator(
|
91 |
+
# name=datasets.Split.VALIDATION,
|
92 |
+
# gen_kwargs={
|
93 |
+
# "filepath": os.path.join(data_dir, "dev.jsonl"),
|
94 |
+
# "split": "dev",
|
95 |
+
# },
|
96 |
+
# ),
|
97 |
+
datasets.SplitGenerator(
|
98 |
+
name=datasets.Split.TEST,
|
99 |
+
# These kwargs will be passed to _generate_examples
|
100 |
+
gen_kwargs={
|
101 |
+
"filepath": os.path.join(data_dir, "test.jsonl"),
|
102 |
+
"split": "test"
|
103 |
+
},
|
104 |
+
),
|
105 |
+
]
|
106 |
+
|
107 |
+
def _generate_examples(self, filepath, split):
|
108 |
+
with open(filepath, encoding="utf-8") as f:
|
109 |
+
for key, row in enumerate(f):
|
110 |
+
instance = json.loads(row)
|
111 |
+
if self.config.name == "vicuna":
|
112 |
+
yield key, instance
|
113 |
+
else:
|
114 |
+
yield key, instance
|
lima_deepl_ko.zip
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:7a2c7fb539fc66d0387e5fa9afc88ba705d8a0cb0bc18b02a4df45d2dfaff46d
|
3 |
+
size 1154251
|
lima_deepl_ko_vicuna.zip
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:799dd5ae4d5283f4f1558d4ba22923513ba47af188ace836855c0b2244ae2c1a
|
3 |
+
size 1162689
|