mlp-gated -- the SwiGLU / GeGLU feed-forward block

Once attention has let the words look at each other, each word is passed on its own through a small two-stage network, and this is where most of what a model knows is stored — usually around two-thirds of all its numbers. The modern version does the first stage twice, side by side: one copy is bent through a curve and then used to scale the other, number by number, so the network can turn parts of itself down to nothing for one word and leave them at full strength for another. That second copy is a third grid of numbers to pay for, so models make each stage narrower to keep the total size roughly where it was.

Interactive page: the gated MLP used in modern transformers (Llama, etc.) — two parallel up-projections, an element-wise gate, and a down-projection. Anchor: A6 MLP shape / A7 activation (Family C2).

What it shows

The block, top to bottom (rows column-aligned so the element-wise step reads vertically):

  1. gate = x · W_gate — project x up to the intermediate width I.
  2. up = x · W_up — a second, parallel projection to the same width.
  3. act(gate) — apply the activation: SiLU (→ SwiGLU) or GELU (→ GeGLU), toggleable.
  4. hidden = act(gate) ⊙ up — the gate: act(gate) modulates up element-by-element (column i of hidden = column i of act(gate) × column i of up).
  5. out = hidden · W_down — project back down to D.

Scrub the transport through the five stages (auto-plays + loops); rows reveal as they're computed and the active stage is highlighted. Drag any input x cell vertically and gate, up, gated, and out all recompute live — the element-wise gating made tangible; hover a gate / up / gated cell for its derivation (hidden[j] = act(gate[j]) · up[j]). The intermediate width I = 2·D here (real models use ~2.7× for SwiGLU to keep the parameter count of the 3 matrices comparable to a 4× un-gated FFN).

Render tier

T1 (Canvas2D heatmaps for the row vectors).

Wiring

layout.mount + controls (dim D, seed, activation) + a per-stage Transport, drawn with render.heatmap + ctx and tensor.silu/gelu/ seededRandn. Interactive per the framework contract: onPointer drag of x + cellAt hover-to-inspect + autoplay/loop. Headless hooks: ?step=N, ?play=1, ?act=silu|gelu, ?hover=x,y, ?drag=i,val (set input cell i, e.g. ?drag=2,1.5). Source: page.js.