AI State of the Art
Ecosystem/Annotated Foundational Papers/11 min
Section 305

"Mixtral of Experts" (2024)

Listen as a podcast →

The Brilliant Idea: Don't Activate Everything

Imagine you have a team of 8 specialists. A math expert, a history expert, a code expert, etc. When someone asks you a math question, you don't mobilize all 8: you just send the 2 best ones for that question. The others stay on standby.

That's exactly what Mixtral 8x7B does. Instead of activating all parameters for every token (like a classic Transformer does), the model selects only the most relevant experts.

Mixtral 8x7B: 8 experts, top-2 activated per token. 47B total parameters. 13B activated at any given time. The quality of a 70B model. The inference costs of a 13B model.

It's an incredible deal.

MoE: Not New, But Finally Accessible

The Mixture of Experts concept has existed since 1991 (Jacobs et al.). Google explored it with Switch Transformer in 2021. But it was Mixtral that made it popular and especially open-source. Before Mixtral, MoE remained a lab thing. After Mixtral, it became a standard architecture that everyone adopts.

Architecture: How It Actually Works

In a classic Transformer, each layer contains an attention block and a feed-forward network (FFN). The FFN is the computationally "heavy" part: that's where the model stores its knowledge.

Mixtral replaces this single FFN with 8 parallel FFNs (the "experts") plus a small network called the router.

The router is a simple linear network. For each token, it produces a score for each of the 8 experts, then selects the top-2. The other 6 experts? Not activated, no computation, no cost.

The outputs of the two selected experts are then weighted by the router's scores and summed. It's elegant and simple.

Figure 1 of the Mixtral paper, titled Mixture of Experts Layer. An inputs arrow enters a router box. The router sends two arrows into a stack of identical blocks labelled expert, of which only two are drawn in solid outline while the others are faded and dashed. The outputs of those two experts meet at a circle containing a plus sign, which produces the outputs arrow. A dotted link leaving the router, labelled gating weights, arrives at that same summation circle.
The paper's figure, which fits on one line: the router receives the token, picks two experts out of eight, and their two outputs are summed after being weighted by the router's scores (the dotted gating weights). The faded experts are the ones not activated, they sit in memory but cost no compute for this token.Source : Mixtral of Experts paper (Jiang et al., figure 1), via a paper review on velog

Concretely:

  • 32 layers of Transformer
  • 47B total parameters
  • 13B parameters activated per token (the 2 experts out of 8, plus the shared attention blocks)
  • Context window: 32K tokens

To give an analogy: it's like a restaurant with 8 specialized chefs. For each dish ordered, the head chef selects the 2 most relevant chefs. You get the quality of a restaurant with 8 chefs, but you only pay the salary of 2 at any given time.

Results: The Proof in Numbers

The results are impressive when put in perspective:

  • Outperforms LLaMA 2 70B on nearly all standard benchmarks
  • Rivals GPT-3.5 on conversational tasks
  • Excellent at code and math, two domains where expert specialization particularly helps
  • Very good at multilingual tasks: routing naturally directs tokens to experts who "know" certain languages

In inference, that's where the gain is spectacular: 6x more throughput than LLaMA 2 70B for similar performance. In production, that means 6x fewer GPUs to serve the same number of users.

The Instruct version of Mixtral (fine-tuned for dialogue) achieved ELO scores on Chatbot Arena surpassing GPT-3.5-Turbo and Claude 2.1 at the time of its release. For an open-source model, that was unprecedented.

Total vs Active: The Crucial Distinction

When you compare MoE models, pay attention to what you're comparing. Mixtral has 47B total parameters but only 13B active parameters. Comparing 47B total with LLaMA 70B total isn't fair. The right comparison is inference cost: 13B active vs 70B active. That's where Mixtral wins.

Routing Analysis: Do the Experts Specialize?

A fascinating question: do the experts learn to specialize? Analysis of routing patterns in Mixtral shows that yes, partially.

Similar tokens (same domain, same syntactic type) tend to be routed to the same experts. Domain-specific patterns are observed. But the specialization isn't absolute: an expert doesn't handle "only" math, for example. It's more subtle, more distributed.

Three columns titled Layer 0, Layer 15 and Layer 31, each showing the same three text excerpts: Python code defining a MoeLayer class, a series of mathematics question-and-answer pairs, and a multiple-choice question about a model airplane. Every word or code fragment is highlighted in a colour indicating the first expert chosen for that token. In the Layer 0 column the colours change on almost every word; in the Layer 15 and Layer 31 columns, runs of identical colour appear across consecutive tokens, notably on code keywords and repeated patterns.
Each colour is the expert picked for a given token. You can see exactly what the text above describes: in the deeper layers, tokens of the same kind (Python keywords, indentation, digit runs) repeatedly go to the same expert. But no single colour covers a whole excerpt: there is no math expert and no code expert.Source : Mixtral of Experts paper (Jiang et al., figure 8), via ar5iv

A classic problem with MoE architectures is routing collapse: all tokens end up routed to the same 1-2 experts, and the others are useless. To prevent this, Mixtral uses an auxiliary load-balancing penalty that forces the router to distribute tokens more evenly across experts.

Three stacked bar charts, for layers 0, 15 and 31 of Mixtral. The horizontal axis lists the eight experts numbered 0 to 7, the vertical axis is selection proportion from 0 to 0.20. For each expert, eight coloured bars represent eight datasets: ArXiv, DM Mathematics, Github, Gutenberg, PhilPapers, PubMed Abstracts, StackExchange and Wikipedia in English. A dashed horizontal line marks the 0.125 level. In layer 0 all bars sit very close to that line; in layers 15 and 31 they deviate more, with for instance DM Mathematics clearly above for experts 1 and 2 and clearly below for expert 5.
The dashed line is a perfectly even split, one eighth of the tokens per expert. No bar strays far from it: the load-balancing penalty is doing its job and no expert is left idle. The deviations visible in the deeper layers are the beginnings of the specialization discussed above, but they stay modest.Source : Mixtral of Experts paper (Jiang et al., figure 7), via SuperAnnotate

Impact: MoE Becomes the Norm

Mixtral triggered a wave. After January 2024, MoE architecture became unavoidable:

  • DeepSeek V2/V3: MoE with innovations on attention (Multi-Head Latent Attention)
  • Grok-1 (xAI): 314B parameters in MoE architecture, made open-source
  • LLaMA 4 (Meta): adopts MoE with the Scout and Maverick models
  • Qwen 2.5 MoE (Alibaba): MoE variant of the Qwen family
  • Gemini (Google): also uses MoE internally

MoE is now an industry standard. The intuition is simple: why pay to activate parameters that aren't useful for the current query? That's waste. Intelligent routing solves this problem.

The Challenges of MoE in Practice

MoE isn't without drawbacks. Total memory remains high (all experts must be loaded in VRAM, even if only 2 are active). Load balancing is tricky and can degrade performance if poorly calibrated. And communication overhead between GPUs for routing can become a bottleneck on very large clusters. But for inference, the gains are undeniable.