MaartenGr Rocketknight1 HF Staff commited on
Commit
476025a
·
1 Parent(s): ddb04d7

Add response_template to tokenizer_config.json (#3)

Browse files

- Add response_template to tokenizer_config.json (2f963e48c1de0e055cee982d332f659fd8ec6ad7)
- Update README.md (5c442ce5a0154487a7e5c0ae8c3d10824cf49831)


Co-authored-by: Matthew Carrigan <Rocketknight1@users.noreply.huggingface.co>

Files changed (2) hide show
  1. README.md +4 -4
  2. tokenizer_config.json +46 -0
README.md CHANGED
@@ -181,7 +181,7 @@ outputs = model.generate(**inputs, max_new_tokens=1024)
181
  response = processor.decode(outputs[0][input_len:], skip_special_tokens=False)
182
 
183
  # Parse output
184
- processor.parse_response(response)
185
  ```
186
 
187
  To enable reasoning, set `enable_thinking=True` and the `parse_response` function will take care of parsing the thinking output.
@@ -241,7 +241,7 @@ outputs = model.generate(**inputs, max_new_tokens=512)
241
  response = processor.decode(outputs[0][input_len:], skip_special_tokens=False)
242
 
243
  # Parse output
244
- processor.parse_response(response)
245
  ```
246
 
247
  </details>
@@ -299,7 +299,7 @@ outputs = model.generate(**inputs, max_new_tokens=512)
299
  response = processor.decode(outputs[0][input_len:], skip_special_tokens=False)
300
 
301
  # Parse output
302
- processor.parse_response(response)
303
  ```
304
 
305
  </details>
@@ -358,7 +358,7 @@ outputs = model.generate(**inputs, max_new_tokens=512)
358
  response = processor.decode(outputs[0][input_len:], skip_special_tokens=False)
359
 
360
  # Parse output
361
- processor.parse_response(response)
362
  ```
363
 
364
  </details>
 
181
  response = processor.decode(outputs[0][input_len:], skip_special_tokens=False)
182
 
183
  # Parse output
184
+ processor.parse_response(response, prefix=inputs["input_ids"])
185
  ```
186
 
187
  To enable reasoning, set `enable_thinking=True` and the `parse_response` function will take care of parsing the thinking output.
 
241
  response = processor.decode(outputs[0][input_len:], skip_special_tokens=False)
242
 
243
  # Parse output
244
+ processor.parse_response(response, prefix=inputs["input_ids"])
245
  ```
246
 
247
  </details>
 
299
  response = processor.decode(outputs[0][input_len:], skip_special_tokens=False)
300
 
301
  # Parse output
302
+ processor.parse_response(response, prefix=inputs["input_ids"])
303
  ```
304
 
305
  </details>
 
358
  response = processor.decode(outputs[0][input_len:], skip_special_tokens=False)
359
 
360
  # Parse output
361
+ processor.parse_response(response, prefix=inputs["input_ids"])
362
  ```
363
 
364
  </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>",