tinymix: 1000M, 100M, 10M, 1M
Browse files- README.md +68 -45
- code/assemble.py +74 -0
- code/build_pool.py +620 -0
- code/publish.py +26 -22
- code/sources.py +48 -20
- data/1000M/train-00000.parquet +3 -0
- data/1000M/train-00001.parquet +3 -0
- data/1000M/train-00002.parquet +3 -0
- data/1000M/train-00003.parquet +3 -0
- data/1000M/train-00004.parquet +3 -0
- data/1000M/train-00005.parquet +3 -0
- data/1000M/train-00006.parquet +3 -0
- data/1000M/train-00007.parquet +3 -0
- data/1000M/train-00008.parquet +3 -0
- data/1000M/train-00009.parquet +3 -0
- data/1000M/train-00010.parquet +3 -0
- data/1000M/train-00011.parquet +3 -0
- data/1000M/train-00012.parquet +3 -0
- data/1000M/train-00013.parquet +3 -0
- data/1000M/train-00014.parquet +3 -0
- data/1000M/train-00015.parquet +3 -0
- data/1000M/train-00016.parquet +3 -0
- data/1000M/train-00017.parquet +3 -0
- data/1000M/train-00018.parquet +3 -0
- data/1000M/train-00019.parquet +3 -0
- data/1000M/validation_books.parquet +3 -0
- data/1000M/validation_dialogue.parquet +3 -0
- data/1000M/validation_expository.parquet +3 -0
- data/1000M/validation_narrative.parquet +3 -0
- data/1000M/validation_news.parquet +3 -0
- data/1000M/validation_poetry.parquet +3 -0
README.md
CHANGED
|
@@ -6,7 +6,7 @@ license_name: mixed-per-source
|
|
| 6 |
license_link: https://huggingface.co/datasets/jncarlo/tinymix#sources-and-licensing
|
| 7 |
pretty_name: tinymix
|
| 8 |
size_categories:
|
| 9 |
-
-
|
| 10 |
task_categories:
|
| 11 |
- text-generation
|
| 12 |
tags:
|
|
@@ -19,7 +19,7 @@ configs:
|
|
| 19 |
- config_name: 1M
|
| 20 |
data_files:
|
| 21 |
- split: train
|
| 22 |
-
path: data/1M/train.parquet
|
| 23 |
- split: validation_dialogue
|
| 24 |
path: data/1M/validation_dialogue.parquet
|
| 25 |
- split: validation_expository
|
|
@@ -29,7 +29,7 @@ configs:
|
|
| 29 |
- config_name: 10M
|
| 30 |
data_files:
|
| 31 |
- split: train
|
| 32 |
-
path: data/10M/train.parquet
|
| 33 |
- split: validation_dialogue
|
| 34 |
path: data/10M/validation_dialogue.parquet
|
| 35 |
- split: validation_expository
|
|
@@ -39,7 +39,7 @@ configs:
|
|
| 39 |
- config_name: 100M
|
| 40 |
data_files:
|
| 41 |
- split: train
|
| 42 |
-
path: data/100M/train.parquet
|
| 43 |
- split: validation_books
|
| 44 |
path: data/100M/validation_books.parquet
|
| 45 |
- split: validation_dialogue
|
|
@@ -52,11 +52,27 @@ configs:
|
|
| 52 |
path: data/100M/validation_news.parquet
|
| 53 |
- split: validation_poetry
|
| 54 |
path: data/100M/validation_poetry.parquet
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
---
|
| 56 |
|
| 57 |
# tinymix
|
| 58 |
|
| 59 |
-
Small, **genre-balanced English pretraining corpora** in
|
| 60 |
very small language models. The mix combines synthetic child-level stories and dialogue, simplified real text,
|
| 61 |
encyclopedic and didactic text, books, poetry and news, all filtered toward clear, self-contained documents. It is
|
| 62 |
inspired by TinyStories, SimpleStories, TinyHelen and the BabyLM challenge.
|
|
@@ -64,7 +80,7 @@ inspired by TinyStories, SimpleStories, TinyHelen and the BabyLM challenge.
|
|
| 64 |
What is different from using those datasets directly:
|
| 65 |
|
| 66 |
- **Several kinds of text in one mix** (narrative, dialogue and chat, expository, books, poetry, news), not only stories or only conversations.
|
| 67 |
-
- **
|
| 68 |
- **No non-commercial sources.** TinyChat (CC-BY-NC) and the BabyLM corpus (no clear license, includes subtitle and child-speech data) were left out on purpose.
|
| 69 |
- **Provenance per document** (`source`, `genre`) and **validation splits per genre**, to see which kind of text a model is weak at.
|
| 70 |
- The whole pipeline is included (`code/`) and every filter decision is documented below.
|
|
@@ -76,6 +92,7 @@ What is different from using those datasets directly:
|
|
| 76 |
| `1M` | 1.0M | 4,135 | ~1.3M |
|
| 77 |
| `10M` | 9.96M | 42,117 | ~12.9M |
|
| 78 |
| `100M` | 99.5M | 338,230 | ~129.3M |
|
|
|
|
| 79 |
|
| 80 |
Words are whitespace-separated words in `train`. Each subset also has about 0.5% of the documents per genre held out as `validation_<genre>` splits
|
| 81 |
(at least one document per genre; the `1M` validation splits are therefore tiny, 4 to 8 documents each, and noisy).
|
|
@@ -94,41 +111,46 @@ Documents are independent; join them with an end-of-text token when training. Di
|
|
| 94 |
|
| 95 |
Share of training words by genre:
|
| 96 |
|
| 97 |
-
| Genre | 1M | 10M | 100M |
|
| 98 |
-
|---|---|---|---|
|
| 99 |
-
| narrative | 38.0% | 35.0% | 21.0% |
|
| 100 |
-
| dialogue | 21.9% | 25.0% | 21.0% |
|
| 101 |
-
| expository | 40.1% | 40.0% | 48.0% |
|
| 102 |
-
| books | 0% | 0% | 8.0% |
|
| 103 |
-
| poetry | 0% | 0% | 1.0% |
|
| 104 |
-
| news | 0% | 0% | 1.0% |
|
| 105 |
|
| 106 |
Million words per source:
|
| 107 |
|
| 108 |
-
| Source | 1M (M words) | 10M (M words) | 100M (M words) |
|
| 109 |
-
|---|---|---|---|
|
| 110 |
-
| TinyStories V2 (GPT-4 split) | 0.189 | 1.494 | 7.959 |
|
| 111 |
-
| SimpleStories | 0.189 | 1.99 | 7.964 |
|
| 112 |
-
| Cosmopedia v0.1, `stories` | 0 | 0 | 4.972 |
|
| 113 |
-
| TinyDialogues | 0.12 | 1.494 | 6.969 |
|
| 114 |
-
| SODA | 0.099 | 0.994 | 8.955 |
|
| 115 |
-
| UltraChat 200k | 0 | 0 | 3.974 |
|
| 116 |
-
| SmolTalk (everyday-conversations, smol-summarize, smol-rewrite) | 0 | 0 | 0.994 |
|
| 117 |
-
| TinyHelen Leaner-Pretrain (book, conversation, textbook, web, wiki) | 0.15 | 1.499 | 9.946 |
|
| 118 |
-
| Simple English Wikipedia (20231101.simple) | 0.1 | 0.996 | 9.951 |
|
| 119 |
-
|
|
| 120 |
-
| Cosmopedia
|
| 121 |
-
|
|
| 122 |
-
|
|
| 123 |
-
|
|
| 124 |
-
| Gutenberg
|
| 125 |
-
|
|
|
|
|
| 126 |
|
| 127 |
The 10M and 100M subsets are within about 1% of their targets (train plus validation splits). In the 10M build,
|
| 128 |
sources that could not fill their quota with the filters (Simple English Wikipedia, Cosmopedia v0.1) were topped up by
|
| 129 |
same-genre substitute sources (tiny-textbooks, Cosmopedia v2), capped per source; that is why `tiny-textbooks` appears
|
| 130 |
there. The 1M subset keeps the 10M proportions except that Cosmopedia stories (not in the 10M mix) were replaced by TinyStories and SimpleStories.
|
| 131 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 132 |
## How it was built
|
| 133 |
|
| 134 |
1. **Normalisation**: `ftfy`, NFKC, ASCII quotes and dashes, whitespace; URLs, e-mails, phone numbers, code, LaTeX and HTML removed. Documents with any character outside ASCII, Latin-1 and Latin Extended-A letters, common punctuation and a few math symbols are rejected whole (reason `charset` in the build stats).
|
|
@@ -138,19 +160,19 @@ there. The 1M subset keeps the 10M proportions except that Cosmopedia stories (n
|
|
| 138 |
5. **Deduplication across all sources**: exact hash and MinHash LSH (5-word shingles, Jaccard >= 0.8).
|
| 139 |
6. **Complexity control by size** (vocabulary coverage = share of lowercase tokens inside the top-N English words of `wordfreq`):
|
| 140 |
|
| 141 |
-
| | 10M | 100M |
|
| 142 |
-
|---|---|---|
|
| 143 |
-
| Reference vocabulary | top 8k | top 15k |
|
| 144 |
-
| Min vocabulary coverage | 90% | 90% |
|
| 145 |
-
| Max Flesch-Kincaid grade (narrative, news, books) | 5 | 8 |
|
| 146 |
-
| Max Flesch-Kincaid grade (expository) | 9 | 10 |
|
| 147 |
-
| Document length | 80 to 600 words | 80 to 1200 words |
|
| 148 |
-
| Dialogue: mean words per turn | <= 25 | <= 40 |
|
| 149 |
|
| 150 |
Assistant chats (`User:` / `Assistant:`) may average up to 4 times the per-turn cap and need at least 2 turns (named dialogues need 4),
|
| 151 |
because summarisation and rewrite tasks have 2 turns and assistant answers are long.
|
| 152 |
|
| 153 |
-
Documents longer than the maximum are split at paragraph borders. The 1M subset is a prefix slice of the 10M build; 10M and
|
| 154 |
7. **Run safety nets** (used to build the larger subsets without manual tuning): a probe per source picks a starting filter strictness, strictness relaxes in up to three logged steps when yield is too low, and shortfalls go to substitute sources.
|
| 155 |
|
| 156 |
Thresholds were calibrated on real data: the first values (95% coverage in the top 5k words, Flesch-Kincaid <= 5 for everything)
|
|
@@ -169,6 +191,7 @@ accepted only 3% of SimpleStories and 0.6% of Cosmopedia v2, so they were relaxe
|
|
| 169 |
| [SmolTalk (everyday-conversations, smol-summarize, smol-rewrite)](https://huggingface.co/datasets/HuggingFaceTB/smoltalk) | Apache-2.0 | chat, summaries, rewrites |
|
| 170 |
| [TinyHelen Leaner-Pretrain (book, conversation, textbook, web, wiki)](https://huggingface.co/datasets/EmpathYang/TinyHelen) | MIT | simplified real text |
|
| 171 |
| [Simple English Wikipedia (20231101.simple)](https://huggingface.co/datasets/wikimedia/wikipedia) | CC-BY-SA-3.0 / GFDL | encyclopedic, simple |
|
|
|
|
| 172 |
| [Cosmopedia v2 (SmolLM-Corpus)](https://huggingface.co/datasets/HuggingFaceTB/smollm-corpus) | Apache-2.0 (corpus: ODC-By) | synthetic textbooks, blogs, stories |
|
| 173 |
| [Cosmopedia v0.1 (wikihow, khanacademy, openstax)](https://huggingface.co/datasets/HuggingFaceTB/cosmopedia) | Apache-2.0 | procedural and didactic |
|
| 174 |
| [tiny-textbooks (`textbook` column)](https://huggingface.co/datasets/nampdn-ai/tiny-textbooks) | Apache-2.0 | short synthetic lessons |
|
|
@@ -181,7 +204,7 @@ accepted only 3% of SimpleStories and 0.6% of Cosmopedia v2, so they were relaxe
|
|
| 181 |
license of its `source`. Obligations that matter when redistributing or reusing it:
|
| 182 |
|
| 183 |
- Attribution is required for CC-BY / ODC-By / CDLA sources (listed above).
|
| 184 |
-
- The Wikipedia
|
| 185 |
- Cosmopedia, SmolTalk, UltraChat, TinyStories, SimpleStories, TinyHelen and tiny-textbooks contain **model-generated text**; check the terms of the generating model (GPT-4, GPT-4o-mini, Mixtral and others) for your use case.
|
| 186 |
- CNN/DailyMail articles and FineWeb-Edu web pages are third-party content; they are included under the dataset licenses above, which do not transfer rights from the original publishers.
|
| 187 |
- Project Gutenberg texts had the Project Gutenberg header and footer removed; they are public domain in the United States, check your jurisdiction.
|
|
@@ -212,9 +235,9 @@ Small GPTs (nanoGPT-style, own byte-level BPE trained on each training set). Eac
|
|
| 212 |
|
| 213 |
## Reproduce
|
| 214 |
|
| 215 |
-
`code/` contains the build scripts (`mix.py` quotas and tiers, `sources.py` adapters, `build.py` pipeline, `
|
| 216 |
-
`publish.py`, `train.py` for the sanity-check runs) and `requirements.txt`. Building a subset:
|
| 217 |
-
then `python assemble.py 10M`. The build streams the source datasets from the Hub.
|
| 218 |
|
| 219 |
## Acknowledgements
|
| 220 |
|
|
|
|
| 6 |
license_link: https://huggingface.co/datasets/jncarlo/tinymix#sources-and-licensing
|
| 7 |
pretty_name: tinymix
|
| 8 |
size_categories:
|
| 9 |
+
- 1M<n<10M
|
| 10 |
task_categories:
|
| 11 |
- text-generation
|
| 12 |
tags:
|
|
|
|
| 19 |
- config_name: 1M
|
| 20 |
data_files:
|
| 21 |
- split: train
|
| 22 |
+
path: data/1M/train*.parquet
|
| 23 |
- split: validation_dialogue
|
| 24 |
path: data/1M/validation_dialogue.parquet
|
| 25 |
- split: validation_expository
|
|
|
|
| 29 |
- config_name: 10M
|
| 30 |
data_files:
|
| 31 |
- split: train
|
| 32 |
+
path: data/10M/train*.parquet
|
| 33 |
- split: validation_dialogue
|
| 34 |
path: data/10M/validation_dialogue.parquet
|
| 35 |
- split: validation_expository
|
|
|
|
| 39 |
- config_name: 100M
|
| 40 |
data_files:
|
| 41 |
- split: train
|
| 42 |
+
path: data/100M/train*.parquet
|
| 43 |
- split: validation_books
|
| 44 |
path: data/100M/validation_books.parquet
|
| 45 |
- split: validation_dialogue
|
|
|
|
| 52 |
path: data/100M/validation_news.parquet
|
| 53 |
- split: validation_poetry
|
| 54 |
path: data/100M/validation_poetry.parquet
|
| 55 |
+
- config_name: 1000M
|
| 56 |
+
data_files:
|
| 57 |
+
- split: train
|
| 58 |
+
path: data/1000M/train*.parquet
|
| 59 |
+
- split: validation_books
|
| 60 |
+
path: data/1000M/validation_books.parquet
|
| 61 |
+
- split: validation_dialogue
|
| 62 |
+
path: data/1000M/validation_dialogue.parquet
|
| 63 |
+
- split: validation_expository
|
| 64 |
+
path: data/1000M/validation_expository.parquet
|
| 65 |
+
- split: validation_narrative
|
| 66 |
+
path: data/1000M/validation_narrative.parquet
|
| 67 |
+
- split: validation_news
|
| 68 |
+
path: data/1000M/validation_news.parquet
|
| 69 |
+
- split: validation_poetry
|
| 70 |
+
path: data/1000M/validation_poetry.parquet
|
| 71 |
---
|
| 72 |
|
| 73 |
# tinymix
|
| 74 |
|
| 75 |
+
Small, **genre-balanced English pretraining corpora** in four sizes (about 1M, 10M, 100M and 1000M words), built for training
|
| 76 |
very small language models. The mix combines synthetic child-level stories and dialogue, simplified real text,
|
| 77 |
encyclopedic and didactic text, books, poetry and news, all filtered toward clear, self-contained documents. It is
|
| 78 |
inspired by TinyStories, SimpleStories, TinyHelen and the BabyLM challenge.
|
|
|
|
| 80 |
What is different from using those datasets directly:
|
| 81 |
|
| 82 |
- **Several kinds of text in one mix** (narrative, dialogue and chat, expository, books, poetry, news), not only stories or only conversations.
|
| 83 |
+
- **Four sizes built with the same recipe**, with complexity limits that grow with size.
|
| 84 |
- **No non-commercial sources.** TinyChat (CC-BY-NC) and the BabyLM corpus (no clear license, includes subtitle and child-speech data) were left out on purpose.
|
| 85 |
- **Provenance per document** (`source`, `genre`) and **validation splits per genre**, to see which kind of text a model is weak at.
|
| 86 |
- The whole pipeline is included (`code/`) and every filter decision is documented below.
|
|
|
|
| 92 |
| `1M` | 1.0M | 4,135 | ~1.3M |
|
| 93 |
| `10M` | 9.96M | 42,117 | ~12.9M |
|
| 94 |
| `100M` | 99.5M | 338,230 | ~129.3M |
|
| 95 |
+
| `1000M` | 994.92M | 3,040,575 | ~1293.4M |
|
| 96 |
|
| 97 |
Words are whitespace-separated words in `train`. Each subset also has about 0.5% of the documents per genre held out as `validation_<genre>` splits
|
| 98 |
(at least one document per genre; the `1M` validation splits are therefore tiny, 4 to 8 documents each, and noisy).
|
|
|
|
| 111 |
|
| 112 |
Share of training words by genre:
|
| 113 |
|
| 114 |
+
| Genre | 1M | 10M | 100M | 1000M |
|
| 115 |
+
|---|---|---|---|---|
|
| 116 |
+
| narrative | 38.0% | 35.0% | 21.0% | 15.0% |
|
| 117 |
+
| dialogue | 21.9% | 25.0% | 21.0% | 19.0% |
|
| 118 |
+
| expository | 40.1% | 40.0% | 48.0% | 56.0% |
|
| 119 |
+
| books | 0% | 0% | 8.0% | 7.0% |
|
| 120 |
+
| poetry | 0% | 0% | 1.0% | 1.0% |
|
| 121 |
+
| news | 0% | 0% | 1.0% | 2.0% |
|
| 122 |
|
| 123 |
Million words per source:
|
| 124 |
|
| 125 |
+
| Source | 1M (M words) | 10M (M words) | 100M (M words) | 1000M (M words) |
|
| 126 |
+
|---|---|---|---|---|
|
| 127 |
+
| TinyStories V2 (GPT-4 split) | 0.189 | 1.494 | 7.959 | 39.793 |
|
| 128 |
+
| SimpleStories | 0.189 | 1.99 | 7.964 | 59.698 |
|
| 129 |
+
| Cosmopedia v0.1, `stories` | 0 | 0 | 4.972 | 49.763 |
|
| 130 |
+
| TinyDialogues | 0.12 | 1.494 | 6.969 | 19.655 |
|
| 131 |
+
| SODA | 0.099 | 0.994 | 8.955 | 83.828 |
|
| 132 |
+
| UltraChat 200k | 0 | 0 | 3.974 | 72.915 |
|
| 133 |
+
| SmolTalk (everyday-conversations, smol-summarize, smol-rewrite) | 0 | 0 | 0.994 | 12.66 |
|
| 134 |
+
| TinyHelen Leaner-Pretrain (book, conversation, textbook, web, wiki) | 0.15 | 1.499 | 9.946 | 33.921 |
|
| 135 |
+
| Simple English Wikipedia (20231101.simple) | 0.1 | 0.996 | 9.951 | 21.201 |
|
| 136 |
+
| English Wikipedia, lead paragraphs | 0 | 0 | 0 | 32.885 |
|
| 137 |
+
| Cosmopedia v2 (SmolLM-Corpus) | 0.1 | 0.996 | 11.944 | 195.975 |
|
| 138 |
+
| Cosmopedia v0.1 (wikihow, khanacademy, openstax) | 0.05 | 0.497 | 2.984 | 29.767 |
|
| 139 |
+
| tiny-textbooks (`textbook` column) | 0 | 0 | 3.98 | 64.294 |
|
| 140 |
+
| FineWeb-Edu (sample-10BT, score >= 4) | 0 | 0 | 8.96 | 179.075 |
|
| 141 |
+
| Project Gutenberg (English books) | 0 | 0 | 7.96 | 69.649 |
|
| 142 |
+
| Gutenberg Poetry Corpus | 0 | 0 | 0.995 | 9.95 |
|
| 143 |
+
| CNN/DailyMail 3.0.0 | 0 | 0 | 0.995 | 19.897 |
|
| 144 |
|
| 145 |
The 10M and 100M subsets are within about 1% of their targets (train plus validation splits). In the 10M build,
|
| 146 |
sources that could not fill their quota with the filters (Simple English Wikipedia, Cosmopedia v0.1) were topped up by
|
| 147 |
same-genre substitute sources (tiny-textbooks, Cosmopedia v2), capped per source; that is why `tiny-textbooks` appears
|
| 148 |
there. The 1M subset keeps the 10M proportions except that Cosmopedia stories (not in the 10M mix) were replaced by TinyStories and SimpleStories.
|
| 149 |
|
| 150 |
+
The 1000M subset is also within about 1% of its target. Five sources ran out under the filters before their quota and were
|
| 151 |
+
topped up by same-genre substitutes (million words): TinyDialogues by SODA (9.3), SmolTalk by UltraChat (12.3), TinyHelen by
|
| 152 |
+
tiny-textbooks (15.9), Simple English Wikipedia by tiny-textbooks (8.7) and English Wikipedia lead paragraphs by Cosmopedia v2 (17.0).
|
| 153 |
+
|
| 154 |
## How it was built
|
| 155 |
|
| 156 |
1. **Normalisation**: `ftfy`, NFKC, ASCII quotes and dashes, whitespace; URLs, e-mails, phone numbers, code, LaTeX and HTML removed. Documents with any character outside ASCII, Latin-1 and Latin Extended-A letters, common punctuation and a few math symbols are rejected whole (reason `charset` in the build stats).
|
|
|
|
| 160 |
5. **Deduplication across all sources**: exact hash and MinHash LSH (5-word shingles, Jaccard >= 0.8).
|
| 161 |
6. **Complexity control by size** (vocabulary coverage = share of lowercase tokens inside the top-N English words of `wordfreq`):
|
| 162 |
|
| 163 |
+
| | 10M | 100M | 1000M |
|
| 164 |
+
|---|---|---|---|
|
| 165 |
+
| Reference vocabulary | top 8k | top 15k | top 30k |
|
| 166 |
+
| Min vocabulary coverage | 90% | 90% | 90% |
|
| 167 |
+
| Max Flesch-Kincaid grade (narrative, news, books) | 5 | 8 | 12 |
|
| 168 |
+
| Max Flesch-Kincaid grade (expository) | 9 | 10 | 12 |
|
| 169 |
+
| Document length | 80 to 600 words | 80 to 1200 words | 80 to 2000 words |
|
| 170 |
+
| Dialogue: mean words per turn | <= 25 | <= 40 | <= 80 |
|
| 171 |
|
| 172 |
Assistant chats (`User:` / `Assistant:`) may average up to 4 times the per-turn cap and need at least 2 turns (named dialogues need 4),
|
| 173 |
because summarisation and rewrite tasks have 2 turns and assistant answers are long.
|
| 174 |
|
| 175 |
+
Documents longer than the maximum are split at paragraph borders. The 1M subset is a prefix slice of the 10M build; 10M, 100M and 1000M were built separately with the same recipe, so they are **not** guaranteed to be subsets of each other (a later fix to the end-of-document check, which wrongly rejected Wikipedia articles that end in a heading, was only applied to sources rebuilt for the 100M run).
|
| 176 |
7. **Run safety nets** (used to build the larger subsets without manual tuning): a probe per source picks a starting filter strictness, strictness relaxes in up to three logged steps when yield is too low, and shortfalls go to substitute sources.
|
| 177 |
|
| 178 |
Thresholds were calibrated on real data: the first values (95% coverage in the top 5k words, Flesch-Kincaid <= 5 for everything)
|
|
|
|
| 191 |
| [SmolTalk (everyday-conversations, smol-summarize, smol-rewrite)](https://huggingface.co/datasets/HuggingFaceTB/smoltalk) | Apache-2.0 | chat, summaries, rewrites |
|
| 192 |
| [TinyHelen Leaner-Pretrain (book, conversation, textbook, web, wiki)](https://huggingface.co/datasets/EmpathYang/TinyHelen) | MIT | simplified real text |
|
| 193 |
| [Simple English Wikipedia (20231101.simple)](https://huggingface.co/datasets/wikimedia/wikipedia) | CC-BY-SA-3.0 / GFDL | encyclopedic, simple |
|
| 194 |
+
| [English Wikipedia, lead paragraphs](https://huggingface.co/datasets/wikimedia/wikipedia) | CC-BY-SA-3.0 / GFDL | encyclopedic |
|
| 195 |
| [Cosmopedia v2 (SmolLM-Corpus)](https://huggingface.co/datasets/HuggingFaceTB/smollm-corpus) | Apache-2.0 (corpus: ODC-By) | synthetic textbooks, blogs, stories |
|
| 196 |
| [Cosmopedia v0.1 (wikihow, khanacademy, openstax)](https://huggingface.co/datasets/HuggingFaceTB/cosmopedia) | Apache-2.0 | procedural and didactic |
|
| 197 |
| [tiny-textbooks (`textbook` column)](https://huggingface.co/datasets/nampdn-ai/tiny-textbooks) | Apache-2.0 | short synthetic lessons |
|
|
|
|
| 204 |
license of its `source`. Obligations that matter when redistributing or reusing it:
|
| 205 |
|
| 206 |
- Attribution is required for CC-BY / ODC-By / CDLA sources (listed above).
|
| 207 |
+
- The Wikipedia parts (`simplewiki`, `enwiki_intro`) are **CC-BY-SA-3.0 / GFDL (share-alike)**. If you need a share-alike-free corpus, filter out those two sources.
|
| 208 |
- Cosmopedia, SmolTalk, UltraChat, TinyStories, SimpleStories, TinyHelen and tiny-textbooks contain **model-generated text**; check the terms of the generating model (GPT-4, GPT-4o-mini, Mixtral and others) for your use case.
|
| 209 |
- CNN/DailyMail articles and FineWeb-Edu web pages are third-party content; they are included under the dataset licenses above, which do not transfer rights from the original publishers.
|
| 210 |
- Project Gutenberg texts had the Project Gutenberg header and footer removed; they are public domain in the United States, check your jurisdiction.
|
|
|
|
| 235 |
|
| 236 |
## Reproduce
|
| 237 |
|
| 238 |
+
`code/` contains the build scripts (`mix.py` quotas and tiers, `sources.py` adapters, `build.py` pipeline, `build_pool.py` for
|
| 239 |
+
1000M, `assemble.py`, `publish.py`, `train.py` for the sanity-check runs) and `requirements.txt`. Building a subset:
|
| 240 |
+
`python build.py 10M` (or `python build_pool.py 1000M`), then `python assemble.py 10M`. The build streams the source datasets from the Hub.
|
| 241 |
|
| 242 |
## Acknowledgements
|
| 243 |
|
code/assemble.py
CHANGED
|
@@ -35,8 +35,82 @@ def load(size):
|
|
| 35 |
return docs
|
| 36 |
|
| 37 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
def main():
|
| 39 |
size = sys.argv[1]
|
|
|
|
|
|
|
| 40 |
docs = load(size)
|
| 41 |
random.Random(0).shuffle(docs)
|
| 42 |
out = ROOT / "out" / size
|
|
|
|
| 35 |
return docs
|
| 36 |
|
| 37 |
|
| 38 |
+
def main_big(size):
|
| 39 |
+
"""Same result as main() in the same shuffled order, without holding the documents in RAM (1000M)."""
|
| 40 |
+
import numpy as np
|
| 41 |
+
import pyarrow as pa
|
| 42 |
+
import pyarrow.parquet as pq
|
| 43 |
+
files = sorted((ROOT / "work" / size).glob("*.jsonl"))
|
| 44 |
+
idx_f, idx_o, n_genre = [], [], defaultdict(int)
|
| 45 |
+
for i, p in enumerate(files):
|
| 46 |
+
pos = 0
|
| 47 |
+
with p.open("rb") as f:
|
| 48 |
+
for line in f:
|
| 49 |
+
idx_f.append(i)
|
| 50 |
+
idx_o.append(pos)
|
| 51 |
+
pos += len(line)
|
| 52 |
+
n_genre[json.loads(line)["genre"]] += 1
|
| 53 |
+
idx_f, idx_o = np.array(idx_f, np.int32), np.array(idx_o, np.int64)
|
| 54 |
+
order = list(range(len(idx_f)))
|
| 55 |
+
random.Random(0).shuffle(order)
|
| 56 |
+
out = ROOT / "out" / size
|
| 57 |
+
pq_dir = out / "parquet"
|
| 58 |
+
pq_dir.mkdir(parents=True, exist_ok=True)
|
| 59 |
+
handles = [p.open("rb") for p in files]
|
| 60 |
+
schema = pa.schema([("text", pa.string()), ("source", pa.string()), ("genre", pa.string())])
|
| 61 |
+
sep = f"\n{EOT}\n"
|
| 62 |
+
held, valid = defaultdict(int), defaultdict(list)
|
| 63 |
+
words, n_train, by_genre, by_source = 0, 0, defaultdict(int), defaultdict(int)
|
| 64 |
+
batch, shard, shard_words = [], 0, 0
|
| 65 |
+
|
| 66 |
+
def flush():
|
| 67 |
+
nonlocal batch, shard, shard_words
|
| 68 |
+
if batch:
|
| 69 |
+
pq.write_table(pa.table({"text": [d["text"] for d in batch],
|
| 70 |
+
"source": [d["src"].split(".")[0] for d in batch],
|
| 71 |
+
"genre": [d["genre"] for d in batch]}, schema=schema),
|
| 72 |
+
pq_dir / f"train-{shard:05d}.parquet", compression="zstd")
|
| 73 |
+
batch, shard, shard_words = [], shard + 1, 0
|
| 74 |
+
|
| 75 |
+
with (out / "train.txt").open("w", encoding="utf-8") as tf:
|
| 76 |
+
for k in order:
|
| 77 |
+
f = handles[idx_f[k]]
|
| 78 |
+
f.seek(idx_o[k])
|
| 79 |
+
d = json.loads(f.readline())
|
| 80 |
+
g = d["genre"]
|
| 81 |
+
if held[g] < max(1, n_genre[g] // 200):
|
| 82 |
+
held[g] += 1
|
| 83 |
+
valid[g].append(d)
|
| 84 |
+
continue
|
| 85 |
+
n = len(d["text"].split())
|
| 86 |
+
tf.write(d["text"] + sep)
|
| 87 |
+
batch.append(d)
|
| 88 |
+
shard_words += n
|
| 89 |
+
n_train += 1
|
| 90 |
+
words += n
|
| 91 |
+
by_genre[g] += n
|
| 92 |
+
by_source[d["src"].split(".")[0]] += n
|
| 93 |
+
if shard_words >= 50_000_000:
|
| 94 |
+
flush()
|
| 95 |
+
flush()
|
| 96 |
+
for h in handles:
|
| 97 |
+
h.close()
|
| 98 |
+
for g, ds in valid.items():
|
| 99 |
+
(out / f"valid_{g}.txt").write_text(sep.join(d["text"] for d in ds) + sep, encoding="utf-8")
|
| 100 |
+
pq.write_table(pa.table({"text": [d["text"] for d in ds], "source": [d["src"].split(".")[0] for d in ds],
|
| 101 |
+
"genre": [d["genre"] for d in ds]}), pq_dir / f"validation_{g}.parquet",
|
| 102 |
+
compression="zstd")
|
| 103 |
+
summary = {"size": size, "train_docs": n_train, "train_words_M": round(words / 1e6, 2),
|
| 104 |
+
"genre_share_%": {g: round(100 * w / words, 1) for g, w in by_genre.items()},
|
| 105 |
+
"source_words_M": {s: round(w / 1e6, 3) for s, w in sorted(by_source.items())}}
|
| 106 |
+
(out / "summary.json").write_text(json.dumps(summary, indent=1))
|
| 107 |
+
print(json.dumps(summary, indent=1))
|
| 108 |
+
|
| 109 |
+
|
| 110 |
def main():
|
| 111 |
size = sys.argv[1]
|
| 112 |
+
if size == "1000M":
|
| 113 |
+
return main_big(size)
|
| 114 |
docs = load(size)
|
| 115 |
random.Random(0).shuffle(docs)
|
| 116 |
out = ROOT / "out" / size
|
code/build_pool.py
ADDED
|
@@ -0,0 +1,620 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Parallel, resource-bounded build for big sizes: python build_pool.py 1000M [options]
|
| 2 |
+
|
| 3 |
+
Same filters and safety nets as build.py (process, probe and the relaxation ladder come from there).
|
| 4 |
+
What is different:
|
| 5 |
+
- Jobs. A source whose estimated time (from work/100M/stats.json) exceeds --job-hours is split into
|
| 6 |
+
shards (whole dataset files, or every k-th row). Jobs run longest first in at most --workers
|
| 7 |
+
processes, at below-normal priority and with one thread each, so the machine stays usable.
|
| 8 |
+
- Memory. Dedup keeps 8-byte keys per document (the md5 key and the LSH band keys build.Dedup
|
| 9 |
+
uses) instead of datasketch's index, and each job only holds its own. A global pass over the key
|
| 10 |
+
files with numpy then drops documents that repeat across jobs; the first occurrence in MIX order
|
| 11 |
+
wins, and a document that matches any earlier one is dropped (build.Dedup only compares against
|
| 12 |
+
kept ones, so this is marginally stricter). Jobs collect --overshoot extra words so that pass
|
| 13 |
+
rarely leaves a source short, and the excess is trimmed.
|
| 14 |
+
The scheduler waits to start jobs while free RAM is below --min-free-gb and stops the youngest job
|
| 15 |
+
when it falls below --kill-free-gb; a stopped job resumes later.
|
| 16 |
+
- Robustness. Each job checkpoints every --ckpt-seconds, after flushing its data, so a hard kill
|
| 17 |
+
loses at most that interval. On a network error it reopens the stream and skips the documents
|
| 18 |
+
already seen (the streams are deterministic: fixed seed and shard). A job that crashes restarts
|
| 19 |
+
from its checkpoint up to --retries times. Rerunning the same command resumes everything and
|
| 20 |
+
skips finished jobs.
|
| 21 |
+
Output: work/<size>/<source>.jsonl and <source>.topup.jsonl plus stats.json, which assemble.py reads as
|
| 22 |
+
before. Per-job files (data, keys, checkpoints, logs) live in work/<size>/jobs/.
|
| 23 |
+
|
| 24 |
+
Testing: --scale 0.002 multiplies every quota (output in work/<size>_x0.002/); a small --job-hours
|
| 25 |
+
forces shards.
|
| 26 |
+
"""
|
| 27 |
+
import argparse
|
| 28 |
+
import hashlib
|
| 29 |
+
import itertools
|
| 30 |
+
import json
|
| 31 |
+
import math
|
| 32 |
+
import multiprocessing as mp
|
| 33 |
+
import os
|
| 34 |
+
import re
|
| 35 |
+
import shutil
|
| 36 |
+
import statistics
|
| 37 |
+
import sys
|
| 38 |
+
import time
|
| 39 |
+
import traceback
|
| 40 |
+
from collections import Counter
|
| 41 |
+
from pathlib import Path
|
| 42 |
+
|
| 43 |
+
# one thread per process for numpy, BLAS and Arrow; spawned workers inherit these
|
| 44 |
+
for _v in ("OMP_NUM_THREADS", "OPENBLAS_NUM_THREADS", "MKL_NUM_THREADS"):
|
| 45 |
+
os.environ.setdefault(_v, "1")
|
| 46 |
+
|
| 47 |
+
import numpy as np
|
| 48 |
+
import psutil
|
| 49 |
+
from datasketch import MinHash, MinHashLSH
|
| 50 |
+
from wordfreq import top_n_list
|
| 51 |
+
|
| 52 |
+
import build
|
| 53 |
+
import mix
|
| 54 |
+
import sources
|
| 55 |
+
|
| 56 |
+
ROOT = build.ROOT
|
| 57 |
+
_LSH = MinHashLSH(threshold=0.8, num_perm=64) # build.Dedup's parameters; only b and r are used
|
| 58 |
+
BANDS, ROWS = _LSH.b, _LSH.r
|
| 59 |
+
_MH = MinHash(num_perm=64) # reused permutations; building them per document is most of MinHash's cost
|
| 60 |
+
PERMS, SCHEME = _MH.permutations, _MH.scheme
|
| 61 |
+
# odd 64-bit multipliers that fold the ROWS values of a band into one key
|
| 62 |
+
MIXER = np.random.RandomState(7).randint(1, 2**62, size=ROWS, dtype=np.int64).astype(np.uint64) | np.uint64(1)
|
| 63 |
+
REC = np.dtype([("x", "<u8"), ("b", "<u8", (BANDS,)), ("w", "<u4")])
|
| 64 |
+
# not streamed through sources._ds (so they cannot be sharded), or row order matters (poetry)
|
| 65 |
+
NO_SHARD = {"tinystories", "tinydialogues", "tinyhelen", "poetry"}
|
| 66 |
+
# Gutenberg rows are whole books in ~300 MB row groups: filling the shuffle buffer from datasets'
|
| 67 |
+
# default 10 files at once peaks at 6 GB, from one file at 1.7 GB (and is faster)
|
| 68 |
+
INPUT_SHARDS = {"gutenberg_books": 1}
|
| 69 |
+
# expected peak RAM per worker (GB), measured: a streamed parquet source with a 20k-row shuffle
|
| 70 |
+
# buffer sits near 1.4. The scheduler raises these to the peaks it observes during the run.
|
| 71 |
+
MEM_GB = {"gutenberg_books": 2.0}
|
| 72 |
+
MEM_DEFAULT_GB = 1.5
|
| 73 |
+
|
| 74 |
+
|
| 75 |
+
def doc_keys(text):
|
| 76 |
+
"""The md5 key and the LSH band keys build.Dedup would use for this text, as 64-bit ints."""
|
| 77 |
+
x = int.from_bytes(hashlib.md5(re.sub(r"\W+", "", text.lower()).encode()).digest()[:8], "little")
|
| 78 |
+
w = text.lower().split()
|
| 79 |
+
mh = MinHash(num_perm=64, permutations=PERMS, scheme=SCHEME)
|
| 80 |
+
mh.update_batch([" ".join(w[i:i + 5]).encode() for i in range(max(len(w) - 4, 1))])
|
| 81 |
+
hv = mh.hashvalues[:BANDS * ROWS].astype(np.uint64).reshape(BANDS, ROWS)
|
| 82 |
+
with np.errstate(over="ignore"):
|
| 83 |
+
return x, (hv * MIXER).sum(axis=1, dtype=np.uint64)
|
| 84 |
+
|
| 85 |
+
|
| 86 |
+
class Keys:
|
| 87 |
+
"""build.Dedup on plain sets of 64-bit keys: same decisions, a fraction of the memory."""
|
| 88 |
+
|
| 89 |
+
def __init__(self):
|
| 90 |
+
self.exact, self.bands = set(), [set() for _ in range(BANDS)]
|
| 91 |
+
|
| 92 |
+
def load(self, path):
|
| 93 |
+
if path.exists():
|
| 94 |
+
recs = np.fromfile(path, dtype=REC)
|
| 95 |
+
self.exact.update(recs["x"].tolist())
|
| 96 |
+
for i, s in enumerate(self.bands):
|
| 97 |
+
s.update(recs["b"][:, i].tolist())
|
| 98 |
+
|
| 99 |
+
def seen(self, x, bands):
|
| 100 |
+
if x in self.exact:
|
| 101 |
+
return True
|
| 102 |
+
self.exact.add(x)
|
| 103 |
+
b = bands.tolist()
|
| 104 |
+
if any(k in s for s, k in zip(self.bands, b)):
|
| 105 |
+
return True
|
| 106 |
+
for s, k in zip(self.bands, b):
|
| 107 |
+
s.add(k)
|
| 108 |
+
return False
|
| 109 |
+
|
| 110 |
+
|
| 111 |
+
def write_json(path, obj):
|
| 112 |
+
tmp = path.with_suffix(path.suffix + ".tmp")
|
| 113 |
+
tmp.write_text(json.dumps(obj), encoding="utf-8")
|
| 114 |
+
for i in range(20): # Windows refuses the replace while another process has the file open
|
| 115 |
+
try:
|
| 116 |
+
os.replace(tmp, path)
|
| 117 |
+
return
|
| 118 |
+
except PermissionError:
|
| 119 |
+
time.sleep(0.5)
|
| 120 |
+
os.replace(tmp, path)
|
| 121 |
+
|
| 122 |
+
|
| 123 |
+
def read_json(path):
|
| 124 |
+
try:
|
| 125 |
+
return json.loads(path.read_text(encoding="utf-8"))
|
| 126 |
+
except (OSError, ValueError):
|
| 127 |
+
return None
|
| 128 |
+
|
| 129 |
+
|
| 130 |
+
def apply_scale(scale, size):
|
| 131 |
+
"""--scale: multiply this size's quotas in memory (parent and every worker), for test runs."""
|
| 132 |
+
if scale == 1:
|
| 133 |
+
return
|
| 134 |
+
i = mix.SIZES[size]
|
| 135 |
+
for k, (g, q) in list(mix.MIX.items()):
|
| 136 |
+
mix.MIX[k] = (g, tuple(v * scale if j == i else v for j, v in enumerate(q)))
|
| 137 |
+
|
| 138 |
+
|
| 139 |
+
def paths(jobs_dir, job):
|
| 140 |
+
return {ext: jobs_dir / f"{job['id']}.{ext}" for ext in ("jsonl", "keys", "ckpt", "done", "log")}
|
| 141 |
+
|
| 142 |
+
|
| 143 |
+
def is_done(jobs_dir, job):
|
| 144 |
+
d = read_json(paths(jobs_dir, job)["done"])
|
| 145 |
+
return bool(d) and abs(d["quota_M"] - job["quota"] / 1e6) < 1e-6
|
| 146 |
+
|
| 147 |
+
|
| 148 |
+
# ---------------------------------------------------------------- worker side
|
| 149 |
+
|
| 150 |
+
def robust_stream(name, size, start, st, tries=8):
|
| 151 |
+
"""Yield the source's documents from index `start`; on a stream error reopen the stream and skip
|
| 152 |
+
what was already yielded."""
|
| 153 |
+
pos, fails = start, 0
|
| 154 |
+
while True:
|
| 155 |
+
try:
|
| 156 |
+
for doc in itertools.islice(sources.REGISTRY[name](size), pos, None):
|
| 157 |
+
pos += 1
|
| 158 |
+
fails = 0
|
| 159 |
+
yield doc
|
| 160 |
+
return
|
| 161 |
+
except Exception as e:
|
| 162 |
+
fails += 1
|
| 163 |
+
st["retries"] = st.get("retries", 0) + 1
|
| 164 |
+
if fails > tries:
|
| 165 |
+
raise
|
| 166 |
+
wait = min(600, 15 * 2 ** fails)
|
| 167 |
+
print(f"stream error at doc {pos} ({e!r}); retry {fails}/{tries} in {wait}s", flush=True)
|
| 168 |
+
time.sleep(wait)
|
| 169 |
+
|
| 170 |
+
|
| 171 |
+
def consumed_docs(job, jobs_dir):
|
| 172 |
+
"""Where a top-up starts: after what its source's primary job read, when both read the same stream."""
|
| 173 |
+
if not job["tag"] or list(job["shard"]) != [0, 1]:
|
| 174 |
+
return 0
|
| 175 |
+
d = read_json(jobs_dir / f"{job['name']}.s0of1.done")
|
| 176 |
+
return d["scanned_docs"] if d else 0
|
| 177 |
+
|
| 178 |
+
|
| 179 |
+
def run_job(job, size, jobs_dir, ckpt_seconds):
|
| 180 |
+
"""build.build_source for one job, with checkpoints and resume."""
|
| 181 |
+
p = paths(jobs_dir, job)
|
| 182 |
+
if is_done(jobs_dir, job):
|
| 183 |
+
return
|
| 184 |
+
name, quota = job["name"], job["quota"]
|
| 185 |
+
genre = mix.MIX[name][0]
|
| 186 |
+
base = mix.TIERS[size]
|
| 187 |
+
vocab = set(top_n_list("en", base["vocab"]))
|
| 188 |
+
dedup = Keys()
|
| 189 |
+
for seed in job["seeds"]: # a top-up must not repeat its own source's primary files
|
| 190 |
+
dedup.load(Path(seed))
|
| 191 |
+
st = read_json(p["ckpt"])
|
| 192 |
+
# resuming skips documents by position, so it is only valid on the very same stream
|
| 193 |
+
stream = [list(job["shard"]), INPUT_SHARDS.get(name)]
|
| 194 |
+
if st and (abs(st["quota"] - quota) > 1 or st.get("stream") != stream):
|
| 195 |
+
st = None # options changed since the checkpoint: start over
|
| 196 |
+
openers = Counter()
|
| 197 |
+
if st:
|
| 198 |
+
# drop whatever was written after the last checkpoint, then rebuild state from the rest
|
| 199 |
+
with p["jsonl"].open("r+b") as f:
|
| 200 |
+
f.truncate(st["bytes"])
|
| 201 |
+
with p["keys"].open("r+b") as f:
|
| 202 |
+
f.truncate(st["kept"] * REC.itemsize)
|
| 203 |
+
dedup.load(p["keys"])
|
| 204 |
+
for line in p["jsonl"].open(encoding="utf-8"):
|
| 205 |
+
openers[" ".join(json.loads(line)["text"].lower().split()[:4])] += 1
|
| 206 |
+
print(f"resume at doc {st['seen_docs']}, {st['got'] / 1e6:.2f}M/{quota / 1e6:.2f}M words", flush=True)
|
| 207 |
+
else:
|
| 208 |
+
step, probe_report = build.probe(name, size, genre, base, vocab, quota)
|
| 209 |
+
print(f"probe: start at ladder step {step}; {probe_report[-1]}", flush=True)
|
| 210 |
+
st = dict(quota=quota, stream=stream, step=step, probe=probe_report, relaxed=[dict(step=step, at_words=0)],
|
| 211 |
+
got=0, scanned=0, kept=0, seen_docs=consumed_docs(job, jobs_dir), rej={}, seconds=0, retries=0,
|
| 212 |
+
bytes=0)
|
| 213 |
+
p["jsonl"].write_bytes(b"")
|
| 214 |
+
p["keys"].write_bytes(b"")
|
| 215 |
+
step = st["step"]
|
| 216 |
+
tier, cov = build.at_step(base, step)
|
| 217 |
+
got, scanned, kept, seen = st["got"], st["scanned"], st["kept"], st["seen_docs"]
|
| 218 |
+
rej = Counter(st["rej"])
|
| 219 |
+
win_scanned = win_kept = win_docs = 0
|
| 220 |
+
abort, t0, last, elapsed0 = None, time.time(), time.time(), st["seconds"]
|
| 221 |
+
with p["jsonl"].open("ab") as f, p["keys"].open("ab") as kf:
|
| 222 |
+
|
| 223 |
+
def save():
|
| 224 |
+
for h in (f, kf):
|
| 225 |
+
h.flush()
|
| 226 |
+
os.fsync(h.fileno())
|
| 227 |
+
st.update(step=step, got=got, scanned=scanned, kept=kept, seen_docs=seen, rej=dict(rej),
|
| 228 |
+
seconds=round(elapsed0 + time.time() - t0), bytes=f.tell())
|
| 229 |
+
write_json(p["ckpt"], st)
|
| 230 |
+
|
| 231 |
+
stream = robust_stream(name, size, seen, st) if got < quota else ()
|
| 232 |
+
for doc in stream:
|
| 233 |
+
seen += 1
|
| 234 |
+
win_docs += 1
|
| 235 |
+
w = build.doc_words(doc)
|
| 236 |
+
scanned += w
|
| 237 |
+
win_scanned += w
|
| 238 |
+
if scanned > quota * mix.MAX_SCAN:
|
| 239 |
+
abort = "scan_cap"
|
| 240 |
+
break
|
| 241 |
+
docs, why = build.process(doc, genre, tier, vocab, name, cov)
|
| 242 |
+
if why:
|
| 243 |
+
rej[why] += 1
|
| 244 |
+
for text in docs:
|
| 245 |
+
op = " ".join(text.lower().split()[:4])
|
| 246 |
+
if genre != "poetry" and openers[op] >= max(5, 0.005 * kept):
|
| 247 |
+
rej["opener_cap"] += 1
|
| 248 |
+
continue
|
| 249 |
+
x, bands = doc_keys(text)
|
| 250 |
+
if dedup.seen(x, bands):
|
| 251 |
+
rej["duplicate"] += 1
|
| 252 |
+
win_scanned -= len(text.split()) # says nothing about the yield of what is left
|
| 253 |
+
continue
|
| 254 |
+
openers[op] += 1
|
| 255 |
+
kept += 1
|
| 256 |
+
n = len(text.split())
|
| 257 |
+
got += n
|
| 258 |
+
win_kept += n
|
| 259 |
+
f.write((json.dumps({"text": text, "genre": genre, "src": name}) + "\n").encode("utf-8"))
|
| 260 |
+
rec = np.zeros(1, REC)
|
| 261 |
+
rec["x"], rec["b"], rec["w"] = x, bands, n
|
| 262 |
+
kf.write(rec.tobytes())
|
| 263 |
+
if got >= quota:
|
| 264 |
+
break
|
| 265 |
+
if time.time() - last >= ckpt_seconds:
|
| 266 |
+
save()
|
| 267 |
+
last = time.time()
|
| 268 |
+
print(f"{seen} docs, kept {kept}, {got / 1e6:.2f}M/{quota / 1e6:.2f}M words, "
|
| 269 |
+
f"step {step}, top rejections {rej.most_common(3)}", flush=True)
|
| 270 |
+
if win_docs >= mix.WINDOW:
|
| 271 |
+
# same rule as build.py: climb a ladder step when the recent yield cannot finish
|
| 272 |
+
# within the scan budget, give up at the top of the ladder
|
| 273 |
+
recent = win_kept / win_scanned if win_scanned > 0 else 0
|
| 274 |
+
need = (quota - got) / recent if recent else float("inf")
|
| 275 |
+
if win_scanned > 0 and need > quota * mix.MAX_SCAN - scanned:
|
| 276 |
+
if step + 1 < len(mix.LADDER):
|
| 277 |
+
step += 1
|
| 278 |
+
tier, cov = build.at_step(base, step)
|
| 279 |
+
st["relaxed"].append(dict(step=step, at_words=got))
|
| 280 |
+
print(f"yield {100 * recent:.1f}% too low, relaxing to step {step}", flush=True)
|
| 281 |
+
else:
|
| 282 |
+
abort = "projected_shortfall"
|
| 283 |
+
break
|
| 284 |
+
win_scanned = win_kept = win_docs = 0
|
| 285 |
+
save()
|
| 286 |
+
stats = dict(job=job["id"], source=name + job["tag"], genre=genre, target_M=job["target"] / 1e6,
|
| 287 |
+
quota_M=quota / 1e6, words_M=round(got / 1e6, 3), docs=kept, scanned_docs=seen,
|
| 288 |
+
scanned_words_M=round(scanned / 1e6, 1), seconds=st["seconds"],
|
| 289 |
+
stopped="quota" if got >= quota else (abort or "source_exhausted"),
|
| 290 |
+
relaxation=st["relaxed"], probe=st["probe"], rejections=dict(rej.most_common()),
|
| 291 |
+
stream_retries=st.get("retries", 0))
|
| 292 |
+
write_json(p["done"], stats)
|
| 293 |
+
p["ckpt"].unlink(missing_ok=True)
|
| 294 |
+
print(f"done: {stats['words_M']}M words, stopped by {stats['stopped']}", flush=True)
|
| 295 |
+
|
| 296 |
+
|
| 297 |
+
def worker(job, size, scale, ckpt_seconds, jobs_dir):
|
| 298 |
+
jobs_dir = Path(jobs_dir)
|
| 299 |
+
sys.stdout = sys.stderr = paths(jobs_dir, job)["log"].open("a", encoding="utf-8", buffering=1)
|
| 300 |
+
print(f"== {job['id']} pid {os.getpid()} {time.strftime('%Y-%m-%d %H:%M:%S')}", flush=True)
|
| 301 |
+
psutil.Process().nice(psutil.BELOW_NORMAL_PRIORITY_CLASS if os.name == "nt" else 10)
|
| 302 |
+
try:
|
| 303 |
+
import pyarrow
|
| 304 |
+
pyarrow.set_cpu_count(1)
|
| 305 |
+
pyarrow.set_io_thread_count(2)
|
| 306 |
+
except Exception:
|
| 307 |
+
pass
|
| 308 |
+
apply_scale(scale, size)
|
| 309 |
+
sources.SHARD = tuple(job["shard"])
|
| 310 |
+
sources.INPUT_SHARDS.update(INPUT_SHARDS)
|
| 311 |
+
try:
|
| 312 |
+
run_job(job, size, jobs_dir, ckpt_seconds)
|
| 313 |
+
except Exception:
|
| 314 |
+
traceback.print_exc()
|
| 315 |
+
sys.exit(1)
|
| 316 |
+
|
| 317 |
+
|
| 318 |
+
# ---------------------------------------------------------------- parent side
|
| 319 |
+
|
| 320 |
+
class Log:
|
| 321 |
+
def __init__(self, path):
|
| 322 |
+
self.f = path.open("a", encoding="utf-8", buffering=1)
|
| 323 |
+
|
| 324 |
+
def __call__(self, msg):
|
| 325 |
+
line = f"{time.strftime('%H:%M:%S')} {msg}"
|
| 326 |
+
print(line, flush=True)
|
| 327 |
+
self.f.write(line + "\n")
|
| 328 |
+
|
| 329 |
+
|
| 330 |
+
def seconds_per_word():
|
| 331 |
+
"""Build seconds per target word for each source, measured on the 100M build."""
|
| 332 |
+
s = read_json(ROOT / "work" / "100M" / "stats.json") or {}
|
| 333 |
+
rates = {r["source"]: r["seconds"] / (r["target_M"] * 1e6)
|
| 334 |
+
for r in s.get("sources", []) if r.get("target_M") and "seconds" in r}
|
| 335 |
+
default = statistics.median(rates.values()) if rates else 1e-4
|
| 336 |
+
return lambda name: rates.get(name, default)
|
| 337 |
+
|
| 338 |
+
|
| 339 |
+
def plan_jobs(targets, tag, args, seeds_for):
|
| 340 |
+
"""Split each (source, words) into shards of at most --job-hours estimated time."""
|
| 341 |
+
rate, jobs = seconds_per_word(), []
|
| 342 |
+
for name, target in targets:
|
| 343 |
+
if target <= 0:
|
| 344 |
+
continue
|
| 345 |
+
est = rate(name) * target
|
| 346 |
+
k = 1 if name in NO_SHARD else max(1, min(args.max_shards, math.ceil(est / (args.job_hours * 3600))))
|
| 347 |
+
for i in range(k):
|
| 348 |
+
jobs.append(dict(id=f"{name}{tag}.s{i}of{k}", name=name, tag=tag, shard=(i, k), target=target / k,
|
| 349 |
+
quota=target / k * (1 + args.overshoot), est=est / k, seeds=seeds_for(name)))
|
| 350 |
+
return jobs
|
| 351 |
+
|
| 352 |
+
|
| 353 |
+
def run_pool(jobs, args, size, jobs_dir, log):
|
| 354 |
+
"""Run jobs in at most --workers processes, longest first, within the RAM and disk limits.
|
| 355 |
+
Returns the jobs that failed more than --retries times."""
|
| 356 |
+
pending = sorted((j for j in jobs if not is_done(jobs_dir, j)), key=lambda j: -j["est"])
|
| 357 |
+
if not pending:
|
| 358 |
+
return []
|
| 359 |
+
total_est = sum(j["est"] for j in pending)
|
| 360 |
+
log(f"{len(pending)} jobs to run ({len(jobs) - len(pending)} already done), about "
|
| 361 |
+
f"{total_est / 3600:.1f} CPU hours by the 100M rates, {args.workers} workers")
|
| 362 |
+
ctx = mp.get_context("spawn")
|
| 363 |
+
running, attempts, failed = {}, Counter(), []
|
| 364 |
+
# a job stopped twice for memory runs alone from then on, otherwise it could be stopped forever
|
| 365 |
+
mem_stops, alone = Counter(), set()
|
| 366 |
+
peak = Counter() # observed peak RSS per source, GB
|
| 367 |
+
hold = kill_hold = last_status = 0.0
|
| 368 |
+
|
| 369 |
+
def need(job):
|
| 370 |
+
return max(MEM_GB.get(job["name"], MEM_DEFAULT_GB), peak[job["name"]])
|
| 371 |
+
|
| 372 |
+
def rss(proc):
|
| 373 |
+
try:
|
| 374 |
+
return psutil.Process(proc.pid).memory_info().rss / 1e9
|
| 375 |
+
except psutil.Error:
|
| 376 |
+
return 0.0
|
| 377 |
+
|
| 378 |
+
def stop(jid, why):
|
| 379 |
+
proc, job, _ = running.pop(jid)
|
| 380 |
+
proc.terminate()
|
| 381 |
+
proc.join()
|
| 382 |
+
pending.insert(0, job)
|
| 383 |
+
log(f"stopped {jid} ({why}); it resumes from its checkpoint")
|
| 384 |
+
|
| 385 |
+
def pick(free, reserved):
|
| 386 |
+
"""First pending job whose expected peak leaves the stop threshold clear, so a big job that
|
| 387 |
+
does not fit yet does not hold back smaller ones; a job marked to run alone waits for the rest."""
|
| 388 |
+
if alone & set(running):
|
| 389 |
+
return None
|
| 390 |
+
for j in pending:
|
| 391 |
+
if j["id"] in alone:
|
| 392 |
+
return j if not running else None
|
| 393 |
+
if not running or free - reserved - need(j) >= args.kill_free_gb + 0.5:
|
| 394 |
+
return j
|
| 395 |
+
return None
|
| 396 |
+
|
| 397 |
+
try:
|
| 398 |
+
while pending or running:
|
| 399 |
+
now = time.time()
|
| 400 |
+
for jid, (proc, job, _) in list(running.items()):
|
| 401 |
+
if proc.is_alive():
|
| 402 |
+
continue
|
| 403 |
+
proc.join()
|
| 404 |
+
del running[jid]
|
| 405 |
+
d = read_json(paths(jobs_dir, job)["done"])
|
| 406 |
+
if d:
|
| 407 |
+
log(f"done {jid}: {d['words_M']}M words in {d['seconds'] / 60:.0f} min, stopped by {d['stopped']}")
|
| 408 |
+
continue
|
| 409 |
+
attempts[jid] += 1
|
| 410 |
+
if attempts[jid] > args.retries:
|
| 411 |
+
failed.append(job)
|
| 412 |
+
log(f"FAILED {jid} after {attempts[jid]} attempts, see {paths(jobs_dir, job)['log']}")
|
| 413 |
+
else:
|
| 414 |
+
pending.insert(0, job)
|
| 415 |
+
hold = max(hold, now + 30)
|
| 416 |
+
log(f"{jid} exited with code {proc.exitcode}; restart {attempts[jid]}/{args.retries}")
|
| 417 |
+
free = psutil.virtual_memory().available / 1e9
|
| 418 |
+
# memory a running job is still expected to take (it grows while its buffers fill)
|
| 419 |
+
reserved = 0.0
|
| 420 |
+
for proc, job, _ in running.values():
|
| 421 |
+
r = rss(proc)
|
| 422 |
+
peak[job["name"]] = max(peak[job["name"]], r)
|
| 423 |
+
reserved += max(0.0, need(job) - r)
|
| 424 |
+
disk = shutil.disk_usage(jobs_dir).free / 1e9
|
| 425 |
+
if disk < args.min_disk_gb:
|
| 426 |
+
for jid in list(running):
|
| 427 |
+
stop(jid, f"only {disk:.1f} GB free on disk")
|
| 428 |
+
raise SystemExit(f"stopped: {disk:.1f} GB free on disk, below --min-disk-gb {args.min_disk_gb}. "
|
| 429 |
+
"Free space and rerun the same command to resume.")
|
| 430 |
+
# the last running job is never stopped: that would only trade progress for nothing
|
| 431 |
+
if free < args.kill_free_gb and len(running) > 1 and now >= kill_hold:
|
| 432 |
+
# one job at a time, then give the OS time to reclaim its memory before judging again
|
| 433 |
+
jid = max(running, key=lambda j: running[j][2])
|
| 434 |
+
stop(jid, f"free RAM {free:.1f} GB < {args.kill_free_gb}")
|
| 435 |
+
mem_stops[jid] += 1
|
| 436 |
+
if mem_stops[jid] >= 2 and jid not in alone:
|
| 437 |
+
alone.add(jid)
|
| 438 |
+
log(f"{jid} will run alone: it was stopped {mem_stops[jid]} times for memory")
|
| 439 |
+
hold, kill_hold = now + 120, now + 30
|
| 440 |
+
elif (len(running) < args.workers and pending and now >= hold and free >= args.min_free_gb
|
| 441 |
+
and (job := pick(free, reserved))):
|
| 442 |
+
pending.remove(job)
|
| 443 |
+
proc = ctx.Process(target=worker, args=(job, size, args.scale, args.ckpt_seconds, str(jobs_dir)))
|
| 444 |
+
proc.start()
|
| 445 |
+
running[job["id"]] = (proc, job, now)
|
| 446 |
+
hold = now + args.stagger
|
| 447 |
+
log(f"start {job['id']} (est {job['est'] / 60:.0f} min, ~{need(job):.1f} GB)")
|
| 448 |
+
if now - last_status >= args.status_seconds:
|
| 449 |
+
last_status = now
|
| 450 |
+
parts = []
|
| 451 |
+
for jid, (proc, job, _) in running.items():
|
| 452 |
+
ck = read_json(paths(jobs_dir, job)["ckpt"])
|
| 453 |
+
prog = f"{100 * ck['got'] / job['quota']:.0f}%" if ck else "probe"
|
| 454 |
+
parts.append(f"{jid} {prog} {rss(proc):.1f}GB")
|
| 455 |
+
log(f"status: {len(pending)} pending, free RAM {free:.1f} GB | " + " | ".join(parts))
|
| 456 |
+
time.sleep(2)
|
| 457 |
+
except KeyboardInterrupt:
|
| 458 |
+
for proc, _, _ in running.values():
|
| 459 |
+
proc.terminate()
|
| 460 |
+
log("interrupted; rerun the same command to resume")
|
| 461 |
+
raise SystemExit(130)
|
| 462 |
+
return failed
|
| 463 |
+
|
| 464 |
+
|
| 465 |
+
def global_pass(groups, jobs_dir, out_dir, log, write):
|
| 466 |
+
"""groups: [(output file, [job, ...])] in priority order. Drops documents whose md5 key or any band
|
| 467 |
+
key appeared in an earlier document, then keeps each job's documents in order until its target.
|
| 468 |
+
With `write`, writes the output files. Returns {job id: report}."""
|
| 469 |
+
jobs = [j for _, js in groups for j in js if is_done(jobs_dir, j)]
|
| 470 |
+
recs = [np.fromfile(paths(jobs_dir, j)["keys"], dtype=REC) for j in jobs]
|
| 471 |
+
allr = np.concatenate(recs) if recs else np.zeros(0, REC)
|
| 472 |
+
order = np.arange(len(allr))
|
| 473 |
+
dup = np.zeros(len(allr), bool)
|
| 474 |
+
for col in [allr["x"]] + [allr["b"][:, i] for i in range(BANDS)]:
|
| 475 |
+
_, first, inv = np.unique(col, return_index=True, return_inverse=True)
|
| 476 |
+
dup |= first[inv.ravel()] != order
|
| 477 |
+
avail, off = {}, 0
|
| 478 |
+
for j, r in zip(jobs, recs):
|
| 479 |
+
avail[j["id"]] = int(r["w"][~dup[off:off + len(r)]].sum(dtype=np.int64))
|
| 480 |
+
off += len(r)
|
| 481 |
+
# the shards of a source share its target: what one lost to duplicates, another with spare words fills
|
| 482 |
+
budget = {}
|
| 483 |
+
for _, js in groups:
|
| 484 |
+
short = sum(max(0, j["target"] - avail[j["id"]]) for j in js if j["id"] in avail)
|
| 485 |
+
for j in js:
|
| 486 |
+
if j["id"] in avail:
|
| 487 |
+
add = min(max(0, avail[j["id"]] - j["target"]), short)
|
| 488 |
+
budget[j["id"]] = j["target"] + add
|
| 489 |
+
short -= add
|
| 490 |
+
report, masks, off = {}, {}, 0
|
| 491 |
+
for j, r in zip(jobs, recs):
|
| 492 |
+
d, w = dup[off:off + len(r)], r["w"].astype(np.int64)
|
| 493 |
+
off += len(r)
|
| 494 |
+
keep = ~d
|
| 495 |
+
kw = np.where(keep, w, 0)
|
| 496 |
+
before = np.cumsum(kw) - kw
|
| 497 |
+
trimmed = keep & (before >= budget[j["id"]])
|
| 498 |
+
keep &= ~trimmed
|
| 499 |
+
masks[j["id"]] = keep
|
| 500 |
+
report[j["id"]] = dict(docs=int(keep.sum()), words=int(w[keep].sum()), dup_docs=int(d.sum()),
|
| 501 |
+
dup_words=int(w[d].sum()), trimmed_words=int(w[trimmed].sum()))
|
| 502 |
+
log(f"global dedup over {len(allr)} docs: {int(dup.sum())} duplicates across jobs, "
|
| 503 |
+
f"{sum(r['trimmed_words'] for r in report.values()) / 1e6:.2f}M words trimmed to quota")
|
| 504 |
+
if write:
|
| 505 |
+
wanted = {fname for fname, _ in groups}
|
| 506 |
+
for fname, js in groups:
|
| 507 |
+
tmp = out_dir / (fname + ".tmp")
|
| 508 |
+
with tmp.open("wb") as dst:
|
| 509 |
+
for j in js:
|
| 510 |
+
if j["id"] not in masks:
|
| 511 |
+
continue
|
| 512 |
+
mask, n = masks[j["id"]], 0
|
| 513 |
+
with paths(jobs_dir, j)["jsonl"].open("rb") as src:
|
| 514 |
+
for line in src:
|
| 515 |
+
if n >= len(mask):
|
| 516 |
+
break
|
| 517 |
+
if mask[n]:
|
| 518 |
+
dst.write(line)
|
| 519 |
+
n += 1
|
| 520 |
+
if n != len(mask):
|
| 521 |
+
raise RuntimeError(f"{j['id']}: {n} lines but {len(mask)} keys; delete its files and rerun")
|
| 522 |
+
os.replace(tmp, out_dir / fname)
|
| 523 |
+
# a top-up file from an earlier run that this plan no longer has would still be read by assemble.py
|
| 524 |
+
for stale in out_dir.glob("*.jsonl"):
|
| 525 |
+
if stale.name not in wanted:
|
| 526 |
+
stale.replace(stale.with_suffix(".jsonl.stale"))
|
| 527 |
+
log(f"renamed stale {stale.name} to .stale")
|
| 528 |
+
return report
|
| 529 |
+
|
| 530 |
+
|
| 531 |
+
def summarize(groups, jobs_dir, report):
|
| 532 |
+
out = []
|
| 533 |
+
for fname, js in groups:
|
| 534 |
+
ds = [read_json(paths(jobs_dir, j)["done"]) for j in js]
|
| 535 |
+
ds = [d for d in ds if d]
|
| 536 |
+
rs = [report[j["id"]] for j in js if j["id"] in report]
|
| 537 |
+
rej = Counter()
|
| 538 |
+
for d in ds:
|
| 539 |
+
rej.update(d["rejections"])
|
| 540 |
+
out.append(dict(
|
| 541 |
+
source=fname[:-len(".jsonl")], genre=mix.MIX[js[0]["name"]][0],
|
| 542 |
+
target_M=round(sum(j["target"] for j in js) / 1e6, 3),
|
| 543 |
+
words_M=round(sum(r["words"] for r in rs) / 1e6, 3), docs=sum(r["docs"] for r in rs),
|
| 544 |
+
collected_M=round(sum(d["words_M"] for d in ds), 3),
|
| 545 |
+
cross_job_duplicates_M=round(sum(r["dup_words"] for r in rs) / 1e6, 3),
|
| 546 |
+
trimmed_M=round(sum(r["trimmed_words"] for r in rs) / 1e6, 3),
|
| 547 |
+
scanned_words_M=round(sum(d["scanned_words_M"] for d in ds), 1),
|
| 548 |
+
seconds=sum(d["seconds"] for d in ds), shards=len(js), jobs_done=len(ds),
|
| 549 |
+
stopped=sorted({d["stopped"] for d in ds}), stream_retries=sum(d["stream_retries"] for d in ds),
|
| 550 |
+
rejections=dict(rej.most_common()),
|
| 551 |
+
jobs=[{k: d[k] for k in ("job", "words_M", "stopped", "relaxation", "probe")} for d in ds]))
|
| 552 |
+
return out
|
| 553 |
+
|
| 554 |
+
|
| 555 |
+
def main():
|
| 556 |
+
phys = psutil.cpu_count(logical=False) or 2
|
| 557 |
+
ap = argparse.ArgumentParser(description=__doc__.split("\n")[0])
|
| 558 |
+
ap.add_argument("size", choices=list(mix.SIZES))
|
| 559 |
+
ap.add_argument("--workers", type=int, default=max(1, phys // 2),
|
| 560 |
+
help=f"parallel jobs (default half the physical cores: {max(1, phys // 2)})")
|
| 561 |
+
ap.add_argument("--min-free-gb", type=float, default=2.0, help="start a job only above this free RAM")
|
| 562 |
+
ap.add_argument("--kill-free-gb", type=float, default=1.0, help="stop the youngest job below this free RAM")
|
| 563 |
+
ap.add_argument("--min-disk-gb", type=float, default=10.0, help="stop everything below this free disk")
|
| 564 |
+
ap.add_argument("--job-hours", type=float, default=1.5, help="split sources estimated above this")
|
| 565 |
+
ap.add_argument("--max-shards", type=int, default=6)
|
| 566 |
+
ap.add_argument("--overshoot", type=float, default=0.03, help="extra share collected before global dedup")
|
| 567 |
+
ap.add_argument("--ckpt-seconds", type=int, default=120)
|
| 568 |
+
ap.add_argument("--retries", type=int, default=3, help="restarts per job after a crash")
|
| 569 |
+
ap.add_argument("--stagger", type=int, default=20, help="seconds between job starts")
|
| 570 |
+
ap.add_argument("--status-seconds", type=int, default=300)
|
| 571 |
+
ap.add_argument("--scale", type=float, default=1.0, help="multiply quotas, for test runs")
|
| 572 |
+
ap.add_argument("--only", nargs="*", default=[], help="build only these sources (no fallbacks)")
|
| 573 |
+
ap.add_argument("--allow-failed", action="store_true", help="go on to fallbacks even if a job failed")
|
| 574 |
+
args = ap.parse_args()
|
| 575 |
+
size = args.size
|
| 576 |
+
apply_scale(args.scale, size)
|
| 577 |
+
out_dir = ROOT / "work" / (size if args.scale == 1 else f"{size}_x{args.scale:g}")
|
| 578 |
+
jobs_dir = out_dir / "jobs"
|
| 579 |
+
jobs_dir.mkdir(parents=True, exist_ok=True)
|
| 580 |
+
log = Log(out_dir / "pool.log")
|
| 581 |
+
psutil.Process().nice(psutil.BELOW_NORMAL_PRIORITY_CLASS if os.name == "nt" else 10)
|
| 582 |
+
t0, idx = time.time(), mix.SIZES[size]
|
| 583 |
+
names = [n for n in mix.MIX if not args.only or n in args.only]
|
| 584 |
+
log(f"== build {size} into {out_dir} ({' '.join(sys.argv[1:])})")
|
| 585 |
+
|
| 586 |
+
prim = plan_jobs([(n, mix.MIX[n][1][idx] * 1e6) for n in names], "", args, lambda n: [])
|
| 587 |
+
shards = Counter(j["name"] for j in prim)
|
| 588 |
+
log("plan: " + ", ".join(f"{n} x{k}" for n, k in shards.items()))
|
| 589 |
+
failed = run_pool(prim, args, size, jobs_dir, log)
|
| 590 |
+
if failed and not args.allow_failed:
|
| 591 |
+
raise SystemExit(f"{len(failed)} jobs failed: {[j['id'] for j in failed]}. Rerun the same command to "
|
| 592 |
+
"retry them, or add --allow-failed to fill their share from fallbacks.")
|
| 593 |
+
groups = [(f"{n}.jsonl", [j for j in prim if j["name"] == n]) for n in names if shards[n]]
|
| 594 |
+
|
| 595 |
+
fallback_log = []
|
| 596 |
+
if not args.only:
|
| 597 |
+
report = global_pass(groups, jobs_dir, out_dir, log, write=False)
|
| 598 |
+
got = Counter()
|
| 599 |
+
for j in prim:
|
| 600 |
+
got[j["name"]] += report.get(j["id"], {}).get("words", 0)
|
| 601 |
+
plan, fallback_log = build.plan_fallbacks(size, [dict(source=n, words_M=got[n] / 1e6) for n in names])
|
| 602 |
+
log(f"fallback plan: {fallback_log}")
|
| 603 |
+
topups = plan_jobs(list(plan.items()), ".topup", args,
|
| 604 |
+
lambda n: [str(paths(jobs_dir, j)["keys"]) for j in prim if j["name"] == n])
|
| 605 |
+
failed = run_pool(topups, args, size, jobs_dir, log)
|
| 606 |
+
if failed and not args.allow_failed:
|
| 607 |
+
raise SystemExit(f"{len(failed)} top-up jobs failed: {[j['id'] for j in failed]}. Rerun to retry.")
|
| 608 |
+
groups += [(f"{n}.topup.jsonl", [j for j in topups if j["name"] == n]) for n in plan]
|
| 609 |
+
|
| 610 |
+
report = global_pass(groups, jobs_dir, out_dir, log, write=True)
|
| 611 |
+
srcs = summarize(groups, jobs_dir, report)
|
| 612 |
+
total = sum(s["words_M"] for s in srcs)
|
| 613 |
+
stats = dict(total_M=round(total, 3), fallbacks=fallback_log, sources=srcs,
|
| 614 |
+
wall_seconds=round(time.time() - t0), options=vars(args))
|
| 615 |
+
(out_dir / "stats.json").write_text(json.dumps(stats, indent=1))
|
| 616 |
+
log(f"== total {total:.2f}M words in {(time.time() - t0) / 60:.0f} min wall")
|
| 617 |
+
|
| 618 |
+
|
| 619 |
+
if __name__ == "__main__":
|
| 620 |
+
main()
|
code/publish.py
CHANGED
|
@@ -11,7 +11,7 @@ from pathlib import Path
|
|
| 11 |
|
| 12 |
ROOT = Path(__file__).resolve().parent.parent
|
| 13 |
REPO = "jncarlo/tinymix"
|
| 14 |
-
SIZES = ["1M", "10M", "100M"]
|
| 15 |
GENRES = ["narrative", "dialogue", "expository", "books", "poetry", "news"]
|
| 16 |
# Sanity-check results: every tinymix row is retrained on the current builds (charset filter included).
|
| 17 |
INCLUDE_RESULTS = True
|
|
@@ -94,7 +94,7 @@ def card():
|
|
| 94 |
sizes, size_t, genre_t, src_t, lic_t = tables()
|
| 95 |
configs = ""
|
| 96 |
for s in sizes:
|
| 97 |
-
configs += f"- config_name: {s}\n data_files:\n - split: train\n path: data/{s}/train.parquet\n"
|
| 98 |
for p in sorted((ROOT / "out" / s / "parquet").glob("validation_*.parquet")):
|
| 99 |
configs += f" - split: {p.stem}\n path: data/{s}/{p.name}\n"
|
| 100 |
return f"""---
|
|
@@ -105,7 +105,7 @@ license_name: mixed-per-source
|
|
| 105 |
license_link: https://huggingface.co/datasets/{REPO}#sources-and-licensing
|
| 106 |
pretty_name: tinymix
|
| 107 |
size_categories:
|
| 108 |
-
-
|
| 109 |
task_categories:
|
| 110 |
- text-generation
|
| 111 |
tags:
|
|
@@ -119,7 +119,7 @@ configs:
|
|
| 119 |
|
| 120 |
# tinymix
|
| 121 |
|
| 122 |
-
Small, **genre-balanced English pretraining corpora** in
|
| 123 |
very small language models. The mix combines synthetic child-level stories and dialogue, simplified real text,
|
| 124 |
encyclopedic and didactic text, books, poetry and news, all filtered toward clear, self-contained documents. It is
|
| 125 |
inspired by TinyStories, SimpleStories, TinyHelen and the BabyLM challenge.
|
|
@@ -127,7 +127,7 @@ inspired by TinyStories, SimpleStories, TinyHelen and the BabyLM challenge.
|
|
| 127 |
What is different from using those datasets directly:
|
| 128 |
|
| 129 |
- **Several kinds of text in one mix** (narrative, dialogue and chat, expository, books, poetry, news), not only stories or only conversations.
|
| 130 |
-
- **
|
| 131 |
- **No non-commercial sources.** TinyChat (CC-BY-NC) and the BabyLM corpus (no clear license, includes subtitle and child-speech data) were left out on purpose.
|
| 132 |
- **Provenance per document** (`source`, `genre`) and **validation splits per genre**, to see which kind of text a model is weak at.
|
| 133 |
- The whole pipeline is included (`code/`) and every filter decision is documented below.
|
|
@@ -161,6 +161,10 @@ sources that could not fill their quota with the filters (Simple English Wikiped
|
|
| 161 |
same-genre substitute sources (tiny-textbooks, Cosmopedia v2), capped per source; that is why `tiny-textbooks` appears
|
| 162 |
there. The 1M subset keeps the 10M proportions except that Cosmopedia stories (not in the 10M mix) were replaced by TinyStories and SimpleStories.
|
| 163 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 164 |
## How it was built
|
| 165 |
|
| 166 |
1. **Normalisation**: `ftfy`, NFKC, ASCII quotes and dashes, whitespace; URLs, e-mails, phone numbers, code, LaTeX and HTML removed. Documents with any character outside ASCII, Latin-1 and Latin Extended-A letters, common punctuation and a few math symbols are rejected whole (reason `charset` in the build stats).
|
|
@@ -170,19 +174,19 @@ there. The 1M subset keeps the 10M proportions except that Cosmopedia stories (n
|
|
| 170 |
5. **Deduplication across all sources**: exact hash and MinHash LSH (5-word shingles, Jaccard >= 0.8).
|
| 171 |
6. **Complexity control by size** (vocabulary coverage = share of lowercase tokens inside the top-N English words of `wordfreq`):
|
| 172 |
|
| 173 |
-
| | 10M | 100M |
|
| 174 |
-
|---|---|---|
|
| 175 |
-
| Reference vocabulary | top 8k | top 15k |
|
| 176 |
-
| Min vocabulary coverage | 90% | 90% |
|
| 177 |
-
| Max Flesch-Kincaid grade (narrative, news, books) | 5 | 8 |
|
| 178 |
-
| Max Flesch-Kincaid grade (expository) | 9 | 10 |
|
| 179 |
-
| Document length | 80 to 600 words | 80 to 1200 words |
|
| 180 |
-
| Dialogue: mean words per turn | <= 25 | <= 40 |
|
| 181 |
|
| 182 |
Assistant chats (`User:` / `Assistant:`) may average up to 4 times the per-turn cap and need at least 2 turns (named dialogues need 4),
|
| 183 |
because summarisation and rewrite tasks have 2 turns and assistant answers are long.
|
| 184 |
|
| 185 |
-
Documents longer than the maximum are split at paragraph borders. The 1M subset is a prefix slice of the 10M build; 10M and
|
| 186 |
7. **Run safety nets** (used to build the larger subsets without manual tuning): a probe per source picks a starting filter strictness, strictness relaxes in up to three logged steps when yield is too low, and shortfalls go to substitute sources.
|
| 187 |
|
| 188 |
Thresholds were calibrated on real data: the first values (95% coverage in the top 5k words, Flesch-Kincaid <= 5 for everything)
|
|
@@ -195,7 +199,7 @@ accepted only 3% of SimpleStories and 0.6% of Cosmopedia v2, so they were relaxe
|
|
| 195 |
license of its `source`. Obligations that matter when redistributing or reusing it:
|
| 196 |
|
| 197 |
- Attribution is required for CC-BY / ODC-By / CDLA sources (listed above).
|
| 198 |
-
- The Wikipedia
|
| 199 |
- Cosmopedia, SmolTalk, UltraChat, TinyStories, SimpleStories, TinyHelen and tiny-textbooks contain **model-generated text**; check the terms of the generating model (GPT-4, GPT-4o-mini, Mixtral and others) for your use case.
|
| 200 |
- CNN/DailyMail articles and FineWeb-Edu web pages are third-party content; they are included under the dataset licenses above, which do not transfer rights from the original publishers.
|
| 201 |
- Project Gutenberg texts had the Project Gutenberg header and footer removed; they are public domain in the United States, check your jurisdiction.
|
|
@@ -213,9 +217,9 @@ No personal data was added; e-mails, phone numbers and URLs were removed, but re
|
|
| 213 |
|
| 214 |
## Reproduce
|
| 215 |
|
| 216 |
-
`code/` contains the build scripts (`mix.py` quotas and tiers, `sources.py` adapters, `build.py` pipeline, `
|
| 217 |
-
`publish.py`, `train.py` for the sanity-check runs) and `requirements.txt`. Building a subset:
|
| 218 |
-
then `python assemble.py 10M`. The build streams the source datasets from the Hub.
|
| 219 |
|
| 220 |
## Acknowledgements
|
| 221 |
|
|
@@ -230,10 +234,10 @@ def stage():
|
|
| 230 |
if out.exists():
|
| 231 |
shutil.rmtree(out)
|
| 232 |
(out / "code").mkdir(parents=True)
|
| 233 |
-
sizes = [s for s in SIZES if (ROOT / "out" / s / "parquet"
|
| 234 |
for s in sizes:
|
| 235 |
-
shutil.copytree(ROOT / "out" / s / "parquet", out / "data" / s)
|
| 236 |
-
for f in ("mix.py", "sources.py", "build.py", "assemble.py", "baselines.py", "train.py", "publish.py"):
|
| 237 |
shutil.copy(ROOT / "scripts" / f, out / "code" / f)
|
| 238 |
shutil.copy(ROOT / "requirements.txt", out / "code" / "requirements.txt")
|
| 239 |
(out / "README.md").write_text(card(), encoding="utf-8")
|
|
@@ -253,7 +257,7 @@ def main():
|
|
| 253 |
api.create_repo(REPO, repo_type="dataset", private=True, exist_ok=True)
|
| 254 |
api.upload_folder(folder_path=str(out), repo_id=REPO, repo_type="dataset",
|
| 255 |
commit_message="tinymix: " + ", ".join(p.name for p in (out / "data").iterdir()))
|
| 256 |
-
print(f"uploaded to https://huggingface.co/datasets/{REPO}
|
| 257 |
|
| 258 |
|
| 259 |
if __name__ == "__main__":
|
|
|
|
| 11 |
|
| 12 |
ROOT = Path(__file__).resolve().parent.parent
|
| 13 |
REPO = "jncarlo/tinymix"
|
| 14 |
+
SIZES = ["1M", "10M", "100M", "1000M"]
|
| 15 |
GENRES = ["narrative", "dialogue", "expository", "books", "poetry", "news"]
|
| 16 |
# Sanity-check results: every tinymix row is retrained on the current builds (charset filter included).
|
| 17 |
INCLUDE_RESULTS = True
|
|
|
|
| 94 |
sizes, size_t, genre_t, src_t, lic_t = tables()
|
| 95 |
configs = ""
|
| 96 |
for s in sizes:
|
| 97 |
+
configs += f"- config_name: {s}\n data_files:\n - split: train\n path: data/{s}/train*.parquet\n"
|
| 98 |
for p in sorted((ROOT / "out" / s / "parquet").glob("validation_*.parquet")):
|
| 99 |
configs += f" - split: {p.stem}\n path: data/{s}/{p.name}\n"
|
| 100 |
return f"""---
|
|
|
|
| 105 |
license_link: https://huggingface.co/datasets/{REPO}#sources-and-licensing
|
| 106 |
pretty_name: tinymix
|
| 107 |
size_categories:
|
| 108 |
+
- 1M<n<10M
|
| 109 |
task_categories:
|
| 110 |
- text-generation
|
| 111 |
tags:
|
|
|
|
| 119 |
|
| 120 |
# tinymix
|
| 121 |
|
| 122 |
+
Small, **genre-balanced English pretraining corpora** in four sizes (about 1M, 10M, 100M and 1000M words), built for training
|
| 123 |
very small language models. The mix combines synthetic child-level stories and dialogue, simplified real text,
|
| 124 |
encyclopedic and didactic text, books, poetry and news, all filtered toward clear, self-contained documents. It is
|
| 125 |
inspired by TinyStories, SimpleStories, TinyHelen and the BabyLM challenge.
|
|
|
|
| 127 |
What is different from using those datasets directly:
|
| 128 |
|
| 129 |
- **Several kinds of text in one mix** (narrative, dialogue and chat, expository, books, poetry, news), not only stories or only conversations.
|
| 130 |
+
- **Four sizes built with the same recipe**, with complexity limits that grow with size.
|
| 131 |
- **No non-commercial sources.** TinyChat (CC-BY-NC) and the BabyLM corpus (no clear license, includes subtitle and child-speech data) were left out on purpose.
|
| 132 |
- **Provenance per document** (`source`, `genre`) and **validation splits per genre**, to see which kind of text a model is weak at.
|
| 133 |
- The whole pipeline is included (`code/`) and every filter decision is documented below.
|
|
|
|
| 161 |
same-genre substitute sources (tiny-textbooks, Cosmopedia v2), capped per source; that is why `tiny-textbooks` appears
|
| 162 |
there. The 1M subset keeps the 10M proportions except that Cosmopedia stories (not in the 10M mix) were replaced by TinyStories and SimpleStories.
|
| 163 |
|
| 164 |
+
The 1000M subset is also within about 1% of its target. Five sources ran out under the filters before their quota and were
|
| 165 |
+
topped up by same-genre substitutes (million words): TinyDialogues by SODA (9.3), SmolTalk by UltraChat (12.3), TinyHelen by
|
| 166 |
+
tiny-textbooks (15.9), Simple English Wikipedia by tiny-textbooks (8.7) and English Wikipedia lead paragraphs by Cosmopedia v2 (17.0).
|
| 167 |
+
|
| 168 |
## How it was built
|
| 169 |
|
| 170 |
1. **Normalisation**: `ftfy`, NFKC, ASCII quotes and dashes, whitespace; URLs, e-mails, phone numbers, code, LaTeX and HTML removed. Documents with any character outside ASCII, Latin-1 and Latin Extended-A letters, common punctuation and a few math symbols are rejected whole (reason `charset` in the build stats).
|
|
|
|
| 174 |
5. **Deduplication across all sources**: exact hash and MinHash LSH (5-word shingles, Jaccard >= 0.8).
|
| 175 |
6. **Complexity control by size** (vocabulary coverage = share of lowercase tokens inside the top-N English words of `wordfreq`):
|
| 176 |
|
| 177 |
+
| | 10M | 100M | 1000M |
|
| 178 |
+
|---|---|---|---|
|
| 179 |
+
| Reference vocabulary | top 8k | top 15k | top 30k |
|
| 180 |
+
| Min vocabulary coverage | 90% | 90% | 90% |
|
| 181 |
+
| Max Flesch-Kincaid grade (narrative, news, books) | 5 | 8 | 12 |
|
| 182 |
+
| Max Flesch-Kincaid grade (expository) | 9 | 10 | 12 |
|
| 183 |
+
| Document length | 80 to 600 words | 80 to 1200 words | 80 to 2000 words |
|
| 184 |
+
| Dialogue: mean words per turn | <= 25 | <= 40 | <= 80 |
|
| 185 |
|
| 186 |
Assistant chats (`User:` / `Assistant:`) may average up to 4 times the per-turn cap and need at least 2 turns (named dialogues need 4),
|
| 187 |
because summarisation and rewrite tasks have 2 turns and assistant answers are long.
|
| 188 |
|
| 189 |
+
Documents longer than the maximum are split at paragraph borders. The 1M subset is a prefix slice of the 10M build; 10M, 100M and 1000M were built separately with the same recipe, so they are **not** guaranteed to be subsets of each other (a later fix to the end-of-document check, which wrongly rejected Wikipedia articles that end in a heading, was only applied to sources rebuilt for the 100M run).
|
| 190 |
7. **Run safety nets** (used to build the larger subsets without manual tuning): a probe per source picks a starting filter strictness, strictness relaxes in up to three logged steps when yield is too low, and shortfalls go to substitute sources.
|
| 191 |
|
| 192 |
Thresholds were calibrated on real data: the first values (95% coverage in the top 5k words, Flesch-Kincaid <= 5 for everything)
|
|
|
|
| 199 |
license of its `source`. Obligations that matter when redistributing or reusing it:
|
| 200 |
|
| 201 |
- Attribution is required for CC-BY / ODC-By / CDLA sources (listed above).
|
| 202 |
+
- The Wikipedia parts (`simplewiki`, `enwiki_intro`) are **CC-BY-SA-3.0 / GFDL (share-alike)**. If you need a share-alike-free corpus, filter out those two sources.
|
| 203 |
- Cosmopedia, SmolTalk, UltraChat, TinyStories, SimpleStories, TinyHelen and tiny-textbooks contain **model-generated text**; check the terms of the generating model (GPT-4, GPT-4o-mini, Mixtral and others) for your use case.
|
| 204 |
- CNN/DailyMail articles and FineWeb-Edu web pages are third-party content; they are included under the dataset licenses above, which do not transfer rights from the original publishers.
|
| 205 |
- Project Gutenberg texts had the Project Gutenberg header and footer removed; they are public domain in the United States, check your jurisdiction.
|
|
|
|
| 217 |
|
| 218 |
## Reproduce
|
| 219 |
|
| 220 |
+
`code/` contains the build scripts (`mix.py` quotas and tiers, `sources.py` adapters, `build.py` pipeline, `build_pool.py` for
|
| 221 |
+
1000M, `assemble.py`, `publish.py`, `train.py` for the sanity-check runs) and `requirements.txt`. Building a subset:
|
| 222 |
+
`python build.py 10M` (or `python build_pool.py 1000M`), then `python assemble.py 10M`. The build streams the source datasets from the Hub.
|
| 223 |
|
| 224 |
## Acknowledgements
|
| 225 |
|
|
|
|
| 234 |
if out.exists():
|
| 235 |
shutil.rmtree(out)
|
| 236 |
(out / "code").mkdir(parents=True)
|
| 237 |
+
sizes = [s for s in SIZES if any((ROOT / "out" / s / "parquet").glob("train*.parquet"))]
|
| 238 |
for s in sizes:
|
| 239 |
+
shutil.copytree(ROOT / "out" / s / "parquet", out / "data" / s, copy_function=os.link) # no second copy on disk
|
| 240 |
+
for f in ("mix.py", "sources.py", "build.py", "build_pool.py", "assemble.py", "baselines.py", "train.py", "publish.py"):
|
| 241 |
shutil.copy(ROOT / "scripts" / f, out / "code" / f)
|
| 242 |
shutil.copy(ROOT / "requirements.txt", out / "code" / "requirements.txt")
|
| 243 |
(out / "README.md").write_text(card(), encoding="utf-8")
|
|
|
|
| 257 |
api.create_repo(REPO, repo_type="dataset", private=True, exist_ok=True)
|
| 258 |
api.upload_folder(folder_path=str(out), repo_id=REPO, repo_type="dataset",
|
| 259 |
commit_message="tinymix: " + ", ".join(p.name for p in (out / "data").iterdir()))
|
| 260 |
+
print(f"uploaded to https://huggingface.co/datasets/{REPO}")
|
| 261 |
|
| 262 |
|
| 263 |
if __name__ == "__main__":
|
code/sources.py
CHANGED
|
@@ -9,11 +9,36 @@ from huggingface_hub import HfFileSystem
|
|
| 9 |
|
| 10 |
SEED = 0
|
| 11 |
EOT = "<|endoftext|>"
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
|
| 19 |
def _lines(path):
|
|
@@ -36,12 +61,12 @@ def tinystories(size):
|
|
| 36 |
|
| 37 |
|
| 38 |
def simplestories(size):
|
| 39 |
-
for r in _ds("SimpleStories/SimpleStories", split="train", shuffle=True):
|
| 40 |
yield {"text": r["story"]}
|
| 41 |
|
| 42 |
|
| 43 |
def cosmo_stories(size):
|
| 44 |
-
for r in _ds("HuggingFaceTB/cosmopedia", "stories", split="train", shuffle=True):
|
| 45 |
yield {"text": r["text"], "audience": r.get("audience")}
|
| 46 |
|
| 47 |
|
|
@@ -58,7 +83,7 @@ def tinydialogues(size):
|
|
| 58 |
|
| 59 |
|
| 60 |
def soda(size):
|
| 61 |
-
for r in _ds("allenai/soda", split="train", shuffle=True):
|
| 62 |
d, s = r["dialogue"], r["speakers"]
|
| 63 |
d = ast.literal_eval(d) if isinstance(d, str) else d
|
| 64 |
s = ast.literal_eval(s) if isinstance(s, str) else s
|
|
@@ -72,13 +97,13 @@ def _chat(msgs):
|
|
| 72 |
|
| 73 |
|
| 74 |
def ultrachat(size):
|
| 75 |
-
for r in _ds("HuggingFaceH4/ultrachat_200k", split="train_sft", shuffle=True):
|
| 76 |
yield {"turns": _chat(r["messages"])}
|
| 77 |
|
| 78 |
|
| 79 |
def smoltalk(size):
|
| 80 |
# interleave the three configs so none is exhausted first
|
| 81 |
-
its = [iter(_ds("HuggingFaceTB/smoltalk", c, split="train", shuffle=True))
|
| 82 |
for c in ("everyday-conversations", "smol-summarize", "smol-rewrite")]
|
| 83 |
while its:
|
| 84 |
for it in list(its):
|
|
@@ -105,26 +130,27 @@ def tinyhelen(size):
|
|
| 105 |
|
| 106 |
|
| 107 |
def simplewiki(size):
|
| 108 |
-
for r in _ds("wikimedia/wikipedia", "20231101.simple", split="train", shuffle=True):
|
| 109 |
yield {"text": r["text"], "title": r["title"]}
|
| 110 |
|
| 111 |
|
| 112 |
def enwiki_intro(size):
|
| 113 |
-
for r in _ds("wikimedia/wikipedia", "20231101.en", split="train", shuffle=True):
|
| 114 |
intro = r["text"].split("\n\n")[0]
|
| 115 |
yield {"text": intro, "title": r["title"]}
|
| 116 |
|
| 117 |
|
| 118 |
def cosmo_v2(size):
|
| 119 |
kids = {"young_children", "middle_school_students", "grade_school_students", "children"}
|
| 120 |
-
for r in _ds("HuggingFaceTB/smollm-corpus", "cosmopedia-v2", split="train", shuffle=True
|
|
|
|
| 121 |
if size == "10M" and r["audience"] not in kids:
|
| 122 |
continue
|
| 123 |
yield {"text": r["text"], "audience": r["audience"], "format": r["format"]}
|
| 124 |
|
| 125 |
|
| 126 |
def cosmo_v01(size):
|
| 127 |
-
its = [iter(_ds("HuggingFaceTB/cosmopedia", c, split="train", shuffle=True))
|
| 128 |
for c in ("wikihow", "khanacademy", "openstax")]
|
| 129 |
while its:
|
| 130 |
for it in list(its):
|
|
@@ -136,19 +162,21 @@ def cosmo_v01(size):
|
|
| 136 |
|
| 137 |
def tiny_textbooks(size):
|
| 138 |
# `text` is raw web (RefinedWeb); `textbook` is the synthetic lesson we want
|
| 139 |
-
for r in _ds("nampdn-ai/tiny-textbooks", split="train", shuffle=True):
|
| 140 |
yield {"text": r["textbook"]}
|
| 141 |
|
| 142 |
|
| 143 |
def fineweb_edu(size):
|
| 144 |
-
for r in _ds("HuggingFaceFW/fineweb-edu", "sample-10BT", split="train"):
|
| 145 |
if r["int_score"] >= 4:
|
| 146 |
yield {"text": r["text"]}
|
| 147 |
|
| 148 |
|
| 149 |
def gutenberg_books(size):
|
| 150 |
-
# whole books per row: a 20k-row shuffle buffer overflows Arrow's 2 GB string offsets
|
| 151 |
-
|
|
|
|
|
|
|
| 152 |
t = r["text"]
|
| 153 |
a = re.search(r"\*\*\* ?START OF (THE|THIS) PROJECT GUTENBERG[^\n]*\n", t)
|
| 154 |
b = re.search(r"\*\*\* ?END OF (THE|THIS) PROJECT GUTENBERG", t)
|
|
@@ -170,7 +198,7 @@ def gutenberg_books(size):
|
|
| 170 |
def poetry(size):
|
| 171 |
rng = random.Random(SEED)
|
| 172 |
cur, lines, target = None, [], rng.randint(4, 20)
|
| 173 |
-
for r in _ds("biglam/gutenberg-poetry-corpus", split="train"):
|
| 174 |
if r["gutenberg_id"] != cur:
|
| 175 |
cur, lines = r["gutenberg_id"], []
|
| 176 |
lines.append(r["line"].strip())
|
|
@@ -180,7 +208,7 @@ def poetry(size):
|
|
| 180 |
|
| 181 |
|
| 182 |
def cnn(size):
|
| 183 |
-
for r in _ds("abisee/cnn_dailymail", "3.0.0", split="train", shuffle=True):
|
| 184 |
text = r["article"]
|
| 185 |
if zlib.crc32(r["id"].encode()) % 10 < 3:
|
| 186 |
text += "\n\nIn short: " + " ".join(r["highlights"].split("\n"))
|
|
|
|
| 9 |
|
| 10 |
SEED = 0
|
| 11 |
EOT = "<|endoftext|>"
|
| 12 |
+
# (index, count): set by build_pool.py workers so each one streams a disjoint part of a dataset
|
| 13 |
+
SHARD = None
|
| 14 |
+
# adapter -> how many files `datasets` reads at once to fill a shuffle buffer (its default is 10).
|
| 15 |
+
# Set by build_pool.py; left empty, every build picks the same documents as before.
|
| 16 |
+
INPUT_SHARDS = {}
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
def _ds(*args, shuffle=False, buffer=20000, columns=None, input_shards=None, **kw):
|
| 20 |
+
# read only the columns an adapter uses: Arrow batches and the shuffle buffer hold whole rows, and
|
| 21 |
+
# Cosmopedia's long prompts nearly double a worker's memory (2.9 -> 1.5 GB). Parquet skips them on
|
| 22 |
+
# read; a format without that option drops them after. Rows and their order do not change.
|
| 23 |
+
try:
|
| 24 |
+
ds = load_dataset(*args, streaming=True, **({"columns": columns} if columns else {}), **kw)
|
| 25 |
+
except (TypeError, ValueError):
|
| 26 |
+
ds = load_dataset(*args, streaming=True, **kw)
|
| 27 |
+
if columns:
|
| 28 |
+
ds = ds.select_columns(columns)
|
| 29 |
+
if SHARD and SHARD[1] > 1:
|
| 30 |
+
i, k = SHARD
|
| 31 |
+
# whole files when there are enough of them, otherwise every k-th row (each worker
|
| 32 |
+
# then downloads the full stream but only processes its rows)
|
| 33 |
+
if ds.n_shards >= k:
|
| 34 |
+
ds = ds.shard(num_shards=k, index=i)
|
| 35 |
+
else:
|
| 36 |
+
ds = ds.filter(lambda _, idx: idx % k == i, with_indices=True)
|
| 37 |
+
if not shuffle:
|
| 38 |
+
return ds
|
| 39 |
+
if input_shards:
|
| 40 |
+
return ds.shuffle(seed=SEED, buffer_size=buffer, max_buffer_input_shards=input_shards)
|
| 41 |
+
return ds.shuffle(seed=SEED, buffer_size=buffer)
|
| 42 |
|
| 43 |
|
| 44 |
def _lines(path):
|
|
|
|
| 61 |
|
| 62 |
|
| 63 |
def simplestories(size):
|
| 64 |
+
for r in _ds("SimpleStories/SimpleStories", split="train", shuffle=True, columns=["story"]):
|
| 65 |
yield {"text": r["story"]}
|
| 66 |
|
| 67 |
|
| 68 |
def cosmo_stories(size):
|
| 69 |
+
for r in _ds("HuggingFaceTB/cosmopedia", "stories", split="train", shuffle=True, columns=["text", "audience"]):
|
| 70 |
yield {"text": r["text"], "audience": r.get("audience")}
|
| 71 |
|
| 72 |
|
|
|
|
| 83 |
|
| 84 |
|
| 85 |
def soda(size):
|
| 86 |
+
for r in _ds("allenai/soda", split="train", shuffle=True, columns=["dialogue", "speakers"]):
|
| 87 |
d, s = r["dialogue"], r["speakers"]
|
| 88 |
d = ast.literal_eval(d) if isinstance(d, str) else d
|
| 89 |
s = ast.literal_eval(s) if isinstance(s, str) else s
|
|
|
|
| 97 |
|
| 98 |
|
| 99 |
def ultrachat(size):
|
| 100 |
+
for r in _ds("HuggingFaceH4/ultrachat_200k", split="train_sft", shuffle=True, columns=["messages"]):
|
| 101 |
yield {"turns": _chat(r["messages"])}
|
| 102 |
|
| 103 |
|
| 104 |
def smoltalk(size):
|
| 105 |
# interleave the three configs so none is exhausted first
|
| 106 |
+
its = [iter(_ds("HuggingFaceTB/smoltalk", c, split="train", shuffle=True, columns=["messages"]))
|
| 107 |
for c in ("everyday-conversations", "smol-summarize", "smol-rewrite")]
|
| 108 |
while its:
|
| 109 |
for it in list(its):
|
|
|
|
| 130 |
|
| 131 |
|
| 132 |
def simplewiki(size):
|
| 133 |
+
for r in _ds("wikimedia/wikipedia", "20231101.simple", split="train", shuffle=True, columns=["text", "title"]):
|
| 134 |
yield {"text": r["text"], "title": r["title"]}
|
| 135 |
|
| 136 |
|
| 137 |
def enwiki_intro(size):
|
| 138 |
+
for r in _ds("wikimedia/wikipedia", "20231101.en", split="train", shuffle=True, columns=["text", "title"]):
|
| 139 |
intro = r["text"].split("\n\n")[0]
|
| 140 |
yield {"text": intro, "title": r["title"]}
|
| 141 |
|
| 142 |
|
| 143 |
def cosmo_v2(size):
|
| 144 |
kids = {"young_children", "middle_school_students", "grade_school_students", "children"}
|
| 145 |
+
for r in _ds("HuggingFaceTB/smollm-corpus", "cosmopedia-v2", split="train", shuffle=True,
|
| 146 |
+
columns=["text", "audience", "format"]):
|
| 147 |
if size == "10M" and r["audience"] not in kids:
|
| 148 |
continue
|
| 149 |
yield {"text": r["text"], "audience": r["audience"], "format": r["format"]}
|
| 150 |
|
| 151 |
|
| 152 |
def cosmo_v01(size):
|
| 153 |
+
its = [iter(_ds("HuggingFaceTB/cosmopedia", c, split="train", shuffle=True, columns=["text"]))
|
| 154 |
for c in ("wikihow", "khanacademy", "openstax")]
|
| 155 |
while its:
|
| 156 |
for it in list(its):
|
|
|
|
| 162 |
|
| 163 |
def tiny_textbooks(size):
|
| 164 |
# `text` is raw web (RefinedWeb); `textbook` is the synthetic lesson we want
|
| 165 |
+
for r in _ds("nampdn-ai/tiny-textbooks", split="train", shuffle=True, columns=["textbook"]):
|
| 166 |
yield {"text": r["textbook"]}
|
| 167 |
|
| 168 |
|
| 169 |
def fineweb_edu(size):
|
| 170 |
+
for r in _ds("HuggingFaceFW/fineweb-edu", "sample-10BT", split="train", columns=["text", "int_score"]):
|
| 171 |
if r["int_score"] >= 4:
|
| 172 |
yield {"text": r["text"]}
|
| 173 |
|
| 174 |
|
| 175 |
def gutenberg_books(size):
|
| 176 |
+
# whole books per row: a 20k-row shuffle buffer overflows Arrow's 2 GB string offsets, and each
|
| 177 |
+
# file decodes ~300 MB row groups, so reading 10 files at once peaks near 6 GB
|
| 178 |
+
for r in _ds("manu/project_gutenberg", split="en", shuffle=True, buffer=8, columns=["text"],
|
| 179 |
+
input_shards=INPUT_SHARDS.get("gutenberg_books")):
|
| 180 |
t = r["text"]
|
| 181 |
a = re.search(r"\*\*\* ?START OF (THE|THIS) PROJECT GUTENBERG[^\n]*\n", t)
|
| 182 |
b = re.search(r"\*\*\* ?END OF (THE|THIS) PROJECT GUTENBERG", t)
|
|
|
|
| 198 |
def poetry(size):
|
| 199 |
rng = random.Random(SEED)
|
| 200 |
cur, lines, target = None, [], rng.randint(4, 20)
|
| 201 |
+
for r in _ds("biglam/gutenberg-poetry-corpus", split="train", columns=["line", "gutenberg_id"]):
|
| 202 |
if r["gutenberg_id"] != cur:
|
| 203 |
cur, lines = r["gutenberg_id"], []
|
| 204 |
lines.append(r["line"].strip())
|
|
|
|
| 208 |
|
| 209 |
|
| 210 |
def cnn(size):
|
| 211 |
+
for r in _ds("abisee/cnn_dailymail", "3.0.0", split="train", shuffle=True, columns=["article", "highlights", "id"]):
|
| 212 |
text = r["article"]
|
| 213 |
if zlib.crc32(r["id"].encode()) % 10 < 3:
|
| 214 |
text += "\n\nIn short: " + " ".join(r["highlights"].split("\n"))
|
data/1000M/train-00000.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e0e89a6e86efedf21d3f2c9dd53560c14dabb75d14c62a6fd3d1045a3a7b7006
|
| 3 |
+
size 125647073
|
data/1000M/train-00001.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c0f000b31144e46e5c437509247b6eca4e810ca7cb286589edfe7a1258de68be
|
| 3 |
+
size 125743285
|
data/1000M/train-00002.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:3b66eb30e094e396e98010c14a09e6fb06d5b7743de3838d1630c6c43a4ea3df
|
| 3 |
+
size 125629837
|
data/1000M/train-00003.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:42692671ce46802fbc5e894d2ecbdc2456053b7b53073a9b6b703ac99a70d614
|
| 3 |
+
size 125664199
|
data/1000M/train-00004.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:0ab5b86b14be844707dc49839c73d06bbd324e3c6101f27274670be39a8ce0bb
|
| 3 |
+
size 125607426
|
data/1000M/train-00005.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b43885f446c1d4191d6660eb3c4a6512bcdd46bcc5acf5826d869f1db0079fad
|
| 3 |
+
size 125674371
|
data/1000M/train-00006.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:26bbe46ad224ee76a7d5df79822ab0ececf054230640092ab4647c8d7928b5f0
|
| 3 |
+
size 125748356
|
data/1000M/train-00007.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:eb1f4e578f497db4e60a82c928bc9f9f00a1c63d34bb29464914b54735593985
|
| 3 |
+
size 125725290
|
data/1000M/train-00008.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f08cbcb54f57165d7524b4179c31f3c00288daedc7b176aaed549396d1387f0b
|
| 3 |
+
size 125708938
|
data/1000M/train-00009.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:65c55791f389b3560422ca627a9b37834fdc748a429e58a5aaf713aac8755274
|
| 3 |
+
size 125708108
|
data/1000M/train-00010.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:99db248e819317d47d9f0ed8d9b6ecab0f2a29004f81b9c7ecd1bc0371dddec3
|
| 3 |
+
size 125761130
|
data/1000M/train-00011.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:207c0bc5203efb763810474b5617837e7b6f0e9e9fbceece029f4b719ec8d78f
|
| 3 |
+
size 125726302
|
data/1000M/train-00012.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:272cda5f9c0401151f0f067637670c8707f94b1ffcef3bab1141bae0298997af
|
| 3 |
+
size 125669726
|
data/1000M/train-00013.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:85c0054369651603384a950ff5180c93f6603c99e68a497a399afe41d4d364e4
|
| 3 |
+
size 125718066
|
data/1000M/train-00014.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:1a9502f6b809be46925ea8cc7653afda0a9721ed06d150908c3e4bb968f2a2ad
|
| 3 |
+
size 125671379
|
data/1000M/train-00015.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:18fb83c264dfee74e9ecd16ad07c761657a9544e2b97c840b465cbe04102a4a7
|
| 3 |
+
size 125698415
|
data/1000M/train-00016.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b4c127bf2478cccdc6dad8eb07bcdff0b01ce5d309229dc1422f7e62a09b8e86
|
| 3 |
+
size 125641566
|
data/1000M/train-00017.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:cf0c9a5aa544c142ed05cad49b6923e6b3a6154473e540dfee07fc7f0766ca58
|
| 3 |
+
size 125648859
|
data/1000M/train-00018.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:138614816d7563d189ba6fc023f64e23c3321a0bde4283cbe59c88e55cf65272
|
| 3 |
+
size 125727219
|
data/1000M/train-00019.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:6639af71a2e5137df5bb69ed6b8acfb99e47c55ee078ea1a4b15da5934bcf801
|
| 3 |
+
size 112912993
|
data/1000M/validation_books.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:17dfa7b7c90d2be963f381191ebbecc6df6d220419ec18f5ddb6f6d8895e9c26
|
| 3 |
+
size 911663
|
data/1000M/validation_dialogue.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:82ee336894f618263b250851676ff08aff8fb17ecbed481933c58bef9ec5f6d2
|
| 3 |
+
size 2034091
|
data/1000M/validation_expository.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d596442fe71daa9c005fd96f1084b1118a742c4337978ec846d84ed2e88a8dbd
|
| 3 |
+
size 7225166
|
data/1000M/validation_narrative.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a99eaa12b33e2bfbaa52874868d2c0ac32523eb16302e7cea3a9ef74489dcfd7
|
| 3 |
+
size 1712401
|
data/1000M/validation_news.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:79b77e149aa308fee433fe9c8614c6f73802579dfab55dc15b8e7d2399f979ce
|
| 3 |
+
size 252377
|
data/1000M/validation_poetry.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:98bd2b4dfa8f80baf68abde0510eb296209fa72bf2a4538d4b6e305fd28c9ac9
|
| 3 |
+
size 147503
|