Sinkhorn doubly stochastic attention rank decay analysis
Organizations: Department of Physics and Astronomy, University of Bologna, Bologna, Italy · Department of Pharmacy and Biotechnologies, University of Bologna Bologna, Italy · Department of Mathematics and Statistics, Queen’s University, Kingston, ON, Canada
Abstract
The self-attention mechanism is central to the success of Transformer architectures. However, standard row-stochastic attention has been shown to suffer from significant signal degradation across layers. In particular, it can induce rank collapse, resulting in increasingly uniform token representations, as well as entropy collapse, characterized by highly concentrated attention distributions. Recent work has highlighted the benefits of doubly stochastic attention as a form of entropy regularization, promoting a more balanced attention distribution and leading to improved empirical performance. In this paper, we study rank collapse across network depth and show that doubly stochastic attention matrices normalized with Sinkhorn algorithm preserve rank more effectively than standard softmax row-stochastic ones. As previously shown for softmax, skip connections are crucial to mitigate rank collapse. We empirically validate this phenomenon on both sentiment analysis and image classification tasks. Moreover, we derive a theoretical bound for the pure self-attention rank decay when using Sinkhorn normalization and find that rank decays to one doubly exponentially with depth, a phenomenon that has already been shown for softmax.
Figures & tables
Appendix figures & tables3 assets
Supplementary material from the paper’s appendix.
Appendix
| Dataset | AG’s News |
|---|---|
| Maximum sequence length | 128 |
| Model dimension | 128 |
| Feed-forward dimension | 512 |
| Attention heads | 4 |
| Number of layers | 24 |
| Batch size | 32 |
| MNIST | Cats and Dogs | |
|---|---|---|
| Image size | ||
| Patch size | 4 | 16 |
| Model dimension | 128 | 128 |
| Feed-forward dimension | 512 | 512 |
| Attention heads | 4 | 4 |
| Number of layers | 24 | 24 |