gemma-3 / chat_template.json
salmankhanpm's picture
Upload model trained with Unsloth
5705484 verified
{
"chat_template": "{% if 'role' in messages[0] %}{{ bos_token }}\n{%- if messages[0] == 'system' -%}\n {%- set system_content = \"Cutting Knowledge Date: October 2024\nToday Date: 8 March 2025\n\nYou are a guardrail assistant designed to evaluate the safety of prompts for children. The input dataset contains these columns:\n- prompt_en (the English version of the prompt)\n- prompt_te (the Telugu version of the prompt)\n- category\n- subcategory\n- intent\n- potential_risk\n\nWhen processing an input prompt (via prompt_en and/or prompt_te), determine if the prompt is safe for children.\n\nIMPORTANT: Respond ONLY with JSON format. No explanations, introductions, or additional text.\n\n\u2022 If the prompt is safe, respond with the following JSON structure ONLY:\n{\n \\\"is_safe\\\": true\n}\n\n\u2022 If the prompt is unsafe, respond with the following JSON structure ONLY:\n{\n \\\"category\\\": \\\"<category>\\\",\n \\\"intent\\\": \\\"<intent>\\\",\n \\\"potential_risk\\\": \\\"<risk>\\\",\n \\\"is_safe\\\": false\n}\" -%}\n {%- set first_user_prefix = system_content + '\n\n' -%}\n {%- set loop_messages = messages[1:] -%}\n{%- else -%}\n {%- set first_user_prefix = \"\" -%}\n {%- set loop_messages = messages -%}\n{%- endif -%}\n\n{%- for message in loop_messages -%}\n {%- set role = \"model\" if message.role == 'assistant' else message.role -%}\n \n {{ '<start_of_turn>' + role + '\n' + (first_user_prefix if loop.first and role == 'user' else \"\") }}\n \n {%- if message.content is string -%}\n {{ message.content | trim }}\n {%- elif message.content is iterable -%}\n {%- for item in message.content -%}\n {%- if item.type == 'image' -%}\n {{ '<start_of_image>' }}\n {%- elif item.type == 'text' -%}\n {{ item.text | trim }}\n {%- endif -%}\n {%- endfor -%}\n {%- else -%}\n {{ message.content }}\n {%- endif -%}\n \n {{ '<end_of_turn>\n' }}\n{%- endfor -%}\n\n{%- if add_generation_prompt -%}\n {{ '<start_of_turn>model\n' }}\n{%- endif -%}\n{% else %}{{ bos_token }}\n{%- if messages[0] == 'system' -%}\n {%- set system_content = \"Cutting Knowledge Date: October 2024\nToday Date: 8 March 2025\n\nYou are a guardrail assistant designed to evaluate the safety of prompts for children. The input dataset contains these columns:\n- prompt_en (the English version of the prompt)\n- prompt_te (the Telugu version of the prompt)\n- category\n- subcategory\n- intent\n- potential_risk\n\nWhen processing an input prompt (via prompt_en and/or prompt_te), determine if the prompt is safe for children.\n\nIMPORTANT: Respond ONLY with JSON format. No explanations, introductions, or additional text.\n\n\u2022 If the prompt is safe, respond with the following JSON structure ONLY:\n{\n \\\"is_safe\\\": true\n}\n\n\u2022 If the prompt is unsafe, respond with the following JSON structure ONLY:\n{\n \\\"category\\\": \\\"<category>\\\",\n \\\"intent\\\": \\\"<intent>\\\",\n \\\"potential_risk\\\": \\\"<risk>\\\",\n \\\"is_safe\\\": false\n}\" -%}\n {%- set first_user_prefix = system_content + '\n\n' -%}\n {%- set loop_messages = messages[1:] -%}\n{%- else -%}\n {%- set first_user_prefix = \"\" -%}\n {%- set loop_messages = messages -%}\n{%- endif -%}\n\n{%- for message in loop_messages -%}\n {%- set role = \"model\" if message.role == 'model' else message.role -%}\n \n {{ '<start_of_turn>' + role + '\n' + (first_user_prefix if loop.first and role == 'user' else \"\") }}\n \n {%- if message.content is string -%}\n {{ message.content | trim }}\n {%- elif message.content is iterable -%}\n {%- for item in message.content -%}\n {%- if item.type == 'image' -%}\n {{ '<start_of_image>' }}\n {%- elif item.type == 'text' -%}\n {{ item.text | trim }}\n {%- endif -%}\n {%- endfor -%}\n {%- else -%}\n {{ message.content }}\n {%- endif -%}\n \n {{ '<end_of_turn>\n' }}\n{%- endfor -%}\n\n{%- if add_generation_prompt -%}\n {{ '<start_of_turn>model\n' }}\n{%- endif -%}\n{% endif %}"
}