All models

fnet

FNet, a BERT-like encoder that mixes tokens with a Fourier transform instead of self-attention.

Language · 229 operations Checked

100%

Showing the top corner; full diagram not loaded yetShowing a small copy; full diagram not loaded yetLarge diagram, not loaded yet

Open SVG

Loading diagram (31 KB)

Open in a new tab

Click or tap a spot to read it up close. Scroll or drag inside the diagram to move through it. Zoom with + and − or Ctrl and scroll. Press 0 for the whole graph. Swipe inside the diagram to move through it. Use + and − to zoom.

At a glance

Parameters
83.5M
Operations
229
Framework
PyTorch
Recurrent
No
License
Apache-2.0
Checked
Passed: the trace was replayed operation by operation and matched the model's own output for this input.

Files

The diagram is a drawing of a TorchLens trace of the source code. It contains no code or weights.

Details
Stable ID
m5056
Graph hash
55ce5e5d41d4e7e43abd723b0887c7e972510e8f2d8f5e2319131c2c135f14a6
Skeleton hash
a677cf064840b7b66e193e9af6fe857111c727b040b4366adf6e7944732e01fc
Architecture hash
90a459b41926d445cf524742e72aa038a16fe083a73e8f051ebc4f1142cb499d
Diagram SHA-256
eed54127f6b9382b5c3cfc78d7c135790573375e9cde186db4125ea95f6e4ed5
TorchLens version
2.35.3
Renderer
graphviz 2.43.0+pyvips 3.2.0+libvips 8.18.7+render-opts@06c1f0d3
Check
Forward pass replayed in PyTorch

How this diagram was made

transformers.AutoModelForMaskedLM.from_config()

What it is

FNet is a BERT model in which the self-attention layer is replaced by a Fourier transform that returns only the real parts of the transform. It was proposed in the paper FNet: Mixing Tokens with Fourier Transforms by James Lee-Thorp, Joshua Ainslie, Ilya Eckstein, Santiago Ontanon. The paper reports that a Transformer encoder with a standard, unparameterized Fourier Transform in place of the self-attention sublayer reaches 92-97% of the accuracy of BERT counterparts on the GLUE benchmark, while training 80% faster on GPUs and 70% faster on TPUs at standard 512 input lengths.

The model was trained without an attention mask, since it is based on the Fourier Transform, and with a maximum sequence length of 512 that includes pad tokens. The library therefore recommends using the same maximum sequence length for fine-tuning and inference.

Key idea. The paper shows that replacing a Transformer encoder's self-attention sublayers with an unparameterized Fourier Transform keeps 92-97% of BERT's GLUE accuracy while training faster.

  • fnet
  • fourier transform
  • mixing tokens with fourier transforms
  • fourier token mixing
  • efficient transformer
  • transformer encoder
  • masked language modeling

AI-written summary, based on the model's documentation and checked automatically against it; not reviewed by a person. Corrections welcome.