[VLM] Florence-2 supports online serving (#16164)
Signed-off-by: Isotr0py <2037008807@qq.com>
This commit is contained in:
@@ -10,7 +10,7 @@ import torch
|
||||
import torch.nn as nn
|
||||
import torch.nn.functional as F
|
||||
from einops import rearrange
|
||||
from transformers import BatchFeature, PretrainedConfig
|
||||
from transformers import BartTokenizer, BatchFeature, PretrainedConfig
|
||||
|
||||
from vllm.config import VllmConfig
|
||||
from vllm.model_executor.layers.logits_processor import LogitsProcessor
|
||||
@@ -826,6 +826,18 @@ class Florence2MultiModalProcessor(
|
||||
) -> Union[str, list[int]]:
|
||||
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(
|
||||
self,
|
||||
prompt: str,
|
||||
|
||||
Reference in New Issue
Block a user