KAUST Reveals How Llama and Gemma Secretly Rebuild Words From Characters
New interpretability research reveals how large language models silently rebuild word tokens from character streams inside their hidden states.
ProTakeaways
- A new interpretability paper identifies word recovery as the mechanism behind LLM tokenization robustness.
- Hidden states reconstruct canonical BPE tokens from character-level input with recovery scores up to 96.8.
- Removing the recovered token direction from the residual stream causes sharp task accuracy drops.
- In-group attention between characters of the same word, in early layers, drives the reconstruction.
- Gemma recovers words early, while Qwen and Llama use a two-stage recovery across layers.
- Tested on Gemma-2-9B, Qwen2.5-7B, Llama-3.2-3B across ARC, CommonsenseQA, and OpenbookQA.
If you feed a modern LLM a stream of individual characters instead of the subword tokens it was trained on, it will still, somewhat miraculously, answer your questions. A new mechanistic interpretability study from researchers at KAUST and collaborators pins down exactly why: the models are secretly rebuilding the tokens they expect before doing anything else. The authors call this process word recovery, and they show it is not a side effect but a load-bearing part of how transformers handle non-canonical input.
The tokenization paradox
Language models like Llama, Qwen, and Gemma are trained with a fixed subword tokenizer, usually a variant of Byte Pair Encoding. Conventional wisdom says that once you break that contract, for example by splitting every word into individual letters, performance should fall off a cliff. The paper notes that recent studies have shown that LLMs trained with canonical tokenization can still perform competitively when evaluated on non-canonical tokenizations, including character-level sequences and randomly segmented tokenizations that break learned token boundaries. Nobody had a mechanistic explanation for that resilience.
The central question the authors set out to answer is whether the model actually reasons over characters, or whether it quietly reconstructs the word-level units it was trained on and treats those as its real vocabulary.
Reading the hidden states
To test this, the team borrowed a well-known interpretability tool called the logit lens, which applies the model's own output embedding matrix to intermediate hidden states to see which vocabulary tokens they most resemble. For each character position and each transformer layer, they take the top-K predicted tokens and check whether the original canonical tokens from the sentence show up anywhere in that set. The fraction that appears is the layerwise word recovery score.
The signal is unmistakable. The maximum recovery scores range from 57.7 to 96.8 across models and datasets, indicating that a large portion of lexical information is internally reconstructed despite the absence of canonical tokenization. Even more interesting, different architectures recover words on different schedules:
- Gemma-2-9B-It recovers most word tokens in early layers, with recovery saturating quickly and remaining high throughout the network.
- Qwen2.5-7B-Instruct and Llama-3.2-3B-Instruct exhibit a two-stage recovery pattern: an initial phase in early layers where a subset of word tokens becomes recoverable, followed by a sharp increase in recovery in mid-to-late layers.
Proving it actually matters
Recoverability is not the same as necessity. To show word recovery is causally required, the authors run a targeted subspace ablation. For each canonical token t, they take its row from the output embedding matrix, treat that direction as the token's signature in representation space, and subtract its projection out of the residual stream at the character positions where t lives. Everything orthogonal to that direction is preserved.
The result is a tight coupling between recovery and task accuracy. When the intervention is applied starting from early layers where canonical word tokens first become recoverable, task performance drops substantially. This indicates that the recovered word-level representations are functionally necessary for downstream computation. As the intervention starting layer moves deeper into the network, task performance rapidly improves and eventually saturates, suggesting that once recovered word representations have been consumed for contextual understanding, removing them in later layers has little additional effect.
A striking finding falls out of this. In early layers, only a small fraction of canonical word tokens (approximately one quarter) are recovered; nevertheless, removing this early recovered subset leads to a large degradation in task performance. The tokens the model gets to first are doing most of the work.
The mechanism: in-group attention
How does the model actually stitch characters back into words? The authors hypothesize that attention between characters that belong to the same canonical token, which they call in-group attention, is the aggregation channel. To test this they add an attention mask that sets scores to negative infinity within each canonical token's character span, blocking those characters from attending to each other while leaving cross-word attention untouched.
The intervention is surgical enough to be revealing. Across all models and datasets, early-layer in-group attention masking leads to a consistent reduction in word recovery scores, indicating that in-group attention in early layers is critical for enabling the word recovery process. Blocking the same attention in later layers barely moves the needle, which is consistent with the picture that words are assembled up front and then consumed by the rest of the network.
Baseline accuracy under character input
The behavioral gap between canonical and character-level tokenization also shows how uneven this robustness really is across model families:
| Benchmark | Gemma-2-9B accuracy drop | Qwen2.5-7B accuracy drop | Llama-3.2-3B accuracy drop |
|---|---|---|---|
| ARC-Easy | -3.50 | -2.30 | -35.80 |
| ARC-Challenge | -4.00 | -4.00 | -33.80 |
| CommonsenseQA | -5.90 | -9.10 | -33.40 |
| OpenbookQA | -7.80 | -8.20 | -30.80 |
Gemma and Qwen shrug off character input; the smaller Llama takes a much larger hit, which lines up with its weaker recovery scores. The findings echo earlier behavioral work such as Broken Tokens, which showed that instruction-tuned models can handle non-canonical tokenization, but this paper is the first to explain the internal machinery behind that observation.
Why this is worth paying attention to
The practical implications are subtle but real. If word recovery is happening inside the residual stream, several downstream behaviors get easier to reason about:
- Robustness to typos, spacing errors, and adversarial character-level perturbations likely rides on the same early-layer aggregation circuits.
- Techniques that promise to skip the tokenizer entirely, including byte-level and character-level models, may still be paying a hidden cost as later layers reconstruct lexical units the input never provided.
- Interventions aimed at controlling model behavior, from safety steering to knowledge editing, need to be careful about which layer they touch. Early layers are where lexical identity gets built, and disturbing them has outsized effects.
The paper does not release code or model checkpoints, and its scope is deliberately narrow: three instruction-tuned models between 3B and 9B parameters, four question-answering benchmarks, and English input. The recovery decoding technique also assumes the output embedding is a reasonable proxy for lexical identity, which is a common but not uncontroversial choice in interpretability work. Even with those caveats, the causal evidence is clean enough to shift the default assumption. Transformers do not think in characters, even when you force them to read in characters. They quietly translate the input back into the vocabulary they know, and then do the real work from there.