MaartenGr Rocketknight1 HF Staff commited on
Commit
707f0a3
·
1 Parent(s): 12ace6d

Add response_template to tokenizer_config.json (#43)

Browse files

- Add response_template to tokenizer_config.json (6e8c319d55ae02b6feed78c5576e7062671d846c)
- Add response_template to tokenizer_config.json (277d410b608fcfb08b7fa241cd38056e2dec5030)
- Update README.md (03be7fbdf2a342429885b43267952ef251b819fe)


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
@@ -175,7 +175,7 @@ outputs = model.generate(**inputs, max_new_tokens=1024)
175
  response = processor.decode(outputs[0][input_len:], skip_special_tokens=False)
176
 
177
  # Parse output
178
- processor.parse_response(response)
179
  ```
180
 
181
  To enable reasoning, set `enable_thinking=True` and the `parse_response` function will take care of parsing the thinking output.
@@ -235,7 +235,7 @@ outputs = model.generate(**inputs, max_new_tokens=512)
235
  response = processor.decode(outputs[0][input_len:], skip_special_tokens=False)
236
 
237
  # Parse output
238
- processor.parse_response(response)
239
  ```
240
 
241
  </details>
@@ -293,7 +293,7 @@ outputs = model.generate(**inputs, max_new_tokens=512)
293
  response = processor.decode(outputs[0][input_len:], skip_special_tokens=False)
294
 
295
  # Parse output
296
- processor.parse_response(response)
297
  ```
298
 
299
  </details>
@@ -352,7 +352,7 @@ outputs = model.generate(**inputs, max_new_tokens=512)
352
  response = processor.decode(outputs[0][input_len:], skip_special_tokens=False)
353
 
354
  # Parse output
355
- processor.parse_response(response)
356
  ```
357
 
358
  </details>
 
175
  response = processor.decode(outputs[0][input_len:], skip_special_tokens=False)
176
 
177
  # Parse output
178
+ processor.parse_response(response, prefix=inputs["input_ids"])
179
  ```
180
 
181
  To enable reasoning, set `enable_thinking=True` and the `parse_response` function will take care of parsing the thinking output.
 
235
  response = processor.decode(outputs[0][input_len:], skip_special_tokens=False)
236
 
237
  # Parse output
238
+ processor.parse_response(response, prefix=inputs["input_ids"])
239
  ```
240
 
241
  </details>
 
293
  response = processor.decode(outputs[0][input_len:], skip_special_tokens=False)
294
 
295
  # Parse output
296
+ processor.parse_response(response, prefix=inputs["input_ids"])
297
  ```
298
 
299
  </details>
 
352
  response = processor.decode(outputs[0][input_len:], skip_special_tokens=False)
353
 
354
  # Parse output
355
+ processor.parse_response(response, prefix=inputs["input_ids"])
356
  ```
357
 
358
  </details>
tokenizer_config.json CHANGED
@@ -63,6 +63,52 @@
63
  "type": "object",
64
  "x-regex": "(\\<\\|channel\\>thought\\n(?P<thinking>.*?)\\<channel\\|\\>)?(?P<tool_calls>\\<\\|tool_call\\>.*\\<tool_call\\|\\>)?(?P<content>(?:(?!\\<turn\\|\\>)(?!\\<\\|tool_response\\>).)+)?(?:\\<turn\\|\\>|\\<\\|tool_response\\>)?"
65
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
66
  "soc_token": "<|channel>",
67
  "sot_token": "<|turn>",
68
  "stc_token": "<|tool_call>",
 
63
  "type": "object",
64
  "x-regex": "(\\<\\|channel\\>thought\\n(?P<thinking>.*?)\\<channel\\|\\>)?(?P<tool_calls>\\<\\|tool_call\\>.*\\<tool_call\\|\\>)?(?P<content>(?:(?!\\<turn\\|\\>)(?!\\<\\|tool_response\\>).)+)?(?:\\<turn\\|\\>|\\<\\|tool_response\\>)?"
65
  },
66
+ "response_template": {
67
+ "defaults": {
68
+ "role": "assistant"
69
+ },
70
+ "fields": {
71
+ "content": {
72
+ "close": [
73
+ "<turn|>",
74
+ "<|tool_response>",
75
+ "<eos>"
76
+ ],
77
+ "content": "text"
78
+ },
79
+ "thinking": {
80
+ "close": "<channel|>",
81
+ "content": "text",
82
+ "open": "<|channel>thought\n"
83
+ },
84
+ "tool_calls": {
85
+ "close": "<tool_call|>",
86
+ "content": "json",
87
+ "content_args": {
88
+ "string_delims": [
89
+ [
90
+ "<|\"|>",
91
+ "<|\"|>"
92
+ ]
93
+ ],
94
+ "unquoted_keys": true
95
+ },
96
+ "open_pattern": "<\\|tool_call>call:(?P<name>\\w+)",
97
+ "repeats": true,
98
+ "transform": {
99
+ "function": {
100
+ "arguments": "{content}",
101
+ "name": "{name}"
102
+ },
103
+ "type": "function"
104
+ }
105
+ }
106
+ },
107
+ "start_anchor": [
108
+ "<|turn>model\n",
109
+ "<tool_response|>"
110
+ ]
111
+ },
112
  "soc_token": "<|channel>",
113
  "sot_token": "<|turn>",
114
  "stc_token": "<|tool_call>",