@@ -30,6 +30,7 @@ class ModelRequestData(NamedTuple):
3030 prompts : list [str ]
3131 stop_token_ids : list [int ] | None = None
3232 lora_requests : list [LoRARequest ] | None = None
33+ sampling_params : list [SamplingParams ] | None = None
3334
3435
3536# NOTE: The default `max_num_seqs` and `max_model_len` may result in OOM on
@@ -153,23 +154,6 @@ def run_chameleon(questions: list[str], modality: str) -> ModelRequestData:
153154 )
154155
155156
156- # Dots-OCR
157- def run_dots_ocr (questions : list [str ], modality : str ) -> ModelRequestData :
158- assert modality == "image"
159-
160- prompts = [f"<|img|><|imgpad|><|endofimg|>{ question } " for question in questions ]
161- engine_args = EngineArgs (
162- model = "rednote-hilab/dots.ocr" ,
163- limit_mm_per_prompt = {modality : 1 },
164- trust_remote_code = True ,
165- )
166-
167- return ModelRequestData (
168- engine_args = engine_args ,
169- prompts = prompts ,
170- )
171-
172-
173157def run_command_a_vision (questions : list [str ], modality : str ) -> ModelRequestData :
174158 assert modality == "image"
175159
@@ -217,6 +201,66 @@ def run_deepseek_vl2(questions: list[str], modality: str) -> ModelRequestData:
217201 )
218202
219203
204+ def run_deepseek_ocr (questions : list [str ], modality : str ) -> ModelRequestData :
205+ from vllm .model_executor .models .deepseek_ocr import NGramPerReqLogitsProcessor
206+
207+ assert modality == "image"
208+
209+ model_name = "deepseek-ai/DeepSeek-OCR"
210+
211+ engine_args = EngineArgs (
212+ model = model_name ,
213+ limit_mm_per_prompt = {modality : 1 },
214+ logits_processors = [NGramPerReqLogitsProcessor ],
215+ )
216+
217+ # deepseek-ocr use plain prompt template
218+ prompts = [f"<image>\n { question } " for question in questions ]
219+
220+ # The following sampling params config is taken from
221+ # the official Deepseek-OCR inference example.
222+ # (IMPORTANT) Use the custom logits processor and avoid skipping
223+ # special tokens for this model for the optimal OCR performance.
224+ sampling_params = [
225+ SamplingParams (
226+ temperature = 0.0 ,
227+ max_tokens = 8192 ,
228+ # ngram logit processor args
229+ extra_args = dict (
230+ ngram_size = 30 ,
231+ window_size = 90 ,
232+ # whitelist: <td>, </td>
233+ whitelist_token_ids = {128821 , 128822 },
234+ ),
235+ skip_special_tokens = False ,
236+ )
237+ for _ in questions
238+ ]
239+
240+ return ModelRequestData (
241+ engine_args = engine_args ,
242+ prompts = prompts ,
243+ sampling_params = sampling_params ,
244+ )
245+
246+
247+ # Dots-OCR
248+ def run_dots_ocr (questions : list [str ], modality : str ) -> ModelRequestData :
249+ assert modality == "image"
250+
251+ prompts = [f"<|img|><|imgpad|><|endofimg|>{ question } " for question in questions ]
252+ engine_args = EngineArgs (
253+ model = "rednote-hilab/dots.ocr" ,
254+ limit_mm_per_prompt = {modality : 1 },
255+ trust_remote_code = True ,
256+ )
257+
258+ return ModelRequestData (
259+ engine_args = engine_args ,
260+ prompts = prompts ,
261+ )
262+
263+
220264# Ernie4.5-VL
221265def run_ernie45_vl (questions : list [str ], modality : str ) -> ModelRequestData :
222266 model_name = "baidu/ERNIE-4.5-VL-28B-A3B-PT"
@@ -1738,9 +1782,10 @@ def run_tarsier2(questions: list[str], modality: str) -> ModelRequestData:
17381782 "bee" : run_bee ,
17391783 "blip-2" : run_blip2 ,
17401784 "chameleon" : run_chameleon ,
1741- "dots_ocr" : run_dots_ocr ,
17421785 "command_a_vision" : run_command_a_vision ,
17431786 "deepseek_vl_v2" : run_deepseek_vl2 ,
1787+ "deepseek_ocr" : run_deepseek_ocr ,
1788+ "dots_ocr" : run_dots_ocr ,
17441789 "ernie45_vl" : run_ernie45_vl ,
17451790 "fuyu" : run_fuyu ,
17461791 "gemma3" : run_gemma3 ,
@@ -2003,8 +2048,12 @@ def main(args):
20032048
20042049 # We set temperature to 0.2 so that outputs can be different
20052050 # even when all prompts are identical when running batch inference.
2006- sampling_params = SamplingParams (
2007- temperature = 0.2 , max_tokens = 64 , stop_token_ids = req_data .stop_token_ids
2051+ sampling_params = (
2052+ SamplingParams (
2053+ temperature = 0.2 , max_tokens = 64 , stop_token_ids = req_data .stop_token_ids
2054+ )
2055+ if req_data .sampling_params is None
2056+ else req_data .sampling_params
20082057 )
20092058
20102059 assert args .num_prompts > 0
0 commit comments