Weight-based Analysis of Detokenization in Language Models: Understanding the First Stage of Inference Without Inference
Go Kamoda, Benjamin Heinzerling, Tatsuro Inaba, Keito Kudo, Keisuke Sakaguchi, Kentaro Inui
TL;DR
The paper presents a weight-based decomposition of GPT-2's first attention layer to explain detokenization without performing any forward passes. By separating token- and position-derived components, it defines six terms $T^{\text{ee}}$, $T^{\text{pp}}$, $T^{\text{pe}}$, $T^{\text{ep}}$, $T^{\text{e}}$, and $T^{\text{p}}$, and demonstrates that $T^{\text{ee}}$ captures token affinity while $T^{\text{p}}$ and $T^{\text{pp}}$ bias attention toward nearby tokens. The work links detokenization to absolute position embeddings, LayerNorm variance, and token frequency via $T^{\text{e}}$, and provides empirical validation on OpenWebText with insights into head-specific roles. While limited to the first layer and GPT-2, the findings offer a principled, weight-based mechanism for early inference in LMs and point to broader applicability across architectures and position-embedding schemes.
Abstract
According to the stages-of-inference hypothesis, early layers of language models map their subword-tokenized input, which does not necessarily correspond to a linguistically meaningful segmentation, to more meaningful representations that form the model's "inner vocabulary". Prior analysis of this detokenization stage has predominantly relied on probing and interventions such as path patching, which involve selecting particular inputs, choosing a subset of components that will be patched, and then observing changes in model behavior. Here, we show that several important aspects of the detokenization stage can be understood purely by analyzing model weights, without performing any model inference steps. Specifically, we introduce an analytical decomposition of first-layer attention in GPT-2. Our decomposition yields interpretable terms that quantify the relative contributions of position-related, token-related, and mixed effects. By focusing on terms in this decomposition, we discover weight-based explanations of attention bias toward close tokens and attention for detokenization.
