Skip to content
StackDecode
LLM Library
Inside the TransformerAnimated

Mixture of Experts

Many expert networks, but only a few run for each token.

The idea

A router scores the experts for each token and sends it to the top few. The model can have hundreds of billions of parameters while using only a small fraction per token.

Watch it work

Press play, pause, or step through. Some animations have settings you can change.

"The"routerE1E2E3E4E5E6E7E8
  • chosen expert
  • running

The token "The" goes to the router, which scores all 8 experts.

1/15

This router is random, to show the mechanism. Real routers are learned.

Step by step

  1. 1Replace the feed-forward layer with several experts
  2. 2A router scores experts for each token
  3. 3The top-k experts run
  4. 4Their outputs are mixed by router weights

Where it is used

Mixtral, DeepSeek V3, Qwen3 MoE, Llama 4, gpt-oss and others.

Watch out for

All experts still need memory, and training must keep the load balanced.