Datasets:

Languages:
Japanese
Size Categories:
1M<n<10M
Tags:
License:
singletongue commited on
Commit
127f135
1 Parent(s): 09bf719

Add a dataset loading script

Browse files
Files changed (2) hide show
  1. README.md +38 -0
  2. aio-passages.py +77 -0
README.md ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - ja
4
+ size_categories:
5
+ - 1M<n<10M
6
+ license:
7
+ - cc-by-sa-3.0
8
+ - gfdl
9
+ dataset_info:
10
+ features:
11
+ - name: id
12
+ dtype: int32
13
+ - name: pageid
14
+ dtype: int32
15
+ - name: revid
16
+ dtype: int32
17
+ - name: text
18
+ dtype: string
19
+ - name: section
20
+ dtype: string
21
+ - name: title
22
+ dtype: string
23
+ splits:
24
+ - name: train
25
+ num_bytes: 3054493919
26
+ num_examples: 4288198
27
+ download_size: 1110830651
28
+ dataset_size: 3054493919
29
+ ---
30
+
31
+ # Dataset Card for llm-book/aio-passages
32
+
33
+ 書籍『大規模言語モデル入門』で使用する、「AI王」コンペティションのパッセージデータセットです。
34
+ GitHub リポジトリ [cl-tohoku/quiz-datasets](https://github.com/cl-tohoku/quiz-datasets) で公開されているデータセットを利用しています。
35
+
36
+ ## Licence
37
+
38
+ 本データセットで利用している Wikipedia のコンテンツは、[クリエイティブ・コモンズ表示・継承ライセンス 3.0 (CC BY-SA 3.0)](https://creativecommons.org/licenses/by-sa/3.0/deed.ja) および [GNU 自由文書ライセンス (GFDL)](https://www.gnu.org/licenses/fdl.html) の下に配布されているものです。
aio-passages.py ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2020 The HuggingFace Datasets Authors.
2
+ # Copyright 2023 Masatoshi Suzuki (@singletongue).
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ import io
16
+ from typing import Iterator, List, Tuple
17
+
18
+ import datasets
19
+ import pyarrow as pa
20
+
21
+
22
+ _DESCRIPTION = (
23
+ "書籍『大規模言語モデル入門』で使用する、「AI王」コンペティションのパッセージデータセットです。"
24
+ "GitHub リポジトリ cl-tohoku/quiz-datasets で公開されているデータセットを利用しています。"
25
+ )
26
+ _HOMEPAGE = "https://github.com/cl-tohoku/quiz-datasets"
27
+ _LICENSE = (
28
+ "本データセットで使用している Wikipedia のコンテンツは、クリエイティブ・コモンズ表示・継承ライセンス 3.0 (CC BY-SA 3.0) "
29
+ "および GNU 自由文書ライセンス (GFDL) の下に配布されているものです。"
30
+ )
31
+
32
+ _URL_BASE = "https://github.com/cl-tohoku/quiz-datasets/releases/download"
33
+ _URL = f"{_URL_BASE}/v1.0.1/passages.jawiki-20220404-c400-large.jsonl.gz"
34
+
35
+
36
+ class AioPassages(datasets.ArrowBasedBuilder):
37
+ VERSION = datasets.Version("1.0.0")
38
+
39
+ def _info(self) -> datasets.DatasetInfo:
40
+ features = datasets.Features({
41
+ "id": datasets.Value("int32"),
42
+ "pageid": datasets.Value("int32"),
43
+ "revid": datasets.Value("int32"),
44
+ "text": datasets.Value("string"),
45
+ "section": datasets.Value("string"),
46
+ "title": datasets.Value("string"),
47
+ })
48
+ return datasets.DatasetInfo(
49
+ description=_DESCRIPTION,
50
+ homepage=_HOMEPAGE,
51
+ license=_LICENSE,
52
+ features=features,
53
+ )
54
+
55
+ def _split_generators(self, dl_manager: datasets.DownloadManager) -> List[datasets.SplitGenerator]:
56
+ filepath = dl_manager.download_and_extract(_URL)
57
+
58
+ split_generators = [datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": filepath})]
59
+ return split_generators
60
+
61
+ def _generate_tables(self, filepath: str, chunksize: int = 10 << 20) -> Iterator[Tuple[int, pa.Table]]:
62
+ # cf. https://github.com/huggingface/datasets/blob/2.12.0/src/datasets/packaged_modules/json/json.py
63
+ with open(filepath, "rb") as f:
64
+ batch_idx = 0
65
+ block_size = max(chunksize // 32, 16 << 10)
66
+ while True:
67
+ batch = f.read(chunksize)
68
+ if not batch:
69
+ break
70
+
71
+ batch += f.readline()
72
+ pa_table = pa.json.read_json(
73
+ io.BytesIO(batch), read_options=pa.json.ReadOptions(block_size=block_size)
74
+ )
75
+
76
+ yield batch_idx, pa_table
77
+ batch_idx += 1