kacperwikiel commited on
Commit
d21799f
·
verified ·
1 Parent(s): 6d68ec8

Document custom mixing and Chinchilla scaling

Browse files
Files changed (1) hide show
  1. README.md +44 -0
README.md CHANGED
@@ -42,3 +42,47 @@ See `catalog.json` for revisions, upstream URLs, document counts, hashes, and sa
42
  - `text`
43
 
44
  Use `source_key` or `category` to build a weighted mixture. `chunk_bytes` is the exact UTF-8 size of the row and can be summed for accounting.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
  - `text`
43
 
44
  Use `source_key` or `category` to build a weighted mixture. `chunk_bytes` is the exact UTF-8 size of the row and can be summed for accounting.
45
+
46
+ ## Build your own mix
47
+
48
+ Load the table, group by `source_key`, and sample rows with weights. This example gives Wikipedia 40%, EUR-Lex 30%, and literature 30%:
49
+
50
+ ```python
51
+ from datasets import load_dataset
52
+ from collections import defaultdict
53
+ import random
54
+
55
+ ds = load_dataset("SlayerLab/fabryka-track-polish-mix", split="train", streaming=True)
56
+ weights = {"wikipedia": .40, "eurlex": .30, "wolne_lektury": .15, "wikisource": .15}
57
+ rows = ((r["text"], r["source_key"]) for r in ds if r["source_key"] in weights)
58
+ by_source = defaultdict(list)
59
+ for text, source in rows:
60
+ by_source[source].append(text)
61
+ mix = []
62
+ for source, weight in weights.items():
63
+ n = round(1000 * weight)
64
+ mix.extend(random.choices(by_source[source], k=n))
65
+ random.shuffle(mix)
66
+ ```
67
+
68
+ For a streaming pipeline, keep a per-source iterator and draw the next source with `random.choices(..., weights=...)`; this avoids materializing the full corpus. Use `chunk_bytes` to stop at an exact byte-token budget.
69
+
70
+ ![Corpus size by source](source_sizes.png)
71
+
72
+ ## What can this corpus train?
73
+
74
+ The canonical expanded sources contain **655.4M UTF-8 byte tokens**. With the current byte-token trainer, a useful planning rule is:
75
+
76
+ | Model size | 20:1 budget | Fit in this corpus? |
77
+ |---:|---:|:---:|
78
+ | 8M | 160M tokens | Yes |
79
+ | 16M | 320M tokens | Yes |
80
+ | 32M | 640M tokens | Barely; only ~2.4% remains |
81
+ | 50M | 1B tokens | No |
82
+ | 100M | 2B tokens | No |
83
+
84
+ The 20:1 line is a Chinchilla-style planning heuristic, not a guarantee of model quality. This dataset uses bytes rather than a subword tokenizer, so the equivalent BPE-token count and the best training ratio will differ.
85
+
86
+ ![Chinchilla-style scaling budget](scaling_budget.png)
87
+
88
+ For a robust 32M run, target at least 800M–1B fresh tokens or allow a documented repeat factor. Larger models require more source text or a larger mix.