Datasets:

Languages:
Japanese
Size Categories:
1M<n<10M
Tags:
License:
singletongue commited on
Commit
5932d8c
1 Parent(s): 5a04654

Add a dataset loading script

Browse files
Files changed (2) hide show
  1. README.md +42 -0
  2. jawiki-paragraphs.py +76 -0
README.md ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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: string
13
+ - name: pageid
14
+ dtype: int64
15
+ - name: revid
16
+ dtype: int64
17
+ - name: paragraph_index
18
+ dtype: int64
19
+ - name: title
20
+ dtype: string
21
+ - name: section
22
+ dtype: string
23
+ - name: text
24
+ dtype: string
25
+ - name: html_tag
26
+ dtype: string
27
+ splits:
28
+ - name: train
29
+ num_bytes: 4417130987
30
+ num_examples: 9668476
31
+ download_size: 1489512230
32
+ dataset_size: 4417130987
33
+ ---
34
+
35
+ # Dataset Card for llm-book/jawiki-paragraphs
36
+
37
+ 書籍『大規模言語モデル入門』で使用する Wikipedia 段落のデータセットです。
38
+ GitHub リポジトリ [singletongue/wikipedia-utils](https://github.com/singletongue/wikipedia-utils) で公開されているデータセットを利用しています。
39
+
40
+ ## Licence
41
+
42
+ 本データセットで使用している 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) の下に配布されているものです。
jawiki-paragraphs.py ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ "書籍『大規模言語モデル入門』で使用する Wikipedia 段落のデータセットです。"
24
+ "GitHub リポジトリ singletongue/wikipedia-utils で公開されているデータセットを利用しています。"
25
+ )
26
+ _HOMEPAGE = "https://github.com/singletongue/wikipedia-utils"
27
+ _LICENSE = (
28
+ "本データセットで使用している Wikipedia のコンテンツは、クリエイティブ・コモンズ表示・継承ライセンス 3.0 (CC BY-SA 3.0) "
29
+ "および GNU 自由文書ライセンス (GFDL) の下に配布されているものです。"
30
+ )
31
+
32
+ _URL = "https://github.com/singletongue/wikipedia-utils/releases/download/2023-04-03/paragraphs-jawiki-20230403.json.gz"
33
+
34
+
35
+ class JaWikiParagraphs(datasets.ArrowBasedBuilder):
36
+ VERSION = datasets.Version("1.0.0")
37
+
38
+ def _info(self) -> datasets.DatasetInfo:
39
+ features = datasets.Features({
40
+ "id": datasets.Value("string"),
41
+ "pageid": datasets.Value("int64"),
42
+ "revid": datasets.Value("int64"),
43
+ "paragraph_index": datasets.Value("int64"),
44
+ "title": datasets.Value("string"),
45
+ "section": datasets.Value("string"),
46
+ "text": datasets.Value("string"),
47
+ "html_tag": datasets.Value("string"),
48
+ })
49
+ return datasets.DatasetInfo(
50
+ description=_DESCRIPTION,
51
+ homepage=_HOMEPAGE,
52
+ license=_LICENSE,
53
+ features=features,
54
+ )
55
+
56
+ def _split_generators(self, dl_manager: datasets.DownloadManager) -> List[datasets.SplitGenerator]:
57
+ filepath = dl_manager.download_and_extract(_URL)
58
+ return [datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": filepath})]
59
+
60
+ def _generate_tables(self, filepath: str, chunksize: int = 10 << 20) -> Iterator[Tuple[int, pa.Table]]:
61
+ # cf. https://github.com/huggingface/datasets/blob/2.12.0/src/datasets/packaged_modules/json/json.py
62
+ with open(filepath, "rb") as f:
63
+ batch_idx = 0
64
+ block_size = max(chunksize // 32, 16 << 10)
65
+ while True:
66
+ batch = f.read(chunksize)
67
+ if not batch:
68
+ break
69
+
70
+ batch += f.readline()
71
+ pa_table = pa.json.read_json(
72
+ io.BytesIO(batch), read_options=pa.json.ReadOptions(block_size=block_size)
73
+ )
74
+
75
+ yield batch_idx, pa_table
76
+ batch_idx += 1