Mistral 7B

Albert Q. Jiang, Alexandre Sablayrolles, Arthur Mensch, Chris Bamford, Devendra Singh Chaplot, Diego de Las Casas, Florian Bressand, Gianna Lengyel, Guillaume Lample, Lucile Saulnier, Lélio Renard Lavaud, Marie-Anne Lachaux, Pierre Stock, Teven Le Scao, Thibaut Lavril, Thomas Wang, Timothée Lacroix, William El SayedarXiv 2023 · DOI

Introduction

The development of Large Language Models (LLMs) has traditionally faced a trade-off between model capability and computational efficiency. While scaling parameters often leads to better performance, it simultaneously increases the barriers to deployment due to high latency and memory requirements. Mistral 7B challenges this paradigm, demonstrating that a compact 7-billion parameter model can outperform models twice its size, such as Llama 2 13B, and rival even larger models like Llama 1 34B in specialized tasks like reasoning and coding.

Architectural Innovations

Mistral 7B is built upon the Transformer architecture but introduces several key optimizations designed to enhance long-sequence handling and inference speed.

Sliding Window Attention (SWA)

Unlike vanilla attention mechanisms that exhibit quadratic complexity relative to sequence length, Sliding Window Attention (SWA) employs a fixed window size ($W=4096$). Each token only attends to a limited number of preceding tokens. However, the hierarchical nature of the Transformer allows information to propagate across layers; a token in layer $k$ can effectively access information from $k \times W$ tokens in the past. This enables the model to handle theoretical context lengths of up to 131K tokens with linear computational complexity.

Comparison of Vanilla Attention vs. Sliding Window Attention and the resulting Effective Context Length.

Grouped-Query Attention (GQA) and Rolling Buffer Cache

To further optimize inference, Mistral 7B utilizes Grouped-Query Attention (GQA), which reduces the memory overhead of the KV cache during decoding. This is paired with a Rolling Buffer Cache of fixed size $W$. As new tokens are generated, they overwrite the oldest entries in the cache once the window size is exceeded. This mechanism ensures that memory usage remains constant regardless of the total sequence length, achieving up to an 8x reduction in cache memory requirements for long-context tasks.

Evaluation and Results

Mistral 7B was evaluated across a diverse suite of benchmarks covering reasoning, world knowledge, and technical proficiency.

Benchmark Performance

The model consistently outperformed Llama 2 13B across all tested categories. Notably, in technical domains such as mathematics and programming, Mistral 7B showed significant leads:

  • GSM8K (Math): 52.2% vs. 34.3% for Llama 2 13B.
  • HumanEval (Code): 30.5% vs. 18.9% for Llama 2 13B.

In general reasoning tasks (e.g., MMLU, Hellaswag), Mistral 7B remained competitive with or superior to models with significantly higher parameter counts. For instruction following, the fine-tuned "Mistral 7B – Instruct" model surpassed Llama 2 13B – Chat on both human evaluations and automated benchmarks like MT-Bench.

Efficiency Gains

The combination of SWA and GQA results in a 2x speedup in inference for 16K sequence lengths compared to standard attention models. This efficiency makes Mistral 7B an ideal candidate for deployment on consumer-grade hardware and real-time applications.

Discussion and Limitations

Mistral 7B redefines the efficiency frontier for LLMs, proving that architectural refinement is as critical as raw parameter scaling. By utilizing hierarchical information flow, the model maintains global context despite local attention windows. Furthermore, Mistral 7B addresses the issue of "over-alignment" seen in models like Llama 2. By using a system prompt and self-reflection mechanism, it avoids refusing harmless requests (e.g., "how to kill a Linux process") while maintaining robust safety guardrails.

However, the authors note that the model's smaller scale inherently limits its "world knowledge" capacity compared to 70B+ parameter models. While it excels in reasoning, its performance on knowledge-dense benchmarks like MMLU is on par with, rather than vastly exceeding, larger counterparts. Future research will likely focus on "3D scaling laws" that incorporate inference cost alongside training cost and capability.

Summary updated

BibTeX
@misc{jiang2023mistral,
  author = {Albert Q. Jiang and Alexandre Sablayrolles and Arthur Mensch and Chris Bamford and Devendra Singh Chaplot and Diego de Las Casas and Florian Bressand and Gianna Lengyel and Guillaume Lample and Lucile Saulnier and Lélio Renard Lavaud and Marie-Anne Lachaux and Pierre Stock and Teven Le Scao and Thibaut Lavril and Thomas Wang and Timothée Lacroix and William El Sayed},
  title = {{Mistral 7B}},
  year = {2023},
  eprint = {2310.06825},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2310.06825},
}
Figure