SourceA Formal Framework for Understanding Length Generalization in Transformers
The paper computes the product p_i^T k^T q p_j for every head in GPT-2 small (12 layers, 12 heads per layer) and measures the offset variance along each sub-diagonal. Most heads show near-constant products (offset variance close to 0), which are trivially translation-invariant. A few heads show higher variance (66.0, 87.9, 142.1) but still exhibit approximately offset-invariant post-softmax attention: the weights from query position j are focused on key positions i with small j-i, consistently across offsets 0, 100, 200, 300, 400. The authors note this invariance is not enforced in training or initialization, suggesting it emerges from the offset-invariant nature of the language modeling task.