XYZNOT

Papers · arXiv 2401.04088

Mixtral of Experts

Published cs.LGcs.CL arXivPDF

Read with translation and AI

Summary in three lines

  1. 🎯 Scaling transformer capacity and performance without incurring prohibitive inference latency and compute costs.
  2. 🔧 A Sparse Mixture of Experts (SMoE) decoder-only architecture replacing standard feedforward blocks with 8 SwiGLU experts, selecting 2 experts per token via a learned router.
  3. 📈 Accesses 47B total parameters with only 13B active per token, outperforming Llama 2 70B on MMLU (70.6% vs 69.9%) and GSM8K (74.4% vs 69.6%).

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.

Reading guide

Problem and motivation

Dense autoregressive language models incur computational costs directly proportional to their total parameter count for every processed token. As models scale up to 70B parameters and beyond, serving them at low latency and high throughput becomes computationally expensive. The authors aim to scale model capacity while keeping per-token inference cost comparable to much smaller models, creating an open-weights model capable of matching or outperforming Llama 2 70B and proprietary baselines like GPT-3.5.

Key ideas

  • Sparse Mixture of Experts (SMoE): Replace dense feedforward network (FFN) blocks across all 32 transformer layers with 8 distinct expert networks, routing each token to only the top-2 experts.
  • Decoupled Parameter Counts: The architecture holds 47B total parameters across its layers, but only executes 13B active parameters per token forward pass, matching the computational footprint of a moderate-sized dense model.
  • Full 32k Context Window: Native support for 32,768 token sequence lengths with 100% retrieval accuracy on passkey benchmarks.
  • Syntactic Rather than Topic-Based Routing: Empirical inspection of token routing reveals expert selection is driven primarily by syntactic function and temporal locality rather than high-level topic domains.

Method (with the key equations)

Mixtral modifies the Mistral 7B architecture ( layers, hidden dimension , attention heads, key-value heads) by substituting every FFN sub-block with an MoE module consisting of experts (), each implemented as a SwiGLU network with intermediate dimension .

For an input token representation , a router network computes a sparse gating distribution across experts using the top- logits (): where the Top-K operator assigns to all coordinates outside the largest values of logits :

The layer's overall output is computed as the gating-weighted sum over expert outputs: Efficient execution is achieved through kernels like MegaBlocks, which represent MoE computation as sparse matrix multiplications, alongside Expert Parallelism across multiple GPUs.

Results (with the most important numbers)

  • General & Reasoning Benchmarks: On MMLU (5-shot), Mixtral 8x7B achieves 70.6% compared to 69.9% for Llama 2 70B and 70.0% for GPT-3.5. On GSM8K (8-shot, maj@8), it reaches 74.4% versus 69.6% for Llama 2 70B. On the MATH benchmark (4-shot, maj@4), Mixtral achieves 28.4% versus Llama 2 70B's 13.8%.
  • Code Generation: Mixtral outperforms Llama 2 70B substantially on HumanEval (40.2% vs 29.3%) and MBPP (60.7% vs 49.8%).
  • Multilingual Tasks: Upsampling multilingual data enables Mixtral to exceed Llama 2 70B across French, German, Spanish, and Italian on ARC-Challenge, HellaSwag, and MMLU (e.g., French MMLU: 70.9% vs 64.3%).
  • Instruction Fine-Tuning & Arena Elo: Mixtral 8x7B – Instruct (trained with SFT and Direct Preference Optimization) scores 8.30 on MT-Bench and achieved an LMSys Chatbot Arena Elo of 1121, outperforming Claude-2.1 (1117), GPT-3.5-Turbo (1117), and Llama-2-70b-chat (1077).
  • Context Retrieval: Achieves 100% retrieval accuracy on the synthetic passkey retrieval task across the entire 32k context window.

Limitations and open questions

  • Memory Footprint vs. Compute: While compute cost scales with the 13B active parameters, serving requires enough VRAM to hold all 47B parameters, demanding multi-GPU setups or offloading techniques.
  • Expert Parallelism Bottlenecks: The paper discovers high temporal locality—consecutive tokens share the same expert assignments much more frequently than random chance (up to 28.4% first-choice repetition at layer 15 vs 12.5% random). This can cause load imbalance and over-subscription of specific GPUs under Expert Parallelism.
  • Lack of Topic Specialization: Router selection does not naturally partition by conceptual domains (e.g., biology vs. philosophy), leaving open questions on how to structure gating if domain-specific expert specialization is explicitly desired.

Key terms

Sparse Mixture of Experts (SMoE)
A neural network architecture where conditional computation routes each input token to a sparse subset of feedforward sub-networks (experts) rather than activating all parameters.
Active Parameter Count
The number of parameters actually loaded and computed during inference for a single token, which is 13B in Mixtral compared to its 47B total sparse parameters.
SwiGLU
A gated linear unit activation variant combining Swish and element-wise multiplication used as the internal architecture of each expert feedforward block.
TopK Gating
A routing mechanism that applies a linear projection to the token representation, retains the top-K highest values while masking the rest to negative infinity, and normalizes them via softmax.
Expert Parallelism (EP)
A distributed partitioning strategy that maps different experts to distinct GPUs and routes token activations across devices to their assigned expert.
Direct Preference Optimization (DPO)
An alignment algorithm that optimizes language model parameters directly on preference pairs without training an explicit reinforcement learning reward model.
Passkey Retrieval
A synthetic evaluation test measuring a model's ability to locate and return a short passkey randomly positioned within long context prompts up to 32k tokens.
Positional Locality
The observed tendency where consecutive tokens in a sequence are repeatedly assigned to the same expert far above uniform random probability.

Questions

Why is Mixtral called 8x7B if it only has 47B parameters instead of 56B?

Although there are 8 experts per layer and the architecture is derived from Mistral 7B, the self-attention weights and embedding layers are shared across all experts. Only the feedforward sub-blocks are replicated 8 times, resulting in 47B total parameters rather than 8 × 7B = 56B.

How many experts are activated for each token during inference?

The router selects exactly 2 experts () out of the 8 available experts at each layer for every token, resulting in 13B active parameters per forward pass.

Do different experts specialize in different academic or domain topics?

No obvious domain specialization was found. Analysis on The Pile showed virtually identical expert assignment distributions across subjects like ArXiv, PubMed, and PhilPapers; instead, routing decisions correlate heavily with syntax, token identity, and positional locality.

Under what software license are the Mixtral 8x7B models released?

Both the Mixtral 8x7B base model and Mixtral 8x7B – Instruct are released under the permissive Apache 2.0 license for academic and commercial use.

The overview on this page was written by AI from the paper and may contain mistakes. Read the paper for the details.

Read with translation and AI