hu / RESEARCH_REPORT.md
omarkamali's picture
Upload all models and assets for hu (latest)
c922b43 verified

Hungarian — Full Ablation Study & Research Report

Detailed evaluation of all model variants trained on Hungarian Wikipedia data by Wikilangs.

👈 Back to README

📋 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

Analysis and Evaluation


1. Tokenizer Evaluation

Tokenizer Compression

Tokenizer Fertility

Tokenizer OOV

Total Tokens

Results

Vocab Size Compression Avg Token Len UNK Rate Total Tokens
8k 3.505x 3.51 0.1725% 3,328,421
16k 3.921x 3.92 0.1930% 2,974,904
32k 4.311x 4.31 0.2122% 2,705,982
64k 4.661x 🏆 4.66 0.2295% 2,502,482

Tokenization Examples

Below are sample sentences tokenized with each vocabulary size:

Sample 1: Elvonás, addiktológia Elvonás, a szóalkotás egy módja

Vocab Tokens Count
8k ▁elv on ás , ▁ad d ikt ológia ▁elv on ... (+9 more) 19
16k ▁elv on ás , ▁add ikt ológia ▁elv on ás ... (+8 more) 18
32k ▁elvon ás , ▁add ikt ológia ▁elvon ás , ▁a ... (+5 more) 15
64k ▁elvon ás , ▁add ikt ológia ▁elvon ás , ▁a ... (+4 more) 14

Sample 2: Memória (biológia) Memória (számítástechnika): Számítástechnikában használják Me...

Vocab Tokens Count
8k ▁mem ória ▁( bi ológia ) ▁mem ória ▁( szám ... (+23 more) 33
16k ▁mem ória ▁( bi ológia ) ▁mem ória ▁( számítás ... (+19 more) 29
32k ▁memória ▁( bi ológia ) ▁memória ▁( számítás technika ): ... (+12 more) 22
64k ▁memória ▁( biológia ) ▁memória ▁( számítás technika ): ▁számítástechn ... (+10 more) 20

Sample 3: Óe, japán családnév Óe, kisváros Japánban, Jamagata prefektúrában ÓE, az Óbudai ...

Vocab Tokens Count
8k ▁ó e , ▁japán ▁család név ▁ó e , ▁kis ... (+21 more) 31
16k ▁ó e , ▁japán ▁családnév ▁ó e , ▁kisváros ▁japánban ... (+16 more) 26
32k ▁ó e , ▁japán ▁családnév ▁ó e , ▁kisváros ▁japánban ... (+13 more) 23
64k ▁ó e , ▁japán ▁családnév ▁ó e , ▁kisváros ▁japánban ... (+11 more) 21

Key Findings

  • Best Compression: 64k achieves 4.661x compression
  • Lowest UNK Rate: 8k with 0.1725% 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

N-gram Unique

N-gram Coverage

Results

N-gram Variant Perplexity Entropy Unique N-grams Top-100 Coverage Top-1000 Coverage
2-gram Word 362,917 18.47 2,207,301 5.4% 14.2%
2-gram Subword 429 🏆 8.74 22,141 54.6% 98.3%
3-gram Word 1,261,909 20.27 3,510,384 2.1% 6.2%
3-gram Subword 4,501 12.14 188,349 17.4% 56.2%
4-gram Word 2,487,801 21.25 5,404,855 2.0% 5.1%
4-gram Subword 29,749 14.86 1,214,042 7.6% 26.9%
5-gram Word 1,806,602 20.78 3,707,959 2.3% 5.8%
5-gram Subword 135,455 17.05 4,635,566 3.7% 15.6%

Top 5 N-grams by Size

2-grams (Word):

Rank N-gram Count
1 és a 381,304
2 hogy a 127,431
3 és az 111,129
4 a magyar 107,955
5 volt a 102,268

3-grams (Word):

Rank N-gram Count
1 személyek elhunyt személyek 25,908
2 született személyek elhunyt 25,567
3 madarai madarai madarai 21,522
4 jegyzetek további információk 19,348
5 kisbolygók listája jegyzetek 13,405

4-grams (Word):

Rank N-gram Count
1 született személyek elhunyt személyek 25,567
2 madarai madarai madarai madarai 17,618
3 listája jegyzetek naprendszer kisbolygói 13,129
4 kisbolygók listája jegyzetek naprendszer 13,128
5 kapcsolódó szócikkek kisbolygók listája 13,112

5-grams (Word):

Rank N-gram Count
1 madarai madarai madarai madarai madarai 14,553
2 kisbolygók listája jegyzetek naprendszer kisbolygói 13,128
3 kapcsolódó szócikkek kisbolygók listája jegyzetek 13,034
4 szócikkek kisbolygók listája jegyzetek naprendszer 12,763
5 a naprendszer kisbolygóövében található aszteroida 12,084

2-grams (Subword):

Rank N-gram Count
1 _ a 14,447,157
2 a _ 13,088,817
3 s z 10,335,605
4 t _ 8,923,690
5 e l 8,560,877

3-grams (Subword):

Rank N-gram Count
1 _ a _ 7,569,874
2 _ s z 3,684,895
3 _ a z 2,740,812
4 é s _ 2,565,914
5 s z e 2,500,891

4-grams (Subword):

Rank N-gram Count
1 _ a z _ 2,372,557
2 _ é s _ 2,184,467
3 _ e g y 1,442,169
4 _ m e g 1,293,813
5 . _ a _ 1,289,446

5-grams (Subword):

Rank N-gram Count
1 _ a z _ e 641,291
2 _ s z e r 617,289
3 _ é s _ a 566,317
4 _ e g y _ 545,352
5 _ v o l t 535,186

Key Findings

  • Best Perplexity: 2-gram (subword) with 429
  • Entropy Trend: Decreases with larger n-grams (more predictable)
  • Coverage: Top-1000 patterns cover ~16% of corpus
  • Recommendation: 4-gram or 5-gram for best predictive performance

3. Markov Chain Evaluation

Markov Entropy

Markov Contexts

Markov Branching

Results

Context Variant Avg Entropy Perplexity Branching Factor Unique Contexts Predictability
1 Word 0.9424 1.922 10.97 3,256,935 5.8%
1 Subword 1.1652 2.243 8.26 11,176 0.0%
2 Word 0.3123 1.242 2.03 35,712,539 68.8%
2 Subword 0.6772 1.599 4.69 92,249 32.3%
3 Word 0.1163 1.084 1.24 72,420,142 88.4%
3 Subword 0.7664 1.701 4.71 432,153 23.4%
4 Word 0.0401 🏆 1.028 1.06 89,534,275 96.0%
4 Subword 0.7484 1.680 3.95 2,032,871 25.2%

Generated Text Samples (Word-based)

Below are text samples generated from each word-based Markov chain model:

Context Size 1:

  1. a filozófiában jeleskedők élete vácon igazgatótanár aszalón bőcsön borsod abaúj zemplén vármegye hon...
  2. az elfelejtett kísérlet singer berta fia némó elbűvölő szörnyeteg régebben megszűnt a európa bajnoki...
  3. és dániai roskilde dánia szoroson át kellett találni a királyi engedélyt egy bizonyos ágakra elosztó...

Context Size 2:

  1. és a helybeli hazafiak köztük władysław gomułka lett akkor több fellépést is a neve és a razorblade
  2. hogy a gerjesztést követően 0 0 0 0 0 0 0 fe7 lépéssorozatból áll a leendő űrkísérletekhez
  3. és az egy évvel korábban halt meg csak hallomásból ismerik a kantonmozdony mivel az ember annak érde...

Context Size 3:

  1. született személyek elhunyt személyek drámaírók novogyevicsi temetőben eltemetett személyek erdélyi ...
  2. madarai madarai madarai északi mariana szigetek madarai madarai madarai madarai amerikai egyesült ál...
  3. jegyzetek további információk labdarúgók river plate labdarúgói cruz azul labdarúgói atlas labdarúgó...

Context Size 4:

  1. madarai madarai madarai madarai madarai madarai tomé és príncipe madarai madarai madarai seychelle s...
  2. született személyek elhunyt személyek úszók olimpiai ezüstérmesek nők
  3. kisbolygók listája jegyzetek naprendszer kisbolygói vec lista de aënna

Generated Text Samples (Subword-based)

Below are text samples generated from each subword-based Markov chain model:

Context Size 1:

  1. _tén.krermi_k_ho
  2. emi_ra_vaiszegyő
  3. ajat_(gola,_jena

Context Size 2:

  1. _a_törül_ingmukiv
  2. a_katt,_fő_sztünc
  3. szvetibelyek_mika

Context Size 3:

  1. _a_„tusábang_napil
  2. _szócikkel_a_bolyg
  3. _az_a4_március_211

Context Size 4:

  1. _az_eszit_lasszultá
  2. _és_galéria_szereti
  3. _egyik_mária_foglal

Key Findings

  • Best Predictability: Context-4 (word) with 96.0% predictability
  • Branching Factor: Decreases with context size (more deterministic)
  • Memory Trade-off: Larger contexts require more storage (2,032,871 contexts)
  • Recommendation: Context-3 or Context-4 for text generation

4. Vocabulary Analysis

Zipf's Law

Top Words

Coverage Curve

Statistics

Metric Value
Vocabulary Size 1,458,224
Total Tokens 103,537,627
Mean Frequency 71.00
Median Frequency 4
Frequency Std Dev 7231.61

Most Common Words

Rank Word Frequency
1 a 7,834,400
2 az 2,443,698
3 és 2,194,407
4 is 733,028
5 egy 579,913
6 hogy 494,341
7 volt 474,789
8 nem 446,048
9 1 405,757
10 magyar 343,055

Least Common Words (from vocabulary)

Rank Word Frequency
1 léggömbzár 2
2 elterelővel 2
3 hajófelderítő 2
4 szűrőrendszerrel 2
5 801ml 2
6 801tp 2
7 sorosmotort 2
8 stammkennzeichen 2
9 schindleréről 2
10 kapraraszműlesiklásnem 2

Zipf's Law Analysis

Metric Value
Zipf Coefficient 0.9296
R² (Goodness of Fit) 0.996343
Adherence Quality excellent

Coverage Analysis

Top N Words Coverage
Top 100 25.8%
Top 1,000 45.6%
Top 5,000 61.9%
Top 10,000 69.2%

Key Findings

  • Zipf Compliance: R²=0.9963 indicates excellent adherence to Zipf's law
  • High Frequency Dominance: Top 100 words cover 25.8% of corpus
  • Long Tail: 1,448,224 words needed for remaining 30.8% coverage

5. Word Embeddings Evaluation

Embedding Isotropy

Similarity Matrix

t-SNE Words

t-SNE Sentences

5.1 Cross-Lingual Alignment

Alignment Quality

Multilingual t-SNE

5.2 Model Comparison

Model Dimension Isotropy Semantic Density Alignment R@1 Alignment R@10
mono_32d 32 0.7886 0.3560 N/A N/A
mono_64d 64 0.7831 0.2846 N/A N/A
mono_128d 128 0.7114 0.2337 N/A N/A
aligned_32d 32 0.7886 🏆 0.3516 0.3600 0.7520
aligned_64d 64 0.7831 0.2765 0.5320 0.8560
aligned_128d 128 0.7114 0.2243 0.6300 0.9180

Key Findings

  • Best Isotropy: aligned_32d with 0.7886 (more uniform distribution)
  • Semantic Density: Average pairwise similarity of 0.2878. Lower values indicate better semantic separation.
  • Alignment Quality: Aligned models achieve up to 63.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.625 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
-s schmör, szabadítására, szertárai
-k kelvinator, kürtszavára, keselyűféléket
-a arkopharma, adequate, akszukhosz
-m megyéjébe, mongu, mozilátogatók
-t tlp, terheltségének, tanulhatóak
-b balszárnyának, bhov, beszédfejlődési
-ma mainstoneky, margati, mayrnak
-e elektronszerkezetével, egységnyiek, esztyemirova

Productive Suffixes

Suffix Examples
-k mozilátogatók, balszárnyának, kóruspadok
-t használókat, felvevőpiacot, keselyűféléket
-n végezetlen, érinthetetlen, állatkertjeiben
-a arkopharma, kürtszavára, vaskarika
-l elektronszerkezetével, versenyeitől, pálinkafőzéssel
-s rombouts, ikszes, gibbins
-i lxviii, desai, vibrálni
-e megyéjébe, jugoslovenske, adequate

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
váro 2.03x 219 contexts város, váron, várod
embe 1.60x 288 contexts ember, embed, bembe
llen 1.53x 361 contexts llena, illen, lleno
atás 1.48x 365 contexts patás, hatás, avatás
llet 1.60x 226 contexts allet, ellet, illet
ítás 1.43x 316 contexts újítás, ásítás, ámítás
ítot 1.65x 136 contexts ított, vított, osított
erül 1.43x 288 contexts kerül, terül, derül
mber 1.33x 400 contexts ember, imber, amber
ület 1.38x 311 contexts fület, szület, őrület
rtén 2.09x 42 contexts örtény, értény, kurtén
örté 1.85x 64 contexts törté, örtény, körték

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
-k -t 115 words közéletét, kansast
-k -k 112 words kreatívnak, kiújulnak
-s -l 101 words szúfizmussal, szinkronstábbal
-s -k 99 words sírkamrájuk, szülővárosnak
-s -t 95 words szakmáikat, shiflett
-m -k 86 words mellékérték, maffiacsoportok
-k -l 83 words középjel, krízisekkel
-s -n 81 words szövegírásban, spalatóban
-k -n 76 words kihalásában, konstruktiven
-k -a 72 words korongcsiga, kaparinthatja

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
vercruysse vercruys-s-e 7.5 s
szocialta szoci-al-ta 7.5 al
stílusbanaz stílusban-a-z 7.5 a
részvényeiket részvényei-k-et 7.5 k
hátoldalra hátold-al-ra 7.5 al
fullernek fuller-n-ek 7.5 n
nézhetőnek nézhető-n-ek 7.5 n
napjainkbeli napjainkb-el-i 7.5 el
gyarmataikra gyarmatai-k-ra 7.5 k
mandülion mandül-i-on 7.5 i
robotterheit robotterhe-i-t 7.5 i
albuginea albugin-e-a 7.5 e
elnagyoltak elnagyol-t-ak 7.5 t
minőségileg minőségil-e-g 7.5 e
szárnyacskák szárnyacs-k-ák 7.5 k

6.6 Linguistic Interpretation

Automated Insight: The language Hungarian 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

Production Recommendations

Component Recommended Rationale
Tokenizer 64k BPE Best compression (4.66x)
N-gram 2-gram Lowest perplexity (429)
Markov Context-4 Highest predictability (96.0%)
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

Generated by Wikilangs Pipeline · 2026-03-04 21:45:03