TL;DR
Mixtral 8x7B is a language model whose feedforward layers are split into eight expert networks. For each token, a small router picks two experts and mixes their outputs, so the model holds 47 billion parameters but uses about 13 billion for any one token. Jiang and colleagues report that it matches or beats Llama 2 70B and GPT-3.5 on most benchmarks, and they release the weights under the Apache 2.0 license.
Builds on: Mixture of Experts, Mistral 7B, Grouped-Query Attention, Sliding Window Attention, RMS Normalization · Leads to: open-weights mixture-of-experts language models, and the instruction-tuned chat version built from the same base.
Why it mattered
Before Mixtral, the best open-weights models were dense: every parameter ran for every token. Mixtral showed that a sparse model with roughly the cost of a 13 billion parameter model could compete with a dense 70 billion parameter model on common benchmarks. The paper's own comparison is the clearest statement of this: Table 2 sets Mixtral against Llama 2 70B with about five times fewer active parameters, and Mixtral still scores higher on several tasks, including mathematics and code.
The release mattered as much as the numbers. The base model and the instruction-tuned model were both published under Apache 2.0, and the authors submitted changes to the open-source vLLM serving project that integrate the Megablocks kernels for sparse experts, so the model could be served with an open stack.
The problem
A dense transformer uses all its weights for each token. To get a better model, you usually make it bigger, which also makes every token more expensive to process. That is a bad trade when a deployment needs low latency or high throughput.
A mixture-of-experts layer offers a different trade. It stores many parameter groups, called experts, and sends each token to only a few of them. The total parameter count grows with the number of experts, while the compute per token grows only with the number of experts chosen. The open question is whether a model built this way can match a dense model that does the same work per token. Mixtral is the paper that answers yes, at a large scale and with an open release.
Three practical issues come with the design. The router must send tokens to experts without making one expert get almost every token, and the authors discuss this under routing. The experts must be spread over several GPUs, which requires expert parallelism. And the whole model must hold 47 billion parameters in memory even though only 13 billion are used per token, so serving cost depends on both numbers.
How it works
Follow one token through one layer. The numbers are small and round, and the router has four experts, of which two are chosen. Mixtral has eight experts and chooses two, but the steps are the same.
- Input. The layer receives the hidden vector for one token. Take a toy that the router turns into four scores, one per expert: .
- Router scores. The router is a linear layer . Here the scores are for experts 1 to 4.
- Top-K selection. Keep the two largest scores, for expert 2 and for expert 4. Set the other two to minus infinity, so they get zero weight. Only experts 2 and 4 will run.
- Softmax over the chosen two. The weights are and , which are about and . They add to 1.
- Expert outputs. Expert 2 processes and returns a toy output of . Expert 4 processes and returns . Experts 1 and 3 never run, which is where the saving comes from.
- Combine. The layer's output is . This replaces the feedforward block's output for this token in this layer.
- Next token. The next token may choose a different pair of experts. The paper finds that the choice follows syntax more than topic, so the same expert can take the same kind of token in code and in prose.
Each expert in Mixtral is a SwiGLU feedforward block, a variant of the gated linear unit. Attention layers are not split, so they are shared by all tokens.
flowchart LR T["Token vector x"] --> R["Router: x times W_g gives 8 scores"] R --> K["Keep top 2 scores, others set to minus infinity"] K --> S["Softmax over the 2 kept scores"] S --> E2["Expert A runs on x"] S --> E4["Expert B runs on x"] E2 --> Y["Weighted sum of the 2 outputs"] E4 --> Y
Worked examples
The three examples below use the paper's formulas on the numbers the paper reports. The first runs a router by hand, the second checks the sparse and active parameter counts, and the third compares the paper's benchmark numbers.
Four experts, , and router scores for one token.
- Top-2 selection: the largest score is (expert 2) and the next is (expert 4). The top-2 vector is .
- Softmax over the two finite values. Compute and . Their sum is .
- Weight for expert 2: . Weight for expert 4: . Check: .
- Suppose expert 2 returns and expert 4 returns for this token. Output: .
- Experts 1 and 3 do not run.
Interpretation: the router chose two of four experts, so half the expert computation was skipped. With eight experts and , a quarter of the expert parameters are touched per token.
The paper reports 47B total parameters and 13B active parameters per token. Write for the parameters that every token uses (attention, embeddings, and the router) and for all the expert parameters together. Assume all eight experts are the same size.
- Total parameters: billion.
- Each token uses two of eight experts, so it uses of . Active parameters: billion.
- Subtract the second equation from the first: , so billion.
- Then billion.
- A rough check from the architecture: attention and the embedding tables, for 32 layers of width 4096, come to about 1.5 to 2 billion parameters. That is consistent with , though this is an estimate, not a figure the paper gives.
Interpretation: almost all of the model is expert weights. Compute per token is set by the 13B active count, but memory must hold all 47B, which is why serving cost depends on both.
Table 2 reports GSM8K (grade-school maths word problems) for Mixtral 8x7B and Llama 2 70B.
- Mixtral 8x7B: 74.4 percent.
- Llama 2 70B: 69.6 percent.
- Difference: points.
- Active parameters: , so Llama 2 70B uses about five times as many parameters per token, matching the paper's "5x".
- On MMLU, the same table gives 70.6 for Mixtral against 69.9 for Llama 2 70B, a gap of 0.7 points.
Interpretation: Mixtral leads on the maths test by a clear margin and on the knowledge test by a small margin, while using about a fifth of the compute per token.
Try it: on the same table, Mixtral scores 40.2 on HumanEval-style code and Llama 2 70B scores 29.3 on the same task. What is the gap in points?
Answer: points.
The math
Definition (the expert layer). Let there be experts , each a feedforward block, and a gating network . For an input vector the layer output is
If most entries of are zero, the experts with zero gates need not run.
Step 1 in symbols (the router logits). The router is a single weight matrix of shape (hidden size) by . Its raw scores for the token are , one number per expert.
Step 2 in symbols (Top-K masking). Let be the number of experts used per token. Define
The softmax of minus infinity is zero, so the masked experts get no weight.
Step 3 in symbols (the gate). The gate is
Because the softmax runs only over the kept scores, the two weights sum to 1 for each token.
Step 4 in symbols (the Mixtral layer). Each expert is a SwiGLU block, and , so the output for one token is
Only two terms in the sum are non-zero, so the cost of the expert part is that of two expert blocks, not eight.
Step 5 in symbols (the two parameter counts). Let be the shared parameters and the total expert parameters. The total count is and the count used per token is . For Mixtral with and , these are and , which is the calculation in Worked example 2.
Results
Benchmarks against Llama 2 70B (Table 2). Mixtral 8x7B has 13B active parameters and Llama 2 70B has 70B. Selected scores (accuracy in percent): MMLU, Mixtral 70.6 against 69.9; HellaSwag, 84.4 against 85.4; Winogrande, 77.2 against 80.4; HumanEval, 40.2 against 29.3; MBPP, 60.7 against 49.8; MATH, 28.4 against 13.8; GSM8K, 74.4 against 69.6; TriviaQA, 71.5 against 73.0. Mixtral is ahead on most maths and code tasks and roughly level on general knowledge. It is behind on some commonsense tasks, so the paper's "matches or outperforms" claim should be read with that in mind.
Multilingual (Table 4). On ARC-Challenge, HellaSwag and MMLU in French, German, Spanish and Italian, Mixtral beats Llama 2 70B in all four languages. For example, in French MMLU it scores 70.9 against 64.3.
Long context (Section 3.2). On the passkey retrieval test, where a random number is hidden in a long prompt, Mixtral reaches 100 percent accuracy for every context length and every position the authors tried, up to the 32k context. Perplexity on a maths corpus falls as the context grows.
Instruction tuning (Section 4). The instruct model reaches a score of 8.30 on MT-Bench, the best open-weights result at the paper's date. Its Arena Elo of 1121 is above Claude-2.1 at 1117 in the leaderboard snapshot the authors show. These are human-preference and judge-based scores, which are noisier than the multiple-choice benchmarks above.
Bias (Section 3.3). On the BBQ question-answering bias benchmark, Mixtral reaches 56.0 percent accuracy against 51.5 percent for Llama 2. On BOLD, its sentiment scores are more positive with similar spread across groups.
Routing (Section 5). Experts do not specialise by topic in any clear way. Across arXiv, maths, GitHub, Wikipedia and other domains, the expert distribution is similar. Consecutive tokens often reuse the same expert: at layer 15 the first-choice repeat rate on arXiv text is 27.9 percent, against 12.5 percent expected for random assignment. The authors suggest this matters for expert parallelism, because a hot expert can become a bottleneck, and for caching.
Limits. The comparisons are the authors' own runs, using their evaluation pipeline, against Llama 2 and GPT-3.5 at a given date. Mixtral still stores 47B parameters, so memory is far above the 13B active count. The routing analysis is descriptive: it shows patterns but does not explain why the router makes the choices it does.
Reading guide
Read the paper in this order. Each section names the lessons it needs.
- Abstract and Section 1, Introduction. Needs Mixture of Experts for the sparse layer and Mistral 7B for the base model Mixtral is built from.
- Section 2, Architectural details (Table 1). Needs Transformer for the block structure, and Grouped-Query Attention, Sliding Window Attention and RMS Normalization for the modifications taken from Mistral 7B.
- Section 2.1, Sparse Mixture of Experts. The core of the paper. Needs Softmax for the gate, Gated Linear Unit (GLU) for the SwiGLU expert, and Mixture of Experts again for the general form. Worked examples 1 and 2 trace this section.
- Section 3, Results. Needs Instruction Tuning only for the chat model in the later sections. The tables are the evidence for the claims above.
- Section 4, Instruction Fine-tuning. Needs Instruction Tuning and Direct Preference Optimization.
- Section 5, Routing analysis. Needs Load-Balancing Loss for why a balanced router matters, and Mixture of Experts for expert parallelism.
Check yourself
QuestionRecall: how many experts does Mixtral 8x7B route each token to, and how many parameters are active per token compared with the total?Show answer
Two experts per token, out of eight. The model has 47 billion parameters in total and uses about 13 billion for each token.
QuestionCompute: a router has four experts and produces scores for a token. Which experts run, and what is the weight of the higher-scoring one?Show answer
The top two scores are (expert 4) and (expert 1). Those two run. The softmax over them gives weight for expert 4, and for expert 1.
QuestionWhy: why does the paper worry about the router sending many tokens to the same expert, and what does it observe?Show answer
If one expert receives most tokens, the GPU that holds it becomes a bottleneck under expert parallelism, and the other GPUs sit idle. The paper observes that consecutive tokens often reuse the same expert, which makes such over-subscription more likely in higher layers. It reports that the expert distribution is roughly even across domains, so the concern is locality rather than topic.
QuestionApplied: a team wants a model with the quality of a 70B dense model but has the memory of a 13B model on a single GPU. What does the paper's design imply?Show answer
The paper's design does not solve this. Mixtral's 13B active count sets its compute cost, but it must still store all 47B parameters, so the memory needed is that of a much larger model, not 13B. The team would need to shard the experts across GPUs or use quantization, and should measure both speed and memory on its own hardware before deciding.
Sources
- Albert Q. Jiang and colleagues, "Mixtral of Experts," arXiv:2401.04088 (2024). https://arxiv.org/abs/2401.04088
- Albert Q. Jiang and colleagues, "Mistral 7B," arXiv:2310.06825 (2023). https://arxiv.org/abs/2310.06825
- Noam Shazeer and colleagues, "Outrageously Large Neural Networks: The Sparsely-Gated Mixture-of-Experts Layer," arXiv:1701.06538 (2017). https://arxiv.org/abs/1701.06538