Add response_template to tokenizer_config.json

#3
by Rocketknight1 HF Staff - opened
Files changed (2) hide show
  1. README.md +4 -4
  2. tokenizer_config.json +46 -0
README.md CHANGED
@@ -180,7 +180,7 @@ outputs = model.generate(**inputs, max_new_tokens=1024)
180
  response = processor.decode(outputs[0][input_len:], skip_special_tokens=False)
181
 
182
  # Parse output
183
- processor.parse_response(response)
184
  ```
185
 
186
  To enable reasoning, set `enable_thinking=True` and the `parse_response` function will take care of parsing the thinking output.
@@ -240,7 +240,7 @@ outputs = model.generate(**inputs, max_new_tokens=512)
240
  response = processor.decode(outputs[0][input_len:], skip_special_tokens=False)
241
 
242
  # Parse output
243
- processor.parse_response(response)
244
  ```
245
 
246
  </details>
@@ -298,7 +298,7 @@ outputs = model.generate(**inputs, max_new_tokens=512)
298
  response = processor.decode(outputs[0][input_len:], skip_special_tokens=False)
299
 
300
  # Parse output
301
- processor.parse_response(response)
302
  ```
303
 
304
  </details>
@@ -357,7 +357,7 @@ outputs = model.generate(**inputs, max_new_tokens=512)
357
  response = processor.decode(outputs[0][input_len:], skip_special_tokens=False)
358
 
359
  # Parse output
360
- processor.parse_response(response)
361
  ```
362
 
363
  </details>
 
180
  response = processor.decode(outputs[0][input_len:], skip_special_tokens=False)
181
 
182
  # Parse output
183
+ processor.parse_response(response, prefix=inputs["input_ids"])
184
  ```
185
 
186
  To enable reasoning, set `enable_thinking=True` and the `parse_response` function will take care of parsing the thinking output.
 
240
  response = processor.decode(outputs[0][input_len:], skip_special_tokens=False)
241
 
242
  # Parse output
243
+ processor.parse_response(response, prefix=inputs["input_ids"])
244
  ```
245
 
246
  </details>
 
298
  response = processor.decode(outputs[0][input_len:], skip_special_tokens=False)
299
 
300
  # Parse output
301
+ processor.parse_response(response, prefix=inputs["input_ids"])
302
  ```
303
 
304
  </details>
 
357
  response = processor.decode(outputs[0][input_len:], skip_special_tokens=False)
358
 
359
  # Parse output
360
+ processor.parse_response(response, prefix=inputs["input_ids"])
361
  ```
362
 
363
  </details>
tokenizer_config.json CHANGED
@@ -85,6 +85,52 @@
85
  "type": "object",
86
  "x-regex": "(\\<\\|channel\\>thought\\n(?P<thinking>.*?)\\<channel\\|\\>)?(?P<tool_calls>\\<\\|tool_call\\>.*\\<tool_call\\|\\>)?(?P<content>(?:(?!\\<turn\\|\\>)(?!\\<\\|tool_response\\>).)+)?(?:\\<turn\\|\\>|\\<\\|tool_response\\>)?"
87
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
88
  "soc_token": "<|channel>",
89
  "sot_token": "<|turn>",
90
  "stc_token": "<|tool_call>",
 
85
  "type": "object",
86
  "x-regex": "(\\<\\|channel\\>thought\\n(?P<thinking>.*?)\\<channel\\|\\>)?(?P<tool_calls>\\<\\|tool_call\\>.*\\<tool_call\\|\\>)?(?P<content>(?:(?!\\<turn\\|\\>)(?!\\<\\|tool_response\\>).)+)?(?:\\<turn\\|\\>|\\<\\|tool_response\\>)?"
87
  },
88
+ "response_template": {
89
+ "defaults": {
90
+ "role": "assistant"
91
+ },
92
+ "fields": {
93
+ "content": {
94
+ "close": [
95
+ "<turn|>",
96
+ "<|tool_response>",
97
+ "<eos>"
98
+ ],
99
+ "content": "text"
100
+ },
101
+ "thinking": {
102
+ "close": "<channel|>",
103
+ "content": "text",
104
+ "open": "<|channel>thought\n"
105
+ },
106
+ "tool_calls": {
107
+ "close": "<tool_call|>",
108
+ "content": "json",
109
+ "content_args": {
110
+ "string_delims": [
111
+ [
112
+ "<|\"|>",
113
+ "<|\"|>"
114
+ ]
115
+ ],
116
+ "unquoted_keys": true
117
+ },
118
+ "open_pattern": "<\\|tool_call>call:(?P<name>\\w+)",
119
+ "repeats": true,
120
+ "transform": {
121
+ "function": {
122
+ "arguments": "{content}",
123
+ "name": "{name}"
124
+ },
125
+ "type": "function"
126
+ }
127
+ }
128
+ },
129
+ "start_anchor": [
130
+ "<|turn>model\n",
131
+ "<tool_response|>"
132
+ ]
133
+ },
134
  "soc_token": "<|channel>",
135
  "sot_token": "<|turn>",
136
  "stc_token": "<|tool_call>",