Upload config.json with huggingface_hub
Browse files- config.json +93 -288
config.json
CHANGED
|
@@ -1,288 +1,93 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
The base period of the RoPE embeddings.
|
| 95 |
-
use_sliding_window (`bool`, *optional*, defaults to `False`):
|
| 96 |
-
Whether to use sliding window attention.
|
| 97 |
-
sliding_window (`int`, *optional*, defaults to 4096):
|
| 98 |
-
Sliding window attention (SWA) window size. If not specified, will default to `4096`.
|
| 99 |
-
max_window_layers (`int`, *optional*, defaults to 80):
|
| 100 |
-
The number of layers that use SWA (Sliding Window Attention). The bottom layers use SWA while the top use full attention.
|
| 101 |
-
attention_dropout (`float`, *optional*, defaults to 0.0):
|
| 102 |
-
The dropout ratio for the attention probabilities.
|
| 103 |
-
rope_scaling (`Dict`, *optional*):
|
| 104 |
-
Dictionary containing the scaling configuration for the RoPE embeddings. NOTE: if you apply new rope type
|
| 105 |
-
and you expect the model to work on longer `max_position_embeddings`, we recommend you to update this value
|
| 106 |
-
accordingly.
|
| 107 |
-
Expected contents:
|
| 108 |
-
`rope_type` (`str`):
|
| 109 |
-
The sub-variant of RoPE to use. Can be one of ['default', 'linear', 'dynamic', 'yarn', 'longrope',
|
| 110 |
-
'llama3'], with 'default' being the original RoPE implementation.
|
| 111 |
-
`factor` (`float`, *optional*):
|
| 112 |
-
Used with all rope types except 'default'. The scaling factor to apply to the RoPE embeddings. In
|
| 113 |
-
most scaling types, a `factor` of x will enable the model to handle sequences of length x *
|
| 114 |
-
original maximum pre-trained length.
|
| 115 |
-
`original_max_position_embeddings` (`int`, *optional*):
|
| 116 |
-
Used with 'dynamic', 'longrope' and 'llama3'. The original max position embeddings used during
|
| 117 |
-
pretraining.
|
| 118 |
-
`attention_factor` (`float`, *optional*):
|
| 119 |
-
Used with 'yarn' and 'longrope'. The scaling factor to be applied on the attention
|
| 120 |
-
computation. If unspecified, it defaults to value recommended by the implementation, using the
|
| 121 |
-
`factor` field to infer the suggested value.
|
| 122 |
-
`beta_fast` (`float`, *optional*):
|
| 123 |
-
Only used with 'yarn'. Parameter to set the boundary for extrapolation (only) in the linear
|
| 124 |
-
ramp function. If unspecified, it defaults to 32.
|
| 125 |
-
`beta_slow` (`float`, *optional*):
|
| 126 |
-
Only used with 'yarn'. Parameter to set the boundary for interpolation (only) in the linear
|
| 127 |
-
ramp function. If unspecified, it defaults to 1.
|
| 128 |
-
`short_factor` (`List[float]`, *optional*):
|
| 129 |
-
Only used with 'longrope'. The scaling factor to be applied to short contexts (<
|
| 130 |
-
`original_max_position_embeddings`). Must be a list of numbers with the same length as the hidden
|
| 131 |
-
size divided by the number of attention heads divided by 2
|
| 132 |
-
`long_factor` (`List[float]`, *optional*):
|
| 133 |
-
Only used with 'longrope'. The scaling factor to be applied to long contexts (<
|
| 134 |
-
`original_max_position_embeddings`). Must be a list of numbers with the same length as the hidden
|
| 135 |
-
size divided by the number of attention heads divided by 2
|
| 136 |
-
`low_freq_factor` (`float`, *optional*):
|
| 137 |
-
Only used with 'llama3'. Scaling factor applied to low frequency components of the RoPE
|
| 138 |
-
`high_freq_factor` (`float`, *optional*):
|
| 139 |
-
Only used with 'llama3'. Scaling factor applied to high frequency components of the RoPE
|
| 140 |
-
image_token_id (`int`, *optional*):
|
| 141 |
-
Token index used as placeholder for image embeddings.
|
| 142 |
-
video_token_id (`int`, *optional*):
|
| 143 |
-
Token index used as placeholder for video embeddings.
|
| 144 |
-
|
| 145 |
-
"""
|
| 146 |
-
|
| 147 |
-
model_type = "LLaVAOneVision1_5_text"
|
| 148 |
-
base_config_key = "text_config"
|
| 149 |
-
keys_to_ignore_at_inference = ["past_key_values"]
|
| 150 |
-
# Default tensor parallel plan for base model `Qwen2VL`
|
| 151 |
-
base_model_tp_plan = {
|
| 152 |
-
"layers.*.self_attn.q_proj": "colwise",
|
| 153 |
-
"layers.*.self_attn.k_proj": "colwise",
|
| 154 |
-
"layers.*.self_attn.v_proj": "colwise",
|
| 155 |
-
"layers.*.self_attn.o_proj": "rowwise",
|
| 156 |
-
"layers.*.mlp.gate_proj": "colwise",
|
| 157 |
-
"layers.*.mlp.up_proj": "colwise",
|
| 158 |
-
"layers.*.mlp.down_proj": "rowwise",
|
| 159 |
-
}
|
| 160 |
-
base_model_pp_plan = {
|
| 161 |
-
"embed_tokens": (["input_ids"], ["inputs_embeds"]),
|
| 162 |
-
"layers": (["hidden_states", "attention_mask"], ["hidden_states"]),
|
| 163 |
-
"norm": (["hidden_states"], ["hidden_states"]),
|
| 164 |
-
}
|
| 165 |
-
|
| 166 |
-
def __init__(
|
| 167 |
-
self,
|
| 168 |
-
vocab_size=151936,
|
| 169 |
-
hidden_size=4096,
|
| 170 |
-
intermediate_size=12288,
|
| 171 |
-
num_hidden_layers=36,
|
| 172 |
-
num_attention_heads=32,
|
| 173 |
-
num_key_value_heads=8,
|
| 174 |
-
head_dim=128,
|
| 175 |
-
hidden_act="silu",
|
| 176 |
-
max_position_embeddings=32768,
|
| 177 |
-
initializer_range=0.02,
|
| 178 |
-
rms_norm_eps=1e-06,
|
| 179 |
-
use_cache=True,
|
| 180 |
-
tie_word_embeddings=False,
|
| 181 |
-
rope_theta=1000000.0,
|
| 182 |
-
attention_bias=False,
|
| 183 |
-
use_sliding_window=False,
|
| 184 |
-
sliding_window=None,
|
| 185 |
-
max_window_layers=36,
|
| 186 |
-
attention_dropout=0.0,
|
| 187 |
-
rope_scaling=None,
|
| 188 |
-
layer_types=None,
|
| 189 |
-
image_token_id=None,
|
| 190 |
-
video_token_id=None,
|
| 191 |
-
**kwargs,
|
| 192 |
-
):
|
| 193 |
-
self.vocab_size = vocab_size
|
| 194 |
-
self.max_position_embeddings = max_position_embeddings
|
| 195 |
-
self.hidden_size = hidden_size
|
| 196 |
-
self.intermediate_size = intermediate_size
|
| 197 |
-
self.num_hidden_layers = num_hidden_layers
|
| 198 |
-
self.num_attention_heads = num_attention_heads
|
| 199 |
-
self.use_sliding_window = use_sliding_window
|
| 200 |
-
self.sliding_window = sliding_window
|
| 201 |
-
self.max_window_layers = max_window_layers
|
| 202 |
-
|
| 203 |
-
# for backward compatibility
|
| 204 |
-
if num_key_value_heads is None:
|
| 205 |
-
num_key_value_heads = num_attention_heads
|
| 206 |
-
|
| 207 |
-
self.num_key_value_heads = num_key_value_heads
|
| 208 |
-
self.head_dim = head_dim
|
| 209 |
-
self.hidden_act = hidden_act
|
| 210 |
-
self.initializer_range = initializer_range
|
| 211 |
-
self.rms_norm_eps = rms_norm_eps
|
| 212 |
-
self.use_cache = use_cache
|
| 213 |
-
self.rope_theta = rope_theta
|
| 214 |
-
self.attention_dropout = attention_dropout
|
| 215 |
-
self.rope_scaling = rope_scaling
|
| 216 |
-
self.attention_bias = attention_bias
|
| 217 |
-
self.tie_word_embeddings = tie_word_embeddings
|
| 218 |
-
|
| 219 |
-
# Validate the correctness of rotary position embeddings parameters
|
| 220 |
-
# BC: if there is a 'type' field, move it to 'rope_type'.
|
| 221 |
-
# and change type from 'mrope' to 'default' because `mrope` does default RoPE calculations
|
| 222 |
-
# one can set it to "linear"/"dynamic" etc. to have scaled RoPE
|
| 223 |
-
# TODO: @raushan update config in the hub
|
| 224 |
-
if self.rope_scaling is not None and "type" in self.rope_scaling:
|
| 225 |
-
if self.rope_scaling["type"] == "mrope":
|
| 226 |
-
self.rope_scaling["type"] = "default"
|
| 227 |
-
self.rope_scaling["rope_type"] = self.rope_scaling["type"]
|
| 228 |
-
rope_config_validation(self, ignore_keys={"mrope_section"})
|
| 229 |
-
self.image_token_id = image_token_id
|
| 230 |
-
self.video_token_id = video_token_id
|
| 231 |
-
|
| 232 |
-
self.layer_types = layer_types
|
| 233 |
-
if self.layer_types is None:
|
| 234 |
-
self.layer_types = [
|
| 235 |
-
"sliding_attention"
|
| 236 |
-
if self.sliding_window is not None and i >= self.max_window_layers
|
| 237 |
-
else "full_attention"
|
| 238 |
-
for i in range(self.num_hidden_layers)
|
| 239 |
-
]
|
| 240 |
-
layer_type_validation(self.layer_types)
|
| 241 |
-
|
| 242 |
-
super().__init__(tie_word_embeddings=tie_word_embeddings, **kwargs)
|
| 243 |
-
|
| 244 |
-
|
| 245 |
-
class Llavaonevision1_5Config(PretrainedConfig):
|
| 246 |
-
r"""
|
| 247 |
-
Args:
|
| 248 |
-
text_config (`Union[PreTrainedConfig, dict]`, *optional*, defaults to `LLaVAOneVision1_5_TextConfig`):
|
| 249 |
-
The config object or dictionary of the text backbone.
|
| 250 |
-
vision_config (`Union[PreTrainedConfig, dict]`, *optional*, defaults to `LLaVAOneVision1_5_VisionConfig`):
|
| 251 |
-
The config object or dictionary of the vision backbone.
|
| 252 |
-
image_token_id (`int`, *optional*, defaults to 151655):
|
| 253 |
-
The image token index to encode the image prompt.
|
| 254 |
-
video_token_id (`int`, *optional*, defaults to 151656):
|
| 255 |
-
The video token index to encode the image prompt.
|
| 256 |
-
"""
|
| 257 |
-
|
| 258 |
-
model_type = "llavaonevision1_5"
|
| 259 |
-
sub_configs = {"vision_config": RiceConfig, "text_config": LLaVAOneVision1_5_TextConfig}
|
| 260 |
-
keys_to_ignore_at_inference = ["past_key_values"]
|
| 261 |
-
|
| 262 |
-
def __init__(
|
| 263 |
-
self,
|
| 264 |
-
text_config=None,
|
| 265 |
-
vision_config=None,
|
| 266 |
-
image_token_id=151655,
|
| 267 |
-
video_token_id=151656,
|
| 268 |
-
vocab_size=152064,
|
| 269 |
-
**kwargs,
|
| 270 |
-
):
|
| 271 |
-
if isinstance(vision_config, dict):
|
| 272 |
-
self.vision_config = self.sub_configs["vision_config"](**vision_config)
|
| 273 |
-
elif vision_config is None:
|
| 274 |
-
self.vision_config = self.sub_configs["vision_config"]()
|
| 275 |
-
|
| 276 |
-
if isinstance(text_config, dict):
|
| 277 |
-
self.text_config = self.sub_configs["text_config"](**text_config)
|
| 278 |
-
elif text_config is None:
|
| 279 |
-
# For BC use all kwargs to init `TextConfig`
|
| 280 |
-
self.text_config = self.sub_configs["text_config"](**kwargs)
|
| 281 |
-
|
| 282 |
-
self.image_token_id = image_token_id
|
| 283 |
-
self.video_token_id = video_token_id
|
| 284 |
-
self.vocab_size = vocab_size
|
| 285 |
-
|
| 286 |
-
super().__init__(**kwargs)
|
| 287 |
-
|
| 288 |
-
__all__ = ["Llavaonevision1_5Config", "LLaVAOneVision1_5_TextConfig"]
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"architectures": [
|
| 3 |
+
"LLaVAOneVision1_5_ForConditionalGeneration"
|
| 4 |
+
],
|
| 5 |
+
"image_token_id": 151655,
|
| 6 |
+
"auto_map": {
|
| 7 |
+
"AutoConfig": "configuration_llavaonevision1_5.Llavaonevision1_5Config",
|
| 8 |
+
"AutoModel": "modeling_llavaonevision1_5.LLaVAOneVision1_5_ForConditionalGeneration",
|
| 9 |
+
"AutoModelForCausalLM": "modeling_llavaonevision1_5.LLaVAOneVision1_5_ForConditionalGeneration"
|
| 10 |
+
},
|
| 11 |
+
"text_config": {
|
| 12 |
+
"attention_bias": false,
|
| 13 |
+
"attention_dropout": 0.0,
|
| 14 |
+
"head_dim": 128,
|
| 15 |
+
"hidden_act": "silu",
|
| 16 |
+
"hidden_size": 4096,
|
| 17 |
+
"image_token_id": null,
|
| 18 |
+
"initializer_range": 0.02,
|
| 19 |
+
"intermediate_size": 12288,
|
| 20 |
+
"layer_types": [
|
| 21 |
+
"full_attention",
|
| 22 |
+
"full_attention",
|
| 23 |
+
"full_attention",
|
| 24 |
+
"full_attention",
|
| 25 |
+
"full_attention",
|
| 26 |
+
"full_attention",
|
| 27 |
+
"full_attention",
|
| 28 |
+
"full_attention",
|
| 29 |
+
"full_attention",
|
| 30 |
+
"full_attention",
|
| 31 |
+
"full_attention",
|
| 32 |
+
"full_attention",
|
| 33 |
+
"full_attention",
|
| 34 |
+
"full_attention",
|
| 35 |
+
"full_attention",
|
| 36 |
+
"full_attention",
|
| 37 |
+
"full_attention",
|
| 38 |
+
"full_attention",
|
| 39 |
+
"full_attention",
|
| 40 |
+
"full_attention",
|
| 41 |
+
"full_attention",
|
| 42 |
+
"full_attention",
|
| 43 |
+
"full_attention",
|
| 44 |
+
"full_attention",
|
| 45 |
+
"full_attention",
|
| 46 |
+
"full_attention",
|
| 47 |
+
"full_attention",
|
| 48 |
+
"full_attention",
|
| 49 |
+
"full_attention",
|
| 50 |
+
"full_attention",
|
| 51 |
+
"full_attention",
|
| 52 |
+
"full_attention",
|
| 53 |
+
"full_attention",
|
| 54 |
+
"full_attention",
|
| 55 |
+
"full_attention",
|
| 56 |
+
"full_attention"
|
| 57 |
+
],
|
| 58 |
+
"max_position_embeddings": 32768,
|
| 59 |
+
"max_window_layers": 36,
|
| 60 |
+
"model_type": "LLaVAOneVision1_5_text",
|
| 61 |
+
"num_attention_heads": 32,
|
| 62 |
+
"num_hidden_layers": 36,
|
| 63 |
+
"num_key_value_heads": 8,
|
| 64 |
+
"rms_norm_eps": 1e-06,
|
| 65 |
+
"rope_scaling": null,
|
| 66 |
+
"rope_theta": 1000000.0,
|
| 67 |
+
"sliding_window": null,
|
| 68 |
+
"use_cache": true,
|
| 69 |
+
"use_sliding_window": false,
|
| 70 |
+
"video_token_id": null,
|
| 71 |
+
"vocab_size": 151936
|
| 72 |
+
},
|
| 73 |
+
"torch_dtype": "float32",
|
| 74 |
+
"transformers_version": "4.53.1",
|
| 75 |
+
"video_token_id": 151656,
|
| 76 |
+
"vision_config": {
|
| 77 |
+
"depth": 24,
|
| 78 |
+
"embed_dim": 1024,
|
| 79 |
+
"hidden_act": "gelu",
|
| 80 |
+
"hidden_size": 1024,
|
| 81 |
+
"in_channels": 3,
|
| 82 |
+
"initializer_range": 0.02,
|
| 83 |
+
"intermediate_size": 4096,
|
| 84 |
+
"layer_norm_eps": 1e-05,
|
| 85 |
+
"model_type": "rice_vit",
|
| 86 |
+
"num_heads": 16,
|
| 87 |
+
"patch_size": 14,
|
| 88 |
+
"spatial_merge_size": 2,
|
| 89 |
+
"temporal_patch_size": 1,
|
| 90 |
+
"text_hidden_size": 4096
|
| 91 |
+
},
|
| 92 |
+
"vocab_size": 151936
|
| 93 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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