Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
change
sglang
Commits
959c4174
Unverified
Commit
959c4174
authored
Jan 22, 2024
by
Lianmin Zheng
Committed by
GitHub
Jan 22, 2024
Browse files
Fix the chat template for QWen (#83)
parent
94e05770
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
2 deletions
+10
-2
python/sglang/lang/chat_template.py
python/sglang/lang/chat_template.py
+4
-2
python/sglang/lang/interpreter.py
python/sglang/lang/interpreter.py
+6
-0
No files found.
python/sglang/lang/chat_template.py
View file @
959c4174
from
dataclasses
import
dataclass
from
dataclasses
import
dataclass
,
field
from
enum
import
Enum
,
auto
from
enum
import
Enum
,
auto
from
typing
import
Callable
,
Dict
,
List
,
Tuple
from
typing
import
Callable
,
Dict
,
List
,
Tuple
,
Optional
class
ChatTemplateStyle
(
Enum
):
class
ChatTemplateStyle
(
Enum
):
...
@@ -13,6 +13,7 @@ class ChatTemplate:
...
@@ -13,6 +13,7 @@ class ChatTemplate:
name
:
str
name
:
str
default_system_prompt
:
str
default_system_prompt
:
str
role_prefix_and_suffix
:
Dict
[
str
,
Tuple
[
str
]]
role_prefix_and_suffix
:
Dict
[
str
,
Tuple
[
str
]]
stop_str
:
List
[
str
]
=
()
image_token
:
str
=
"<image>"
image_token
:
str
=
"<image>"
style
:
ChatTemplateStyle
=
ChatTemplateStyle
.
PLAIN
style
:
ChatTemplateStyle
=
ChatTemplateStyle
.
PLAIN
...
@@ -110,6 +111,7 @@ register_chat_template(
...
@@ -110,6 +111,7 @@ register_chat_template(
"assistant"
:
(
"<|im_start|>assistant
\n
"
,
"
\n
<|im_end|>
\n
"
),
"assistant"
:
(
"<|im_start|>assistant
\n
"
,
"
\n
<|im_end|>
\n
"
),
},
},
style
=
ChatTemplateStyle
.
PLAIN
,
style
=
ChatTemplateStyle
.
PLAIN
,
stop_str
=
(
'<|im_end|>'
,)
)
)
)
)
...
...
python/sglang/lang/interpreter.py
View file @
959c4174
...
@@ -486,6 +486,12 @@ class StreamExecutor:
...
@@ -486,6 +486,12 @@ class StreamExecutor:
if
clone
is
None
:
if
clone
is
None
:
clone
=
self
.
default_sampling_para
.
clone
()
clone
=
self
.
default_sampling_para
.
clone
()
setattr
(
clone
,
item
,
value
)
setattr
(
clone
,
item
,
value
)
if
self
.
chat_template
.
stop_str
:
if
not
clone
:
clone
=
self
.
default_sampling_para
.
clone
()
clone
.
stop
+=
self
.
chat_template
.
stop_str
return
clone
or
self
.
default_sampling_para
return
clone
or
self
.
default_sampling_para
def
__del__
(
self
):
def
__del__
(
self
):
...
...
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