# 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨 # This file was automatically generated from src/transformers/models/tipsv2/modular_tipsv2.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_tipsv2.py file directly. One of our CI enforces this. # 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨 # Copyright 2026 Google LLC 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 ...backbone_utils import BackboneConfigMixin from ...configuration_utils import PreTrainedConfig from ...utils import auto_docstring @auto_docstring(checkpoint="google/tipsv2-b14") @strict class Tipsv2VisionConfig(BackboneConfigMixin, PreTrainedConfig): r""" layerscale_value (`float`, *optional*, defaults to `1.0`): Initial value to use for layer scale. use_swiglu_ffn (`bool`, *optional*, defaults to `False`): Whether to use the SwiGLU feedforward neural network. Otherwise a standard MLP with `hidden_act` as activation function is used. num_register_tokens (`int`, *optional*, defaults to `1`): Number of register tokens to use. apply_layernorm (`bool`, *optional*, defaults to `True`): Whether to apply layer normalization to the feature maps in case the model is used as backbone. reshape_hidden_states (`bool`, *optional*, defaults to `True`): Whether to reshape the feature maps to 4D tensors of shape `(batch_size, hidden_size, height, width)` in case the model is used as backbone. If `False`, the feature maps will be 3D tensors of shape `(batch_size, seq_len, hidden_size)`. Example: ```python >>> from transformers import Tipsv2VisionConfig, Tipsv2VisionModel >>> configuration = Tipsv2VisionConfig() >>> model = Tipsv2VisionModel(configuration) >>> configuration = model.config ```""" model_type = "tipsv2_vision_model" hidden_size: int = 768 num_hidden_layers: int = 12 num_attention_heads: int = 12 mlp_ratio: int | float = 4 # float required for so400m14 checkpoint hidden_act: str = "gelu" hidden_dropout_prob: float | int = 0.0 attention_probs_dropout_prob: float | int = 0.0 initializer_range: float = 0.02 layer_norm_eps: float = 1e-6 image_size: int | list[int] | tuple[int, int] = 448 patch_size: int | list[int] | tuple[int, int] = 14 num_channels: int = 3 qkv_bias: bool = True layerscale_value: float = 1.0 drop_path_rate: float | int = 0.0 use_swiglu_ffn: bool = False num_register_tokens: int = 1 _out_features: list[str] | None = None _out_indices: list[int] | None = None apply_layernorm: bool = True reshape_hidden_states: bool = True base_config_key = "vision_config" def __post_init__(self, **kwargs): self.stage_names = ["stem"] + [f"stage{idx}" for idx in range(1, self.num_hidden_layers + 1)] self.set_output_features_output_indices( out_indices=kwargs.pop("out_indices", None), out_features=kwargs.pop("out_features", None) ) super().__post_init__(**kwargs) @auto_docstring(checkpoint="google/tipsv2-b14") @strict class Tipsv2TextConfig(PreTrainedConfig): r""" scale_sqrt_depth (`bool`, *optional*, defaults to `True`): Whether to scale token embeddings by `sqrt(hidden_size)` before adding sinusoidal position embeddings. pooling_epsilon (`float`, *optional*, defaults to `1e-8`): Epsilon added to the valid token count when computing masked mean pooling. Example: ```python >>> from transformers import Tipsv2TextConfig, Tipsv2TextModel >>> configuration = Tipsv2TextConfig() >>> model = Tipsv2TextModel(configuration) >>> configuration = model.config ```""" model_type = "tipsv2_text_model" base_config_key = "text_config" vocab_size: int = 32000 hidden_size: int = 768 intermediate_size: int = 3072 num_hidden_layers: int = 12 num_attention_heads: int = 12 max_position_embeddings: int = 64 hidden_act: str = "relu" layer_norm_eps: float = 1e-5 attention_dropout: float | int = 0.0 pad_token_id: int | None = 0 bos_token_id: int | None = None eos_token_id: int | list[int] | None = None initializer_range: float = 0.02 scale_sqrt_depth: bool = True pooling_epsilon: float = 1e-8 def validate_architecture(self): """Part of `@strict`-powered validation. Validates the architecture of the config.""" super().validate_architecture() if self.hidden_size % self.num_attention_heads != 0: raise ValueError( f"The hidden size ({self.hidden_size}) is not a multiple of the number of attention " f"heads ({self.num_attention_heads})." ) @auto_docstring(checkpoint="google/tipsv2-b14") @strict class Tipsv2Config(PreTrainedConfig): r""" text_config (`dict`, *optional*): Dictionary of configuration options used to initialize [`Tipsv2TextConfig`]. vision_config (`dict`, *optional*): Dictionary of configuration options used to initialize [`Tipsv2VisionConfig`]. temperature_init_value (`float`, *optional*, defaults to `0.005065968260169029`): Initial value for the learnable temperature parameter used to scale cosine-similarity logits in [`Tipsv2Model`]. Example: ```python >>> from transformers import Tipsv2Config, Tipsv2Model >>> configuration = Tipsv2Config() >>> model = Tipsv2Model(configuration) >>> configuration = model.config >>> from transformers import Tipsv2TextConfig, Tipsv2VisionConfig >>> text_config = Tipsv2TextConfig() >>> vision_config = Tipsv2VisionConfig() >>> config = Tipsv2Config(text_config=text_config, vision_config=vision_config) ```""" model_type = "tipsv2" sub_configs = {"text_config": Tipsv2TextConfig, "vision_config": Tipsv2VisionConfig} text_config: dict | Tipsv2TextConfig | None = None vision_config: dict | Tipsv2VisionConfig | None = None temperature_init_value: float = 0.005065968260169029 def __post_init__(self, **kwargs): if isinstance(self.text_config, dict): self.text_config = self.sub_configs["text_config"](**self.text_config) elif self.text_config is None: self.text_config = self.sub_configs["text_config"]() if isinstance(self.vision_config, dict): self.vision_config = self.sub_configs["vision_config"](**self.vision_config) elif self.vision_config is None: self.vision_config = self.sub_configs["vision_config"]() super().__post_init__(**kwargs) def validate_architecture(self): super().validate_architecture() if ( isinstance(self.text_config, Tipsv2TextConfig) and isinstance(self.vision_config, Tipsv2VisionConfig) and self.text_config.hidden_size != self.vision_config.hidden_size ): raise ValueError( f"`text_config.hidden_size` ({self.text_config.hidden_size}) and " f"`vision_config.hidden_size` ({self.vision_config.hidden_size}) must be equal." ) if self.temperature_init_value <= 0: raise ValueError(f"`temperature_init_value` ({self.temperature_init_value}) must be strictly positive.") __all__ = ["Tipsv2Config", "Tipsv2TextConfig", "Tipsv2VisionConfig"]