Skip to main content
QUICK REVIEW

[Paper Review] Skyformer: Remodel Self-Attention with Gaussian Kernel and Nystr\\"om Method

Yifan Chen, Qi Zeng|arXiv (Cornell University)|Oct 29, 2021
Neural Networks and ApplicationsComputer Science24 references7 citations
TL;DR

Skyformer proposes a kernelized attention mechanism that replaces the standard softmax in self-attention with a Gaussian kernel to improve training stability and enables efficient approximation via a modified Nyström method for non-positive semidefinite matrices. The method achieves comparable or better performance than full self-attention on the Long Range Arena benchmark with significantly reduced computational cost and improved convergence stability.

ABSTRACT

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.

Motivation & Objective

  • To address the high computational cost and training instability of standard self-attention in Transformers.
  • To leverage kernel methods to stabilize training by replacing the softmax structure with a Gaussian kernel.
  • To develop an efficient approximation method for kernelized attention using the Nyström method on non-positive semidefinite matrices.
  • To provide theoretical guarantees on matrix approximation error in spectral norm for the proposed method.
  • To demonstrate that the proposed method achieves competitive performance with reduced resource consumption on long sequence tasks.

Proposed method

  • Replaces the standard softmax attention with a Gaussian kernel-based attention mechanism to stabilize training and improve numerical behavior.
  • Adapts the Nyström method to approximate the kernelized attention matrix by lifting it into a larger positive semidefinite matrix, enabling low-rank approximation.
  • Uses randomized sketching to reduce the dimensionality of the kernel matrix, accelerating computation while maintaining accuracy.
  • Theoretical analysis shows that the spectral norm of the matrix approximation error is small, providing a formal guarantee on approximation quality.
  • Employs a symmetrization technique to handle non-PSD kernel matrices arising from distinct query and key matrices in attention computation.
  • Applies the method to the Long Range Arena benchmark to evaluate performance and efficiency across diverse NLP tasks.

Experimental results

Research questions

  • RQ1Can replacing the softmax structure in self-attention with a Gaussian kernel improve training stability and reduce sensitivity to hyperparameters?
  • RQ2Can the Nyström method be effectively adapted to non-positive semidefinite kernel matrices arising in self-attention to enable efficient approximation?
  • RQ3What is the theoretical bound on the approximation error of the proposed method in terms of spectral norm?
  • RQ4Does the proposed method achieve comparable or better performance than standard self-attention while reducing computational and memory costs?
  • RQ5How does the method scale with increasing sequence length, and what is the relationship between sequence length and approximation efficiency?

Key findings

  • Skyformer achieves nearly 4x speed-up on text classification and document retrieval tasks compared to standard self-attention, with reduced training time and memory usage.
  • The model improves accuracy by 2.75% on text classification and 1.37% on document retrieval over the standard self-attention baseline.
  • Training with Skyformer is more stable across different random seeds, with reduced convergence failure and less sensitivity to learning rate changes.
  • Theoretical analysis confirms that the matrix approximation error of Skyformer is small in the spectral norm, supporting its reliability.
  • The method performs better on longer sequences, as the statistical dimension of the kernel matrix is smaller relative to sequence length, making approximation more effective.
  • Experiments show that direct Nyström approximation of standard self-attention leads to numerical instability, while the kernelized attention variant stabilizes training.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.