oddadmix commited on
Commit
2f47fbc
·
verified ·
1 Parent(s): 5dd448d

add README.md

Browse files
Files changed (1) hide show
  1. README.md +63 -0
README.md ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language: [ar]
3
+ license: apache-2.0
4
+ library_name: transformers
5
+ base_model: oddadmix/Nawah-BERT-6M-v2
6
+ datasets: [oddadmix/arabic-prompt-routing]
7
+ tags: [arabic, zero-shot-classification, prompt-routing, router, bert, encoder, tiny-model]
8
+ ---
9
+
10
+ # Nawah-Router-BERT-6M-v2 — موجّه عربي صفري
11
+
12
+ Give it a text and **any categories in plain Arabic**; it scores all of them in
13
+ one forward pass. No fixed taxonomy. **5,977,985 parameters** against
14
+ [`Nawah-Router-v3`](https://huggingface.co/oddadmix/Nawah-Router-v3)'s
15
+ 52,049,409 — **8.7× smaller**.
16
+
17
+ ## Results — it beats the 52M on three of four
18
+
19
+ **All three models scored in one session** by the shipped `eval_router_only.py`;
20
+ Router-v3 reproduced its published card (0.9305 / 0.6976 / 0.6130 / 0.9008).
21
+
22
+ | eval | Router-v3 (Llama, 52M) | BERT-6M **v1** | **this model, v2** | random |
23
+ |---|---|---|---|---|
24
+ | unseen category sets | 0.9308 | 0.9137 | **0.9327** | 0.2137 |
25
+ | unseen domains | 0.6975 | 0.6696 | **0.7009** | 0.2521 |
26
+ | unseen axes | **0.6127** | 0.6024 | 0.6000 | 0.2358 |
27
+ | deliberately adjacent categories | 0.9017 | 0.8924 | **0.9101** | 0.2109 |
28
+
29
+ A 6M encoder **outperforms the 52M decoder** on unseen category sets (+0.2),
30
+ unseen domains (+0.3) and adjacent categories (+0.8), at **1/8.7 the size**.
31
+
32
+ **It loses on unseen axes** — 0.6000 against 0.6127 — and that is the column the
33
+ original card calls its strongest claim: `tools` and `retrieval` appear nowhere
34
+ in training. Note also that v2 is *worse* than v1 there (0.6024), the only
35
+ metric across all three tasks where more pretraining hurt. Three of the four
36
+ margins are under one point, which is within what a single run can tell you.
37
+
38
+ ## Why no pooling change was needed
39
+
40
+ `RouterModel` pools each category's **token span** via `bmm(cat_pool, hidden)`
41
+ rather than a fixed position, so it is architecture-agnostic and a BERT backbone
42
+ drops in unchanged. The sibling
43
+ [`Nawah-Guard-BERT-6M-v2`](https://huggingface.co/oddadmix/Nawah-Guard-BERT-6M-v2)
44
+ needed a mean-pooling patch; this did not.
45
+
46
+ ## Usage
47
+
48
+ ```python
49
+ from transformers import AutoTokenizer
50
+ from routing_model import RouterModel, route # ships in this repo
51
+
52
+ M = "oddadmix/Nawah-Router-BERT-6M-v2"
53
+ tok = AutoTokenizer.from_pretrained(M)
54
+ model = RouterModel.from_pretrained(M)
55
+
56
+ route(model, tok, "كم صار سعر صرف الدولار اليوم؟",
57
+ ["بحث في الويب", "حاسبة", "تقويم ومواعيد", "لا يحتاج أداة"])
58
+ ```
59
+
60
+ Trained on `oddadmix/arabic-prompt-routing` (207,097 rows, 12 axes) with the
61
+ dataset's own `train_router_head.py` at its defaults — decoder-tuned.
62
+
63
+ © KAND CA 2026 — PROJECT NAWAH