--- language: lg language_name: Ganda language_family: bantu_eastern tags: - wikilangs - nlp - tokenizer - embeddings - n-gram - markov - wikipedia - feature-extraction - sentence-similarity - tokenization - n-grams - markov-chain - text-mining - fasttext - babelvec - vocabulous - vocabulary - monolingual - family-bantu_eastern license: mit library_name: wikilangs pipeline_tag: text-generation datasets: - omarkamali/wikipedia-monthly dataset_info: name: wikipedia-monthly description: Monthly snapshots of Wikipedia articles across 300+ languages metrics: - name: best_compression_ratio type: compression value: 4.749 - name: best_isotropy type: isotropy value: 0.8731 - name: vocabulary_size type: vocab value: 0 generated: 2026-01-10 --- # Ganda - Wikilangs Models ## Comprehensive Research Report & Full Ablation Study This repository contains NLP models trained and evaluated by Wikilangs, specifically on **Ganda** 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 ![Performance Dashboard](visualizations/performance_dashboard.png) ### 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 ![Tokenizer Compression](visualizations/tokenizer_compression.png) ![Tokenizer Fertility](visualizations/tokenizer_fertility.png) ![Tokenizer OOV](visualizations/tokenizer_oov.png) ![Total Tokens](visualizations/tokenizer_total_tokens.png) ### Results | Vocab Size | Compression | Avg Token Len | UNK Rate | Total Tokens | |------------|-------------|---------------|----------|--------------| | **8k** | 3.693x | 3.70 | 0.2870% | 259,571 | | **16k** | 4.077x | 4.08 | 0.3168% | 235,148 | | **32k** | 4.439x | 4.44 | 0.3449% | 215,974 | | **64k** | 4.749x 🏆 | 4.75 | 0.3690% | 201,887 | ### Tokenization Examples Below are sample sentences tokenized with each vocabulary size: **Sample 1:** `Kigulu, ekibuga mu Kira Town mu Wakiso mu Yuganda.` | Vocab | Tokens | Count | |-------|--------|-------| | 8k | `▁ki gulu , ▁ekibuga ▁mu ▁kira ▁town ▁mu ▁wakiso ▁mu ... (+2 more)` | 12 | | 16k | `▁ki gulu , ▁ekibuga ▁mu ▁kira ▁town ▁mu ▁wakiso ▁mu ... (+2 more)` | 12 | | 32k | `▁kigulu , ▁ekibuga ▁mu ▁kira ▁town ▁mu ▁wakiso ▁mu ▁yuganda ... (+1 more)` | 11 | | 64k | `▁kigulu , ▁ekibuga ▁mu ▁kira ▁town ▁mu ▁wakiso ▁mu ▁yuganda ... (+1 more)` | 11 | **Sample 2:** `Kibuku nsi e disitulikit wa Yuganda. Obugazi: 490.2 km². Abantu: 181 700 mu Yuga...` | Vocab | Tokens | Count | |-------|--------|-------| | 8k | `▁kibu ku ▁nsi ▁e ▁disitulikit ▁wa ▁yuganda . ▁obugazi : ... (+21 more)` | 31 | | 16k | `▁kibuku ▁nsi ▁e ▁disitulikit ▁wa ▁yuganda . ▁obugazi : ▁ ... (+20 more)` | 30 | | 32k | `▁kibuku ▁nsi ▁e ▁disitulikit ▁wa ▁yuganda . ▁obugazi : ▁ ... (+20 more)` | 30 | | 64k | `▁kibuku ▁nsi ▁e ▁disitulikit ▁wa ▁yuganda . ▁obugazi : ▁ ... (+20 more)` | 30 | **Sample 3:** `thumbnail Flippy lwe e okuba mu naye nga Happy Tree Friends.` | Vocab | Tokens | Count | |-------|--------|-------| | 8k | `▁thumb na il ▁f li pp y ▁lwe ▁e ▁okuba ... (+12 more)` | 22 | | 16k | `▁thumb na il ▁f lipp y ▁lwe ▁e ▁okuba ▁mu ... (+8 more)` | 18 | | 32k | `▁thumb na il ▁f lipp y ▁lwe ▁e ▁okuba ▁mu ... (+7 more)` | 17 | | 64k | `▁thumbnail ▁flippy ▁lwe ▁e ▁okuba ▁mu ▁naye ▁nga ▁ha ppy ... (+3 more)` | 13 | ### Key Findings - **Best Compression:** 64k achieves 4.749x compression - **Lowest UNK Rate:** 8k with 0.2870% 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 ![N-gram Perplexity](visualizations/ngram_perplexity.png) ![N-gram Unique](visualizations/ngram_unique.png) ![N-gram Coverage](visualizations/ngram_coverage.png) ### Results | N-gram | Variant | Perplexity | Entropy | Unique N-grams | Top-100 Coverage | Top-1000 Coverage | |--------|---------|------------|---------|----------------|------------------|-------------------| | **2-gram** | Word | 14,199 | 13.79 | 38,632 | 12.7% | 34.6% | | **2-gram** | Subword | 219 🏆 | 7.77 | 2,147 | 71.2% | 99.8% | | **3-gram** | Word | 26,700 | 14.70 | 56,796 | 9.4% | 25.1% | | **3-gram** | Subword | 1,669 | 10.70 | 19,121 | 29.6% | 78.5% | | **4-gram** | Word | 70,764 | 16.11 | 118,544 | 6.5% | 15.1% | | **4-gram** | Subword | 8,452 | 13.05 | 97,188 | 14.1% | 45.2% | | **5-gram** | Word | 61,726 | 15.91 | 94,350 | 7.0% | 14.7% | | **5-gram** | Subword | 28,463 | 14.80 | 255,792 | 7.8% | 27.9% | ### Top 5 N-grams by Size **2-grams (Word):** | Rank | N-gram | Count | |------|--------|-------| | 1 | `okuva mu` | 5,167 | | 2 | `mu uganda` | 4,435 | | 3 | `y e` | 3,265 | | 4 | `ya uganda` | 2,854 | | 5 | `mu mwaka` | 2,411 | **3-grams (Word):** | Rank | N-gram | Count | |------|--------|-------| | 1 | `disitulikiti y e` | 1,864 | | 2 | `mu mwaka gwa` | 1,837 | | 3 | `mu disitulikiti y` | 1,235 | | 4 | `okuva mu okutuuka` | 888 | | 5 | `mu okutuuka mu` | 872 | **4-grams (Word):** | Rank | N-gram | Count | |------|--------|-------| | 1 | `mu disitulikiti y e` | 1,155 | | 2 | `okuva mu okutuuka mu` | 831 | | 3 | `mu ssaza ly e` | 811 | | 4 | `united states of america` | 742 | | 5 | `erisangibwa mu ssaza ly` | 735 | **5-grams (Word):** | Rank | N-gram | Count | |------|--------|-------| | 1 | `erisangibwa mu ssaza ly e` | 735 | | 2 | `mu nsi ya united states` | 734 | | 3 | `states of america g e` | 733 | | 4 | `united states of america g` | 733 | | 5 | `ya united states of america` | 733 | **2-grams (Subword):** | Rank | N-gram | Count | |------|--------|-------| | 1 | `a _` | 510,380 | | 2 | `m u` | 198,216 | | 3 | `u _` | 192,024 | | 4 | `_ e` | 166,670 | | 5 | `_ m` | 159,088 | **3-grams (Subword):** | Rank | N-gram | Count | |------|--------|-------| | 1 | `m u _` | 121,316 | | 2 | `_ m u` | 114,905 | | 3 | `o k u` | 71,249 | | 4 | `w a _` | 70,500 | | 5 | `a _ e` | 66,280 | **4-grams (Subword):** | Rank | N-gram | Count | |------|--------|-------| | 1 | `_ m u _` | 89,059 | | 2 | `a _ m u` | 52,454 | | 3 | `_ o k u` | 49,017 | | 4 | `n g a _` | 45,054 | | 5 | `b w a _` | 32,976 | **5-grams (Subword):** | Rank | N-gram | Count | |------|--------|-------| | 1 | `a _ m u _` | 43,937 | | 2 | `_ n g a _` | 29,244 | | 3 | `a _ o k u` | 23,484 | | 4 | `g a n d a` | 23,102 | | 5 | `u g a n d` | 22,563 | ### Key Findings - **Best Perplexity:** 2-gram (subword) with 219 - **Entropy Trend:** Decreases with larger n-grams (more predictable) - **Coverage:** Top-1000 patterns cover ~28% of corpus - **Recommendation:** 4-gram or 5-gram for best predictive performance --- ## 3. Markov Chain Evaluation ![Markov Entropy](visualizations/markov_entropy.png) ![Markov Contexts](visualizations/markov_contexts.png) ![Markov Branching](visualizations/markov_branching.png) ### Results | Context | Variant | Avg Entropy | Perplexity | Branching Factor | Unique Contexts | Predictability | |---------|---------|-------------|------------|------------------|-----------------|----------------| | **1** | Word | 0.7920 | 1.731 | 5.69 | 115,787 | 20.8% | | **1** | Subword | 1.1968 | 2.292 | 11.50 | 360 | 0.0% | | **2** | Word | 0.2704 | 1.206 | 1.67 | 657,016 | 73.0% | | **2** | Subword | 1.2119 | 2.316 | 7.94 | 4,135 | 0.0% | | **3** | Word | 0.1023 | 1.073 | 1.18 | 1,092,887 | 89.8% | | **3** | Subword | 0.9620 | 1.948 | 4.72 | 32,782 | 3.8% | | **4** | Word | 0.0425 🏆 | 1.030 | 1.06 | 1,288,031 | 95.7% | | **4** | Subword | 0.6947 | 1.619 | 3.00 | 154,616 | 30.5% | ### Generated Text Samples (Word-based) Below are text samples generated from each word-based Markov chain model: **Context Size 1:** 1. `mu mutwe gwayo kwe yali mukiise mu mawanga g e kenya visa pour la masaka n` 2. `ku modern uganda olw amanyi mu kitundu ekisooka difiiri bw ebyoto ebisatu by ebijanjaalo biwerako er...` 3. `nga 7 223 530 mu mukundani eyatometa n asuulibwa eddalu lya uganda premier soccer league uganda` **Context Size 2:** 1. `okuva mu bumannyirivu bwe ne famire ye jyavaamu baddamu ebigambo bye baba balowozaako h wewale okuka...` 2. `mu uganda judith babirye obuto bwe n okusoma kwe kakoma yazaalibwa mu buganda nga tewanabaawo kyefan...` 3. `y e makerere ayongerako nti yalina ekisanja kye ekyokubiri nga enkambi yamaje era essomero lino lwal...` **Context Size 3:** 1. `disitulikiti y e buhweju olukalala lw abakyala abawandiisi mu uganda eka femrite era abadde muwandii...` 2. `mu mwaka gwa okutuuka mu yakomawo mu uganda mu n alondebwa okuba omusumba mu n awummula mu joseph` 3. `mu disitulikiti y e kayunga mu paalamenti ey omwenda mwalimu edward katumba wamala yazaalibwa ng enn...` **Context Size 4:** 1. `mu disitulikiti y e ibanda siniya eyokuna yagimaliririza mu immaculate heart nyakibale secondary sch...` 2. `okuva mu okutuuka mu oluvannyuma yakola ng omukulu w essomero mu yalondebwa nga ssentebe w ekibiina ...` 3. `mu ssaza ly e texas mu nsi ya united states of america g e kentucky united states ebisangibwa mu` ### Generated Text Samples (Subword-based) Below are text samples generated from each subword-based Markov chain model: **Context Size 1:** 1. `_ddenndeti_e_ngo` 2. `a_kulizyokamu_ku` 3. `erokokin’o_ebake` **Context Size 2:** 1. `a_n'ebyasootard,_` 2. `mu_neba_kiri_aba_` 3. `u_mmu_binovera_co` **Context Size 3:** 1. `mu_kino_okwe_yatal` 2. `_mu_ugaziko_emisom` 3. `okutender,_mu_gulu` **Context Size 4:** 1. `_mu_by'amateekera_e` 2. `a_mu_mabuvo_bwe_mu_` 3. `_okuva_mu_luguumiro` ### Key Findings - **Best Predictability:** Context-4 (word) with 95.7% predictability - **Branching Factor:** Decreases with context size (more deterministic) - **Memory Trade-off:** Larger contexts require more storage (154,616 contexts) - **Recommendation:** Context-3 or Context-4 for text generation --- ## 4. Vocabulary Analysis ![Zipf's Law](visualizations/zipf_law.png) ![Top Words](visualizations/top20_words.png) ![Coverage Curve](visualizations/vocab_coverage.png) ### Statistics | Metric | Value | |--------|-------| | Vocabulary Size | 51,479 | | Total Tokens | 1,503,057 | | Mean Frequency | 29.20 | | Median Frequency | 4 | | Frequency Std Dev | 508.71 | ### Most Common Words | Rank | Word | Frequency | |------|------|-----------| | 1 | mu | 89,527 | | 2 | ku | 30,386 | | 3 | nga | 29,634 | | 4 | n | 29,585 | | 5 | uganda | 17,006 | | 6 | ne | 15,431 | | 7 | era | 14,238 | | 8 | y | 12,890 | | 9 | e | 10,819 | | 10 | ya | 10,765 | ### Least Common Words (from vocabulary) | Rank | Word | Frequency | |------|------|-----------| | 1 | leku | 2 | | 2 | agataalimu | 2 | | 3 | gyebafuna | 2 | | 4 | omuwuubi | 2 | | 5 | baakyalira | 2 | | 6 | eturude | 2 | | 7 | bannanyinimu | 2 | | 8 | obusoose | 2 | | 9 | abanyanya | 2 | | 10 | kalogo | 2 | ### Zipf's Law Analysis | Metric | Value | |--------|-------| | Zipf Coefficient | 1.0794 | | R² (Goodness of Fit) | 0.993590 | | Adherence Quality | **excellent** | ### Coverage Analysis | Top N Words | Coverage | |-------------|----------| | Top 100 | 36.5% | | Top 1,000 | 63.8% | | Top 5,000 | 82.3% | | Top 10,000 | 88.9% | ### Key Findings - **Zipf Compliance:** R²=0.9936 indicates excellent adherence to Zipf's law - **High Frequency Dominance:** Top 100 words cover 36.5% of corpus - **Long Tail:** 41,479 words needed for remaining 11.1% coverage --- ## 5. Word Embeddings Evaluation ![Embedding Isotropy](visualizations/embedding_isotropy.png) ![Similarity Matrix](visualizations/embedding_similarity.png) ![t-SNE Words](visualizations/tsne_words.png) ![t-SNE Sentences](visualizations/tsne_sentences.png) ### 5.1 Cross-Lingual Alignment ![Alignment Quality](visualizations/embedding_alignment_quality.png) ![Multilingual t-SNE](visualizations/embedding_tsne_multilingual.png) ### 5.2 Model Comparison | Model | Dimension | Isotropy | Semantic Density | Alignment R@1 | Alignment R@10 | |-------|-----------|----------|------------------|---------------|----------------| | **mono_32d** | 32 | 0.8731 | 0.3015 | N/A | N/A | | **mono_64d** | 64 | 0.8603 | 0.2214 | N/A | N/A | | **mono_128d** | 128 | 0.6513 | 0.2031 | N/A | N/A | | **aligned_32d** | 32 | 0.8731 🏆 | 0.2999 | 0.0840 | 0.3380 | | **aligned_64d** | 64 | 0.8603 | 0.2236 | 0.0980 | 0.3860 | | **aligned_128d** | 128 | 0.6513 | 0.2073 | 0.1800 | 0.5160 | ### Key Findings - **Best Isotropy:** aligned_32d with 0.8731 (more uniform distribution) - **Semantic Density:** Average pairwise similarity of 0.2428. Lower values indicate better semantic separation. - **Alignment Quality:** Aligned models achieve up to 18.0% 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 | **-0.474** | Low formulaic 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 | |--------|----------| | `-a` | atuzibwa, abafirosoofa, amazze | | `-e` | ekifuula, enschede, ebisonjola | | `-ba` | banabyamizannyo, bazanye, babonabona | | `-b` | banabyamizannyo, bazanye, braun | | `-m` | musambi, miracle, margret | | `-k` | kyaleetera, kikungiri, kipande | | `-ka` | kabwegyere, kaweefube, kagoma | | `-o` | okwefuula, omugate, okulinnyisibwa | #### Productive Suffixes | Suffix | Examples | |--------|----------| | `-a` | atuzibwa, lwawangula, okwefuula | | `-wa` | atuzibwa, okulinnyisibwa, obubwa | | `-o` | banabyamizannyo, luweero, ssonko | | `-e` | enschede, omugate, kipande | | `-ra` | kyaleetera, yakyogera, luddirira | | `-i` | musambi, kikungiri, ppulaani | | `-u` | ekizungu, ntenjeru, gyawulwamu | | `-za` | awezezza, byanjigiriza, kulowooza | ### 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 | |------|----------|------------------|----------| | `teek` | 2.29x | 104 contexts | teeka, ateeka, eteeka | | `tion` | 2.59x | 28 contexts | action, motion, cation | | `wang` | 1.81x | 117 contexts | wangu, wangi, lwang | | `gand` | 2.28x | 38 contexts | ganda, ugand, nganda | | `anny` | 1.99x | 62 contexts | danny, zannya, zannyi | | `atio` | 2.45x | 26 contexts | ratio, cation, nation | | `embe` | 2.09x | 37 contexts | ember, dembe, ddembe | | `ugan` | 1.97x | 46 contexts | ugand, uganda, ugandas | | `erez` | 2.01x | 30 contexts | perez, tereza, wereza | | `omuk` | 1.90x | 34 contexts | omuko, omuka, omukka | | `okus` | 1.82x | 37 contexts | okusa, okussa, okusiba | | `okuk` | 1.97x | 26 contexts | okuka, okukka, okukuu | ### 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 | |--------|--------|-----------|----------| | `-o` | `-a` | 720 words | okukiikirirwa, okumusaba | | `-e` | `-a` | 516 words | eyonooneddwa, entakyuuka | | `-k` | `-a` | 384 words | kuvuganya, kubula | | `-a` | `-a` | 376 words | atea, akomererwa | | `-e` | `-o` | 230 words | ebipapajjo, ekigattikakibabiro | | `-ba` | `-a` | 197 words | bamerika, balumbagana | | `-b` | `-a` | 185 words | bamerika, balumbagana | | `-o` | `-o` | 147 words | ogwomukwano, okuzaawo | | `-e` | `-wa` | 138 words | eyonooneddwa, egizannyirwa | | `-o` | `-u` | 116 words | ogusibukamu, ogirimu | ### 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 | |------|-----------------|------------|------| | baamatwale | **`baamat-wa-le`** | 7.5 | `wa` | | ebikwatibwako | **`ebikwatib-wa-ko`** | 7.5 | `wa` | | okuyisaawo | **`okuyisa-a-wo`** | 7.5 | `a` | | ekisingamu | **`ekising-a-mu`** | 7.5 | `a` | | obusingirayo | **`obusingir-a-yo`** | 7.5 | `a` | | kumuyamba | **`ku-mu-yamba`** | 7.5 | `yamba` | | kwatuukibwako | **`kwatuukib-wa-ko`** | 7.5 | `wa` | | mukungaaniramu | **`mukungaanir-a-mu`** | 7.5 | `a` | | ekitangaala | **`ekitanga-a-la`** | 7.5 | `a` | | batandikawo | **`batandik-a-wo`** | 7.5 | `a` | | bannyonyola | **`bannyony-o-la`** | 7.5 | `o` | | obunakuwavu | **`obunaku-wa-vu`** | 7.5 | `wa` | | akaateekebwawo | **`akaateekeb-wa-wo`** | 7.5 | `wa` | | okwetuusaako | **`okwetuusa-a-ko`** | 7.5 | `a` | | ekwatibwako | **`ekwatib-wa-ko`** | 7.5 | `wa` | ### 6.6 Linguistic Interpretation > **Automated Insight:** The language Ganda shows high morphological productivity. The subword models are significantly more efficient than word models, suggesting a rich system of affixation or compounding. --- ## 7. Summary & Recommendations ![Performance Dashboard](visualizations/performance_dashboard.png) ### Production Recommendations | Component | Recommended | Rationale | |-----------|-------------|-----------| | Tokenizer | **64k BPE** | Best compression (4.75x) | | N-gram | **2-gram** | Lowest perplexity (219) | | Markov | **Context-4** | Highest predictability (95.7%) | | 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 | --- ## About This Project ### Data Source Models trained on [wikipedia-monthly](https://huggingface.co/datasets/omarkamali/wikipedia-monthly) - a monthly snapshot of Wikipedia articles across 300+ languages. ### Project A 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) ### Citation If 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} } ``` ### License MIT 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-10 10:45:52*