From Tokens to Words: On the Inner Lexicon of LLMs

Guy Kaplan, Matanel Oren, Yuval Reif, Roy Schwartz

Large Language Models (LLMs) don't see the world in words. Instead, they process "tokens"—arbitrary chunks of characters like un-, h-, and -appiness. While this helps models handle any text, it creates a gap between how humans think and how machines compute. A recent paper from researchers at The Hebrew University of Jerusalem, titled "From Tokens to Words: On the Inner Lexicon of LLMs," reveals that models bridge this gap by internally "stitching" tokens back into whole words in their middle layers.

The Problem: Statistical Tetris or True Understanding?

Most modern LLMs use Byte-Pair Encoding (BPE) to break text into tokens. While efficient, BPE often mangles the linguistic structure of words. For example, the word "cats" might be split into "ca" and "ts." This raises a fundamental question: Does the model actually "know" it’s looking at the word cats, or is it just playing a sophisticated game of statistical Tetris with character fragments?

The authors investigate whether LLMs maintain an internal "mental lexicon" similar to humans—a latent space where fragmented tokens are reconstructed into meaningful word-level concepts.

Uncovering the Inner Lexicon

To peek under the hood of models like Llama-2, Llama-3, and Mistral, the researchers employed several interpretability techniques:

  1. Probing: They trained a simple k-Nearest Neighbors classifier on the model's hidden states to see if it could distinguish between real English words (e.g., "unhappiness") and "gibberish" non-words created by shuffling tokens.
  2. Logit Lens & Patchscopes: They projected internal hidden states back into the model's vocabulary space. If the hidden state of the token "ts" (from "cats") projected strongly to the embedding for the full word "cats," it proved the model had reconstructed the concept.
  3. FFN Ablation: They identified specific Feedforward Network (FFN) layers that seemed to "retrieve" word meanings and zeroed them out to see if the model's ability to understand the word collapsed.
  4. Vocabulary Expansion (Tokens2Words): They used Procrustes transformations to map the model's internal "fused" word vectors into new, single-token embeddings, allowing the model to treat a multi-token word as a single token in the future.

These tests were run across diverse datasets, including the Gutenberg Corpus, WikiText-103, PubMed, and Wiki40B-Arabic, ensuring the findings weren't just a fluke of standard English.

Key Insights: How Models Reconstruct Words

The study uncovered a fascinating mechanical process within the transformer architecture that handles this "detokenization."

  • The "Last Token" Phenomenon: Detokenization doesn't happen everywhere at once. The model uses the last token of a word sequence as a "mailbox." Attention mechanisms aggregate information from all previous sub-tokens into this final position to form the complete word concept.
  • FFNs are the Dictionary: Feedforward layers act as key-value memories. When the model processes the aggregated tokens, the FFNs "retrieve" the full word representation and write it into the residual stream.
Diagram showing attention aggregating tokens to the last token, and FFN retrieving the word concept
  • The Middle-Layer Sweet Spot: Models don't recognize words immediately. In Llama-2-7B, word recognition peaks around layer 13. Early layers focus on aggregating raw tokens, while late layers shift toward predicting the next word.
  • Robustness to Noise: LLMs are surprisingly good at detokenizing even when words have typos or are split in weird, non-standard ways. This suggests their "inner lexicon" is much broader than the fixed BPE vocabulary they were trained on.

Results and Practical Applications

The existence of this inner lexicon is strongly supported by the probing results. A simple classifier achieved 89% accuracy in telling real words apart from gibberish based solely on internal representations at the last token.

Nonword creation process and layer-wise classification accuracy showing a peak in middle layers

Beyond proving that models understand words, this discovery has immediate practical benefits:

  • Successful "Patching": For 64% of multi-token words, the model could "understand" a single internal vector as the full word, even if it had never seen that word represented as a single token during training.
  • Zero-Shot Expansion & Efficiency: By adding these "fused" vectors to the model's vocabulary, the researchers reduced the number of tokens processed by 10.5% to 14.5%. Because this vocabulary expansion requires no finetuning of the model's core weights, it serves as a "plug-and-play" solution for reducing latency and memory usage.

Limitations and Future Work

While the results are promising, the "inner lexicon" isn't perfect. About 23% of multi-token words could never be successfully decoded from hidden states, suggesting some words remain permanently fragmented in the model's "mind."

Furthermore, the success rate for identifying detokenized words in Arabic was significantly lower (around 16%) than in English. This suggests that while the detokenization mechanism exists across languages, the "completeness" of the inner lexicon may vary based on the training data's diversity. Future work will likely focus on how to better populate this inner lexicon for low-resource languages and specialized domains.

Summary updated

BibTeX
@inproceedings{kaplan2025from,
  author = {Guy Kaplan and Matanel Oren and Yuval Reif and Roy Schwartz},
  title = {{From Tokens to Words: On the Inner Lexicon of LLMs}},
  booktitle = {International Conference on Learning Representations},
  year = {2025},
  url = {https://openreview.net/forum?id=328vch6tRs},
}
Figure