# Mixtral of Experts

Albert Q. Jiang, Alexandre Sablayrolles, Antoine Roux, Arthur Mensch, Blanche Savary, Chris Bamford and 20 more · arXiv · 2024-1-8

- **Problem** Dense language models spend full compute on every parameter for every token, so adding capacity also raises inference cost. Sparse mixture-of-experts layers try to decouple total parameter count from per-token compute.
- **Method** Replaces each feedforward block with eight SwiGLU experts and a top-2 gating network that picks two experts per token in each layer, combining their outputs with routing weights.
- **Results** Reached 74.4% on GSM8K against 69.6% for Llama 2 70B, using 13B active parameters per token.

![Figure 1: Mixture of Experts Layer. Each input vector is assigned to 2 of the 8 experts by a router. The layer’s output is the weighted sum of the outputs of t…](https://refivu.com/papers/5e1d3fc2-10c6-4121-ba03-4ef4430aadca/figures/figure-addbd1e3714a03aa7007537e37ef27ec.png?thumb=512)

**Figure 1** : Mixture of Experts Layer. Each input vector is assigned to 2 of the 8 experts by a router. The layer’s output is the weighted sum of the outputs of the two selected experts. In Mixtral, an expert is a standard feedforward block as in a vanilla transformer architecture.

[Original paper](https://arxiv.org/abs/2401.04088v1) · [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) · Extracted the figure area from page 2 of the original PDF.

## Adding parameters without adding per-token compute

In a dense model, every weight takes part in every token's forward pass, so more capacity means more compute per token. A sparse mixture of experts breaks that link by keeping several parallel feedforward blocks and letting each token use only a few of them. Mixtral 8x7B applies this inside a decoder-only transformer: each layer holds eight expert blocks, and a router sends every token to two of them.

Because the two chosen experts can differ from one timestep to the next, the model as a whole draws on about 47B parameters, while each token activates about 13B during inference. The two counts matter for different costs: the total count sets the memory needed to serve the model, and the active count sets the inference compute for each token.

## How the router selects and weights experts

The layer output is a sum over the experts, where each expert's output is multiplied by a gate value produced by the gating network. Each expert is an ordinary feedforward function, and the gate values say how much each expert contributes to the token's output.

The gate is \\(G(x) = \\mathrm{Softmax}(\\mathrm{TopK}(x W\_g))\\), where \\(x W\_g\\) is a linear layer producing one logit per expert. TopK keeps the K largest logits and sets the rest to minus infinity, so the softmax gives zero weight to every expert outside the top K. Because the gate is zero for the unselected experts, their outputs never need to be computed, and K sets how much compute each token receives.

For Mixtral, K is 2 and each expert is a SwiGLU block, so the output for an input token \\(x\\) is \\(y = \\sum\_{i=0}^{n-1} \\mathrm{Softmax}(\\mathrm{Top2}(x W\_g))\_i \\cdot \\mathrm{SwiGLU}\_i(x)\\). Only two SwiGLU sub-blocks with different weights process each token, and the layer is applied independently to each token in place of the feedforward sub-block.

Expert layers can run efficiently on a single GPU with specialised kernels, and Megablocks expresses the expert feedforward computation as large sparse matrix multiplications. Across several GPUs, Expert Parallelism sends each token to the GPU that holds its expert and returns the output to the original position, which makes balancing the load across GPUs necessary.

The design resembles GShard, but Mixtral replaces every feedforward block with a mixture-of-experts layer, where GShard replaces every other block. GShard also uses a more elaborate gate for the second expert, which Mixtral does not.

## Benchmark results against Llama 2 70B and GPT-3.5

All models were re-run with the same evaluation pipeline, so the numbers are compared under matching conditions rather than taken from the original reports. The benchmarks cover commonsense reasoning, world knowledge, reading comprehension, math with GSM8K (8-shot, maj@8) and MATH (4-shot, maj@4), code with Humaneval and MBPP, and aggregated tests such as MMLU.

Against Llama 2 70B, Mixtral 8x7B scores 74.4% on GSM8K and 69.6% for Llama 2 70B, and 28.4% on MATH against 13.8%. On HumanEval it scores 40.2% against 29.3%, while using 13B active parameters against 70B for the Llama model. The Figure 3 caption records that Llama 2 70B is better on the reading comprehension benchmarks, so the advantage is not uniform across categories.

Against GPT-3.5, the MMLU gap is small: Mixtral 8x7B scores 70.6% against 70.0% for GPT-3.5 and 69.9% for Llama 2 70B. On MBPP pass@1, Mixtral 8x7B reaches 60.7% against 52.2% for GPT-3.5 and 49.8% for Llama 2 70B, using the hand-verified MBPP subset. On GSM-8K (5-shot) the scores are 58.4% for Mixtral 8x7B, 57.1% for GPT-3.5 and 53.6% for Llama 2 70B.

## Multilingual, long-context and bias results

On French, Mixtral 8x7B scores 58.2% on ARC Challenge and 70.9% on MMLU, against 49.9% and 64.3% for Llama 2 70B. On the other three languages, Mixtral also exceeds Llama 2 70B on ARC Challenge, HellaSwag and MMLU.

Long-context ability is tested with passkey retrieval, a synthetic task in which a passkey is placed at a random position in a long prompt. The authors report 100% retrieval accuracy regardless of context length or passkey position. On a subset of proof-pile, perplexity falls monotonically as the context grows.

BBQ measures social bias across nine categories, and BOLD contains 23,679 English prompts across five domains. On BBQ, Mixtral 8x7B reaches 56.0% accuracy against 51.5% for Llama 2 70B. On BOLD, its average sentiment is higher for gender (0.323 against 0.293) and profession (0.243 against 0.218), and lower for religious ideology (0.144 against 0.188).

Political ideology has a higher average (0.186 against 0.149), and race is unchanged at 0.232, with the standard deviation larger for Mixtral in profession and political ideology. The authors read the BBQ and sentiment results as less bias for Mixtral, though the BOLD pattern is mixed across groups.

## The instruct variant and human preference scores

Mixtral 8x7B – Instruct is trained first with supervised fine-tuning on an instruction dataset, and then with Direct Preference Optimization on a paired feedback dataset. The preference step is what separates the instruct model from a plain fine-tuned model in this description.

On MT-Bench, Mixtral 8x7B – Instruct scores 8.30, slightly below the 8.32 for GPT-3.5-Turbo (gpt-3.5-turbo-1106) and above the 6.86 for Llama 2 70B. The authors describe it as the best open-weights model at the time of the December 2023 release.

The LMSys leaderboard screenshot from 22 December 2023 gives Mixtral 8x7B Instruct v0.1 an Arena Elo rating of 1121. That is above Claude-2.1 (1117), Gemini Pro (1111) and Llama-2-70b-chat (1077), with the best GPT-3.5-Turbo version at 1117.

## What the router's expert choices show

The routing analysis measures the share of tokens sent to each expert on validation subsets of The Pile, at layers 0, 15 and 31. Figure 7 shows the expert proportions per domain, and the 1/8 uniform line marks the expected share for each expert. No obvious topic-specific pattern appears, and only DM Mathematics differs marginally from the other domains.

The authors attribute that marginal divergence to the synthetic nature of that dataset and its limited coverage of natural language.

The routing follows syntax more than topic: words like 'self' in Python and 'Question' in English tend to go to the same expert across their subword tokens. Indentation tokens in code are assigned to the same experts, mostly at the first and last layers.

Consecutive tokens often share an expert, and Table 5 gives the repetition rate per domain and layer. At layer 0 the first-choice repetition rate is 13.6% to 14.9%, close to the 12.5% expected under random assignment. At layer 15 it ranges from 23.6% to 28.4%, with 27.9% for ArXiv, and layer 31 values are also well above random. The authors read this as temporal locality in the router at higher layers, which is why Figure 10 shows repeated assignments above the uniform level.

Locality of this kind has two implications: heavily reused experts can be overloaded under Expert Parallelism, and the same locality could be used for caching, as an offloading method does.

## Limits of the efficiency argument

Inference compute tracks the 13B active parameters, but serving memory tracks the 47B sparse count, which is still smaller than Llama 2 70B. The routing mechanism adds overhead, and running more than one expert per device increases memory loads, so the layers suit batched workloads with high arithmetic intensity.

Expert Parallelism needs an even spread of tokens across GPUs, and the repetition seen in the routing analysis can overload particular experts. The throughput and latency advantages stated in the introduction rest on active parameter counts; the text gives no measured latency or throughput figures.

The passkey task is synthetic, and the perplexity result covers only a subset of proof-pile. Some Llama 2 scores were obtained with changed protocols: MBPP uses the hand-verified subset and TriviaQA is run without Wikipedia contexts.

## Paper info

- **Authors**: 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
- **Venue**: arXiv · Preprint
- **First published**: 2024-1-8
- **Added**: 2026-10-20
- **Updated**: 2024-1-8
- **Version**: v1
- **arXiv**: 2401.04088
- **Category**: cs.LG · cs.CL
- **Original paper terms**: [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/)
- **What we show**: Paper info, commentary and permitted figures from the original paper

[Original paper ↗](https://arxiv.org/abs/2401.04088v1) · [PDF ↗](https://arxiv.org/pdf/2401.04088v1)

AI commentary is a separate explanation from the original paper and may contain errors. The original paper and figures follow each source's terms of use and any rights noted separately.

## Abstract

We introduce Mixtral 8x7B, a Sparse Mixture of Experts (SMoE) language model. Mixtral has the same architecture as Mistral 7B, with the difference that each layer is composed of 8 feedforward blocks (i.e. experts). For every token, at each layer, a router network selects two experts to process the current state and combine their outputs. Even though each token only sees two experts, the selected experts can be different at each timestep. As a result, each token has access to 47B parameters, but only uses 13B active parameters during inference. Mixtral was trained with a context size of 32k tokens and it outperforms or matches Llama 2 70B and GPT-3.5 across all evaluated benchmarks. In particular, Mixtral vastly outperforms Llama 2 70B on mathematics, code generation, and multilingual benchmarks. We also provide a model fine-tuned to follow instructions, Mixtral 8x7B - Instruct, that surpasses GPT-3.5 Turbo, Claude-2.1, Gemini Pro, and Llama 2 70B - chat model on human benchmarks. Both the base and instruct models are released under the Apache 2.0 license.

## Quote from the paper

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 et al. (2024). Mixtral of Experts. arXiv:2401.04088v1. https://arxiv.org/abs/2401.04088v1

**BibTeX**

```
@misc{jiang2024mixtral,
  title = {{Mixtral of Experts}},
  author = {Albert Q. Jiang and Alexandre Sablayrolles and Antoine Roux and Arthur Mensch and Blanche Savary and Chris Bamford and Devendra Singh Chaplot and Diego de las Casas and Emma Bou Hanna and Florian Bressand and Gianna Lengyel and Guillaume Bour and Guillaume Lample and Lélio Renard Lavaud and Lucile Saulnier and Marie-Anne Lachaux and Pierre Stock and Sandeep Subramanian and Sophia Yang and Szymon Antoniak and Teven Le Scao and Théophile Gervet and Thibaut Lavril and Thomas Wang and Timothée Lacroix and William El Sayed},
  year = {2024},
  eprint = {2401.04088},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2401.04088v1}
}
```

## Other paper commentary

- [Why Self-Distillation Helps and Hurts: Denoising vs. Signal Forgetting](https://refivu.com/en/papers/c70638c0-8d0a-4b89-9840-3a8ed7406fca-why-self-distillation-helps-and-hurts-denoising-vs.md)
- [Don’t Drop Dropout: Optimizing Layer Sparsity for Efficient LLM Training and Inference](https://refivu.com/en/papers/c6799446-0a64-4c27-835e-5fb01a7e9ecb-don-t-drop-dropout-optimizing-layer-sparsity-for.md)
- [Improving the Robustness-Utility Trade-off in Decentralized Learning over Sparse Networks](https://refivu.com/en/papers/0021685e-ff0c-4ec9-8010-954978eb5ca1-improving-the-robustness-utility-trade-off-in-decentralized.md)
- [EntroKV: Entropy-Guided Dynamic Budget Allocation for KV-Cache Compression](https://refivu.com/en/papers/057d5e1a-3097-4692-bf08-f2e331814f7d-entrokv-entropy-guided-dynamic-budget-allocation-for-kv.md)
- [CoT-Proxy: Cross-Format Transfer for Distilling Long-Horizon Policies](https://refivu.com/en/papers/133530c1-3978-43b6-aece-30ba42baee72-cot-proxy-cross-format-transfer-for-distilling-long.md)
- [RSA-CP: Efficient Conformal Prediction in Small-Sample Regimes via Random Score Alignment](https://refivu.com/en/papers/21bdc1a9-8a21-4757-b322-ec7470296d48-rsa-cp-efficient-conformal-prediction-in-small-sample.md)
- [PaLM: Scaling Language Modeling with Pathways](https://refivu.com/en/papers/31a94910-97f3-470b-a240-6c8b698de722-palm-scaling-language-modeling-with-pathways.md)
- [Mistral 7B](https://refivu.com/en/papers/9993f1cb-8618-4aeb-9dc5-d4a5aa598381-mistral-7b.md)
- [High-Resolution Image Synthesis with Latent Diffusion Models](https://refivu.com/en/papers/33bd1500-c829-47e5-9545-ad078523241e-high-resolution-image-synthesis-with-latent-diffusion-models.md)
- [Scaling Laws for Neural Language Models](https://refivu.com/en/papers/0b00379f-9c4e-4d81-be48-4963190a673b-scaling-laws-for-neural-language-models.md)
- [Exploring the Limits of Transfer Learning with a Unified Text-to-Text Transformer](https://refivu.com/en/papers/d6599844-fea7-4829-8f9f-c8bdc6543855-exploring-the-limits-of-transfer-learning-with-a.md)
- [Language Models are Few-Shot Learners](https://refivu.com/en/papers/82602214-e941-40a1-bc42-5b92c1268a53-language-models-are-few-shot-learners.md)

## Terms in this paper

- [Transformer](https://refivu.com/en/terms/48e8be2570bc-transformer)
- [supervised fine-tuning](https://refivu.com/en/terms/1a2c1f079517-supervised-fine-tuning)
- [SwiGLU](https://refivu.com/en/terms/9b64288c190e-swiglu)
- [Direct Preference Optimization](https://refivu.com/en/terms/81ed2010f707-direct-preference-optimization)
- [GPT-3.5](https://refivu.com/en/terms/30414fb33dba-gpt-3-5)
- [The Pile](https://refivu.com/en/terms/fd2fd47693ec-the-pile)
- [BOLD](https://refivu.com/en/terms/11baeeb98524-bold)
- [MT-Bench](https://refivu.com/en/terms/0cad66f1f433-mt-bench)
- [BBQ](https://refivu.com/en/terms/22404d47b03a-bbq)
- [Expert Parallelism](https://refivu.com/en/terms/730d0f2b6260-expert-parallelism)
- [gating network](https://refivu.com/en/terms/e7cdc00558dc-gating-network)
- [GShard](https://refivu.com/en/terms/a8742b1fc36e-gshard)
- [Megablocks](https://refivu.com/en/terms/83fee96cd210-megablocks)
- [passkey retrieval](https://refivu.com/en/terms/5c967bdf0089-passkey-retrieval)

---

AI-written text can contain mistakes. [Refivu](https://refivu.com/en/papers/5e1d3fc2-10c6-4121-ba03-4ef4430aadca-mixtral-of-experts)
