Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
OpenDAS
vllm_cscc
Commits
2990cee9
Unverified
Commit
2990cee9
authored
Apr 30, 2025
by
Chauncey
Committed by
GitHub
Apr 30, 2025
Browse files
[Feature] The Qwen3 reasoning parser supports guided decoding (#17466)
Signed-off-by:
chaunceyjiang
<
chaunceyjiang@gmail.com
>
parent
0be6d05b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
1 deletion
+12
-1
vllm/reasoning/qwen3_reasoning_parser.py
vllm/reasoning/qwen3_reasoning_parser.py
+12
-1
No files found.
vllm/reasoning/qwen3_reasoning_parser.py
View file @
2990cee9
...
@@ -47,6 +47,18 @@ class Qwen3ReasoningParser(ReasoningParser):
...
@@ -47,6 +47,18 @@ class Qwen3ReasoningParser(ReasoningParser):
"Qwen3 reasoning parser could not locate think start/end "
"Qwen3 reasoning parser could not locate think start/end "
"tokens in the tokenizer!"
)
"tokens in the tokenizer!"
)
def
is_reasoning_end
(
self
,
input_ids
:
list
[
int
])
->
bool
:
return
self
.
think_end_token_id
in
input_ids
def
extract_content_ids
(
self
,
input_ids
:
list
[
int
])
->
list
[
int
]:
"""
Extract the content after the end tokens
"""
if
self
.
think_end_token_id
not
in
input_ids
[:
-
1
]:
return
[]
else
:
return
input_ids
[
input_ids
.
index
(
self
.
think_end_token_id
)
+
1
:]
def
extract_reasoning_content_streaming
(
def
extract_reasoning_content_streaming
(
self
,
self
,
previous_text
:
str
,
previous_text
:
str
,
...
@@ -88,7 +100,6 @@ class Qwen3ReasoningParser(ReasoningParser):
...
@@ -88,7 +100,6 @@ class Qwen3ReasoningParser(ReasoningParser):
# reasoning content continues
# reasoning content continues
return
DeltaMessage
(
reasoning_content
=
delta_text
)
return
DeltaMessage
(
reasoning_content
=
delta_text
)
elif
self
.
think_start_token_id
in
delta_token_ids
:
elif
self
.
think_start_token_id
in
delta_token_ids
:
logger
.
info
(
delta_text
)
if
self
.
think_end_token_id
in
delta_token_ids
:
if
self
.
think_end_token_id
in
delta_token_ids
:
# <think> in delta, </think> in delta, extract reasoning content
# <think> in delta, </think> in delta, extract reasoning content
start_index
=
delta_text
.
find
(
self
.
think_start_token
)
start_index
=
delta_text
.
find
(
self
.
think_start_token
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment