Swish Gated Linear Unit

A gated feed-forward design that multiplies a value branch by a swish gate before projecting back.

The swish gated linear unit (SwiGLU) splits a feed-forward layer into value and gate branches, applies the sigmoid linear unit (SiLU) to the gate, and multiplies the two branches so the layer can filter features more selectively.

At a glance

Released

February 2020

Authors

Noam Shazeer

Optimizes

  • Feed Forward Expressiveness

What It Is

The swish gated linear unit (SwiGLU) is a gated feed-forward design used in many modern language models. Instead of using one expanded hidden branch, the layer creates a value branch and a gate branch. The gate branch passes through SiLU, then scales the value branch element by element before the layer projects back to the model width.

Why It Exists

SwiGLU optimizes for a more selective dense hidden path. Instead of treating every hidden feature the same way, it lets a learned gate strengthen or suppress each feature before the final projection.

How It Works

The input state enters two learned projections. One branch carries candidate values. The other branch becomes a SiLU gate. The two branches multiply elementwise, and the layer then projects the result back to the model width. The path stays dense because every token still uses the same shared block.

Math Or Compute Schema

The dense baseline below shows the simpler one-branch feed-forward layer. The SwiGLU formula shows the extra gate that turns that same slot into a two-branch gated path.
Standard dense feed-forward layer
FFN(ht)=W2 σ(W1ht+b1)+b2\mathrm{FFN}(h_t) = W_2\,\sigma(W_1 h_t + b_1) + b_2
hth_t
Hidden state for token position t.
W1W_1
Projection into the wide hidden layer.
W2W_2
Projection back to model width.
σσ
Pointwise activation inside the dense hidden layer.
Swish gated linear unit variant
SwiGLU(ht)=Wo((Wvht)⊙SiLU(Wght))\mathrm{SwiGLU}(h_t) = W_o\big((W_v h_t) \odot \mathrm{SiLU}(W_g h_t)\big)
hth_t
Hidden state for token position t.
WvW_v
Projection that builds the value branch.
WgW_g
Projection that builds the gate branch.
WoW_o
Projection back to model width after gating.
⊙\odot
Elementwise multiplication between the value and gate branches.

Compared To Nearby Modules

SwiGLU stays closer to the standard dense feed-forward baseline than mixture of experts does. It changes how features are filtered inside one dense block rather than turning the slot into a sparse routed expert system.
Comparison dimensionSwiGLUStandard feed-forwardMixture of experts
Path shapeValue branch multiplied by a SiLU gate branchOne dense expand -> activate -> project pathRouter selects a few expert MLPs, then merges them
Active compute per tokenAll hidden units plus a learned gateAll hidden units in one shared feed-forward blockOnly top-k experts activate for each token
Main tradeoffMore selective dense features, but still full dense computeSimpler path, but less selective hidden filteringMore capacity, but routing and sparse training become part of the design

Example Architectures

Many recent decoder-only language models use gated feed-forward designs like SwiGLU while keeping the same attention-then-feed-forward block structure.

Limitations And Tradeoffs

SwiGLU is still a dense block, so every token activates the whole path. It improves selectivity inside the layer, but it does not add sparse expert capacity the way mixture of experts does.

Why It Still Matters

SwiGLU appears often enough in modern model descriptions that readers benefit from seeing it as one of the default feed-forward baselines, not as a rare paper-only detail.

Tags

References

  1. Shazeer, Noam. "GLU Variants Improve Transformer." arXiv, 2020, https://arxiv.org/abs/2002.05202.