[Feature]Optimization of Thinking Pattern Framework#4302
Conversation
|
Thanks for your contribution! |
| @@ -153,6 +154,10 @@ def process_request(self, request, max_model_len=None, **kwargs): | |||
| request.set("top_p", _SAMPLING_EPS) | |||
| if self.reasoning_parser and self.reasoning_parser.__class__.__name__ == "ErnieX1ReasoningParser": | |||
| @@ -231,7 +236,10 @@ def process_request_dict(self, request, max_model_len=None): | |||
| request["top_p"] = _SAMPLING_EPS | |||
| if self.reasoning_parser and self.reasoning_parser.__class__.__name__ == "ErnieX1ReasoningParser": | |||
| request["enable_thinking"] = True | |||
| if response_dict.outputs.text == "" and response_dict.outputs.reasoning_content == "": | ||
| return None | ||
| if req_id in self.model_status_dict: | ||
| del self.model_status_dict[req_id] |
There was a problem hiding this comment.
要在上面的 return之前 做del 的判断。
| request.enable_thinking = True | ||
| if self.reasoning_parser: | ||
| model_status = self.reasoning_parser.get_model_status(request.prompt_token_ids) | ||
| self.model_status_dict[request.request_id] = model_status |
There was a problem hiding this comment.
在 n 参数的场景, request_id = XX_m, 在后处理的 response 中取到的 req_id, 是 XX_m_n, 会造成取不到这个 model_status
| enable_thinking=enable_thinking, | ||
| **kwargs, | ||
| ) | ||
|
|
There was a problem hiding this comment.
还有一个 qwen_vl 的processor, 看看是不是需要修改。
| reasoning_content = delta_text[:end_index] | ||
| content = delta_text[end_index + len(self.think_end_token) :] | ||
| return DeltaMessage(reasoning_content=reasoning_content, content=content) | ||
| elif self.think_end_token_id in previous_token_ids: |
There was a problem hiding this comment.
直接用 if 就可以,不用 elif。 下面也不需要 else
| self.think_end_token_id, | ||
| self.response_start_token_id, | ||
| self.response_end_token_id, | ||
| ]: |
There was a problem hiding this comment.
如果遇到的是 tool_call 的special, 也可以直接返回 none 了
| n = request.get("n", 1) | ||
| for idx in range(n): | ||
| self.model_status_dict[f"{real_req_id}_{idx}"] = model_status | ||
| request["enable_thinking"] = model_status == "think_start" |
There was a problem hiding this comment.
real_req_id 没法区分多个 prompt
| reasoning_content, text = self.reasoning_parser.extract_reasoning_content( | ||
| full_text, | ||
| response_dict, | ||
| self.model_status_dict[req_id], |
There was a problem hiding this comment.
idx // (1 if request.n is None else request.n) 用这种方式,获取 status
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## develop #4302 +/- ##
==========================================
Coverage ? 60.12%
==========================================
Files ? 329
Lines ? 41066
Branches ? 6244
==========================================
Hits ? 24689
Misses ? 14492
Partials ? 1885
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
LiqinruiG
left a comment
There was a problem hiding this comment.
思考机制优化 ok, parser 细节可以进一步优化
* add model status in vl * add x1 parser * add model_status * fix parser * fix parser * fix parser * fix parser * Revert "fix parser" This reverts commit 300f446. * fix parser * fix * fix * fix * fix * fix parser * fix unit test * fix unit test * add unit test * fix * fix * add unit test * fix unit test * add unit test * add unit test * fix unit test * fix unit test * fix bug * fix unit test * x1 tool parser * fix unit test * fix unit test * fix unit test * fix n * fix unit test * add unit test * add unit test * remove pring
* add model status in vl * add x1 parser * add model_status * fix parser * fix parser * fix parser * fix parser * Revert "fix parser" This reverts commit 300f446. * fix parser * fix * fix * fix * fix * fix parser * fix unit test * fix unit test * add unit test * fix * fix * add unit test * fix unit test * add unit test * add unit test * fix unit test * fix unit test * fix bug * fix unit test * x1 tool parser * fix unit test * fix unit test * fix unit test * fix n * fix unit test * add unit test * add unit test * remove pring
1.Add the
get_model_statusmethod in thereasoning_parserto obtain the model's status, and determine how to perform parsing based on the status.2.Remove the judgment of
enable_thinking.