From Tokens to Words: On the Inner Lexicon of LLMs
Guy Kaplan, Matanel Oren, Yuval Reif, Roy Schwartz
TL;DR
This work reveals that LLMs maintain an internal, word-level lexicon beyond the tokenizer and perform detokenization primarily in early-to-mid layers by aggregating subword tokens and using FFN-driven updates to reconstruct full word representations. By applying probing, logit-lens, and Patchscopes analyses, the authors show robust word vs. nonword discrimination and demonstrate word retrieval for both artificially split single-token words and multi-token out-of-vocabulary words, implying an expansive latent vocabulary. They propose a practical three-step, finetuning-free method to expand an LLM’s vocabulary by deriving detokenized representations and learning lightweight linear mappings to embed and unembed new words, achieving token-length reductions with minimal impact on accuracy across multiple domains. These findings offer a concrete pathway to improve efficiency and multilingual capability without changing base model parameters, with potential implications for token management and domain adaptation.
Abstract
Natural language is composed of words, but modern large language models (LLMs) process sub-words as input. A natural question raised by this discrepancy is whether LLMs encode words internally, and if so how. We present evidence that LLMs engage in an intrinsic detokenization process, where sub-word sequences are combined into coherent whole-word representations at their last token. Our experiments show that this process primarily takes place within the early and middle layers of the model. We further demonstrate its robustness to arbitrary splits (e.g., "cats" to "ca" and "ts"), typos, and importantly-to out-of-vocabulary words: when feeding the last token internal representations of such words to the model as input, it can "understand" them as the complete word despite never seeing such representations as input during training. Our findings suggest that LLMs maintain a latent vocabulary beyond the tokenizer's scope. These insights provide a practical, finetuning-free application for expanding the vocabulary of pre-trained models. By enabling the addition of new vocabulary words, we reduce input length and inference iterations, which reduces both space and model latency, with little to no loss in model accuracy.
