Add response_template to tokenizer_config.json

#6
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
@@ -60,6 +60,52 @@
60
  "type": "object",
61
  "x-regex": "(\\<\\|channel\\>thought\\n(?P<thinking>.*?)\\<channel\\|\\>)?(?P<tool_calls>\\<\\|tool_call\\>.*\\<tool_call\\|\\>)?(?P<content>(?:(?!\\<turn\\|\\>)(?!\\<\\|tool_response\\>).)+)?(?:\\<turn\\|\\>|\\<\\|tool_response\\>)?"
62
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
63
  "soc_token": "<|channel>",
64
  "sot_token": "<|turn>",
65
  "stc_token": "<|tool_call>",
 
60
  "type": "object",
61
  "x-regex": "(\\<\\|channel\\>thought\\n(?P<thinking>.*?)\\<channel\\|\\>)?(?P<tool_calls>\\<\\|tool_call\\>.*\\<tool_call\\|\\>)?(?P<content>(?:(?!\\<turn\\|\\>)(?!\\<\\|tool_response\\>).)+)?(?:\\<turn\\|\\>|\\<\\|tool_response\\>)?"
62
  },
63
+ "response_template": {
64
+ "defaults": {
65
+ "role": "assistant"
66
+ },
67
+ "fields": {
68
+ "content": {
69
+ "close": [
70
+ "<turn|>",
71
+ "<|tool_response>",
72
+ "<eos>"
73
+ ],
74
+ "content": "text"
75
+ },
76
+ "thinking": {
77
+ "close": "<channel|>",
78
+ "content": "text",
79
+ "open": "<|channel>thought\n"
80
+ },
81
+ "tool_calls": {
82
+ "close": "<tool_call|>",
83
+ "content": "json",
84
+ "content_args": {
85
+ "string_delims": [
86
+ [
87
+ "<|\"|>",
88
+ "<|\"|>"
89
+ ]
90
+ ],
91
+ "unquoted_keys": true
92
+ },
93
+ "open_pattern": "<\\|tool_call>call:(?P<name>\\w+)",
94
+ "repeats": true,
95
+ "transform": {
96
+ "function": {
97
+ "arguments": "{content}",
98
+ "name": "{name}"
99
+ },
100
+ "type": "function"
101
+ }
102
+ }
103
+ },
104
+ "start_anchor": [
105
+ "<|turn>model\n",
106
+ "<tool_response|>"
107
+ ]
108
+ },
109
  "soc_token": "<|channel>",
110
  "sot_token": "<|turn>",
111
  "stc_token": "<|tool_call>",