main
py 35 lines 1.42 KB
Raw
1 # SPDX-License-Identifier: Apache-2.0
2 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project
3
4 # Unlimited-OCR (baidu/Unlimited-OCR) reuses
5 # the DeepSeek-OCR multimodal layout (DeepEncoder = SAM-ViT-B + CLIP-L, a linear
6 # MLP projector and a DeepSeek-V2 text backbone). The only architectural
7 # difference is the language model, which is a DeepSeek-V2 *MoE* with plain
8 # multi-head attention (``use_mla=False``) instead of the dense MLA backbone.
9 # We therefore reuse ``DeepseekVLV2Config`` for parsing the nested config.
10
11 from vllm.transformers_utils.configs.deepseek_vl2 import DeepseekVLV2Config
12
13
14 class UnlimitedOCRConfig(DeepseekVLV2Config):
15 model_type = "unlimited-ocr"
16
17 # An explicit ``__init__`` is required: Transformers v5 processes each
18 # concrete config class' ``__init__`` signature to build nested sub-configs,
19 # and an empty subclass (only overriding ``model_type``) would skip
20 # ``DeepseekVLV2Config.__init__``, leaving ``text_config`` unset.
21 def __init__(
22 self,
23 tile_tag: str = "2D",
24 global_view_pos: str = "head",
25 candidate_resolutions: tuple[tuple[int, int]] = ((384, 384),),
26 rswa_window: int = 128,
27 **kwargs,
28 ):
29 super().__init__(
30 tile_tag=tile_tag,
31 global_view_pos=global_view_pos,
32 candidate_resolutions=candidate_resolutions,
33 **kwargs,
34 )
35 self.rswa_window = rswa_window