{{ bos_token }}{% for message in messages %}
{% if message['role'] == 'system' %}
{{ '[INFO] ' + message['content'] + ' [/INFO]' }}
{% elif message['role'] == 'user' %}
{{ '[INST] ' + message['content'] + ' [/INST]' }}
{% elif message['role'] == 'assistant' %}
{{ message['content'] + eos_token}}
{% else %}{{ raise_exception('Only system, user and assistant roles are supported!') }}{% endif %}{% endfor %}
Context (verified 2026-10-02)
A Jinja chat template using the classic
[INST] ... [/INST]markers of early Mistral Instruct models. The[INFO]wrapper for system messages is not part of Mistral’s official template: the officialMistral-7B-Instruct-v0.1tokenizer_config.json(read 2026-10-02) has no[INFO]marker and handles an optional initial system message by prepending it, plus a blank line, to the first[INST]block; it enforces alternating user/assistant roles. The template above therefore differs from the official one; its origin is unknown (see Open items). Current Mistral models (mistral-family: Medium 3.5, Small 4, Large 3) ship their own chat templates in their Hugging Face repos: use those instead.
Official v0.1 template, for comparison (abridged): bos_token, then for each turn [INST] <content> [/INST] for user (first user turn prefixed with the system message and \n\n) and <content><eos> for assistant.
Open items
- Origin of the
[INFO]variant is unknown (a community or personal clipping). Which Mistral model, if any, it was meant for is unverified. Treat it as a reference snippet only, not as a template to deploy.
Sources (accessed 2026-10-02)
- https://huggingface.co/mistralai/Mistral-7B-Instruct-v0.1 and its raw
tokenizer_config.json - https://docs.mistral.ai/getting-started/models/models_overview/