{#- Training-compatible Qwen3 chat template with thinking disabled.
Renders the same tokens as Qwen3 official + enable_thinking=false, plus
{% generation %} markers around the assistant turn so trl.SFTTrainer can
mask user tokens via assistant_only_loss=True. The generation markers are
a no-op at inference. -#}
{%- for message in messages -%}
{%- if message.role == 'system' -%}
{{- '<|im_start|>system\n' + message.content + '<|im_end|>\n' -}}
{%- elif message.role == 'user' -%}
{{- '<|im_start|>user\n' + message.content + '<|im_end|>\n' -}}
{%- elif message.role == 'assistant' -%}
{% generation %}{{ '<|im_start|>assistant\n\n\n\n\n' + message.content + '<|im_end|>\n' }}{% endgeneration %}
{%- endif -%}
{%- endfor -%}
{%- if add_generation_prompt -%}
{{- '<|im_start|>assistant\n\n\n\n\n' -}}
{%- endif -%}