system HF staff commited on
Commit
49197f8
0 Parent(s):

Update files from the datasets library (from 1.9.0)

Browse files

Release notes: https://github.com/huggingface/datasets/releases/tag/1.9.0

Files changed (4) hide show
  1. .gitattributes +27 -0
  2. README.md +525 -0
  3. dummy/af/0.0.0/dummy_data.zip +3 -0
  4. mc4.py +329 -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,525 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ pretty_name: mC4
3
+ annotations_creators:
4
+ - no-annotation
5
+ language_creators:
6
+ - found
7
+ languages:
8
+ - af
9
+ - am
10
+ - ar
11
+ - az
12
+ - be
13
+ - bg
14
+ - bg-Latn
15
+ - bn
16
+ - ca
17
+ - ceb
18
+ - co
19
+ - cs
20
+ - cy
21
+ - da
22
+ - de
23
+ - el
24
+ - el-Latn
25
+ - en
26
+ - eo
27
+ - es
28
+ - et
29
+ - eu
30
+ - fa
31
+ - fi
32
+ - fil
33
+ - fr
34
+ - fy
35
+ - ga
36
+ - gd
37
+ - gl
38
+ - gu
39
+ - ha
40
+ - haw
41
+ - hi
42
+ - hi-Latn
43
+ - hmn
44
+ - ht
45
+ - hu
46
+ - hy
47
+ - id
48
+ - ig
49
+ - is
50
+ - it
51
+ - iw
52
+ - ja
53
+ - ja-Latn
54
+ - jv
55
+ - ka
56
+ - kk
57
+ - km
58
+ - kn
59
+ - ko
60
+ - ku
61
+ - ky
62
+ - la
63
+ - lb
64
+ - lo
65
+ - lt
66
+ - lv
67
+ - mg
68
+ - mi
69
+ - mk
70
+ - ml
71
+ - mn
72
+ - mr
73
+ - ms
74
+ - mt
75
+ - my
76
+ - ne
77
+ - nl
78
+ - "no"
79
+ - ny
80
+ - pa
81
+ - pl
82
+ - ps
83
+ - pt
84
+ - ro
85
+ - ru
86
+ - ru-Latn
87
+ - sd
88
+ - si
89
+ - sk
90
+ - sl
91
+ - sm
92
+ - sn
93
+ - so
94
+ - sq
95
+ - sr
96
+ - st
97
+ - su
98
+ - sv
99
+ - sw
100
+ - ta
101
+ - te
102
+ - tg
103
+ - th
104
+ - tr
105
+ - uk
106
+ - und
107
+ - ur
108
+ - uz
109
+ - vi
110
+ - xh
111
+ - yi
112
+ - yo
113
+ - zh
114
+ - zh-Latn
115
+ - zu
116
+ licenses:
117
+ - odc-by-1-0
118
+ multilinguality:
119
+ - multilingual
120
+ size_categories:
121
+ - n<1K
122
+ - 1K<n<10K
123
+ - 10K<n<100K
124
+ - 100K<n<1M
125
+ - 1M<n<10M
126
+ - 10M<n<100M
127
+ - 100M<n<1B
128
+ - 1B<n<10B
129
+ source_datasets:
130
+ - original
131
+ task_categories:
132
+ - sequence-modeling
133
+ task_ids:
134
+ - language-modeling
135
+ paperswithcode_id: mc4
136
+ ---
137
+
138
+ # Dataset Card for mC4
139
+
140
+ ## Table of Contents
141
+
142
+ - [Dataset Card for mC4](#dataset-card-for-mc4)
143
+ - [Table of Contents](#table-of-contents)
144
+ - [Dataset Description](#dataset-description)
145
+ - [Dataset Summary](#dataset-summary)
146
+ - [Supported Tasks and Leaderboards](#supported-tasks-and-leaderboards)
147
+ - [Languages](#languages)
148
+ - [Dataset Structure](#dataset-structure)
149
+ - [Data Instances](#data-instances)
150
+ - [Data Fields](#data-fields)
151
+ - [Data Splits](#data-splits)
152
+ - [Dataset Creation](#dataset-creation)
153
+ - [Curation Rationale](#curation-rationale)
154
+ - [Source Data](#source-data)
155
+ - [Initial Data Collection and Normalization](#initial-data-collection-and-normalization)
156
+ - [Who are the source language producers?](#who-are-the-source-language-producers)
157
+ - [Annotations](#annotations)
158
+ - [Annotation process](#annotation-process)
159
+ - [Who are the annotators?](#who-are-the-annotators)
160
+ - [Personal and Sensitive Information](#personal-and-sensitive-information)
161
+ - [Considerations for Using the Data](#considerations-for-using-the-data)
162
+ - [Social Impact of Dataset](#social-impact-of-dataset)
163
+ - [Discussion of Biases](#discussion-of-biases)
164
+ - [Other Known Limitations](#other-known-limitations)
165
+ - [Additional Information](#additional-information)
166
+ - [Dataset Curators](#dataset-curators)
167
+ - [Licensing Information](#licensing-information)
168
+ - [Citation Information](#citation-information)
169
+ - [Contributions](#contributions)
170
+
171
+ ## Dataset Description
172
+
173
+ - **Homepage:** https://huggingface.co/datasets/allenai/c4
174
+ - **Paper:** https://arxiv.org/abs/1910.10683
175
+
176
+ ### Dataset Summary
177
+
178
+ A multilingual colossal, cleaned version of Common Crawl's web crawl corpus. Based on Common Crawl dataset: "https://commoncrawl.org".
179
+
180
+ This is the version prepared by AllenAI, hosted at this address: https://huggingface.co/datasets/allenai/c4
181
+
182
+ 108 languages are available and are reported in the table below.
183
+
184
+ Note that the languages that end with "-Latn" are simply romanized variants, i.e. written using the Latin script.
185
+
186
+ | language code | language name |
187
+ |:----------------|:---------------------|
188
+ | af | Afrikaans |
189
+ | am | Amharic |
190
+ | ar | Arabic |
191
+ | az | Azerbaijani |
192
+ | be | Belarusian |
193
+ | bg | Bulgarian |
194
+ | bg-Latn | Bulgarian (Latin) |
195
+ | bn | Bangla |
196
+ | ca | Catalan |
197
+ | ceb | Cebuano |
198
+ | co | Corsican |
199
+ | cs | Czech |
200
+ | cy | Welsh |
201
+ | da | Danish |
202
+ | de | German |
203
+ | el | Greek |
204
+ | el-Latn | Greek (Latin) |
205
+ | en | English |
206
+ | eo | Esperanto |
207
+ | es | Spanish |
208
+ | et | Estonian |
209
+ | eu | Basque |
210
+ | fa | Persian |
211
+ | fi | Finnish |
212
+ | fil | Filipino |
213
+ | fr | French |
214
+ | fy | Western Frisian |
215
+ | ga | Irish |
216
+ | gd | Scottish Gaelic |
217
+ | gl | Galician |
218
+ | gu | Gujarati |
219
+ | ha | Hausa |
220
+ | haw | Hawaiian |
221
+ | hi | Hindi |
222
+ | hi-Latn | Hindi (Latin script) |
223
+ | hmn | Hmong, Mong |
224
+ | ht | Haitian |
225
+ | hu | Hungarian |
226
+ | hy | Armenian |
227
+ | id | Indonesian |
228
+ | ig | Igbo |
229
+ | is | Icelandic |
230
+ | it | Italian |
231
+ | iw | former Hebrew |
232
+ | ja | Japanese |
233
+ | ja-Latn | Japanese (Latin) |
234
+ | jv | Javanese |
235
+ | ka | Georgian |
236
+ | kk | Kazakh |
237
+ | km | Khmer |
238
+ | kn | Kannada |
239
+ | ko | Korean |
240
+ | ku | Kurdish |
241
+ | ky | Kyrgyz |
242
+ | la | Latin |
243
+ | lb | Luxembourgish |
244
+ | lo | Lao |
245
+ | lt | Lithuanian |
246
+ | lv | Latvian |
247
+ | mg | Malagasy |
248
+ | mi | Maori |
249
+ | mk | Macedonian |
250
+ | ml | Malayalam |
251
+ | mn | Mongolian |
252
+ | mr | Marathi |
253
+ | ms | Malay |
254
+ | mt | Maltese |
255
+ | my | Burmese |
256
+ | ne | Nepali |
257
+ | nl | Dutch |
258
+ | no | Norwegian |
259
+ | ny | Nyanja |
260
+ | pa | Punjabi |
261
+ | pl | Polish |
262
+ | ps | Pashto |
263
+ | pt | Portuguese |
264
+ | ro | Romanian |
265
+ | ru | Russian |
266
+ | ru-Latn | Russian (Latin) |
267
+ | sd | Sindhi |
268
+ | si | Sinhala |
269
+ | sk | Slovak |
270
+ | sl | Slovenian |
271
+ | sm | San Marino |
272
+ | sn | Shona |
273
+ | so | Somali |
274
+ | sq | Albanian |
275
+ | sr | Serbian |
276
+ | st | Southern Sotho |
277
+ | su | Sundanese |
278
+ | sv | Swedish |
279
+ | sw | Swahili |
280
+ | ta | Tamil |
281
+ | te | Telugu |
282
+ | tg | Tajik |
283
+ | th | Thai |
284
+ | tr | Turkish |
285
+ | uk | Ukrainian |
286
+ | und | Unknown language |
287
+ | ur | Urdu |
288
+ | uz | Uzbek |
289
+ | vi | Vietnamese |
290
+ | xh | Xhosa |
291
+ | yi | Yiddish |
292
+ | yo | Yoruba |
293
+ | zh | Chinese |
294
+ | zh-Latn | Chinese (Latin) |
295
+ | zu | Zulu |
296
+
297
+ You can load the mC4 subset of any language like this:
298
+
299
+ ```python
300
+ from datasets import load_dataset
301
+
302
+ en_mc4 = load_dataset("mc4", "en")
303
+ ```
304
+
305
+ And if you can even specify a list of languages:
306
+
307
+ ```python
308
+ from datasets import load_dataset
309
+
310
+ mc4_subset_with_five_languages = load_dataset("mc4", languages=["en", "fr", "es", "de", "zh"])
311
+ ```
312
+
313
+ ### Supported Tasks and Leaderboards
314
+
315
+ mC4 is mainly intended to pretrain language models and word representations.
316
+
317
+ ### Languages
318
+
319
+ The dataset supports 108 languages.
320
+
321
+ ## Dataset Structure
322
+
323
+ ### Data Instances
324
+
325
+ An example form the `en` config is:
326
+
327
+ ```
328
+ {'timestamp': '2018-06-24T01:32:39Z',
329
+ 'text': 'Farm Resources in Plumas County\nShow Beginning Farmer Organizations & Professionals (304)\nThere are 304 resources serving Plumas County in the following categories:\nMap of Beginning Farmer Organizations & Professionals serving Plumas County\nVictoria Fisher - Office Manager - Loyalton, CA\nAmy Lynn Rasband - UCCE Plumas-Sierra Administrative Assistant II - Quincy , CA\nShow Farm Income Opportunities Organizations & Professionals (353)\nThere are 353 resources serving Plumas County in the following categories:\nFarm Ranch And Forest Retailers (18)\nMap of Farm Income Opportunities Organizations & Professionals serving Plumas County\nWarner Valley Wildlife Area - Plumas County\nShow Farm Resources Organizations & Professionals (297)\nThere are 297 resources serving Plumas County in the following categories:\nMap of Farm Resources Organizations & Professionals serving Plumas County\nThere are 57 resources serving Plumas County in the following categories:\nMap of Organic Certification Organizations & Professionals serving Plumas County',
330
+ 'url': 'http://www.californialandcan.org/Plumas/Farm-Resources/'}
331
+ ```
332
+
333
+ ### Data Fields
334
+
335
+ The data have several fields:
336
+
337
+ - `url`: url of the source as a string
338
+ - `text`: text content as a string
339
+ - `timestamp`: timestamp as a string
340
+
341
+ ### Data Splits
342
+
343
+ To build mC4, the authors used [CLD3](https://github.com/google/cld3) to identify over 100 languages. The resulting mC4 subsets for each language are reported in this table:
344
+
345
+ | config | train | validation |
346
+ |:---------|:--------|:-------------|
347
+ | af | ? | ? |
348
+ | am | ? | ? |
349
+ | ar | ? | ? |
350
+ | az | ? | ? |
351
+ | be | ? | ? |
352
+ | bg | ? | ? |
353
+ | bg-Latn | ? | ? |
354
+ | bn | ? | ? |
355
+ | ca | ? | ? |
356
+ | ceb | ? | ? |
357
+ | co | ? | ? |
358
+ | cs | ? | ? |
359
+ | cy | ? | ? |
360
+ | da | ? | ? |
361
+ | de | ? | ? |
362
+ | el | ? | ? |
363
+ | el-Latn | ? | ? |
364
+ | en | ? | ? |
365
+ | eo | ? | ? |
366
+ | es | ? | ? |
367
+ | et | ? | ? |
368
+ | eu | ? | ? |
369
+ | fa | ? | ? |
370
+ | fi | ? | ? |
371
+ | fil | ? | ? |
372
+ | fr | ? | ? |
373
+ | fy | ? | ? |
374
+ | ga | ? | ? |
375
+ | gd | ? | ? |
376
+ | gl | ? | ? |
377
+ | gu | ? | ? |
378
+ | ha | ? | ? |
379
+ | haw | ? | ? |
380
+ | hi | ? | ? |
381
+ | hi-Latn | ? | ? |
382
+ | hmn | ? | ? |
383
+ | ht | ? | ? |
384
+ | hu | ? | ? |
385
+ | hy | ? | ? |
386
+ | id | ? | ? |
387
+ | ig | ? | ? |
388
+ | is | ? | ? |
389
+ | it | ? | ? |
390
+ | iw | ? | ? |
391
+ | ja | ? | ? |
392
+ | ja-Latn | ? | ? |
393
+ | jv | ? | ? |
394
+ | ka | ? | ? |
395
+ | kk | ? | ? |
396
+ | km | ? | ? |
397
+ | kn | ? | ? |
398
+ | ko | ? | ? |
399
+ | ku | ? | ? |
400
+ | ky | ? | ? |
401
+ | la | ? | ? |
402
+ | lb | ? | ? |
403
+ | lo | ? | ? |
404
+ | lt | ? | ? |
405
+ | lv | ? | ? |
406
+ | mg | ? | ? |
407
+ | mi | ? | ? |
408
+ | mk | ? | ? |
409
+ | ml | ? | ? |
410
+ | mn | ? | ? |
411
+ | mr | ? | ? |
412
+ | ms | ? | ? |
413
+ | mt | ? | ? |
414
+ | my | ? | ? |
415
+ | ne | ? | ? |
416
+ | nl | ? | ? |
417
+ | no | ? | ? |
418
+ | ny | ? | ? |
419
+ | pa | ? | ? |
420
+ | pl | ? | ? |
421
+ | ps | ? | ? |
422
+ | pt | ? | ? |
423
+ | ro | ? | ? |
424
+ | ru | ? | ? |
425
+ | ru-Latn | ? | ? |
426
+ | sd | ? | ? |
427
+ | si | ? | ? |
428
+ | sk | ? | ? |
429
+ | sl | ? | ? |
430
+ | sm | ? | ? |
431
+ | sn | ? | ? |
432
+ | so | ? | ? |
433
+ | sq | ? | ? |
434
+ | sr | ? | ? |
435
+ | st | ? | ? |
436
+ | su | ? | ? |
437
+ | sv | ? | ? |
438
+ | sw | ? | ? |
439
+ | ta | ? | ? |
440
+ | te | ? | ? |
441
+ | tg | ? | ? |
442
+ | th | ? | ? |
443
+ | tr | ? | ? |
444
+ | uk | ? | ? |
445
+ | und | ? | ? |
446
+ | ur | ? | ? |
447
+ | uz | ? | ? |
448
+ | vi | ? | ? |
449
+ | xh | ? | ? |
450
+ | yi | ? | ? |
451
+ | yo | ? | ? |
452
+ | zh | ? | ? |
453
+ | zh-Latn | ? | ? |
454
+ | zu | ? | ? |
455
+
456
+ ## Dataset Creation
457
+
458
+ ### Curation Rationale
459
+
460
+ [More Information Needed]
461
+
462
+ ### Source Data
463
+
464
+ #### Initial Data Collection and Normalization
465
+
466
+ [More Information Needed]
467
+
468
+ #### Who are the source language producers?
469
+
470
+ [More Information Needed]
471
+
472
+ ### Annotations
473
+
474
+ #### Annotation process
475
+
476
+ [More Information Needed]
477
+
478
+ #### Who are the annotators?
479
+
480
+ [More Information Needed]
481
+
482
+ ### Personal and Sensitive Information
483
+
484
+ [More Information Needed]
485
+
486
+ ## Considerations for Using the Data
487
+
488
+ ### Social Impact of Dataset
489
+
490
+ [More Information Needed]
491
+
492
+ ### Discussion of Biases
493
+
494
+ [More Information Needed]
495
+
496
+ ### Other Known Limitations
497
+
498
+ [More Information Needed]
499
+
500
+ ## Additional Information
501
+
502
+ ### Dataset Curators
503
+
504
+ [More Information Needed]
505
+
506
+ ### Licensing Information
507
+
508
+ AllenAI are releasing this dataset under the terms of ODC-BY. By using this, you are also bound by the Common Crawl terms of use in respect of the content contained in the dataset.
509
+
510
+ ### Citation Information
511
+
512
+ ```
513
+ @article{2019t5,
514
+ author = {Colin Raffel and Noam Shazeer and Adam Roberts and Katherine Lee and Sharan Narang and Michael Matena and Yanqi Zhou and Wei Li and Peter J. Liu},
515
+ title = {Exploring the Limits of Transfer Learning with a Unified Text-to-Text Transformer},
516
+ journal = {arXiv e-prints},
517
+ year = {2019},
518
+ archivePrefix = {arXiv},
519
+ eprint = {1910.10683},
520
+ }
521
+ ```
522
+
523
+ ### Contributions
524
+
525
+ Thanks to [@dirkgr](https://github.com/dirkgr) and [@lhoestq](https://github.com/lhoestq) for adding this dataset.
dummy/af/0.0.0/dummy_data.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:218653d57c80e3175933b9fb757fb499a6bee3893ff3e913753333a7bfc485a5
3
+ size 8543
mc4.py ADDED
@@ -0,0 +1,329 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """mC4 dataset based on Common Crawl."""
2
+
3
+
4
+ import gzip
5
+ import json
6
+
7
+ import datasets
8
+
9
+
10
+ logger = datasets.logging.get_logger(__name__)
11
+
12
+
13
+ _DESCRIPTION = """\
14
+ A colossal, cleaned version of Common Crawl's web crawl corpus.
15
+
16
+ Based on Common Crawl dataset: "https://commoncrawl.org".
17
+
18
+ This is the processed version of Google's mC4 dataset by AllenAI.
19
+ """
20
+
21
+ _CITATION = """
22
+ @article{2019t5,
23
+ author = {Colin Raffel and Noam Shazeer and Adam Roberts and Katherine Lee and Sharan Narang and Michael Matena and Yanqi Zhou and Wei Li and Peter J. Liu},
24
+ title = {Exploring the Limits of Transfer Learning with a Unified Text-to-Text Transformer},
25
+ journal = {arXiv e-prints},
26
+ year = {2019},
27
+ archivePrefix = {arXiv},
28
+ eprint = {1910.10683},
29
+ }
30
+ """
31
+
32
+ _URL = "https://github.com/allenai/allennlp/discussions/5056"
33
+
34
+ _DATA_URL = "https://huggingface.co/datasets/allenai/c4/resolve/1ddc917116b730e1859edef32896ec5c16be51d0/multilingual/c4-{language}{split_suffix}.tfrecord-{index:05d}-of-{n_shards:05d}.json.gz"
35
+
36
+ _LANGUAGES = [
37
+ "af",
38
+ "am",
39
+ "ar",
40
+ "az",
41
+ "be",
42
+ "bg",
43
+ "bg-Latn",
44
+ "bn",
45
+ "ca",
46
+ "ceb",
47
+ "co",
48
+ "cs",
49
+ "cy",
50
+ "da",
51
+ "de",
52
+ "el",
53
+ "el-Latn",
54
+ "en",
55
+ "eo",
56
+ "es",
57
+ "et",
58
+ "eu",
59
+ "fa",
60
+ "fi",
61
+ "fil",
62
+ "fr",
63
+ "fy",
64
+ "ga",
65
+ "gd",
66
+ "gl",
67
+ "gu",
68
+ "ha",
69
+ "haw",
70
+ "hi",
71
+ "hi-Latn",
72
+ "hmn",
73
+ "ht",
74
+ "hu",
75
+ "hy",
76
+ "id",
77
+ "ig",
78
+ "is",
79
+ "it",
80
+ "iw",
81
+ "ja",
82
+ "ja-Latn",
83
+ "jv",
84
+ "ka",
85
+ "kk",
86
+ "km",
87
+ "kn",
88
+ "ko",
89
+ "ku",
90
+ "ky",
91
+ "la",
92
+ "lb",
93
+ "lo",
94
+ "lt",
95
+ "lv",
96
+ "mg",
97
+ "mi",
98
+ "mk",
99
+ "ml",
100
+ "mn",
101
+ "mr",
102
+ "ms",
103
+ "mt",
104
+ "my",
105
+ "ne",
106
+ "nl",
107
+ "no",
108
+ "ny",
109
+ "pa",
110
+ "pl",
111
+ "ps",
112
+ "pt",
113
+ "ro",
114
+ "ru",
115
+ "ru-Latn",
116
+ "sd",
117
+ "si",
118
+ "sk",
119
+ "sl",
120
+ "sm",
121
+ "sn",
122
+ "so",
123
+ "sq",
124
+ "sr",
125
+ "st",
126
+ "su",
127
+ "sv",
128
+ "sw",
129
+ "ta",
130
+ "te",
131
+ "tg",
132
+ "th",
133
+ "tr",
134
+ "uk",
135
+ "und",
136
+ "ur",
137
+ "uz",
138
+ "vi",
139
+ "xh",
140
+ "yi",
141
+ "yo",
142
+ "zh",
143
+ "zh-Latn",
144
+ "zu",
145
+ ]
146
+
147
+ _N_SHARDS_PER_SPLIT = {
148
+ "af": {"train": 64, "validation": 1},
149
+ "am": {"train": 16, "validation": 1},
150
+ "ar": {"train": 1024, "validation": 4},
151
+ "az": {"train": 256, "validation": 1},
152
+ "be": {"train": 128, "validation": 1},
153
+ "bg": {"train": 1024, "validation": 1},
154
+ "bg-Latn": {"train": 4, "validation": 1},
155
+ "bn": {"train": 512, "validation": 1},
156
+ "ca": {"train": 512, "validation": 1},
157
+ "ceb": {"train": 8, "validation": 1},
158
+ "co": {"train": 8, "validation": 1},
159
+ "cs": {"train": 1024, "validation": 2},
160
+ "cy": {"train": 256, "validation": 1},
161
+ "da": {"train": 1024, "validation": 1},
162
+ "de": {"train": 2048, "validation": 16},
163
+ "el": {"train": 1024, "validation": 2},
164
+ "el-Latn": {"train": 16, "validation": 1},
165
+ "en": {"train": 11264, "validation": 128},
166
+ "eo": {"train": 32, "validation": 1},
167
+ "es": {"train": 2048, "validation": 16},
168
+ "et": {"train": 256, "validation": 1},
169
+ "eu": {"train": 64, "validation": 1},
170
+ "fa": {"train": 1024, "validation": 2},
171
+ "fi": {"train": 1024, "validation": 1},
172
+ "fil": {"train": 64, "validation": 1},
173
+ "fr": {"train": 2048, "validation": 16},
174
+ "fy": {"train": 16, "validation": 1},
175
+ "ga": {"train": 16, "validation": 1},
176
+ "gd": {"train": 16, "validation": 1},
177
+ "gl": {"train": 128, "validation": 1},
178
+ "gu": {"train": 64, "validation": 1},
179
+ "ha": {"train": 8, "validation": 1},
180
+ "haw": {"train": 2, "validation": 1},
181
+ "hi": {"train": 1024, "validation": 2},
182
+ "hi-Latn": {"train": 16, "validation": 1},
183
+ "hmn": {"train": 8, "validation": 1},
184
+ "ht": {"train": 8, "validation": 1},
185
+ "hu": {"train": 1024, "validation": 2},
186
+ "hy": {"train": 128, "validation": 1},
187
+ "id": {"train": 1024, "validation": 4},
188
+ "ig": {"train": 4, "validation": 1},
189
+ "is": {"train": 128, "validation": 1},
190
+ "it": {"train": 1024, "validation": 8},
191
+ "iw": {"train": 1024, "validation": 1},
192
+ "ja": {"train": 1024, "validation": 8},
193
+ "ja-Latn": {"train": 8, "validation": 1},
194
+ "jv": {"train": 8, "validation": 1},
195
+ "ka": {"train": 256, "validation": 1},
196
+ "kk": {"train": 256, "validation": 1},
197
+ "km": {"train": 64, "validation": 1},
198
+ "kn": {"train": 64, "validation": 1},
199
+ "ko": {"train": 1024, "validation": 1},
200
+ "ku": {"train": 16, "validation": 1},
201
+ "ky": {"train": 64, "validation": 1},
202
+ "la": {"train": 64, "validation": 1},
203
+ "lb": {"train": 32, "validation": 1},
204
+ "lo": {"train": 8, "validation": 1},
205
+ "lt": {"train": 512, "validation": 1},
206
+ "lv": {"train": 256, "validation": 1},
207
+ "mg": {"train": 8, "validation": 1},
208
+ "mi": {"train": 4, "validation": 1},
209
+ "mk": {"train": 128, "validation": 1},
210
+ "ml": {"train": 128, "validation": 1},
211
+ "mn": {"train": 128, "validation": 1},
212
+ "mr": {"train": 1024, "validation": 1},
213
+ "ms": {"train": 512, "validation": 1},
214
+ "mt": {"train": 128, "validation": 1},
215
+ "my": {"train": 64, "validation": 1},
216
+ "ne": {"train": 256, "validation": 1},
217
+ "nl": {"train": 1024, "validation": 4},
218
+ "no": {"train": 1024, "validation": 1},
219
+ "ny": {"train": 4, "validation": 1},
220
+ "pa": {"train": 32, "validation": 1},
221
+ "pl": {"train": 1024, "validation": 4},
222
+ "ps": {"train": 16, "validation": 1},
223
+ "pt": {"train": 1024, "validation": 4},
224
+ "ro": {"train": 1024, "validation": 2},
225
+ "ru": {"train": 4096, "validation": 32},
226
+ "ru-Latn": {"train": 32, "validation": 1},
227
+ "sd": {"train": 64, "validation": 1},
228
+ "si": {"train": 64, "validation": 1},
229
+ "sk": {"train": 512, "validation": 1},
230
+ "sl": {"train": 256, "validation": 1},
231
+ "sm": {"train": 4, "validation": 1},
232
+ "sn": {"train": 8, "validation": 1},
233
+ "so": {"train": 64, "validation": 1},
234
+ "sq": {"train": 128, "validation": 1},
235
+ "sr": {"train": 256, "validation": 1},
236
+ "st": {"train": 2, "validation": 1},
237
+ "su": {"train": 4, "validation": 1},
238
+ "sv": {"train": 1024, "validation": 2},
239
+ "sw": {"train": 32, "validation": 1},
240
+ "ta": {"train": 256, "validation": 1},
241
+ "te": {"train": 128, "validation": 1},
242
+ "tg": {"train": 64, "validation": 1},
243
+ "th": {"train": 1024, "validation": 1},
244
+ "tr": {"train": 1024, "validation": 4},
245
+ "uk": {"train": 1024, "validation": 2},
246
+ "und": {"train": 3072, "validation": 32},
247
+ "ur": {"train": 128, "validation": 1},
248
+ "uz": {"train": 32, "validation": 1},
249
+ "vi": {"train": 1024, "validation": 4},
250
+ "xh": {"train": 2, "validation": 1},
251
+ "yi": {"train": 16, "validation": 1},
252
+ "yo": {"train": 2, "validation": 1},
253
+ "zh": {"train": 1024, "validation": 2},
254
+ "zh-Latn": {"train": 8, "validation": 1},
255
+ "zu": {"train": 8, "validation": 1},
256
+ }
257
+
258
+
259
+ class Mc4Config(datasets.BuilderConfig):
260
+ """BuilderConfig for mC4."""
261
+
262
+ def __init__(self, *args, languages, **kwargs):
263
+ """BuilderConfig for mC4.
264
+ Args:
265
+ languages (:obj:`List[str]`): list of languages to load
266
+ **kwargs: keyword arguments forwarded to super.
267
+ """
268
+ super().__init__(
269
+ *args,
270
+ name="+".join(languages),
271
+ **kwargs,
272
+ )
273
+ self.languages = languages
274
+
275
+
276
+ class Mc4(datasets.GeneratorBasedBuilder):
277
+ """mC4, a colossal, cleaned version of Common Crawl's web crawl corpus."""
278
+
279
+ BUILDER_CONFIGS = [Mc4Config(languages=[lang]) for lang in _LANGUAGES]
280
+ BUILDER_CONFIG_CLASS = Mc4Config
281
+
282
+ def _info(self):
283
+ return datasets.DatasetInfo(
284
+ description=_DESCRIPTION,
285
+ features=datasets.Features(
286
+ {
287
+ "text": datasets.Value("string"),
288
+ "timestamp": datasets.Value("string"),
289
+ "url": datasets.Value("string"),
290
+ }
291
+ ),
292
+ supervised_keys=None,
293
+ homepage=_URL,
294
+ citation=_CITATION,
295
+ )
296
+
297
+ def _split_generators(self, dl_manager):
298
+ data_urls = {}
299
+ for split in ["train", "validation"]:
300
+ data_urls[split] = [
301
+ _DATA_URL.format(
302
+ language=self.config.name,
303
+ split_suffix="-validation" if split == "validation" else "",
304
+ index=index,
305
+ n_shards=_N_SHARDS_PER_SPLIT[lang][split],
306
+ )
307
+ for lang in self.config.languages
308
+ for index in range(_N_SHARDS_PER_SPLIT[lang][split])
309
+ ]
310
+ train_downloaded_files = dl_manager.download(data_urls["train"])
311
+ validation_downloaded_files = dl_manager.download(data_urls["validation"])
312
+ return [
313
+ datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepaths": train_downloaded_files}),
314
+ datasets.SplitGenerator(
315
+ name=datasets.Split.VALIDATION, gen_kwargs={"filepaths": validation_downloaded_files}
316
+ ),
317
+ ]
318
+
319
+ def _generate_examples(self, filepaths):
320
+ """This function returns the examples in the raw (text) form by iterating on all the files."""
321
+ id_ = 0
322
+ for filepath in filepaths:
323
+ logger.info("generating examples from = %s", filepath)
324
+ with gzip.open(open(filepath, "rb"), "rt", encoding="utf-8") as f:
325
+ for line in f:
326
+ if line:
327
+ example = json.loads(line)
328
+ yield id_, example
329
+ id_ += 1