Comprehensive Research Report & Full Ablation Study
This repository contains NLP models trained and evaluated by Wikilangs, specifically on Waray 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)
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
6,771
12.73
587,286
39.6%
56.6%
2-gram
Subword
247 🏆
7.95
5,747
68.3%
99.7%
3-gram
Word
17,032
14.06
1,208,224
31.7%
47.8%
3-gram
Subword
1,598
10.64
47,440
34.4%
76.9%
4-gram
Word
50,245
15.62
3,168,479
23.5%
38.5%
4-gram
Subword
5,867
12.52
301,900
26.2%
55.3%
5-gram
Word
68,533
16.06
2,392,175
19.2%
34.2%
5-gram
Subword
14,203
13.79
1,156,846
23.4%
47.8%
Top 5 N-grams by Size
2-grams (Word):
Rank
N-gram
Count
1
nahilalakip ha
1,196,502
2
in nahilalakip
1,196,444
3
in uska
1,161,092
4
mga kasarigan
1,140,811
5
familia nga
1,136,619
3-grams (Word):
Rank
N-gram
Count
1
in nahilalakip ha
1,196,442
2
ha genus nga
1,059,395
3
nahilalakip ha genus
1,059,391
4
uska species han
1,059,159
5
in uska species
1,059,158
4-grams (Word):
Rank
N-gram
Count
1
nahilalakip ha genus nga
1,059,391
2
in nahilalakip ha genus
1,059,349
3
in uska species han
1,059,153
4
hini subspecies nga nakalista
1,022,924
5
waray hini subspecies nga
1,022,924
5-grams (Word):
Rank
N-gram
Count
1
in nahilalakip ha genus nga
1,059,349
2
waray hini subspecies nga nakalista
1,022,924
3
hini subspecies nga nakalista mga
1,022,834
4
subspecies nga nakalista mga kasarigan
1,022,831
5
in uska species han magnoliopsida
202,211
2-grams (Subword):
Rank
N-gram
Count
1
a _
15,944,152
2
n _
13,013,735
3
a n
11,288,391
4
_ n
11,062,347
5
g a
9,641,404
3-grams (Subword):
Rank
N-gram
Count
1
a n _
7,717,416
2
n g a
6,387,666
3
_ n g
6,209,737
4
g a _
6,146,693
5
_ h a
4,483,798
4-grams (Subword):
Rank
N-gram
Count
1
_ n g a
6,206,771
2
n g a _
4,713,126
3
g a n _
2,648,745
4
_ i n _
2,593,266
5
s p e c
2,524,428
5-grams (Subword):
Rank
N-gram
Count
1
_ n g a _
4,702,772
2
s p e c i
2,510,965
3
p e c i e
2,471,786
4
e c i e s
2,467,835
5
c i e s _
2,396,660
Key Findings
Best Perplexity: 2-gram (subword) with 247
Entropy Trend: Decreases with larger n-grams (more predictable)
Coverage: Top-1000 patterns cover ~48% 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.9524
1.935
6.58
763,014
4.8%
1
Subword
0.8828
1.844
5.77
3,095
11.7%
2
Word
0.3392
1.265
1.87
4,989,422
66.1%
2
Subword
0.6967
1.621
4.99
17,724
30.3%
3
Word
0.2062
1.154
1.43
9,222,656
79.4%
3
Subword
0.7365
1.666
4.85
88,254
26.3%
4
Word
0.1336 🏆
1.097
1.25
13,040,247
86.6%
4
Subword
0.7108
1.637
3.87
427,478
28.9%
Generated Text Samples (Word-based)
Below are text samples generated from each word-based Markov chain model:
Context Size 1:
nga nakalista mga sumpay ha familia nga ginhulagway ni léon dufour hadton an notocelis ngan familia
in nahilalakip ha genus nga nakalista mga kasarigan website zoonomen zoological nomenclature and ter...
an leptomastix tanasijtshuki in uska species han bryozoa world checklist of the global lepidoptera n...
Context Size 2:
nahilalakip ha genus nga tonnoiriella ngan familia nga terebellidae waray hini subspecies nga nakali...
in nahilalakip ha genus nga clitoria ngan familia nga rubiaceae waray hini subspecies nga nakalista ...
in uska species han diptera nga ginhulagway ni henri ernest baillon ngan ginhatag han pagkayana nga ...
Context Size 3:
in nahilalakip ha genus nga buxus ngan familia nga cheliferidae waray hini subspecies nga nakalista ...
ha genus nga exorista ngan familia nga tetranychidae waray hini subspecies nga nakalista mga kasarig...
nahilalakip ha genus nga miostauropus ngan familia nga rutelidae waray hini subspecies nga nakalista...
Context Size 4:
nahilalakip ha genus nga euprosopia ngan familia nga platystomatidae mabibilngan ini ha sri lanka wa...
in nahilalakip ha genus nga haploops ngan familia nga ampeliscidae waray hini subspecies nga nakalis...
in uska species han liliopsida nga ginhulagway ni john hutchinson ngan john mcewan dalziel an bertie...
Generated Text Samples (Subword-based)
Below are text samples generated from each subword-based Markov chain model:
Context Size 1:
_doni_n_his_wano
abs_ithonce_ndul
ngspysogakid_and
Context Size 2:
a_ini_wcspectic_t
n_in_390._ara).,_
anterk_nganthopte
Context Size 3:
an_pindros_the_e._
nga_cera_nga_syste
_nga_sipalmeestrit
Context Size 4:
_nga_syahan_diaphen
nga_ginhulagway_ni_
gan_familia_nga_nak
Key Findings
Best Predictability: Context-4 (word) with 86.6% predictability
Branching Factor: Decreases with context size (more deterministic)
Memory Trade-off: Larger contexts require more storage (427,478 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
548,741
Total Tokens
79,294,042
Mean Frequency
144.50
Median Frequency
4
Frequency Std Dev
11269.34
Most Common Words
Rank
Word
Frequency
1
nga
4,703,546
2
in
2,921,835
3
an
2,589,624
4
ha
1,893,436
5
han
1,625,103
6
ngan
1,415,641
7
mga
1,401,419
8
species
1,374,922
9
of
1,347,178
10
nahilalakip
1,196,509
Least Common Words (from vocabulary)
Rank
Word
Frequency
1
sermersooq
2
2
kulusuk
2
3
sporcle
2
4
loocnon
2
5
estadyum
2
6
katalyst
2
7
haluk
2
8
bilginer
2
9
squibb
2
10
paca
2
Zipf's Law Analysis
Metric
Value
Zipf Coefficient
1.1284
R² (Goodness of Fit)
0.998865
Adherence Quality
excellent
Coverage Analysis
Top N Words
Coverage
Top 100
58.7%
Top 1,000
76.4%
Top 5,000
85.5%
Top 10,000
89.1%
Key Findings
Zipf Compliance: R²=0.9989 indicates excellent adherence to Zipf's law
High Frequency Dominance: Top 100 words cover 58.7% of corpus
Long Tail: 538,741 words needed for remaining 10.9% 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.8470
0.3349
N/A
N/A
mono_64d
64
0.8029
0.3103
N/A
N/A
mono_128d
128
0.7779
0.2306
N/A
N/A
aligned_32d
32
0.8470 🏆
0.3453
0.0380
0.2940
aligned_64d
64
0.8029
0.3113
0.1440
0.4780
aligned_128d
128
0.7779
0.2362
0.2780
0.6400
Key Findings
Best Isotropy: aligned_32d with 0.8470 (more uniform distribution)
Semantic Density: Average pairwise similarity of 0.2947. Lower values indicate better semantic separation.
Alignment Quality: Aligned models achieve up to 27.8% 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.284
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
ameziane, alucao, astroma
-ma
majerorum, maracasi, marsa
-s
sustansiya, szijji, subtriflora
-pa
parle, pasiphimus, paradontophora
-ca
callites, callochiton, cabanisii
-p
parle, psdamyc, polystylata
-ba
basilewskyanus, bathyprion, balangigan
-b
biselinifera, basilewskyanus, bicolora
Productive Suffixes
Suffix
Examples
-s
basilewskyanus, bomareoides, pasiphimus
-a
sustansiya, wolynia, biselinifera
-us
basilewskyanus, pasiphimus, hesperotychus
-is
niasensis, moniliventris, admotalis
-e
ocellate, ameziane, parle
-um
majerorum, curvinervium, tapinelytrum
-i
kuehhasii, minjujuŭi, maracasi
-es
bomareoides, callites, pedes
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
kasa
2.52x
45 contexts
akasa, kasaï, kasal
ilal
2.61x
36 contexts
silal, bilal, kilal
asar
2.10x
62 contexts
casar, asara, pasar
opte
1.62x
202 contexts
opter, scoptes, eoptera
ulag
2.87x
14 contexts
bulag, dulag, nabulag
ahil
2.32x
27 contexts
dahil, tahil, kahili
akal
2.15x
34 contexts
zakal, yakal, bakal
akip
3.06x
11 contexts
lakip, nakipa, kalakip
agwa
2.64x
16 contexts
dagway, magway, nagwara
fami
2.07x
24 contexts
famiy, famil, famiie
peci
1.77x
36 contexts
specis, specia, pecina
subs
2.90x
8 contexts
subst, subsp, subsaga
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
303 words
antoninus, albocingulatus
-p
-s
258 words
plethobasus, platypygus
-a
-a
251 words
artopenna, anahita
-p
-a
250 words
pindica, paradoxophyla
-s
-a
225 words
spodopa, synpsylla
-s
-s
220 words
simaethis, spartiformis
-m
-s
147 words
machetis, mesozonalis
-a
-us
135 words
antoninus, albocingulatus
-b
-s
111 words
beombawigulensis, boridiensis
-m
-a
109 words
missiona, mauritacantha
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
yungchangense
yungchangen-s-e
7.5
s
betinensis
betinen-s-is
7.5
s
hundungensis
hundungen-s-is
7.5
s
yoneyamai
yoneyam-a-i
7.5
a
austrocolumbiana
austrocolumbi-a-na
7.5
a
glycereen
glycer-e-en
7.5
e
agesilaus
agesi-la-us
7.5
la
discoelongata
discoelong-a-ta
7.5
a
desordenata
desorden-a-ta
7.5
a
sexpectinata
sexpectin-a-ta
7.5
a
pluvigena
pluvig-e-na
7.5
e
chondrichthyans
chondrichthy-a-ns
7.5
a
ecorticata
ecortic-a-ta
7.5
a
binuangan
binuang-a-n
7.5
a
dallasiana
dallasi-a-na
7.5
a
6.6 Linguistic Interpretation
Automated Insight:
The language Waray 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 (3.93x)
N-gram
2-gram
Lowest perplexity (247)
Markov
Context-4
Highest predictability (86.6%)
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
Compare within model families: Metrics are most meaningful when comparing models of the same type (e.g., 8k vs 64k tokenizer).
Consider trade-offs: Better performance on one metric often comes at the cost of another (e.g., compression vs. OOV rate).
Context matters: Optimal values depend on downstream tasks. Text generation may prioritize different metrics than classification.
Corpus influence: All metrics are influenced by corpus characteristics. Wikipedia text differs from social media or literature.
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 - a monthly snapshot of Wikipedia articles across 300+ languages.
Project
A project by Wikilangs - Open-source NLP models for every Wikipedia language.