Skip to main content
QUICK REVIEW

[Paper Review] FNet: Mixing Tokens with Fourier Transforms

James Lee-Thorp, Joshua Ainslie|arXiv (Cornell University)|May 9, 2021
Topic ModelingComputer Science14 citations
TL;DR

FNet replaces self-attention in Transformer encoders with parameter-free Fourier transforms for efficient sequence modeling. It achieves 92–97% of BERT's GLUE accuracy while training 80% faster on GPUs and 70% faster on TPUs, with superior scalability on long sequences and strong performance at small model sizes.

ABSTRACT

We show that Transformer encoder architectures can be sped up, with limited accuracy costs, by replacing the self-attention sublayers with simple linear transformations that "mix" input tokens. These linear mixers, along with standard nonlinearities in feed-forward layers, prove competent at modeling semantic relationships in several text classification tasks. Most surprisingly, we find that replacing the self-attention sublayer in a Transformer encoder with a standard, unparameterized Fourier Transform achieves 92-97% of the accuracy of BERT counterparts on the GLUE benchmark, but trains 80% faster on GPUs and 70% faster on TPUs at standard 512 input lengths. At longer input lengths, our FNet model is significantly faster: when compared to the "efficient" Transformers on the Long Range Arena benchmark, FNet matches the accuracy of the most accurate models, while outpacing the fastest models across all sequence lengths on GPUs (and across relatively shorter lengths on TPUs). Finally, FNet has a light memory footprint and is particularly efficient at smaller model sizes; for a fixed speed and accuracy budget, small FNet models outperform Transformer counterparts.

Motivation & Objective

  • To investigate whether simpler, parameter-free linear transformations can replace self-attention in Transformer encoders without significant accuracy loss.
  • To evaluate the effectiveness of the Fourier Transform as a structured, efficient token mixing mechanism in place of attention.
  • To demonstrate that Fourier-based mixing enables faster training and inference, especially at longer sequence lengths.
  • To explore hybrid models combining a few attention layers with Fourier mixing for improved accuracy-speed trade-offs.
  • To establish that alternative mixing mechanisms may outperform approximations of attention in practice, particularly on long-range tasks.

Proposed method

  • FNet replaces the self-attention sublayer in each Transformer encoder block with a parameter-free Fourier Transform using the Fast Fourier Transform (FFT) algorithm.
  • The Fourier Transform operates on the sequence dimension, mixing tokens across positions via frequency-domain transformation.
  • Each block applies layer normalization after the Fourier mixing, followed by a standard feed-forward network with ReLU and dropout.
  • The model uses standard positional embeddings and a learnable pooler head for classification tasks.
  • For hybrid models, a small number of self-attention layers are inserted at specific positions (e.g., top layers) while the rest use Fourier mixing.
  • Training is performed using standard optimization with learning rate scheduling, and inference is evaluated on GLUE and Long Range Arena benchmarks.

Experimental results

Research questions

  • RQ1Can a parameter-free Fourier Transform effectively replace self-attention in Transformer encoders while maintaining competitive accuracy?
  • RQ2How does FNet's training and inference speed compare to BERT and efficient Transformer variants on standard and long sequences?
  • RQ3What is the optimal placement and number of attention layers in a hybrid FNet model for balancing accuracy and speed?
  • RQ4How does FNet scale in performance and efficiency across different input lengths, especially on long-range tasks?
  • RQ5Does replacing attention with a structured linear transform like the FFT offer advantages over parameterized or sparse attention approximations?

Key findings

  • FNet achieves 92–97% of BERT-Base and BERT-Large performance on the GLUE benchmark, respectively, while training 80% faster on GPUs and 70% faster on TPUs at 512 input length.
  • On the Long Range Arena benchmark, FNet matches the accuracy of the most accurate efficient Transformers and outperforms them in speed across all sequence lengths on GPUs.
  • For longer sequences, FNet is faster than all evaluated efficient Transformer models on GPUs and outperforms the fastest models on TPUs for shorter sequences.
  • Hybrid FNet models with only two self-attention layers placed at the top achieve 97–99% of BERT’s accuracy while still training 40–70% faster.
  • FNet has a smaller memory footprint and outperforms standard Transformer models under fixed speed and accuracy budgets, especially at smaller model sizes.
  • The Fourier Transform’s O(N log N) complexity enables superior practical scalability compared to O(N²) attention, even when attention is approximated.

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.