oddadmix commited on
Commit
5b09a34
·
verified ·
1 Parent(s): cce96ad

add README.md

Browse files
Files changed (1) hide show
  1. README.md +66 -0
README.md ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language: [ar]
3
+ license: apache-2.0
4
+ library_name: transformers
5
+ pipeline_tag: fill-mask
6
+ tags: [arabic, bert, masked-lm, encoder, nawah, tiny]
7
+ datasets: [kaust-generative-ai/fineweb-edu-ar]
8
+ ---
9
+
10
+ # Nawah-BERT-6M-v2
11
+
12
+ A **5,993,600-parameter** Arabic BERT trained from scratch on **15B tokens**.
13
+ Same architecture as [`Nawah-BERT-6M`](https://huggingface.co/oddadmix/Nawah-BERT-6M)
14
+ (hidden 128, 8 layers, 2 heads, ctx 2,048, 32K vocab) — **only the token budget
15
+ changed**, and it changed everything.
16
+
17
+ ## v1 → v2: the token budget was the whole story
18
+
19
+ Held-out MLM on 1,024 chunks neither run trained on, standard 80/10/10:
20
+
21
+ | | tokens | loss @15% | **ppl** | loss @30% | in-context top-1 | top-5 |
22
+ |---|---|---|---|---|---|---|
23
+ | v1 | 5B | 6.0424 | 420.9 | 6.1053 | 2.7% | 7.3% |
24
+ | **v2** | **15B** | **3.3542** | **28.6** | **3.8419** | **37.2%** | **53.0%** |
25
+ | *corpus unigram* | — | *8.031* | *3,076* | — | — | — |
26
+
27
+ **Perplexity improved 14.7×** and single-mask recovery went from near-nothing to
28
+ recovering the exact token 37% of the time.
29
+
30
+ ### Correcting the v1 card
31
+
32
+ The v1 card said the model had *saturated* — that "5B tokens is roughly 500×
33
+ past Chinchilla-optimal for this size, and the flat tail is what that looks
34
+ like." **That was wrong.** The flat tail was the **cosine learning rate decaying
35
+ to zero**, not the model running out of capacity. Warm-starting at lr 3e-4 on
36
+ fresh tokens moved held-out loss 6.04 → 3.35. A 1.9M-parameter backbone had far
37
+ more to give than its own loss curve suggested.
38
+
39
+ ## Training
40
+
41
+ Continued from v1: 10B **unseen** tokens (permutation chunks 2,441,344 onward of
42
+ `tokens_20B_sep.bin`, so no repetition of what v1 saw), lr 3e-4 cosine, 38,146
43
+ steps at 262,144 tokens/step, mask 30%→15% annealed at step 33,949, bf16,
44
+ `torch_compile`. 3.5 h on a single consumer GPU. Total across both runs: 15B of
45
+ the corpus's 20B.
46
+
47
+ ## Downstream
48
+
49
+ Fine-tuned on three tasks and compared against the Llama models built for each.
50
+ Full numbers in each card:
51
+
52
+ | task | v1 | **v2** | reference (Llama) |
53
+ |---|---|---|---|
54
+ | [RuleCheck](https://huggingface.co/oddadmix/Nawah-RuleCheck-BERT-6M-v2) unseen wording | 0.9357 | **0.9598** | 0.9949 (5M) |
55
+ | [Guard](https://huggingface.co/oddadmix/Nawah-Guard-BERT-6M-v2) held-out over-refusal ↓ | 0.0146 | **0.0115** | 0.0094 (52M) |
56
+ | [Router](https://huggingface.co/oddadmix/Nawah-Router-BERT-6M-v2) unseen category sets | 0.9137 | **0.9327** | 0.9308 (52M) |
57
+
58
+ ### Use mean pooling, not [CLS]
59
+
60
+ Pretrained on **packed 2,048-token chunks with no `[CLS]`**, so position 0 has no
61
+ summary role and `BertForSequenceClassification`'s pooler arrives randomly
62
+ initialised. With it the model never leaves the class prior at any learning rate
63
+ from 1e-4 to 3e-3. Mean-pool over non-pad positions instead — see
64
+ `bert_meanpool.py` in the task repos.
65
+
66
+ © KAND CA 2026 — PROJECT NAWAH