TopK⁡(G(x))\operatorname{TopK}(\mathcal{G}(\mathbf{x}))

Mixture-of-experts routing

A small gate network scores every expert for a token, only the K highest-scoring experts run, and their outputs are combined using the gate's weights.

G(x)\mathcal{G}(\mathbf{x}) (curly G, the gate) gives one score per expert. TopK⁡\operatorname{TopK} keeps the KK best, for example 8 of 64 in a fine-grained design, or 2 of 16 in a coarser one. gi(x)g_i(\mathbf{x}) is the weight for chosen expert ii's output. NEN_E is the total number of experts. The parameter count grows with the number of experts, but the compute per token grows only with KK.

The difficulty is balance. Left alone, the gate tends to send most tokens to a few favorite experts. The auxiliary loss Laux\mathcal{L}_{\text{aux}} sums fiPif_i P_i over experts, where fif_i is the fraction of tokens sent to expert ii and PiP_i its average gate probability. That sum is smallest when tokens are spread evenly.

Where the course uses it

Related terms