Log inStart free
LESSON 10.10 · 6 STAGES · 2 CONTROLS · 3 CHECKSPRO · PREVIEW

Dense vs Mixture-of-Experts layers

Watch one MLP become 4 experts, and each token use only some of them.


Pro lesson. Stage 1 is free to watch. Pro opens all 6 stages, 2 controls and 3 checks, in this lesson and every other.

Go Pro · $8.25/mo
EXPLAINER · 10.10 · MOE LAYERDENSE · 96 WEIGHTS · ALL 96 PER TOKEN
01
Stage 1 of 6 · One dense MLP
A dense layer sends every token through one MLP. All 96 weights work on every token.
Explain it simply

On the left you see 8 tokens, each a row of 4 numbers. Every token flows through the same MLP box in the middle. That box holds 96 weights, and all of them work on each token. So every weight you add makes each token cost more.

8 tokens on the left each flow through one MLP box with 96 weights. The output rows sit on the right. The output for cat is (−0.60, −0.22, 0.76, −0.83).

token vectorsweightsrouter shares, gates, layer outputexpert the followed token skips
dense MLP96 weightsW_gate, W_up, W_downthecatsatonmatranrugdogthecatsatonmatranrugdogone dense MLPtokensoutputs96 weights per tokendense MLP96 weightsW_gate, W_up, W_downthecatsatonmatranrugdogthecatsatonmatranrugdogone dense MLPtokensoutputs96 weights per token
Toy: 8 tokens of width 4, 4 experts of 96 weights; random weights, not trained
STAGE 1 / 6
MATH · STAGE 1HOVER A SYMBOL OR A SHAPE
y=(silu(x Wgate)⊙x Wup) Wdown\sy{y}{out}{y} = \big(\mathrm{silu}(\sy{x}{data}{x}\,\sy{w}{param}{W_{\text{gate}}}) \odot \sy{x}{data}{x}\,\sy{w}{param}{W_{\text{up}}}\big)\,\sy{w}{param}{W_{\text{down}}}
ycat=(−0.60, −0.22, 0.76, −0.83)y_{\text{cat}} = (-0.60,\ -0.22,\ 0.76,\ -0.83)

Every token goes through all three weight tables of one MLP.

Common mix-ups

MYTHAn MoE layer runs all its experts on every token.

The fix, and 1 more mix-up with the diagram to show them, come with Pro.

Predict, then reveal
3 CHECKS · PRO
Q01With 1 expert per token, how many weights work on each token?

Make your guess, then test it in the diagram. All 3 checks come with Pro.

PRO LESSON · YOU WATCHED STAGE 1 OF 6
Unlock the full explainer
  • 5 more stages and 2 live controls
  • 2 mix-up cards and 3 predict-then-reveal checks
  • Watch it as a narrated video, in three voices
  • Every Pro lesson and capstone · 656 in total

$99 a year, or $15 a month. Cancel any time.