Download code/mix.py from jncarlo/tinymix: direct link, hf CLI and curl.
- Browser
- Download file 3.74 kB
-
https://huggingface.co/datasets/jncarlo/tinymix/resolve/main/code/mix.py
- Command line
-
hf download hf://datasets/jncarlo/tinymix/code/mix.py
-
curl -L -o mix.py https://huggingface.co/datasets/jncarlo/tinymix/resolve/main/code/mix.py
3.74 kB
| """Mix definition: million words per source for the 10M / 100M / 1000M versions.""" | |
| SIZES = {"10M": 0, "100M": 1, "1000M": 2} | |
| # key: (genre, (10M, 100M, 1000M) quota in million words) | |
| MIX = { | |
| "tinystories": ("narrative", (1.5, 8, 40)), | |
| "simplestories": ("narrative", (2.0, 8, 60)), | |
| "cosmo_stories": ("narrative", (0, 5, 50)), | |
| "tinydialogues": ("dialogue", (1.5, 7, 29)), | |
| "soda": ("dialogue", (1, 9, 75)), | |
| "ultrachat": ("dialogue", (0, 4, 61)), | |
| "smoltalk": ("dialogue", (0, 1, 25)), | |
| "tinyhelen": ("expository", (1.5, 10, 50)), | |
| "simplewiki": ("expository", (1, 10, 30)), | |
| "enwiki_intro": ("expository", (0, 0, 50)), | |
| "cosmo_v2": ("expository", (1, 12, 180)), | |
| "tiny_textbooks": ("expository", (0, 4, 40)), # uses the synthetic `textbook` column | |
| "cosmo_v01": ("expository", (0.5, 3, 30)), | |
| "fineweb_edu": ("expository", (0, 9, 180)), | |
| "gutenberg_books": ("books", (0, 8, 70)), | |
| "poetry": ("poetry", (0, 1, 10)), | |
| "cnn": ("news", (0, 1, 20)), | |
| } | |
| # Complexity tiers per size: reference vocab size, max Flesch-Kincaid grade, | |
| # document length range (words), max average words per dialogue turn. | |
| TIERS = { | |
| "10M": dict(vocab=8000, fk=5, fk_exp=9, doc_max=600, turn=25), | |
| "100M": dict(vocab=15000, fk=8, fk_exp=10, doc_max=1200, turn=40), | |
| "1000M": dict(vocab=30000, fk=12, fk_exp=12, doc_max=2000, turn=80), | |
| } | |
| # fk_exp: expository text (Cosmopedia textbooks) has median grade ~11 even for school | |
| # audiences, so fk=5 passed 0.2% of it. Vocabulary coverage still guards simplicity. | |
| # Assistant chats may average this many times the per-turn word cap of a named dialogue. | |
| CHAT_TURN_MULT = 4 | |
| # --- run safety nets (see build.py) --- | |
| # Relaxation ladder: (extra Flesch-Kincaid grades, change to vocabulary coverage). | |
| LADDER = [(0, 0.0), (1, -0.02), (2, -0.04), (3, -0.06)] | |
| PROBE_DOCS = 1000 # docs sampled before a source starts, to pick the starting ladder step | |
| WINDOW = 5000 # docs per yield check while a source runs | |
| MAX_SCAN = 40 # hard cap: raw words scanned per source = MAX_SCAN x its quota | |
| # When a source falls short, same-genre substitutes make up the difference in order. | |
| # A substitute may add at most max(EXTRA_FRAC x its quota, EXTRA_FLOOR x total target) | |
| # and never end above SHARE_CAP x total target. | |
| EXTRA_FRAC, EXTRA_FLOOR, SHARE_CAP = 0.5, 0.05, 0.35 | |
| FALLBACKS = { | |
| "tinystories": ["simplestories", "cosmo_stories"], | |
| "simplestories": ["tinystories", "cosmo_stories"], | |
| "cosmo_stories": ["simplestories", "tinystories"], | |
| "tinydialogues": ["soda", "smoltalk"], | |
| "soda": ["tinydialogues", "ultrachat", "smoltalk"], | |
| "ultrachat": ["smoltalk", "soda"], | |
| "smoltalk": ["ultrachat", "soda"], | |
| "tinyhelen": ["tiny_textbooks", "cosmo_v2", "fineweb_edu"], | |
| "simplewiki": ["tiny_textbooks", "tinyhelen", "cosmo_v2"], | |
| "enwiki_intro": ["cosmo_v2", "tiny_textbooks", "fineweb_edu"], | |
| "cosmo_v2": ["tiny_textbooks", "tinyhelen", "fineweb_edu"], | |
| "cosmo_v01": ["tiny_textbooks", "cosmo_v2", "tinyhelen"], | |
| "fineweb_edu": ["cosmo_v2", "tiny_textbooks", "tinyhelen"], | |
| "gutenberg_books": ["tinyhelen", "fineweb_edu"], | |
| "poetry": [], | |
| "cnn": ["fineweb_edu", "cosmo_v2"], | |
| } | |
| # min share of (lowercase) tokens inside the reference vocab. The original 95% @ top-5k | |
| # passed only 3% of SimpleStories and 35% of TinyStories, so it is 90% with larger vocabs. | |
| VOCAB_COVERAGE = 0.90 | |
| # English-only by construction and made of one-word toddler turns, which fastText misreads | |
| LID_SKIP = {"tinydialogues"} | |
| DOC_MIN = 80 | |