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
3edba9bc
Unverified
Commit
3edba9bc
authored
Oct 30, 2025
by
Tanjiro
Committed by
GitHub
Oct 30, 2025
Browse files
[fix] added image token as prefix for deepseek-ocr (#12358)
parent
e5ec9764
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
1 deletion
+7
-1
python/sglang/srt/parser/conversation.py
python/sglang/srt/parser/conversation.py
+7
-1
No files found.
python/sglang/srt/parser/conversation.py
View file @
3edba9bc
...
@@ -101,6 +101,7 @@ class Conversation:
...
@@ -101,6 +101,7 @@ class Conversation:
stop_token_ids
:
Optional
[
int
]
=
None
stop_token_ids
:
Optional
[
int
]
=
None
audio_data
:
Optional
[
List
[
str
]]
=
None
audio_data
:
Optional
[
List
[
str
]]
=
None
image_token_at_prefix
:
bool
=
False
def
get_prompt
(
self
)
->
str
:
def
get_prompt
(
self
)
->
str
:
"""Get the prompt for generation."""
"""Get the prompt for generation."""
...
@@ -445,6 +446,7 @@ class Conversation:
...
@@ -445,6 +446,7 @@ class Conversation:
image_token
=
self
.
image_token
,
image_token
=
self
.
image_token
,
video_token
=
self
.
video_token
,
video_token
=
self
.
video_token
,
audio_token
=
self
.
audio_token
,
audio_token
=
self
.
audio_token
,
image_token_at_prefix
=
self
.
image_token_at_prefix
,
)
)
def
dict
(
self
):
def
dict
(
self
):
...
@@ -512,6 +514,7 @@ def generate_embedding_convs(
...
@@ -512,6 +514,7 @@ def generate_embedding_convs(
image_token
=
conv_template
.
image_token
,
image_token
=
conv_template
.
image_token
,
video_token
=
conv_template
.
video_token
,
video_token
=
conv_template
.
video_token
,
audio_token
=
conv_template
.
audio_token
,
audio_token
=
conv_template
.
audio_token
,
image_token_at_prefix
=
conv_template
.
image_token_at_prefix
,
)
)
real_content
=
""
real_content
=
""
...
@@ -578,6 +581,7 @@ def generate_chat_conv(
...
@@ -578,6 +581,7 @@ def generate_chat_conv(
image_token
=
conv
.
image_token
,
image_token
=
conv
.
image_token
,
audio_token
=
conv
.
audio_token
,
audio_token
=
conv
.
audio_token
,
video_token
=
conv
.
video_token
,
video_token
=
conv
.
video_token
,
image_token_at_prefix
=
conv
.
image_token_at_prefix
,
)
)
if
isinstance
(
request
.
messages
,
str
):
if
isinstance
(
request
.
messages
,
str
):
...
@@ -627,7 +631,7 @@ def generate_chat_conv(
...
@@ -627,7 +631,7 @@ def generate_chat_conv(
real_content
+=
content
.
text
real_content
+=
content
.
text
elif
content
.
type
==
"image_url"
:
elif
content
.
type
==
"image_url"
:
# NOTE: works for llava and intervl2_5
# NOTE: works for llava and intervl2_5
if
conv
.
name
in
[
"internvl-2-5"
]
:
if
conv
.
image_token_at_prefix
:
real_content
=
image_token
+
real_content
real_content
=
image_token
+
real_content
else
:
else
:
real_content
+=
image_token
real_content
+=
image_token
...
@@ -820,6 +824,7 @@ register_conv_template(
...
@@ -820,6 +824,7 @@ register_conv_template(
sep
=
"<|im_end|>
\n
"
,
sep
=
"<|im_end|>
\n
"
,
stop_str
=
[
"<|im_end|>"
,
"<|action_end|>"
],
stop_str
=
[
"<|im_end|>"
,
"<|action_end|>"
],
image_token
=
"<IMG_CONTEXT>"
,
image_token
=
"<IMG_CONTEXT>"
,
image_token_at_prefix
=
True
,
)
)
)
)
...
@@ -848,6 +853,7 @@ register_conv_template(
...
@@ -848,6 +853,7 @@ register_conv_template(
sep_style
=
SeparatorStyle
.
NO_COLON_SINGLE
,
sep_style
=
SeparatorStyle
.
NO_COLON_SINGLE
,
stop_str
=
[
"<|end▁of▁sentence|>"
],
stop_str
=
[
"<|end▁of▁sentence|>"
],
image_token
=
"<image>"
,
image_token
=
"<image>"
,
image_token_at_prefix
=
True
,
)
)
)
)
...
...
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