Notes

Mixture of Experts (MoE)

Scaling a dense transformer means every parameter does work on every token, so capacity and cost rise together. Mixture of Experts breaks that link: the model grows a large pool of parameters, but each token is routed to only a small slice of it.

The mechanics

The feed-forward block of a transformer layer is replaced by several parallel copies, the experts. A small gating network scores the experts for each token and keeps the top one or two; the chosen experts run, their outputs are combined, the rest stay idle. Routing happens per token rather than per sequence, so a single sentence can draw on different experts word by word.

Making routing behave

Left alone, the gate collapses onto a few favourite experts and the others never learn. Training therefore adds an auxiliary load-balancing loss and a per-expert capacity limit, above which surplus tokens are dropped or passed through unchanged. Getting this wrong is the usual cause of an MoE that trains unstably or fails to beat the dense model it replaced.

What it costs and what it buys

Switch Transformer, GLaM, Mixtral and DeepSeek's MoE models all take this shape, now the standard way to add capacity when serving cost rather than training cost is the binding constraint. The trade:

  • Cheaper per token — compute scales with the active experts, not the total parameter count.
  • Expensive in memory — every expert must be resident, so GPU memory tracks the total.
  • Harder to serve — experts are sharded across devices, adding communication inside every layer.

Mixture of Experts replaces a transformer's feed-forward block with several parallel expert networks plus a gating network that routes each token to only one or two of them. This decouples parameter count from compute per token, so the model gains capacity without a proportional rise in serving cost. The price is memory, since all experts must be held at once, and training instability unless a load-balancing loss stops the router favouring a few experts.

A big hospital does not send every patient to the same doctor. A receptionist glances at why you came and points you to the right specialist, so the hospital can know an enormous amount while your appointment stays short. Mixture of Experts builds an AI model the same way. Inside it sit many sub-networks, and for each word a small router picks just one or two of them to do the work. The model ends up far more knowledgeable than its running cost suggests. The downside is space: all the specialists need a room, even the ones sitting idle.