Mind the Gap: a Spectral Analysis of Rank Collapse and Signal Propagation in Transformers
<|reference_start|>Mind the Gap: a Spectral Analysis of Rank Collapse and Signal Propagation in Transformers: Attention layers are the core component of transformers, the current state-of-the-art neural network architecture. However, \softmaxx-based attention puts transformers' trainability at risk. Even \textit{at initialisation}, the propagation of signals and gradients through the random network can be pathological, resulting in known issues such as (i) vanishing/exploding gradients and (ii) \textit{rank collapse}, i.e. when all tokens converge to a single representation \textit{with depth}. This paper examines signal propagation in \textit{attention-only} transformers from a random matrix perspective, illuminating the origin of such issues, as well as unveiling a new phenomenon -- (iii) rank collapse \textit{in width}. Modelling \softmaxx-based attention at initialisation with Random Markov matrices, our theoretical analysis reveals that a \textit{spectral gap} between the two largest singular values of the attention matrix causes (iii), which, in turn, exacerbates (i) and (ii). Building on this insight, we propose a novel, yet simple, practical solution to resolve rank collapse in width by removing the spectral gap. Moreover, we validate our findings and discuss the training benefits of the proposed fix through experiments that also motivate a revision of some of the default parameter scaling. Our attention model accurately describes the standard key-query attention in a single-layer transformer, making this work a significant first step towards a better understanding of the initialisation dynamics in the multi-layer case.<|reference_end|>
@article{naderi2024mind,
    title={Mind the Gap: a Spectral Analysis of Rank Collapse and Signal
  Propagation in Transformers},
    author={Alireza Naderi, Thiziri Nait Saada, Jared Tanner},
    journal={arXiv preprint arXiv:2410.07799},
    year={2024},
    archivePrefix={arXiv},
    eprint={2410.07799},
    primaryClass={cs.LG stat.ML}
}