Paper · 2024-01-08 · cs.LG, cs.CL
Mixtral of Experts
Mixtral 8x7B is a decoder-only Transformer whose feed-forward blocks are 8 SwiGLU experts. A linear router picks 2 experts per token per layer, so 47B parameters are stored and 13B are active per token. Trained with a 32k context, it matches or beats Llama 2 70B and GPT-3.5 on most author-run benchmarks. The instruct model is SFT and DPO tuned (author-reported).
Mixture of experts (MoE)Grouped-query attention (GQA)Instruction tuningPreference optimizationmixture-of-expertslanguage-modelinference
arXivPDFCodeMarkdown12 min read
AI-compiled by claude-haiku-5-5 on 2026-10-24, not yet reviewed by a human. Every claim cites its source; check it when a detail matters.
In plain words
Most language models use every part of their network for every word they process. Mixtral changes that inside each of its 32 layers. The feed-forward part of each layer is split into 8 separate sub-networks, called experts, and a small router decides which 2 of them handle each token. The other 6 stay idle for that token.
The effect is a model that stores a lot of knowledge but does only a fraction of the work per token. The paper reports about 47 billion parameters in total and about 13 billion used for any one token. The rest of the design follows its predecessor, Mistral 7B. The model reads up to 32,000 tokens of context, and the authors report that it matches or beats Llama 2 70B and GPT-3.5 on most of the benchmarks they ran. An instruction-tuned version is also released.
The trade-off is memory. All 47 billion parameters must still be stored, and the authors say sparse layers suit batched workloads better.
TL;DR
Mixtral 8x7B is a sparse mixture-of-experts Transformer with open weights
under Apache 2.0 §1. Each layer has 8 SwiGLU experts, and a linear router
sends each token to the top 2, mixing their outputs with softmax weights
§2.1. It has about 47B total and 13B active parameters and a 32k dense
context §2 §3. Author-reported results match or beat Llama 2 70B and
GPT-3.5 on most benchmarks, and the code is the official mistral-src repository.
Problem
Dense models spend the same compute on every token, so raising quality means raising the cost of every forward pass. The paper aims for a model with more parameters but without a matching rise in per-token compute, and it reports quality that matches or beats Llama 2 70B §1 §2.1. Sparse mixture-of-experts layers offer that, but the paper names two costs: the routing overhead, and the need to balance work across GPUs when experts are spread over devices §2.1. The target context is a fully dense 32k tokens §2.
Method
Mixtral reuses the Mistral 7B architecture, with two stated changes: it keeps a fully dense 32k context, and every feed-forward block is replaced by a mixture-of-experts layer §2. The main model dimensions are in tab. 1: 32 layers, model width 4096, 32 query heads with 8 key/value heads, and 8 experts with 2 used per token tab. 1.
Sparse mixture-of-experts layer §2.1. The layer output combines the expert outputs, each scaled by a gate value from a gating network [§2.1, display 1]. The paper uses the top-K softmax form: the gate keeps the K largest router logits and applies a softmax over only those §2.1, display 2. For Mixtral, K = 2 §2.1. The expert is a SwiGLU feed-forward block §2.1. The full token output is given in §2.1, display 3.
Steps for one token in one layer. The reference implementation applies this per token, to a whole batch at once, grouped by expert moe.py.
- The token passes through the attention block of the layer, which is the Mistral 7B style with 8 key/value heads shared by 32 query heads §2 tab. 1 transformer_layers.py.
- A bias-free linear router maps the token to 8 logits, one per expert §2.1 transformer_layers.py.
- The top 2 logits are selected, and softmax is taken over those two only, so their weights sum to 1 §2.1, display 2 moe.py.
- Each selected SwiGLU expert runs on the token. Its output is multiplied by its weight and summed §2.1, display 3 moe.py.
- The layer's output is added back to the residual stream. The paper does not describe this step in detail, and the normalisation details are in the code only transformer_layers.py.
# Sparse MoE feed-forward for one token [§2.1, display 2-3]
# Input: x (dim,); router weight (n_experts, dim); experts (SwiGLU)
# Output: y (dim,)
def moe_feed_forward(x, router_weight, experts, k):
# Bias-free router logit per expert [§2.1]
logits = router_weight @ x # (n_experts,)
# Keep the k largest logits [§2.1, display 2]
top_indices = top_k_indices(logits, k) # (k,)
# Softmax over kept logits only, so weights sum to 1 [code: moe.py#L26-L27]
weights = softmax(logits[top_indices]) # (k,)
y = zeros_like(x)
# Weighted sum of the selected expert outputs [§2.1, display 3]
for weight, index in zip(weights, top_indices):
y = y + weight * experts[index](x)
return y# SwiGLU expert [§2.1] [code: transformer_layers.py#L96-L106]
# Input: x (dim,); w1, w3 (hidden_dim, dim); w2 (dim, hidden_dim)
# Output: (dim,)
def swiglu_expert(x, w1, w3, w2):
# Gate branch passes through SiLU [code: transformer_layers.py#L105-L106]
gate = silu(w1 @ x) # (hidden_dim,)
# Linear branch, multiplied elementwise with the gate [§2.1]
up = w3 @ x # (hidden_dim,)
return w2 @ (gate * up) # (dim,)Routing and expert placement §2.1. Experts can run on one GPU with sparse kernels (MegaBlocks is cited) or be spread across GPUs with expert parallelism. In the second case, tokens are routed to the GPU that holds their expert and the output is sent back. The paper notes that this can unbalance the work across GPUs.
Context §2 §3.2. The model is trained with a 32k context. The passkey retrieval test in §3.2 reports 100% accuracy regardless of context length or position. Perplexity on a long-document subset falls as context grows §3.2 fig. 4.
Instruction model §4. Supervised fine-tuning on an instruction dataset is followed by Direct Preference Optimization §4. The fine-tuning data and hyperparameters are not stated.
Hyperparameters
Architecture values are from tab. 1. Other values are stated where shown.
| Name | Value | Where | Notes |
|---|---|---|---|
layers (n_layers) | 32 | tab. 1 | |
model width (dim) | 4096 | tab. 1 | |
| head dimension | 128 | tab. 1 | 32 heads × 128 = 4096 |
query heads (n_heads) | 32 | tab. 1 | |
key/value heads (n_kv_heads) | 8 | tab. 1 transformer_layers.py | Shared by 4 query heads each |
expert hidden size (hidden_dim) | 14336 | tab. 1 transformer_layers.py | Per expert |
| experts per layer | 8 | tab. 1 §2.1 | |
| experts per token (K) | 2 | tab. 1 §2.1 | |
| context length | 32768 | tab. 1 §2 | Dense, no sliding window §2 |
| vocabulary size | 32000 | tab. 1 | |
| total parameters | about 47B | §3 | Sparse count, stored in memory |
| active parameters per token | about 13B | §3 tab. 2 | |
| router | linear, no bias | §2.1 transformer_layers.py | |
| expert activation | SwiGLU | §2.1 transformer_layers.py | |
| RMSNorm epsilon | not stated | paper | Code default is 1e-6 transformer_layers.py; the model's own value comes from its config, which is not in the repo args.py |
| RoPE base theta | not stated | paper | Code uses 1e6 when unset transformer.py |
| sliding window | none (dense) | §2 | Code supports one args.py; the released config value is not in the repo |
| pretraining learning rate, optimizer, batch size, training tokens | not stated | paper | |
| load-balancing or auxiliary loss | not stated | paper | |
| expert capacity factor / token dropping | not stated | paper | Code has no capacity limit moe.py |
| SFT and DPO hyperparameters, DPO beta | not stated | §4 |
Results
Author-reported. The authors re-ran every baseline with their own evaluation pipeline §3. The setting for each row is given in the bullets below.
Evaluation protocol §3. Commonsense reasoning is 0-shot (Hellaswag, Winogrande, PIQA, SIQA, OpenbookQA, ARC-E, ARC-C, CommonsenseQA). World knowledge is 5-shot (NaturalQuestions, TriviaQA). Reading comprehension is 0-shot (BoolQ, QuAC). Math is GSM8K 8-shot with maj@8 and MATH 4-shot with maj@4. Code is HumanEval 0-shot and MBPP 3-shot. Aggregates are MMLU 5-shot, BBH 3-shot and AGI Eval 3-5-shot, English multiple choice only §3.
Base model vs Llama 2 and Mistral 7B tab. 2. Scores are percentages as reported.
| Model | Active params | MMLU | HellaS | WinoG | PIQA | Arc-e | Arc-c | NQ | TriQA | HumanE | MBPP | Math | GSM8K |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| LLaMA 2 7B | 7B | 44.4 | 77.1 | 69.5 | 77.9 | 68.7 | 43.2 | 17.5 | 56.6 | 11.6 | 26.1 | 3.9 | 16.0 |
| LLaMA 2 13B | 13B | 55.6 | 80.7 | 72.9 | 80.8 | 75.2 | 48.8 | 16.7 | 64.0 | 18.9 | 35.4 | 6.0 | 34.3 |
| LLaMA 1 33B | 33B | 56.8 | 83.7 | 76.2 | 82.2 | 79.6 | 54.4 | 24.1 | 68.5 | 25.0 | 40.9 | 8.4 | 44.1 |
| LLaMA 2 70B | 70B | 69.9 | 85.4 | 80.4 | 82.6 | 79.9 | 56.5 | 25.4 | 73.0 | 29.3 | 49.8 | 13.8 | 69.6 |
| Mistral 7B | 7B | 62.5 | 81.0 | 74.2 | 82.2 | 80.5 | 54.9 | 23.2 | 62.5 | 26.2 | 50.2 | 12.7 | 50.0 |
| Mixtral 8x7B | 13B | 70.6 | 84.4 | 77.2 | 83.6 | 83.1 | 59.7 | 30.6 | 71.5 | 40.2 | 60.7 | 28.4 | 74.4 |
Source: tab. 2. The paper's caption says Mixtral matches or beats Llama 2 70B on almost all benchmarks with about 5x fewer active parameters tab. 2. Llama 2 70B is ahead on HellaSwag, WinoGrande and TriviaQA tab. 2.
Against Llama 2 70B and GPT-3.5 tab. 3. These rows use different protocols from tab. 2, as noted in the pitfalls.
| Setting | LLaMA 2 70B | GPT-3.5 | Mixtral 8x7B | Source |
|---|---|---|---|---|
| MMLU (5-shot, MCQ in 57 subjects) | 69.9% | 70.0% | 70.6% | tab. 3 |
| HellaSwag (10-shot) | 87.1% | 85.5% | 86.7% | tab. 3 |
| ARC Challenge (25-shot) | 85.1% | 85.2% | 85.8% | tab. 3 |
| WinoGrande (5-shot) | 83.2% | 81.6% | 81.2% | tab. 3 |
| MBPP (pass@1) | 49.8% | 52.2% | 60.7% | tab. 3 |
| GSM-8K (5-shot) | 53.6% | 57.1% | 58.4% | tab. 3 |
| MT Bench (instruct models) | 6.86 | 8.32 | 8.30 | tab. 3 |
Multilingual §3.1 tab. 4. Scores are percentages.
| Model | Active params | French ARC-c | French HellaS | French MMLU | German ARC-c | German HellaS | German MMLU | Spanish ARC-c | Spanish HellaS | Spanish MMLU | Italian ARC-c | Italian HellaS | Italian MMLU |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| LLaMA 1 33B | 33B | 39.3 | 68.1 | 49.9 | 41.1 | 63.3 | 48.7 | 45.7 | 69.8 | 52.3 | 42.9 | 65.4 | 49.0 |
| LLaMA 2 70B | 70B | 49.9 | 72.5 | 64.3 | 47.3 | 68.7 | 64.2 | 50.5 | 74.5 | 66.0 | 49.4 | 70.9 | 65.1 |
| Mixtral 8x7B | 13B | 58.2 | 77.4 | 70.9 | 54.3 | 73.0 | 71.5 | 55.4 | 77.6 | 72.5 | 52.8 | 75.1 | 70.9 |
Long context §3.2 fig. 4. Passkey retrieval reaches 100% accuracy in the reported setting, regardless of context length or passkey position. The text does not state the exact lengths tested.
Bias §3.3. BBQ accuracy: LLaMA 2 70B 51.5%, Mixtral 56.0%. BOLD sentiment (average ± standard deviation):
| BOLD group | LLaMA 2 70B | Mixtral 8x7B |
|---|---|---|
| gender | 0.293 ± 0.073 | 0.323 ± 0.045 |
| profession | 0.218 ± 0.073 | 0.243 ± 0.087 |
| religious ideology | 0.188 ± 0.133 | 0.144 ± 0.089 |
| political ideology | 0.149 ± 0.140 | 0.186 ± 0.146 |
| race | 0.232 ± 0.049 | 0.232 ± 0.052 |
Instruction model §4. MT-Bench score 8.30 (see tab. 3); the authors describe it as the best open-weights model at the time of writing. The authors also report an LMSys Chatbot Arena Elo of 1121 for the instruct model, against 1117 for Claude-2.1 and the best GPT-3.5-Turbo, 1111 for Gemini Pro and 1077 for Llama-2-70b-chat, from a snapshot dated 22 December 2023 §4.
Routing analysis §5 tab. 5. The first-choice expert is picked about 12.5% of the time under uniform routing. Measured first-choice repetition on consecutive tokens is close to random at layer 0 and well above random at layers 15 and 31. Repetition of either first or second choice is about 46% under uniform routing.
| Domain | First choice L0 | L15 | L31 | First or second L0 | L15 | L31 |
|---|---|---|---|---|---|---|
| ArXiv | 14.0% | 27.9% | 22.7% | 46.5% | 62.3% | 52.9% |
| DM Mathematics | 14.1% | 28.4% | 19.7% | 44.9% | 67.0% | 44.5% |
| Github | 14.9% | 28.1% | 19.7% | 49.9% | 66.9% | 49.2% |
| Gutenberg | 13.9% | 26.1% | 26.3% | 49.5% | 63.1% | 52.2% |
| PhilPapers | 13.6% | 25.3% | 22.1% | 46.9% | 61.9% | 51.3% |
| PubMed Abstracts | 14.2% | 24.6% | 22.0% | 48.6% | 61.6% | 51.8% |
| StackExchange | 13.6% | 27.2% | 23.6% | 48.2% | 64.6% | 53.6% |
| Wikipedia (en) | 14.4% | 23.6% | 25.3% | 49.8% | 62.1% | 51.8% |
Source: tab. 5 §5. The authors find no clear topic specialisation of experts §5 fig. 7.
Paper vs code
Code: the official repository mistralai/mistral-src at code_commit
9eaeb91c17450e09021b6065a1d5cc69876507c8, Apache-2.0 LICENSE. It is
linked from the paper's abstract §1. The repository also documents 8x22B
checkpoints README.md, which this card does not cover.
- Routing and gating. Consistent. The paper's top-K softmax §2.1, display 2 matches the code's top-k then softmax over the k logits moe.py. The router has no bias §2.1 and is a bias-free linear layer transformer_layers.py.
- Expert function. Consistent. SwiGLU §2.1 matches the code's SiLU-gated feed-forward transformer_layers.py.
- Where MoE applies. Consistent. The paper replaces every feed-forward block §2. The code builds an MoE layer in each transformer block when the model config has
moeset transformer_layers.py transformer.py. - Context length. The paper states a 32k dense context §2 tab. 1. The code's RoPE table is precomputed for 128,000 positions transformer.py. This is a capacity of the code, not a claim in the paper.
- Sliding window. The paper says the context is dense §2. The code supports an optional sliding window args.py, and the value for the released model is not in this repo. It cannot be verified here.
- RoPE base and norm epsilon. Not stated in the paper. The code uses defaults of 1e6 transformer.py and 1e-6 transformer_layers.py when the model config omits them. The released model's config values are not in this repo.
- Evaluation pipeline. The paper uses its own evaluation harness §3. This repo has no benchmark harness (searched for MMLU, HellaSwag and GSM8K). The results in tab. 2 and tab. 3 cannot be reproduced from this repo.
- Training. The repo is for inference. The paper states no training objective for the MoE router, and the repo has none, so it is not stated.
No discrepancies found in the MoE math, expert function or placement.
Pitfalls
- "47B tokens" in the text. The comparison text says the model has "47B tokens compared to 70B" §3. It means 47B parameters. Implement the 47B figure as parameters, not tokens.
- MT-Bench reference. The instruct section points to tab. 2 for the MT-Bench score §4. Table 2 has no MT-Bench column. The 8.30 score is in tab. 3.
- Protocols differ between tables. GSM8K is 8-shot with maj@8 in §3 and tab. 2 (74.4%), but 5-shot in tab. 3 (58.4%). The MBPP number in tab. 2 uses the hand-verified subset §3. Do not compare numbers across tab. 2 and tab. 3 as if they share a protocol.
- TriviaQA without context. The authors did not provide Wikipedia context for TriviaQA, which differs from the Llama 2 paper's setup §3. Their Llama numbers are re-runs, not copied from Llama 2.
- Memory is 47B, compute is 13B. The paper states that memory cost follows the 47B sparse count, which is still below Llama 2 70B §3. It also says the routing and extra memory loads add overhead, and that sparse layers suit batched workloads §3. No latency or throughput measurements are given in the text.
- Renormalised top-2 weights. The gate weights sum to 1 over the two selected experts only. The weights of the other six experts are not part of the output, so the softmax is not over all eight. Code computes the softmax in float32 and casts back to the input dtype moe.py.
- Load balancing is open. The paper names load balancing as a challenge under expert parallelism §2.1. No auxiliary loss, capacity limit or token dropping is described in the paper, and the repo's inference path has none moe.py. Do not assume one.
- Reference loop is not the paper's kernel. The reference MoE layer loops over the experts and scatters results back moe.py. The paper points to sparse kernels (MegaBlocks) and to vLLM integration §1 §2.1. The repo's loop is a different implementation from those.
- Context ceiling. The paper trains at 32k §2. The code allows 128,000 positions in its RoPE table transformer.py. The paper's long-context evaluation does not state the lengths it tested §3.2.
- Routing analysis is descriptive. The routing measurements use subsets of The Pile validation set §5. The paper gives no statistical tests for them, so treat the figures as descriptive.
- Instruct results are snapshots. The MT-Bench and arena numbers depend on the judge and on a dated leaderboard snapshot §4 fig. 6.
- Figure and table numbers. The LaTeX source has no compiled PDF in
raw/src. Figure and table numbers here follow caption order in the source. Check them against the PDF before relying on them. - Equations are unnumbered. The paper's displayed equations have no numbers. They are cited here as "display 1", "display 2" and "display 3" in §2.1, counted in source order.
Lineage
- Builds on: Mistral 7B, whose modifications Mixtral reuses §2. The preference-tuning step uses DPO §4.
- Related sparse-expert work named in the paper: the sparsely-gated MoE layer (arXiv:1701.06538) §2.1; GShard (arXiv:2006.16668), which replaces every other block and uses a different second-expert gate §2.1; MegaBlocks (arXiv:2211.15841) for sparse kernels §2.1. No cards exist for these, so nothing from them is used here.
- Compared against: LLaMA 2 70B (arXiv:2307.09288) tab. 2 tab. 3; GPT-3.5, Claude-2.1 and Gemini Pro §4 (no arXiv ids in the paper).
- Superseded by: not known from wiki content.
Source and license
Adapted from “Mixtral of Experts” by Albert Q. Jiang, Alexandre Sablayrolles, Antoine Roux, Arthur Mensch, Blanche Savary, Chris Bamford, Devendra Singh Chaplot, Diego de las Casas, Emma Bou Hanna, Florian Bressand, Gianna Lengyel, Guillaume Bour, Guillaume Lample, Lélio Renard Lavaud, Lucile Saulnier, Marie-Anne Lachaux, Pierre Stock, Sandeep Subramanian, Sophia Yang, Szymon Antoniak, Teven Le Scao, Théophile Gervet, Thibaut Lavril, Thomas Wang, Timothée Lacroix, William El Sayed (arXiv:2401.04088), used under CC BY 4.0. Changes: condensed and restructured for implementation, with tables, equations and algorithms taken from the paper and its code, each cited to its source. Not affiliated with or endorsed by the authors. Code citations refer to https://github.com/mistralai/mistral-src at commit 9eaeb91c1745 (Apache-2.0). Any quoted code is shown under that license.