TheLantern 32K looked better. Until I trained it.
If I’d blindly followed the tokenizer advice from a quick Google search, I’d probably have picked the wrong vocabulary size for Qal, my Tigrinya language model.
The advice sounds reasonable. Larger vocabularies compress better, so you get fewer tokens per word, shorter sequences and more compact inputs.
On Tuesday I shared what happened when I tested it with three vocabulary sizes. A quick compression test seemed to confirm the advice:
- 32K: 1.45 tokens per word
- 16K: 1.60 tokens per word
- 8K: 1.80 tokens per word
On compression alone, 32K was the OBVIOUS pick.
Then I trained the same transformer setup with each one, tracking validation perplexity (PPL, how surprised the model is by text it hasn’t seen, so lower is better) and the train/validation gap (how much better it does on training text than on new text). Same dataset, same transformer, different tokenizers. The results moved in the opposite direction:
- 8K: val PPL 31.27, gap 0.18
- 16K: val PPL 41.96, gap 0.27
- 32K: val PPL 52.68, gap 0.38
8K, the one that LOST on compression, won on both.
To be fair, comparing perplexity across tokenizers is tricky, because each tokenizer changes the unit of prediction. So I treat it as one signal.
The other signal is cost, and that was my second post the same day. Take Qal’s largest architecture, with 8 layers, 12 attention heads, a 768 hidden size and a 128-token context. Without the input embedding and output projection, the transformer stack is about 56.6M parameters. Without weight tying (sharing one table between the input and the output), here’s what the vocabulary adds, with its share of the whole model:
- 8K: +12.6M → ~69.2M (~18%)
- 16K: +25.2M → ~81.8M (~31%)
- 32K: +50.3M → ~106.9M (~47%)
That’s nearly HALF the model, just for the vocabulary.
And cost wasn’t the only problem. A larger vocabulary compressed Tigrinya better, but it also spread the same ~70M-token dataset across more token IDs. Some tokens appeared often, and many appeared rarely. 8K kept the vocabulary denser and gave the model more repeated exposure to common Tigrinya subword patterns. That’s why Qal uses 8K.
The common advice still holds where it comes from, with much larger datasets and billion-parameter models that can support larger vocabularies. Qal works under different constraints.
All of this ran on a tokenizer I understood from the inside. The week started with lessons from building BPE from scratch, before I moved to Hugging Face Tokenizers, and three failure modes came out of that:
- Merge order
BPE learns an ordered sequence of merge rules, and my first version stored them too casually. - Whitespace
My first tokenizer decoded “low resource language” as “lowresourcelanguage” (one very long word, haha). - Round trips
Encode, decode, compare. Otherwise you never see what got lost.
Building it myself turned the tokenizer from a black box into a system I could debug, and Part 3 of Building Qal, my blog series on Substack, has the code for both versions.
So 32K looked better, right up until I trained it.
A good tokenizer for a low-resource language has to fit more than the language. It also has to fit the dataset, the model size, the training budget and the task.
Talk soon,
Fanus
P.S. Be honest. Looking only at compression, would you have picked 32K too? (I nearly did.) Reply by email with 8K, 16K or 32K. No judgement.
this week's sources
- LinkedInBuilding BPE from scratch taught me 3 tokenizer failure modes ↗
- LinkedInFor a small language model like Qal, vocabulary size is unbelievably expensive ↗
- LinkedInIf I had blindly followed tokenizer advice, I'd have picked the wrong vocabulary size ↗
- Blog[3/7] Building Qal: From Characters to Tokens ↗
$ Get the next one in your inbox
The Lantern goes out once a week, along with each new part of Building Qal. Unsubscribe anytime.