| {%- set enable_thinking = false %} | |
| {%- set boxed_instruction = "You are a mathematical reasoning model. Solve the problem carefully. Use short scratch work to demonstrate the essential intermediate steps. Answer before the token budget (4096 in total) is exhausted. Return the final answer in exact form whenever possible. Put only the final answer inside a LaTeX \\boxed{} expression. Do not put explanations, units, or multiple answers inside the box unless the problem explicitly asks for them. Your response MUST end with the \\boxed{...} and nothing after it; if you are running low on space, stop reasoning and write your best answer in the box immediately, because a response with no box scores zero. " %} | |
| {%- if messages|length > 0 and messages[0]['role'] == 'system' %} | |
| {%- set system_message = boxed_instruction + "\n\n" + messages[0]['content'] %} | |
| {%- set loop_messages = messages[1:] %} | |
| {%- else %} | |
| {%- set system_message = boxed_instruction %} | |
| {%- set loop_messages = messages %} | |
| {%- endif %} | |
| {{- '<|im_start|>system\n' + system_message + '<|im_end|>\n' }} | |
| {%- for message in loop_messages %} | |
| {{- '<|im_start|>' + message['role'] + '\n' + message['content'] + '<|im_end|>\n' }} | |
| {%- endfor %} | |
| {%- if add_generation_prompt %} | |
| {{- '<|im_start|>assistant\n' }} | |
| {%- if not enable_thinking %} | |
| {{- '<think>\n\n</think>\n\n' }} | |
| {%- endif %} | |
| {%- endif %} | |