Rocketknight1 HF Staff commited on
Commit
8217eea
·
verified ·
1 Parent(s): 7c4c459

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +7 -12
README.md CHANGED
@@ -123,18 +123,13 @@ generated_ids = model.generate(
123
  )
124
  output_ids = generated_ids[0][len(model_inputs.input_ids[0]):].tolist()
125
 
126
- # parsing thinking content
127
- try:
128
- # rindex finding 151668 (</think>)
129
- index = len(output_ids) - output_ids[::-1].index(151668)
130
- except ValueError:
131
- index = 0
132
-
133
- thinking_content = tokenizer.decode(output_ids[:index], skip_special_tokens=True).strip("\n")
134
- content = tokenizer.decode(output_ids[index:], skip_special_tokens=True).strip("\n")
135
-
136
- print("thinking content:", thinking_content) # no opening <think> tag
137
- print("content:", content)
138
 
139
  ```
140
 
 
123
  )
124
  output_ids = generated_ids[0][len(model_inputs.input_ids[0]):].tolist()
125
 
126
+ # parsing output - if you get errors, make sure you update to the latest version of transformers!
127
+ response = tokenizer.parse_response(tokenizer.decode(output_ids))
128
+
129
+ # If any tool calls are present, they will be in response.tool_calls
130
+ # You can continue the chat by simply appending `response` to `messages`.
131
+ print("thinking content:", response.reasoning)
132
+ print("content:", response.content)
 
 
 
 
 
133
 
134
  ```
135