Write the conversation
System, then alternating user and assistant turns; add or remove turns freely.
Models
Every instruction-tuned model expects its own wrapping of roles and special tokens, and getting it slightly wrong quietly degrades answers. Enter a conversation once and see the rendered prompt for each template, with special tokens highlighted, ready to paste into a raw completion call, a llama.cpp prompt, or a test.
Loading the tool…
System, then alternating user and assistant turns; add or remove turns freely.
ChatML (Qwen, many fine-tunes), Llama 3 and 3.1, Llama 2, Mistral / Mixtral, Gemma, Phi-3, Alpaca, Vicuna, and a custom Jinja-lite editor.
The rendered string, with an option to add the generation prompt (the assistant header without content) for inference.
Rendered as text here; when tokenising with the real tokenizer they must map to their single ids. Most Hugging Face tokenizers handle this when add_special_tokens is left on.
Llama 2 and Mistral place the system text inside the first user turn; Gemma has no system role and the tool folds it into the first user message, as the model card recommends.
The same rendering is what SFTTrainer applies via tokenizer.apply_chat_template; use it to check what the model actually sees.
The one in its tokenizer_config.json chat_template; the custom editor accepts a subset of that Jinja syntax.
Per template: Llama and Mistral start with <s> or <|begin_of_text|>; ChatML does not.
Yes; templates that require alternation warn when turns do not alternate.