FAQ

Fine-tuning

Fine-tuning Mistral models: data format and licence variation

Several Mistral releases are Apache 2.0, which makes this family unusually clean for commercial work — but not all of them are, and the templates differ.

Mistral's appeal for commercial work is licensing: a number of its releases are Apache 2.0, which removes a whole category of problem. The catch is that this is not uniform across the family.

Check the licence per release, not per family

Several Mistral models have shipped under Apache 2.0 — genuinely permissive, no acceptable-use rider, no user-count threshold. For an organisation that needs to ship a model without a licence conversation, that is a significant practical advantage over families with bespoke community licences.

But the family has grown to include releases under other terms, including research-only and commercial licences for some of the larger and more specialised models. The variation is per release rather than per family, and the naming does not reliably tell you which is which.

So the rule here is simply: check the licence on the specific checkpoint you are about to train. Do not infer it from another Mistral model, however similar the name. This is a five-minute check that occasionally saves a project.

The template, and the system-prompt wrinkle

Mistral's chat format differs from Llama's, and the earlier models in the family had a notable characteristic: no distinct system role. System instructions were folded into a user turn instead — the first user message with the v1 tokenizer, the last user message with v2 and v3 — rather than carried separately. In multi-turn data the two placements produce different training strings.

A small table, Guardrails against MT Bench: no system prompt 6.84 ± 0.07, Llama 2 system prompt 6.38 ± 0.07, Mistral system prompt 6.58 ± 0.05.
MT-Bench scores for Mistral 7B Instruct with no system prompt (6.84), with Llama 2's system prompt (6.38) and with Mistral's own guardrail prompt (6.58), each averaged over 10 runs. The system prompt you train or evaluate with moves the score, so keep it fixed and record it with your data. Image: Table 4 of the paper · CC BY 4.0 · from Jiang et al. 2023, “Mistral 7B”, arXiv:2310.06825

Later releases in the family added system-role support, so this varies by checkpoint. It matters for your data preparation: if you store conversations with a separate system message and the template has nowhere to put it, the template may reject it with an error or drop it silently, and your carefully written system prompt never reaches the model.

The defence is the same as always and is worth repeating because it catches this exact bug: render one example with the tokenizer's own template and read the output. If your system content is not in the rendered string, you have found the problem before it cost you a training run. Our conversation formats post covers the general principle.

check that your system prompt survives
from transformers import AutoTokenizer
tok = AutoTokenizer.from_pretrained("<mistral-checkpoint>")

msgs = [
    {"role": "system", "content": "SENTINEL_SYSTEM_TEXT"},
    {"role": "user",   "content": "hello"},
]

try:
    rendered = tok.apply_chat_template(msgs, tokenize=False)
except Exception as e:      # early templates raise on a system message
    raise SystemExit(f"template rejects a system role ({e}) - fold it into a user turn")
assert "SENTINEL_SYSTEM_TEXT" in rendered, \
    "this checkpoint's template drops the system role - fold it into a user turn"
print(repr(rendered))
One stored conversation becomes a different training string under each template: v1 folds the system text into the first user turn, v2 and v3 into the last, where earlier replies never see it, and later releases keep it as a role of its own. A template with no place for it rejects it with an error or drops it silently, so render one example and read it before you train.

What the family is good at

The Mistral models have a reputation for strong performance per parameter, and the smaller ones are genuinely capable relative to their size — which is the practical reason to pick the family when inference cost matters.

Four line charts of score against model size (7B to 70B) for LLaMA 2, each with Mistral 7B as a single orange square and a dashed line to the equivalent LLaMA 2 size: MMLU 23B (3.3x), reasoning 38B (5.4x), knowledge 13B (1.9x) and comprehension 21B (3x).
Mistral 7B against the Llama 2 family on four benchmark groups, with the size of Llama 2 model it matches: 23B (3.3x) on MMLU, 38B (5.4x) on reasoning and 21B (3x) on comprehension, but only 13B (1.9x) on knowledge. A small model stores fewer facts, so a knowledge-heavy task needs retrieval or data, not just the base model. Image: Figure 5 of the paper · CC BY 4.0 · from “Mistral 7B”, arXiv:2310.06825

European language coverage has generally been a relative strength, which is worth knowing if you work in French, German, Italian or Spanish and have been assuming you need continued pretraining. Test before concluding that.

The family also includes mixture-of-experts and code-specialised releases. For a mixture-of-experts model, be aware that fine-tuning behaves differently from a dense model of the same nominal parameter count, and that the memory requirement is driven by total rather than active parameters. If your framework's defaults were tuned on dense models, check them.

A diagram titled 'Mixture of Experts Layer'. Inputs enter a router box; the router sends each token to a subset of stacked expert blocks and also emits gating weights along a dotted path; the selected experts' outputs are combined at a summation node to produce the layer output.
The sparse mixture-of-experts layer that separates several Mistral releases from the dense ones. It is also why memory has to be budgeted for total, not active, parameters. Image: mistralai/mistral-inference · Apache-2.0 repository · from “Mixtral of Experts”, arXiv:2401.04088

Settings and data

The data shape is the standard one: a messages list for conversational tuning, Alpaca-style flat fields for single-turn tasks, loss masked to assistant turns. Nothing about this family changes the contract, which is TRL's — see the TRL dataset contract.

Unsloth's published memory table puts a 7B model at about 5 GB for 4-bit QLoRA and about 19 GB for 16-bit LoRA, and Unsloth says Mistral Small 3.1 (24B) can be fine-tuned with at least 18 GB of VRAM. The 7B figure is comfortably within consumer hardware.

Starting points: rank 16 to 32, alpha equal to rank or double, learning rate around 2e-4 for SFT, one to three epochs. For preference tuning, around 5e-6 and one epoch. The rank, alpha, learning rates and epoch range match Unsloth's published LoRA hyperparameters guide (rank 16 or 32, alpha equal to or twice the rank, 2e-4, one to three epochs, 5e-6 for DPO and GRPO), so treat them as framework starting points rather than Mistral-specific recommendations. The how much data for a LoRA post is explicit about which numbers in this area are sourced and which are folklore.

During training a LoRA adapter never materialises ΔW: it stores the two thin factors and applies them as two small matrix multiplies. For deployment you keep them separate or merge BA into W once. Rank sets capacity, so a rank too low for the shift you are asking for cannot be fixed with more data or more epochs.

Questions people ask

Are all Mistral models Apache 2.0?

No. Several are, which is the family's main attraction for commercial work, but the family includes releases under other terms including research-only and commercial licences. Check the specific checkpoint; the name will not tell you.

Does the lack of a system role break my data?

Only if you assume it is there. For checkpoints whose template has no system role, fold the system content into a user turn the same way that checkpoint's tokenizer does — the first user message for v1, the last user message for v2 and v3 — then confirm by rendering with apply_chat_template. The check in the code above tells you which case you are in.

Is a mixture-of-experts model harder to fine-tune?

Different rather than harder, but the differences are real: memory is driven by total parameters rather than active ones, and expert routing interacts with adapter placement. Check that your framework explicitly supports the architecture rather than assuming settings transfer from a dense model.

How much data do I need?

The published figures come from Unsloth's documentation, not from the model's maker: a minimum of 100 rows with over 1,000 preferable for supervised fine-tuning, at 1–3 epochs, and at least 500 rows for GRPO. Nothing is published for DPO-style preference tuning. See how much data for a LoRA for the doubling experiment that answers it for your task rather than in general.

Stop hunting. Start searching.

Tens of thousands of curated datasets, searchable in plain language — with the licence and size checked before you download anything.

Search Dataset Finder →