On Identifiability in Transformers
Gino Brunner, Yang Liu, Damián Pascual, Oliver Richter, Massimiliano Ciaramita, Roger Wattenhofer
TL;DR
This work analyzes identifiability in Transformer architectures, focusing on self-attention and token embeddings. It proves that attention weights are non-identifiable when sequence length exceeds the attention head dimension and introduces effective attention as a diagnostic tool. Through token identifiability and gradient-based Hidden Token Attribution, the paper shows that input tokens largely retain identity via angular information and that context is heavily mixed into hidden embeddings, though aggregation remains mostly local. The findings challenge naive interpretations of attention distributions and provide practical techniques to better understand and investigate Transformer models.
Abstract
In this paper we delve deep in the Transformer architecture by investigating two of its core components: self-attention and contextual embeddings. In particular, we study the identifiability of attention weights and token embeddings, and the aggregation of context into hidden tokens. We show that, for sequences longer than the attention head dimension, attention weights are not identifiable. We propose effective attention as a complementary tool for improving explanatory interpretations based on attention. Furthermore, we show that input tokens retain to a large degree their identity across the model. We also find evidence suggesting that identity information is mainly encoded in the angle of the embeddings and gradually decreases with depth. Finally, we demonstrate strong mixing of input information in the generation of contextual embeddings by means of a novel quantification method based on gradient attribution. Overall, we show that self-attention distributions are not directly interpretable and present tools to better understand and further investigate Transformer models.
