(Un)interpretability of Transformers: a case study with Dyck grammars

Published: 23 Jun 2023, Last Modified: 23 Jun 2023DeployableGenerativeAIEveryoneRevisions
Keywords: Transformer, Self Attention, Dyck Language, Context Free Grammar, Formal Language, Theory, Interpretability
TL;DR: By a combination of theory and experiments on synthetic and real data, we show that interpretability claims based on individual heads or weight matrices in the transformer can be misleading.
Abstract: Understanding the algorithm implemented by a model is important for trustworthiness when deploying large-scale models, which has been a topic of great interest for interpretability. In this work, we take a critical view of methods that exclusively focus on individual parts of the model, rather than consider the network as a whole. We consider a simple synthetic setup of learning a Dyck language. Theoretically, we show that the set of models that can solve this task satisfies a structural characterization derived from ideas in formal languages (the pumping lemma). We use this characterization to show that the set of optima is qualitatively rich: in particular, the attention pattern of a single layer can be ``nearly randomized'', while preserving the functionality of the network. We also show via extensive experiments that these constructions are not merely a theoretical artifact: even with severe constraints to the architecture of the model, vastly different solutions can be reached via standard training. Thus, interpretability claims based on individual heads or weight matrices in the Transformer can be misleading.
Submission Number: 55
Loading