Skyformer: Remodel Self-Attention with Gaussian Kernel and Nystr\"om Method
About
Transformers are expensive to train due to the quadratic time and space complexity in the self-attention mechanism. On the other hand, although kernel machines suffer from the same computation bottleneck in pairwise dot products, several approximation schemes have been successfully incorporated to considerably reduce their computational cost without sacrificing too much accuracy. In this work, we leverage the computation methods for kernel machines to alleviate the high computational cost and introduce Skyformer, which replaces the softmax structure with a Gaussian kernel to stabilize the model training and adapts the Nystr\"om method to a non-positive semidefinite matrix to accelerate the computation. We further conduct theoretical analysis by showing that the matrix approximation error of our proposed method is small in the spectral norm. Experiments on Long Range Arena benchmark show that the proposed method is sufficient in getting comparable or even better performance than the full self-attention while requiring fewer computation resources.
Related benchmarks
| Task | Dataset | Result | Rank | |
|---|---|---|---|---|
| Long-range sequence modeling | Long Range Arena (LRA) | Text Accuracy64.7 | 164 | |
| Long sequence classification | LRA (Long Range Arena) (test) | Average Accuracy59.39 | 92 | |
| Image Classification | LRA reimplementation (test) | Running Time (h)3.4 | 9 | |
| Pathfinder | LRA Pathfinder reimplementation (test) | Running Time (h)2.03 | 9 | |
| Retrieval | LRA Document Retrieval reimplementation (test) | Running Time (h)1.86 | 9 | |
| Text Classification | LRA Text Classification reimplementation (test) | Running Time (Hours)1.02 | 9 | |
| ListOps | LRA ListOps (test) | Running Time (h)1.29 | 9 |