Relative Positional Encoding for Transformers with Linear Complexity

Abstract

Recent advances in Transformer models allow for unprecedented sequence lengths, due to linear space and time complexity. In the meantime, relative positional encoding (RPE) was proposed as beneficial for classical Transformers and consists in exploiting lags instead of absolute positions for inference. Still, RPE is not available for the recent linear-variants of the Transformer, because it requires the explicit computation of the attention matrix, which is precisely what is avoided by such methods. In this paper, we bridge this gap and present Stochastic Positional Encoding as a way to generate PE that can be used as a replacement to the classical additive (sinusoidal) PE and provably behaves like RPE. The main theoretical contribution is to make a connection between positional encoding and cross-covariance structures of correlated Gaussian processes. We illustrate the performance of our approach on the Long-Range Arena benchmark and on music generation.

Cite

Text

Liutkus et al. "Relative Positional Encoding for Transformers with Linear Complexity." International Conference on Machine Learning, 2021.

Markdown

[Liutkus et al. "Relative Positional Encoding for Transformers with Linear Complexity." International Conference on Machine Learning, 2021.](https://mlanthology.org/icml/2021/liutkus2021icml-relative/)

BibTeX

@inproceedings{liutkus2021icml-relative,
  title     = {{Relative Positional Encoding for Transformers with Linear Complexity}},
  author    = {Liutkus, Antoine and Cı́fka, Ondřej and Wu, Shih-Lun and Simsekli, Umut and Yang, Yi-Hsuan and Richard, Gael},
  booktitle = {International Conference on Machine Learning},
  year      = {2021},
  pages     = {7067-7079},
  volume    = {139},
  url       = {https://mlanthology.org/icml/2021/liutkus2021icml-relative/}
}