From Tokens to Words: On the Inner Lexicon of LLMs

Guy Kaplan, Matanel Oren, Yuval Reif, Roy Schwartz · DOI

Introduction

Large Language Models (LLMs) process text as "tokens" rather than whole words. Due to Byte-Pair Encoding (BPE), a single word like "unhappiness" is often fragmented into sub-units such as "un," "h," and "appiness." While efficient for handling large vocabularies, this raises a fundamental question: do LLMs ever reconstruct the concept of a whole word, or do they operate solely on sub-word statistics?

Recent research from The Hebrew University of Jerusalem, titled "From Tokens to Words: On the Inner Lexicon of LLMs," demonstrates that LLMs perform an internal "detokenization" process. The models maintain an inner lexicon—a latent vocabulary stored within their weights that transcends the limitations of the initial tokenizer.

The Detokenization Gap

The mismatch between natural language (words) and LLM inputs (tokens) can break morphological structures and increase sensitivity to typos. If a word is split across multiple tokens, the model must theoretically "wait" until the final token to resolve the word's identity. The researchers investigated whether models recognize when tokens form a valid word, where this fusion occurs, and if these internal representations can be leveraged for efficiency.

Methodology

The study analyzed models including Llama 2, Llama 3, Mistral, and Yi using several interpretability techniques:

  • Probing: A k-nearest neighbors (k-NN) classifier was trained on hidden states to distinguish real multi-token words from "non-words" (shuffled tokens).
  • Logit Lens: Hidden states from intermediate layers were projected back into the input embedding space to see if they matched single-token word embeddings.
  • Patchscopes: A hidden state from one context was "patched" into a new prompt (e.g., "Repeat this word: [HIDDEN STATE]"). Successful generation of the original word indicates the state contains the full word identity.
  • Ablation: Feed-Forward Network (FFN) updates were selectively zeroed out to identify layers responsible for word retrieval.

The Mechanism: A Two-Stage Process

The study reveals that detokenization is a structured, two-phase process occurring primarily in the early-to-middle layers:

  1. Aggregation (Layers 1-2): The attention mechanism pulls information from prefix tokens into the representation of the word's final token.
  2. Retrieval (Layers 3-15): FFN layers act as a "key-value" memory, looking up the integrated prefix information and writing the full word concept into the residual stream.
The internal detokenization process: (b) attention aggregates sub-tokens, and (c) FFN retrieves the full word representation.

This "inner lexicon" is robust; the model can reconstruct words even with non-standard splits or typos, suggesting a "soft" associative memory rather than a rigid lookup table.

Key Results and Efficiency Gains

The empirical evidence for an internal lexicon is strong:

  • Word Recognition: By layer 13, a k-NN probe achieved 89% accuracy in distinguishing words from non-words.
  • Successful Decoding: Using Patchscopes, the model successfully repeated the original word from a single hidden vector in 64% of cases for multi-token words.
  • FFN Criticality: Ablating just 5% of the FFN layers identified as "word-retrieving" caused word retrieval rates to plummet from 85% to 18%.
Nonword creation process and classification accuracy across layers, showing peak word recognition in middle layers.

Beyond theoretical interest, these findings have practical applications. By treating internal "fused" representations as new tokens—effectively expanding the latent vocabulary—the researchers reduced input sequence lengths by 10.5% to 14.5% across datasets without additional finetuning or significant loss in accuracy.

Limitations and Future Outlook

The inner lexicon is not exhaustive. Approximately 23% of multi-token words remained fragmented or undecodable. Furthermore, success rates in Arabic were notably lower (16%), suggesting that current training paradigms may not build equally robust inner lexicons for morphologically complex, non-English languages. Future research will likely explore how these lexicons emerge during pre-training and how to optimize them for global linguistic diversity.

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