Great question! Let me clarify how tokenization works in this case and how the vocabulary is structured.
How the Tokenizer Treats Subword Units
In the example:
- English: "running" →
["run", "##ning"]
- Spanish: "corriendo" →
["corri", "##endo"]
The tokenizer does not know that "##ning" and "##endo" are semantically related across languages. To the tokenizer and model, these are completely separate tokens in the vocabulary.
Vocabulary Size Explanation
For this specific example, the vocabulary would need to include all four tokens:
"run"
"##ning"
"corri"
"##endo"
So yes, in this minimal example, the vocabulary would need at least these 4 tokens to represent these words. However, in a real-world tokenizer:
- The actual vocabulary is much larger (e.g., 32K-128K tokens)
- These tokens would be among thousands of others
- The tokenizer doesn't know or care that "##ning" and "##endo" are related suffixes in different languages
How the Tokenizer Actually Works
The tokenizer is created through an algorithm like Byte Pair Encoding (BPE) or SentencePiece, which:
- Starts with individual characters
- Iteratively merges the most frequent pairs of tokens
- Builds up a vocabulary of common subword units
During this process:
- The algorithm doesn't know about language relationships
- It just looks at statistical frequency of token pairs across all training data
- Common suffixes like "##ning" in English and "##endo" in Spanish would emerge independently because they're frequent in their respective languages
Why This Works for Multilingual Models
Even though the model treats these as separate tokens, the multilingual capability comes from:
-
Shared Representations: During training, the model learns that:
- "run" + "##ning" often appears in contexts about motion/activity (English)
- "corri" + "##endo" often appears in similar contexts (Spanish)
- The model can learn that these different token sequences represent similar concepts
-
Cross-Language Patterns: The model sees many examples where similar concepts are expressed with different tokens in different languages, and learns to connect them through context
-
Positional Information: The model also uses positional information to understand how these tokens combine to form words
Real-World Vocabulary Example
In a real tokenizer with 32K tokens, you might find:
- Hundreds of English subword units
- Hundreds of Spanish subword units
- Plus units from all other supported languages
- Plus whole words for very common terms
- Plus special tokens for different languages/scripts
But there's no explicit connection between language-specific subword units - the model learns these relationships implicitly during training by seeing how these tokens are used in different contexts.
Key Insight
The power of multilingual models comes not from the tokenizer knowing that "##ning" and "##endo" are related, but from:
- The model seeing these tokens used in similar contexts across languages during training
- The model's ability to learn distributed representations where similar concepts in different languages end up with related internal representations
So while the tokenizer treats them as completely separate tokens, the model itself can learn that they represent similar concepts through exposure to multilingual data during training.