Skip to content

[Feature]Optimization of Thinking Pattern Framework#4302

Merged
LiqinruiG merged 49 commits into
PaddlePaddle:developfrom
luukunn:think
Dec 10, 2025
Merged

[Feature]Optimization of Thinking Pattern Framework#4302
LiqinruiG merged 49 commits into
PaddlePaddle:developfrom
luukunn:think

Conversation

@luukunn
Copy link
Copy Markdown
Collaborator

@luukunn luukunn commented Sep 28, 2025

1.Add the get_model_status method in the reasoning_parser to obtain the model's status, and determine how to perform parsing based on the status.
2.Remove the judgment of enable_thinking.

@paddle-bot
Copy link
Copy Markdown

paddle-bot Bot commented Sep 28, 2025

Thanks for your contribution!

@paddle-bot paddle-bot Bot added the contributor External developers label Sep 28, 2025
Comment thread fastdeploy/input/ernie4_5_processor.py Outdated
@@ -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":
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个判断可以去掉了

Comment thread fastdeploy/input/ernie4_5_processor.py Outdated
@@ -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
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

同上

Comment thread fastdeploy/input/ernie4_5_processor.py Outdated
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]
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

要在上面的 return之前 做del 的判断。

Comment thread fastdeploy/input/ernie4_5_processor.py Outdated
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
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

在 n 参数的场景, request_id = XX_m, 在后处理的 response 中取到的 req_id, 是 XX_m_n, 会造成取不到这个 model_status

enable_thinking=enable_thinking,
**kwargs,
)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

还有一个 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:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

直接用 if 就可以,不用 elif。 下面也不需要 else

self.think_end_token_id,
self.response_start_token_id,
self.response_end_token_id,
]:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

如果遇到的是 tool_call 的special, 也可以直接返回 none 了

@LiqinruiG LiqinruiG changed the title [Feature]add model status [Feature]Optimization of Thinking Pattern Framework Oct 17, 2025
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"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

real_req_id 没法区分多个 prompt

reasoning_content, text = self.reasoning_parser.extract_reasoning_content(
full_text,
response_dict,
self.model_status_dict[req_id],
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

idx // (1 if request.n is None else request.n) 用这种方式,获取 status

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Dec 3, 2025

Codecov Report

❌ Patch coverage is 73.55623% with 87 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (develop@b0cf2c4). Learn more about missing BASE report.

Files with missing lines Patch % Lines
fastdeploy/input/text_processor.py 25.00% 21 Missing and 6 partials ⚠️
...reasoning/ernie_45_vl_thinking_reasoning_parser.py 75.38% 10 Missing and 6 partials ⚠️
fastdeploy/input/ernie4_5_processor.py 58.82% 12 Missing and 2 partials ⚠️
fastdeploy/reasoning/qwen3_reasoning_parsers.py 78.68% 9 Missing and 4 partials ⚠️
fastdeploy/reasoning/ernie_x1_reasoning_parsers.py 80.32% 3 Missing and 9 partials ⚠️
fastdeploy/reasoning/ernie_vl_reasoning_parsers.py 86.48% 3 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             develop    #4302   +/-   ##
==========================================
  Coverage           ?   60.12%           
==========================================
  Files              ?      329           
  Lines              ?    41066           
  Branches           ?     6244           
==========================================
  Hits               ?    24689           
  Misses             ?    14492           
  Partials           ?     1885           
Flag Coverage Δ
GPU 60.12% <73.55%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Collaborator

@LiqinruiG LiqinruiG left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

思考机制优化 ok, parser 细节可以进一步优化

@LiqinruiG LiqinruiG merged commit fbc9bce into PaddlePaddle:develop Dec 10, 2025
13 of 17 checks passed
@luukunn luukunn deleted the think branch February 5, 2026 06:11
chang-wenbin pushed a commit to chang-wenbin/FastDeploy that referenced this pull request Mar 2, 2026
* 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
xiaoguoguo626807 pushed a commit to xiaoguoguo626807/FastDeploy that referenced this pull request May 7, 2026
* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contributor External developers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants