| # Spanish — Full Ablation Study & Research Report |
|
|
| Detailed evaluation of all model variants trained on **Spanish** 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.885x | 3.89 | 0.0687% | 4,882,549 | |
| | **16k** | 4.280x | 4.28 | 0.0756% | 4,432,264 | |
| | **32k** | 4.603x | 4.60 | 0.0813% | 4,121,359 | |
| | **64k** | 4.831x 🏆 | 4.83 | 0.0854% | 3,926,906 | |
|
|
| ### Tokenization Examples |
|
|
| Below are sample sentences tokenized with each vocabulary size: |
|
|
| **Sample 1:** `Opegrapha es un género de hongos liquenizados de la familia Opegraphaceae. Espec...` |
|
|
| | Vocab | Tokens | Count | |
| |-------|--------|-------| |
| | 8k | `▁o pe gra p ha ▁es ▁un ▁género ▁de ▁hon ... (+22 more)` | 32 | |
| | 16k | `▁o pe gra pha ▁es ▁un ▁género ▁de ▁hongos ▁li ... (+18 more)` | 28 | |
| | 32k | `▁o pe gra pha ▁es ▁un ▁género ▁de ▁hongos ▁li ... (+17 more)` | 27 | |
| | 64k | `▁o pe gra pha ▁es ▁un ▁género ▁de ▁hongos ▁li ... (+17 more)` | 27 | |
|
|
| **Sample 2:** `Una única familia: Salicaceae. Árboles, arbustos y matas. Numerosos óvulos; 2 ca...` |
|
|
| | Vocab | Tokens | Count | |
| |-------|--------|-------| |
| | 8k | `▁una ▁única ▁familia : ▁sal ica ceae . ▁árboles , ... (+29 more)` | 39 | |
| | 16k | `▁una ▁única ▁familia : ▁sal ica ceae . ▁árboles , ... (+24 more)` | 34 | |
| | 32k | `▁una ▁única ▁familia : ▁sal icaceae . ▁árboles , ▁arbustos ... (+17 more)` | 27 | |
| | 64k | `▁una ▁única ▁familia : ▁sal icaceae . ▁árboles , ▁arbustos ... (+17 more)` | 27 | |
|
|
| **Sample 3:** `Apogonia es un género de escarabajos. Algunos son plagas de los árboles de durio...` |
|
|
| | Vocab | Tokens | Count | |
| |-------|--------|-------| |
| | 8k | `▁apo gon ia ▁es ▁un ▁género ▁de ▁esca ra ba ... (+14 more)` | 24 | |
| | 16k | `▁apo gon ia ▁es ▁un ▁género ▁de ▁esca raba jos ... (+13 more)` | 23 | |
| | 32k | `▁apo gonia ▁es ▁un ▁género ▁de ▁esca raba jos . ... (+12 more)` | 22 | |
| | 64k | `▁apo gonia ▁es ▁un ▁género ▁de ▁escarabajos . ▁algunos ▁son ... (+9 more)` | 19 | |
|
|
|
|
| ### Key Findings |
|
|
| - **Best Compression:** 64k achieves 4.831x compression |
| - **Lowest UNK Rate:** 8k with 0.0687% 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 | 183,447 | 17.49 | 4,181,700 | 10.2% | 22.2% | |
| | **2-gram** | Subword | 225 🏆 | 7.82 | 32,676 | 73.3% | 99.3% | |
| | **3-gram** | Word | 1,817,727 | 20.79 | 12,295,310 | 2.4% | 7.7% | |
| | **3-gram** | Subword | 1,802 | 10.82 | 237,444 | 31.5% | 76.4% | |
| | **4-gram** | Word | 7,309,961 | 22.80 | 24,272,836 | 1.0% | 3.5% | |
| | **4-gram** | Subword | 10,272 | 13.33 | 1,392,210 | 16.3% | 43.2% | |
| | **5-gram** | Word | 8,151,138 | 22.96 | 17,610,926 | 0.6% | 2.4% | |
| | **5-gram** | Subword | 43,696 | 15.42 | 4,988,047 | 9.3% | 26.6% | |
|
|
| ### Top 5 N-grams by Size |
|
|
| **2-grams (Word):** |
|
|
| | Rank | N-gram | Count | |
| |------|--------|-------| |
| | 1 | `de la` | 3,764,844 | |
| | 2 | `en el` | 1,831,679 | |
| | 3 | `en la` | 1,685,738 | |
| | 4 | `de los` | 1,321,114 | |
| | 5 | `a la` | 938,285 | |
|
|
| **3-grams (Word):** |
|
|
| | Rank | N-gram | Count | |
| |------|--------|-------| |
| | 1 | `uno de los` | 141,403 | |
| | 2 | `de la ciudad` | 115,570 | |
| | 3 | `la ciudad de` | 108,727 | |
| | 4 | `referencias enlaces externos` | 100,698 | |
| | 5 | `la provincia de` | 97,604 | |
|
|
| **4-grams (Word):** |
|
|
| | Rank | N-gram | Count | |
| |------|--------|-------| |
| | 1 | `de la provincia de` | 59,022 | |
| | 2 | `de la ciudad de` | 41,783 | |
| | 3 | `a lo largo de` | 38,783 | |
| | 4 | `de la universidad de` | 33,450 | |
| | 5 | `en la ciudad de` | 31,628 | |
|
|
| **5-grams (Word):** |
|
|
| | Rank | N-gram | Count | |
| |------|--------|-------| |
| | 1 | `a lo largo de la` | 12,052 | |
| | 2 | `cuenta con una población de` | 11,005 | |
| | 3 | `0 0 0 0 0` | 10,612 | |
| | 4 | `en los juegos olímpicos de` | 8,927 | |
| | 5 | `de la segunda guerra mundial` | 8,768 | |
|
|
| **2-grams (Subword):** |
|
|
| | Rank | N-gram | Count | |
| |------|--------|-------| |
| | 1 | `e _` | 52,737,608 | |
| | 2 | `a _` | 52,540,713 | |
| | 3 | `_ d` | 41,585,544 | |
| | 4 | `d e` | 41,490,874 | |
| | 5 | `s _` | 40,981,306 | |
|
|
| **3-grams (Subword):** |
|
|
| | Rank | N-gram | Count | |
| |------|--------|-------| |
| | 1 | `_ d e` | 34,910,171 | |
| | 2 | `d e _` | 27,000,114 | |
| | 3 | `_ l a` | 16,444,469 | |
| | 4 | `o s _` | 15,082,263 | |
| | 5 | `e l _` | 14,921,174 | |
|
|
| **4-grams (Subword):** |
|
|
| | Rank | N-gram | Count | |
| |------|--------|-------| |
| | 1 | `_ d e _` | 25,355,198 | |
| | 2 | `_ l a _` | 12,685,143 | |
| | 3 | `_ e n _` | 10,248,634 | |
| | 4 | `_ e l _` | 9,367,910 | |
| | 5 | `o _ d e` | 6,941,874 | |
|
|
| **5-grams (Subword):** |
|
|
| | Rank | N-gram | Count | |
| |------|--------|-------| |
| | 1 | `_ d e _ l` | 6,404,305 | |
| | 2 | `o _ d e _` | 5,587,851 | |
| | 3 | `s _ d e _` | 5,212,347 | |
| | 4 | `_ q u e _` | 5,016,845 | |
| | 5 | `d e _ l a` | 4,732,721 | |
|
|
|
|
| ### Key Findings |
|
|
| - **Best Perplexity:** 2-gram (subword) with 225 |
| - **Entropy Trend:** Decreases with larger n-grams (more predictable) |
| - **Coverage:** Top-1000 patterns cover ~27% 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 | 1.0184 | 2.026 | 16.60 | 2,511,755 | 0.0% | |
| | **1** | Subword | 1.1686 | 2.248 | 8.74 | 17,433 | 0.0% | |
| | **2** | Word | 0.4618 | 1.377 | 3.10 | 41,654,830 | 53.8% | |
| | **2** | Subword | 0.6288 | 1.546 | 4.11 | 152,257 | 37.1% | |
| | **3** | Word | 0.2403 | 1.181 | 1.67 | 128,974,391 | 76.0% | |
| | **3** | Subword | 0.6792 | 1.601 | 4.08 | 625,267 | 32.1% | |
| | **4** | Word | 0.1170 🏆 | 1.084 | 1.24 | 214,851,229 | 88.3% | |
| | **4** | Subword | 0.6781 | 1.600 | 3.60 | 2,547,890 | 32.2% | |
|
|
| ### Generated Text Samples (Word-based) |
|
|
| Below are text samples generated from each word-based Markov chain model: |
|
|
| **Context Size 1:** |
|
|
| 1. `de boca juniors al alcanzar sus danzas en el nk con ellos el español y el` |
| 2. `la ribera de jabez aúl en el primer álbum considerada una variante guacara data del encéfalo` |
| 3. `en la pequeña localidad recibió una especie musa valí de megaron del origen suizo enfrentar demandas` |
|
|
| **Context Size 2:** |
|
|
| 1. `de la campana de huesca por el proyecto de igual manera considera a los que la rebelión` |
| 2. `en el reino humano ahí habitaban las estribaciones de la flota de la presidencia de manuel fernández` |
| 3. `en la victoria del ejército mexicano las investigaciones arqueológicas fue también del talmud en el ...` |
|
|
| **Context Size 3:** |
|
|
| 1. `uno de los testimonios más antiguos independientes de eugène canseliet y tomados exclusivamente de f...` |
| 2. `de la ciudad donde el cadáver yacía aún en el aeropuerto recibió a 4 120 000 de los` |
| 3. `la ciudad de bogotá ya que también fue considerado para ser desarrollado como una expresión profunda...` |
|
|
| **Context Size 4:** |
|
|
| 1. `de la provincia de buenos aires de argentina de bienestar social de mallorca cirer toma posesión del...` |
| 2. `de la ciudad de méxico y dentro de la esfera de las tradiciones judías con elementos de culto judío` |
| 3. `a lo largo de la jornada feria barroca a primeros de octubre embarcaron rumbo a la desierta isla de` |
|
|
|
|
| ### Generated Text Samples (Subword-based) |
|
|
| Below are text samples generated from each subword-based Markov chain model: |
|
|
| **Context Size 1:** |
|
|
| 1. `_uien_y_sene_fuá` |
| 2. `e_locipa_y_tatr_` |
| 3. `atrs_a_playblay_` |
|
|
| **Context Size 2:** |
|
|
| 1. `e_con_utien_dity,` |
| 2. `a_a_ta_y_carro_el` |
| 3. `_de_tes_perona_pr` |
|
|
| **Context Size 3:** |
|
|
| 1. `_de_un_mar_más_all` |
| 2. `de_la_bra_con_el_,` |
| 3. `_la_la_conte,_g._c` |
|
|
| **Context Size 4:** |
|
|
| 1. `_de_la_justaventas_` |
| 2. `_la_interés_pequeta` |
| 3. `_en_varie_daño_a_la` |
|
|
|
|
| ### Key Findings |
|
|
| - **Best Predictability:** Context-4 (word) with 88.3% predictability |
| - **Branching Factor:** Decreases with context size (more deterministic) |
| - **Memory Trade-off:** Larger contexts require more storage (2,547,890 contexts) |
| - **Recommendation:** Context-3 or Context-4 for text generation |
|
|
| --- |
| ## 4. Vocabulary Analysis |
|
|
|  |
|
|
|  |
|
|
|  |
|
|
| ### Statistics |
|
|
| | Metric | Value | |
| |--------|-------| |
| | Vocabulary Size | 1,128,398 | |
| | Total Tokens | 317,857,480 | |
| | Mean Frequency | 281.69 | |
| | Median Frequency | 4 | |
| | Frequency Std Dev | 33492.75 | |
|
|
| ### Most Common Words |
|
|
| | Rank | Word | Frequency | |
| |------|------|-----------| |
| | 1 | de | 25,424,319 | |
| | 2 | la | 12,852,916 | |
| | 3 | en | 10,451,863 | |
| | 4 | el | 9,561,089 | |
| | 5 | y | 8,147,125 | |
| | 6 | a | 5,543,222 | |
| | 7 | que | 5,130,281 | |
| | 8 | del | 4,632,587 | |
| | 9 | los | 4,528,979 | |
| | 10 | se | 3,615,320 | |
|
|
| ### Least Common Words (from vocabulary) |
|
|
| | Rank | Word | Frequency | |
| |------|------|-----------| |
| | 1 | drammenselva | 2 | |
| | 2 | bidagos | 2 | |
| | 3 | guillenpbro | 2 | |
| | 4 | peytrequincomisión | 2 | |
| | 5 | méndezpbro | 2 | |
| | 6 | ollerhno | 2 | |
| | 7 | ricamonseñor | 2 | |
| | 8 | grezillé | 2 | |
| | 9 | leguedeniau | 2 | |
| | 10 | lajubaudiere | 2 | |
|
|
| ### Zipf's Law Analysis |
|
|
| | Metric | Value | |
| |--------|-------| |
| | Zipf Coefficient | 0.9940 | |
| | R² (Goodness of Fit) | 0.993771 | |
| | Adherence Quality | **excellent** | |
|
|
| ### Coverage Analysis |
|
|
| | Top N Words | Coverage | |
| |-------------|----------| |
| | Top 100 | 44.4% | |
| | Top 1,000 | 62.8% | |
| | Top 5,000 | 78.2% | |
| | Top 10,000 | 84.3% | |
|
|
| ### Key Findings |
|
|
| - **Zipf Compliance:** R²=0.9938 indicates excellent adherence to Zipf's law |
| - **High Frequency Dominance:** Top 100 words cover 44.4% of corpus |
| - **Long Tail:** 1,118,398 words needed for remaining 15.7% 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.7898 | 0.3869 | N/A | N/A | |
| | **mono_64d** | 64 | 0.7625 | 0.3145 | N/A | N/A | |
| | **mono_128d** | 128 | 0.6860 | 0.2555 | N/A | N/A | |
| | **aligned_32d** | 32 | 0.7898 🏆 | 0.3861 | 0.5660 | 0.8680 | |
| | **aligned_64d** | 64 | 0.7625 | 0.3206 | 0.7520 | 0.9260 | |
| | **aligned_128d** | 128 | 0.6860 | 0.2619 | 0.7960 | 0.9680 | |
|
|
| ### Key Findings |
|
|
| - **Best Isotropy:** aligned_32d with 0.7898 (more uniform distribution) |
| - **Semantic Density:** Average pairwise similarity of 0.3209. Lower values indicate better semantic separation. |
| - **Alignment Quality:** Aligned models achieve up to 79.6% 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.909** | 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` | aprile, akiya, argumenta | |
| | `-s` | seifer, seninho, stobar | |
| | `-ma` | maremmae, maozim, manks | |
| | `-m` | mizrajíes, moguereños, morganáticas | |
| | `-c` | captivos, coevolucionarias, clips | |
| | `-p` | pk3, polistinae, polypetalæ | |
| | `-t` | tangamanga, tedros, tubariales | |
| | `-b` | bundesagentur, bitschnau, botrioides | |
| |
| #### Productive Suffixes |
| | Suffix | Examples | |
| |--------|----------| |
| | `-s` | lebbeus, tedros, captivos | |
| | `-a` | tangamanga, akiya, luvana | |
| | `-o` | kajanto, seninho, ducetio | |
| | `-e` | aprile, trimble, dumonde | |
| | `-n` | hazzan, ameln, bebieron | |
| | `-os` | tedros, captivos, moguereños | |
| | `-es` | tubariales, emboques, mizrajíes | |
| | `-as` | coevolucionarias, morganáticas, turillas | |
| |
| ### 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 | |
| |------|----------|------------------|----------| |
| | `iend` | 1.89x | 259 contexts | iendo, fiend, liendo | |
| | `ient` | 1.55x | 383 contexts | aient, iente, cient | |
| | `spañ` | 2.35x | 44 contexts | españ, spaña, españa | |
| | `ació` | 1.84x | 114 contexts | ación, vació, yació | |
| | `lmen` | 1.79x | 97 contexts | ülmen, olmen, ilmen | |
| | `aliz` | 1.40x | 288 contexts | aliza, valiz, alizé | |
| | `ombr` | 1.52x | 179 contexts | ombri, sombr, ombre | |
| | `resi` | 1.36x | 299 contexts | resis, resid, resit | |
| | `stru` | 1.34x | 259 contexts | strub, strul, struk | |
| | `ontr` | 1.45x | 156 contexts | contr, pontro, lontra | |
| | `renc` | 1.40x | 185 contexts | prenc, renck, frenc | |
| | `ntre` | 1.41x | 176 contexts | antre, intre, entre | |
| |
| ### 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 | |
| |--------|--------|-----------|----------| |
| | `-a` | `-s` | 162 words | arrianas, alumbrados | |
| | `-c` | `-s` | 149 words | certhiaxis, corpasinos | |
| | `-c` | `-a` | 139 words | contrarreforma, cusítica | |
| | `-p` | `-s` | 132 words | phitos, preformados | |
| | `-a` | `-a` | 118 words | azaña, artemisina | |
| | `-s` | `-s` | 116 words | subtropicalis, senderistas | |
| | `-p` | `-a` | 114 words | proteobacteria, prevalescencia | |
| | `-e` | `-s` | 111 words | estamos, escarpes | |
| | `-t` | `-s` | 94 words | tragaluces, thenailles | |
| | `-c` | `-o` | 88 words | cristofano, calpetano | |
| |
| ### 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 | |
| |------|-----------------|------------|------| |
| | desarrollarlas | **`desarrollar-la-s`** | 7.5 | `la` | |
| | peptoides | **`peptoi-d-es`** | 7.5 | `d` | |
| | şemsiruhsar | **`şemsiruh-s-ar`** | 7.5 | `s` | |
| | zakrisson | **`zakris-s-on`** | 7.5 | `s` | |
| | caesarobrigenses | **`caesarobrigen-s-es`** | 7.5 | `s` | |
| | kushiyara | **`kushiy-a-ra`** | 7.5 | `a` | |
| | ngwempisi | **`ngwempi-s-i`** | 7.5 | `s` | |
| | hēmitheos | **`hēmith-e-os`** | 7.5 | `e` | |
| | tsimliansk | **`tsimlian-s-k`** | 7.5 | `s` | |
| | inculcado | **`inculc-a-do`** | 7.5 | `a` | |
| | cbgranada | **`cbgran-a-da`** | 7.5 | `a` | |
| | trespasser | **`trespas-s-er`** | 7.5 | `s` | |
| | megasares | **`megas-ar-es`** | 7.5 | `ar` | |
| | programarlas | **`programar-la-s`** | 7.5 | `la` | |
| | galactano | **`galac-ta-no`** | 7.5 | `ta` | |
| |
| ### 6.6 Linguistic Interpretation |
| |
| > **Automated Insight:** |
| The language Spanish 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.83x) | |
| | N-gram | **2-gram** | Lowest perplexity (225) | |
| | Markov | **Context-4** | Highest predictability (88.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-04 06:09:07* |
|
|