Mixture of Experts

A sparse feed-forward layer that routes each token to a small subset of expert layers instead of one dense shared block.

A mixture-of-experts layer, often shortened to MoE, routes each token through a few specialist expert layers instead of one dense shared feed-forward block, trading sparse activation for extra capacity.

At a glance

Released

January 2017

Authors

Noam Shazeer, Azalia Mirhoseini, Krzysztof Maziarz, et al.

Optimizes

  • Parameter Capacity
  • Compute Efficiency

Example models

What It Is

A mixture-of-experts layer, often shortened to MoE, replaces the single dense feed-forward network in a transformer block with many parallel expert layers plus a router. For each token position, a gating network scores every expert and sends the token state to only the top-k experts. The chosen expert outputs are then weighted and merged back into one updated token state.

Why It Exists

MoE optimizes for parameter capacity without forcing every token to pay for every expert. Instead of making one dense feed-forward block larger, it keeps activation sparse and lets different tokens use different expert subsets.

How It Works

The token state first goes through a router. The router picks a small top-k expert set for that token. Each selected expert runs its own feed-forward sublayer, and their outputs are blended into one result. The next token in the sequence can activate a different expert set even though the block slot in the architecture stays the same.

Math Or Compute Schema

The dense feed-forward formula below is the baseline that activates one shared path for every token. The mixture-of-experts formula adds routing and weighted expert selection to the same general slot.
Standard dense feed-forward network
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.
Mixture of experts
MoE(ht)=∑e∈TopK(r(ht))αe(ht) Experte(ht)\mathrm{MoE}(h_t) = \sum_{e \in \mathrm{TopK}(r(h_t))} \alpha_e(h_t)\,\mathrm{Expert}_e(h_t)
hth_t
Hidden state for token position t.
rr
Router that scores experts for the current token.
TopK\mathrm{TopK}
Operation that keeps only the highest-scoring expert choices.
αe\alpha_e
Weight assigned to expert e for this token.
Experte\mathrm{Expert}_e
Expert-specific feed-forward layer chosen by the router.

Compared To Nearby Modules

Compared with dense feed-forward variants, MoE changes not just the hidden path shape but the activation pattern itself. The key contrast is dense-for-every-token versus sparse top-k routing.
Comparison dimensionMixture of expertsStandard feed-forwardSwiGLU
Path shapeRouter selects a few expert layers, then merges themOne dense expand -> activate -> project pathValue branch multiplied by a SiLU gate branch
Active compute per tokenOnly top-k experts activate for each tokenAll hidden units in one shared feed-forward blockAll hidden units plus a learned gate
Main tradeoffAdds much more parameter capacity, but routing and balancing add system complexitySimple dense baseline, but every token pays for the whole blockMore expressive dense path, but still no sparse expert capacity

Example Architectures

Large decoder-only language models often mention expert count and top-k routing in their architecture summaries when they adopt MoE blocks.

Limitations And Tradeoffs

MoE adds routing, capacity management, and load-balancing concerns that dense feed-forward layers do not have. It can raise total capacity efficiently, but the training and serving story becomes more complex.

Why It Still Matters

Sparse expert routing remains one of the clearest ways to separate total parameter count from active per-token compute, so readers keep encountering MoE whenever scaling tradeoffs come up.

Tags

References

  1. Shazeer, Noam, et al. "Outrageously Large Neural Networks: The Sparsely-Gated Mixture-of-Experts Layer." arXiv, 2017, https://arxiv.org/abs/1701.06538.