MaartenGr Rocketknight1 HF Staff commited on
Commit
96d4c8c
·
1 Parent(s): cd038d0

Add response_template to tokenizer_config.json (#6)

Browse files

- Add response_template to tokenizer_config.json (ff54284cd034b8a59f9939bd6bbb2ad00fc42719)
- Update README.md (5520cf733af1b4d958b048dabe9be4b7beb03f3c)


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
@@ -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>",