
switch_transformers
Language2,079 ops317.3M params
Sparse T5 whose MLP layers are replaced by a routed mixture of experts.
Language · 2,079 operations Checked
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.
The file opened in a new tab. Use your browser's Save command there to keep it.
The diagram is a drawing of a TorchLens trace of the source code. It contains no code or weights.
How this diagram was made
transformers.AutoModel.from_config()
About this model's family
Switch Transformers is a sparse T5 model in which the MLP layer is replaced by a Mixture-of-Experts. A routing mechanism associates each token with an expert, and each expert is a dense MLP. Sparsity enables better scaling, and the routing lets the model select relevant weights on the fly, which increases model capacity.
The library exposes the top-1 router and the sparse MLP as their own modules, next to the encoder-decoder model, a conditional generation head and an encoder-only variant. The original checkpoints, such as google/switch-base-8, live under the Switch Transformer collection. Both captured members instantiate the plain encoder-decoder model from configuration, so their weights are untrained and the traced output is hidden states rather than token predictions.
Key idea. Replacing the MLP of a T5 transformer with a Mixture-of-Experts whose router sends each token to a single dense expert, adding capacity through sparsity.
AI-written summary, based on the model's documentation and checked automatically against it; not reviewed by a person. Corrections welcome.