lmms-lab-encoder/onevision-encoder-large
15100
1from transformers.configuration_utils import PretrainedConfig2from transformers.utils import logging3 4 5logger = logging.get_logger(__name__)6 7 8class OneVisionEncoderConfig(PretrainedConfig):9 r"""10 This is the configuration class to store the configuration of a [`OneVisionEncoderModel`]. It is used to instantiate a11 OneVision Encoder model according to the specified arguments, defining the model architecture. Instantiating a configuration12 with the defaults will yield a similar configuration to that of the OneVision Encoder architecture.13 14 Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the15 documentation from [`PretrainedConfig`] for more information.16 17 Args:18 hidden_size (`int`, *optional*, defaults to 1024):19 Dimensionality of the encoder layers and the pooler layer.20 intermediate_size (`int`, *optional*, defaults to 4096):21 Dimensionality of the "intermediate" (i.e., feed-forward) layer in the Transformer encoder.22 num_hidden_layers (`int`, *optional*, defaults to 24):23 Number of hidden layers in the Transformer encoder.24 num_attention_heads (`int`, *optional*, defaults to 16):25 Number of attention heads for each attention layer in the Transformer encoder.26 num_channels (`int`, *optional*, defaults to 3):27 The number of input channels.28 image_size (`int`, *optional*, defaults to 224):29 The size (resolution) of each image.30 patch_size (`int`, *optional*, defaults to 14):31 The size (resolution) of each patch.32 hidden_act (`str` or `function`, *optional*, defaults to `"gelu"`):33 The non-linear activation function (function or string) in the encoder and pooler.34 layer_norm_eps (`float`, *optional*, defaults to 1e-6):35 The epsilon used by the layer normalization layers.36 layer_norm_type (`str`, *optional*, defaults to `"layer_norm"`):37 The type of layer normalization to use. Supported values: `"layer_norm"`, `"rms_norm"`.38 attention_dropout (`float`, *optional*, defaults to 0.0):39 The dropout ratio for the attention probabilities.40 initializer_range (`float`, *optional*, defaults to 0.02):41 The standard deviation of the truncated_normal_initializer for initializing all weight matrices.42 rope_theta (`float`, *optional*, defaults to 10000.0):43 The base period of the RoPE embeddings.44 use_head (`bool`, *optional*, defaults to `True`):45 Whether to use the pooling head.46 47 Example:48 49 ```python50 >>> from configuration_onevision_encoder import OneVisionEncoderConfig51 >>> from modeling_onevision_encoder import OneVisionEncoderModel52 53 >>> # Initializing a OneVisionEncoder configuration54 >>> configuration = OneVisionEncoderConfig()55 56 >>> # Initializing a model (with random weights) from the configuration57 >>> model = OneVisionEncoderModel(configuration)58 59 >>> # Accessing the model configuration60 >>> configuration = model.config61 ```62 """63 64 model_type = "onevision_encoder"65 66 def __init__(67 self,68 hidden_size=1024,69 intermediate_size=4096,70 num_hidden_layers=24,71 num_attention_heads=16,72 num_channels=3,73 image_size=448,74 patch_size=14,75 hidden_act="gelu",76 layer_norm_eps=1e-6,77 layer_norm_type="layer_norm",78 attention_dropout=0.0,79 initializer_range=0.02,80 rope_theta=10000.0,81 rope_temporal_size=64,82 use_head=True,83 **kwargs,84 ):85 super().__init__(**kwargs)86 self.hidden_size = hidden_size87 self.intermediate_size = intermediate_size88 self.num_hidden_layers = num_hidden_layers89 self.num_attention_heads = num_attention_heads90 self.num_channels = num_channels91 self.image_size = image_size92 self.patch_size = patch_size93 self.hidden_act = hidden_act94 self.layer_norm_eps = layer_norm_eps95 self.layer_norm_type = layer_norm_type96 self.attention_dropout = attention_dropout97 self.initializer_range = initializer_range98 self.rope_theta = rope_theta99 self.rope_temporal_size = rope_temporal_size # None=use actual frames, int=fixed size (legacy: 64)100 self.use_head = use_head101 