stas commited on
Commit
c6830ab
1 Parent(s): 383521c

create dataset

Browse files
Files changed (4) hide show
  1. README.md +29 -0
  2. dataset_infos.json +1 -0
  3. oscar-en-10k.py +82 -0
  4. process.txt +49 -0
README.md ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ This is a small subset representing the 10K records from the original OSCAR dataset, "unshuffled_deduplicated_en" subset - created for testing. The records were extracted after having been shuffled.
2
+
3
+ The full 1TB+ dataset is at https://huggingface.co/datasets/oscar.
4
+
5
+ ```
6
+ $ python -c "from datasets import load_dataset; ds=load_dataset('stas/oscar-en-10k'); print(ds)"
7
+ DatasetDict({
8
+ train: Dataset({
9
+ features: ['text'],
10
+ num_rows: 10000
11
+ })
12
+ })
13
+ ```
14
+
15
+ * Records: 10,000
16
+ * compressed size: ~37MB
17
+ * uncompressed size: 131MB
18
+
19
+ To convert to jsonlines:
20
+
21
+ ```
22
+ from datasets import load_dataset
23
+ dataset_name = "stas/oscar-en-10k"
24
+ name = dataset_name.split('/')[-1]
25
+ ds = load_dataset(dataset_name, split='train')
26
+ ds.to_json(f"{name}.jsonl", orient="records", lines=True)
27
+ ```
28
+
29
+ To see how this subset was created, here is the [instructions file](./process.txt).
dataset_infos.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"plain_text": {"description": "This is a small subset representing 10K records from the original OSCAR dataset, \"unshuffled_deduplicated_en\" subset - created for testing. The records were extracted after having been shuffled.\n\nThe full 1TB+ dataset is at https://huggingface.co/datasets/oscar.\n", "citation": "@inproceedings{OrtizSuarezSagotRomary2019,\n author = {Pedro Javier {Ortiz Su{'a}rez} and Benoit Sagot and Laurent Romary},\n title = {Asynchronous pipelines for processing huge corpora on medium to low resource infrastructures},\n series = {Proceedings of the Workshop on Challenges in the Management of Large Corpora (CMLC-7) 2019. Cardiff, 22nd July 2019},\n editor = {Piotr Ba\u0144ski and Adrien Barbaresi and Hanno Biber and Evelyn Breiteneder and Simon Clematide and Marc Kupietz and Harald L{\"u}ngen and Caroline Iliadi},\n publisher = {Leibniz-Institut f{\"u}r Deutsche Sprache},\n address = {Mannheim},\n doi = {10.14618/ids-pub-9021},\n url = {http://nbn-resolving.de/urn:nbn:de:bsz:mh39-90215},\n pages = {9 -- 16},\n year = {2019},\n abstract = {Common Crawl is a considerably large, heterogeneous multilingual corpus comprised of crawled documents from the internet, surpassing 20TB of data and distributed as a set of more than 50 thousand plain text files where each contains many documents written in a wide variety of languages. Even though each document has a metadata block associated to it, this data lacks any information about the language in which each document is written, making it extremely difficult to use Common Crawl for monolingual applications. We propose a general, highly parallel, multithreaded pipeline to clean and classify Common Crawl by language; we specifically design it so that it runs efficiently on medium to low resource infrastructures where I/O speeds are the main constraint. We develop the pipeline so that it can be easily reapplied to any kind of heterogeneous corpus and so that it can be parameterised to a wide range of infrastructures. We also distribute a 6.3TB version of Common Crawl, filtered, classified by language, shuffled at line level in order to avoid copyright issues, and ready to be used for NLP applications.},\n language = {en}\n}\n", "homepage": "https://oscar-corpus.com/", "license": "", "features": {"text": {"dtype": "string", "id": null, "_type": "Value"}}, "post_processed": null, "supervised_keys": null, "task_templates": null, "builder_name": "oscar_en10k", "config_name": "plain_text", "version": {"version_str": "1.0.0", "description": null, "major": 1, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 135537185, "num_examples": 10000, "dataset_name": "oscar_en10k"}}, "download_checksums": {"https://cdn-datasets.huggingface.co/nlp/datasets/oscar/oscar-en-10k.tar.xz": {"num_bytes": 38353240, "checksum": "5192c684786286c50270940579d778bc914609e5a93fb7d0741171006d295742"}}, "download_size": 38353240, "post_processing_size": null, "dataset_size": 135537185, "size_in_bytes": 173890425}}
oscar-en-10k.py ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # coding=utf-8
2
+ # Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor.
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
+ """The Open WebText Corpus"""
16
+
17
+
18
+ import os
19
+ import json
20
+
21
+ import datasets
22
+
23
+
24
+ _CITATION = """\
25
+ @inproceedings{OrtizSuarezSagotRomary2019,
26
+ author = {Pedro Javier {Ortiz Su{'a}rez} and Benoit Sagot and Laurent Romary},
27
+ title = {Asynchronous pipelines for processing huge corpora on medium to low resource infrastructures},
28
+ series = {Proceedings of the Workshop on Challenges in the Management of Large Corpora (CMLC-7) 2019. Cardiff, 22nd July 2019},
29
+ editor = {Piotr Bański and Adrien Barbaresi and Hanno Biber and Evelyn Breiteneder and Simon Clematide and Marc Kupietz and Harald L{"u}ngen and Caroline Iliadi},
30
+ publisher = {Leibniz-Institut f{"u}r Deutsche Sprache},
31
+ address = {Mannheim},
32
+ doi = {10.14618/ids-pub-9021},
33
+ url = {http://nbn-resolving.de/urn:nbn:de:bsz:mh39-90215},
34
+ pages = {9 -- 16},
35
+ year = {2019},
36
+ abstract = {Common Crawl is a considerably large, heterogeneous multilingual corpus comprised of crawled documents from the internet, surpassing 20TB of data and distributed as a set of more than 50 thousand plain text files where each contains many documents written in a wide variety of languages. Even though each document has a metadata block associated to it, this data lacks any information about the language in which each document is written, making it extremely difficult to use Common Crawl for monolingual applications. We propose a general, highly parallel, multithreaded pipeline to clean and classify Common Crawl by language; we specifically design it so that it runs efficiently on medium to low resource infrastructures where I/O speeds are the main constraint. We develop the pipeline so that it can be easily reapplied to any kind of heterogeneous corpus and so that it can be parameterised to a wide range of infrastructures. We also distribute a 6.3TB version of Common Crawl, filtered, classified by language, shuffled at line level in order to avoid copyright issues, and ready to be used for NLP applications.},
37
+ language = {en}
38
+ }
39
+ """
40
+
41
+ _DESCRIPTION = """\
42
+ This is a small subset representing 10K records from the original OSCAR dataset, "unshuffled_deduplicated_en" subset - created for testing. The records were extracted after having been shuffled.
43
+
44
+ The full 1TB+ dataset is at https://huggingface.co/datasets/oscar.
45
+ """
46
+
47
+ _URL = "https://cdn-datasets.huggingface.co/nlp/datasets/oscar/oscar-en-10k.tar.xz"
48
+
49
+ class OscarEn10k(datasets.GeneratorBasedBuilder):
50
+ """The Open WebText dataset."""
51
+
52
+ BUILDER_CONFIGS = [
53
+ datasets.BuilderConfig(
54
+ name="plain_text",
55
+ description="Plain text",
56
+ version=datasets.Version("1.0.0"),
57
+ )
58
+ ]
59
+
60
+ def _info(self):
61
+ return datasets.DatasetInfo(
62
+ description=_DESCRIPTION,
63
+ features=datasets.Features({"text": datasets.Value("string")}),
64
+ homepage="https://oscar-corpus.com/",
65
+ citation=_CITATION,
66
+ )
67
+
68
+ def _split_generators(self, dl_manager):
69
+ dl_dir = dl_manager.download_and_extract(_URL)
70
+ jsonl_file = os.path.join(dl_dir, "oscar-en-10k", "oscar-en-10k.jsonl")
71
+ return [
72
+ datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"jsonl_file": jsonl_file}),
73
+ ]
74
+
75
+ def _generate_examples(self, jsonl_file):
76
+ """Yields examples."""
77
+ with open(jsonl_file, encoding="utf-8") as f:
78
+ idx = 0
79
+ for line in f:
80
+ rec = json.loads(line)
81
+ yield idx, {"text": rec["text"]}
82
+ idx += 1
process.txt ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ # this is a small derivative from 8M-big oscar-en dataset for testing
3
+
4
+ # how this build script and dataset_infos.json were generated
5
+
6
+ #
7
+
8
+ mkdir oscar-en-10k
9
+ cd oscar-en-10k
10
+
11
+ # data (extracted oscar-1GB.jsonl elsewhere) - this is a 1.63TB dataset, so tough to rebuild from scratch
12
+ head -10000 oscar-1GB.jsonl > oscar-en-10k.jsonl
13
+
14
+ mkdir oscar-en-10k
15
+ mv oscar-en-10k.jsonl oscar-en-10k
16
+ tar cfJ oscar-en-10k.tar.xz oscar-en-10k
17
+
18
+ # the oscar-en-10k subdir gets created on the fly
19
+ aws s3 cp oscar-en-10k.tar.xz s3://datasets.huggingface.co/nlp/datasets/oscar/
20
+
21
+ # script
22
+ (adapted from stas/openwebtext-10k)
23
+
24
+ # manually check that the script is correct - edit the descriptions
25
+
26
+ # create a new dataset entry on the hub
27
+ https://huggingface.co/new-dataset
28
+
29
+ # once created clone it
30
+ git clone https://huggingface.co/datasets/stas/oscar-en-10k
31
+ cp oscar-en-10k.py process.txt oscar-en-10k
32
+ cd oscar-en-10k
33
+
34
+ git add oscar-en-10k.py process.txt
35
+ git commit -m "build script" oscar-en-10k.py process.txt
36
+ git push
37
+
38
+ # test and generate config file
39
+ cd ..
40
+ datasets-cli test ./oscar-en-10k --save_infos --all_configs
41
+
42
+ # add and push the generated config
43
+ cd oscar-en-10k
44
+ git add dataset_infos.json
45
+ git commit -m "add dataset_infos.json" dataset_infos.json
46
+ git push
47
+
48
+ # test that the dataset is working
49
+ python -c "from datasets import load_dataset; ds=load_dataset('stas/oscar-en-10k'); print(ds)"