# 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨 # This file was automatically generated from src/transformers/models/minicpmv4_6/modular_minicpmv4_6.py. # Do NOT edit this file manually as any edits will be overwritten by the generation of # the file from the modular. If any change should be done, please apply the change to the # modular_minicpmv4_6.py file directly. One of our CI enforces this. # 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨 # Copyright 2026 OpenBMB and the HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. from huggingface_hub.dataclasses import strict from ...configuration_utils import PreTrainedConfig from ...utils import auto_docstring from ..auto import CONFIG_MAPPING, AutoConfig @auto_docstring(checkpoint="openbmb/MiniCPM-V-4.6") @strict class MiniCPMV4_6VisionConfig(PreTrainedConfig): r""" insert_layer_id (`int`, *optional*, defaults to 6): Vision encoder layer index after which the window-attention merger is applied. window_kernel_size (`tuple[int, int]`, *optional*, defaults to `(2, 2)`): Window size `(h, w)` for the intermediate window-attention merger. """ model_type = "minicpmv4_6_vision" base_config_key = "vision_config" hidden_size: int = 768 intermediate_size: int = 3072 num_hidden_layers: int = 12 num_attention_heads: int = 12 num_channels: int = 3 image_size: int | list[int] | tuple[int, int] = 224 patch_size: int | list[int] | tuple[int, int] = 16 hidden_act: str = "gelu_pytorch_tanh" layer_norm_eps: float = 1e-6 attention_dropout: float | int = 0.0 insert_layer_id: int = 6 window_kernel_size: tuple[int, int] | list[int] = (2, 2) @property def window_hidden_size(self) -> int: return self.hidden_size * self.window_kernel_size[0] * self.window_kernel_size[1] @property def window_intermediate_size(self) -> int: return self.intermediate_size * self.window_kernel_size[0] * self.window_kernel_size[1] @auto_docstring(checkpoint="openbmb/MiniCPM-V-4.6") @strict class MiniCPMV4_6Config(PreTrainedConfig): r""" insert_layer_id (`int`, *optional*, defaults to 6): Vision encoder layer index after which the window-attention merger is applied. image_size (`int`, *optional*, defaults to 448): Base resolution for image preprocessing. drop_vision_last_layer (`bool`, *optional*, defaults to `False`): Whether to drop the last layer of the vision encoder. image_token_id (`int`, *optional*): Token id used as the image placeholder. video_token_id (`int`, *optional*): Token id used as the video placeholder. downsample_mode (`str`, *optional*, defaults to `"16x"`): Visual token downsampling ratio. `"4x"` keeps 4× more tokens. merge_kernel_size (`tuple[int, int]`, *optional*, defaults to `(2, 2)`): Kernel size `(h, w)` for merging adjacent visual patches in the Merger. merger_times (`int`, *optional*, defaults to 1): Number of iterative merge rounds in the Merger. """ model_type = "minicpmv4_6" sub_configs = {"text_config": AutoConfig, "vision_config": MiniCPMV4_6VisionConfig} text_config: dict | PreTrainedConfig | None = None vision_config: dict | PreTrainedConfig | None = None insert_layer_id: int = 6 image_size: int = 448 drop_vision_last_layer: bool = False image_token_id: int | None = None video_token_id: int | None = None tie_word_embeddings: bool = False downsample_mode: str = "16x" merge_kernel_size: tuple[int, int] | list[int] = (2, 2) merger_times: int = 1 def __post_init__(self, **kwargs): if isinstance(self.vision_config, dict): self.vision_config.pop("model_type", None) self.vision_config = MiniCPMV4_6VisionConfig(**self.vision_config) elif self.vision_config is None: self.vision_config = MiniCPMV4_6VisionConfig() self.vision_config.insert_layer_id = self.insert_layer_id self.patch_size = self.vision_config.patch_size if isinstance(self.text_config, dict): self.text_config = CONFIG_MAPPING[self.text_config["model_type"]](**self.text_config) elif self.text_config is None: self.text_config = CONFIG_MAPPING["qwen3_5_text"]() super().__post_init__(**kwargs) __all__ = ["MiniCPMV4_6Config", "MiniCPMV4_6VisionConfig"]