Upload README.md with huggingface_hub
Browse files16 unmodified lines1718192021222324252627282930313233341 unmodified line363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401412 unmodified lines14414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924016 unmodified lines- n>100K---# Darija Subword Tokenizer Benchmark (`OiQ/daa-tokenizers`)Comprehensive benchmark of 40 subword tokenizers for **Moroccan Darija** (Arabic and Arabizi/Latin scripts), trained on the [`OiQ/daa-pairs`](https://huggingface.co/datasets/OiQ/daa-pairs) dataset (112,814 sentence pairs).## Tokenizers| Type | Algorithms | Vocab Sizes | Count ||------|-----------|-------------|-------|| **Shared** (single vocab for Arabic + Arabizi) | BPE, Unigram, WordPiece, BBPE | 8K, 16K, 32K, 80K, 110K | 20 || **Concatenated** (separate Arabic/Arabizi vocabs, shifted IDs) | BPE, Unigram, WordPiece, BBPE | 8K, 16K, 32K, 80K, 110K | 20 |**Total: 40 tokenizer configurations**, released in both raw (HuggingFace `tokenizers`) and `transformers`-compatible formats. The 80K and 110K sizes match DarijaBERT's vocabulary sizes for direct comparison.## Quick Start1 unmodified linefrom transformers import AutoTokenizer# Load a shared tokenizertok = AutoTokenizer.from_pretrained("OiQ/daa-tokenizers", subfolder="transformers_tokenizers/shared_bpe_32000")# Load a concatenated tokenizer (Arabic)tok_ar = AutoTokenizer.from_pretrained("OiQ/daa-tokenizers", subfolder="transformers_tokenizers/concat_bpe_32000_tokenizer_ar")# Load a concatenated tokenizer (Arabizi/Latin)tok_az = AutoTokenizer.from_pretrained("OiQ/daa-tokenizers", subfolder="transformers_tokenizers/concat_bpe_32000_tokenizer_az")# Tokenizetext_ar = "Ω Ψ§Ψ¨ΩΨ§Ψ΄ ΩΩΨΉΨ±Ω Ψ΄ΩΩ ΩΨ―ΩΨ±Ψ Ψ¨ΩΩ Ψ§ΩΩΨ§ΩΩΩ ΩΨ¨ΩΩ ΩΩΩΨ―Ψ§ΨͺΩ."text_az = "wash kayn shi jdid?"print(tok.encode(text_ar))print(tok_az.encode(text_az))```## Evaluation Metrics### Surface Metrics- **Fertility**: Average tokens per word (lower = more efficient). Overall fertility is a word-count-weighted average of per-script fertilities: F β 0.65Β·F_ar + 0.35Β·F_az- **CPT**: Characters per token β grapheme-aware (higher = more efficient)- **Cross-script Disparity** (ΞF): Relative difference |F_ar β F_az| / max(F_ar, F_az). Zero = perfect cross-script fairness.- **Exact Match Rate**: Fraction of texts that round-trip perfectly- **Vocab Gini**: Vocabulary usage inequality (0 = uniform, 1 = concentrated)- **Shannon Entropy**: Token distribution entropy### Morphological Metrics (Arabic-script only)- **ΞΌe (Morphological Edit Distance)**: DP alignment between tokenizer token boundaries and Farasa morpheme boundaries. Lower = better morphological alignment.- **ΞΌc (Morphological Consistency F1)**: Whether shared morphemes (via KMeans clustering) are assigned shared tokens. Precision/Recall/F1.### StatisticsAll fertility and CPT metrics include **bootstrap 95% confidence intervals** (n=500 resamples).## Results Summary### Best Tokenizers by Vocabulary Size| Vocab Size | Name | Type | Algorithm | Fertility | Disparity | ΞΌe | ΞΌc F1 | Exact Match ||------------|------|------|-----------|-----------|-----------|----|------|-------------|| 8000 | shared_wordpiece_8000 | shared | WordPiece | **1.572** | 0.164 | 4.177 | 0.155 | 99.9% || 16000 | shared_wordpiece_16000 | shared | WordPiece | **1.402** | 0.138 | 4.116 | 0.139 | 99.9% || 32000 | shared_wordpiece_32000 | shared | WordPiece | **1.274** | 0.099 | 4.070 | 0.127 | 99.9% || 80000 | shared_wordpiece_80000 | shared | WordPiece | **1.171** | 0.049 | β | β | 99.9% || 110000 | concat_wordpiece_110000 | concatenated | WordPiece | **1.155** | 0.093 | β | β | 99.6% |### Key Patterns- **Compression**: BPE and WordPiece lead; BBPE has highest fertility at all sizes- **Saturation**: 80K and 110K produce nearly identical results (e.g., shared WordPiece: 1.171 at both sizes)- **Fairness**: Shared Unigram achieves ΞF = 0.015 at 80K/110K (lowest of any configuration); concatenated architectures maintain ΞF β€ 0.094- **BBPE disparity**: Shared BBPE has extreme cross-script bias (ΞF = 0.219β0.243); concatenation is essential for this algorithm- All 40 configurations achieve β₯99% exact match### Full Results Table| Name | Type | Algo | V | Fert | CPT | ΞF | EM | Gini ||------|------|------|---|------|-----|-----|-----|------|| shared_bpe_8000 | shared | BPE | 8K | 1.574 | 3.53 | 0.161 | 99.9% | 0.742 || concat_bpe_8000 | concat | BPE | 8K | 1.625 | 3.41 | 0.089 | 99.8% | 0.716 || shared_unigram_8000 | shared | Uni | 8K | 1.586 | 3.51 | 0.127 | 99.9% | 0.801 || concat_unigram_8000 | concat | Uni | 8K | 1.631 | 3.43 | 0.089 | 99.8% | 0.784 || shared_wordpiece_8000 | shared | WP | 8K | 1.572 | 3.53 | 0.164 | 99.9% | 0.725 || concat_wordpiece_8000 | concat | WP | 8K | 1.631 | 3.40 | 0.084 | 99.9% | 0.694 || shared_bbpe_8000 | shared | BBPE | 8K | 1.716 | 3.27 | 0.243 | 99.9% | 0.785 || concat_bbpe_8000 | concat | BBPE | 8K | 1.770 | 3.13 | 0.057 | 100.0% | 0.765 || shared_bpe_16000 | shared | BPE | 16K | 1.406 | 3.94 | 0.138 | 99.9% | 0.771 || concat_bpe_16000 | concat | BPE | 16K | 1.443 | 3.84 | 0.084 | 99.8% | 0.750 || shared_unigram_16000 | shared | Uni | 16K | 1.439 | 3.86 | 0.103 | 99.9% | 0.820 || concat_unigram_16000 | concat | Uni | 16K | 1.469 | 3.80 | 0.084 | 99.8% | 0.813 || shared_wordpiece_16000 | shared | WP | 16K | 1.402 | 3.95 | 0.138 | 99.9% | 0.757 || concat_wordpiece_16000 | concat | WP | 16K | 1.442 | 3.84 | 0.081 | 99.9% | 0.733 || shared_bbpe_16000 | shared | BBPE | 16K | 1.563 | 3.58 | 0.241 | 99.9% | 0.815 || concat_bbpe_16000 | concat | BBPE | 16K | 1.604 | 3.46 | 0.090 | 100.0% | 0.804 || shared_bpe_32000 | shared | BPE | 32K | 1.280 | 4.30 | 0.099 | 99.9% | 0.784 || concat_bpe_32000 | concat | BPE | 32K | 1.307 | 4.23 | 0.084 | 99.8% | 0.782 || shared_unigram_32000 | shared | Uni | 32K | 1.334 | 4.14 | 0.065 | 99.9% | 0.825 || concat_unigram_32000 | concat | Uni | 32K | 1.350 | 4.12 | 0.087 | 99.8% | 0.828 || shared_wordpiece_32000 | shared | WP | 32K | 1.274 | 4.32 | 0.099 | 99.9% | 0.775 || concat_wordpiece_32000 | concat | WP | 32K | 1.303 | 4.24 | 0.083 | 99.9% | 0.769 || shared_bbpe_32000 | shared | BBPE | 32K | 1.454 | 3.83 | 0.229 | 99.9% | 0.829 || concat_bbpe_32000 | concat | BBPE | 32K | 1.307 | 4.23 | 0.084 | 99.8% | 0.782 || shared_bpe_80000 | shared | BPE | 80K | 1.177 | 4.66 | 0.053 | 99.9% | 0.789 || concat_bpe_80000 | concat | BPE | 80K | 1.187 | 4.64 | 0.090 | 99.8% | 0.795 || shared_unigram_80000 | shared | Uni | 80K | 1.253 | 4.37 | 0.015 | 99.9% | 0.817 || concat_unigram_80000 | concat | Uni | 80K | 1.248 | 4.42 | 0.091 | 99.8% | 0.830 || shared_wordpiece_80000 | shared | WP | 80K | 1.171 | 4.68 | 0.049 | 99.9% | 0.784 || concat_wordpiece_80000 | concat | WP | 80K | 1.183 | 4.65 | 0.090 | 99.8% | 0.790 || shared_bbpe_80000 | shared | BBPE | 80K | 1.392 | 3.99 | 0.219 | 99.9% | 0.836 || concat_bbpe_80000 | concat | BBPE | 80K | 1.388 | 3.99 | 0.144 | 100.0% | 0.844 || shared_bpe_110000 | shared | BPE | 110K | 1.177 | 4.66 | 0.053 | 99.9% | 0.789 || concat_bpe_110000 | concat | BPE | 110K | 1.159 | 4.75 | 0.094 | 99.8% | 0.795 || shared_unigram_110000 | shared | Uni | 110K | 1.253 | 4.37 | 0.015 | 99.9% | 0.817 || concat_unigram_110000 | concat | Uni | 110K | 1.224 | 4.49 | 0.091 | 99.8% | 0.827 || shared_wordpiece_110000 | shared | WP | 110K | 1.171 | 4.68 | 0.049 | 99.9% | 0.784 || concat_wordpiece_110000 | concat | WP | 110K | 1.155 | 4.76 | 0.093 | 99.8% | 0.792 || shared_bbpe_110000 | shared | BBPE | 110K | 1.392 | 3.99 | 0.219 | 99.9% | 0.836 || concat_bbpe_110000 | concat | BBPE | 110K | 1.370 | 4.04 | 0.148 | 100.0% | 0.845 |## Visualizations### Fertility Comparison### Cross-Script Disparity2 unmodified lines### External Tokenizer Comparison## Comparison with Existing TokenizersWe compared our best tokenizers at matching vocabulary sizes against nine existing Arabic and Darija tokenizers:### MSA Tokenizers| Tokenizer | V | Fertility β | Disparity β | EM (Ar) | EM (Az) ||-----------|---|-------------|-------------|---------|---------|| **Ours: concat WP 80K** | **80K** | **1.183** | 0.090 | **99.9%** | **99.6%** || **Ours: concat WP 110K** | **110K** | **1.155** | 0.093 | **99.8%** | **99.6%** || [CaMeLBERT-MSA](https://huggingface.co/CAMeL-Lab/bert-base-arabic-camelbert-msa) | 30K | 2.289 | 0.427 | 29.9% | 38.9% || [Asafaya-BERT](https://huggingface.co/asafaya/bert-base-arabic) | 32K | 2.143 | 0.358 | 19.9% | 15.2% || [Aranizer-SP-86k](https://huggingface.co/riotu-lab/Aranizer-SP-86k) | 86K | 1.918 | 0.368 | 99.8% | 99.6% || [B2BERT](https://huggingface.co/AHAAM/B2BERT) | 30K | 2.289 | 0.427 | 29.9% | 38.9% |### Darija Tokenizers| Tokenizer | V | Fertility β | Disparity β | EM (Ar) | EM (Az) ||-----------|---|-------------|-------------|---------|---------|| **Ours: concat BPE 32K** | **32K** | **1.307** | 0.084 | **99.9%** | **99.6%** || **Ours: concat WP 80K** | **80K** | **1.183** | 0.090 | **99.9%** | **99.6%** || **Ours: concat WP 110K** | **110K** | **1.155** | 0.093 | **99.8%** | **99.6%** || [DarijaBERT-ar](https://huggingface.co/SI2M-Lab/DarijaBERT) | 80K | 1.761 | 0.410 | 13.7% | 8.0% || [DarijaBERT-az](https://huggingface.co/SI2M-Lab/DarijaBERT-arabizi) | 110K | 1.575 | 0.055 | 14.8% | 8.0% || [Darija-Tokenizer](https://huggingface.co/BounharAbdelaziz/Moroccan-Darija-Tokenizer) | 30K | 2.034 | 0.459 | 0.0% | 0.0% || [Translit-Darija](https://huggingface.co/atlasia/Transliteration-Moroccan-Darija) | 30K | 1.748 | 0.077 | 0.0% | 0.0% || [Qwen2.5-Darija](https://huggingface.co/GemMaroc/Qwen2.5-7B-Instruct-darija) | 152K | 2.307 | 0.040 | 100.0% | 100.0% |### Key Results- At matching vocabulary sizes, our 80K tokenizer achieves **33% lower fertility** than DarijaBERT-ar (1.183 vs 1.761), and our 110K tokenizer achieves **27% lower fertility** than DarijaBERT-az (1.155 vs 1.575)- Our 32K tokenizer (1.307) outperforms DarijaBERT-az (1.575) by 17% despite using 3.4Γ fewer vocabulary slots- MSA tokenizers produce **40β50% higher fertility** than our best tokenizer- Qwen2.5-Darija (152K vocab) achieves only 2.307 fertility β **76% higher** than our 32K tokenizer- All external tokenizers (except DarijaBERT-az, Translit-Darija, Qwen2.5-Darija) exhibit cross-script disparity > 0.35; our tokenizers maintain β€ 0.094- All 40 of our tokenizer configurations achieve β₯99% exact match; most external BERT-based tokenizers fail to reconstruct Darija text (<40%)## Code-Switching Evaluation32% of test texts contain intra-sentence script switching (Arabic + Arabizi). Mixed-script texts require 7β14% more tokens than pure-script text (F_mi=1.404 vs F_ar=1.308 at 32K). All our tokenizers achieve β₯99.5% exact match on code-switched input.## Arabizi Validation (atlasia/DODa)We evaluate on [atlasia/DODa](https://huggingface.co/datasets/atlasia/DODa) (87K Arabizi entries), a dictionary not used in training. Since we train on Arabizi, this is an in-domain but distributionally distinct validation:| Tokenizer | V | Fert β | CPT β | EM ||-----------|---|--------|-------|-----|| concat BPE 32K | 32K | 1.909 | 3.19 | 100.00% || concat WP 80K | 80K | 1.768 | 3.55 | 99.97% || concat WP 110K | 110K | 1.735 | 3.63 | 99.97% || **DarijaBERT-az** | **110K** | **1.314** | **4.55** | 94.4% || Translit-Darija | 30K | 1.869 | 3.21 | 3.0% || CaMeLBERT-MSA | 30K | 3.667 | 1.59 | 98.4% || Asafaya-BERT | 32K | 3.187 | 1.83 | 94.6% |DODa is a dictionary of diverse vocabulary, not sentences β fertility is higher for all tokenizers vs. sentence-level evaluation. DarijaBERT-az (trained specifically for Arabizi) achieves the lowest fertility here.## Methodology1. **Dataset**: `OiQ/daa-pairs` β 112,814 Moroccan Darija sentence pairs in Arabic script and Arabizi2. **Pre-tokenization**: Metaspace (BPE/Unigram/WordPiece) or ByteLevel (BBPE)3. **Training**: HuggingFace `tokenizers` library with standard trainer hyperparameters4. **Evaluation**: 14 metrics including fertility, CPT, disparity, exact match, morphological alignment (Farasa), and bootstrap CIs5. **Export**: `transformers`-compatible format via `PreTrainedTokenizerFast`## Repository Structure```daa-tokenizers/βββ README.mdβββ script.py # Benchmark script (reproducible)βββ eval_test_set.py # Test-set evaluationβββ eval_all_externals.py # External tokenizer comparisonβββ test_set_results.csv # Single source of truth (40 tokenizers)βββ external_comparison.csv # Comparison with external tokenizersβββ bootstrap_ci_test_set.csv # Bootstrap 95% CIsβββ tokenizer_results.csv # Full metrics table (morphological)βββ morphology/β βββ farasa_segmentations.json # Cached Farasa morph segmentationsβββ tokenizers/ # Raw tokenizer JSON files (60 files)βββ transformers_tokenizers/ # 60 dirs for transformers libraryβββ plots/ # Visualization PNGs```## Citation```bibtex@misc{laamiri2026daa-tokenizers,title={Darija Subword Tokenizer Benchmark},author={Laamiri, Ouail and Berrada, Ismail and Belfadil, Anas},year={2026},url={https://huggingface.co/OiQ/daa-tokenizers}}```16 unmodified lines1718192021222324252627282930313233343536373839404142434445464748491 unmodified line515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391402 unmodified lines14314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923016 unmodified lines- n>100K---# Darija Subword Tokenizer Benchmark<p align="center"><strong>In collaboration with</strong><br><a href="https://www.um6p.ma/en/um6p-college-computing">UM6P College of Computing</a></p>---## OverviewThe first systematic subword tokenizer benchmark for **Moroccan Darija**, a low-resource dialect written concurrently in Arabic script and Arabizi (Latin script). We train and evaluate **40 tokenizer configurations** spanning four algorithms, two architectures, and five vocabulary sizes (8K--110K) on 112,814 parallel sentence pairs from [`OiQ/daa-pairs`](https://huggingface.co/datasets/OiQ/daa-pairs).Our tokenizers achieve **27--34% lower fertility** than existing Darija tokenizers (DarijaBERT) at matching vocabulary sizes, and **40--50% lower fertility** than MSA-trained tokenizers. All 40 configurations maintain $\geq$99% exact reconstruction.---## Tokenizers| Architecture | Description | Algorithms | Vocab Sizes | Count ||---|---|---|---|---|| **Shared** | Single vocabulary trained on mixed Arabic + Arabizi corpus | BPE, Unigram, WordPiece, BBPE | 8K, 16K, 32K, 80K, 110K | 20 || **Concatenated** | Separate per-script vocabularies ($V/2$ each) with ID shifting | BPE, Unigram, WordPiece, BBPE | 8K, 16K, 32K, 80K, 110K | 20 |All tokenizers are released in both raw (HuggingFace `tokenizers`) and `transformers`-compatible formats. The 80K and 110K sizes match DarijaBERT's vocabulary sizes for direct comparison.---## Quick Start1 unmodified linefrom transformers import AutoTokenizer# Load a shared tokenizertok = AutoTokenizer.from_pretrained("OiQ/daa-tokenizers",subfolder="transformers_tokenizers/shared_bpe_32000")# Tokenize Arabic-script texttext_ar = "Ω Ψ§Ψ¨ΩΨ§Ψ΄ ΩΩΨΉΨ±Ω Ψ΄ΩΩ ΩΨ―ΩΨ±Ψ Ψ¨ΩΩ Ψ§ΩΩΨ§ΩΩΩ ΩΨ¨ΩΩ ΩΩΩΨ―Ψ§ΨͺΩ."print(tok.encode(text_ar))# Load a concatenated tokenizer (separate Arabic and Arabizi sub-tokenizers)tok_ar = AutoTokenizer.from_pretrained("OiQ/daa-tokenizers",subfolder="transformers_tokenizers/concat_bpe_32000_tokenizer_ar")tok_az = AutoTokenizer.from_pretrained("OiQ/daa-tokenizers",subfolder="transformers_tokenizers/concat_bpe_32000_tokenizer_az")text_az = "wash kayn shi jdid?"print(tok_az.encode(text_az))```---## Key Results### Best Tokenizer per Vocabulary Size| Vocab | Configuration | Algorithm | Fertility $\downarrow$ | Disparity $\downarrow$ | Exact Match ||---|---|---|---|---|---|| 8K | Shared | WordPiece | **1.572** | 0.164 | 99.9% || 16K | Shared | WordPiece | **1.402** | 0.138 | 99.9% || 32K | Shared | WordPiece | **1.274** | 0.099 | 99.9% || 80K | Shared | WordPiece | **1.171** | 0.049 | 99.9% || 110K | Concat | WordPiece | **1.155** | 0.093 | 99.6% |### Comparison with Existing Tokenizers| Tokenizer | Vocab | Fertility $\downarrow$ | Disparity $\downarrow$ | EM (Ar) | EM (Az) ||---|---|---|---|---|---|| **Ours: concat WP 110K** | **110K** | **1.155** | 0.093 | **99.9%** | **99.6%** || **Ours: concat WP 80K** | **80K** | **1.183** | 0.090 | **99.9%** | **99.6%** || **Ours: concat BPE 32K** | **32K** | **1.307** | 0.084 | **99.9%** | **99.6%** || DarijaBERT-ar | 80K | 1.761 | 0.410 | 13.7% | 8.0% || DarijaBERT-az | 110K | 1.575 | 0.055 | 14.8% | 8.0% || CaMeLBERT-MSA | 30K | 2.289 | 0.427 | 29.9% | 38.9% || Aranizer-SP-86k | 86K | 1.918 | 0.368 | 99.8% | 99.6% || Qwen2.5-Darija | 152K | 2.307 | 0.040 | 100.0% | 100.0% |At matching vocabulary sizes, our 80K tokenizer achieves **33% lower fertility** than DarijaBERT-ar (1.183 vs 1.761). Our 110K achieves **27% lower** than DarijaBERT-az (1.155 vs 1.575). Even our 32K tokenizer outperforms DarijaBERT-az despite using 3.4x fewer vocabulary slots.---## Evaluation Metrics### Compression & Fairness| Metric | Definition | Direction ||---|---|---|| **Fertility** ($F$) | Tokens per word, averaged over test set | Lower is better || **CPT** | Grapheme clusters per token (Unicode-aware) | Higher is better || **Disparity** ($\Delta F$) | Relative cross-script gap: $\|F_{ar} - F_{az}\| / \max(F_{ar}, F_{az})$ | Lower is better || **Exact Match** | Fraction of texts that round-trip perfectly through encode/decode | Higher is better || **Gini** | Vocabulary usage inequality (0 = uniform, 1 = concentrated) | Lower is better |Overall fertility is word-count-weighted: $F \approx 0.65 \cdot F_{ar} + 0.35 \cdot F_{az}$### Morphological Fidelity (Arabic-script only)| Metric | Definition | Direction ||---|---|---|| **$\mu_e$** | Edit distance between tokenizer boundaries and Farasa morpheme boundaries | Lower is better || **$\mu_c$-F1** | Whether words sharing morphemes also share tokens (KMeans + TF-IDF) | Higher is better |### Statistical RigorAll fertility and CPT values include **bootstrap 95% confidence intervals** (500 resamples). CI width is $\leq 0.006$ for all configurations.---## Visualizations### Fertility by Algorithm and Vocabulary Size### Cross-Script Disparity2 unmodified lines### External Tokenizer Comparison---## Key Findings1. **Darija-specific tokenization dramatically improves compression.** Our tokenizers achieve 27--34% lower fertility than DarijaBERT at matching vocabulary sizes.2. **Cross-script fairness is achievable.** Shared Unigram at 80K reaches $\Delta F = 0.015$ (near-zero disparity) without concatenation. Concatenated architectures maintain $\Delta F \leq 0.094$ across all non-BBPE algorithms.3. **Vocabulary size saturates early.** Moving from 32K to 110K yields only marginal gains. The training corpus exhausts merge candidates around 80K.4. **BBPE requires concatenation.** Shared BBPE exhibits extreme cross-script disparity ($\Delta F = 0.219$--$0.243$). Concatenation reduces this 4x.5. **MSA tokenizers transfer poorly to Darija.** They produce 40--50% higher fertility, allocating vocabulary to MSA patterns absent in Darija.---## Methodology| Stage | Details ||---|---|| **Dataset** | `OiQ/daa-pairs` β 112,814 Moroccan Darija sentence triplets (Arabic, Arabizi, Mixed) from 12,695 unique sources || **Split** | 80/10/10 train/validation/test with stratified sampling || **Pre-tokenization** | Metaspace (BPE/Unigram/WordPiece) or ByteLevel (BBPE) || **Training** | HuggingFace `tokenizers` library with matched pre-tokenizer/decoder pairs || **Evaluation** | 14 metrics on 33,846 test texts (11,282 per script x 3 scripts) || **Morphological** | Farasa segmenter for gold-standard Arabic morpheme boundaries || **Export** | Raw + `transformers`-compatible via `PreTrainedTokenizerFast` |---## Code & ReproducibilityAll scripts, evaluation code, and documentation are included in this repository. See [`code.md`](code.md) for a complete guide to every script and its outputs.### Repository Structure```daa-tokenizers/βββ README.md # This fileβββ code.md # Script documentationβββ script.py # Master benchmark pipelineβββ eval_test_set.py # Test-set evaluationβββ eval_morph_large.py # Morphological metrics (80K/110K)βββ bootstrap_test_set.py # Bootstrap confidence intervalsβββ eval_all_externals.py # External tokenizer comparisonβββ eval_codeswitch_and_new_baselines.pyβββ eval_doda_independent.py # DODa validationβββ regen_figures.py # Figure generationβββ verify_arithmetic.py # Numeric claims verificationβββ results/β βββ test_set_results.csv # Primary results (40 tokenizers)β βββ external_comparison.csv # External comparisonβ βββ morph_large_vocab_results.csv# Morphological metrics (80K/110K)β βββ bootstrap_ci_test_set.csv # Bootstrap 95% CIsβ βββ tokenizers/ # 60 raw tokenizer JSONsβ βββ transformers_tokenizers/ # Transformers-compatible exportsβ βββ corpora/ # Train/test text splitsβ βββ morphology/ # Farasa segmentations cacheβ βββ plots/ # All visualization PNGsβββ plots/ # Paper figures```---## Citation```bibtex@misc{laamiri2026daa-tokenizers,title = {Darija Subword Tokenizer Benchmark},author = {Laamiri, Ouail and Berrada, Ismail and Belfadil, Anas},year = {2026},url = {https://huggingface.co/OiQ/daa-tokenizers},note = {In collaboration with UM6P College of Computing}}```---## LicenseMIT License β see [LICENSE](LICENSE) for details.## AcknowledgmentsThis work was developed in collaboration with the [UM6P College of Computing](https://www.um6p.ma/en/um6p-college-computing), Mohammed VI Polytechnic University, Ben Guerir, Morocco. We thank the HuggingFace community for providing the infrastructure to host these resources.
README.md+155-165