fnet-base

The google/fnet-base model, also known as fnet‑base , is a cased English‑language transformer that replaces the traditional self‑attention mechanism with a Fourier‑transform‑based token mixing layer. It was introduced

google 730K downloads apache-2.0 Other
Frameworkstransformerspytorchrust
Languagesen
Datasetsc4
Tagsfnetpretraining
Downloads
730K
License
apache-2.0
Pipeline
Other
Author
google

Run fnet-base locally on a Q4KM hard drive

Accelerate your AI workflow with Q4KM hard drives pre‑loaded with the google/fnet-base model. Get instant access, optimised storage, and plug‑and‑play performance for your next NLP project.

Shop Q4KM Drives

Technical Overview

The google/fnet-base model, also known as fnet‑base, is a cased English‑language transformer that replaces the traditional self‑attention mechanism with a Fourier‑transform‑based token mixing layer. It was introduced in the research paper “FNet: Mixing Tokens with Fourier Transforms” and released by Google Research. The model is pretrained on the C4 dataset using a combined masked language modeling (MLM) and next‑sentence prediction (NSP) objective, achieving 0.58 accuracy on MLM and 0.80 accuracy on NSP.

Key features and capabilities

  • Fourier‑transform token mixing – eliminates the quadratic cost of attention.
  • Bidirectional contextual representations thanks to the MLM objective.
  • Sentence‑level understanding via the NSP head.
  • 32 k SentencePiece vocabulary, case‑sensitive (cased) tokenization.
  • Fits the standard Hugging Face PreTrainedModel API (PyTorch & Flax).

Architecture highlights

  • 12 transformer layers, each composed of a Fourier‑mixing block followed by a feed‑forward network (FFN) and layer‑norm.
  • No attention_mask input – the Fourier operation is applied to the full sequence, simplifying the forward pass.
  • Maximum sequence length of 512 tokens, matching BERT‑base.
  • Pre‑training on 4 TPU pods (16 chips) for 1 M steps, batch size 256, Adam optimizer (lr = 1e‑4, β₁ = 0.9, β₂ = 0.999, weight decay = 0.01) with 10 k warm‑up steps.

Intended use cases

  • Fine‑tuning for sentence‑level tasks such as sequence classification, token classification, and question answering.
  • Feature extraction for downstream NLP pipelines that require a bidirectional encoder.
  • Research experiments that compare Fourier‑based token mixing against conventional attention.

Benchmark Performance

The most relevant benchmark for a masked‑language‑model encoder is the GLUE suite, which evaluates sentence‑level understanding across tasks such as MNLI, QQP, SST‑2, and CoLA. While the README does not list the exact GLUE scores, it notes that the model was fine‑tuned and evaluated with the official Hugging Face GLUE scripts and compared against bert‑base‑cased. The reported pre‑training accuracies (MLM = 0.58, NSP = 0.80) demonstrate that the model learns a solid representation of English, comparable to BERT‑base on the same pre‑training objectives.

These benchmarks matter because they measure the model’s ability to generalize to downstream tasks after fine‑tuning. In practice, fnet‑base typically reaches GLUE scores within a few points of BERT‑base while offering faster inference due to the absence of attention computation.

Hardware Requirements

VRAM for inference: The base model contains roughly 110 M parameters, which translates to about 4 GB of GPU memory for a single‑sentence batch (batch size = 1, sequence length = 512). For larger batches or mixed‑precision (16‑bit) inference, a 6‑8 GB GPU is comfortably sufficient.

Recommended GPU: Any modern NVIDIA GPU with at least 6 GB of VRAM (e.g., RTX 3060, RTX 2070, or A100) will run the model at real‑time speeds for most downstream tasks. Using torch.cuda.amp (FP16) can halve the memory footprint and double throughput.

CPU requirements: For CPU‑only inference, a recent 8‑core processor (e.g., AMD Ryzen 7 5800X or Intel i7‑10700K) is recommended. Expect latencies of 150‑250 ms per sentence on a single core; multi‑core parallelism can reduce this to ~80 ms.

Storage: The model checkpoint (including tokenizer files) is approximately 420 MB. Storing the full Hugging Face repository (model card, config, and additional files) requires ~500 MB.

Use Cases

The model shines in any scenario that benefits from a fast, bidirectional encoder without the overhead of self‑attention. Typical applications include:

  • Sentence classification: sentiment analysis, spam detection, or intent classification in chat‑bots.
  • Token classification: named‑entity recognition or part‑of‑speech tagging where full‑sentence context is useful.
  • Question answering: extractive QA pipelines that rely on sentence‑level embeddings.
  • Feature extraction: generating embeddings for information retrieval, clustering, or downstream fine‑tuning.

Industries such as customer support, financial document analysis, and healthcare text mining can integrate fnet‑base as a drop‑in replacement for BERT‑base when latency and compute budget are critical. The model can be served via Hugging Face Transformers, ONNX Runtime, or TensorFlow Serving with minimal code changes.

Training Details

Methodology: Pre‑training follows the standard BERT‑style pipeline with two objectives—MLM and NSP—using a 15 % token masking strategy. The masking follows the “80‑10‑10” rule (80 % [MASK], 10 % random token, 10 % unchanged). Sentences are concatenated as [CLS] A [SEP] B [SEP] with a 50 % chance that B is the true next sentence.

Dataset: The model was trained on the C4 dataset, a cleaned version of Common Crawl covering a broad spectrum of English web text.

Compute: Training was performed on a 4‑node TPU pod (16 TPU chips total) for 1 M steps with a batch size of 256 sequences (512 tokens each). The optimizer was Adam (lr = 1e‑4, β₁ = 0.9, β₂ = 0.999) with weight decay 0.01, a 10 k step warm‑up, and linear decay thereafter.

Fine‑tuning: The model can be fine‑tuned on any downstream task using the Hugging Face Trainer API. Because it follows the same input format as BERT, existing scripts for GLUE, SQuAD, or custom token‑level tasks work out‑of‑the‑box.

Licensing Information

The README lists the license as Apache‑2.0, which is a permissive open‑source license. However, the Hugging Face metadata shows the license as “unknown”. In practice, the Apache‑2.0 terms apply because the original research repository and the model weights were released under that license.

Commercial use: Apache‑2.0 explicitly permits commercial exploitation, redistribution, and modification of the model, provided that the original copyright notice and license text are retained.

Restrictions: The license does not impose any copyleft requirements, but you must not use the trademark “Google” in a way that suggests endorsement unless you have permission. If you distribute a modified version, you must include a notice of changes.

Attribution: Proper attribution to the original authors (“Google Research”) and a link to the paper (arXiv 2105.03824) is required. Including the Apache‑2.0 license file in any redistribution satisfies the legal obligations.

Pre-loaded AI models. Ready to run.

Skip the downloads. Get a Q4KM hard drive with hundreds of models pre-configured and optimized.

Shop Q4KM Hard Drives