PermuteFormer: Efficient Relative Position Encoding for Long Sequences

Peng Chen
9/6/2021
cs.CLcs.LG
transformer-attention

Official code: cpcp1998/PermuteFormer (42 stars, Python, last commit 2021-10-10).

Abstract

A recent variation of Transformer, Performer, scales Transformer to longer sequences with a linear attention mechanism. However, it is not compatible with relative position encoding, which has advantages over absolute position encoding.

Show full abstract

In this paper, we discuss possible ways to add relative position encoding to Performer. Based on the analysis, we propose PermuteFormer, a Performer-based model with relative position encoding that scales linearly on long sequences. PermuteFormer applies position-dependent transformation on queries and keys to encode positional information into the attention module. This transformation is carefully crafted so that the final output of self-attention is not affected by absolute positions of tokens. PermuteFormer introduces negligible computational overhead by design that it runs as fast as Performer. We evaluate PermuteFormer on Long-Range Arena, a dataset for long sequences, as well as WikiText-103, a language modeling dataset. The experiments show that PermuteFormer uniformly improves the performance of Performer with almost no computational overhead and outperforms vanilla Transformer on most of the tasks.

View on arXivView PDF

Code Implementations(1)

Code for the paper PermuteFormer

423Python, ShellSep 3, 20215 years ago

Similar Papers

Cite this paper

@article{chen2021permuteformer,
  title  = {PermuteFormer: Efficient Relative Position Encoding for Long Sequences},
  author = {Peng Chen},
  year   = {2021},
  eprint = {2109.02377},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2109.02377}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2109.02377.svg)](https://codeofpaper.com/paper/2109.02377)

Discussion