jchwenger parquet-converter commited on
Commit
fa81298
·
0 Parent(s):

Duplicate from karpathy/tiny_shakespeare

Browse files

Co-authored-by: Parquet-converter (BOT) <parquet-converter@users.noreply.huggingface.co>

Files changed (3) hide show
  1. .gitattributes +27 -0
  2. README.md +183 -0
  3. tiny_shakespeare.py +110 -0
.gitattributes ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bin.* filter=lfs diff=lfs merge=lfs -text
5
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.model filter=lfs diff=lfs merge=lfs -text
12
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
13
+ *.onnx filter=lfs diff=lfs merge=lfs -text
14
+ *.ot filter=lfs diff=lfs merge=lfs -text
15
+ *.parquet filter=lfs diff=lfs merge=lfs -text
16
+ *.pb filter=lfs diff=lfs merge=lfs -text
17
+ *.pt filter=lfs diff=lfs merge=lfs -text
18
+ *.pth filter=lfs diff=lfs merge=lfs -text
19
+ *.rar filter=lfs diff=lfs merge=lfs -text
20
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
21
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
22
+ *.tflite filter=lfs diff=lfs merge=lfs -text
23
+ *.tgz filter=lfs diff=lfs merge=lfs -text
24
+ *.xz filter=lfs diff=lfs merge=lfs -text
25
+ *.zip filter=lfs diff=lfs merge=lfs -text
26
+ *.zstandard filter=lfs diff=lfs merge=lfs -text
27
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,183 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ paperswithcode_id: null
3
+ pretty_name: TinyShakespeare
4
+ dataset_info:
5
+ features:
6
+ - name: text
7
+ dtype: string
8
+ splits:
9
+ - name: test
10
+ num_bytes: 55780
11
+ num_examples: 1
12
+ - name: train
13
+ num_bytes: 1003864
14
+ num_examples: 1
15
+ - name: validation
16
+ num_bytes: 55780
17
+ num_examples: 1
18
+ download_size: 1115394
19
+ dataset_size: 1115424
20
+ ---
21
+
22
+ # Dataset Card for "tiny_shakespeare"
23
+
24
+ ## Table of Contents
25
+ - [Dataset Description](#dataset-description)
26
+ - [Dataset Summary](#dataset-summary)
27
+ - [Supported Tasks and Leaderboards](#supported-tasks-and-leaderboards)
28
+ - [Languages](#languages)
29
+ - [Dataset Structure](#dataset-structure)
30
+ - [Data Instances](#data-instances)
31
+ - [Data Fields](#data-fields)
32
+ - [Data Splits](#data-splits)
33
+ - [Dataset Creation](#dataset-creation)
34
+ - [Curation Rationale](#curation-rationale)
35
+ - [Source Data](#source-data)
36
+ - [Annotations](#annotations)
37
+ - [Personal and Sensitive Information](#personal-and-sensitive-information)
38
+ - [Considerations for Using the Data](#considerations-for-using-the-data)
39
+ - [Social Impact of Dataset](#social-impact-of-dataset)
40
+ - [Discussion of Biases](#discussion-of-biases)
41
+ - [Other Known Limitations](#other-known-limitations)
42
+ - [Additional Information](#additional-information)
43
+ - [Dataset Curators](#dataset-curators)
44
+ - [Licensing Information](#licensing-information)
45
+ - [Citation Information](#citation-information)
46
+ - [Contributions](#contributions)
47
+
48
+ ## Dataset Description
49
+
50
+ - **Homepage:** [https://github.com/karpathy/char-rnn/blob/master/data/tinyshakespeare/input.txt](https://github.com/karpathy/char-rnn/blob/master/data/tinyshakespeare/input.txt)
51
+ - **Repository:** [More Information Needed](https://github.com/huggingface/datasets/blob/master/CONTRIBUTING.md#how-to-contribute-to-the-dataset-cards)
52
+ - **Paper:** [More Information Needed](https://github.com/huggingface/datasets/blob/master/CONTRIBUTING.md#how-to-contribute-to-the-dataset-cards)
53
+ - **Point of Contact:** [More Information Needed](https://github.com/huggingface/datasets/blob/master/CONTRIBUTING.md#how-to-contribute-to-the-dataset-cards)
54
+ - **Size of downloaded dataset files:** 1.11 MB
55
+ - **Size of the generated dataset:** 1.11 MB
56
+ - **Total amount of disk used:** 2.23 MB
57
+
58
+ ### Dataset Summary
59
+
60
+ 40,000 lines of Shakespeare from a variety of Shakespeare's plays. Featured in Andrej Karpathy's blog post 'The Unreasonable Effectiveness of Recurrent Neural Networks': http://karpathy.github.io/2015/05/21/rnn-effectiveness/.
61
+
62
+ To use for e.g. character modelling:
63
+
64
+ ```
65
+ d = datasets.load_dataset(name='tiny_shakespeare')['train']
66
+ d = d.map(lambda x: datasets.Value('strings').unicode_split(x['text'], 'UTF-8'))
67
+ # train split includes vocabulary for other splits
68
+ vocabulary = sorted(set(next(iter(d)).numpy()))
69
+ d = d.map(lambda x: {'cur_char': x[:-1], 'next_char': x[1:]})
70
+ d = d.unbatch()
71
+ seq_len = 100
72
+ batch_size = 2
73
+ d = d.batch(seq_len)
74
+ d = d.batch(batch_size)
75
+ ```
76
+
77
+ ### Supported Tasks and Leaderboards
78
+
79
+ [More Information Needed](https://github.com/huggingface/datasets/blob/master/CONTRIBUTING.md#how-to-contribute-to-the-dataset-cards)
80
+
81
+ ### Languages
82
+
83
+ [More Information Needed](https://github.com/huggingface/datasets/blob/master/CONTRIBUTING.md#how-to-contribute-to-the-dataset-cards)
84
+
85
+ ## Dataset Structure
86
+
87
+ ### Data Instances
88
+
89
+ #### default
90
+
91
+ - **Size of downloaded dataset files:** 1.11 MB
92
+ - **Size of the generated dataset:** 1.11 MB
93
+ - **Total amount of disk used:** 2.23 MB
94
+
95
+ An example of 'train' looks as follows.
96
+ ```
97
+ {
98
+ "text": "First Citizen:\nBefore we proceed any further, hear me "
99
+ }
100
+ ```
101
+
102
+ ### Data Fields
103
+
104
+ The data fields are the same among all splits.
105
+
106
+ #### default
107
+ - `text`: a `string` feature.
108
+
109
+ ### Data Splits
110
+
111
+ | name |train|validation|test|
112
+ |-------|----:|---------:|---:|
113
+ |default| 1| 1| 1|
114
+
115
+ ## Dataset Creation
116
+
117
+ ### Curation Rationale
118
+
119
+ [More Information Needed](https://github.com/huggingface/datasets/blob/master/CONTRIBUTING.md#how-to-contribute-to-the-dataset-cards)
120
+
121
+ ### Source Data
122
+
123
+ #### Initial Data Collection and Normalization
124
+
125
+ [More Information Needed](https://github.com/huggingface/datasets/blob/master/CONTRIBUTING.md#how-to-contribute-to-the-dataset-cards)
126
+
127
+ #### Who are the source language producers?
128
+
129
+ [More Information Needed](https://github.com/huggingface/datasets/blob/master/CONTRIBUTING.md#how-to-contribute-to-the-dataset-cards)
130
+
131
+ ### Annotations
132
+
133
+ #### Annotation process
134
+
135
+ [More Information Needed](https://github.com/huggingface/datasets/blob/master/CONTRIBUTING.md#how-to-contribute-to-the-dataset-cards)
136
+
137
+ #### Who are the annotators?
138
+
139
+ [More Information Needed](https://github.com/huggingface/datasets/blob/master/CONTRIBUTING.md#how-to-contribute-to-the-dataset-cards)
140
+
141
+ ### Personal and Sensitive Information
142
+
143
+ [More Information Needed](https://github.com/huggingface/datasets/blob/master/CONTRIBUTING.md#how-to-contribute-to-the-dataset-cards)
144
+
145
+ ## Considerations for Using the Data
146
+
147
+ ### Social Impact of Dataset
148
+
149
+ [More Information Needed](https://github.com/huggingface/datasets/blob/master/CONTRIBUTING.md#how-to-contribute-to-the-dataset-cards)
150
+
151
+ ### Discussion of Biases
152
+
153
+ [More Information Needed](https://github.com/huggingface/datasets/blob/master/CONTRIBUTING.md#how-to-contribute-to-the-dataset-cards)
154
+
155
+ ### Other Known Limitations
156
+
157
+ [More Information Needed](https://github.com/huggingface/datasets/blob/master/CONTRIBUTING.md#how-to-contribute-to-the-dataset-cards)
158
+
159
+ ## Additional Information
160
+
161
+ ### Dataset Curators
162
+
163
+ [More Information Needed](https://github.com/huggingface/datasets/blob/master/CONTRIBUTING.md#how-to-contribute-to-the-dataset-cards)
164
+
165
+ ### Licensing Information
166
+
167
+ [More Information Needed](https://github.com/huggingface/datasets/blob/master/CONTRIBUTING.md#how-to-contribute-to-the-dataset-cards)
168
+
169
+ ### Citation Information
170
+
171
+ ```
172
+ @misc{
173
+ author={Karpathy, Andrej},
174
+ title={char-rnn},
175
+ year={2015},
176
+ howpublished={\url{https://github.com/karpathy/char-rnn}}
177
+ }
178
+ ```
179
+
180
+
181
+ ### Contributions
182
+
183
+ Thanks to [@thomwolf](https://github.com/thomwolf), [@lewtun](https://github.com/lewtun), [@patrickvonplaten](https://github.com/patrickvonplaten) for adding this dataset.
tiny_shakespeare.py ADDED
@@ -0,0 +1,110 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # coding=utf-8
2
+ # Copyright 2020 The TensorFlow Datasets Authors and the HuggingFace Datasets Authors.
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
+
16
+ # Lint as: python3
17
+ """Tiny Shakespeare dataset."""
18
+
19
+
20
+ import os
21
+
22
+ import datasets
23
+
24
+
25
+ _CITATION = """\
26
+ @misc{
27
+ author={Karpathy, Andrej},
28
+ title={char-rnn},
29
+ year={2015},
30
+ howpublished={\\url{https://github.com/karpathy/char-rnn}}
31
+ }"""
32
+
33
+ _DESCRIPTION = """\
34
+ 40,000 lines of Shakespeare from a variety of Shakespeare's plays. \
35
+ Featured in Andrej Karpathy's blog post 'The Unreasonable Effectiveness of \
36
+ Recurrent Neural Networks': \
37
+ http://karpathy.github.io/2015/05/21/rnn-effectiveness/.
38
+
39
+ To use for e.g. character modelling:
40
+
41
+ ```
42
+ d = datasets.load_dataset(name='tiny_shakespeare')['train']
43
+ d = d.map(lambda x: datasets.Value('strings').unicode_split(x['text'], 'UTF-8'))
44
+ # train split includes vocabulary for other splits
45
+ vocabulary = sorted(set(next(iter(d)).numpy()))
46
+ d = d.map(lambda x: {'cur_char': x[:-1], 'next_char': x[1:]})
47
+ d = d.unbatch()
48
+ seq_len = 100
49
+ batch_size = 2
50
+ d = d.batch(seq_len)
51
+ d = d.batch(batch_size)
52
+ ```
53
+ """
54
+
55
+
56
+ class TinyShakespeare(datasets.GeneratorBasedBuilder):
57
+ """Tiny Shakespeare dataset builder."""
58
+
59
+ VERSION = datasets.Version("1.0.0")
60
+
61
+ def _info(self):
62
+ return datasets.DatasetInfo(
63
+ description=_DESCRIPTION,
64
+ features=datasets.Features({"text": datasets.Value("string")}),
65
+ supervised_keys=None,
66
+ homepage="https://github.com/karpathy/char-rnn/blob/master/data/tinyshakespeare/input.txt",
67
+ citation=_CITATION,
68
+ )
69
+
70
+ def _split_generators(self, dl_manager):
71
+ """Returns SplitGenerators."""
72
+ download_path = dl_manager.download_and_extract(
73
+ "https://raw.githubusercontent.com/karpathy/char-rnn/master/data/tinyshakespeare/input.txt"
74
+ )
75
+ if os.path.isdir(download_path):
76
+ # During testing the download manager mock gives us a directory
77
+ txt_path = os.path.join(download_path, "input.txt")
78
+ else:
79
+ txt_path = download_path
80
+ with open(txt_path, "r", encoding="utf-8") as f:
81
+ text = f.read()
82
+
83
+ # 90/5/5 split
84
+ i = int(len(text) * 0.9)
85
+ train_text, text = text[:i], text[i:]
86
+ i = int(len(text) * 0.5)
87
+ validation_text, text = text[:i], text[i:]
88
+ test_text = text
89
+
90
+ return [
91
+ datasets.SplitGenerator(
92
+ name=datasets.Split.TRAIN,
93
+ # These kwargs will be passed to _generate_examples
94
+ gen_kwargs={"split_key": "train", "split_text": train_text},
95
+ ),
96
+ datasets.SplitGenerator(
97
+ name=datasets.Split.VALIDATION,
98
+ gen_kwargs={"split_key": "validation", "split_text": validation_text},
99
+ ),
100
+ datasets.SplitGenerator(
101
+ name=datasets.Split.TEST,
102
+ gen_kwargs={"split_key": "test", "split_text": test_text},
103
+ ),
104
+ ]
105
+
106
+ def _generate_examples(self, split_key, split_text):
107
+ """Yields examples."""
108
+ data_key = split_key # Should uniquely identify the thing yielded
109
+ feature_dict = {"text": split_text}
110
+ yield data_key, feature_dict