TL;DR
Large Language Models (LLMs) process text as subword "tokens" that are often semantically meaningless on their own. This paper discovers an "erasure effect" in early model layers where information about individual tokens is discarded to form higher-level "implicit vocabulary" items, and introduces a method to "read out" these internal concepts directly from the model's hidden states.
What Problem Does This Paper Address?
Most modern LLMs don't "see" words; they see tokens generated by Byte-Pair Encoding (BPE). While efficient, BPE often splits meaningful words into arbitrary fragments. For instance, Llama-2-7b sees "northeastern" as [_n, ort, he, astern]. None of these fragments carry the meaning of the full word. Similarly, multi-word entities like "Neil Young" or idioms like "break a leg" are processed as sequences of fragments.
The central mystery is: How and where do LLMs convert these arbitrary fragments into unified, meaningful concepts? The authors investigate the mechanistic process of "detokenization"—the internal transition from raw tokens to a higher-level "implicit vocabulary."
Methods
The researchers employed Linear Probing to track information flow through the layers of Llama-2-7b and Llama-3-8b.
- Probing Hidden States: They trained simple linear classifiers (probes) to predict the identity of a token (at position $t$) using the hidden states of the model at different layers ($\ell$). They tested the model's ability to "remember" the current token ($i=0$), the previous token ($i=-1$), and tokens further back.
- Identifying Erasure: If a probe's accuracy drops sharply at a specific layer, it suggests the model has "erased" that specific token-level information from its representation.
- The Erasure Score ($\psi$): The authors developed a heuristic score to identify sequences that the model treats as single lexical units. A high $\psi$ score indicates a sequence where the model "forgets" the individual constituent tokens at the final token position, replacing them with a unified concept.
- Document Segmentation: They created an algorithm (Algorithm 1) that uses this score to break down natural text into the model's own "implicit" units, effectively mapping out the model's internal dictionary.
Datasets
- The Pile: A massive, diverse text dataset used to train the linear probes.
- COUNTERFACT: A dataset of factual prompts (e.g., "The Space Needle is in...") used to evaluate how the model represents named entities.
- Wikipedia: Used to test the erasure effect on multi-token words and to extract the implicit vocabulary.
- Wikidata: Used to augment the entity datasets with specific pairs like [movie → creator].
Key Insights and Ideas
- The "Last Token" Phenomenon: Erasure almost exclusively happens at the last token of a multi-token word or entity. Because transformers are autoregressive, the model can only "realize" it is looking at a specific concept (like "Star Wars") once it reaches the final token ("Wars"). At that moment, it overwrites the individual token data with the unified concept.
- Early Layer Processing: This "detokenization" happens very early in the network—typically by layer 9 in the Llama models studied. This suggests that forming a stable lexical representation is a prerequisite for the higher-level reasoning that occurs in later layers.
- Implicit vs. Explicit Vocab: The model's internal "vocabulary" is much broader than the BPE tokens it was trained on. It includes not just multi-token words, but common phrases ("thank you for your understanding"), LaTeX commands, and code snippets.
- Tokenizer Influence: Llama-3-8b has a much larger explicit vocabulary than Llama-2. Consequently, its "implicit" vocabulary tends to consist of even larger multi-word expressions and code blocks rather than just single words.
Key Results
The researchers found a striking difference in how models treat "normal" tokens versus the final tokens of entities.
As seen in Figure 2 (and similarly for multi-token words in Figure 3), the accuracy for predicting the current and previous tokens ($i=0, -1$) crashes in early layers for the "Last Subject" tokens, while remaining relatively high for "Other Tokens." This is the "erasure" footprint.
Quantitatively, for Llama-2-7b on Wikipedia text, 44.9% of the sequences identified by their algorithm were confirmed multi-token words or entities. While the "recall" (the percentage of all words found) is low (~1.6%), the "precision" is high enough to suggest that the erasure score is a valid signal for identifying internal lexical units.
Limitations and Future Work
- Ground Truth Challenges: There is no "master list" of what an LLM truly knows, making it difficult to measure the absolute accuracy of the extracted implicit vocabulary.
- Scope: The study focused on Llama models and English text. It remains to be seen if these patterns hold across different architectures (like MoE) or in low-resource languages.
- Intermediate Cases: The authors note that their current method might struggle with "intermediate" cases, such as fictional entities or rare words that the model only partially understands.
- Future Directions: The authors suggest this method could be used to evaluate how "familiar" a model is with specific concepts, potentially identifying gaps in its training data.
Summary updated