Text Generation
fastText
Moroccan Arabic
wikilangs
nlp
tokenizer
embeddings
n-gram
markov
wikipedia
feature-extraction
sentence-similarity
tokenization
n-grams
markov-chain
text-mining
babelvec
vocabulous
vocabulary
monolingual
family-arabic
Instructions to use wikilangs/ary with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- fastText
How to use wikilangs/ary with fastText:
from huggingface_hub import hf_hub_download import fasttext model = fasttext.load_model(hf_hub_download("wikilangs/ary", "model.bin")) - Notebooks
- Google Colab
- Kaggle
Upload all models and assets for ary (latest)
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
Files changed (50)
- README.md+130-665
- RESEARCH_REPORT.mdAdded+688
- ary_morph_tokenizer.jsonAdded
- models/embeddings/aligned/ary_128d.bin+2-2
- models/embeddings/aligned/ary_128d.projection.npy+1-1
- models/embeddings/aligned/ary_128d_metadata.json+2-2
- models/embeddings/aligned/ary_32d.bin+2-2
- models/embeddings/aligned/ary_32d.projection.npy+1-1
- models/embeddings/aligned/ary_32d_metadata.json+2-2
- models/embeddings/aligned/ary_64d.bin+2-2
- models/embeddings/aligned/ary_64d.projection.npy+1-1
- models/embeddings/aligned/ary_64d_metadata.json+2-2
- models/embeddings/monolingual/ary_128d.bin+2-2
- models/embeddings/monolingual/ary_128d_metadata.json+3-2
- models/embeddings/monolingual/ary_32d.bin+2-2
- models/embeddings/monolingual/ary_32d_metadata.json+3-2
- models/embeddings/monolingual/ary_64d.bin+2-2
- models/embeddings/monolingual/ary_64d_metadata.json+3-2
- models/subword_markov/ary_markov_ctx1_subword.parquet+2-2
- models/subword_markov/ary_markov_ctx1_subword_metadata.json+2-2
- models/subword_markov/ary_markov_ctx2_subword.parquet+2-2
- models/subword_markov/ary_markov_ctx2_subword_metadata.json+2-2
- models/subword_markov/ary_markov_ctx3_subword.parquet+2-2
- models/subword_markov/ary_markov_ctx3_subword_metadata.json+2-2
- models/subword_markov/ary_markov_ctx4_subword.parquet+2-2
- models/subword_markov/ary_markov_ctx4_subword_metadata.json+2-2
- models/subword_ngram/ary_2gram_subword.parquet+2-2
- models/subword_ngram/ary_2gram_subword_metadata.json+2-2
- models/subword_ngram/ary_3gram_subword.parquet+2-2
- models/subword_ngram/ary_3gram_subword_metadata.json+2-2
- models/subword_ngram/ary_4gram_subword.parquet+2-2
- models/subword_ngram/ary_4gram_subword_metadata.json+2-2
- models/subword_ngram/ary_5gram_subword.parquet+2-2
- models/subword_ngram/ary_5gram_subword_metadata.json+2-2
- models/tokenizer/ary_tokenizer_16k.model+2-2
- models/tokenizer/ary_tokenizer_16k.vocab
- models/tokenizer/ary_tokenizer_32k.model+2-2
- models/tokenizer/ary_tokenizer_32k.vocab
- models/tokenizer/ary_tokenizer_64k.model+2-2
- models/tokenizer/ary_tokenizer_64k.vocab
- models/tokenizer/ary_tokenizer_8k.model+2-2
- models/tokenizer/ary_tokenizer_8k.vocab
- models/vocabulary/ary_vocabulary.parquet+2-2
- models/vocabulary/ary_vocabulary_metadata.json+9-9
- models/word_markov/ary_markov_ctx1_word.parquet+2-2
- models/word_markov/ary_markov_ctx1_word_metadata.json+2-2
- models/word_markov/ary_markov_ctx2_word.parquet+2-2
- models/word_markov/ary_markov_ctx2_word_metadata.json+2-2
- models/word_markov/ary_markov_ctx3_word.parquet+2-2
- models/word_markov/ary_markov_ctx3_word_metadata.json+2-2
32 unmodified lines3334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476532 unmodified linesmetrics:- name: best_compression_ratiotype: compressionvalue: 4.171- name: best_isotropytype: isotropyvalue: 0.8284- name: vocabulary_sizetype: vocabvalue: 0generated: 2026-01-03---# Moroccan Arabic - Wikilangs Models## Comprehensive Research Report & Full Ablation StudyThis repository contains NLP models trained and evaluated by Wikilangs, specifically on **Moroccan Arabic** Wikipedia data.We analyze tokenizers, n-gram models, Markov chains, vocabulary statistics, and word embeddings.## 📋 Repository Contents### Models & Assets- Tokenizers (8k, 16k, 32k, 64k)- N-gram models (2, 3, 4, 5-gram)- Markov chains (context of 1, 2, 3, 4 and 5)- Subword N-gram and Markov chains- Embeddings in various sizes and dimensions (aligned and unaligned)- Language Vocabulary- Language Statistics### Analysis and Evaluation- [1. Tokenizer Evaluation](#1-tokenizer-evaluation)- [2. N-gram Model Evaluation](#2-n-gram-model-evaluation)- [3. Markov Chain Evaluation](#3-markov-chain-evaluation)- [4. Vocabulary Analysis](#4-vocabulary-analysis)- [5. Word Embeddings Evaluation](#5-word-embeddings-evaluation)- [6. Morphological Analysis (Experimental)](#6--morphological-analysis-experimental)- [7. Summary & Recommendations](#7-summary--recommendations)- [Metrics Glossary](#appendix-metrics-glossary--interpretation-guide)- [Visualizations Index](#visualizations-index)---## 1. Tokenizer Evaluation### Results| Vocab Size | Compression | Avg Token Len | UNK Rate | Total Tokens ||------------|-------------|---------------|----------|--------------|| **8k** | 3.480x | 3.48 | 0.0910% | 300,099 || **16k** | 3.753x | 3.76 | 0.0981% | 278,271 || **32k** | 3.983x | 3.99 | 0.1041% | 262,209 || **64k** | 4.171x 🏆 | 4.18 | 0.1090% | 250,397 |### Tokenization ExamplesBelow are sample sentences tokenized with each vocabulary size:**Sample 1:** `هادي صفحة د التوضيح، كلمة بركان يمكن يكونو عندها هاد لمعاني: بْرْكان: مدينة مغري...`| Vocab | Tokens | Count ||-------|--------|-------|| 8k | `▁هادي ▁صفحة ▁د ▁التوضيح ، ▁كلمة ▁بركان ▁يمكن ▁يكونو ▁عندها ... (+23 more)` | 33 || 16k | `▁هادي ▁صفحة ▁د ▁التوضيح ، ▁كلمة ▁بركان ▁يمكن ▁يكونو ▁عندها ... (+21 more)` | 31 || 32k | `▁هادي ▁صفحة ▁د ▁التوضيح ، ▁كلمة ▁بركان ▁يمكن ▁يكونو ▁عندها ... (+19 more)` | 29 || 64k | `▁هادي ▁صفحة ▁د ▁التوضيح ، ▁كلمة ▁بركان ▁يمكن ▁يكونو ▁عندها ... (+18 more)` | 28 |**Sample 2:** `لْفزضاض ؤلا أفزضاض (سمية لعلمية Microcosmus sabatieri) حيوان لاسنسولي كيعيش ف لب...`| Vocab | Tokens | Count ||-------|--------|-------|| 8k | `▁لْ ف ز ضاض ▁ؤلا ▁أف ز ضاض ▁( سمية ... (+31 more)` | 41 || 16k | `▁لْ ف ز ضاض ▁ؤلا ▁أف ز ضاض ▁( سمية ... (+28 more)` | 38 || 32k | `▁لْف ز ضاض ▁ؤلا ▁أف ز ضاض ▁( سمية ▁لعلمية ... (+25 more)` | 35 || 64k | `▁لْف زضاض ▁ؤلا ▁أف زضاض ▁( سمية ▁لعلمية ▁microcos mus ... (+17 more)` | 27 |**Sample 3:** `نيلز أبراهام لانݣليت (مزيود ف 9 يوليوز - مات ف 30 مارس هوّا عالم د شّيمي سويدي. ...`| Vocab | Tokens | Count ||-------|--------|-------|| 8k | `▁نيل ز ▁أب راهام ▁ل انݣ ليت ▁( مزيود ▁ف ... (+19 more)` | 29 || 16k | `▁نيل ز ▁أبراهام ▁ل انݣ ليت ▁( مزيود ▁ف ▁ ... (+16 more)` | 26 || 32k | `▁نيلز ▁أبراهام ▁لانݣ ليت ▁( مزيود ▁ف ▁ 9 ▁يوليوز ... (+14 more)` | 24 || 64k | `▁نيلز ▁أبراهام ▁لانݣليت ▁( مزيود ▁ف ▁ 9 ▁يوليوز ▁- ... (+13 more)` | 23 |### Key Findings- **Best Compression:** 64k achieves 4.171x compression- **Lowest UNK Rate:** 8k with 0.0910% unknown tokens- **Trade-off:** Larger vocabularies improve compression but increase model size- **Recommendation:** 32k vocabulary provides optimal balance for production use---## 2. N-gram Model Evaluation### Results| N-gram | Variant | Perplexity | Entropy | Unique N-grams | Top-100 Coverage | Top-1000 Coverage ||--------|---------|------------|---------|----------------|------------------|-------------------|| **2-gram** | Word | 7,228 | 12.82 | 39,512 | 23.0% | 50.8% || **2-gram** | Subword | 424 🏆 | 8.73 | 5,903 | 58.0% | 96.4% || **3-gram** | Word | 5,655 | 12.47 | 43,555 | 27.5% | 57.1% || **3-gram** | Subword | 3,784 | 11.89 | 44,651 | 23.1% | 60.7% || **4-gram** | Word | 7,985 | 12.96 | 70,559 | 27.5% | 53.6% || **4-gram** | Subword | 20,064 | 14.29 | 220,807 | 12.0% | 36.0% || **5-gram** | Word | 7,565 | 12.89 | 58,964 | 28.5% | 52.9% || **5-gram** | Subword | 62,379 | 15.93 | 527,725 | 7.3% | 25.0% |### Top 5 N-grams by Size**2-grams (Word):**| Rank | N-gram | Count ||------|--------|-------|| 1 | `واصلة ل` | 8,540 || 2 | `نسبة د` | 7,170 || 3 | `ف لمغريب` | 6,305 || 4 | `ف إقليم` | 6,018 || 5 | `ف نسبة` | 4,265 |**3-grams (Word):**| Rank | N-gram | Count ||------|--------|-------|| 1 | `ف نسبة د` | 4,264 || 2 | `فيها مصدر و` | 3,236 || 3 | `و نسبة د` | 2,894 || 4 | `مصدر و بايت` | 2,856 || 5 | `اللي خدامين ف` | 2,760 |**4-grams (Word):**| Rank | N-gram | Count ||------|--------|-------|| 1 | `فيها مصدر و بايت` | 2,856 || 2 | `نسبة نّاس اللي خدامين` | 2,705 || 3 | `نّاس اللي خدامين ف` | 2,594 || 4 | `على حساب لإحصاء الرسمي` | 2,501 || 5 | `حساب لإحصاء الرسمي د` | 2,500 |**5-grams (Word):**| Rank | N-gram | Count ||------|--------|-------|| 1 | `نسبة نّاس اللي خدامين ف` | 2,593 || 2 | `ف لمغريب هاد دّوار كينتامي` | 2,500 || 3 | `هاد دّوار كينتامي ل مشيخة` | 2,500 || 4 | `لمغريب هاد دّوار كينتامي ل` | 2,500 || 5 | `حساب لإحصاء الرسمي د عام` | 2,500 |**2-grams (Subword):**| Rank | N-gram | Count ||------|--------|-------|| 1 | `ا ل` | 347,466 || 2 | `_ ل` | 278,371 || 3 | `ة _` | 229,442 || 4 | `_ ا` | 220,960 || 5 | `_ م` | 156,801 |**3-grams (Subword):**| Rank | N-gram | Count ||------|--------|-------|| 1 | `_ ا ل` | 216,048 || 2 | `_ ف _` | 83,146 || 3 | `ا ت _` | 63,800 || 4 | `ي ة _` | 60,271 || 5 | `_ د _` | 59,563 |**4-grams (Subword):**| Rank | N-gram | Count ||------|--------|-------|| 1 | `_ د ي ا` | 47,798 || 2 | `د ي ا ل` | 47,559 || 3 | `ي ا ل _` | 33,039 || 4 | `د _ ا ل` | 32,831 || 5 | `_ م ن _` | 28,909 |**5-grams (Subword):**| Rank | N-gram | Count ||------|--------|-------|| 1 | `_ د ي ا ل` | 47,427 || 2 | `د ي ا ل _` | 32,608 || 3 | `_ ع ل ى _` | 19,473 || 4 | `_ ا ل ل ي` | 18,967 || 5 | `ا ل ل ي _` | 18,744 |### Key Findings- **Best Perplexity:** 2-gram (subword) with 424- **Entropy Trend:** Decreases with larger n-grams (more predictable)- **Coverage:** Top-1000 patterns cover ~25% of corpus- **Recommendation:** 4-gram or 5-gram for best predictive performance---## 3. Markov Chain Evaluation### Results| Context | Variant | Avg Entropy | Perplexity | Branching Factor | Unique Contexts | Predictability ||---------|---------|-------------|------------|------------------|-----------------|----------------|| **1** | Word | 0.8561 | 1.810 | 5.38 | 178,865 | 14.4% || **1** | Subword | 1.1236 | 2.179 | 8.36 | 2,156 | 0.0% || **2** | Word | 0.2259 | 1.169 | 1.49 | 962,233 | 77.4% || **2** | Subword | 0.8160 | 1.761 | 5.10 | 18,029 | 18.4% || **3** | Word | 0.0618 | 1.044 | 1.10 | 1,431,084 | 93.8% || **3** | Subword | 0.8022 | 1.744 | 4.13 | 91,858 | 19.8% || **4** | Word | 0.0208 🏆 | 1.015 | 1.04 | 1,574,083 | 97.9% || **4** | Subword | 0.6604 | 1.581 | 2.86 | 379,445 | 34.0% |### Generated Text Samples (Word-based)Below are text samples generated from each word-based Markov chain model:**Context Size 1:**1. `ف لمغريب فيها 5 463 462 461 كم من غير ب شبه منقّر مكررعبد المسيح في`2. `و أداب روسيا ف لمغريب ف وقت مابين اللغات الرسمية ديال حيزب لإستقلال تا سينيما ليها`3. `د الناس فليبيا اكتشفو أنه يتقتل ولكن بقات كتلعب فالتيران ديال هاد الريحلة معا لمونتاخاب و`**Context Size 2:**1. `واصلة ل 98 6 و عدد لفاميلات تزاد ب 81 6 و نسبة د الناس و لمحيط`2. `نسبة د الشوماج واصلة ل 21 12 نوطات مصادر ف لمغريب جّبل معروف عند الصامويين حتال ليوم`3. `ف لمغريب هاد دّوار كينتامي ل مشيخة سدي حمد الدغوغي لي كتضم 14 د دّواور لعاداد د`**Context Size 3:**1. `ف نسبة د التسكويل واصلة ل 91 89 و نسبة د الشوماج واصلة ل 7 6 و لخصوبة`2. `فيها مصدر و بايت زادهوم داريجابوت حيين مغاربا د لقرن 21 مغاربا مغاربا فيها مصدر و بايت زادهوم`3. `و نسبة د لأمية واصلة ل 53 4 و نسبة د لأمية واصلة ل 92 5 و نسبة`**Context Size 4:**1. `نسبة نّاس اللي خدامين ف دّولة ولا لبيطاليين اللي سبق ليهوم خدمو 44 3 نسبة نّاس اللي خدامين ف`2. `نّاس اللي خدامين ف لپريڤي ولا لبيطاليين اللي سبق ليهوم مصادر الدار البيضاء سطات قروية ف إقليم سطات ق...`3. `على حساب لإحصاء الرسمي د عام إحصائيات إحصائيات عامة عدد السكان ديال أورسفان نقص ب 30 7 و عدد`### Generated Text Samples (Subword-based)Below are text samples generated from each subword-based Markov chain model:**Context Size 1:**1. `_دّرى_لجالب_لتالع`2. `اكترن_لعاميلة_ن_`3. `لت_پرومدي_و_ماتم`**Context Size 2:**1. `الرجل_بين_ماعة_لخ`2. `_لكينو_العرفوقعوه`3. `ة_27_نت،_خري_د_لج`**Context Size 3:**1. `_الروس_و_هي_ماية_ك`2. `_ف_موقريب._الدفايي`3. `ات_ف_البالشخصياتول`**Context Size 4:**1. `_ديالو._ميامينش_و_ت`2. `ديال_أسباب_الغرب_6_`3. `يال_تعرّض_للحزب_الوه`### Key Findings- **Best Predictability:** Context-4 (word) with 97.9% predictability- **Branching Factor:** Decreases with context size (more deterministic)- **Memory Trade-off:** Larger contexts require more storage (379,445 contexts)- **Recommendation:** Context-3 or Context-4 for text generation---## 4. Vocabulary Analysis### Statistics| Metric | Value ||--------|-------|| Vocabulary Size | 78,779 || Total Tokens | 2,032,841 || Mean Frequency | 25.80 || Median Frequency | 4 || Frequency Std Dev | 515.92 |### Most Common Words| Rank | Word | Frequency ||------|------|-----------|| 1 | ف | 83,458 || 2 | و | 59,829 || 3 | د | 59,731 || 4 | ديال | 32,565 || 5 | من | 29,236 || 6 | ل | 23,572 || 7 | على | 19,570 || 8 | لي | 18,402 || 9 | اللي | 17,442 || 10 | ب | 17,233 |### Least Common Words (from vocabulary)| Rank | Word | Frequency ||------|------|-----------|| 1 | بوفوار | 2 || 2 | بيتسي | 2 || 3 | وصانعي | 2 || 4 | وأهميتها | 2 || 5 | بورديو | 2 || 6 | بلومر | 2 || 7 | مقترحة | 2 || 8 | anchor | 2 || 9 | بعصبة | 2 || 10 | ماڭي | 2 |### Zipf's Law Analysis| Metric | Value ||--------|-------|| Zipf Coefficient | 1.0213 || R² (Goodness of Fit) | 0.998918 || Adherence Quality | **excellent** |### Coverage Analysis| Top N Words | Coverage ||-------------|----------|| Top 100 | 38.6% || Top 1,000 | 62.9% || Top 5,000 | 77.8% || Top 10,000 | 84.2% |### Key Findings- **Zipf Compliance:** R²=0.9989 indicates excellent adherence to Zipf's law- **High Frequency Dominance:** Top 100 words cover 38.6% of corpus- **Long Tail:** 68,779 words needed for remaining 15.8% coverage---## 5. Word Embeddings Evaluation### 5.1 Cross-Lingual Alignment### 5.2 Model Comparison| Model | Dimension | Isotropy | Semantic Density | Alignment R@1 | Alignment R@10 ||-------|-----------|----------|------------------|---------------|----------------|| **mono_32d** | 32 | 0.8284 🏆 | 0.3330 | N/A | N/A || **mono_64d** | 64 | 0.8181 | 0.2588 | N/A | N/A || **mono_128d** | 128 | 0.7036 | 0.2093 | N/A | N/A || **aligned_32d** | 32 | 0.8284 | 0.3345 | 0.0180 | 0.1360 || **aligned_64d** | 64 | 0.8181 | 0.2550 | 0.0380 | 0.1760 || **aligned_128d** | 128 | 0.7036 | 0.2072 | 0.0620 | 0.2760 |### Key Findings- **Best Isotropy:** mono_32d with 0.8284 (more uniform distribution)- **Semantic Density:** Average pairwise similarity of 0.2663. Lower values indicate better semantic separation.- **Alignment Quality:** Aligned models achieve up to 6.2% R@1 in cross-lingual retrieval.- **Recommendation:** 128d aligned for best cross-lingual performance---## 6. Morphological Analysis (Experimental)This section presents an automated morphological analysis derived from the statistical divergence between word-level and subword-level models. By analyzing where subword predictability spikes and where word-level coverage fails, we can infer linguistic structures without supervised data.### 6.1 Productivity & Complexity| Metric | Value | Interpretation | Recommendation ||--------|-------|----------------|----------------|| Productivity Index | **5.000** | High morphological productivity | Reliable analysis || Idiomaticity Gap | **1.114** | High formulaic/idiomatic content | - |### 6.2 Affix Inventory (Productive Units)These are the most productive prefixes and suffixes identified by sampling the vocabulary for global substitutability patterns. A unit is considered an affix if stripping it leaves a valid stem that appears in other contexts.#### Productive Prefixes| Prefix | Examples ||--------|----------|| `-ال` | الأمني, اللحظة, الفيرمات || `-لم` | لمتعصبين, لمحافض, لمونضامة || `-كا` | كاتدير, كايتحلو, كايقممو |#### Productive Suffixes| Suffix | Examples ||--------|----------|| `-ة` | سميّة, رقصة, اللحظة || `-ات` | سطراتيجيات, الفيرمات, لحتيفالات || `-ية` | الشرقية, اللاجنسية, ولوسطانية || `-ين` | لمتعصبين, ثنين, لمالحين |### 6.3 Bound Stems (Lexical Roots)Bound stems are high-frequency subword units that are semantically cohesive but rarely appear as standalone words. These often correspond to the 'core' of a word that requires inflection or derivation to be valid.| Stem | Cohesion | Substitutability | Examples ||------|----------|------------------|----------|| `انية` | 1.80x | 68 contexts | غانية, ثانية, سانية || `اللو` | 1.74x | 61 contexts | اللوه, اللور, اللول || `الات` | 1.71x | 65 contexts | تالات, حالات, صالات || `جماع` | 1.90x | 38 contexts | جماعي, تجماع, إجماع || `النا` | 1.63x | 63 contexts | الناي, النار, الناس || `لمغر` | 1.92x | 30 contexts | لمغرب, لمغربب, للمغرب || `إحصا` | 2.13x | 17 contexts | إحصاء, لإحصا, إحصائي || `مغري` | 2.08x | 18 contexts | مغريب, مغرية, مغريبي || `حصاء` | 2.24x | 14 contexts | إحصاء, لإحصاء, ليحصاء || `دهوم` | 2.14x | 16 contexts | ضدهوم, يردهوم, زادهوم || `قليم` | 2.06x | 17 contexts | فقليم, اقليم, إقليم || `لجوا` | 1.77x | 26 contexts | لجواب, لجواد, الجوا |### 6.4 Affix Compatibility (Co-occurrence)This table shows which prefixes and suffixes most frequently co-occur on the same stems, revealing the 'stacking' rules of the language's morphology.| Prefix | Suffix | Frequency | Examples ||--------|--------|-----------|----------|| `-ال` | `-ة` | 280 words | الراكوبة, العمدة || `-ال` | `-ات` | 163 words | الشلالات, العبرات || `-ال` | `-ية` | 152 words | الزراعية, الطباشيرية || `-ال` | `-ين` | 76 words | الموحدين, الاثنين || `-لم` | `-ة` | 66 words | لمملكة, لمُحمدية || `-لم` | `-ين` | 45 words | لموناضيلين, لمعتقلين || `-لم` | `-ات` | 25 words | لمونضّامات, لممرات || `-لم` | `-ية` | 21 words | لمُحمدية, لمراكشية || `-كا` | `-ين` | 2 words | كايسين, كاتبين |### 6.5 Recursive Morpheme SegmentationUsing **Recursive Hierarchical Substitutability**, we decompose complex words into their constituent morphemes. This approach handles nested affixes (e.g., `prefix-prefix-root-suffix`).| Word | Suggested Split | Confidence | Stem ||------|-----------------|------------|------|| التوجيهات | **`ال-توجيه-ات`** | 6.0 | `توجيه` || الصومالية | **`ال-صومال-ية`** | 6.0 | `صومال` || الپاكستانية | **`ال-پاكستان-ية`** | 6.0 | `پاكستان` || الدوّازات | **`ال-دوّاز-ات`** | 6.0 | `دوّاز` || الصالونات | **`ال-صالون-ات`** | 6.0 | `صالون` || التعبيرية | **`ال-تعبير-ية`** | 6.0 | `تعبير` || الانقلابية | **`ال-انقلاب-ية`** | 6.0 | `انقلاب` || لمنقارضين | **`لم-نقارض-ين`** | 6.0 | `نقارض` || التقليديين | **`ال-تقليدي-ين`** | 6.0 | `تقليدي` || لمنتاشرين | **`لم-نتاشر-ين`** | 6.0 | `نتاشر` || الماكينات | **`ال-ماكين-ات`** | 6.0 | `ماكين` || البرونزية | **`ال-برونز-ية`** | 6.0 | `برونز` || التكوينية | **`ال-تكوين-ية`** | 6.0 | `تكوين` || التعليمية | **`ال-تعليم-ية`** | 6.0 | `تعليم` || التلفزيونية | **`ال-تلفزيون-ية`** | 6.0 | `تلفزيون` |### 6.6 Linguistic Interpretation> **Automated Insight:**The language Moroccan Arabic shows high morphological productivity. The subword models are significantly more efficient than word models, suggesting a rich system of affixation or compounding.> **Note on Idiomaticity:** The high Idiomaticity Gap suggests a large number of frequent multi-word expressions or formulaic sequences that are statistically distinct from their component parts.---## 7. Summary & Recommendations### Production Recommendations| Component | Recommended | Rationale ||-----------|-------------|-----------|| Tokenizer | **64k BPE** | Best compression (4.17x) || N-gram | **2-gram** | Lowest perplexity (424) || Markov | **Context-4** | Highest predictability (97.9%) || Embeddings | **100d** | Balanced semantic capture and isotropy |---## Appendix: Metrics Glossary & Interpretation GuideThis section provides definitions, intuitions, and guidance for interpreting the metrics used throughout this report.### Tokenizer Metrics**Compression Ratio**> *Definition:* The ratio of characters to tokens (chars/token). Measures how efficiently the tokenizer represents text.>> *Intuition:* Higher compression means fewer tokens needed to represent the same text, reducing sequence lengths for downstream models. A 3x compression means ~3 characters per token on average.>> *What to seek:* Higher is generally better for efficiency, but extremely high compression may indicate overly aggressive merging that loses morphological information.**Average Token Length (Fertility)**> *Definition:* Mean number of characters per token produced by the tokenizer.>> *Intuition:* Reflects the granularity of tokenization. Longer tokens capture more context but may struggle with rare words; shorter tokens are more flexible but increase sequence length.>> *What to seek:* Balance between 2-5 characters for most languages. Arabic/morphologically-rich languages may benefit from slightly longer tokens.**Unknown Token Rate (OOV Rate)**> *Definition:* Percentage of tokens that map to the unknown/UNK token, indicating words the tokenizer cannot represent.>> *Intuition:* Lower OOV means better vocabulary coverage. High OOV indicates the tokenizer encounters many unseen character sequences.>> *What to seek:* Below 1% is excellent; below 5% is acceptable. BPE tokenizers typically achieve very low OOV due to subword fallback.### N-gram Model Metrics**Perplexity**> *Definition:* Measures how "surprised" the model is by test data. Mathematically: 2^(cross-entropy). Lower values indicate better prediction.>> *Intuition:* If perplexity is 100, the model is as uncertain as if choosing uniformly among 100 options at each step. A perplexity of 10 means effectively choosing among 10 equally likely options.>> *What to seek:* Lower is better. Perplexity decreases with larger n-grams (more context). Values vary widely by language and corpus size.**Entropy**> *Definition:* Average information content (in bits) needed to encode the next token given the context. Related to perplexity: perplexity = 2^entropy.>> *Intuition:* High entropy means high uncertainty/randomness; low entropy means predictable patterns. Natural language typically has entropy between 1-4 bits per character.>> *What to seek:* Lower entropy indicates more predictable text patterns. Entropy should decrease as n-gram size increases.**Coverage (Top-K)**> *Definition:* Percentage of corpus occurrences explained by the top K most frequent n-grams.>> *Intuition:* High coverage with few patterns indicates repetitive/formulaic text; low coverage suggests diverse vocabulary usage.>> *What to seek:* Depends on use case. For language modeling, moderate coverage (40-60% with top-1000) is typical for natural text.### Markov Chain Metrics**Average Entropy**> *Definition:* Mean entropy across all contexts, measuring average uncertainty in next-word prediction.>> *Intuition:* Lower entropy means the model is more confident about what comes next. Context-1 has high entropy (many possible next words); Context-4 has low entropy (few likely continuations).>> *What to seek:* Decreasing entropy with larger context sizes. Very low entropy (<0.1) indicates highly deterministic transitions.**Branching Factor**> *Definition:* Average number of unique next tokens observed for each context.>> *Intuition:* High branching = many possible continuations (flexible but uncertain); low branching = few options (predictable but potentially repetitive).>> *What to seek:* Branching factor should decrease with context size. Values near 1.0 indicate nearly deterministic chains.**Predictability**> *Definition:* Derived metric: (1 - normalized_entropy) × 100%. Indicates how deterministic the model's predictions are.>> *Intuition:* 100% predictability means the next word is always certain; 0% means completely random. Real text falls between these extremes.>> *What to seek:* Higher predictability for text generation quality, but too high (>98%) may produce repetitive output.### Vocabulary & Zipf's Law Metrics**Zipf's Coefficient**> *Definition:* The slope of the log-log plot of word frequency vs. rank. Zipf's law predicts this should be approximately -1.>> *Intuition:* A coefficient near -1 indicates the corpus follows natural language patterns where a few words are very common and most words are rare.>> *What to seek:* Values between -0.8 and -1.2 indicate healthy natural language distribution. Deviations may suggest domain-specific or artificial text.**R² (Coefficient of Determination)**> *Definition:* Measures how well the linear fit explains the frequency-rank relationship. Ranges from 0 to 1.>> *Intuition:* R² near 1.0 means the data closely follows Zipf's law; lower values indicate deviation from expected word frequency patterns.>> *What to seek:* R² > 0.95 is excellent; > 0.99 indicates near-perfect Zipf adherence typical of large natural corpora.**Vocabulary Coverage**> *Definition:* Cumulative percentage of corpus tokens accounted for by the top N words.>> *Intuition:* Shows how concentrated word usage is. If top-100 words cover 50% of text, the corpus relies heavily on common words.>> *What to seek:* Top-100 covering 30-50% is typical. Higher coverage indicates more repetitive text; lower suggests richer vocabulary.### Word Embedding Metrics**Isotropy**> *Definition:* Measures how uniformly distributed vectors are in the embedding space. Computed as the ratio of minimum to maximum singular values.>> *Intuition:* High isotropy (near 1.0) means vectors spread evenly in all directions; low isotropy means vectors cluster in certain directions, reducing expressiveness.>> *What to seek:* Higher isotropy generally indicates better-quality embeddings. Values > 0.1 are reasonable; > 0.3 is good. Lower-dimensional embeddings tend to have higher isotropy.**Average Norm**> *Definition:* Mean magnitude (L2 norm) of word vectors in the embedding space.>> *Intuition:* Indicates the typical "length" of vectors. Consistent norms suggest stable training; high variance may indicate some words are undertrained.>> *What to seek:* Relatively consistent norms across models. The absolute value matters less than consistency (low std deviation).**Cosine Similarity**> *Definition:* Measures angular similarity between vectors, ranging from -1 (opposite) to 1 (identical direction).>> *Intuition:* Words with similar meanings should have high cosine similarity. This is the standard metric for semantic relatedness in embeddings.>> *What to seek:* Semantically related words should score > 0.5; unrelated words should be near 0. Synonyms often score > 0.7.**t-SNE Visualization**> *Definition:* t-Distributed Stochastic Neighbor Embedding - a dimensionality reduction technique that preserves local structure for visualization.>> *Intuition:* Clusters in t-SNE plots indicate groups of semantically related words. Spread indicates vocabulary diversity; tight clusters suggest semantic coherence.>> *What to seek:* Meaningful clusters (e.g., numbers together, verbs together). Avoid over-interpreting distances - t-SNE preserves local, not global, structure.### General Interpretation Guidelines1. **Compare within model families:** Metrics are most meaningful when comparing models of the same type (e.g., 8k vs 64k tokenizer).2. **Consider trade-offs:** Better performance on one metric often comes at the cost of another (e.g., compression vs. OOV rate).3. **Context matters:** Optimal values depend on downstream tasks. Text generation may prioritize different metrics than classification.4. **Corpus influence:** All metrics are influenced by corpus characteristics. Wikipedia text differs from social media or literature.5. **Language-specific patterns:** Morphologically rich languages (like Arabic) may show different optimal ranges than analytic languages.### Visualizations Index| Visualization | Description ||---------------|-------------|| Tokenizer Compression | Compression ratios by vocabulary size || Tokenizer Fertility | Average token length by vocabulary || Tokenizer OOV | Unknown token rates || Tokenizer Total Tokens | Total tokens by vocabulary || N-gram Perplexity | Perplexity by n-gram size || N-gram Entropy | Entropy by n-gram size || N-gram Coverage | Top pattern coverage || N-gram Unique | Unique n-gram counts || Markov Entropy | Entropy by context size || Markov Branching | Branching factor by context || Markov Contexts | Unique context counts || Zipf's Law | Frequency-rank distribution with fit || Vocab Frequency | Word frequency distribution || Top 20 Words | Most frequent words || Vocab Coverage | Cumulative coverage curve || Embedding Isotropy | Vector space uniformity || Embedding Norms | Vector magnitude distribution || Embedding Similarity | Word similarity heatmap || Nearest Neighbors | Similar words for key terms || t-SNE Words | 2D word embedding visualization || t-SNE Sentences | 2D sentence embedding visualization || Position Encoding | Encoding method comparison || Model Sizes | Storage requirements || Performance Dashboard | Comprehensive performance overview |---## About This Project### Data SourceModels trained on [wikipedia-monthly](https://huggingface.co/datasets/omarkamali/wikipedia-monthly) - a monthly snapshot of Wikipedia articles across 300+ languages.### ProjectA project by **[Wikilangs](https://wikilangs.org)** - Open-source NLP models for every Wikipedia language.### Maintainer[Omar Kamali](https://omarkamali.com) - [Omneity Labs](https://omneitylabs.com)### CitationIf you use these models in your research, please cite:```bibtex@misc{wikilangs2025,author = {Kamali, Omar},title = {Wikilangs: Open NLP Models for Wikipedia Languages},year = {2025},doi = {10.5281/zenodo.18073153},publisher = {Zenodo},url = {https://huggingface.co/wikilangs}institution = {Omneity Labs}}```### LicenseMIT License - Free for academic and commercial use.### Links- 🌐 Website: [wikilangs.org](https://wikilangs.org)- 🤗 Models: [huggingface.co/wikilangs](https://huggingface.co/wikilangs)- 📊 Data: [wikipedia-monthly](https://huggingface.co/datasets/omarkamali/wikipedia-monthly)- 👤 Author: [Omar Kamali](https://huggingface.co/omarkamali)- 🤝 Sponsor: [Featherless AI](https://featherless.ai)---*Generated by Wikilangs Models Pipeline**Report Date: 2026-01-03 16:42:17*32 unmodified lines3334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923032 unmodified linesmetrics:- name: best_compression_ratiotype: compressionvalue: 4.172- name: best_isotropytype: isotropyvalue: 0.8215- name: best_alignment_r10type: alignmentvalue: 0.2420- name: vocabulary_sizetype: vocabvalue: 79667generated: 2026-03-02---# Moroccan Arabic — Wikilangs ModelsOpen-source tokenizers, n-gram & Markov language models, vocabulary stats, and word embeddings trained on **Moroccan Arabic** Wikipedia by [Wikilangs](https://wikilangs.org).🌐 [Language Page](https://wikilangs.org/languages/ary/) · 🎮 [Playground](https://wikilangs.org/playground/?lang=ary) · 📊 [Full Research Report](RESEARCH_REPORT.md)## Language SamplesExample sentences drawn from the Moroccan Arabic Wikipedia corpus:> آيت ميلك جماعة ترابية قروية كاينة في إقليم اشتوكة آيت باها، جهة سوس ماسة، ساكنين فيها نسمة، على حسب الإحصاء العام ويب> أورو هي لفلوس لي كاتخدًم بزاف ديال الدول ديال الاتحاد الأوروپي. هاد الدول تافقو يخدًمو الأورو مبعد المعاهدة ديال ماستريخت عام شوف حتى الاتحاد الأوروپي مصادر> إيلبا (ب ، إيصولا د إيلبا) هي واحد الجزيرة تابعة للطاليان و تيسكن فيها تقريبا 30.000 واحد. جات ف البحر البيض المتوسط مابين طوسكانيا و كورسيكا. مصادر ف الطاليان ݣزيرة> حرب كردستان لعراق هي واحد الحرب ف كردستان لعراق سالات بالربح ديال لعراق. بدات ف عام و سالات ف و ربح فيها لعراق مين كان حاكمو حزب لبعث. مصادر> الدارجة التطوانية هي الدارجة لي كيهضرو الناس د المدينة د تطوان و النواحي ديالا، و عندها تأثيرات من العربية د الأندلس و اللهجة الجبلية لي قريبا لها. مصادر د داريجة## Quick Start### Load the Tokenizer```pythonimport sentencepiece as spmsp = spm.SentencePieceProcessor()sp.Load("ary_tokenizer_32k.model")text = "قريش هيا قبيلة ؤلا أجموع قبلي لي، علا حساب لمصادر لإسلامية، كانت ف مكة ؤ كاينتام"tokens = sp.EncodeAsPieces(text)ids = sp.EncodeAsIds(text)print(tokens) # subword piecesprint(ids) # integer ids# Decode backprint(sp.DecodeIds(ids))```<details><summary><b>Tokenization examples (click to expand)</b></summary>**Sample 1:** `قريش هيا قبيلة ؤلا أجموع قبلي لي، عل�� حساب لمصادر لإسلامية، كانت ف مكة ؤ كاينتام…`| Vocab | Tokens | Count ||-------|--------|-------|| 8k | `▁ق ريش ▁هيا ▁قبيلة ▁ؤلا ▁أج موع ▁ق بلي ▁لي … (+19 more)` | 29 || 16k | `▁قريش ▁هيا ▁قبيلة ▁ؤلا ▁أج موع ▁ق بلي ▁لي ، … (+16 more)` | 26 || 32k | `▁قريش ▁هيا ▁قبيلة ▁ؤلا ▁أجموع ▁ق بلي ▁لي ، ▁علا … (+15 more)` | 25 || 64k | `▁قريش ▁هيا ▁قبيلة ▁ؤلا ▁أجموع ▁قبلي ▁لي ، ▁علا ▁حساب … (+14 more)` | 24 |**Sample 2:** `آيت ميلك جماعة ترابية قروية كاينة في إقليم اشتوكة آيت باها، جهة سوس ماسة، ساكنين…`| Vocab | Tokens | Count ||-------|--------|-------|| 8k | `▁آيت ▁ميل ك ▁جماعة ▁ترابية ▁قروية ▁كاينة ▁في ▁إقليم ▁اشتوكة … (+16 more)` | 26 || 16k | `▁آيت ▁ميل ك ▁جماعة ▁ترابية ▁قروية ▁كاينة ▁في ▁إقليم ▁اشتوكة … (+16 more)` | 26 || 32k | `▁آيت ▁ميل ك ▁جماعة ▁ترابية ▁قروية ▁كاينة ▁في ▁إقليم ▁اشتوكة … (+16 more)` | 26 || 64k | `▁آيت ▁ميلك ▁جماعة ▁ترابية ▁قروية ▁كاينة ▁في ▁إقليم ▁اشتوكة ▁آيت … (+15 more)` | 25 |**Sample 3:** `خديجة بنت علي بن أبي طالب، هي بنت علي بن أبي طالب. مصادر د نسا`| Vocab | Tokens | Count ||-------|--------|-------|| 8k | `▁خديجة ▁بنت ▁علي ▁بن ▁أبي ▁طالب ، ▁هي ▁بنت ▁علي … (+7 more)` | 17 || 16k | `▁خديجة ▁بنت ▁علي ▁بن ▁أبي ▁طالب ، ▁هي ▁بنت ▁علي … (+7 more)` | 17 || 32k | `▁خديجة ▁بنت ▁علي ▁بن ▁أبي ▁طالب ، ▁هي ▁بنت ▁علي … (+7 more)` | 17 || 64k | `▁خديجة ▁بنت ▁علي ▁بن ▁أبي ▁طالب ، ▁هي ▁بنت ▁علي … (+7 more)` | 17 |</details>### Load Word Embeddings```pythonfrom gensim.models import KeyedVectors# Aligned embeddings (cross-lingual, mapped to English vector space)wv = KeyedVectors.load("ary_embeddings_128d_aligned.kv")similar = wv.most_similar("word", topn=5)for word, score in similar:print(f" {word}: {score:.3f}")```### Load N-gram Model```pythonimport pyarrow.parquet as pqdf = pq.read_table("ary_3gram_word.parquet").to_pandas()print(df.head())```## Models Overview| Category | Assets ||----------|--------|| Tokenizers | BPE at 8k, 16k, 32k, 64k vocab sizes || N-gram models | 2 / 3 / 4 / 5-gram (word & subword) || Markov chains | Context 1–5 (word & subword) || Embeddings | 32d, 64d, 128d — mono & aligned || Vocabulary | Full frequency list + Zipf analysis || Statistics | Corpus & model statistics JSON |## Metrics Summary| Component | Model | Key Metric | Value ||-----------|-------|------------|-------|| Tokenizer | 8k BPE | Compression | 3.48x || Tokenizer | 16k BPE | Compression | 3.76x || Tokenizer | 32k BPE | Compression | 3.98x || Tokenizer | 64k BPE | Compression | 4.17x 🏆 || N-gram | 2-gram (subword) | Perplexity | 428 🏆 || N-gram | 2-gram (word) | Perplexity | 7,415 || N-gram | 3-gram (subword) | Perplexity | 3,823 || N-gram | 3-gram (word) | Perplexity | 5,775 || N-gram | 4-gram (subword) | Perplexity | 20,320 || N-gram | 4-gram (word) | Perplexity | 8,149 || N-gram | 5-gram (subword) | Perplexity | 63,356 || N-gram | 5-gram (word) | Perplexity | 7,702 || Markov | ctx-1 (subword) | Predictability | 0.0% || Markov | ctx-1 (word) | Predictability | 14.2% || Markov | ctx-2 (subword) | Predictability | 18.4% || Markov | ctx-2 (word) | Predictability | 77.3% || Markov | ctx-3 (subword) | Predictability | 19.7% || Markov | ctx-3 (word) | Predictability | 93.8% || Markov | ctx-4 (subword) | Predictability | 33.7% || Markov | ctx-4 (word) | Predictability | 97.9% 🏆 || Vocabulary | full | Size | 79,667 || Vocabulary | full | Zipf R² | 0.9989 || Embeddings | mono_32d | Isotropy | 0.8215 🏆 || Embeddings | mono_64d | Isotropy | 0.8006 || Embeddings | mono_128d | Isotropy | 0.6555 || Embeddings | aligned_32d | Isotropy | 0.8215 || Embeddings | aligned_64d | Isotropy | 0.8006 || Embeddings | aligned_128d | Isotropy | 0.6555 || Alignment | aligned_32d | R@1 / R@5 / R@10 | 0.8% / 5.8% / 10.8% || Alignment | aligned_64d | R@1 / R@5 / R@10 | 3.8% / 10.0% / 20.0% || Alignment | aligned_128d | R@1 / R@5 / R@10 | 4.4% / 15.6% / 24.2% 🏆 |📊 **[Full ablation study, per-model breakdowns, and interpretation guide →](RESEARCH_REPORT.md)**---## AboutTrained on [wikipedia-monthly](https://huggingface.co/datasets/omarkamali/wikipedia-monthly) — monthly snapshots of 300+ Wikipedia languages.A project by **[Wikilangs](https://wikilangs.org)** · Maintainer: [Omar Kamali](https://omarkamali.com) · [Omneity Labs](https://omneitylabs.com)### Citation```bibtex@misc{wikilangs2025,author = {Kamali, Omar},title = {Wikilangs: Open NLP Models for Wikipedia Languages},year = {2025},doi = {10.5281/zenodo.18073153},publisher = {Zenodo},url = {https://huggingface.co/wikilangs},institution = {Omneity Labs}}```### Links- 🌐 [wikilangs.org](https://wikilangs.org)- 🌍 [Language page](https://wikilangs.org/languages/ary/)- 🎮 [Playground](https://wikilangs.org/playground/?lang=ary)- 🤗 [HuggingFace models](https://huggingface.co/wikilangs)- 📊 [wikipedia-monthly dataset](https://huggingface.co/datasets/omarkamali/wikipedia-monthly)- 👤 [Omar Kamali](https://huggingface.co/omarkamali)- 🤝 Sponsor: [Featherless AI](https://featherless.ai)**License:** MIT — free for academic and commercial use.---*Generated by Wikilangs Pipeline · 2026-03-02 12:03:27*
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688# Moroccan Arabic — Full Ablation Study & Research Report
Detailed evaluation of all model variants trained on **Moroccan Arabic** Wikipedia data by [Wikilangs](https://wikilangs.org).
👈 [Back to README](README.md)
## 📋 Repository Contents
### Models & Assets
- Tokenizers (8k, 16k, 32k, 64k)- N-gram models (2, 3, 4, 5-gram)- Markov chains (context of 1, 2, 3, 4 and 5)- Subword N-gram and Markov chains- Embeddings in various sizes and dimensions (aligned and unaligned)- Language Vocabulary- Language Statistics

### Analysis and Evaluation
- [1. Tokenizer Evaluation](#1-tokenizer-evaluation)- [2. N-gram Model Evaluation](#2-n-gram-model-evaluation)- [3. Markov Chain Evaluation](#3-markov-chain-evaluation)- [4. Vocabulary Analysis](#4-vocabulary-analysis)- [5. Word Embeddings Evaluation](#5-word-embeddings-evaluation)- [6. Morphological Analysis (Experimental)](#6--morphological-analysis-experimental)- [7. Summary & Recommendations](#7-summary--recommendations)- [Metrics Glossary](#appendix-metrics-glossary--interpretation-guide)- [Visualizations Index](#visualizations-index)
---## 1. Tokenizer Evaluation




### Results
| Vocab Size | Compression | Avg Token Len | UNK Rate | Total Tokens ||------------|-------------|---------------|----------|--------------|| **8k** | 3.481x | 3.48 | 0.0910% | 300,053 || **16k** | 3.755x | 3.76 | 0.0982% | 278,145 || **32k** | 3.985x | 3.99 | 0.1041% | 262,127 || **64k** | 4.172x 🏆 | 4.18 | 0.1090% | 250,361 |
### Tokenization Examples
Below are sample sentences tokenized with each vocabulary size:
**Sample 1:** `قريش هيا قبيلة ؤلا أجموع قبلي لي، علا حساب لمصادر لإسلامية، كانت ف مكة ؤ كاينتام...`
| Vocab | Tokens | Count ||-------|--------|-------|| 8k | `▁ق ريش ▁هيا ▁قبيلة ▁ؤلا ▁أج موع ▁ق بلي ▁لي ... (+19 more)` | 29 || 16k | `▁قريش ▁هيا ▁قبيلة ▁ؤلا ▁أج موع ▁ق بلي ▁لي ، ... (+16 more)` | 26 || 32k | `▁قريش ▁هيا ▁قبيلة ▁ؤلا ▁أجموع ▁ق بلي ▁لي ، ▁علا ... (+15 more)` | 25 || 64k | `▁قريش ▁هيا ▁قبيلة ▁ؤلا ▁أجموع ▁قبلي ▁لي ، ▁علا ▁حساب ... (+14 more)` | 24 |
**Sample 2:** `آيت ميلك جماعة ترابية قروية كاينة في إقليم اشتوكة آيت باها، جهة سوس ماسة، ساكنين...`
| Vocab | Tokens | Count ||-------|--------|-------|| 8k | `▁آيت ▁ميل ك ▁جماعة ▁ترابية ▁قروية ▁كاينة ▁في ▁إقليم ▁اشتوكة ... (+16 more)` | 26 || 16k | `▁آيت ▁ميل ك ▁جماعة ▁ترابية ▁قروية ▁كاينة ▁في ▁إقليم ▁اشتوكة ... (+16 more)` | 26 || 32k | `▁آيت ▁ميل ك ▁جماعة ▁ترابية ▁قروية ▁كاينة ▁في ▁إقليم ▁اشتوكة ... (+16 more)` | 26 || 64k | `▁آيت ▁ميلك ▁جماعة ▁ترابية ▁قروية ▁كاينة ▁في ▁إقليم ▁اشتوكة ▁آيت ... (+15 more)` | 25 |
**Sample 3:** `خديجة بنت علي بن أبي طالب، هي بنت علي بن أبي طالب. مصادر د نسا`
| Vocab | Tokens | Count ||-------|--------|-------|| 8k | `▁خديجة ▁بنت ▁علي ▁بن ▁أبي ▁طالب ، ▁هي ▁بنت ▁علي ... (+7 more)` | 17 || 16k | `▁خديجة ▁بنت ▁علي ▁بن ▁أبي ▁طالب ، ▁هي ▁بنت ▁علي ... (+7 more)` | 17 || 32k | `▁خديجة ▁بنت ▁علي ▁بن ▁أبي ▁طالب ، ▁هي ▁بنت ▁علي ... (+7 more)` | 17 || 64k | `▁خديجة ▁بنت ▁علي ▁بن ▁أبي ▁طالب ، ▁هي ▁بنت ▁علي ... (+7 more)` | 17 |
### Key Findings
- **Best Compression:** 64k achieves 4.172x compression- **Lowest UNK Rate:** 8k with 0.0910% unknown tokens- **Trade-off:** Larger vocabularies improve compression but increase model size- **Recommendation:** 32k vocabulary provides optimal balance for production use
---## 2. N-gram Model Evaluation



### Results
| N-gram | Variant | Perplexity | Entropy | Unique N-grams | Top-100 Coverage | Top-1000 Coverage ||--------|---------|------------|---------|----------------|------------------|-------------------|| **2-gram** | Word | 7,415 | 12.86 | 40,208 | 22.8% | 50.4% || **2-gram** | Subword | 428 🏆 | 8.74 | 5,913 | 57.8% | 96.3% || **3-gram** | Word | 5,775 | 12.50 | 44,139 | 27.3% | 56.7% || **3-gram** | Subword | 3,823 | 11.90 | 44,840 | 23.0% | 60.5% || **4-gram** | Word | 8,149 | 12.99 | 71,489 | 27.3% | 53.3% || **4-gram** | Subword | 20,320 | 14.31 | 222,645 | 11.9% | 35.8% || **5-gram** | Word | 7,702 | 12.91 | 59,669 | 28.3% | 52.6% || **5-gram** | Subword | 63,356 | 15.95 | 533,903 | 7.3% | 24.8% |
### Top 5 N-grams by Size
**2-grams (Word):**
| Rank | N-gram | Count ||------|--------|-------|| 1 | `واصلة ل` | 8,540 || 2 | `نسبة د` | 7,170 || 3 | `ف لمغريب` | 6,310 || 4 | `ف إقليم` | 6,015 || 5 | `ف نسبة` | 4,265 |
**3-grams (Word):**
| Rank | N-gram | Count ||------|--------|-------|| 1 | `ف نسبة د` | 4,264 || 2 | `فيها مصدر و` | 3,235 || 3 | `و نسبة د` | 2,894 || 4 | `مصدر و بايت` | 2,855 || 5 | `اللي خدامين ف` | 2,761 |
**4-grams (Word):**
| Rank | N-gram | Count ||------|--------|-------|| 1 | `فيها مصدر و بايت` | 2,855 || 2 | `نسبة نّاس اللي خدامين` | 2,705 || 3 | `نّاس اللي خدامين ف` | 2,595 || 4 | `على حساب لإحصاء الرسمي` | 2,501 || 5 | `لمغريب هاد دّوار كينتامي` | 2,500 |
**5-grams (Word):**
| Rank | N-gram | Count ||------|--------|-------|| 1 | `نسبة نّاس اللي خدامين ف` | 2,594 || 2 | `ف لمغريب هاد دّوار كينتامي` | 2,500 || 3 | `لمغريب هاد دّوار كينتامي ل` | 2,500 || 4 | `هاد دّوار كينتامي ل مشيخة` | 2,500 || 5 | `حساب لإحصاء الرسمي د عام` | 2,500 |
**2-grams (Subword):**
| Rank | N-gram | Count ||------|--------|-------|| 1 | `ا ل` | 348,897 || 2 | `_ ل` | 282,523 || 3 | `ة _` | 230,243 || 4 | `_ ا` | 221,714 || 5 | `_ م` | 157,830 |
**3-grams (Subword):**
| Rank | N-gram | Count ||------|--------|-------|| 1 | `_ ا ل` | 216,894 || 2 | `_ ف _` | 84,068 || 3 | `ا ت _` | 64,715 || 4 | `_ و _` | 60,577 || 5 | `ي ة _` | 60,370 |
**4-grams (Subword):**
| Rank | N-gram | Count ||------|--------|-------|| 1 | `_ د ي ا` | 48,269 || 2 | `د ي ا ل` | 48,014 || 3 | `ي ا ل _` | 33,434 || 4 | `د _ ا ل` | 33,075 || 5 | `_ م ن _` | 29,173 |
**5-grams (Subword):**
| Rank | N-gram | Count ||------|--------|-------|| 1 | `_ د ي ا ل` | 47,884 || 2 | `د ي ا ل _` | 33,006 || 3 | `_ ع ل ى _` | 19,658 || 4 | `_ ا ل ل ي` | 18,939 || 5 | `ا ل ل ي _` | 18,733 |
### Key Findings
- **Best Perplexity:** 2-gram (subword) with 428- **Entropy Trend:** Decreases with larger n-grams (more predictable)- **Coverage:** Top-1000 patterns cover ~25% of corpus- **Recommendation:** 4-gram or 5-gram for best predictive performance
---## 3. Markov Chain Evaluation



### Results
| Context | Variant | Avg Entropy | Perplexity | Branching Factor | Unique Contexts | Predictability ||---------|---------|-------------|------------|------------------|-----------------|----------------|| **1** | Word | 0.8581 | 1.813 | 5.40 | 180,421 | 14.2% || **1** | Subword | 1.1243 | 2.180 | 8.36 | 2,159 | 0.0% || **2** | Word | 0.2267 | 1.170 | 1.49 | 973,633 | 77.3% || **2** | Subword | 0.8165 | 1.761 | 5.10 | 18,051 | 18.4% || **3** | Word | 0.0619 | 1.044 | 1.10 | 1,450,643 | 93.8% || **3** | Subword | 0.8035 | 1.745 | 4.14 | 92,103 | 19.7% || **4** | Word | 0.0207 🏆 | 1.014 | 1.04 | 1,595,675 | 97.9% || **4** | Subword | 0.6627 | 1.583 | 2.87 | 381,563 | 33.7% |
### Generated Text Samples (Word-based)
Below are text samples generated from each word-based Markov chain model:
**Context Size 1:**
1. `ف ايكنان نقص ب سباب غتيال لماليك لأمازيغي ؤ ولّا على المنطق والبحث كان حتا زلزال`2. `و نسبة نّاس اللي سبق ليهوم مصادر ربحو جايزة أحسن 10 سنين موراها تولّا لحكم الداتي`3. `د لميداليات ف إقليم لحوز جهة مراكش آسفي ف المغرب من بعد باللي كان نتر خيالي`
**Context Size 2:**
1. `واصلة ل 3 ف لعقد ديال عوام كيوافق ف تّقويم لهيجري ؤ ف تّقويم لڭريڭوري بدا نهار`2. `نسبة د الشوماج واصلة ل 6 6 044 0 290 يوكطوتانية هيدروجين 7 7 و لخصوبة لكاملة`3. `ف لمغريب هاد دّوار كينتامي ل مشيخة أيت قضني لي كتضم 9 د دّواور لعاداد د سّكان`
**Context Size 3:**
1. `ف نسبة د التسكويل واصلة ل 90 8 و نسبة د لأمية واصلة ل 50 33 لخدمة ف`2. `فيها مصدر و بايت على حساب النوع د لحنش التشلال التنفوسي فشلان لكبدة لكوما و bites a d`3. `و نسبة د الشوماج واصلة ل 18 4 و لموعدّال د لعمر عند الجواج اللولاني هوّ 23 87`
**Context Size 4:**
1. `نسبة نّاس اللي خدامين في لقطاع لخاص 39 1 مصادر الرباط سلا القنيطرة قروية ف إقليم لخميسات مسكونين ف`2. `نّاس اللي خدامين ف لپريڤي 57 1 مصادر الرباط سلا القنيطرة قروية ف إقليم سيدي إيفني جهة ݣلميم واد`3. `على حساب لإحصاء الرسمي د عام نوطات مصادر ف لمغريب ف إقليم تارودانت زادهوم داريجابوت`
### Generated Text Samples (Subword-based)
Below are text samples generated from each subword-based Markov chain model:
**Context Size 1:**
1. `_أو_جة_م_-اسبش_د`2. `الاف_ف،_عية_لحدا`3. `لعة_ل_وعبر،_اليب`
**Context Size 2:**
1. `الجديات)._عنصاد_ا`2. `_لخمسيوسيحطولا_صر`3. `ة_ديال_لهي_بزرقة_`
**Context Size 3:**
1. `_اللي_خمائيات_ديال`2. `_ف_لجمهورية_الطابل`3. `ات_(گاع_ل_من_مابين`
**Context Size 4:**
1. `_ديال_المرسى_ديال_ا`2. `ديالهوم_مصادر_فيهم_`3. `يال_شيحد_من_بعد_فـ_`
### Key Findings
- **Best Predictability:** Context-4 (word) with 97.9% predictability- **Branching Factor:** Decreases with context size (more deterministic)- **Memory Trade-off:** Larger contexts require more storage (381,563 contexts)- **Recommendation:** Context-3 or Context-4 for text generation
---## 4. Vocabulary Analysis



### Statistics
| Metric | Value ||--------|-------|| Vocabulary Size | 79,667 || Total Tokens | 2,057,009 || Mean Frequency | 25.82 || Median Frequency | 4 || Frequency Std Dev | 518.98 |
### Most Common Words
| Rank | Word | Frequency ||------|------|-----------|| 1 | ف | 84,381 || 2 | و | 60,856 || 3 | د | 60,420 || 4 | ديال | 32,966 || 5 | من | 29,503 || 6 | ل | 23,808 || 7 | على | 19,757 || 8 | لي | 18,777 || 9 | ب | 17,745 || 10 | اللي | 17,410 |
### Least Common Words (from vocabulary)
| Rank | Word | Frequency ||------|------|-----------|| 1 | ختيلال | 2 || 2 | تسطية | 2 || 3 | التخمار | 2 || 4 | لمركزين | 2 || 5 | تعلاف | 2 || 6 | الروضيو | 2 || 7 | رِد | 2 || 8 | وينغز | 2 || 9 | تايغرز | 2 || 10 | كلتة | 2 |
### Zipf's Law Analysis
| Metric | Value ||--------|-------|| Zipf Coefficient | 1.0203 || R² (Goodness of Fit) | 0.998917 || Adherence Quality | **excellent** |
### Coverage Analysis
| Top N Words | Coverage ||-------------|----------|| Top 100 | 38.4% || Top 1,000 | 62.8% || Top 5,000 | 77.7% || Top 10,000 | 84.1% |
### Key Findings
- **Zipf Compliance:** R²=0.9989 indicates excellent adherence to Zipf's law- **High Frequency Dominance:** Top 100 words cover 38.4% of corpus- **Long Tail:** 69,667 words needed for remaining 15.9% coverage
---## 5. Word Embeddings Evaluation




### 5.1 Cross-Lingual Alignment


### 5.2 Model Comparison
| Model | Dimension | Isotropy | Semantic Density | Alignment R@1 | Alignment R@10 ||-------|-----------|----------|------------------|---------------|----------------|| **mono_32d** | 32 | 0.8215 🏆 | 0.3275 | N/A | N/A || **mono_64d** | 64 | 0.8006 | 0.2538 | N/A | N/A || **mono_128d** | 128 | 0.6555 | 0.2039 | N/A | N/A || **aligned_32d** | 32 | 0.8215 | 0.3276 | 0.0080 | 0.1080 || **aligned_64d** | 64 | 0.8006 | 0.2565 | 0.0380 | 0.2000 || **aligned_128d** | 128 | 0.6555 | 0.2044 | 0.0440 | 0.2420 |
### Key Findings
- **Best Isotropy:** mono_32d with 0.8215 (more uniform distribution)- **Semantic Density:** Average pairwise similarity of 0.2623. Lower values indicate better semantic separation.- **Alignment Quality:** Aligned models achieve up to 4.4% R@1 in cross-lingual retrieval.- **Recommendation:** 128d aligned for best cross-lingual performance
---## 6. Morphological Analysis (Experimental)
This section presents an automated morphological analysis derived from the statistical divergence between word-level and subword-level models. By analyzing where subword predictability spikes and where word-level coverage fails, we can infer linguistic structures without supervised data.
### 6.1 Productivity & Complexity
| Metric | Value | Interpretation | Recommendation ||--------|-------|----------------|----------------|| Productivity Index | **5.000** | High morphological productivity | Reliable analysis || Idiomaticity Gap | **1.121** | High formulaic/idiomatic content | - |
### 6.2 Affix Inventory (Productive Units)
These are the most productive prefixes and suffixes identified by sampling the vocabulary for global substitutability patterns. A unit is considered an affix if stripping it leaves a valid stem that appears in other contexts.
#### Productive Prefixes| Prefix | Examples ||--------|----------|| `-ال` | القوميين, الاحتياطية, الطابلة || `-ل` | لعضان, لكرواتي, لعاميد || `-ت` | تقرا, تحقيقات, تشارلي || `-م` | ميطاكا, معاهد, موليكيلة || `-لم` | لمحلولة, لمقبولين, لمطلوق || `-و` | والهيئات, والطرقان, وبطريقة || `-الم` | المركب, المعروفين, المناخية || `-ب` | بنشليخة, بيئات, بلمارشالية |
#### Productive Suffixes| Suffix | Examples ||--------|----------|| `-ت` | والهيئات, تحقيقات, لبويرات || `-ة` | بنشليخة, وبطريقة, عشبة || `-ات` | والهيئات, تحقيقات, لبويرات || `-ن` | لعضان, والطرقان, القوميين || `-ية` | أكترية, الاحتياطية, والاشتراكية || `-ا` | ميطاكا, تقرا, سيينا || `-ي` | ؤطوماتيكي, لكرواتي, سينتشي || `-ين` | القوميين, پيسّين, مشهورين |
### 6.3 Bound Stems (Lexical Roots)
Bound stems are high-frequency subword units that are semantically cohesive but rarely appear as standalone words. These often correspond to the 'core' of a word that requires inflection or derivation to be valid.
| Stem | Cohesion | Substitutability | Examples ||------|----------|------------------|----------|| `انية` | 1.84x | 68 contexts | سانية, تانية, غانية || `النا` | 1.79x | 63 contexts | الناي, الناس, النار || `لمغر` | 2.03x | 30 contexts | لمغرب, المغرب, لمغربي || `جماع` | 1.89x | 37 contexts | جماعة, إجماع, جماعي || `اللو` | 1.66x | 61 contexts | اللون, اللور, اللوز || `الات` | 1.59x | 65 contexts | صالات, حالات, سالات || `مغري` | 2.11x | 18 contexts | مغرية, مغريب, لمغريب || `دهوم` | 2.19x | 16 contexts | ضدهوم, يردهوم, جهدهوم || `إحصا` | 2.09x | 17 contexts | إحصاء, لإحصا, إحصائي || `حصاء` | 2.23x | 14 contexts | إحصاء, ليحصاء, لإحصاء || `قليم` | 2.08x | 16 contexts | إقليم, فقليم, اقليم || `لجوا` | 1.76x | 26 contexts | لجواب, الجوا, لجواد |
### 6.4 Affix Compatibility (Co-occurrence)
This table shows which prefixes and suffixes most frequently co-occur on the same stems, revealing the 'stacking' rules of the language's morphology.
| Prefix | Suffix | Frequency | Examples ||--------|--------|-----------|----------|| `-ال` | `-ة` | 281 words | الرواقية, القهوة || `-ل` | `-ة` | 184 words | لفريسة, للمنصة || `-ال` | `-ت` | 170 words | المجموعات, الصوتيات || `-ال` | `-ات` | 164 words | المجموعات, الصوتيات || `-ال` | `-ية` | 142 words | الرواقية, السيادية || `-ل` | `-ت` | 131 words | لقمقومات, لپوطوات || `-ل` | `-ات` | 125 words | لقمقومات, لپوطوات || `-ل` | `-ن` | 124 words | لعيّان, لخيشوميين || `-ال` | `-ن` | 119 words | الكربون, الفريقين || `-ل` | `-ية` | 116 words | لعدمية, لبيولوجية |
### 6.5 Recursive Morpheme Segmentation
Using **Recursive Hierarchical Substitutability**, we decompose complex words into their constituent morphemes. This approach handles nested affixes (e.g., `prefix-prefix-root-suffix`).
| Word | Suggested Split | Confidence | Stem ||------|-----------------|------------|------|| والعمالات | **`و-ال-عمالات`** | 7.5 | `عمالات` || والراشيدية | **`و-ال-راشيدية`** | 7.5 | `راشيدية` || والمشروبات | **`و-ال-مشروبات`** | 7.5 | `مشروبات` || والمؤرخين | **`و-ال-مؤرخين`** | 7.5 | `مؤرخين` || والمسيحية | **`و-ال-مسيحية`** | 7.5 | `مسيحية` || فالسعودية | **`ف-ال-سعودية`** | 7.5 | `سعودية` || بالفرنسية | **`ب-ال-فرنسية`** | 7.5 | `فرنسية` || بالكيلوݣرام | **`ب-ال-كيلوݣرام`** | 7.5 | `كيلوݣرام` || والأساتذة | **`و-ال-أساتذة`** | 7.5 | `أساتذة` || والأقاليم | **`و-ال-أقاليم`** | 7.5 | `أقاليم` || باللاتينية | **`ب-ال-لاتينية`** | 7.5 | `لاتينية` || باليونانية | **`ب-ال-يونانية`** | 7.5 | `يونانية` || لبزقوليين | **`لبزقول-ي-ين`** | 7.5 | `ي` || فالجورنال | **`ف-ال-جورنال`** | 7.5 | `جورنال` || بالصيناعة | **`ب-ال-صيناعة`** | 7.5 | `صيناعة` |
### 6.6 Linguistic Interpretation
> **Automated Insight:**The language Moroccan Arabic shows high morphological productivity. The subword models are significantly more efficient than word models, suggesting a rich system of affixation or compounding.
> **Note on Idiomaticity:** The high Idiomaticity Gap suggests a large number of frequent multi-word expressions or formulaic sequences that are statistically distinct from their component parts.
---## 7. Summary & Recommendations

### Production Recommendations
| Component | Recommended | Rationale ||-----------|-------------|-----------|| Tokenizer | **64k BPE** | Best compression (4.17x) || N-gram | **2-gram** | Lowest perplexity (428) || Markov | **Context-4** | Highest predictability (97.9%) || Embeddings | **100d** | Balanced semantic capture and isotropy |
---## Appendix: Metrics Glossary & Interpretation Guide
This section provides definitions, intuitions, and guidance for interpreting the metrics used throughout this report.
### Tokenizer Metrics
**Compression Ratio**> *Definition:* The ratio of characters to tokens (chars/token). Measures how efficiently the tokenizer represents text.>> *Intuition:* Higher compression means fewer tokens needed to represent the same text, reducing sequence lengths for downstream models. A 3x compression means ~3 characters per token on average.>> *What to seek:* Higher is generally better for efficiency, but extremely high compression may indicate overly aggressive merging that loses morphological information.
**Average Token Length (Fertility)**> *Definition:* Mean number of characters per token produced by the tokenizer.>> *Intuition:* Reflects the granularity of tokenization. Longer tokens capture more context but may struggle with rare words; shorter tokens are more flexible but increase sequence length.>> *What to seek:* Balance between 2-5 characters for most languages. Arabic/morphologically-rich languages may benefit from slightly longer tokens.
**Unknown Token Rate (OOV Rate)**> *Definition:* Percentage of tokens that map to the unknown/UNK token, indicating words the tokenizer cannot represent.>> *Intuition:* Lower OOV means better vocabulary coverage. High OOV indicates the tokenizer encounters many unseen character sequences.>> *What to seek:* Below 1% is excellent; below 5% is acceptable. BPE tokenizers typically achieve very low OOV due to subword fallback.
### N-gram Model Metrics
**Perplexity**> *Definition:* Measures how "surprised" the model is by test data. Mathematically: 2^(cross-entropy). Lower values indicate better prediction.>> *Intuition:* If perplexity is 100, the model is as uncertain as if choosing uniformly among 100 options at each step. A perplexity of 10 means effectively choosing among 10 equally likely options.>> *What to seek:* Lower is better. Perplexity decreases with larger n-grams (more context). Values vary widely by language and corpus size.
**Entropy**> *Definition:* Average information content (in bits) needed to encode the next token given the context. Related to perplexity: perplexity = 2^entropy.>> *Intuition:* High entropy means high uncertainty/randomness; low entropy means predictable patterns. Natural language typically has entropy between 1-4 bits per character.>> *What to seek:* Lower entropy indicates more predictable text patterns. Entropy should decrease as n-gram size increases.
**Coverage (Top-K)**> *Definition:* Percentage of corpus occurrences explained by the top K most frequent n-grams.>> *Intuition:* High coverage with few patterns indicates repetitive/formulaic text; low coverage suggests diverse vocabulary usage.>> *What to seek:* Depends on use case. For language modeling, moderate coverage (40-60% with top-1000) is typical for natural text.
### Markov Chain Metrics
**Average Entropy**> *Definition:* Mean entropy across all contexts, measuring average uncertainty in next-word prediction.>> *Intuition:* Lower entropy means the model is more confident about what comes next. Context-1 has high entropy (many possible next words); Context-4 has low entropy (few likely continuations).>> *What to seek:* Decreasing entropy with larger context sizes. Very low entropy (<0.1) indicates highly deterministic transitions.
**Branching Factor**> *Definition:* Average number of unique next tokens observed for each context.>> *Intuition:* High branching = many possible continuations (flexible but uncertain); low branching = few options (predictable but potentially repetitive).>> *What to seek:* Branching factor should decrease with context size. Values near 1.0 indicate nearly deterministic chains.
**Predictability**> *Definition:* Derived metric: (1 - normalized_entropy) × 100%. Indicates how deterministic the model's predictions are.>> *Intuition:* 100% predictability means the next word is always certain; 0% means completely random. Real text falls between these extremes.>> *What to seek:* Higher predictability for text generation quality, but too high (>98%) may produce repetitive output.
### Vocabulary & Zipf's Law Metrics
**Zipf's Coefficient**> *Definition:* The slope of the log-log plot of word frequency vs. rank. Zipf's law predicts this should be approximately -1.>> *Intuition:* A coefficient near -1 indicates the corpus follows natural language patterns where a few words are very common and most words are rare.>> *What to seek:* Values between -0.8 and -1.2 indicate healthy natural language distribution. Deviations may suggest domain-specific or artificial text.
**R² (Coefficient of Determination)**> *Definition:* Measures how well the linear fit explains the frequency-rank relationship. Ranges from 0 to 1.>> *Intuition:* R² near 1.0 means the data closely follows Zipf's law; lower values indicate deviation from expected word frequency patterns.>> *What to seek:* R² > 0.95 is excellent; > 0.99 indicates near-perfect Zipf adherence typical of large natural corpora.
**Vocabulary Coverage**> *Definition:* Cumulative percentage of corpus tokens accounted for by the top N words.>> *Intuition:* Shows how concentrated word usage is. If top-100 words cover 50% of text, the corpus relies heavily on common words.>> *What to seek:* Top-100 covering 30-50% is typical. Higher coverage indicates more repetitive text; lower suggests richer vocabulary.
### Word Embedding Metrics
**Isotropy**> *Definition:* Measures how uniformly distributed vectors are in the embedding space. Computed as the ratio of minimum to maximum singular values.>> *Intuition:* High isotropy (near 1.0) means vectors spread evenly in all directions; low isotropy means vectors cluster in certain directions, reducing expressiveness.>> *What to seek:* Higher isotropy generally indicates better-quality embeddings. Values > 0.1 are reasonable; > 0.3 is good. Lower-dimensional embeddings tend to have higher isotropy.
**Average Norm**> *Definition:* Mean magnitude (L2 norm) of word vectors in the embedding space.>> *Intuition:* Indicates the typical "length" of vectors. Consistent norms suggest stable training; high variance may indicate some words are undertrained.>> *What to seek:* Relatively consistent norms across models. The absolute value matters less than consistency (low std deviation).
**Cosine Similarity**> *Definition:* Measures angular similarity between vectors, ranging from -1 (opposite) to 1 (identical direction).>> *Intuition:* Words with similar meanings should have high cosine similarity. This is the standard metric for semantic relatedness in embeddings.>> *What to seek:* Semantically related words should score > 0.5; unrelated words should be near 0. Synonyms often score > 0.7.
**t-SNE Visualization**> *Definition:* t-Distributed Stochastic Neighbor Embedding - a dimensionality reduction technique that preserves local structure for visualization.>> *Intuition:* Clusters in t-SNE plots indicate groups of semantically related words. Spread indicates vocabulary diversity; tight clusters suggest semantic coherence.>> *What to seek:* Meaningful clusters (e.g., numbers together, verbs together). Avoid over-interpreting distances - t-SNE preserves local, not global, structure.
### General Interpretation Guidelines
1. **Compare within model families:** Metrics are most meaningful when comparing models of the same type (e.g., 8k vs 64k tokenizer).2. **Consider trade-offs:** Better performance on one metric often comes at the cost of another (e.g., compression vs. OOV rate).3. **Context matters:** Optimal values depend on downstream tasks. Text generation may prioritize different metrics than classification.4. **Corpus influence:** All metrics are influenced by corpus characteristics. Wikipedia text differs from social media or literature.5. **Language-specific patterns:** Morphologically rich languages (like Arabic) may show different optimal ranges than analytic languages.
### Visualizations Index
| Visualization | Description ||---------------|-------------|| Tokenizer Compression | Compression ratios by vocabulary size || Tokenizer Fertility | Average token length by vocabulary || Tokenizer OOV | Unknown token rates || Tokenizer Total Tokens | Total tokens by vocabulary || N-gram Perplexity | Perplexity by n-gram size || N-gram Entropy | Entropy by n-gram size || N-gram Coverage | Top pattern coverage || N-gram Unique | Unique n-gram counts || Markov Entropy | Entropy by context size || Markov Branching | Branching factor by context || Markov Contexts | Unique context counts || Zipf's Law | Frequency-rank distribution with fit || Vocab Frequency | Word frequency distribution || Top 20 Words | Most frequent words || Vocab Coverage | Cumulative coverage curve || Embedding Isotropy | Vector space uniformity || Embedding Norms | Vector magnitude distribution || Embedding Similarity | Word similarity heatmap || Nearest Neighbors | Similar words for key terms || t-SNE Words | 2D word embedding visualization || t-SNE Sentences | 2D sentence embedding visualization || Position Encoding | Encoding method comparison || Model Sizes | Storage requirements || Performance Dashboard | Comprehensive performance overview |
---👈 [Back to README](README.md)
*Generated by Wikilangs Pipeline · 2026-03-02 12:03:50*123version https://git-lfs.github.com/spec/v1oid sha256:ec09f2d29ccb3090249f3738f6068e825d70e537decf94ac5428ed8f1bc41e8fsize 1060912662123version https://git-lfs.github.com/spec/v1oid sha256:23dd29124172fc87eca0b06da00cc83acbea4338d4ab0bb944c1443f13f8a402size 1061407900
123version https://git-lfs.github.com/spec/v1oid sha256:8d5d793e55a655ac0900c665a7dd2b25bfb2c721388f369f0c888b532aab2b2dsize 65664123version https://git-lfs.github.com/spec/v1oid sha256:cf17e00d60be7e77cd190f5673e7b5fb42725875195a574e8af838fe7ab7c4fesize 65664
2 unmodified lines3456782 unmodified lines"dimension": 128,"version": "aligned","hub_language": "en","seed_vocab_size": 3796,"vocab_size": 35328}2 unmodified lines3456782 unmodified lines"dimension": 128,"version": "aligned","hub_language": "en","seed_vocab_size": 3971,"vocab_size": 35802}
123version https://git-lfs.github.com/spec/v1oid sha256:8540a7a08f8241b60423dc69caaee169822f093e1cf6353b8295063122a7e4bfsize 265780758123version https://git-lfs.github.com/spec/v1oid sha256:85ae7c72bcc613fc8ebe04229c068b299fa614cafb556f87a170dec369e8b068size 265911964
123version https://git-lfs.github.com/spec/v1oid sha256:ce8e1e863fb9c4375db9cffb22d2a2c951ffc80e15e09b06bf6aebee82431cd7size 4224123version https://git-lfs.github.com/spec/v1oid sha256:6a4134a5733227be26d45ca94a80c670cff54c5a385ea3abd083727066f0058fsize 4224
2 unmodified lines3456782 unmodified lines"dimension": 32,"version": "aligned","hub_language": "en","seed_vocab_size": 3796,"vocab_size": 35328}2 unmodified lines3456782 unmodified lines"dimension": 32,"version": "aligned","hub_language": "en","seed_vocab_size": 3971,"vocab_size": 35802}
123version https://git-lfs.github.com/spec/v1oid sha256:22c1abedc8bbe33e113c64455d6fd411194e4a7ddb5e0a3c659df8c08962758dsize 530824726123version https://git-lfs.github.com/spec/v1oid sha256:e0f2ba5eeba6b085b95d8dddb3edbbf6f17c9da5abe2bda71e649e7efa93dba0size 531077276
123version https://git-lfs.github.com/spec/v1oid sha256:468aba2325cf26abc86b89cccca9a63ff95115fe381081eceafadf68a2846d6bsize 16512123version https://git-lfs.github.com/spec/v1oid sha256:bec30000a60507faa1fe0b953a2e43945709f09dad828de79a04e310e7380831size 16512
2 unmodified lines3456782 unmodified lines"dimension": 64,"version": "aligned","hub_language": "en","seed_vocab_size": 3796,"vocab_size": 35328}2 unmodified lines3456782 unmodified lines"dimension": 64,"version": "aligned","hub_language": "en","seed_vocab_size": 3971,"vocab_size": 35802}
123version https://git-lfs.github.com/spec/v1oid sha256:ec09f2d29ccb3090249f3738f6068e825d70e537decf94ac5428ed8f1bc41e8fsize 1060912662123version https://git-lfs.github.com/spec/v1oid sha256:23dd29124172fc87eca0b06da00cc83acbea4338d4ab0bb944c1443f13f8a402size 1061407900
8 unmodified lines91011121314158 unmodified lines"negative": 5,"epochs": 5,"encoding_method": "rope","dim": 128},"vocab_size": 35328}8 unmodified lines9101112131415168 unmodified lines"negative": 5,"epochs": 5,"encoding_method": "rope","dim": 128,"threads": 40},"vocab_size": 35802}
123version https://git-lfs.github.com/spec/v1oid sha256:8540a7a08f8241b60423dc69caaee169822f093e1cf6353b8295063122a7e4bfsize 265780758123version https://git-lfs.github.com/spec/v1oid sha256:85ae7c72bcc613fc8ebe04229c068b299fa614cafb556f87a170dec369e8b068size 265911964
8 unmodified lines91011121314158 unmodified lines"negative": 5,"epochs": 5,"encoding_method": "rope","dim": 32},"vocab_size": 35328}8 unmodified lines9101112131415168 unmodified lines"negative": 5,"epochs": 5,"encoding_method": "rope","dim": 32,"threads": 40},"vocab_size": 35802}
123version https://git-lfs.github.com/spec/v1oid sha256:22c1abedc8bbe33e113c64455d6fd411194e4a7ddb5e0a3c659df8c08962758dsize 530824726123version https://git-lfs.github.com/spec/v1oid sha256:e0f2ba5eeba6b085b95d8dddb3edbbf6f17c9da5abe2bda71e649e7efa93dba0size 531077276
8 unmodified lines91011121314158 unmodified lines"negative": 5,"epochs": 5,"encoding_method": "rope","dim": 64},"vocab_size": 35328}8 unmodified lines9101112131415168 unmodified lines"negative": 5,"epochs": 5,"encoding_method": "rope","dim": 64,"threads": 40},"vocab_size": 35802}
123version https://git-lfs.github.com/spec/v1oid sha256:6aa85613e52f70b5400e89d68121d9f314136f411cc3b9ddb727f1a18275c75bsize 139539123version https://git-lfs.github.com/spec/v1oid sha256:a47d186cfa8ba5504f207f80b2a7ee4d4a993924df44c1e658f81586ab974232size 138893
1 unmodified line2345671 unmodified line"context_size": 1,"variant": "subword","language": "ary","unique_contexts": 2156,"total_transitions": 11674521}1 unmodified line2345671 unmodified line"context_size": 1,"variant": "subword","language": "ary","unique_contexts": 2159,"total_transitions": 11813843}
123version https://git-lfs.github.com/spec/v1oid sha256:b46ebfbdafda98e2adad1319ead7fedc44d9204d2776cf2e3205c3bd5f5afebesize 797041123version https://git-lfs.github.com/spec/v1oid sha256:186a66b4aac4749ba72cd645b66d11d219a06361505677603344d72626665cc8size 793471
1 unmodified line2345671 unmodified line"context_size": 2,"variant": "subword","language": "ary","unique_contexts": 18029,"total_transitions": 11663613}1 unmodified line2345671 unmodified line"context_size": 2,"variant": "subword","language": "ary","unique_contexts": 18051,"total_transitions": 11802900}
123version https://git-lfs.github.com/spec/v1oid sha256:6b4192f99a87bb45ced2563948e266621a565af8ac63ce8f4bde28a93144d756size 2874859123version https://git-lfs.github.com/spec/v1oid sha256:a84fe22f4f1abae384b0dab4be36edac253da06347c8acfe4c377644117593e6size 2887510
1 unmodified line2345671 unmodified line"context_size": 3,"variant": "subword","language": "ary","unique_contexts": 91858,"total_transitions": 11652705}1 unmodified line2345671 unmodified line"context_size": 3,"variant": "subword","language": "ary","unique_contexts": 92103,"total_transitions": 11791957}
123version https://git-lfs.github.com/spec/v1oid sha256:aadd6890898708013a847b49d511a4f98c3b4ee57283f361bdeaeedfa6653f41size 9246973123version https://git-lfs.github.com/spec/v1oid sha256:b35928174eefb8cdcf6d948433a4d30d1732c733bee1a59cbf4b1b34a96af4a9size 9333153
1 unmodified line2345671 unmodified line"context_size": 4,"variant": "subword","language": "ary","unique_contexts": 379445,"total_transitions": 11641797}1 unmodified line2345671 unmodified line"context_size": 4,"variant": "subword","language": "ary","unique_contexts": 381563,"total_transitions": 11781014}
123version https://git-lfs.github.com/spec/v1oid sha256:85362146166777b9bcdb0f05aa64508022ee248e5e3f69964e1de614c03e7699size 83835123version https://git-lfs.github.com/spec/v1oid sha256:11f67345d6612258f0c36fbcc4ef91d3a4f788f8946cd10aca12fb49e0591722size 83143
1 unmodified line2345671 unmodified line"n": 2,"variant": "subword","language": "ary","unique_ngrams": 5903,"total_ngrams": 11674521}1 unmodified line2345671 unmodified line"n": 2,"variant": "subword","language": "ary","unique_ngrams": 5913,"total_ngrams": 11813843}
123version https://git-lfs.github.com/spec/v1oid sha256:40969977a99672eecdb27448421f16a3f187d65f3c0dc151cea853e070cbadb7size 604436123version https://git-lfs.github.com/spec/v1oid sha256:731fe728fefb3100db18de2567e0ab19ed6320bc9b3860a656e1b0d723071d5fsize 605193
1 unmodified line2345671 unmodified line"n": 3,"variant": "subword","language": "ary","unique_ngrams": 44651,"total_ngrams": 11663613}1 unmodified line2345671 unmodified line"n": 3,"variant": "subword","language": "ary","unique_ngrams": 44840,"total_ngrams": 11802900}
123version https://git-lfs.github.com/spec/v1oid sha256:2378e1e2d64b3df9e93427a1a78bcd5faaf6ed666409f9219472f778c7c03606size 2807017123version https://git-lfs.github.com/spec/v1oid sha256:2906b0bb46f6eb9129cd9215d946598cc0e16a7cae247295719ba3050cc96116size 2842344
1 unmodified line2345671 unmodified line"n": 4,"variant": "subword","language": "ary","unique_ngrams": 220807,"total_ngrams": 11652705}1 unmodified line2345671 unmodified line"n": 4,"variant": "subword","language": "ary","unique_ngrams": 222645,"total_ngrams": 11791957}
123version https://git-lfs.github.com/spec/v1oid sha256:faf8ee4ec12ef42cd5e3558d66ad4aeff0631f166fba66070e4e84f08a774416size 7211281123version https://git-lfs.github.com/spec/v1oid sha256:533843b27ab76aad1a2125aba30039074abf08adaee6e22d0fe500236c06a257size 7278591
1 unmodified line2345671 unmodified line"n": 5,"variant": "subword","language": "ary","unique_ngrams": 527725,"total_ngrams": 11641797}1 unmodified line2345671 unmodified line"n": 5,"variant": "subword","language": "ary","unique_ngrams": 533903,"total_ngrams": 11781014}
123version https://git-lfs.github.com/spec/v1oid sha256:1180ec148decdb3ef68cab243d4b164e40e6f3a9cd004c5a4a6675974d1751d6size 559287123version https://git-lfs.github.com/spec/v1oid sha256:f4d5e32d06745b883de576bf9b8e04f6b546761414ef32c72ce2e58c2493d6f2size 558827
123version https://git-lfs.github.com/spec/v1oid sha256:62ead2fffa727c9fa33838adbab2d6cfe8e11b224486009a2df8900f2a79d842size 891778123version https://git-lfs.github.com/spec/v1oid sha256:a7d26a99b4d6eaba0bf6312cb2107eb329d0d96c3e427e621e8b0750a99f2374size 891273
123version https://git-lfs.github.com/spec/v1oid sha256:1cc3477018e21f222e7e79316e39de3e66d54eaa975a1b19e66cb19ef807cd23size 1592960123version https://git-lfs.github.com/spec/v1oid sha256:3d3dc68570a8afe23be4f8d6f0d33b09f73fc4cd0a38ab57824a5bc552a1eeb9size 1592537
123version https://git-lfs.github.com/spec/v1oid sha256:6c9d36c71b1333556ef6580bcbbd43671c35b88296320664be74ffda2b47642csize 396519123version https://git-lfs.github.com/spec/v1oid sha256:8ef26d909eaf49e80af1cd939826a6e5d8ecab53a921532d6dd5019f91013175size 396383
123version https://git-lfs.github.com/spec/v1oid sha256:06972d02fe5edd7023b3c7da816f69a17e6b3e79183317908fa5f435bcd3fe0bsize 1396990123version https://git-lfs.github.com/spec/v1oid sha256:ae2ef916c872a66f5ac3b2a576a30a32773cb05153f900a81655c67a9a53d98dsize 1426642
1234567891011121314151617{"language": "ary","vocabulary_size": 78779,"variant": "full","statistics": {"type_token_ratio": 0.0838713972533892,"coverage": {"top_100": 0.36742576968301266,"top_1000": 0.5995843327288514,"top_5000": 0.7413866015051412,"top_10000": 0.8022598684642346},"hapax_count": 100115,"hapax_ratio": 0.5596330788064441,"total_documents": 10908}}1234567891011121314151617{"language": "ary","vocabulary_size": 79667,"variant": "full","statistics": {"type_token_ratio": 0.08362757688063684,"coverage": {"top_100": 0.366426714703403,"top_1000": 0.5985740986276256,"top_5000": 0.7404440555697419,"top_10000": 0.8014438827079335},"hapax_count": 100784,"hapax_ratio": 0.558511728945808,"total_documents": 10943}}
123version https://git-lfs.github.com/spec/v1oid sha256:7a010a2fee1638b81b95efa703c67ec669457295da9be4b0fd98080b9fa5269bsize 10613710123version https://git-lfs.github.com/spec/v1oid sha256:ea031ad3bae66c0cd73c32d8253f69299f69d10016ee3f7ed372ca7d93a180ddsize 10728094
1 unmodified line2345671 unmodified line"context_size": 1,"variant": "word","language": "ary","unique_contexts": 178865,"total_transitions": 2122048}1 unmodified line2345671 unmodified line"context_size": 1,"variant": "word","language": "ary","unique_contexts": 180421,"total_transitions": 2146850}
123version https://git-lfs.github.com/spec/v1oid sha256:712f90109dc88d6441f66e51cbe823ae8692297f944de4a533056a1db4fd292fsize 26628986123version https://git-lfs.github.com/spec/v1oid sha256:b484e89a2f5ad24d4011e063ffd1dfcceaa56a738004916a9aff590bcdc9eb02size 26992628
1 unmodified line2345671 unmodified line"context_size": 2,"variant": "word","language": "ary","unique_contexts": 962233,"total_transitions": 2111140}1 unmodified line2345671 unmodified line"context_size": 2,"variant": "word","language": "ary","unique_contexts": 973633,"total_transitions": 2135907}
123version https://git-lfs.github.com/spec/v1oid sha256:0f27df8a6b3c1b3e0c9195f59edb4203d0589a76026e8e82991c554cda82d38fsize 36690145123version https://git-lfs.github.com/spec/v1oid sha256:7131ba67344fb5d89210dc4d2112f8cc84f31f8e36fb9130be3ca9cf72dc830fsize 37168553
1 unmodified line2345671 unmodified line"context_size": 3,"variant": "word","language": "ary","unique_contexts": 1431084,"total_transitions": 2100232}1 unmodified line2345671 unmodified line"context_size": 3,"variant": "word","language": "ary","unique_contexts": 1450643,"total_transitions": 2124964}
README.md+130-665
RESEARCH_REPORT.mdAdded+688
ary_morph_tokenizer.jsonAdded
models/embeddings/aligned/ary_128d.bin+2-2
models/embeddings/aligned/ary_128d.projection.npy+1-1
models/embeddings/aligned/ary_128d_metadata.json+2-2
models/embeddings/aligned/ary_32d.bin+2-2
models/embeddings/aligned/ary_32d.projection.npy+1-1
models/embeddings/aligned/ary_32d_metadata.json+2-2
models/embeddings/aligned/ary_64d.bin+2-2
models/embeddings/aligned/ary_64d.projection.npy+1-1
models/embeddings/aligned/ary_64d_metadata.json+2-2
models/embeddings/monolingual/ary_128d.bin+2-2
models/embeddings/monolingual/ary_128d_metadata.json+3-2
models/embeddings/monolingual/ary_32d.bin+2-2
models/embeddings/monolingual/ary_32d_metadata.json+3-2
models/embeddings/monolingual/ary_64d.bin+2-2
models/embeddings/monolingual/ary_64d_metadata.json+3-2
models/subword_markov/ary_markov_ctx1_subword.parquet+2-2
models/subword_markov/ary_markov_ctx1_subword_metadata.json+2-2
models/subword_markov/ary_markov_ctx2_subword.parquet+2-2
models/subword_markov/ary_markov_ctx2_subword_metadata.json+2-2
models/subword_markov/ary_markov_ctx3_subword.parquet+2-2
models/subword_markov/ary_markov_ctx3_subword_metadata.json+2-2
models/subword_markov/ary_markov_ctx4_subword.parquet+2-2
models/subword_markov/ary_markov_ctx4_subword_metadata.json+2-2
models/subword_ngram/ary_2gram_subword.parquet+2-2
models/subword_ngram/ary_2gram_subword_metadata.json+2-2
models/subword_ngram/ary_3gram_subword.parquet+2-2
models/subword_ngram/ary_3gram_subword_metadata.json+2-2
models/subword_ngram/ary_4gram_subword.parquet+2-2
models/subword_ngram/ary_4gram_subword_metadata.json+2-2
models/subword_ngram/ary_5gram_subword.parquet+2-2
models/subword_ngram/ary_5gram_subword_metadata.json+2-2
models/tokenizer/ary_tokenizer_16k.model+2-2
models/tokenizer/ary_tokenizer_16k.vocab
models/tokenizer/ary_tokenizer_32k.model+2-2
models/tokenizer/ary_tokenizer_32k.vocab
models/tokenizer/ary_tokenizer_64k.model+2-2
models/tokenizer/ary_tokenizer_64k.vocab
models/tokenizer/ary_tokenizer_8k.model+2-2
models/tokenizer/ary_tokenizer_8k.vocab
models/vocabulary/ary_vocabulary.parquet+2-2
models/vocabulary/ary_vocabulary_metadata.json+9-9
models/word_markov/ary_markov_ctx1_word.parquet+2-2
models/word_markov/ary_markov_ctx1_word_metadata.json+2-2
models/word_markov/ary_markov_ctx2_word.parquet+2-2
models/word_markov/ary_markov_ctx2_word_metadata.json+2-2
models/word_markov/ary_markov_ctx3_word.parquet+2-2
models/word_markov/ary_markov_ctx3_word_metadata.json+2-2