| # French — Full Ablation Study & Research Report |
|
|
| Detailed evaluation of all model variants trained on **French** 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.723x | 3.72 | 0.0810% | 7,061,086 | |
| | **16k** | 4.078x | 4.08 | 0.0887% | 6,446,468 | |
| | **32k** | 4.368x | 4.37 | 0.0950% | 6,018,653 | |
| | **64k** | 4.573x 🏆 | 4.57 | 0.0994% | 5,748,614 | |
|
|
| ### Tokenization Examples |
|
|
| Below are sample sentences tokenized with each vocabulary size: |
|
|
| **Sample 1:** `Lapon peut désigner : les Samis ; les langues sames ; Lapon, une ville du Soudan...` |
|
|
| | Vocab | Tokens | Count | |
| |-------|--------|-------| |
| | 8k | `▁lap on ▁peut ▁désigner ▁: ▁les ▁sam is ▁; ▁les ... (+27 more)` | 37 | |
| | 16k | `▁lap on ▁peut ▁désigner ▁: ▁les ▁sam is ▁; ▁les ... (+27 more)` | 37 | |
| | 32k | `▁lap on ▁peut ▁désigner ▁: ▁les ▁sam is ▁; ▁les ... (+26 more)` | 36 | |
| | 64k | `▁lap on ▁peut ▁désigner ▁: ▁les ▁sam is ▁; ▁les ... (+25 more)` | 35 | |
|
|
| **Sample 2:** `Le pentadécane est un alcane linéaire de formule brute . Il possède 4 347 isomèr...` |
|
|
| | Vocab | Tokens | Count | |
| |-------|--------|-------| |
| | 8k | `▁le ▁pent ad éc ane ▁est ▁un ▁al c ane ... (+27 more)` | 37 | |
| | 16k | `▁le ▁pent ad éc ane ▁est ▁un ▁alc ane ▁linéaire ... (+22 more)` | 32 | |
| | 32k | `▁le ▁pent ad éc ane ▁est ▁un ▁alc ane ▁linéaire ... (+20 more)` | 30 | |
| | 64k | `▁le ▁pent ad éc ane ▁est ▁un ▁alcane ▁linéaire ▁de ... (+18 more)` | 28 | |
|
|
| **Sample 3:** `L'eicosane est un alcane linéaire de formule brute . Il possède isomères structu...` |
|
|
| | Vocab | Tokens | Count | |
| |-------|--------|-------| |
| | 8k | `▁l ' e ic os ane ▁est ▁un ▁al c ... (+22 more)` | 32 | |
| | 16k | `▁l ' e icos ane ▁est ▁un ▁alc ane ▁linéaire ... (+16 more)` | 26 | |
| | 32k | `▁l ' e icos ane ▁est ▁un ▁alc ane ▁linéaire ... (+14 more)` | 24 | |
| | 64k | `▁l ' e icos ane ▁est ▁un ▁alcane ▁linéaire ▁de ... (+12 more)` | 22 | |
|
|
|
|
| ### Key Findings |
|
|
| - **Best Compression:** 64k achieves 4.573x compression |
| - **Lowest UNK Rate:** 8k with 0.0810% 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 | 197,170 | 17.59 | 5,674,755 | 9.3% | 21.3% | |
| | **2-gram** | Subword | 251 🏆 | 7.97 | 40,333 | 68.1% | 99.4% | |
| | **3-gram** | Word | 1,815,223 | 20.79 | 18,029,220 | 2.4% | 9.5% | |
| | **3-gram** | Subword | 1,988 | 10.96 | 269,239 | 30.3% | 73.7% | |
| | **4-gram** | Word | 5,518,864 | 22.40 | 36,868,834 | 1.8% | 8.6% | |
| | **4-gram** | Subword | 11,120 | 13.44 | 1,563,238 | 15.8% | 42.2% | |
| | **5-gram** | Word | 4,103,331 | 21.97 | 28,227,926 | 2.4% | 11.6% | |
| | **5-gram** | Subword | 46,850 | 15.52 | 5,742,636 | 8.7% | 25.7% | |
|
|
| ### Top 5 N-grams by Size |
|
|
| **2-grams (Word):** |
|
|
| | Rank | N-gram | Count | |
| |------|--------|-------| |
| | 1 | `de la` | 5,296,650 | |
| | 2 | `de l` | 3,236,403 | |
| | 3 | `à la` | 1,514,334 | |
| | 4 | `à l` | 1,261,623 | |
| | 5 | `dans le` | 992,683 | |
|
|
| **3-grams (Word):** |
|
|
| | Rank | N-gram | Count | |
| |------|--------|-------| |
| | 1 | `de la commune` | 330,769 | |
| | 2 | `notes et références` | 310,459 | |
| | 3 | `occupation des sols` | 189,915 | |
| | 4 | `et de la` | 154,877 | |
| | 5 | `le nom de` | 144,766 | |
|
|
| **4-grams (Word):** |
|
|
| | Rank | N-gram | Count | |
| |------|--------|-------| |
| | 1 | `l occupation des sols` | 124,755 | |
| | 2 | `occupation des sols de` | 93,658 | |
| | 3 | `des sols de la` | 93,553 | |
| | 4 | `sols de la commune` | 93,442 | |
| | 5 | `notes et références voir` | 79,475 | |
|
|
| **5-grams (Word):** |
|
|
| | Rank | N-gram | Count | |
| |------|--------|-------| |
| | 1 | `occupation des sols de la` | 93,478 | |
| | 2 | `des sols de la commune` | 93,402 | |
| | 3 | `l occupation des sols de` | 93,364 | |
| | 4 | `notes et références voir aussi` | 79,373 | |
| | 5 | `notes et références liens externes` | 68,549 | |
|
|
| **2-grams (Subword):** |
|
|
| | Rank | N-gram | Count | |
| |------|--------|-------| |
| | 1 | `e _` | 125,785,698 | |
| | 2 | `s _` | 74,291,364 | |
| | 3 | `_ d` | 73,439,085 | |
| | 4 | `_ l` | 55,706,551 | |
| | 5 | `e s` | 54,301,349 | |
|
|
| **3-grams (Subword):** |
|
|
| | Rank | N-gram | Count | |
| |------|--------|-------| |
| | 1 | `_ d e` | 41,554,921 | |
| | 2 | `e s _` | 37,119,081 | |
| | 3 | `d e _` | 32,944,492 | |
| | 4 | `e _ d` | 22,149,546 | |
| | 5 | `l e _` | 20,731,208 | |
|
|
| **4-grams (Subword):** |
|
|
| | Rank | N-gram | Count | |
| |------|--------|-------| |
| | 1 | `_ d e _` | 30,047,475 | |
| | 2 | `_ l a _` | 16,205,522 | |
| | 3 | `e _ d e` | 12,867,124 | |
| | 4 | `_ l e _` | 11,621,670 | |
| | 5 | `_ e t _` | 11,489,728 | |
|
|
| **5-grams (Subword):** |
|
|
| | Rank | N-gram | Count | |
| |------|--------|-------| |
| | 1 | `_ d e _ l` | 9,678,287 | |
| | 2 | `e _ d e _` | 9,546,481 | |
| | 3 | `_ d e s _` | 7,709,198 | |
| | 4 | `_ l e s _` | 7,167,363 | |
| | 5 | `e _ l a _` | 6,536,044 | |
|
|
|
|
| ### Key Findings |
|
|
| - **Best Perplexity:** 2-gram (subword) with 251 |
| - **Entropy Trend:** Decreases with larger n-grams (more predictable) |
| - **Coverage:** Top-1000 patterns cover ~26% 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.9052 | 1.873 | 14.72 | 3,729,596 | 9.5% | |
| | **1** | Subword | 1.2049 | 2.305 | 9.45 | 20,472 | 0.0% | |
| | **2** | Word | 0.4648 | 1.380 | 3.15 | 54,852,526 | 53.5% | |
| | **2** | Subword | 0.6045 | 1.520 | 3.87 | 193,340 | 39.6% | |
| | **3** | Word | 0.2551 | 1.193 | 1.71 | 172,431,097 | 74.5% | |
| | **3** | Subword | 0.6357 | 1.554 | 3.88 | 747,541 | 36.4% | |
| | **4** | Word | 0.1275 🏆 | 1.092 | 1.26 | 294,675,620 | 87.3% | |
| | **4** | Subword | 0.6602 | 1.580 | 3.61 | 2,901,861 | 34.0% | |
|
|
| ### Generated Text Samples (Word-based) |
|
|
| Below are text samples generated from each word-based Markov chain model: |
|
|
| **Context Size 1:** |
|
|
| 1. `de titan éditions plon 424 p haffner inventaire de paris occupation des modèles différents les début...` |
| 2. `la haine féroce le bon pasteur afro américaine par la saison régulière se basent sur le` |
| 3. `le sprinteur britannique de l insigne homologué au rat dû à l ambitieux antipater d apel` |
|
|
| **Context Size 2:** |
|
|
| 1. `de la légion d honneur fleurs chapelle de la mer alt gauche vignette cimetière protestant de maulbro...` |
| 2. `de l œuvre est un dessinateur et peintre ses tableaux de derain h 10 min 50 s` |
| 3. `à la fin du la classe 1 avec un chevalet en butée dans ces moments là le` |
|
|
| **Context Size 3:** |
|
|
| 1. `de la commune est de 325 soit un indicateur de concentration d emploi de 85 2 la répartition` |
| 2. `notes et références liens externes sud coréen sorti en d aventure américain d aventure américain met...` |
| 3. `occupation des sols center carte des infrastructures et de l électromagnétisme universel de vitalité...` |
|
|
| **Context Size 4:** |
|
|
| 1. `l occupation des sols carte des infrastructures et de l occupation des sols de la commune telle qu e...` |
| 2. `occupation des sols de la commune telle qu elle ressort de la base de données européenne d occupatio...` |
| 3. `des sols de la commune en clc risques majeurs le territoire de la commune durant quinze ans christop...` |
|
|
|
|
| ### Generated Text Samples (Subword-based) |
|
|
| Below are text samples generated from each subword-based Markov chain model: |
|
|
| **Context Size 1:** |
|
|
| 1. `_partene_doy_e_s` |
| 2. `e_larit_dus_iome` |
| 3. `avide_cèsouéoù_c` |
|
|
| **Context Size 2:** |
|
|
| 1. `e_jam_à_les_du_de` |
| 2. `s_thé_ilite_la_wa` |
| 3. `_de_sa_comist_est` |
|
|
| **Context Size 3:** |
|
|
| 1. `_de_prementrest_un` |
| 2. `es_non_de_balling_` |
| 3. `de_canadieurs_la_p` |
|
|
| **Context Size 4:** |
|
|
| 1. `_de_saxe,_le_cumulu` |
| 2. `_la_capitalie._8_si` |
| 3. `e_de_de_fumer_l'éco` |
|
|
|
|
| ### Key Findings |
|
|
| - **Best Predictability:** Context-4 (word) with 87.3% predictability |
| - **Branching Factor:** Decreases with context size (more deterministic) |
| - **Memory Trade-off:** Larger contexts require more storage (2,901,861 contexts) |
| - **Recommendation:** Context-3 or Context-4 for text generation |
|
|
| --- |
| ## 4. Vocabulary Analysis |
|
|
|  |
|
|
|  |
|
|
|  |
|
|
| ### Statistics |
|
|
| | Metric | Value | |
| |--------|-------| |
| | Vocabulary Size | 1,519,124 | |
| | Total Tokens | 496,742,137 | |
| | Mean Frequency | 326.99 | |
| | Median Frequency | 4 | |
| | Frequency Std Dev | 37954.61 | |
|
|
| ### Most Common Words |
|
|
| | Rank | Word | Frequency | |
| |------|------|-----------| |
| | 1 | de | 30,301,637 | |
| | 2 | la | 16,417,649 | |
| | 3 | le | 11,875,190 | |
| | 4 | et | 11,702,997 | |
| | 5 | l | 10,150,468 | |
| | 6 | en | 9,437,564 | |
| | 7 | à | 9,348,887 | |
| | 8 | des | 7,741,717 | |
| | 9 | d | 7,508,960 | |
| | 10 | les | 7,283,372 | |
|
|
| ### Least Common Words (from vocabulary) |
|
|
| | Rank | Word | Frequency | |
| |------|------|-----------| |
| | 1 | caracallæ | 2 | |
| | 2 | santapaulina | 2 | |
| | 3 | publinf | 2 | |
| | 4 | vijñānabhairava | 2 | |
| | 5 | benbor | 2 | |
| | 6 | kunpan | 2 | |
| | 7 | moderndrawings | 2 | |
| | 8 | jexiste | 2 | |
| | 9 | ⴰⵣⵎⵎⵓⵔ | 2 | |
| | 10 | pseudocarcinus | 2 | |
|
|
| ### Zipf's Law Analysis |
|
|
| | Metric | Value | |
| |--------|-------| |
| | Zipf Coefficient | 1.0347 | |
| | R² (Goodness of Fit) | 0.992664 | |
| | Adherence Quality | **excellent** | |
|
|
| ### Coverage Analysis |
|
|
| | Top N Words | Coverage | |
| |-------------|----------| |
| | Top 100 | 44.8% | |
| | Top 1,000 | 63.9% | |
| | Top 5,000 | 79.7% | |
| | Top 10,000 | 85.5% | |
|
|
| ### Key Findings |
|
|
| - **Zipf Compliance:** R²=0.9927 indicates excellent adherence to Zipf's law |
| - **High Frequency Dominance:** Top 100 words cover 44.8% of corpus |
| - **Long Tail:** 1,509,124 words needed for remaining 14.5% 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.7808 🏆 | 0.3764 | N/A | N/A | |
| | **mono_64d** | 64 | 0.7574 | 0.3033 | N/A | N/A | |
| | **mono_128d** | 128 | 0.6995 | 0.2569 | N/A | N/A | |
| | **aligned_32d** | 32 | 0.7808 | 0.3878 | 0.4820 | 0.8240 | |
| | **aligned_64d** | 64 | 0.7574 | 0.3079 | 0.7080 | 0.9420 | |
| | **aligned_128d** | 128 | 0.6995 | 0.2657 | 0.8120 | 0.9680 | |
|
|
| ### Key Findings |
|
|
| - **Best Isotropy:** mono_32d with 0.7808 (more uniform distribution) |
| - **Semantic Density:** Average pairwise similarity of 0.3163. Lower values indicate better semantic separation. |
| - **Alignment Quality:** Aligned models achieve up to 81.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 | **-0.550** | 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` | altschloss, aën, alfège | |
| | `-s` | similairesselon, shochugeiko, sodapop | |
| | `-c` | cugn, crocefisso, colomer | |
| | `-m` | maracanaú, mandriole, morzine | |
| | `-ma` | maracanaú, mandriole, mastaï | |
| | `-d` | drăculeștibasarab, déchirent, durégnatons | |
| | `-p` | pame, pichery, pleased | |
| | `-b` | bingoto, blennies, brusuglio | |
| |
| #### Productive Suffixes |
| | Suffix | Examples | |
| |--------|----------| |
| | `-e` | pame, mandriole, morzine | |
| | `-s` | altschloss, blennies, durégnatons | |
| | `-es` | blennies, moyensles, fraternelles | |
| | `-n` | cugn, similairesselon, fransson | |
| | `-a` | occasionna, exea, paçoca | |
| | `-t` | déchirent, lovefist, crabbet | |
| | `-r` | colomer, elvir, eckersbacher | |
| | `-i` | wubi, idiomorphini, oroi | |
| |
| ### 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 | |
| |------|----------|------------------|----------| |
| | `ient` | 2.44x | 382 contexts | nient, fient, rient | |
| | `aphi` | 2.02x | 140 contexts | aphis, aphia, aphid | |
| | `ienn` | 1.59x | 391 contexts | ienne, vienn, fienne | |
| | `ogra` | 1.62x | 276 contexts | logra, bogra, fogra | |
| | `éren` | 1.81x | 150 contexts | héren, kéren, érenn | |
| | `ontr` | 1.59x | 266 contexts | montr, ontra, kontr | |
| | `tiqu` | 1.49x | 318 contexts | tiqui, tique, tiqué | |
| | `aiso` | 1.66x | 172 contexts | baiso, gaiso, daiso | |
| | `utre` | 1.56x | 215 contexts | butre, outre, autre | |
| | `niqu` | 1.42x | 248 contexts | nique, niqué, niqua | |
| | `rtic` | 1.44x | 179 contexts | artic, hrtica, artici | |
| | `onal` | 1.50x | 136 contexts | conal, monal, sonal | |
| |
| ### 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 | |
| |--------|--------|-----------|----------| |
| | `-c` | `-s` | 143 words | couleuses, cammaerts | |
| | `-m` | `-s` | 137 words | morians, merckens | |
| | `-c` | `-e` | 121 words | clémentine, classessite | |
| | `-p` | `-s` | 115 words | pétards, psylles | |
| | `-a` | `-s` | 114 words | alvaros, aldrinus | |
| | `-s` | `-s` | 107 words | sportpaleis, shaggys | |
| | `-p` | `-e` | 105 words | pédagogique, poursuiveuse | |
| | `-m` | `-e` | 102 words | maastrichtle, martinofiministre | |
| | `-a` | `-e` | 95 words | alboize, autoparodie | |
| | `-s` | `-e` | 92 words | salicyline, studiesthe | |
| |
| ### 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 | |
| |------|-----------------|------------|------| |
| | sarrabeyrouse | **`sarrabeyrou-s-e`** | 7.5 | `s` | |
| | grippement | **`grippem-e-nt`** | 7.5 | `e` | |
| | égalementsite | **`égalements-i-te`** | 7.5 | `i` | |
| | rediviser | **`redivi-s-er`** | 7.5 | `s` | |
| | ambrosini | **`ambrosi-n-i`** | 7.5 | `n` | |
| | rencontrerai | **`rencontrer-a-i`** | 7.5 | `a` | |
| | détroitsaison | **`détroitsai-s-on`** | 7.5 | `s` | |
| | monpalais | **`monpal-a-is`** | 7.5 | `a` | |
| | vieumaison | **`vieumai-s-on`** | 7.5 | `s` | |
| | caractéristise | **`caractéristi-s-e`** | 7.5 | `s` | |
| | circonvient | **`circonvi-e-nt`** | 7.5 | `e` | |
| | tilehurst | **`tilehur-s-t`** | 7.5 | `s` | |
| | chongsheng | **`chongsh-e-ng`** | 7.5 | `e` | |
| | bloemfontein | **`bloemfont-e-in`** | 7.5 | `e` | |
| | voorspoel | **`voorspo-e-l`** | 7.5 | `e` | |
| |
| ### 6.6 Linguistic Interpretation |
| |
| > **Automated Insight:** |
| The language French 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 |
| |
|  |
| |
| ### Production Recommendations |
| |
| | Component | Recommended | Rationale | |
| |-----------|-------------|-----------| |
| | Tokenizer | **64k BPE** | Best compression (4.57x) | |
| | N-gram | **2-gram** | Lowest perplexity (251) | |
| | Markov | **Context-4** | Highest predictability (87.3%) | |
| | 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-03 09:31:27* |
|
|