1- """VideoLLaMA3 model configuration"""
1+ # 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨
2+ # This file was automatically generated from src/transformers/models/videollama3/modular_videollama3.py.
3+ # Do NOT edit this file manually as any edits will be overwritten by the generation of
4+ # the file from the modular. If any change should be done, please apply the change to the
5+ # modular_videollama3.py file directly. One of our CI enforces this.
6+ # 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨
27
38from ...configuration_utils import PretrainedConfig
4- from ...utils import logging
5- from ..auto import CONFIG_MAPPING , AutoConfig
6- from ..qwen2 import Qwen2Config
7-
8-
9- logger = logging .get_logger (__name__ )
9+ from ..qwen2 .configuration_qwen2 import Qwen2Config
1010
1111
1212class Videollama3VisionConfig (PretrainedConfig ):
@@ -31,19 +31,21 @@ class Videollama3VisionConfig(PretrainedConfig):
3131 The epsilon used by the layer normalization layers.
3232 attention_dropout (`float`, *optional*, defaults to 0.0):
3333 The dropout ratio for the attention probabilities.
34+ initializer_range (`float`, *optional*, defaults to 0.02):
35+ The standard deviation of the truncated_normal_initializer for initializing all weight matrices.
3436 """
3537
3638 model_type = "videollama3_vision"
3739 base_config_key = "vision_config"
3840
3941 def __init__ (
4042 self ,
41- hidden_size = 1152 ,
42- intermediate_size = 4304 ,
43- num_hidden_layers = 27 ,
44- num_attention_heads = 16 ,
43+ hidden_size = 768 ,
44+ intermediate_size = 3072 ,
45+ num_hidden_layers = 12 ,
46+ num_attention_heads = 12 ,
4547 num_channels = 3 ,
46- patch_size = 14 ,
48+ patch_size = 16 ,
4749 hidden_act = "gelu_pytorch_tanh" ,
4850 layer_norm_eps = 1e-6 ,
4951 attention_dropout = 0.0 ,
@@ -58,9 +60,10 @@ def __init__(
5860 self .num_attention_heads = num_attention_heads
5961 self .num_channels = num_channels
6062 self .patch_size = patch_size
61- self .hidden_act = hidden_act
62- self .layer_norm_eps = layer_norm_eps
6363 self .attention_dropout = attention_dropout
64+ self .layer_norm_eps = layer_norm_eps
65+ self .hidden_act = hidden_act
66+
6467 self .initializer_range = initializer_range
6568
6669
@@ -71,60 +74,42 @@ class Videollama3Config(PretrainedConfig):
7174 The config object or dictionary of the text backbone.
7275 vision_config (`Union[PreTrainedConfig, dict]`, *optional*, defaults to `Videollama3VisionConfig`):
7376 The config object or dictionary of the vision backbone.
74- use_token_compression (`bool`, *optional*, defaults to `False`):
75- Whether to use temporal token compression to reduce the number of video tokens.
7677 image_token_id (`int`, *optional*, defaults to -1):
7778 The image token index to encode the image prompt.
7879 video_token_id (`int`, *optional*, defaults to -1):
7980 The video token index to encode the image prompt.
81+ use_token_compression (`bool`, *optional*, defaults to `False`):
82+ Whether to use temporal token compression to reduce the number of video tokens.
8083 """
8184
8285 model_type = "videollama3"
83- sub_configs = {"vision_config" : Videollama3VisionConfig , "text_config" : AutoConfig }
86+ sub_configs = {"vision_config" : Videollama3VisionConfig , "text_config" : Qwen2Config }
8487 keys_to_ignore_at_inference = ["past_key_values" ]
8588
8689 def __init__ (
8790 self ,
8891 text_config = None ,
8992 vision_config = None ,
93+ image_token_id = 151655 ,
94+ video_token_id = 151656 ,
9095 use_token_compression = False ,
91- image_token_id = - 1 ,
92- video_token_id = - 1 ,
9396 ** kwargs ,
9497 ):
95- if text_config is None :
96- self .text_config = Qwen2Config (** kwargs )
97- logger .info ("text_config is None, using default qwen2 config" )
98- elif isinstance (text_config , dict ):
99- assert "model_type" in text_config , "text_config must contain 'model_type' key"
100- self .text_config = CONFIG_MAPPING [text_config ["model_type" ]](** text_config )
101- elif isinstance (text_config , PretrainedConfig ):
102- self .text_config = text_config
103- else :
104- raise ValueError (
105- "text_config must be a dictionary, PretrainedConfig instance, or None. "
106- f"Got { type (text_config )} instead."
107- )
98+ super ().__init__ (** kwargs )
99+ if isinstance (vision_config , dict ):
100+ self .vision_config = self .sub_configs ["vision_config" ](** vision_config )
101+ elif vision_config is None :
102+ self .vision_config = self .sub_configs ["vision_config" ]()
108103
109- if vision_config is None :
110- self .vision_config = Videollama3VisionConfig ()
111- logger .info ("vision_config is None, using default vision config" )
112- elif isinstance (vision_config , dict ):
113- assert "model_type" in vision_config , "vision_config must contain 'model_type' key"
114- self .vision_config = CONFIG_MAPPING [vision_config ["model_type" ]](** vision_config )
115- elif isinstance (vision_config , PretrainedConfig ):
116- self .vision_config = vision_config
117- else :
118- raise ValueError (
119- "vision_config must be a dictionary, PretrainedConfig instance, or None. "
120- f"Got { type (vision_config )} instead."
121- )
104+ if isinstance (text_config , dict ):
105+ self .text_config = self .sub_configs ["text_config" ](** text_config )
106+ elif text_config is None :
107+ # For BC use all kwargs to init `TextConfig`
108+ self .text_config = self .sub_configs ["text_config" ](** kwargs )
122109
123- self .use_token_compression = use_token_compression
124110 self .image_token_id = image_token_id
125111 self .video_token_id = video_token_id
126-
127- super ().__init__ (** kwargs )
112+ self .use_token_compression = use_token_compression
128113
129114
130- __all__ = ["Videollama3Config " , "Videollama3VisionConfig " ]
115+ __all__ = ["Videollama3VisionConfig " , "Videollama3Config " ]
0 commit comments