--- language: [ar] license: apache-2.0 library_name: transformers base_model: oddadmix/Nawah-BERT-6M-v2 datasets: [oddadmix/arabic-prompt-routing] tags: [arabic, zero-shot-classification, prompt-routing, router, bert, encoder, tiny-model] --- # Nawah-Router-BERT-6M-v2 — موجّه عربي صفري Give it a text and **any categories in plain Arabic**; it scores all of them in one forward pass. No fixed taxonomy. **5,977,985 parameters** against [`Nawah-Router-v3`](https://huggingface.co/oddadmix/Nawah-Router-v3)'s 52,049,409 — **8.7× smaller**. ## Results — it beats the 52M on three of four **All three models scored in one session** by the shipped `eval_router_only.py`; Router-v3 reproduced its published card (0.9305 / 0.6976 / 0.6130 / 0.9008). | eval | Router-v3 (Llama, 52M) | BERT-6M **v1** | **this model, v2** | random | |---|---|---|---|---| | unseen category sets | 0.9308 | 0.9137 | **0.9327** | 0.2137 | | unseen domains | 0.6975 | 0.6696 | **0.7009** | 0.2521 | | unseen axes | **0.6127** | 0.6024 | 0.6000 | 0.2358 | | deliberately adjacent categories | 0.9017 | 0.8924 | **0.9101** | 0.2109 | A 6M encoder **outperforms the 52M decoder** on unseen category sets (+0.2), unseen domains (+0.3) and adjacent categories (+0.8), at **1/8.7 the size**. **It loses on unseen axes** — 0.6000 against 0.6127 — and that is the column the original card calls its strongest claim: `tools` and `retrieval` appear nowhere in training. Note also that v2 is *worse* than v1 there (0.6024), the only metric across all three tasks where more pretraining hurt. Three of the four margins are under one point, which is within what a single run can tell you. ## Why no pooling change was needed `RouterModel` pools each category's **token span** via `bmm(cat_pool, hidden)` rather than a fixed position, so it is architecture-agnostic and a BERT backbone drops in unchanged. The sibling [`Nawah-Guard-BERT-6M-v2`](https://huggingface.co/oddadmix/Nawah-Guard-BERT-6M-v2) needed a mean-pooling patch; this did not. ## Usage ```python from transformers import AutoTokenizer from routing_model import RouterModel, route # ships in this repo M = "oddadmix/Nawah-Router-BERT-6M-v2" tok = AutoTokenizer.from_pretrained(M) model = RouterModel.from_pretrained(M) route(model, tok, "كم صار سعر صرف الدولار اليوم؟", ["بحث في الويب", "حاسبة", "تقويم ومواعيد", "لا يحتاج أداة"]) ``` Trained on `oddadmix/arabic-prompt-routing` (207,097 rows, 12 axes) with the dataset's own `train_router_head.py` at its defaults — decoder-tuned. © KAND CA 2026 — PROJECT NAWAH