Gabriel Kressin Palacios commited on
Commit
3ecf042
1 Parent(s): 70dcc8c

initial wikitext commit

Browse files
.gitattributes CHANGED
@@ -35,3 +35,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
35
  *.mp3 filter=lfs diff=lfs merge=lfs -text
36
  *.ogg filter=lfs diff=lfs merge=lfs -text
37
  *.wav filter=lfs diff=lfs merge=lfs -text
 
 
 
35
  *.mp3 filter=lfs diff=lfs merge=lfs -text
36
  *.ogg filter=lfs diff=lfs merge=lfs -text
37
  *.wav filter=lfs diff=lfs merge=lfs -text
38
+ wikitext103/ filter=lfs diff=lfs merge=lfs -text
39
+ wikitext2 filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,317 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ annotations_creators:
3
+ - machine-generated
4
+ language_creators:
5
+ - machine-generated
6
+ languages:
7
+ - en
8
+ licenses:
9
+ - cc-by-sa-4.0
10
+ multilinguality:
11
+ - monolingual
12
+ pretty_name: wikitext_linked
13
+ size_categories:
14
+ - 1M<n<10M
15
+ source_datasets:
16
+ - extended|wikitext
17
+ task_categories:
18
+ - fill-mask
19
+ - token-classification
20
+ - text-classification
21
+ task_ids:
22
+ - masked-language-modeling
23
+ - named-entity-recognition
24
+ - part-of-speech
25
+ - lemmatization
26
+ - parsing
27
+ - entity-linking-classification
28
+ ---
29
+
30
+ # Dataset Card for [Dataset Name]
31
+
32
+ ## Table of Contents
33
+ - [Table of Contents](#table-of-contents)
34
+ - [Dataset Description](#dataset-description)
35
+ - [Dataset Summary](#dataset-summary)
36
+ - [Supported Tasks and Leaderboards](#supported-tasks-and-leaderboards)
37
+ - [Languages](#languages)
38
+ - [Dataset Structure](#dataset-structure)
39
+ - [Data Instances](#data-instances)
40
+ - [Data Fields](#data-fields)
41
+ - [Data Splits](#data-splits)
42
+ - [Dataset Creation](#dataset-creation)
43
+ - [Curation Rationale](#curation-rationale)
44
+ - [Source Data](#source-data)
45
+ - [Annotations](#annotations)
46
+ - [Personal and Sensitive Information](#personal-and-sensitive-information)
47
+ - [Considerations for Using the Data](#considerations-for-using-the-data)
48
+ - [Social Impact of Dataset](#social-impact-of-dataset)
49
+ - [Discussion of Biases](#discussion-of-biases)
50
+ - [Other Known Limitations](#other-known-limitations)
51
+ - [Additional Information](#additional-information)
52
+ - [Dataset Curators](#dataset-curators)
53
+ - [Licensing Information](#licensing-information)
54
+ - [Citation Information](#citation-information)
55
+ - [Contributions](#contributions)
56
+
57
+ ## Dataset Description
58
+
59
+ - **Homepage:** -
60
+ - **Repository:** [https://github.com/GabrielKP/svo/](https://github.com/GabrielKP/svo/)
61
+ - **Paper:** -
62
+ - **Leaderboard:** -
63
+ - **Point of Contact:** [[email protected]](mailto:[email protected])
64
+
65
+ ### Dataset Summary
66
+
67
+ The WikiText language modeling dataset is a collection of over 100 million tokens extracted from
68
+ the set of verified Good and Featured articles on Wikipedia. Dependency Relations, POS, NER tags
69
+ are marked with [trankit](https://github.com/nlp-uoregon/trankit), entities are linked with
70
+ [entity-fishing](https://nerd.readthedocs.io/en/latest/index.html), which also tags another field
71
+ of NER tags. The dataset is available under the Creative Commons Attribution-ShareAlike License.
72
+
73
+ Compared to the preprocessed version of Penn Treebank (PTB), WikiText-2 is over 2 times larger and
74
+ WikiText-103 is over 110 times larger. The WikiText dataset also features a far larger vocabulary
75
+ and retains the original case, punctuation and numbers - all of which are removed in PTB. As it is
76
+ composed of full articles, the dataset is well suited for models that can take advantage of long
77
+ term dependencies.
78
+
79
+ ### Supported Tasks and Leaderboards
80
+
81
+ - masked-language-modeling
82
+ - named-entity-recognition
83
+ - part-of-speech
84
+ - lemmatization
85
+ - parsing
86
+ - entity-linking-classification
87
+
88
+ ### Languages
89
+
90
+ English.
91
+
92
+ ## Dataset Structure
93
+
94
+ ### Data Instances
95
+
96
+ #### wikitext2
97
+
98
+ - **Size of downloaded dataset files:** ?
99
+ - **Size of the generated dataset:** ?
100
+ - **Total amount of disk used:** 197.2 MB
101
+ An example of 'validation' looks as follows.
102
+
103
+ ```
104
+ {
105
+ 'text': 'It is closely related to the American lobster , H. americanus .',
106
+ 'original_id': 3,
107
+ 'tok_span': [[0, 0], [0, 2], [3, 5], [6, 13], [14, 21], [22, 24], [25, 28], [29, 37], [38, 45], [46, 47], [48, 50], [51, 61], [62, 63]],
108
+ 'tok_upos': ['root', 'PRON', 'AUX', 'ADV', 'ADJ', 'ADP', 'DET', 'ADJ', 'NOUN', 'PUNCT', 'PROPN', 'PROPN', 'PUNCT'],
109
+ 'tok_xpos': ['root', 'PRP', 'VBZ', 'RB', 'JJ', 'IN', 'DT', 'JJ', 'NN', ',', 'NNP', 'NNP', '.'],
110
+ 'tok_dephead': [0, 4, 4, 4, 0, 8, 8, 8, 4, 8, 8, 10, 4],
111
+ 'tok_deprel': ['root', 'nsubj', 'cop', 'advmod', 'root', 'case', 'det', 'amod', 'obl', 'punct', 'appos', 'flat', 'punct'],
112
+ 'tok_lemma': [None, 'it', 'be', 'closely', 'related', 'to', 'the', 'american', 'lobster', ',', 'H.', 'americanus', '.'],
113
+ 'tok_ner': [None, 'O', 'O', 'O', 'O', 'O', 'O', 'S-MISC', 'O', 'O', 'O', 'O', 'O'],
114
+ 'ent_span': [[29, 45]],
115
+ 'ent_wikipedia_external_ref': ['377397'],
116
+ 'ent_ner': [None],
117
+ 'ent_domains': [['Enterprise']],
118
+ }
119
+ ```
120
+
121
+ #### wikitext103
122
+
123
+ - **Size of downloaded dataset files:** ?
124
+ - **Size of the generated dataset:** ?
125
+ - **Total amount of disk used:** 7.82 GB
126
+ An example of 'train' looks as follows.
127
+ ```
128
+ {
129
+ 'text': 'Vision for the PlayStation Portable .',
130
+ 'original_id': 3,
131
+ 'tok_span': [[0, 0], [0, 6], [7, 10], [11, 14], [15, 26], [27, 35], [36, 37]],
132
+ 'tok_upos': ['root', 'NOUN', 'ADP', 'DET', 'PROPN', 'PROPN', 'PUNCT'],
133
+ 'tok_xpos': ['root', 'NN', 'IN', 'DT', 'NNP', 'NNP', '.'],
134
+ 'tok_dephead': [0, 0, 5, 5, 5, 1, 1],
135
+ 'tok_deprel': ['root', 'root', 'case', 'det', 'compound', 'nmod', 'punct'],
136
+ 'tok_lemma': [None, 'vision', 'for', 'the', 'PlayStation', 'Portable', '.'],
137
+ 'tok_ner': [None, 'O', 'O', 'O', 'B-MISC', 'E-MISC', 'O'],
138
+ 'ent_span': [[15, 35]],
139
+ 'ent_wikipedia_external_ref': ['619009'],
140
+ 'ent_ner': [None],
141
+ 'ent_domains': [['Electronics', 'Computer_Science']]
142
+ }
143
+ ```
144
+
145
+ Use following code to print the examples nicely:
146
+ ```py
147
+ def print_tokens_entities(example):
148
+ text = example['text']
149
+ print(
150
+ "Text:\n"
151
+ f" {text}"
152
+ "\nOrig-Id: "
153
+ f"{example['original_id']}"
154
+ "\nTokens:"
155
+ )
156
+ iterator = enumerate(zip(
157
+ example["tok_span"],
158
+ example["tok_upos"],
159
+ example["tok_xpos"],
160
+ example["tok_ner"],
161
+ example["tok_dephead"],
162
+ example["tok_deprel"],
163
+ example["tok_lemma"],
164
+ ))
165
+ print(f" Id | {'token':12} | {'upos':8} | {'xpos':8} | {'ner':8} | {'deph':4} | {'deprel':9} | {'lemma':12} | Id")
166
+ print("---------------------------------------------------------------------------------------------------")
167
+ for idx, (tok_span, upos, xpos, ner, dephead, deprel, lemma) in iterator:
168
+ print(f" {idx:3} | {text[tok_span[0]:tok_span[1]]:12} | {upos:8} | {xpos:8} | {str(ner):8} | {str(dephead):4} | {deprel:9} | {str(lemma):12} | {idx}")
169
+
170
+ iterator = list(enumerate(zip(
171
+ example.get("ent_span", []),
172
+ example.get("ent_wikipedia_external_ref", []),
173
+ example.get("ent_ner", []),
174
+ example.get("ent_domains", []),
175
+ )))
176
+ if len(iterator) > 0:
177
+ print("Entities")
178
+ print(f" Id | {'entity':21} | {'wiki_ref':7} | {'ner':7} | domains")
179
+ print("--------------------------------------------------------------------")
180
+ for idx, ((start, end), wiki_ref, ent_ner, ent_domains) in iterator:
181
+ print(f" {idx:3} | {text[start:end]:21} | {str(wiki_ref):7} | {str(ent_ner):7} | {ent_domains}")
182
+ ```
183
+
184
+ ### Data Fields
185
+
186
+ The data fields are the same among all splits.
187
+
188
+ * text: string feature.
189
+ * original_id: int feature. Mapping to index within original wikitext dataset.
190
+ * tok_span: sequence of (int, int) tuples. Denotes token spans (start inclusive, end exclusive)
191
+ within each sentence.
192
+ **Note that each sentence includes an artificial root node to align dependency relations.**
193
+ * tok_upos: string feature. [Universal Dependency POS tag](https://universaldependencies.org/)
194
+ tags. Aligned with tok_span. Root node has tag "root".
195
+ * tok_xpos: string geature. [XPOS POS tag](https://trankit.readthedocs.io/en/latest/overview.html#token-list).
196
+ Aligned with tok_span. Root node has tag "root".
197
+ * tok_dephead: int feature.
198
+ [Universal Dependency Head Node](https://universaldependencies.org/introduction.html). Int refers
199
+ to tokens in tok_span. Root node has head `0` (itself).
200
+ * tok_deprel: [Universal Dependency Relation Description](https://universaldependencies.org/introduction.html).
201
+ Refers to the relation between this token and head token. Aligned with tok_span. Root node has
202
+ dependency relation "root" to itself.
203
+ * tok_lemma: string feature. Lemma of token. Aligend with tok_span.
204
+ * tok_ner: string feature. NER tag of token. Marked in BIOS schema (e.g. S-MISC, B-LOC, ...)
205
+ Aligned with tok_span. Root node has NER tag `None`.
206
+ * ent_span: sequence of (int, int) tuples. Denotes entities found by entity-fishing
207
+ (start inclusive, end exclusive).
208
+ * ent_wikipedia_external_ref: string feature. External Reference to wikipedia page. You can
209
+ access the wikipedia page via the url `https://en.wikipedia.org/wiki?curid=<ent_wikipedia_external_ref>`.
210
+ Aligend with ent_span. All entities either have this field, or the `ent_ner` field, but not both.
211
+ An empty field is denoted by the string `None`. Aligned with ent_span.
212
+ * ent_ner: string feature. Denotes NER tags. An empty field is denoted by the string `None`.
213
+ Aligned with ent_span.
214
+ "ent_domains": sequence of string. Denotes domains of entity. Can be empty sequence. Aligned with
215
+ ent_span.
216
+
217
+ ### Data Splits
218
+
219
+ | name | train |validation| test|
220
+ |-------------------|------:|---------:|----:|
221
+ |wikitext103 |4076530| 8607|10062|
222
+ |wikitext2 | 82649| 8606|10062|
223
+
224
+ ## Dataset Creation
225
+
226
+ ### Curation Rationale
227
+
228
+ [More Information Needed]
229
+
230
+ ### Source Data
231
+
232
+ #### Initial Data Collection and Normalization
233
+
234
+ [https://huggingface.co/datasets/wikitext](https://huggingface.co/datasets/wikitext)
235
+
236
+ #### Who are the source language producers?
237
+
238
+ [More Information Needed]
239
+
240
+ ### Annotations
241
+
242
+ #### Annotation process
243
+
244
+ 1. Started with `wikitext2-raw-v1` and `wikitext103-raw-v1` from [wikitext](https://huggingface.co/datasets/wikitext)
245
+ 2. Ran datasets through Trankit. Marked all fields starting with `tok`.
246
+
247
+ In this step, the texts have been split into sentences. To retain the original text sections
248
+ you can accumulate over `original_id` (examples are in order).
249
+
250
+ 3. Ran datasets through entity-fishing. Marked all fields starting with `ent`.
251
+
252
+ #### Who are the annotators?
253
+
254
+ Machines powered by [DFKI](https://www.dfki.de/web).
255
+
256
+ ### Personal and Sensitive Information
257
+
258
+ [More Information Needed]
259
+
260
+ ## Considerations for Using the Data
261
+
262
+ ### Social Impact of Dataset
263
+
264
+ [More Information Needed]
265
+
266
+ ### Discussion of Biases
267
+
268
+ [More Information Needed]
269
+
270
+ ### Other Known Limitations
271
+
272
+ [More Information Needed]
273
+
274
+ ## Additional Information
275
+
276
+ ### Dataset Curators
277
+
278
+ [More Information Needed]
279
+
280
+ ### Licensing Information
281
+
282
+ Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
283
+
284
+ ### Citation Information
285
+
286
+ Please cite the original creators of wikitext, and the great people
287
+ developing trankit and entity-fishing.
288
+ ```
289
+ @misc{merity2016pointer,
290
+ title={Pointer Sentinel Mixture Models},
291
+ author={Stephen Merity and Caiming Xiong and James Bradbury and Richard Socher},
292
+ year={2016},
293
+ eprint={1609.07843},
294
+ archivePrefix={arXiv},
295
+ primaryClass={cs.CL}
296
+ }
297
+
298
+ @inproceedings{nguyen2021trankit,
299
+ title={Trankit: A Light-Weight Transformer-based Toolkit for Multilingual Natural Language Processing},
300
+ author={Nguyen, Minh Van and Lai, Viet Dac and Veyseh, Amir Pouran Ben and Nguyen, Thien Huu},
301
+ booktitle="Proceedings of the 16th Conference of the European Chapter of the Association for Computational Linguistics: System Demonstrations",
302
+ year={2021}
303
+ }
304
+
305
+ @misc{entity-fishing,
306
+ title = {entity-fishing},
307
+ howpublished = {\\url{https://github.com/kermitt2/entity-fishing}},
308
+ publisher = {GitHub},
309
+ year = {2016--2022},
310
+ archivePrefix = {swh},
311
+ eprint = {1:dir:cb0ba3379413db12b0018b7c3af8d0d2d864139c}
312
+ }
313
+ ```
314
+
315
+ ### Contributions
316
+
317
+ Thanks to [@GabrielKP](https://github.com/GabrielKP) for adding this dataset.
dataset_infos.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"wikitext2": {"description": " The WikiText language modeling dataset is a collection of over 100 million tokens extracted from the set of verified\n Good and Featured articles on Wikipedia. Dependency Relations, POS, NER tags are marked with trankit and\n entities are linked with entity-fishing.\n The dataset is available under the Creative Commons Attribution-ShareAlike License.\n", "citation": "@misc{merity2016pointer,\n title={Pointer Sentinel Mixture Models},\n author={Stephen Merity and Caiming Xiong and James Bradbury and Richard Socher},\n year={2016},\n eprint={1609.07843},\n archivePrefix={arXiv},\n primaryClass={cs.CL}\n}\n\n@inproceedings{nguyen2021trankit,\n title={Trankit: A Light-Weight Transformer-based Toolkit for Multilingual Natural Language Processing},\n author={Nguyen, Minh Van and Lai, Viet Dac and Veyseh, Amir Pouran Ben and Nguyen, Thien Huu},\n booktitle=\"Proceedings of the 16th Conference of the European Chapter of the Association for Computational Linguistics: System Demonstrations\",\n year={2021}\n}\n\n@misc{entity-fishing,\n title = {entity-fishing},\n howpublished = {\\url{https://github.com/kermitt2/entity-fishing}},\n publisher = {GitHub},\n year = {2016--2022},\n archivePrefix = {swh},\n eprint = {1:dir:cb0ba3379413db12b0018b7c3af8d0d2d864139c}\n}\n", "homepage": "", "license": "Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)", "features": {"text": {"dtype": "string", "id": null, "_type": "Value"}, "original_id": {"dtype": "int64", "id": null, "_type": "Value"}, "tok_span": {"feature": {"feature": {"dtype": "int64", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "length": -1, "id": null, "_type": "Sequence"}, "tok_upos": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "tok_xpos": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "tok_dephead": {"feature": {"dtype": "int64", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "tok_deprel": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "tok_lemma": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "tok_ner": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "ent_span": {"feature": {"feature": {"dtype": "int64", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "length": -1, "id": null, "_type": "Sequence"}, "ent_wikipedia_external_ref": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "ent_ner": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "ent_domains": {"feature": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "length": -1, "id": null, "_type": "Sequence"}}, "post_processed": null, "supervised_keys": null, "task_templates": null, "builder_name": "wikitext_linked", "config_name": "wikitext2", "version": {"version_str": "1.0.0", "description": null, "major": 1, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 168970698, "num_examples": 82649, "dataset_name": "wikitext_linked"}, "validation": {"name": "validation", "num_bytes": 17702375, "num_examples": 8606, "dataset_name": "wikitext_linked"}, "test": {"name": "test", "num_bytes": 20013719, "num_examples": 10062, "dataset_name": "wikitext_linked"}}, "download_checksums": {}, "download_size": 0, "post_processing_size": null, "dataset_size": 206686792, "size_in_bytes": 206686792}, "wikitext103": {"description": " The WikiText language modeling dataset is a collection of over 100 million tokens extracted from the set of verified\n Good and Featured articles on Wikipedia. Dependency Relations, POS, NER tags are marked with trankit and\n entities are linked with entity-fishing.\n The dataset is available under the Creative Commons Attribution-ShareAlike License.\n", "citation": "@misc{merity2016pointer,\n title={Pointer Sentinel Mixture Models},\n author={Stephen Merity and Caiming Xiong and James Bradbury and Richard Socher},\n year={2016},\n eprint={1609.07843},\n archivePrefix={arXiv},\n primaryClass={cs.CL}\n}\n\n@inproceedings{nguyen2021trankit,\n title={Trankit: A Light-Weight Transformer-based Toolkit for Multilingual Natural Language Processing},\n author={Nguyen, Minh Van and Lai, Viet Dac and Veyseh, Amir Pouran Ben and Nguyen, Thien Huu},\n booktitle=\"Proceedings of the 16th Conference of the European Chapter of the Association for Computational Linguistics: System Demonstrations\",\n year={2021}\n}\n\n@misc{entity-fishing,\n title = {entity-fishing},\n howpublished = {\\url{https://github.com/kermitt2/entity-fishing}},\n publisher = {GitHub},\n year = {2016--2022},\n archivePrefix = {swh},\n eprint = {1:dir:cb0ba3379413db12b0018b7c3af8d0d2d864139c}\n}\n", "homepage": "", "license": "Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)", "features": {"text": {"dtype": "string", "id": null, "_type": "Value"}, "original_id": {"dtype": "int64", "id": null, "_type": "Value"}, "tok_span": {"feature": {"feature": {"dtype": "int64", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "length": -1, "id": null, "_type": "Sequence"}, "tok_upos": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "tok_xpos": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "tok_dephead": {"feature": {"dtype": "int64", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "tok_deprel": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "tok_lemma": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "tok_ner": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "ent_span": {"feature": {"feature": {"dtype": "int64", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "length": -1, "id": null, "_type": "Sequence"}, "ent_wikipedia_external_ref": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "ent_ner": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "ent_domains": {"feature": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "length": -1, "id": null, "_type": "Sequence"}}, "post_processed": null, "supervised_keys": null, "task_templates": null, "builder_name": "wikitext_linked", "config_name": "wikitext103", "version": {"version_str": "1.0.0", "description": null, "major": 1, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 8356828955, "num_examples": 4076530, "dataset_name": "wikitext_linked"}, "validation": {"name": "validation", "num_bytes": 17702461, "num_examples": 8607, "dataset_name": "wikitext_linked"}, "test": {"name": "test", "num_bytes": 20013609, "num_examples": 10062, "dataset_name": "wikitext_linked"}}, "download_checksums": {}, "download_size": 0, "post_processing_size": null, "dataset_size": 8394545025, "size_in_bytes": 8394545025}}
wikitext103/test.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:791c364b0c84bfff37738a8a12c6c08374d354cc2dc19d8c2fb540bcd9690143
3
+ size 3121651
wikitext103/train.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5f73231cf4fbf2ce77a7762dc8662656baaecebbe06ef0a9eaf60ac0c5646d9c
3
+ size 1313130334
wikitext103/validation.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:08199a4d18e9ce663b52948d54f64f6e65207471a1d2c7ac917a1c26642c0b9e
3
+ size 2755917
wikitext2/test.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4674d94eff80195b563cb9a2a1bc97aa25ef7a6b500bf2257036c14bdd0ae306
3
+ size 3127331
wikitext2/train.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:722ecc0b545203de71e6891b3b8b92f1f1cec301b95f68380adef222a5da3777
3
+ size 26645424
wikitext2/validation.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f48f826bfe84b977f6d983f37ee08fab0dce48c3ec187387836661b242e807ff
3
+ size 2763767
wikitext_linked.py ADDED
@@ -0,0 +1,163 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ """Datasets loading script for wikitext_linked"""
15
+
16
+ import os
17
+
18
+ import datasets
19
+ import pyarrow as pa
20
+ import pyarrow.parquet as pq
21
+
22
+
23
+ logger = datasets.utils.logging.get_logger(__name__)
24
+
25
+
26
+ _CITATION = """\
27
+ @misc{merity2016pointer,
28
+ title={Pointer Sentinel Mixture Models},
29
+ author={Stephen Merity and Caiming Xiong and James Bradbury and Richard Socher},
30
+ year={2016},
31
+ eprint={1609.07843},
32
+ archivePrefix={arXiv},
33
+ primaryClass={cs.CL}
34
+ }
35
+
36
+ @inproceedings{nguyen2021trankit,
37
+ title={Trankit: A Light-Weight Transformer-based Toolkit for Multilingual Natural Language Processing},
38
+ author={Nguyen, Minh Van and Lai, Viet Dac and Veyseh, Amir Pouran Ben and Nguyen, Thien Huu},
39
+ booktitle="Proceedings of the 16th Conference of the European Chapter of the Association for Computational Linguistics: System Demonstrations",
40
+ year={2021}
41
+ }
42
+
43
+ @misc{entity-fishing,
44
+ title = {entity-fishing},
45
+ howpublished = {\\url{https://github.com/kermitt2/entity-fishing}},
46
+ publisher = {GitHub},
47
+ year = {2016--2022},
48
+ archivePrefix = {swh},
49
+ eprint = {1:dir:cb0ba3379413db12b0018b7c3af8d0d2d864139c}
50
+ }
51
+ """
52
+
53
+ _DESCRIPTION = """\
54
+ The WikiText language modeling dataset is a collection of over 100 million tokens extracted from the set of verified
55
+ Good and Featured articles on Wikipedia. Dependency Relations, POS, NER tags are marked with trankit and
56
+ entities are linked with entity-fishing.
57
+ The dataset is available under the Creative Commons Attribution-ShareAlike License.
58
+ """
59
+
60
+ _HOMEPAGE = "https://github.com/GabrielKP/svo/"
61
+
62
+ _LICENSE = "Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)"
63
+
64
+
65
+ FEATURES = datasets.Features(
66
+ {
67
+ "text": datasets.Value("string"),
68
+ "original_id": datasets.Value("int64"),
69
+ "tok_span": datasets.Sequence(feature=datasets.Sequence(feature=datasets.Value("int64"))),
70
+ "tok_upos": datasets.Sequence(feature=datasets.Value("string")),
71
+ "tok_xpos": datasets.Sequence(feature=datasets.Value("string")),
72
+ "tok_dephead": datasets.Sequence(feature=datasets.Value("int64")),
73
+ "tok_deprel": datasets.Sequence(feature=datasets.Value("string")),
74
+ "tok_lemma": datasets.Sequence(feature=datasets.Value("string")),
75
+ "tok_ner": datasets.Sequence(feature=datasets.Value("string")),
76
+ "ent_span": datasets.Sequence(feature=datasets.Sequence(feature=datasets.Value("int64"))),
77
+ "ent_wikipedia_external_ref": datasets.Sequence(feature=datasets.Value("string")),
78
+ "ent_ner": datasets.Sequence(feature=datasets.Value("string")),
79
+ "ent_domains": datasets.Sequence(
80
+ feature=datasets.Sequence(feature=datasets.Value("string"))
81
+ ),
82
+ }
83
+ )
84
+
85
+
86
+ class WikitextLinked(datasets.ArrowBasedBuilder):
87
+ """wikitext_linked is an annotated and linked version from wikitext. Wikitext is a
88
+ collection of over 100 million tokens extracted from the set of verified Good and
89
+ Featured articles on Wikipedia.
90
+ """
91
+
92
+ VERSION = datasets.Version("1.0.0")
93
+
94
+ BUILDER_CONFIGS = [
95
+ datasets.BuilderConfig(
96
+ name="wikitext2",
97
+ version=VERSION,
98
+ description="The small version",
99
+ data_dir="wikitext2",
100
+ ),
101
+ datasets.BuilderConfig(
102
+ name="wikitext103",
103
+ version=VERSION,
104
+ description="The big version",
105
+ data_dir="wikitext103",
106
+ ),
107
+ ]
108
+
109
+ def _info(self):
110
+ return datasets.DatasetInfo(
111
+ description=_DESCRIPTION,
112
+ citation=_CITATION,
113
+ license=_LICENSE,
114
+ features=FEATURES,
115
+ version=self.VERSION,
116
+ homepage=_HOMEPAGE,
117
+ )
118
+
119
+ def _split_generators(self, dl_manager):
120
+ return [
121
+ datasets.SplitGenerator(
122
+ name=datasets.Split.TRAIN,
123
+ # These kwargs will be passed to _generate_examples
124
+ gen_kwargs={
125
+ "filepath": os.path.join(self.config.data_dir, "train.parquet"),
126
+ },
127
+ ),
128
+ datasets.SplitGenerator(
129
+ name=datasets.Split.VALIDATION,
130
+ # These kwargs will be passed to _generate_examples
131
+ gen_kwargs={
132
+ "filepath": os.path.join(self.config.data_dir, "validation.parquet"),
133
+ },
134
+ ),
135
+ datasets.SplitGenerator(
136
+ name=datasets.Split.TEST,
137
+ # These kwargs will be passed to _generate_examples
138
+ gen_kwargs={
139
+ "filepath": os.path.join(self.config.data_dir, "test.parquet"),
140
+ },
141
+ ),
142
+ ]
143
+
144
+ # method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
145
+ def _generate_tables(self, filepath):
146
+ schema = pa.schema(FEATURES.type)
147
+ with open(filepath, "rb") as f:
148
+ parquet_file = pq.ParquetFile(f)
149
+ try:
150
+ for batch_idx, record_batch in enumerate(
151
+ parquet_file.iter_batches(batch_size=10000, columns=None)
152
+ ):
153
+ pa_table = pa.Table.from_batches([record_batch])
154
+ pa_table = pa.Table.from_arrays(
155
+ [pa_table[field.name] for field in schema], schema=schema
156
+ )
157
+ # Uncomment for debugging (will print the Arrow table size and elements)
158
+ # logger.warning(f"pa_table: {pa_table} num rows: {pa_table.num_rows}")
159
+ # logger.warning('\n'.join(str(pa_table.slice(i, 1).to_pydict()) for i in range(pa_table.num_rows)))
160
+ yield f"{batch_idx}", pa_table
161
+ except ValueError as e:
162
+ logger.error(f"Failed to read file '{filepath}' with error {type(e)}: {e}")
163
+ raise