ErenOzilgili commited on
Commit
704db0e
·
verified ·
1 Parent(s): 26dfd93

Upload folder using huggingface_hub

Browse files
Files changed (3) hide show
  1. chat_template.jinja +133 -19
  2. model.safetensors +1 -1
  3. tokenizer_config.json +1 -1
chat_template.jinja CHANGED
@@ -1,23 +1,137 @@
1
- {%- if not add_generation_prompt is defined -%}{%- set add_generation_prompt = false -%}{%- endif -%}
2
- {%- if not enable_thinking is defined -%}{%- set enable_thinking = true -%}{%- endif -%}
3
- {%- set forced_system_prompt = 'You are a helpful assistant expert in mathematics. Please reason step by step inside the reasoning block. Break down complex equations, carefully verify your arithmetic at each step, and actively look for edge cases or alternative solution paths. Crucially, simplify your final mathematical results completely into their most reduced or standard form whenever possible. Once you have thoroughly double-checked your work, place this final simplified result strictly within \\boxed{}.' -%}
 
 
 
4
 
5
- {#- 1. Inject forced system prompt if not present -#}
6
- {%- if messages[0]['role'] != 'system' -%}
7
- <|im_start|>system
8
- {{ forced_system_prompt }}<|im_end|>
9
- {% endif -%}
10
 
11
- {#- 2. Loop through normal user/assistant message history -#}
12
- {%- for message in messages -%}
13
- <|im_start|>{{ message['role'] }}
14
- {{ message['content'] }}<|im_end|>
15
- {% endfor -%}
16
 
17
- {#- 3. Handle generation prompt based on the thinking toggle flag -#}
18
- {%- if add_generation_prompt -%}
19
- <|im_start|>assistant
20
- {% if enable_thinking -%}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
  <think>
22
- {% endif -%}
23
- {%- endif -%}
 
1
+ {%- set default_system = "You are a helpful assistant expert in mathematics. Please reason step by step inside the reasoning block. Break down complex equations, carefully verify your arithmetic at each step, and actively look for edge cases or alternative solution paths. Crucially, simplify your final mathematical results completely into their most reduced or standard form whenever possible. Once you have thoroughly double-checked your work, place this final simplified result strictly within \boxed{}." %}
2
+ {%- if tools %}
3
+ {{- '<|im_start|>system
4
+ ' }}
5
+ {%- if messages[0].role == 'system' %}
6
+ {{- messages[0].content + '
7
 
8
+ ' }}
9
+ {%- else %}
10
+ {{- default_system + '
 
 
11
 
12
+ ' }}
13
+ {%- endif %}
14
+ {{- "# Tools
 
 
15
 
16
+ You may call one or more functions to assist with the user query.
17
+
18
+ You are provided with function signatures within <tools></tools> XML tags:
19
+ <tools>" }}
20
+ {%- for tool in tools %}
21
+ {{- "
22
+ " }}
23
+ {{- tool | tojson }}
24
+ {%- endfor %}
25
+ {{- '
26
+ </tools>
27
+
28
+ For each function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags:
29
+ <tool_call>
30
+ {"name": <function-name>, "arguments": <args-json-object>}
31
+ </tool_call><|im_end|>
32
+ ' }}
33
+ {%- else %}
34
+ {%- if messages[0].role == 'system' %}
35
+ {{- '<|im_start|>system
36
+ ' + messages[0].content + '<|im_end|>
37
+ ' }}
38
+ {%- else %}
39
+ {{- '<|im_start|>system
40
+ ' + default_system + '<|im_end|>
41
+ ' }}
42
+ {%- endif %}
43
+ {%- endif %}
44
+ {%- set ns = namespace(multi_step_tool=true, last_query_index=messages|length - 1) %}
45
+ {%- for message in messages[::-1] %}
46
+ {%- set index = (messages|length - 1) - loop.index0 %}
47
+ {%- if ns.multi_step_tool and message.role == "user" and message.content is string and not(message.content.startswith('<tool_response>') and message.content.endswith('</tool_response>')) %}
48
+ {%- set ns.multi_step_tool = false %}
49
+ {%- set ns.last_query_index = index %}
50
+ {%- endif %}
51
+ {%- endfor %}
52
+ {%- for message in messages %}
53
+ {%- if message.content is string %}
54
+ {%- set content = message.content %}
55
+ {%- else %}
56
+ {%- set content = '' %}
57
+ {%- endif %}
58
+ {%- if (message.role == "user") or (message.role == "system" and not loop.first) %}
59
+ {{- '<|im_start|>' + message.role + '
60
+ ' + content + '<|im_end|>' + '
61
+ ' }}
62
+ {%- elif message.role == "assistant" %}
63
+ {%- set reasoning_content = '' %}
64
+ {%- if message.reasoning_content is string %}
65
+ {%- set reasoning_content = message.reasoning_content %}
66
+ {%- else %}
67
+ {%- if '</think>' in content %}
68
+ {%- set reasoning_content = content.split('</think>')[0].rstrip('
69
+ ').split('<think>')[-1].lstrip('
70
+ ') %}
71
+ {%- set content = content.split('</think>')[-1].lstrip('
72
+ ') %}
73
+ {%- endif %}
74
+ {%- endif %}
75
+ {%- if loop.index0 > ns.last_query_index %}
76
+ {%- if loop.last or (not loop.last and reasoning_content) %}
77
+ {{- '<|im_start|>' + message.role + '
78
+ <think>
79
+ ' + reasoning_content.strip('
80
+ ') + '
81
+ </think>
82
+
83
+ ' + content.lstrip('
84
+ ') }}
85
+ {%- else %}
86
+ {{- '<|im_start|>' + message.role + '
87
+ ' + content }}
88
+ {%- endif %}
89
+ {%- else %}
90
+ {{- '<|im_start|>' + message.role + '
91
+ ' + content }}
92
+ {%- endif %}
93
+ {%- if message.tool_calls %}
94
+ {%- for tool_call in message.tool_calls %}
95
+ {%- if (loop.first and content) or (not loop.first) %}
96
+ {{- '
97
+ ' }}
98
+ {%- endif %}
99
+ {%- if tool_call.function %}
100
+ {%- set tool_call = tool_call.function %}
101
+ {%- endif %}
102
+ {{- '<tool_call>
103
+ {"name": "' }}
104
+ {{- tool_call.name }}
105
+ {{- '", "arguments": ' }}
106
+ {%- if tool_call.arguments is string %}
107
+ {{- tool_call.arguments }}
108
+ {%- else %}
109
+ {{- tool_call.arguments | tojson }}
110
+ {%- endif %}
111
+ {{- '}
112
+ </tool_call>' }}
113
+ {%- endfor %}
114
+ {%- endif %}
115
+ {{- '<|im_end|>
116
+ ' }}
117
+ {%- elif message.role == "tool" %}
118
+ {%- if loop.first or (messages[loop.index0 - 1].role != "tool") %}
119
+ {{- '<|im_start|>user' }}
120
+ {%- endif %}
121
+ {{- '
122
+ <tool_response>
123
+ ' }}
124
+ {{- content }}
125
+ {{- '
126
+ </tool_response>' }}
127
+ {%- if loop.last or (messages[loop.index0 + 1].role != "tool") %}
128
+ {{- '<|im_end|>
129
+ ' }}
130
+ {%- endif %}
131
+ {%- endif %}
132
+ {%- endfor %}
133
+ {%- if add_generation_prompt %}
134
+ {{- '<|im_start|>assistant
135
  <think>
136
+ ' }}
137
+ {%- endif %}
model.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:2681b92baa1a60817e59d5df685b1ed721ed39aa64511277a9ac2cca440ac614
3
  size 3441185608
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a2b45e45f397943e0175905a4c5283827b3af534a73733c50b0c337a50de049d
3
  size 3441185608
tokenizer_config.json CHANGED
@@ -20,7 +20,7 @@
20
  "<|image_pad|>",
21
  "<|video_pad|>"
22
  ],
23
- "is_local": false,
24
  "local_files_only": false,
25
  "model_max_length": 131072,
26
  "pad_token": "<|endoftext|>",
 
20
  "<|image_pad|>",
21
  "<|video_pad|>"
22
  ],
23
+ "is_local": true,
24
  "local_files_only": false,
25
  "model_max_length": 131072,
26
  "pad_token": "<|endoftext|>",