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
7c803687
Unverified
Commit
7c803687
authored
Apr 07, 2025
by
Isotr0py
Committed by
GitHub
Apr 07, 2025
Browse files
[VLM] Florence-2 supports online serving (#16164)
Signed-off-by:
Isotr0py
<
2037008807@qq.com
>
parent
95d63f38
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
3 deletions
+22
-3
examples/template_florence2.jinja
examples/template_florence2.jinja
+7
-0
vllm/entrypoints/chat_utils.py
vllm/entrypoints/chat_utils.py
+2
-2
vllm/model_executor/models/florence2.py
vllm/model_executor/models/florence2.py
+13
-1
No files found.
examples/template_florence2.jinja
0 → 100644
View file @
7c803687
{%- for message in messages -%}
{%- if message['role'] == 'user' -%}
{{- message['content'] -}}
{%- elif message['role'] == 'assistant' -%}
{{- message['content'] -}}
{%- endif -%}
{%- endfor -%}
vllm/entrypoints/chat_utils.py
View file @
7c803687
...
@@ -487,8 +487,8 @@ class BaseMultiModalItemTracker(ABC, Generic[_T]):
...
@@ -487,8 +487,8 @@ class BaseMultiModalItemTracker(ABC, Generic[_T]):
return
"<|endoftext10|>"
# 200010 (see vocab.json in hf model)
return
"<|endoftext10|>"
# 200010 (see vocab.json in hf model)
if
model_type
in
(
"minicpmo"
,
"minicpmv"
):
if
model_type
in
(
"minicpmo"
,
"minicpmv"
):
return
"(<image>./</image>)"
return
"(<image>./</image>)"
if
model_type
in
(
"blip-2"
,
"fuyu"
,
"paligemma"
,
"pixtral"
,
if
model_type
in
(
"blip-2"
,
"florence2"
,
"fuyu"
,
"paligemma"
,
"mistral3"
):
"pixtral"
,
"mistral3"
):
# These models do not use image tokens in the prompt
# These models do not use image tokens in the prompt
return
None
return
None
if
model_type
==
"qwen"
:
if
model_type
==
"qwen"
:
...
...
vllm/model_executor/models/florence2.py
View file @
7c803687
...
@@ -10,7 +10,7 @@ import torch
...
@@ -10,7 +10,7 @@ import torch
import
torch.nn
as
nn
import
torch.nn
as
nn
import
torch.nn.functional
as
F
import
torch.nn.functional
as
F
from
einops
import
rearrange
from
einops
import
rearrange
from
transformers
import
BatchFeature
,
PretrainedConfig
from
transformers
import
BartTokenizer
,
BatchFeature
,
PretrainedConfig
from
vllm.config
import
VllmConfig
from
vllm.config
import
VllmConfig
from
vllm.model_executor.layers.logits_processor
import
LogitsProcessor
from
vllm.model_executor.layers.logits_processor
import
LogitsProcessor
...
@@ -826,6 +826,18 @@ class Florence2MultiModalProcessor(
...
@@ -826,6 +826,18 @@ class Florence2MultiModalProcessor(
)
->
Union
[
str
,
list
[
int
]]:
)
->
Union
[
str
,
list
[
int
]]:
return
[
self
.
info
.
get_hf_config
().
eos_token_id
]
return
[
self
.
info
.
get_hf_config
().
eos_token_id
]
def
_apply_hf_processor_tokens_only
(
self
,
prompt_tokens
:
list
[
int
],
)
->
list
[
int
]:
hf_processor
=
self
.
info
.
get_hf_processor
()
tokenizer
:
BartTokenizer
=
hf_processor
.
tokenizer
prompt_text
=
tokenizer
.
decode
(
prompt_tokens
)
# convert task tokens to prompt
prompt_text
=
hf_processor
.
_construct_prompts
([
prompt_text
])[
0
]
prompt_tokens
=
tokenizer
.
encode
(
prompt_text
,
add_special_tokens
=
False
)
return
prompt_tokens
def
_call_hf_processor
(
def
_call_hf_processor
(
self
,
self
,
prompt
:
str
,
prompt
:
str
,
...
...
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