Paper commentary
Mistral 7B
- Problem Scaling up a language model raises compute cost and inference latency, which makes practical deployment harder.
- Method Combines grouped-query attention with sliding window attention, a rolling buffer cache and chunked pre-filling, then fine-tunes a chat variant on public instruction data.
- Results Reached 60.1% MMLU against 55.6% for Llama 2 13B, both pretrained, in the authors' re-run evaluation.

Figure 1 : Sliding Window Attention. The number of operations in vanilla attention is quadratic in the sequence length, and the memory increases linearly with the number of tokens. At inference time, this incurs higher latency and smaller throughput due to reduced cache availability. To alleviate this issue, we use sliding window attention: each token can attend to at most W tokens from the previous layer (here, W = 3). Note that tokens outside the sliding window still influence next word prediction. At each attention layer, information can move forward by W tokens. Hence, after k attention layers, information can move forward by up to k × W tokens.
Original paper · CC BY 4.0 · 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 Sayed · Mistral 7B · Original paper figure · Extracted the figure area from page 2 of the original PDF.Why a 7B model needs a different efficiency trade-off
Making a language model larger tends to raise both computational cost and inference latency, which puts deployment in practical settings out of reach for many users. Mistral 7B is built to test whether a 7B model can keep high quality while staying cheap to run at inference time. It is measured against Llama 2 13B, the previous best 13B model, and against Llama 1 34B, because Llama 2 34B was never released as open weights.
The model combines two attention variants to balance quality against inference cost. The first of these, grouped-query attention, speeds up decoding and lowers memory use while decoding, which allows larger batches and higher throughput. The second, sliding window attention, lets longer sequences be handled at a lower computational cost.
How sliding window attention reaches past its window
In sliding window attention, the hidden state at position i in layer k reads the previous layer's hidden states at positions from i − W to i, so each layer sees only a window of width W. Because each layer reads a window of the layer below, reach grows with depth: a state can access input tokens at a distance of up to W × k tokens. With W = 4096 at the last layer, the theoretical attention span is about 131K tokens.
Figure 1 uses W = 3 to show that tokens outside the window still affect the next-word prediction through earlier layers. For a sequence length of 16K with W = 4096, the authors' changes to FlashAttention and xFormers gave a 2x speed improvement over a vanilla attention baseline.
Grouped-query attention is set up with 32 attention heads that share 8 key-value heads. The rest of the architecture uses a model dimension of 4096, 32 layers, a head dimension of 128 and a hidden dimension of 14336, with a context length of 8192 and a vocabulary of 32000. Sliding window attention and the 4096-token window are the changes from the Llama architecture that the rest of the design depends on.
Keeping the cache bounded and filling it with long prompts
Because attention only spans a fixed window, the cache can be limited to W entries in a rolling buffer. The keys and values for position i are written to position i mod W, so once the position passes W, the oldest values are overwritten and the cache size stops increasing. On sequences of 32k tokens this cuts the cache memory usage by 8x, which the authors report without any effect on model quality.
Figure 2 shows the same overwriting with a cache of size W = 4.
Generation is sequential, but the prompt is known in advance, so its keys and values can be pre-filled into the cache before decoding starts. A long prompt can be split into chunks whose size equals the window size, and attention for each chunk is computed over the cache and over the chunk itself. Figure 3 walks through a three-chunk example, where the last chunk attends to itself with a causal mask, to the cache through a sliding window, and ignores tokens outside the window.
Base model results against Llama models
Commonsense reasoning is evaluated zero-shot, world knowledge 5-shot and reading comprehension zero-shot, while math uses GSM8K with 8-shot maj@8 and MATH with 4-shot maj@4. Code is measured with HumanEval zero-shot and MBPP 3-shot, and the aggregated results use MMLU 5-shot, BBH 3-shot and AGI Eval. All baselines are re-run with the authors' own evaluation pipeline, so the comparison is made under one protocol.
In the authors' re-run evaluation, Mistral 7B outperforms Llama 2 13B across all tested benchmarks. In the pretrained rows of Table 2, MMLU is 60.1% for Mistral 7B against 55.6% for Llama 2 13B, and GSM8K is 52.2% against 34.3%. Table 2 compares the pretrained models; the code and math columns are where the gap to Llama 2 13B is widest.
Against Llama 1 34B, Mistral 7B is ahead on most benchmarks, and the authors report that it is clearly superior in mathematics, code and reasoning. Figure 4 summarises these comparisons, and it shows Llama 1 34B as the baseline in mathematics, code generation and reasoning.
On code, Mistral 7B approaches Code-Llama 7B without matching it: HumanEval is 30.5% against 31.1%, and MBPP is 47.5% against 52.5%. The authors estimate equivalent sizes within the Llama 2 family. On reasoning, comprehension and MMLU, Mistral 7B performs like a Llama 2 model more than 3x its size. Knowledge benchmarks are the exception, where the compression rate is 1.9x, which the authors attribute to the model's limited parameter count.
Chat model results
Mistral 7B – Instruct is fine-tuned from the base model on instruction datasets that are publicly available on the Hugging Face repository. No proprietary data or training tricks were used, and the authors present the chat model as a simple demonstration that the base model can be fine-tuned easily.
On MT Bench, Mistral 7B – Instruct scores 6.84 ± 0.07, which is above every 7B chat model in Table 3 and comparable to the 13B chat models. Llama 2 13B – Chat scores 6.65 on MT Bench, and in the Chatbot Arena ELO Rating Mistral 7B – Instruct reaches 1031 against 1012 for Llama 2 13B – Chat. WizardLM 13B v1.2 is higher on both measures, with an ELO Rating of 1047 and an MT Bench score of 7.2.
In an independent human evaluation, participants saw anonymous responses from two models and selected the one they preferred. As of October 6, 2023, Mistral 7B – Instruct outputs were preferred 5020 times, against 4143 preferences for Llama 2 13B – Chat.
Guardrails through system prompts and self-reflection
The system prompt asks the model to assist with care, respect and truth, and to avoid harmful, unethical, prejudiced or negative content. Enabling it moves the model along a trade-off between answer utility and guardrail enforcement. On MT Bench, the score is 6.84 ± 0.07 with no system prompt, 6.58 ± 0.05 with the Mistral system prompt and 6.38 ± 0.07 with the Llama 2 system prompt.
With the recommended system prompt, Mistral 7B – Instruct declines to answer 100% of the harmful questions in a set of 175 unsafe prompts. In the Table 5 example, Mistral 7B – Instruct gives the command-line answer to how to kill a Linux process under the Mistral system prompt, while Llama 2 13B – Chat declines under its own prompt. Both models answer correctly when system prompts are turned off.
Self-reflection is a prompt that asks the model to classify a user prompt or its own generated answer as acceptable or as belonging to one of the listed harmful categories. On the authors' manually curated and balanced set of adversarial and standard prompts, self-reflection reached a precision of 99.4% at a recall of 95.6%, treating acceptable prompts as positives.
Limitations
On knowledge benchmarks Mistral 7B is only on par with Llama 2 13B, and the authors attribute this to the model's limited parameter count, which restricts how much knowledge it can store.
Some numbers differ from the Llama 2 paper's protocol: MBPP uses the hand-verified subset, and TriviaQA is run without Wikipedia contexts. The guardrail safety check uses 175 unsafe prompts, and the self-reflection precision and recall come from the authors' own curated set. The human preference counts come from an external leaderboard, so they are not a controlled comparison of the two models.
Paper info
- Authors
- 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 Sayed
- Venue
- arXiv · Preprint
- First published
- 2023-10-10
- Added
- 2026-10-20
- Updated
- 2023-10-10
- Version
- v1
- arXiv
- 2310.06825
- Category
- cs.CL · cs.AI · cs.LG
- Original paper terms
- CC BY 4.0
- What we show
- Paper info, commentary and permitted figures from the original paper
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 Mistral 7B v0.1, a 7-billion-parameter language model engineered for superior performance and efficiency. Mistral 7B outperforms Llama 2 13B across all evaluated benchmarks, and Llama 1 34B in reasoning, mathematics, and code generation. Our model leverages grouped-query attention (GQA) for faster inference, coupled with sliding window attention (SWA) to effectively handle sequences of arbitrary length with a reduced inference cost. We also provide a model fine-tuned to follow instructions, Mistral 7B -- Instruct, that surpasses the Llama 2 13B -- Chat model both on human and automated benchmarks. Our models are released under the Apache 2.0 license.
Quote from the paper
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 Sayed (2023). Mistral 7B. arXiv:2310.06825v1. https://arxiv.org/abs/2310.06825v1
BibTeX
@misc{jiang2023mistral,
title = {{Mistral 7B}},
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},
year = {2023},
eprint = {2310.06825},
archivePrefix = {arXiv},
url = {https://arxiv.org/abs/2310.06825v1}
}