Modern Large Language Models (LLMs) increasingly rely on byte-fallback tokenization to process rare or out-of-vocabulary (OOV) characters. Instead of failing on an unknown symbol, the tokenizer decomposes it into its underlying UTF-8 bytes. While this guarantees the model can read any Unicode input, writing (generating) valid UTF-8 is a distinct and complex challenge.
UTF-8 is a strict encoding standard requiring specific bit patterns across 1 to 4 bytes. If a model predicts a byte that violates these rules—such as starting a 4-byte sequence but failing to provide the correct continuation bytes—the resulting text is structurally broken and cannot be decoded. This paper investigates when and how models actually learn the structural rules of UTF-8, revealing that standard perplexity metrics are insufficient for tracking this fundamental capability.
Methodology and Evaluation Framework
The researchers trained a 355M-parameter GPT-2 style model from scratch on 80 billion tokens. The training data comprised a balanced multilingual corpus derived from FineWeb (English) and FineWeb2 (Japanese, Korean, and Simplified Chinese), utilizing Weighted Dynamic Sampling to maintain natural document boundaries.
To evaluate UTF-8 competence, the authors introduced the ByteCanary dataset, stratifying OOV characters into Common, Uncommon, Rare, and Unseen tiers. The "Unseen" tier specifically targeted 4-byte CJK Extension B ideographs to test zero-shot generalization. They also designed a novel evaluation framework:
- Level 0 (Context-Free): Tests if the model has internalized UTF-8 syntax by prompting it to complete a partial byte prefix of a rare character without semantic clues.
- Level 1 (Context-Guided): Tests the mapping between semantics and bytes by requiring the model to complete a character's byte sequence within a natural sentence.
- Rigorous Metrics: A Deterministic Finite Automaton (DFA) was used to check validity. The authors introduced $V_{partial}$ (giving partial credit for valid but incomplete sequences) and Term Match (checking if the model generated the semantically correct character, not just a valid one).
Key Findings
The "Validity Lag"
The most striking finding is that UTF-8 validity convergence lags behind perplexity by roughly a factor of two. While the model's perplexity stabilized at 2.1 billion tokens, it required 4.2 billion tokens to reach stable UTF-8 validity. This demonstrates that low perplexity does not guarantee structurally valid output.
Byte-Length Dictates Difficulty
The number of bytes in a character is a more significant axis of difficulty than character frequency. Models struggle considerably more with 4-byte sequences than 3-byte sequences, often collapsing to a single 4-byte template they memorized during training. Interestingly, in context-free generation, rare characters achieved higher structural validity than common characters, suggesting an over-specialization of frequent character representations.
Structure vs. Semantics
Generating a structurally valid byte sequence is much easier than generating the correct one. Even after extensive training, the model's Term Match Rate (semantic correctness) plateaued at approximately 60%, significantly lower than its structural validity.
Zero-Shot Generalization
Despite the challenges, the model achieved 86.97% partial-credit validity on characters it had never seen during training. This suggests the model successfully induced abstract rules of UTF-8 rather than merely memorizing seen sequences.
Cross-Model Implications
The study's insights extend beyond the custom 355M model. Evaluations of 10 open-weight models (including Llama 3.2 and Qwen 3.5) revealed a massive gap—sometimes up to 65 percentage points—between partial validity ($V_{partial}$) and strict validity.
Furthermore, tokenizer design often proved more impactful than raw model size. Smaller models with smaller vocabularies are forced to "practice" byte-fallback more frequently during training. As a result, they often outperformed massive models with large vocabularies at retrieving the correct bytes for rare characters.
Limitations and Future Directions
While the study provides critical insights, the training dynamics were analyzed on a 355M parameter model. Full checkpoint sweeps on 7B+ parameter models are needed to confirm if the "2x validity lag" holds at scale. Additionally, the research focused on CJK and English scripts; other multi-byte scripts like Arabic or Devanagari may exhibit different learning curves.
Ultimately, reliable UTF-8 generation is a distinct capability requiring evaluation beyond standard perplexity. The authors suggest that future architectural interventions, such as explicit byte-position encodings, might be necessary to accelerate the learning of low-level encoding rules in LLMs.
Summary updated