MaartenGr Rocketknight1 HF Staff commited on
Commit
dd693ff
·
1 Parent(s): b11b042

Add response_template to tokenizer_config.json (#3)

Browse files

- Add response_template to tokenizer_config.json (038d33eda91a8bc781fe00fcf02bca588c5f7549)
- Update README.md (9b149bfa3534f32606f1df268bf15ab4fa3142a0)


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