Upload Videollama3Qwen2ForCausalLM
Browse files- config.json +44 -0
- configuration_videollama3.py +65 -0
- configuration_videollama3_encoder.py +33 -0
- generation_config.json +14 -0
- model-00001-of-00004.safetensors +3 -0
- model-00002-of-00004.safetensors +3 -0
- model-00003-of-00004.safetensors +3 -0
- model-00004-of-00004.safetensors +3 -0
- model.safetensors.index.json +786 -0
- modeling_videollama3.py +454 -0
- modeling_videollama3_encoder.py +534 -0
config.json
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"architectures": [
|
3 |
+
"Videollama3Qwen2ForCausalLM"
|
4 |
+
],
|
5 |
+
"attention_dropout": 0.0,
|
6 |
+
"auto_map": {
|
7 |
+
"AutoConfig": "configuration_videollama3.Videollama3Qwen2Config",
|
8 |
+
"AutoModelForCausalLM": "modeling_videollama3.Videollama3Qwen2ForCausalLM"
|
9 |
+
},
|
10 |
+
"bos_token_id": 151643,
|
11 |
+
"eos_token_id": 151645,
|
12 |
+
"hidden_act": "silu",
|
13 |
+
"hidden_size": 3584,
|
14 |
+
"image_token_index": 151665,
|
15 |
+
"initializer_range": 0.02,
|
16 |
+
"intermediate_size": 18944,
|
17 |
+
"max_position_embeddings": 32768,
|
18 |
+
"max_window_layers": 28,
|
19 |
+
"mm_projector_type": "mlp2x_gelu",
|
20 |
+
"model_type": "videollama3_qwen2",
|
21 |
+
"num_attention_heads": 28,
|
22 |
+
"num_hidden_layers": 28,
|
23 |
+
"num_key_value_heads": 4,
|
24 |
+
"rms_norm_eps": 1e-06,
|
25 |
+
"rope_scaling": null,
|
26 |
+
"rope_theta": 1000000.0,
|
27 |
+
"sliding_window": null,
|
28 |
+
"tie_word_embeddings": false,
|
29 |
+
"torch_dtype": "bfloat16",
|
30 |
+
"transformers_version": "4.46.3",
|
31 |
+
"use_cache": true,
|
32 |
+
"use_sliding_window": false,
|
33 |
+
"use_token_compression": true,
|
34 |
+
"vision_encoder": null,
|
35 |
+
"vision_encoder_config": {
|
36 |
+
"hidden_size": 1152,
|
37 |
+
"intermediate_size": 4304,
|
38 |
+
"model_type": "videollama3_vision_encoder",
|
39 |
+
"num_attention_heads": 16,
|
40 |
+
"num_hidden_layers": 27,
|
41 |
+
"patch_size": 14
|
42 |
+
},
|
43 |
+
"vocab_size": 152064
|
44 |
+
}
|
configuration_videollama3.py
ADDED
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""VideoLLaMA3 model configuration."""
|
2 |
+
|
3 |
+
import importlib.util
|
4 |
+
import os.path as osp
|
5 |
+
from typing import Optional, Dict, Any
|
6 |
+
|
7 |
+
from transformers import AutoConfig, AutoModel, PretrainedConfig, Qwen2Config
|
8 |
+
|
9 |
+
try:
|
10 |
+
from .configuration_videollama3_encoder import Videollama3VisionEncoderConfig
|
11 |
+
except ModuleNotFoundError:
|
12 |
+
spec = importlib.util.spec_from_file_location(
|
13 |
+
"configuration_videollama3_encoder",
|
14 |
+
osp.join(osp.dirname(__file__), "configuration_videollama3_encoder.py"),
|
15 |
+
)
|
16 |
+
configuration_videollama3_encoder = importlib.util.module_from_spec(spec)
|
17 |
+
spec.loader.exec_module(configuration_videollama3_encoder)
|
18 |
+
Videollama3VisionEncoderConfig = getattr(
|
19 |
+
configuration_videollama3_encoder,
|
20 |
+
"Videollama3VisionEncoderConfig",
|
21 |
+
)
|
22 |
+
|
23 |
+
try:
|
24 |
+
from .modeling_videollama3_encoder import Videollama3VisionEncoderModel
|
25 |
+
except ModuleNotFoundError:
|
26 |
+
spec = importlib.util.spec_from_file_location(
|
27 |
+
"modeling_videollama3_encoder",
|
28 |
+
osp.join(osp.dirname(__file__), "modeling_videollama3_encoder.py"),
|
29 |
+
)
|
30 |
+
modeling_videollama3_encoder = importlib.util.module_from_spec(spec)
|
31 |
+
spec.loader.exec_module(modeling_videollama3_encoder)
|
32 |
+
Videollama3VisionEncoderModel = getattr(
|
33 |
+
modeling_videollama3_encoder,
|
34 |
+
"Videollama3VisionEncoderModel",
|
35 |
+
)
|
36 |
+
|
37 |
+
AutoConfig.register("videollama3_vision_encoder", Videollama3VisionEncoderConfig)
|
38 |
+
AutoModel.register(Videollama3VisionEncoderConfig, Videollama3VisionEncoderModel)
|
39 |
+
|
40 |
+
|
41 |
+
class Videollama3Qwen2Config(Qwen2Config):
|
42 |
+
|
43 |
+
model_type = "videollama3_qwen2"
|
44 |
+
sub_configs = {"vision_encoder_config": Videollama3VisionEncoderConfig}
|
45 |
+
|
46 |
+
def __init__(
|
47 |
+
self,
|
48 |
+
vision_encoder: Optional[str] = None,
|
49 |
+
vision_encoder_config: Dict[str, Any] = {},
|
50 |
+
mm_projector_type: str = "mlp2x_gelu",
|
51 |
+
use_token_compression: bool = True,
|
52 |
+
image_token_index: int = -1,
|
53 |
+
**kwargs,
|
54 |
+
):
|
55 |
+
super().__init__(**kwargs)
|
56 |
+
self.model_type = "videollama3_qwen2"
|
57 |
+
|
58 |
+
self.vision_encoder = vision_encoder
|
59 |
+
if vision_encoder_config is not None and not isinstance(vision_encoder_config, PretrainedConfig):
|
60 |
+
vision_encoder_config = Videollama3VisionEncoderConfig(**vision_encoder_config)
|
61 |
+
self.vision_encoder_config = vision_encoder_config
|
62 |
+
|
63 |
+
self.mm_projector_type = mm_projector_type
|
64 |
+
self.use_token_compression = use_token_compression
|
65 |
+
self.image_token_index = image_token_index
|
configuration_videollama3_encoder.py
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""VideoLLaMA3 vision encoder model configuration."""
|
2 |
+
|
3 |
+
from transformers import PretrainedConfig
|
4 |
+
|
5 |
+
|
6 |
+
class Videollama3VisionEncoderConfig(PretrainedConfig):
|
7 |
+
|
8 |
+
model_type = "videollama3_vision_encoder"
|
9 |
+
|
10 |
+
def __init__(
|
11 |
+
self,
|
12 |
+
hidden_size=768,
|
13 |
+
intermediate_size=3072,
|
14 |
+
num_hidden_layers=12,
|
15 |
+
num_attention_heads=12,
|
16 |
+
num_channels=3,
|
17 |
+
patch_size=16,
|
18 |
+
hidden_act="gelu_pytorch_tanh",
|
19 |
+
layer_norm_eps=1e-6,
|
20 |
+
attention_dropout=0.0,
|
21 |
+
**kwargs,
|
22 |
+
):
|
23 |
+
super().__init__(**kwargs)
|
24 |
+
|
25 |
+
self.hidden_size = hidden_size
|
26 |
+
self.intermediate_size = intermediate_size
|
27 |
+
self.num_hidden_layers = num_hidden_layers
|
28 |
+
self.num_attention_heads = num_attention_heads
|
29 |
+
self.num_channels = num_channels
|
30 |
+
self.patch_size = patch_size
|
31 |
+
self.attention_dropout = attention_dropout
|
32 |
+
self.layer_norm_eps = layer_norm_eps
|
33 |
+
self.hidden_act = hidden_act
|
generation_config.json
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"bos_token_id": 151643,
|
3 |
+
"do_sample": true,
|
4 |
+
"eos_token_id": [
|
5 |
+
151645,
|
6 |
+
151643
|
7 |
+
],
|
8 |
+
"pad_token_id": 151643,
|
9 |
+
"repetition_penalty": 1.05,
|
10 |
+
"temperature": 0.7,
|
11 |
+
"top_k": 20,
|
12 |
+
"top_p": 0.8,
|
13 |
+
"transformers_version": "4.46.3"
|
14 |
+
}
|
model-00001-of-00004.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:fcf3cd07a53eaca6c2fba39beb931b0d24dc0472f61fd16cf368f401ce65a0da
|
3 |
+
size 4877660776
|
model-00002-of-00004.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:2e6c1fca735cd93b965ca3d4e760b21c3582f6ca5e138ae7ec4d5b2fc5b52480
|
3 |
+
size 4932751008
|
model-00003-of-00004.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:296db075c639cef89394e3c5384ee7cc03624b8e362d0a77735f727660d88071
|
3 |
+
size 4992883728
|
model-00004-of-00004.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:0471b2563c52a841697c60ebe6da1805267ecaddabe3c35cb9835d2bd21dc89f
|
3 |
+
size 1286291720
|
model.safetensors.index.json
ADDED
@@ -0,0 +1,786 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"metadata": {
|
3 |
+
"total_size": 16089489888
|
4 |
+
},
|
5 |
+
"weight_map": {
|
6 |
+
"lm_head.weight": "model-00004-of-00004.safetensors",
|
7 |
+
"model.embed_tokens.weight": "model-00001-of-00004.safetensors",
|
8 |
+
"model.layers.0.input_layernorm.weight": "model-00001-of-00004.safetensors",
|
9 |
+
"model.layers.0.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
|
10 |
+
"model.layers.0.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
|
11 |
+
"model.layers.0.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
|
12 |
+
"model.layers.0.post_attention_layernorm.weight": "model-00001-of-00004.safetensors",
|
13 |
+
"model.layers.0.self_attn.k_proj.bias": "model-00001-of-00004.safetensors",
|
14 |
+
"model.layers.0.self_attn.k_proj.weight": "model-00001-of-00004.safetensors",
|
15 |
+
"model.layers.0.self_attn.o_proj.weight": "model-00001-of-00004.safetensors",
|
16 |
+
"model.layers.0.self_attn.q_proj.bias": "model-00001-of-00004.safetensors",
|
17 |
+
"model.layers.0.self_attn.q_proj.weight": "model-00001-of-00004.safetensors",
|
18 |
+
"model.layers.0.self_attn.v_proj.bias": "model-00001-of-00004.safetensors",
|
19 |
+
"model.layers.0.self_attn.v_proj.weight": "model-00001-of-00004.safetensors",
|
20 |
+
"model.layers.1.input_layernorm.weight": "model-00001-of-00004.safetensors",
|
21 |
+
"model.layers.1.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
|
22 |
+
"model.layers.1.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
|
23 |
+
"model.layers.1.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
|
24 |
+
"model.layers.1.post_attention_layernorm.weight": "model-00001-of-00004.safetensors",
|
25 |
+
"model.layers.1.self_attn.k_proj.bias": "model-00001-of-00004.safetensors",
|
26 |
+
"model.layers.1.self_attn.k_proj.weight": "model-00001-of-00004.safetensors",
|
27 |
+
"model.layers.1.self_attn.o_proj.weight": "model-00001-of-00004.safetensors",
|
28 |
+
"model.layers.1.self_attn.q_proj.bias": "model-00001-of-00004.safetensors",
|
29 |
+
"model.layers.1.self_attn.q_proj.weight": "model-00001-of-00004.safetensors",
|
30 |
+
"model.layers.1.self_attn.v_proj.bias": "model-00001-of-00004.safetensors",
|
31 |
+
"model.layers.1.self_attn.v_proj.weight": "model-00001-of-00004.safetensors",
|
32 |
+
"model.layers.10.input_layernorm.weight": "model-00002-of-00004.safetensors",
|
33 |
+
"model.layers.10.mlp.down_proj.weight": "model-00002-of-00004.safetensors",
|
34 |
+
"model.layers.10.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
|
35 |
+
"model.layers.10.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
|
36 |
+
"model.layers.10.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
|
37 |
+
"model.layers.10.self_attn.k_proj.bias": "model-00002-of-00004.safetensors",
|
38 |
+
"model.layers.10.self_attn.k_proj.weight": "model-00002-of-00004.safetensors",
|
39 |
+
"model.layers.10.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
|
40 |
+
"model.layers.10.self_attn.q_proj.bias": "model-00002-of-00004.safetensors",
|
41 |
+
"model.layers.10.self_attn.q_proj.weight": "model-00002-of-00004.safetensors",
|
42 |
+
"model.layers.10.self_attn.v_proj.bias": "model-00002-of-00004.safetensors",
|
43 |
+
"model.layers.10.self_attn.v_proj.weight": "model-00002-of-00004.safetensors",
|
44 |
+
"model.layers.11.input_layernorm.weight": "model-00002-of-00004.safetensors",
|
45 |
+
"model.layers.11.mlp.down_proj.weight": "model-00002-of-00004.safetensors",
|
46 |
+
"model.layers.11.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
|
47 |
+
"model.layers.11.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
|
48 |
+
"model.layers.11.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
|
49 |
+
"model.layers.11.self_attn.k_proj.bias": "model-00002-of-00004.safetensors",
|
50 |
+
"model.layers.11.self_attn.k_proj.weight": "model-00002-of-00004.safetensors",
|
51 |
+
"model.layers.11.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
|
52 |
+
"model.layers.11.self_attn.q_proj.bias": "model-00002-of-00004.safetensors",
|
53 |
+
"model.layers.11.self_attn.q_proj.weight": "model-00002-of-00004.safetensors",
|
54 |
+
"model.layers.11.self_attn.v_proj.bias": "model-00002-of-00004.safetensors",
|
55 |
+
"model.layers.11.self_attn.v_proj.weight": "model-00002-of-00004.safetensors",
|
56 |
+
"model.layers.12.input_layernorm.weight": "model-00002-of-00004.safetensors",
|
57 |
+
"model.layers.12.mlp.down_proj.weight": "model-00002-of-00004.safetensors",
|
58 |
+
"model.layers.12.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
|
59 |
+
"model.layers.12.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
|
60 |
+
"model.layers.12.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
|
61 |
+
"model.layers.12.self_attn.k_proj.bias": "model-00002-of-00004.safetensors",
|
62 |
+
"model.layers.12.self_attn.k_proj.weight": "model-00002-of-00004.safetensors",
|
63 |
+
"model.layers.12.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
|
64 |
+
"model.layers.12.self_attn.q_proj.bias": "model-00002-of-00004.safetensors",
|
65 |
+
"model.layers.12.self_attn.q_proj.weight": "model-00002-of-00004.safetensors",
|
66 |
+
"model.layers.12.self_attn.v_proj.bias": "model-00002-of-00004.safetensors",
|
67 |
+
"model.layers.12.self_attn.v_proj.weight": "model-00002-of-00004.safetensors",
|
68 |
+
"model.layers.13.input_layernorm.weight": "model-00002-of-00004.safetensors",
|
69 |
+
"model.layers.13.mlp.down_proj.weight": "model-00002-of-00004.safetensors",
|
70 |
+
"model.layers.13.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
|
71 |
+
"model.layers.13.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
|
72 |
+
"model.layers.13.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
|
73 |
+
"model.layers.13.self_attn.k_proj.bias": "model-00002-of-00004.safetensors",
|
74 |
+
"model.layers.13.self_attn.k_proj.weight": "model-00002-of-00004.safetensors",
|
75 |
+
"model.layers.13.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
|
76 |
+
"model.layers.13.self_attn.q_proj.bias": "model-00002-of-00004.safetensors",
|
77 |
+
"model.layers.13.self_attn.q_proj.weight": "model-00002-of-00004.safetensors",
|
78 |
+
"model.layers.13.self_attn.v_proj.bias": "model-00002-of-00004.safetensors",
|
79 |
+
"model.layers.13.self_attn.v_proj.weight": "model-00002-of-00004.safetensors",
|
80 |
+
"model.layers.14.input_layernorm.weight": "model-00002-of-00004.safetensors",
|
81 |
+
"model.layers.14.mlp.down_proj.weight": "model-00002-of-00004.safetensors",
|
82 |
+
"model.layers.14.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
|
83 |
+
"model.layers.14.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
|
84 |
+
"model.layers.14.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
|
85 |
+
"model.layers.14.self_attn.k_proj.bias": "model-00002-of-00004.safetensors",
|
86 |
+
"model.layers.14.self_attn.k_proj.weight": "model-00002-of-00004.safetensors",
|
87 |
+
"model.layers.14.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
|
88 |
+
"model.layers.14.self_attn.q_proj.bias": "model-00002-of-00004.safetensors",
|
89 |
+
"model.layers.14.self_attn.q_proj.weight": "model-00002-of-00004.safetensors",
|
90 |
+
"model.layers.14.self_attn.v_proj.bias": "model-00002-of-00004.safetensors",
|
91 |
+
"model.layers.14.self_attn.v_proj.weight": "model-00002-of-00004.safetensors",
|
92 |
+
"model.layers.15.input_layernorm.weight": "model-00002-of-00004.safetensors",
|
93 |
+
"model.layers.15.mlp.down_proj.weight": "model-00002-of-00004.safetensors",
|
94 |
+
"model.layers.15.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
|
95 |
+
"model.layers.15.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
|
96 |
+
"model.layers.15.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
|
97 |
+
"model.layers.15.self_attn.k_proj.bias": "model-00002-of-00004.safetensors",
|
98 |
+
"model.layers.15.self_attn.k_proj.weight": "model-00002-of-00004.safetensors",
|
99 |
+
"model.layers.15.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
|
100 |
+
"model.layers.15.self_attn.q_proj.bias": "model-00002-of-00004.safetensors",
|
101 |
+
"model.layers.15.self_attn.q_proj.weight": "model-00002-of-00004.safetensors",
|
102 |
+
"model.layers.15.self_attn.v_proj.bias": "model-00002-of-00004.safetensors",
|
103 |
+
"model.layers.15.self_attn.v_proj.weight": "model-00002-of-00004.safetensors",
|
104 |
+
"model.layers.16.input_layernorm.weight": "model-00002-of-00004.safetensors",
|
105 |
+
"model.layers.16.mlp.down_proj.weight": "model-00002-of-00004.safetensors",
|
106 |
+
"model.layers.16.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
|
107 |
+
"model.layers.16.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
|
108 |
+
"model.layers.16.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
|
109 |
+
"model.layers.16.self_attn.k_proj.bias": "model-00002-of-00004.safetensors",
|
110 |
+
"model.layers.16.self_attn.k_proj.weight": "model-00002-of-00004.safetensors",
|
111 |
+
"model.layers.16.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
|
112 |
+
"model.layers.16.self_attn.q_proj.bias": "model-00002-of-00004.safetensors",
|
113 |
+
"model.layers.16.self_attn.q_proj.weight": "model-00002-of-00004.safetensors",
|
114 |
+
"model.layers.16.self_attn.v_proj.bias": "model-00002-of-00004.safetensors",
|
115 |
+
"model.layers.16.self_attn.v_proj.weight": "model-00002-of-00004.safetensors",
|
116 |
+
"model.layers.17.input_layernorm.weight": "model-00002-of-00004.safetensors",
|
117 |
+
"model.layers.17.mlp.down_proj.weight": "model-00002-of-00004.safetensors",
|
118 |
+
"model.layers.17.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
|
119 |
+
"model.layers.17.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
|
120 |
+
"model.layers.17.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
|
121 |
+
"model.layers.17.self_attn.k_proj.bias": "model-00002-of-00004.safetensors",
|
122 |
+
"model.layers.17.self_attn.k_proj.weight": "model-00002-of-00004.safetensors",
|
123 |
+
"model.layers.17.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
|
124 |
+
"model.layers.17.self_attn.q_proj.bias": "model-00002-of-00004.safetensors",
|
125 |
+
"model.layers.17.self_attn.q_proj.weight": "model-00002-of-00004.safetensors",
|
126 |
+
"model.layers.17.self_attn.v_proj.bias": "model-00002-of-00004.safetensors",
|
127 |
+
"model.layers.17.self_attn.v_proj.weight": "model-00002-of-00004.safetensors",
|
128 |
+
"model.layers.18.input_layernorm.weight": "model-00003-of-00004.safetensors",
|
129 |
+
"model.layers.18.mlp.down_proj.weight": "model-00003-of-00004.safetensors",
|
130 |
+
"model.layers.18.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
|
131 |
+
"model.layers.18.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
|
132 |
+
"model.layers.18.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
|
133 |
+
"model.layers.18.self_attn.k_proj.bias": "model-00002-of-00004.safetensors",
|
134 |
+
"model.layers.18.self_attn.k_proj.weight": "model-00002-of-00004.safetensors",
|
135 |
+
"model.layers.18.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
|
136 |
+
"model.layers.18.self_attn.q_proj.bias": "model-00002-of-00004.safetensors",
|
137 |
+
"model.layers.18.self_attn.q_proj.weight": "model-00002-of-00004.safetensors",
|
138 |
+
"model.layers.18.self_attn.v_proj.bias": "model-00002-of-00004.safetensors",
|
139 |
+
"model.layers.18.self_attn.v_proj.weight": "model-00002-of-00004.safetensors",
|
140 |
+
"model.layers.19.input_layernorm.weight": "model-00003-of-00004.safetensors",
|
141 |
+
"model.layers.19.mlp.down_proj.weight": "model-00003-of-00004.safetensors",
|
142 |
+
"model.layers.19.mlp.gate_proj.weight": "model-00003-of-00004.safetensors",
|
143 |
+
"model.layers.19.mlp.up_proj.weight": "model-00003-of-00004.safetensors",
|
144 |
+
"model.layers.19.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
|
145 |
+
"model.layers.19.self_attn.k_proj.bias": "model-00003-of-00004.safetensors",
|
146 |
+
"model.layers.19.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
|
147 |
+
"model.layers.19.self_attn.o_proj.weight": "model-00003-of-00004.safetensors",
|
148 |
+
"model.layers.19.self_attn.q_proj.bias": "model-00003-of-00004.safetensors",
|
149 |
+
"model.layers.19.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
|
150 |
+
"model.layers.19.self_attn.v_proj.bias": "model-00003-of-00004.safetensors",
|
151 |
+
"model.layers.19.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
|
152 |
+
"model.layers.2.input_layernorm.weight": "model-00001-of-00004.safetensors",
|
153 |
+
"model.layers.2.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
|
154 |
+
"model.layers.2.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
|
155 |
+
"model.layers.2.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
|
156 |
+
"model.layers.2.post_attention_layernorm.weight": "model-00001-of-00004.safetensors",
|
157 |
+
"model.layers.2.self_attn.k_proj.bias": "model-00001-of-00004.safetensors",
|
158 |
+
"model.layers.2.self_attn.k_proj.weight": "model-00001-of-00004.safetensors",
|
159 |
+
"model.layers.2.self_attn.o_proj.weight": "model-00001-of-00004.safetensors",
|
160 |
+
"model.layers.2.self_attn.q_proj.bias": "model-00001-of-00004.safetensors",
|
161 |
+
"model.layers.2.self_attn.q_proj.weight": "model-00001-of-00004.safetensors",
|
162 |
+
"model.layers.2.self_attn.v_proj.bias": "model-00001-of-00004.safetensors",
|
163 |
+
"model.layers.2.self_attn.v_proj.weight": "model-00001-of-00004.safetensors",
|
164 |
+
"model.layers.20.input_layernorm.weight": "model-00003-of-00004.safetensors",
|
165 |
+
"model.layers.20.mlp.down_proj.weight": "model-00003-of-00004.safetensors",
|
166 |
+
"model.layers.20.mlp.gate_proj.weight": "model-00003-of-00004.safetensors",
|
167 |
+
"model.layers.20.mlp.up_proj.weight": "model-00003-of-00004.safetensors",
|
168 |
+
"model.layers.20.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
|
169 |
+
"model.layers.20.self_attn.k_proj.bias": "model-00003-of-00004.safetensors",
|
170 |
+
"model.layers.20.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
|
171 |
+
"model.layers.20.self_attn.o_proj.weight": "model-00003-of-00004.safetensors",
|
172 |
+
"model.layers.20.self_attn.q_proj.bias": "model-00003-of-00004.safetensors",
|
173 |
+
"model.layers.20.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
|
174 |
+
"model.layers.20.self_attn.v_proj.bias": "model-00003-of-00004.safetensors",
|
175 |
+
"model.layers.20.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
|
176 |
+
"model.layers.21.input_layernorm.weight": "model-00003-of-00004.safetensors",
|
177 |
+
"model.layers.21.mlp.down_proj.weight": "model-00003-of-00004.safetensors",
|
178 |
+
"model.layers.21.mlp.gate_proj.weight": "model-00003-of-00004.safetensors",
|
179 |
+
"model.layers.21.mlp.up_proj.weight": "model-00003-of-00004.safetensors",
|
180 |
+
"model.layers.21.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
|
181 |
+
"model.layers.21.self_attn.k_proj.bias": "model-00003-of-00004.safetensors",
|
182 |
+
"model.layers.21.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
|
183 |
+
"model.layers.21.self_attn.o_proj.weight": "model-00003-of-00004.safetensors",
|
184 |
+
"model.layers.21.self_attn.q_proj.bias": "model-00003-of-00004.safetensors",
|
185 |
+
"model.layers.21.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
|
186 |
+
"model.layers.21.self_attn.v_proj.bias": "model-00003-of-00004.safetensors",
|
187 |
+
"model.layers.21.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
|
188 |
+
"model.layers.22.input_layernorm.weight": "model-00003-of-00004.safetensors",
|
189 |
+
"model.layers.22.mlp.down_proj.weight": "model-00003-of-00004.safetensors",
|
190 |
+
"model.layers.22.mlp.gate_proj.weight": "model-00003-of-00004.safetensors",
|
191 |
+
"model.layers.22.mlp.up_proj.weight": "model-00003-of-00004.safetensors",
|
192 |
+
"model.layers.22.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
|
193 |
+
"model.layers.22.self_attn.k_proj.bias": "model-00003-of-00004.safetensors",
|
194 |
+
"model.layers.22.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
|
195 |
+
"model.layers.22.self_attn.o_proj.weight": "model-00003-of-00004.safetensors",
|
196 |
+
"model.layers.22.self_attn.q_proj.bias": "model-00003-of-00004.safetensors",
|
197 |
+
"model.layers.22.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
|
198 |
+
"model.layers.22.self_attn.v_proj.bias": "model-00003-of-00004.safetensors",
|
199 |
+
"model.layers.22.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
|
200 |
+
"model.layers.23.input_layernorm.weight": "model-00003-of-00004.safetensors",
|
201 |
+
"model.layers.23.mlp.down_proj.weight": "model-00003-of-00004.safetensors",
|
202 |
+
"model.layers.23.mlp.gate_proj.weight": "model-00003-of-00004.safetensors",
|
203 |
+
"model.layers.23.mlp.up_proj.weight": "model-00003-of-00004.safetensors",
|
204 |
+
"model.layers.23.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
|
205 |
+
"model.layers.23.self_attn.k_proj.bias": "model-00003-of-00004.safetensors",
|
206 |
+
"model.layers.23.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
|
207 |
+
"model.layers.23.self_attn.o_proj.weight": "model-00003-of-00004.safetensors",
|
208 |
+
"model.layers.23.self_attn.q_proj.bias": "model-00003-of-00004.safetensors",
|
209 |
+
"model.layers.23.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
|
210 |
+
"model.layers.23.self_attn.v_proj.bias": "model-00003-of-00004.safetensors",
|
211 |
+
"model.layers.23.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
|
212 |
+
"model.layers.24.input_layernorm.weight": "model-00003-of-00004.safetensors",
|
213 |
+
"model.layers.24.mlp.down_proj.weight": "model-00003-of-00004.safetensors",
|
214 |
+
"model.layers.24.mlp.gate_proj.weight": "model-00003-of-00004.safetensors",
|
215 |
+
"model.layers.24.mlp.up_proj.weight": "model-00003-of-00004.safetensors",
|
216 |
+
"model.layers.24.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
|
217 |
+
"model.layers.24.self_attn.k_proj.bias": "model-00003-of-00004.safetensors",
|
218 |
+
"model.layers.24.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
|
219 |
+
"model.layers.24.self_attn.o_proj.weight": "model-00003-of-00004.safetensors",
|
220 |
+
"model.layers.24.self_attn.q_proj.bias": "model-00003-of-00004.safetensors",
|
221 |
+
"model.layers.24.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
|
222 |
+
"model.layers.24.self_attn.v_proj.bias": "model-00003-of-00004.safetensors",
|
223 |
+
"model.layers.24.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
|
224 |
+
"model.layers.25.input_layernorm.weight": "model-00003-of-00004.safetensors",
|
225 |
+
"model.layers.25.mlp.down_proj.weight": "model-00003-of-00004.safetensors",
|
226 |
+
"model.layers.25.mlp.gate_proj.weight": "model-00003-of-00004.safetensors",
|
227 |
+
"model.layers.25.mlp.up_proj.weight": "model-00003-of-00004.safetensors",
|
228 |
+
"model.layers.25.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
|
229 |
+
"model.layers.25.self_attn.k_proj.bias": "model-00003-of-00004.safetensors",
|
230 |
+
"model.layers.25.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
|
231 |
+
"model.layers.25.self_attn.o_proj.weight": "model-00003-of-00004.safetensors",
|
232 |
+
"model.layers.25.self_attn.q_proj.bias": "model-00003-of-00004.safetensors",
|
233 |
+
"model.layers.25.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
|
234 |
+
"model.layers.25.self_attn.v_proj.bias": "model-00003-of-00004.safetensors",
|
235 |
+
"model.layers.25.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
|
236 |
+
"model.layers.26.input_layernorm.weight": "model-00003-of-00004.safetensors",
|
237 |
+
"model.layers.26.mlp.down_proj.weight": "model-00003-of-00004.safetensors",
|
238 |
+
"model.layers.26.mlp.gate_proj.weight": "model-00003-of-00004.safetensors",
|
239 |
+
"model.layers.26.mlp.up_proj.weight": "model-00003-of-00004.safetensors",
|
240 |
+
"model.layers.26.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
|
241 |
+
"model.layers.26.self_attn.k_proj.bias": "model-00003-of-00004.safetensors",
|
242 |
+
"model.layers.26.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
|
243 |
+
"model.layers.26.self_attn.o_proj.weight": "model-00003-of-00004.safetensors",
|
244 |
+
"model.layers.26.self_attn.q_proj.bias": "model-00003-of-00004.safetensors",
|
245 |
+
"model.layers.26.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
|
246 |
+
"model.layers.26.self_attn.v_proj.bias": "model-00003-of-00004.safetensors",
|
247 |
+
"model.layers.26.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
|
248 |
+
"model.layers.27.input_layernorm.weight": "model-00003-of-00004.safetensors",
|
249 |
+
"model.layers.27.mlp.down_proj.weight": "model-00003-of-00004.safetensors",
|
250 |
+
"model.layers.27.mlp.gate_proj.weight": "model-00003-of-00004.safetensors",
|
251 |
+
"model.layers.27.mlp.up_proj.weight": "model-00003-of-00004.safetensors",
|
252 |
+
"model.layers.27.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
|
253 |
+
"model.layers.27.self_attn.k_proj.bias": "model-00003-of-00004.safetensors",
|
254 |
+
"model.layers.27.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
|
255 |
+
"model.layers.27.self_attn.o_proj.weight": "model-00003-of-00004.safetensors",
|
256 |
+
"model.layers.27.self_attn.q_proj.bias": "model-00003-of-00004.safetensors",
|
257 |
+
"model.layers.27.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
|
258 |
+
"model.layers.27.self_attn.v_proj.bias": "model-00003-of-00004.safetensors",
|
259 |
+
"model.layers.27.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
|
260 |
+
"model.layers.3.input_layernorm.weight": "model-00001-of-00004.safetensors",
|
261 |
+
"model.layers.3.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
|
262 |
+
"model.layers.3.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
|
263 |
+
"model.layers.3.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
|
264 |
+
"model.layers.3.post_attention_layernorm.weight": "model-00001-of-00004.safetensors",
|
265 |
+
"model.layers.3.self_attn.k_proj.bias": "model-00001-of-00004.safetensors",
|
266 |
+
"model.layers.3.self_attn.k_proj.weight": "model-00001-of-00004.safetensors",
|
267 |
+
"model.layers.3.self_attn.o_proj.weight": "model-00001-of-00004.safetensors",
|
268 |
+
"model.layers.3.self_attn.q_proj.bias": "model-00001-of-00004.safetensors",
|
269 |
+
"model.layers.3.self_attn.q_proj.weight": "model-00001-of-00004.safetensors",
|
270 |
+
"model.layers.3.self_attn.v_proj.bias": "model-00001-of-00004.safetensors",
|
271 |
+
"model.layers.3.self_attn.v_proj.weight": "model-00001-of-00004.safetensors",
|
272 |
+
"model.layers.4.input_layernorm.weight": "model-00001-of-00004.safetensors",
|
273 |
+
"model.layers.4.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
|
274 |
+
"model.layers.4.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
|
275 |
+
"model.layers.4.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
|
276 |
+
"model.layers.4.post_attention_layernorm.weight": "model-00001-of-00004.safetensors",
|
277 |
+
"model.layers.4.self_attn.k_proj.bias": "model-00001-of-00004.safetensors",
|
278 |
+
"model.layers.4.self_attn.k_proj.weight": "model-00001-of-00004.safetensors",
|
279 |
+
"model.layers.4.self_attn.o_proj.weight": "model-00001-of-00004.safetensors",
|
280 |
+
"model.layers.4.self_attn.q_proj.bias": "model-00001-of-00004.safetensors",
|
281 |
+
"model.layers.4.self_attn.q_proj.weight": "model-00001-of-00004.safetensors",
|
282 |
+
"model.layers.4.self_attn.v_proj.bias": "model-00001-of-00004.safetensors",
|
283 |
+
"model.layers.4.self_attn.v_proj.weight": "model-00001-of-00004.safetensors",
|
284 |
+
"model.layers.5.input_layernorm.weight": "model-00001-of-00004.safetensors",
|
285 |
+
"model.layers.5.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
|
286 |
+
"model.layers.5.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
|
287 |
+
"model.layers.5.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
|
288 |
+
"model.layers.5.post_attention_layernorm.weight": "model-00001-of-00004.safetensors",
|
289 |
+
"model.layers.5.self_attn.k_proj.bias": "model-00001-of-00004.safetensors",
|
290 |
+
"model.layers.5.self_attn.k_proj.weight": "model-00001-of-00004.safetensors",
|
291 |
+
"model.layers.5.self_attn.o_proj.weight": "model-00001-of-00004.safetensors",
|
292 |
+
"model.layers.5.self_attn.q_proj.bias": "model-00001-of-00004.safetensors",
|
293 |
+
"model.layers.5.self_attn.q_proj.weight": "model-00001-of-00004.safetensors",
|
294 |
+
"model.layers.5.self_attn.v_proj.bias": "model-00001-of-00004.safetensors",
|
295 |
+
"model.layers.5.self_attn.v_proj.weight": "model-00001-of-00004.safetensors",
|
296 |
+
"model.layers.6.input_layernorm.weight": "model-00001-of-00004.safetensors",
|
297 |
+
"model.layers.6.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
|
298 |
+
"model.layers.6.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
|
299 |
+
"model.layers.6.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
|
300 |
+
"model.layers.6.post_attention_layernorm.weight": "model-00001-of-00004.safetensors",
|
301 |
+
"model.layers.6.self_attn.k_proj.bias": "model-00001-of-00004.safetensors",
|
302 |
+
"model.layers.6.self_attn.k_proj.weight": "model-00001-of-00004.safetensors",
|
303 |
+
"model.layers.6.self_attn.o_proj.weight": "model-00001-of-00004.safetensors",
|
304 |
+
"model.layers.6.self_attn.q_proj.bias": "model-00001-of-00004.safetensors",
|
305 |
+
"model.layers.6.self_attn.q_proj.weight": "model-00001-of-00004.safetensors",
|
306 |
+
"model.layers.6.self_attn.v_proj.bias": "model-00001-of-00004.safetensors",
|
307 |
+
"model.layers.6.self_attn.v_proj.weight": "model-00001-of-00004.safetensors",
|
308 |
+
"model.layers.7.input_layernorm.weight": "model-00001-of-00004.safetensors",
|
309 |
+
"model.layers.7.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
|
310 |
+
"model.layers.7.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
|
311 |
+
"model.layers.7.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
|
312 |
+
"model.layers.7.post_attention_layernorm.weight": "model-00001-of-00004.safetensors",
|
313 |
+
"model.layers.7.self_attn.k_proj.bias": "model-00001-of-00004.safetensors",
|
314 |
+
"model.layers.7.self_attn.k_proj.weight": "model-00001-of-00004.safetensors",
|
315 |
+
"model.layers.7.self_attn.o_proj.weight": "model-00001-of-00004.safetensors",
|
316 |
+
"model.layers.7.self_attn.q_proj.bias": "model-00001-of-00004.safetensors",
|
317 |
+
"model.layers.7.self_attn.q_proj.weight": "model-00001-of-00004.safetensors",
|
318 |
+
"model.layers.7.self_attn.v_proj.bias": "model-00001-of-00004.safetensors",
|
319 |
+
"model.layers.7.self_attn.v_proj.weight": "model-00001-of-00004.safetensors",
|
320 |
+
"model.layers.8.input_layernorm.weight": "model-00002-of-00004.safetensors",
|
321 |
+
"model.layers.8.mlp.down_proj.weight": "model-00002-of-00004.safetensors",
|
322 |
+
"model.layers.8.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
|
323 |
+
"model.layers.8.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
|
324 |
+
"model.layers.8.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
|
325 |
+
"model.layers.8.self_attn.k_proj.bias": "model-00001-of-00004.safetensors",
|
326 |
+
"model.layers.8.self_attn.k_proj.weight": "model-00001-of-00004.safetensors",
|
327 |
+
"model.layers.8.self_attn.o_proj.weight": "model-00001-of-00004.safetensors",
|
328 |
+
"model.layers.8.self_attn.q_proj.bias": "model-00001-of-00004.safetensors",
|
329 |
+
"model.layers.8.self_attn.q_proj.weight": "model-00001-of-00004.safetensors",
|
330 |
+
"model.layers.8.self_attn.v_proj.bias": "model-00001-of-00004.safetensors",
|
331 |
+
"model.layers.8.self_attn.v_proj.weight": "model-00001-of-00004.safetensors",
|
332 |
+
"model.layers.9.input_layernorm.weight": "model-00002-of-00004.safetensors",
|
333 |
+
"model.layers.9.mlp.down_proj.weight": "model-00002-of-00004.safetensors",
|
334 |
+
"model.layers.9.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
|
335 |
+
"model.layers.9.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
|
336 |
+
"model.layers.9.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
|
337 |
+
"model.layers.9.self_attn.k_proj.bias": "model-00002-of-00004.safetensors",
|
338 |
+
"model.layers.9.self_attn.k_proj.weight": "model-00002-of-00004.safetensors",
|
339 |
+
"model.layers.9.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
|
340 |
+
"model.layers.9.self_attn.q_proj.bias": "model-00002-of-00004.safetensors",
|
341 |
+
"model.layers.9.self_attn.q_proj.weight": "model-00002-of-00004.safetensors",
|
342 |
+
"model.layers.9.self_attn.v_proj.bias": "model-00002-of-00004.safetensors",
|
343 |
+
"model.layers.9.self_attn.v_proj.weight": "model-00002-of-00004.safetensors",
|
344 |
+
"model.mm_projector.readout.0.bias": "model-00004-of-00004.safetensors",
|
345 |
+
"model.mm_projector.readout.0.weight": "model-00004-of-00004.safetensors",
|
346 |
+
"model.mm_projector.readout.2.bias": "model-00004-of-00004.safetensors",
|
347 |
+
"model.mm_projector.readout.2.weight": "model-00004-of-00004.safetensors",
|
348 |
+
"model.norm.weight": "model-00003-of-00004.safetensors",
|
349 |
+
"model.vision_encoder.embeddings.patch_embedding.bias": "model-00003-of-00004.safetensors",
|
350 |
+
"model.vision_encoder.embeddings.patch_embedding.weight": "model-00003-of-00004.safetensors",
|
351 |
+
"model.vision_encoder.encoder.layers.0.layer_norm1.bias": "model-00003-of-00004.safetensors",
|
352 |
+
"model.vision_encoder.encoder.layers.0.layer_norm1.weight": "model-00003-of-00004.safetensors",
|
353 |
+
"model.vision_encoder.encoder.layers.0.layer_norm2.bias": "model-00003-of-00004.safetensors",
|
354 |
+
"model.vision_encoder.encoder.layers.0.layer_norm2.weight": "model-00003-of-00004.safetensors",
|
355 |
+
"model.vision_encoder.encoder.layers.0.mlp.fc1.bias": "model-00003-of-00004.safetensors",
|
356 |
+
"model.vision_encoder.encoder.layers.0.mlp.fc1.weight": "model-00003-of-00004.safetensors",
|
357 |
+
"model.vision_encoder.encoder.layers.0.mlp.fc2.bias": "model-00003-of-00004.safetensors",
|
358 |
+
"model.vision_encoder.encoder.layers.0.mlp.fc2.weight": "model-00003-of-00004.safetensors",
|
359 |
+
"model.vision_encoder.encoder.layers.0.self_attn.k_proj.bias": "model-00003-of-00004.safetensors",
|
360 |
+
"model.vision_encoder.encoder.layers.0.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
|
361 |
+
"model.vision_encoder.encoder.layers.0.self_attn.out_proj.bias": "model-00003-of-00004.safetensors",
|
362 |
+
"model.vision_encoder.encoder.layers.0.self_attn.out_proj.weight": "model-00003-of-00004.safetensors",
|
363 |
+
"model.vision_encoder.encoder.layers.0.self_attn.q_proj.bias": "model-00003-of-00004.safetensors",
|
364 |
+
"model.vision_encoder.encoder.layers.0.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
|
365 |
+
"model.vision_encoder.encoder.layers.0.self_attn.v_proj.bias": "model-00003-of-00004.safetensors",
|
366 |
+
"model.vision_encoder.encoder.layers.0.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
|
367 |
+
"model.vision_encoder.encoder.layers.1.layer_norm1.bias": "model-00003-of-00004.safetensors",
|
368 |
+
"model.vision_encoder.encoder.layers.1.layer_norm1.weight": "model-00003-of-00004.safetensors",
|
369 |
+
"model.vision_encoder.encoder.layers.1.layer_norm2.bias": "model-00003-of-00004.safetensors",
|
370 |
+
"model.vision_encoder.encoder.layers.1.layer_norm2.weight": "model-00003-of-00004.safetensors",
|
371 |
+
"model.vision_encoder.encoder.layers.1.mlp.fc1.bias": "model-00003-of-00004.safetensors",
|
372 |
+
"model.vision_encoder.encoder.layers.1.mlp.fc1.weight": "model-00003-of-00004.safetensors",
|
373 |
+
"model.vision_encoder.encoder.layers.1.mlp.fc2.bias": "model-00003-of-00004.safetensors",
|
374 |
+
"model.vision_encoder.encoder.layers.1.mlp.fc2.weight": "model-00003-of-00004.safetensors",
|
375 |
+
"model.vision_encoder.encoder.layers.1.self_attn.k_proj.bias": "model-00003-of-00004.safetensors",
|
376 |
+
"model.vision_encoder.encoder.layers.1.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
|
377 |
+
"model.vision_encoder.encoder.layers.1.self_attn.out_proj.bias": "model-00003-of-00004.safetensors",
|
378 |
+
"model.vision_encoder.encoder.layers.1.self_attn.out_proj.weight": "model-00003-of-00004.safetensors",
|
379 |
+
"model.vision_encoder.encoder.layers.1.self_attn.q_proj.bias": "model-00003-of-00004.safetensors",
|
380 |
+
"model.vision_encoder.encoder.layers.1.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
|
381 |
+
"model.vision_encoder.encoder.layers.1.self_attn.v_proj.bias": "model-00003-of-00004.safetensors",
|
382 |
+
"model.vision_encoder.encoder.layers.1.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
|
383 |
+
"model.vision_encoder.encoder.layers.10.layer_norm1.bias": "model-00003-of-00004.safetensors",
|
384 |
+
"model.vision_encoder.encoder.layers.10.layer_norm1.weight": "model-00003-of-00004.safetensors",
|
385 |
+
"model.vision_encoder.encoder.layers.10.layer_norm2.bias": "model-00003-of-00004.safetensors",
|
386 |
+
"model.vision_encoder.encoder.layers.10.layer_norm2.weight": "model-00003-of-00004.safetensors",
|
387 |
+
"model.vision_encoder.encoder.layers.10.mlp.fc1.bias": "model-00003-of-00004.safetensors",
|
388 |
+
"model.vision_encoder.encoder.layers.10.mlp.fc1.weight": "model-00003-of-00004.safetensors",
|
389 |
+
"model.vision_encoder.encoder.layers.10.mlp.fc2.bias": "model-00003-of-00004.safetensors",
|
390 |
+
"model.vision_encoder.encoder.layers.10.mlp.fc2.weight": "model-00003-of-00004.safetensors",
|
391 |
+
"model.vision_encoder.encoder.layers.10.self_attn.k_proj.bias": "model-00003-of-00004.safetensors",
|
392 |
+
"model.vision_encoder.encoder.layers.10.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
|
393 |
+
"model.vision_encoder.encoder.layers.10.self_attn.out_proj.bias": "model-00003-of-00004.safetensors",
|
394 |
+
"model.vision_encoder.encoder.layers.10.self_attn.out_proj.weight": "model-00003-of-00004.safetensors",
|
395 |
+
"model.vision_encoder.encoder.layers.10.self_attn.q_proj.bias": "model-00003-of-00004.safetensors",
|
396 |
+
"model.vision_encoder.encoder.layers.10.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
|
397 |
+
"model.vision_encoder.encoder.layers.10.self_attn.v_proj.bias": "model-00003-of-00004.safetensors",
|
398 |
+
"model.vision_encoder.encoder.layers.10.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
|
399 |
+
"model.vision_encoder.encoder.layers.11.layer_norm1.bias": "model-00003-of-00004.safetensors",
|
400 |
+
"model.vision_encoder.encoder.layers.11.layer_norm1.weight": "model-00003-of-00004.safetensors",
|
401 |
+
"model.vision_encoder.encoder.layers.11.layer_norm2.bias": "model-00003-of-00004.safetensors",
|
402 |
+
"model.vision_encoder.encoder.layers.11.layer_norm2.weight": "model-00003-of-00004.safetensors",
|
403 |
+
"model.vision_encoder.encoder.layers.11.mlp.fc1.bias": "model-00003-of-00004.safetensors",
|
404 |
+
"model.vision_encoder.encoder.layers.11.mlp.fc1.weight": "model-00003-of-00004.safetensors",
|
405 |
+
"model.vision_encoder.encoder.layers.11.mlp.fc2.bias": "model-00003-of-00004.safetensors",
|
406 |
+
"model.vision_encoder.encoder.layers.11.mlp.fc2.weight": "model-00003-of-00004.safetensors",
|
407 |
+
"model.vision_encoder.encoder.layers.11.self_attn.k_proj.bias": "model-00003-of-00004.safetensors",
|
408 |
+
"model.vision_encoder.encoder.layers.11.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
|
409 |
+
"model.vision_encoder.encoder.layers.11.self_attn.out_proj.bias": "model-00003-of-00004.safetensors",
|
410 |
+
"model.vision_encoder.encoder.layers.11.self_attn.out_proj.weight": "model-00003-of-00004.safetensors",
|
411 |
+
"model.vision_encoder.encoder.layers.11.self_attn.q_proj.bias": "model-00003-of-00004.safetensors",
|
412 |
+
"model.vision_encoder.encoder.layers.11.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
|
413 |
+
"model.vision_encoder.encoder.layers.11.self_attn.v_proj.bias": "model-00003-of-00004.safetensors",
|
414 |
+
"model.vision_encoder.encoder.layers.11.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
|
415 |
+
"model.vision_encoder.encoder.layers.12.layer_norm1.bias": "model-00003-of-00004.safetensors",
|
416 |
+
"model.vision_encoder.encoder.layers.12.layer_norm1.weight": "model-00003-of-00004.safetensors",
|
417 |
+
"model.vision_encoder.encoder.layers.12.layer_norm2.bias": "model-00003-of-00004.safetensors",
|
418 |
+
"model.vision_encoder.encoder.layers.12.layer_norm2.weight": "model-00003-of-00004.safetensors",
|
419 |
+
"model.vision_encoder.encoder.layers.12.mlp.fc1.bias": "model-00003-of-00004.safetensors",
|
420 |
+
"model.vision_encoder.encoder.layers.12.mlp.fc1.weight": "model-00003-of-00004.safetensors",
|
421 |
+
"model.vision_encoder.encoder.layers.12.mlp.fc2.bias": "model-00003-of-00004.safetensors",
|
422 |
+
"model.vision_encoder.encoder.layers.12.mlp.fc2.weight": "model-00003-of-00004.safetensors",
|
423 |
+
"model.vision_encoder.encoder.layers.12.self_attn.k_proj.bias": "model-00003-of-00004.safetensors",
|
424 |
+
"model.vision_encoder.encoder.layers.12.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
|
425 |
+
"model.vision_encoder.encoder.layers.12.self_attn.out_proj.bias": "model-00003-of-00004.safetensors",
|
426 |
+
"model.vision_encoder.encoder.layers.12.self_attn.out_proj.weight": "model-00003-of-00004.safetensors",
|
427 |
+
"model.vision_encoder.encoder.layers.12.self_attn.q_proj.bias": "model-00003-of-00004.safetensors",
|
428 |
+
"model.vision_encoder.encoder.layers.12.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
|
429 |
+
"model.vision_encoder.encoder.layers.12.self_attn.v_proj.bias": "model-00003-of-00004.safetensors",
|
430 |
+
"model.vision_encoder.encoder.layers.12.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
|
431 |
+
"model.vision_encoder.encoder.layers.13.layer_norm1.bias": "model-00003-of-00004.safetensors",
|
432 |
+
"model.vision_encoder.encoder.layers.13.layer_norm1.weight": "model-00003-of-00004.safetensors",
|
433 |
+
"model.vision_encoder.encoder.layers.13.layer_norm2.bias": "model-00003-of-00004.safetensors",
|
434 |
+
"model.vision_encoder.encoder.layers.13.layer_norm2.weight": "model-00003-of-00004.safetensors",
|
435 |
+
"model.vision_encoder.encoder.layers.13.mlp.fc1.bias": "model-00003-of-00004.safetensors",
|
436 |
+
"model.vision_encoder.encoder.layers.13.mlp.fc1.weight": "model-00003-of-00004.safetensors",
|
437 |
+
"model.vision_encoder.encoder.layers.13.mlp.fc2.bias": "model-00003-of-00004.safetensors",
|
438 |
+
"model.vision_encoder.encoder.layers.13.mlp.fc2.weight": "model-00003-of-00004.safetensors",
|
439 |
+
"model.vision_encoder.encoder.layers.13.self_attn.k_proj.bias": "model-00003-of-00004.safetensors",
|
440 |
+
"model.vision_encoder.encoder.layers.13.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
|
441 |
+
"model.vision_encoder.encoder.layers.13.self_attn.out_proj.bias": "model-00003-of-00004.safetensors",
|
442 |
+
"model.vision_encoder.encoder.layers.13.self_attn.out_proj.weight": "model-00003-of-00004.safetensors",
|
443 |
+
"model.vision_encoder.encoder.layers.13.self_attn.q_proj.bias": "model-00003-of-00004.safetensors",
|
444 |
+
"model.vision_encoder.encoder.layers.13.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
|
445 |
+
"model.vision_encoder.encoder.layers.13.self_attn.v_proj.bias": "model-00003-of-00004.safetensors",
|
446 |
+
"model.vision_encoder.encoder.layers.13.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
|
447 |
+
"model.vision_encoder.encoder.layers.14.layer_norm1.bias": "model-00003-of-00004.safetensors",
|
448 |
+
"model.vision_encoder.encoder.layers.14.layer_norm1.weight": "model-00003-of-00004.safetensors",
|
449 |
+
"model.vision_encoder.encoder.layers.14.layer_norm2.bias": "model-00003-of-00004.safetensors",
|
450 |
+
"model.vision_encoder.encoder.layers.14.layer_norm2.weight": "model-00003-of-00004.safetensors",
|
451 |
+
"model.vision_encoder.encoder.layers.14.mlp.fc1.bias": "model-00003-of-00004.safetensors",
|
452 |
+
"model.vision_encoder.encoder.layers.14.mlp.fc1.weight": "model-00003-of-00004.safetensors",
|
453 |
+
"model.vision_encoder.encoder.layers.14.mlp.fc2.bias": "model-00003-of-00004.safetensors",
|
454 |
+
"model.vision_encoder.encoder.layers.14.mlp.fc2.weight": "model-00003-of-00004.safetensors",
|
455 |
+
"model.vision_encoder.encoder.layers.14.self_attn.k_proj.bias": "model-00003-of-00004.safetensors",
|
456 |
+
"model.vision_encoder.encoder.layers.14.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
|
457 |
+
"model.vision_encoder.encoder.layers.14.self_attn.out_proj.bias": "model-00003-of-00004.safetensors",
|
458 |
+
"model.vision_encoder.encoder.layers.14.self_attn.out_proj.weight": "model-00003-of-00004.safetensors",
|
459 |
+
"model.vision_encoder.encoder.layers.14.self_attn.q_proj.bias": "model-00003-of-00004.safetensors",
|
460 |
+
"model.vision_encoder.encoder.layers.14.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
|
461 |
+
"model.vision_encoder.encoder.layers.14.self_attn.v_proj.bias": "model-00003-of-00004.safetensors",
|
462 |
+
"model.vision_encoder.encoder.layers.14.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
|
463 |
+
"model.vision_encoder.encoder.layers.15.layer_norm1.bias": "model-00003-of-00004.safetensors",
|
464 |
+
"model.vision_encoder.encoder.layers.15.layer_norm1.weight": "model-00003-of-00004.safetensors",
|
465 |
+
"model.vision_encoder.encoder.layers.15.layer_norm2.bias": "model-00003-of-00004.safetensors",
|
466 |
+
"model.vision_encoder.encoder.layers.15.layer_norm2.weight": "model-00003-of-00004.safetensors",
|
467 |
+
"model.vision_encoder.encoder.layers.15.mlp.fc1.bias": "model-00003-of-00004.safetensors",
|
468 |
+
"model.vision_encoder.encoder.layers.15.mlp.fc1.weight": "model-00003-of-00004.safetensors",
|
469 |
+
"model.vision_encoder.encoder.layers.15.mlp.fc2.bias": "model-00003-of-00004.safetensors",
|
470 |
+
"model.vision_encoder.encoder.layers.15.mlp.fc2.weight": "model-00003-of-00004.safetensors",
|
471 |
+
"model.vision_encoder.encoder.layers.15.self_attn.k_proj.bias": "model-00003-of-00004.safetensors",
|
472 |
+
"model.vision_encoder.encoder.layers.15.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
|
473 |
+
"model.vision_encoder.encoder.layers.15.self_attn.out_proj.bias": "model-00003-of-00004.safetensors",
|
474 |
+
"model.vision_encoder.encoder.layers.15.self_attn.out_proj.weight": "model-00003-of-00004.safetensors",
|
475 |
+
"model.vision_encoder.encoder.layers.15.self_attn.q_proj.bias": "model-00003-of-00004.safetensors",
|
476 |
+
"model.vision_encoder.encoder.layers.15.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
|
477 |
+
"model.vision_encoder.encoder.layers.15.self_attn.v_proj.bias": "model-00003-of-00004.safetensors",
|
478 |
+
"model.vision_encoder.encoder.layers.15.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
|
479 |
+
"model.vision_encoder.encoder.layers.16.layer_norm1.bias": "model-00003-of-00004.safetensors",
|
480 |
+
"model.vision_encoder.encoder.layers.16.layer_norm1.weight": "model-00003-of-00004.safetensors",
|
481 |
+
"model.vision_encoder.encoder.layers.16.layer_norm2.bias": "model-00003-of-00004.safetensors",
|
482 |
+
"model.vision_encoder.encoder.layers.16.layer_norm2.weight": "model-00003-of-00004.safetensors",
|
483 |
+
"model.vision_encoder.encoder.layers.16.mlp.fc1.bias": "model-00003-of-00004.safetensors",
|
484 |
+
"model.vision_encoder.encoder.layers.16.mlp.fc1.weight": "model-00003-of-00004.safetensors",
|
485 |
+
"model.vision_encoder.encoder.layers.16.mlp.fc2.bias": "model-00003-of-00004.safetensors",
|
486 |
+
"model.vision_encoder.encoder.layers.16.mlp.fc2.weight": "model-00003-of-00004.safetensors",
|
487 |
+
"model.vision_encoder.encoder.layers.16.self_attn.k_proj.bias": "model-00003-of-00004.safetensors",
|
488 |
+
"model.vision_encoder.encoder.layers.16.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
|
489 |
+
"model.vision_encoder.encoder.layers.16.self_attn.out_proj.bias": "model-00003-of-00004.safetensors",
|
490 |
+
"model.vision_encoder.encoder.layers.16.self_attn.out_proj.weight": "model-00003-of-00004.safetensors",
|
491 |
+
"model.vision_encoder.encoder.layers.16.self_attn.q_proj.bias": "model-00003-of-00004.safetensors",
|
492 |
+
"model.vision_encoder.encoder.layers.16.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
|
493 |
+
"model.vision_encoder.encoder.layers.16.self_attn.v_proj.bias": "model-00003-of-00004.safetensors",
|
494 |
+
"model.vision_encoder.encoder.layers.16.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
|
495 |
+
"model.vision_encoder.encoder.layers.17.layer_norm1.bias": "model-00003-of-00004.safetensors",
|
496 |
+
"model.vision_encoder.encoder.layers.17.layer_norm1.weight": "model-00003-of-00004.safetensors",
|
497 |
+
"model.vision_encoder.encoder.layers.17.layer_norm2.bias": "model-00003-of-00004.safetensors",
|
498 |
+
"model.vision_encoder.encoder.layers.17.layer_norm2.weight": "model-00003-of-00004.safetensors",
|
499 |
+
"model.vision_encoder.encoder.layers.17.mlp.fc1.bias": "model-00003-of-00004.safetensors",
|
500 |
+
"model.vision_encoder.encoder.layers.17.mlp.fc1.weight": "model-00003-of-00004.safetensors",
|
501 |
+
"model.vision_encoder.encoder.layers.17.mlp.fc2.bias": "model-00003-of-00004.safetensors",
|
502 |
+
"model.vision_encoder.encoder.layers.17.mlp.fc2.weight": "model-00003-of-00004.safetensors",
|
503 |
+
"model.vision_encoder.encoder.layers.17.self_attn.k_proj.bias": "model-00003-of-00004.safetensors",
|
504 |
+
"model.vision_encoder.encoder.layers.17.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
|
505 |
+
"model.vision_encoder.encoder.layers.17.self_attn.out_proj.bias": "model-00003-of-00004.safetensors",
|
506 |
+
"model.vision_encoder.encoder.layers.17.self_attn.out_proj.weight": "model-00003-of-00004.safetensors",
|
507 |
+
"model.vision_encoder.encoder.layers.17.self_attn.q_proj.bias": "model-00003-of-00004.safetensors",
|
508 |
+
"model.vision_encoder.encoder.layers.17.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
|
509 |
+
"model.vision_encoder.encoder.layers.17.self_attn.v_proj.bias": "model-00003-of-00004.safetensors",
|
510 |
+
"model.vision_encoder.encoder.layers.17.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
|
511 |
+
"model.vision_encoder.encoder.layers.18.layer_norm1.bias": "model-00003-of-00004.safetensors",
|
512 |
+
"model.vision_encoder.encoder.layers.18.layer_norm1.weight": "model-00003-of-00004.safetensors",
|
513 |
+
"model.vision_encoder.encoder.layers.18.layer_norm2.bias": "model-00003-of-00004.safetensors",
|
514 |
+
"model.vision_encoder.encoder.layers.18.layer_norm2.weight": "model-00003-of-00004.safetensors",
|
515 |
+
"model.vision_encoder.encoder.layers.18.mlp.fc1.bias": "model-00003-of-00004.safetensors",
|
516 |
+
"model.vision_encoder.encoder.layers.18.mlp.fc1.weight": "model-00003-of-00004.safetensors",
|
517 |
+
"model.vision_encoder.encoder.layers.18.mlp.fc2.bias": "model-00003-of-00004.safetensors",
|
518 |
+
"model.vision_encoder.encoder.layers.18.mlp.fc2.weight": "model-00003-of-00004.safetensors",
|
519 |
+
"model.vision_encoder.encoder.layers.18.self_attn.k_proj.bias": "model-00003-of-00004.safetensors",
|
520 |
+
"model.vision_encoder.encoder.layers.18.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
|
521 |
+
"model.vision_encoder.encoder.layers.18.self_attn.out_proj.bias": "model-00003-of-00004.safetensors",
|
522 |
+
"model.vision_encoder.encoder.layers.18.self_attn.out_proj.weight": "model-00003-of-00004.safetensors",
|
523 |
+
"model.vision_encoder.encoder.layers.18.self_attn.q_proj.bias": "model-00003-of-00004.safetensors",
|
524 |
+
"model.vision_encoder.encoder.layers.18.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
|
525 |
+
"model.vision_encoder.encoder.layers.18.self_attn.v_proj.bias": "model-00003-of-00004.safetensors",
|
526 |
+
"model.vision_encoder.encoder.layers.18.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
|
527 |
+
"model.vision_encoder.encoder.layers.19.layer_norm1.bias": "model-00003-of-00004.safetensors",
|
528 |
+
"model.vision_encoder.encoder.layers.19.layer_norm1.weight": "model-00003-of-00004.safetensors",
|
529 |
+
"model.vision_encoder.encoder.layers.19.layer_norm2.bias": "model-00003-of-00004.safetensors",
|
530 |
+
"model.vision_encoder.encoder.layers.19.layer_norm2.weight": "model-00003-of-00004.safetensors",
|
531 |
+
"model.vision_encoder.encoder.layers.19.mlp.fc1.bias": "model-00003-of-00004.safetensors",
|
532 |
+
"model.vision_encoder.encoder.layers.19.mlp.fc1.weight": "model-00003-of-00004.safetensors",
|
533 |
+
"model.vision_encoder.encoder.layers.19.mlp.fc2.bias": "model-00003-of-00004.safetensors",
|
534 |
+
"model.vision_encoder.encoder.layers.19.mlp.fc2.weight": "model-00003-of-00004.safetensors",
|
535 |
+
"model.vision_encoder.encoder.layers.19.self_attn.k_proj.bias": "model-00003-of-00004.safetensors",
|
536 |
+
"model.vision_encoder.encoder.layers.19.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
|
537 |
+
"model.vision_encoder.encoder.layers.19.self_attn.out_proj.bias": "model-00003-of-00004.safetensors",
|
538 |
+
"model.vision_encoder.encoder.layers.19.self_attn.out_proj.weight": "model-00003-of-00004.safetensors",
|
539 |
+
"model.vision_encoder.encoder.layers.19.self_attn.q_proj.bias": "model-00003-of-00004.safetensors",
|
540 |
+
"model.vision_encoder.encoder.layers.19.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
|
541 |
+
"model.vision_encoder.encoder.layers.19.self_attn.v_proj.bias": "model-00003-of-00004.safetensors",
|
542 |
+
"model.vision_encoder.encoder.layers.19.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
|
543 |
+
"model.vision_encoder.encoder.layers.2.layer_norm1.bias": "model-00003-of-00004.safetensors",
|
544 |
+
"model.vision_encoder.encoder.layers.2.layer_norm1.weight": "model-00003-of-00004.safetensors",
|
545 |
+
"model.vision_encoder.encoder.layers.2.layer_norm2.bias": "model-00003-of-00004.safetensors",
|
546 |
+
"model.vision_encoder.encoder.layers.2.layer_norm2.weight": "model-00003-of-00004.safetensors",
|
547 |
+
"model.vision_encoder.encoder.layers.2.mlp.fc1.bias": "model-00003-of-00004.safetensors",
|
548 |
+
"model.vision_encoder.encoder.layers.2.mlp.fc1.weight": "model-00003-of-00004.safetensors",
|
549 |
+
"model.vision_encoder.encoder.layers.2.mlp.fc2.bias": "model-00003-of-00004.safetensors",
|
550 |
+
"model.vision_encoder.encoder.layers.2.mlp.fc2.weight": "model-00003-of-00004.safetensors",
|
551 |
+
"model.vision_encoder.encoder.layers.2.self_attn.k_proj.bias": "model-00003-of-00004.safetensors",
|
552 |
+
"model.vision_encoder.encoder.layers.2.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
|
553 |
+
"model.vision_encoder.encoder.layers.2.self_attn.out_proj.bias": "model-00003-of-00004.safetensors",
|
554 |
+
"model.vision_encoder.encoder.layers.2.self_attn.out_proj.weight": "model-00003-of-00004.safetensors",
|
555 |
+
"model.vision_encoder.encoder.layers.2.self_attn.q_proj.bias": "model-00003-of-00004.safetensors",
|
556 |
+
"model.vision_encoder.encoder.layers.2.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
|
557 |
+
"model.vision_encoder.encoder.layers.2.self_attn.v_proj.bias": "model-00003-of-00004.safetensors",
|
558 |
+
"model.vision_encoder.encoder.layers.2.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
|
559 |
+
"model.vision_encoder.encoder.layers.20.layer_norm1.bias": "model-00003-of-00004.safetensors",
|
560 |
+
"model.vision_encoder.encoder.layers.20.layer_norm1.weight": "model-00003-of-00004.safetensors",
|
561 |
+
"model.vision_encoder.encoder.layers.20.layer_norm2.bias": "model-00003-of-00004.safetensors",
|
562 |
+
"model.vision_encoder.encoder.layers.20.layer_norm2.weight": "model-00003-of-00004.safetensors",
|
563 |
+
"model.vision_encoder.encoder.layers.20.mlp.fc1.bias": "model-00003-of-00004.safetensors",
|
564 |
+
"model.vision_encoder.encoder.layers.20.mlp.fc1.weight": "model-00003-of-00004.safetensors",
|
565 |
+
"model.vision_encoder.encoder.layers.20.mlp.fc2.bias": "model-00003-of-00004.safetensors",
|
566 |
+
"model.vision_encoder.encoder.layers.20.mlp.fc2.weight": "model-00003-of-00004.safetensors",
|
567 |
+
"model.vision_encoder.encoder.layers.20.self_attn.k_proj.bias": "model-00003-of-00004.safetensors",
|
568 |
+
"model.vision_encoder.encoder.layers.20.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
|
569 |
+
"model.vision_encoder.encoder.layers.20.self_attn.out_proj.bias": "model-00003-of-00004.safetensors",
|
570 |
+
"model.vision_encoder.encoder.layers.20.self_attn.out_proj.weight": "model-00003-of-00004.safetensors",
|
571 |
+
"model.vision_encoder.encoder.layers.20.self_attn.q_proj.bias": "model-00003-of-00004.safetensors",
|
572 |
+
"model.vision_encoder.encoder.layers.20.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
|
573 |
+
"model.vision_encoder.encoder.layers.20.self_attn.v_proj.bias": "model-00003-of-00004.safetensors",
|
574 |
+
"model.vision_encoder.encoder.layers.20.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
|
575 |
+
"model.vision_encoder.encoder.layers.21.layer_norm1.bias": "model-00003-of-00004.safetensors",
|
576 |
+
"model.vision_encoder.encoder.layers.21.layer_norm1.weight": "model-00003-of-00004.safetensors",
|
577 |
+
"model.vision_encoder.encoder.layers.21.layer_norm2.bias": "model-00004-of-00004.safetensors",
|
578 |
+
"model.vision_encoder.encoder.layers.21.layer_norm2.weight": "model-00004-of-00004.safetensors",
|
579 |
+
"model.vision_encoder.encoder.layers.21.mlp.fc1.bias": "model-00003-of-00004.safetensors",
|
580 |
+
"model.vision_encoder.encoder.layers.21.mlp.fc1.weight": "model-00003-of-00004.safetensors",
|
581 |
+
"model.vision_encoder.encoder.layers.21.mlp.fc2.bias": "model-00004-of-00004.safetensors",
|
582 |
+
"model.vision_encoder.encoder.layers.21.mlp.fc2.weight": "model-00004-of-00004.safetensors",
|
583 |
+
"model.vision_encoder.encoder.layers.21.self_attn.k_proj.bias": "model-00003-of-00004.safetensors",
|
584 |
+
"model.vision_encoder.encoder.layers.21.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
|
585 |
+
"model.vision_encoder.encoder.layers.21.self_attn.out_proj.bias": "model-00003-of-00004.safetensors",
|
586 |
+
"model.vision_encoder.encoder.layers.21.self_attn.out_proj.weight": "model-00003-of-00004.safetensors",
|
587 |
+
"model.vision_encoder.encoder.layers.21.self_attn.q_proj.bias": "model-00003-of-00004.safetensors",
|
588 |
+
"model.vision_encoder.encoder.layers.21.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
|
589 |
+
"model.vision_encoder.encoder.layers.21.self_attn.v_proj.bias": "model-00003-of-00004.safetensors",
|
590 |
+
"model.vision_encoder.encoder.layers.21.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
|
591 |
+
"model.vision_encoder.encoder.layers.22.layer_norm1.bias": "model-00004-of-00004.safetensors",
|
592 |
+
"model.vision_encoder.encoder.layers.22.layer_norm1.weight": "model-00004-of-00004.safetensors",
|
593 |
+
"model.vision_encoder.encoder.layers.22.layer_norm2.bias": "model-00004-of-00004.safetensors",
|
594 |
+
"model.vision_encoder.encoder.layers.22.layer_norm2.weight": "model-00004-of-00004.safetensors",
|
595 |
+
"model.vision_encoder.encoder.layers.22.mlp.fc1.bias": "model-00004-of-00004.safetensors",
|
596 |
+
"model.vision_encoder.encoder.layers.22.mlp.fc1.weight": "model-00004-of-00004.safetensors",
|
597 |
+
"model.vision_encoder.encoder.layers.22.mlp.fc2.bias": "model-00004-of-00004.safetensors",
|
598 |
+
"model.vision_encoder.encoder.layers.22.mlp.fc2.weight": "model-00004-of-00004.safetensors",
|
599 |
+
"model.vision_encoder.encoder.layers.22.self_attn.k_proj.bias": "model-00004-of-00004.safetensors",
|
600 |
+
"model.vision_encoder.encoder.layers.22.self_attn.k_proj.weight": "model-00004-of-00004.safetensors",
|
601 |
+
"model.vision_encoder.encoder.layers.22.self_attn.out_proj.bias": "model-00004-of-00004.safetensors",
|
602 |
+
"model.vision_encoder.encoder.layers.22.self_attn.out_proj.weight": "model-00004-of-00004.safetensors",
|
603 |
+
"model.vision_encoder.encoder.layers.22.self_attn.q_proj.bias": "model-00004-of-00004.safetensors",
|
604 |
+
"model.vision_encoder.encoder.layers.22.self_attn.q_proj.weight": "model-00004-of-00004.safetensors",
|
605 |
+
"model.vision_encoder.encoder.layers.22.self_attn.v_proj.bias": "model-00004-of-00004.safetensors",
|
606 |
+
"model.vision_encoder.encoder.layers.22.self_attn.v_proj.weight": "model-00004-of-00004.safetensors",
|
607 |
+
"model.vision_encoder.encoder.layers.23.layer_norm1.bias": "model-00004-of-00004.safetensors",
|
608 |
+
"model.vision_encoder.encoder.layers.23.layer_norm1.weight": "model-00004-of-00004.safetensors",
|
609 |
+
"model.vision_encoder.encoder.layers.23.layer_norm2.bias": "model-00004-of-00004.safetensors",
|
610 |
+
"model.vision_encoder.encoder.layers.23.layer_norm2.weight": "model-00004-of-00004.safetensors",
|
611 |
+
"model.vision_encoder.encoder.layers.23.mlp.fc1.bias": "model-00004-of-00004.safetensors",
|
612 |
+
"model.vision_encoder.encoder.layers.23.mlp.fc1.weight": "model-00004-of-00004.safetensors",
|
613 |
+
"model.vision_encoder.encoder.layers.23.mlp.fc2.bias": "model-00004-of-00004.safetensors",
|
614 |
+
"model.vision_encoder.encoder.layers.23.mlp.fc2.weight": "model-00004-of-00004.safetensors",
|
615 |
+
"model.vision_encoder.encoder.layers.23.self_attn.k_proj.bias": "model-00004-of-00004.safetensors",
|
616 |
+
"model.vision_encoder.encoder.layers.23.self_attn.k_proj.weight": "model-00004-of-00004.safetensors",
|
617 |
+
"model.vision_encoder.encoder.layers.23.self_attn.out_proj.bias": "model-00004-of-00004.safetensors",
|
618 |
+
"model.vision_encoder.encoder.layers.23.self_attn.out_proj.weight": "model-00004-of-00004.safetensors",
|
619 |
+
"model.vision_encoder.encoder.layers.23.self_attn.q_proj.bias": "model-00004-of-00004.safetensors",
|
620 |
+
"model.vision_encoder.encoder.layers.23.self_attn.q_proj.weight": "model-00004-of-00004.safetensors",
|
621 |
+
"model.vision_encoder.encoder.layers.23.self_attn.v_proj.bias": "model-00004-of-00004.safetensors",
|
622 |
+
"model.vision_encoder.encoder.layers.23.self_attn.v_proj.weight": "model-00004-of-00004.safetensors",
|
623 |
+
"model.vision_encoder.encoder.layers.24.layer_norm1.bias": "model-00004-of-00004.safetensors",
|
624 |
+
"model.vision_encoder.encoder.layers.24.layer_norm1.weight": "model-00004-of-00004.safetensors",
|
625 |
+
"model.vision_encoder.encoder.layers.24.layer_norm2.bias": "model-00004-of-00004.safetensors",
|
626 |
+
"model.vision_encoder.encoder.layers.24.layer_norm2.weight": "model-00004-of-00004.safetensors",
|
627 |
+
"model.vision_encoder.encoder.layers.24.mlp.fc1.bias": "model-00004-of-00004.safetensors",
|
628 |
+
"model.vision_encoder.encoder.layers.24.mlp.fc1.weight": "model-00004-of-00004.safetensors",
|
629 |
+
"model.vision_encoder.encoder.layers.24.mlp.fc2.bias": "model-00004-of-00004.safetensors",
|
630 |
+
"model.vision_encoder.encoder.layers.24.mlp.fc2.weight": "model-00004-of-00004.safetensors",
|
631 |
+
"model.vision_encoder.encoder.layers.24.self_attn.k_proj.bias": "model-00004-of-00004.safetensors",
|
632 |
+
"model.vision_encoder.encoder.layers.24.self_attn.k_proj.weight": "model-00004-of-00004.safetensors",
|
633 |
+
"model.vision_encoder.encoder.layers.24.self_attn.out_proj.bias": "model-00004-of-00004.safetensors",
|
634 |
+
"model.vision_encoder.encoder.layers.24.self_attn.out_proj.weight": "model-00004-of-00004.safetensors",
|
635 |
+
"model.vision_encoder.encoder.layers.24.self_attn.q_proj.bias": "model-00004-of-00004.safetensors",
|
636 |
+
"model.vision_encoder.encoder.layers.24.self_attn.q_proj.weight": "model-00004-of-00004.safetensors",
|
637 |
+
"model.vision_encoder.encoder.layers.24.self_attn.v_proj.bias": "model-00004-of-00004.safetensors",
|
638 |
+
"model.vision_encoder.encoder.layers.24.self_attn.v_proj.weight": "model-00004-of-00004.safetensors",
|
639 |
+
"model.vision_encoder.encoder.layers.25.layer_norm1.bias": "model-00004-of-00004.safetensors",
|
640 |
+
"model.vision_encoder.encoder.layers.25.layer_norm1.weight": "model-00004-of-00004.safetensors",
|
641 |
+
"model.vision_encoder.encoder.layers.25.layer_norm2.bias": "model-00004-of-00004.safetensors",
|
642 |
+
"model.vision_encoder.encoder.layers.25.layer_norm2.weight": "model-00004-of-00004.safetensors",
|
643 |
+
"model.vision_encoder.encoder.layers.25.mlp.fc1.bias": "model-00004-of-00004.safetensors",
|
644 |
+
"model.vision_encoder.encoder.layers.25.mlp.fc1.weight": "model-00004-of-00004.safetensors",
|
645 |
+
"model.vision_encoder.encoder.layers.25.mlp.fc2.bias": "model-00004-of-00004.safetensors",
|
646 |
+
"model.vision_encoder.encoder.layers.25.mlp.fc2.weight": "model-00004-of-00004.safetensors",
|
647 |
+
"model.vision_encoder.encoder.layers.25.self_attn.k_proj.bias": "model-00004-of-00004.safetensors",
|
648 |
+
"model.vision_encoder.encoder.layers.25.self_attn.k_proj.weight": "model-00004-of-00004.safetensors",
|
649 |
+
"model.vision_encoder.encoder.layers.25.self_attn.out_proj.bias": "model-00004-of-00004.safetensors",
|
650 |
+
"model.vision_encoder.encoder.layers.25.self_attn.out_proj.weight": "model-00004-of-00004.safetensors",
|
651 |
+
"model.vision_encoder.encoder.layers.25.self_attn.q_proj.bias": "model-00004-of-00004.safetensors",
|
652 |
+
"model.vision_encoder.encoder.layers.25.self_attn.q_proj.weight": "model-00004-of-00004.safetensors",
|
653 |
+
"model.vision_encoder.encoder.layers.25.self_attn.v_proj.bias": "model-00004-of-00004.safetensors",
|
654 |
+
"model.vision_encoder.encoder.layers.25.self_attn.v_proj.weight": "model-00004-of-00004.safetensors",
|
655 |
+
"model.vision_encoder.encoder.layers.26.layer_norm1.bias": "model-00004-of-00004.safetensors",
|
656 |
+
"model.vision_encoder.encoder.layers.26.layer_norm1.weight": "model-00004-of-00004.safetensors",
|
657 |
+
"model.vision_encoder.encoder.layers.26.layer_norm2.bias": "model-00004-of-00004.safetensors",
|
658 |
+
"model.vision_encoder.encoder.layers.26.layer_norm2.weight": "model-00004-of-00004.safetensors",
|
659 |
+
"model.vision_encoder.encoder.layers.26.mlp.fc1.bias": "model-00004-of-00004.safetensors",
|
660 |
+
"model.vision_encoder.encoder.layers.26.mlp.fc1.weight": "model-00004-of-00004.safetensors",
|
661 |
+
"model.vision_encoder.encoder.layers.26.mlp.fc2.bias": "model-00004-of-00004.safetensors",
|
662 |
+
"model.vision_encoder.encoder.layers.26.mlp.fc2.weight": "model-00004-of-00004.safetensors",
|
663 |
+
"model.vision_encoder.encoder.layers.26.self_attn.k_proj.bias": "model-00004-of-00004.safetensors",
|
664 |
+
"model.vision_encoder.encoder.layers.26.self_attn.k_proj.weight": "model-00004-of-00004.safetensors",
|
665 |
+
"model.vision_encoder.encoder.layers.26.self_attn.out_proj.bias": "model-00004-of-00004.safetensors",
|
666 |
+
"model.vision_encoder.encoder.layers.26.self_attn.out_proj.weight": "model-00004-of-00004.safetensors",
|
667 |
+
"model.vision_encoder.encoder.layers.26.self_attn.q_proj.bias": "model-00004-of-00004.safetensors",
|
668 |
+
"model.vision_encoder.encoder.layers.26.self_attn.q_proj.weight": "model-00004-of-00004.safetensors",
|
669 |
+
"model.vision_encoder.encoder.layers.26.self_attn.v_proj.bias": "model-00004-of-00004.safetensors",
|
670 |
+
"model.vision_encoder.encoder.layers.26.self_attn.v_proj.weight": "model-00004-of-00004.safetensors",
|
671 |
+
"model.vision_encoder.encoder.layers.3.layer_norm1.bias": "model-00003-of-00004.safetensors",
|
672 |
+
"model.vision_encoder.encoder.layers.3.layer_norm1.weight": "model-00003-of-00004.safetensors",
|
673 |
+
"model.vision_encoder.encoder.layers.3.layer_norm2.bias": "model-00003-of-00004.safetensors",
|
674 |
+
"model.vision_encoder.encoder.layers.3.layer_norm2.weight": "model-00003-of-00004.safetensors",
|
675 |
+
"model.vision_encoder.encoder.layers.3.mlp.fc1.bias": "model-00003-of-00004.safetensors",
|
676 |
+
"model.vision_encoder.encoder.layers.3.mlp.fc1.weight": "model-00003-of-00004.safetensors",
|
677 |
+
"model.vision_encoder.encoder.layers.3.mlp.fc2.bias": "model-00003-of-00004.safetensors",
|
678 |
+
"model.vision_encoder.encoder.layers.3.mlp.fc2.weight": "model-00003-of-00004.safetensors",
|
679 |
+
"model.vision_encoder.encoder.layers.3.self_attn.k_proj.bias": "model-00003-of-00004.safetensors",
|
680 |
+
"model.vision_encoder.encoder.layers.3.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
|
681 |
+
"model.vision_encoder.encoder.layers.3.self_attn.out_proj.bias": "model-00003-of-00004.safetensors",
|
682 |
+
"model.vision_encoder.encoder.layers.3.self_attn.out_proj.weight": "model-00003-of-00004.safetensors",
|
683 |
+
"model.vision_encoder.encoder.layers.3.self_attn.q_proj.bias": "model-00003-of-00004.safetensors",
|
684 |
+
"model.vision_encoder.encoder.layers.3.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
|
685 |
+
"model.vision_encoder.encoder.layers.3.self_attn.v_proj.bias": "model-00003-of-00004.safetensors",
|
686 |
+
"model.vision_encoder.encoder.layers.3.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
|
687 |
+
"model.vision_encoder.encoder.layers.4.layer_norm1.bias": "model-00003-of-00004.safetensors",
|
688 |
+
"model.vision_encoder.encoder.layers.4.layer_norm1.weight": "model-00003-of-00004.safetensors",
|
689 |
+
"model.vision_encoder.encoder.layers.4.layer_norm2.bias": "model-00003-of-00004.safetensors",
|
690 |
+
"model.vision_encoder.encoder.layers.4.layer_norm2.weight": "model-00003-of-00004.safetensors",
|
691 |
+
"model.vision_encoder.encoder.layers.4.mlp.fc1.bias": "model-00003-of-00004.safetensors",
|
692 |
+
"model.vision_encoder.encoder.layers.4.mlp.fc1.weight": "model-00003-of-00004.safetensors",
|
693 |
+
"model.vision_encoder.encoder.layers.4.mlp.fc2.bias": "model-00003-of-00004.safetensors",
|
694 |
+
"model.vision_encoder.encoder.layers.4.mlp.fc2.weight": "model-00003-of-00004.safetensors",
|
695 |
+
"model.vision_encoder.encoder.layers.4.self_attn.k_proj.bias": "model-00003-of-00004.safetensors",
|
696 |
+
"model.vision_encoder.encoder.layers.4.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
|
697 |
+
"model.vision_encoder.encoder.layers.4.self_attn.out_proj.bias": "model-00003-of-00004.safetensors",
|
698 |
+
"model.vision_encoder.encoder.layers.4.self_attn.out_proj.weight": "model-00003-of-00004.safetensors",
|
699 |
+
"model.vision_encoder.encoder.layers.4.self_attn.q_proj.bias": "model-00003-of-00004.safetensors",
|
700 |
+
"model.vision_encoder.encoder.layers.4.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
|
701 |
+
"model.vision_encoder.encoder.layers.4.self_attn.v_proj.bias": "model-00003-of-00004.safetensors",
|
702 |
+
"model.vision_encoder.encoder.layers.4.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
|
703 |
+
"model.vision_encoder.encoder.layers.5.layer_norm1.bias": "model-00003-of-00004.safetensors",
|
704 |
+
"model.vision_encoder.encoder.layers.5.layer_norm1.weight": "model-00003-of-00004.safetensors",
|
705 |
+
"model.vision_encoder.encoder.layers.5.layer_norm2.bias": "model-00003-of-00004.safetensors",
|
706 |
+
"model.vision_encoder.encoder.layers.5.layer_norm2.weight": "model-00003-of-00004.safetensors",
|
707 |
+
"model.vision_encoder.encoder.layers.5.mlp.fc1.bias": "model-00003-of-00004.safetensors",
|
708 |
+
"model.vision_encoder.encoder.layers.5.mlp.fc1.weight": "model-00003-of-00004.safetensors",
|
709 |
+
"model.vision_encoder.encoder.layers.5.mlp.fc2.bias": "model-00003-of-00004.safetensors",
|
710 |
+
"model.vision_encoder.encoder.layers.5.mlp.fc2.weight": "model-00003-of-00004.safetensors",
|
711 |
+
"model.vision_encoder.encoder.layers.5.self_attn.k_proj.bias": "model-00003-of-00004.safetensors",
|
712 |
+
"model.vision_encoder.encoder.layers.5.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
|
713 |
+
"model.vision_encoder.encoder.layers.5.self_attn.out_proj.bias": "model-00003-of-00004.safetensors",
|
714 |
+
"model.vision_encoder.encoder.layers.5.self_attn.out_proj.weight": "model-00003-of-00004.safetensors",
|
715 |
+
"model.vision_encoder.encoder.layers.5.self_attn.q_proj.bias": "model-00003-of-00004.safetensors",
|
716 |
+
"model.vision_encoder.encoder.layers.5.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
|
717 |
+
"model.vision_encoder.encoder.layers.5.self_attn.v_proj.bias": "model-00003-of-00004.safetensors",
|
718 |
+
"model.vision_encoder.encoder.layers.5.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
|
719 |
+
"model.vision_encoder.encoder.layers.6.layer_norm1.bias": "model-00003-of-00004.safetensors",
|
720 |
+
"model.vision_encoder.encoder.layers.6.layer_norm1.weight": "model-00003-of-00004.safetensors",
|
721 |
+
"model.vision_encoder.encoder.layers.6.layer_norm2.bias": "model-00003-of-00004.safetensors",
|
722 |
+
"model.vision_encoder.encoder.layers.6.layer_norm2.weight": "model-00003-of-00004.safetensors",
|
723 |
+
"model.vision_encoder.encoder.layers.6.mlp.fc1.bias": "model-00003-of-00004.safetensors",
|
724 |
+
"model.vision_encoder.encoder.layers.6.mlp.fc1.weight": "model-00003-of-00004.safetensors",
|
725 |
+
"model.vision_encoder.encoder.layers.6.mlp.fc2.bias": "model-00003-of-00004.safetensors",
|
726 |
+
"model.vision_encoder.encoder.layers.6.mlp.fc2.weight": "model-00003-of-00004.safetensors",
|
727 |
+
"model.vision_encoder.encoder.layers.6.self_attn.k_proj.bias": "model-00003-of-00004.safetensors",
|
728 |
+
"model.vision_encoder.encoder.layers.6.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
|
729 |
+
"model.vision_encoder.encoder.layers.6.self_attn.out_proj.bias": "model-00003-of-00004.safetensors",
|
730 |
+
"model.vision_encoder.encoder.layers.6.self_attn.out_proj.weight": "model-00003-of-00004.safetensors",
|
731 |
+
"model.vision_encoder.encoder.layers.6.self_attn.q_proj.bias": "model-00003-of-00004.safetensors",
|
732 |
+
"model.vision_encoder.encoder.layers.6.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
|
733 |
+
"model.vision_encoder.encoder.layers.6.self_attn.v_proj.bias": "model-00003-of-00004.safetensors",
|
734 |
+
"model.vision_encoder.encoder.layers.6.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
|
735 |
+
"model.vision_encoder.encoder.layers.7.layer_norm1.bias": "model-00003-of-00004.safetensors",
|
736 |
+
"model.vision_encoder.encoder.layers.7.layer_norm1.weight": "model-00003-of-00004.safetensors",
|
737 |
+
"model.vision_encoder.encoder.layers.7.layer_norm2.bias": "model-00003-of-00004.safetensors",
|
738 |
+
"model.vision_encoder.encoder.layers.7.layer_norm2.weight": "model-00003-of-00004.safetensors",
|
739 |
+
"model.vision_encoder.encoder.layers.7.mlp.fc1.bias": "model-00003-of-00004.safetensors",
|
740 |
+
"model.vision_encoder.encoder.layers.7.mlp.fc1.weight": "model-00003-of-00004.safetensors",
|
741 |
+
"model.vision_encoder.encoder.layers.7.mlp.fc2.bias": "model-00003-of-00004.safetensors",
|
742 |
+
"model.vision_encoder.encoder.layers.7.mlp.fc2.weight": "model-00003-of-00004.safetensors",
|
743 |
+
"model.vision_encoder.encoder.layers.7.self_attn.k_proj.bias": "model-00003-of-00004.safetensors",
|
744 |
+
"model.vision_encoder.encoder.layers.7.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
|
745 |
+
"model.vision_encoder.encoder.layers.7.self_attn.out_proj.bias": "model-00003-of-00004.safetensors",
|
746 |
+
"model.vision_encoder.encoder.layers.7.self_attn.out_proj.weight": "model-00003-of-00004.safetensors",
|
747 |
+
"model.vision_encoder.encoder.layers.7.self_attn.q_proj.bias": "model-00003-of-00004.safetensors",
|
748 |
+
"model.vision_encoder.encoder.layers.7.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
|
749 |
+
"model.vision_encoder.encoder.layers.7.self_attn.v_proj.bias": "model-00003-of-00004.safetensors",
|
750 |
+
"model.vision_encoder.encoder.layers.7.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
|
751 |
+
"model.vision_encoder.encoder.layers.8.layer_norm1.bias": "model-00003-of-00004.safetensors",
|
752 |
+
"model.vision_encoder.encoder.layers.8.layer_norm1.weight": "model-00003-of-00004.safetensors",
|
753 |
+
"model.vision_encoder.encoder.layers.8.layer_norm2.bias": "model-00003-of-00004.safetensors",
|
754 |
+
"model.vision_encoder.encoder.layers.8.layer_norm2.weight": "model-00003-of-00004.safetensors",
|
755 |
+
"model.vision_encoder.encoder.layers.8.mlp.fc1.bias": "model-00003-of-00004.safetensors",
|
756 |
+
"model.vision_encoder.encoder.layers.8.mlp.fc1.weight": "model-00003-of-00004.safetensors",
|
757 |
+
"model.vision_encoder.encoder.layers.8.mlp.fc2.bias": "model-00003-of-00004.safetensors",
|
758 |
+
"model.vision_encoder.encoder.layers.8.mlp.fc2.weight": "model-00003-of-00004.safetensors",
|
759 |
+
"model.vision_encoder.encoder.layers.8.self_attn.k_proj.bias": "model-00003-of-00004.safetensors",
|
760 |
+
"model.vision_encoder.encoder.layers.8.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
|
761 |
+
"model.vision_encoder.encoder.layers.8.self_attn.out_proj.bias": "model-00003-of-00004.safetensors",
|
762 |
+
"model.vision_encoder.encoder.layers.8.self_attn.out_proj.weight": "model-00003-of-00004.safetensors",
|
763 |
+
"model.vision_encoder.encoder.layers.8.self_attn.q_proj.bias": "model-00003-of-00004.safetensors",
|
764 |
+
"model.vision_encoder.encoder.layers.8.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
|
765 |
+
"model.vision_encoder.encoder.layers.8.self_attn.v_proj.bias": "model-00003-of-00004.safetensors",
|
766 |
+
"model.vision_encoder.encoder.layers.8.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
|
767 |
+
"model.vision_encoder.encoder.layers.9.layer_norm1.bias": "model-00003-of-00004.safetensors",
|
768 |
+
"model.vision_encoder.encoder.layers.9.layer_norm1.weight": "model-00003-of-00004.safetensors",
|
769 |
+
"model.vision_encoder.encoder.layers.9.layer_norm2.bias": "model-00003-of-00004.safetensors",
|
770 |
+
"model.vision_encoder.encoder.layers.9.layer_norm2.weight": "model-00003-of-00004.safetensors",
|
771 |
+
"model.vision_encoder.encoder.layers.9.mlp.fc1.bias": "model-00003-of-00004.safetensors",
|
772 |
+
"model.vision_encoder.encoder.layers.9.mlp.fc1.weight": "model-00003-of-00004.safetensors",
|
773 |
+
"model.vision_encoder.encoder.layers.9.mlp.fc2.bias": "model-00003-of-00004.safetensors",
|
774 |
+
"model.vision_encoder.encoder.layers.9.mlp.fc2.weight": "model-00003-of-00004.safetensors",
|
775 |
+
"model.vision_encoder.encoder.layers.9.self_attn.k_proj.bias": "model-00003-of-00004.safetensors",
|
776 |
+
"model.vision_encoder.encoder.layers.9.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
|
777 |
+
"model.vision_encoder.encoder.layers.9.self_attn.out_proj.bias": "model-00003-of-00004.safetensors",
|
778 |
+
"model.vision_encoder.encoder.layers.9.self_attn.out_proj.weight": "model-00003-of-00004.safetensors",
|
779 |
+
"model.vision_encoder.encoder.layers.9.self_attn.q_proj.bias": "model-00003-of-00004.safetensors",
|
780 |
+
"model.vision_encoder.encoder.layers.9.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
|
781 |
+
"model.vision_encoder.encoder.layers.9.self_attn.v_proj.bias": "model-00003-of-00004.safetensors",
|
782 |
+
"model.vision_encoder.encoder.layers.9.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
|
783 |
+
"model.vision_encoder.post_layernorm.bias": "model-00004-of-00004.safetensors",
|
784 |
+
"model.vision_encoder.post_layernorm.weight": "model-00004-of-00004.safetensors"
|
785 |
+
}
|
786 |
+
}
|
modeling_videollama3.py
ADDED
@@ -0,0 +1,454 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Adopted from https://github.com/haotian-liu/LLaVA.
|
2 |
+
# Below is the original copyright:
|
3 |
+
# Copyright 2023 Haotian Liu
|
4 |
+
#
|
5 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
+
# you may not use this file except in compliance with the License.
|
7 |
+
# You may obtain a copy of the License at
|
8 |
+
#
|
9 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10 |
+
#
|
11 |
+
# Unless required by applicable law or agreed to in writing, software
|
12 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14 |
+
# See the License for the specific language governing permissions and
|
15 |
+
# limitations under the License.
|
16 |
+
"""PyTorch VideoLLaMA3 model."""
|
17 |
+
|
18 |
+
import importlib.util
|
19 |
+
import os.path as osp
|
20 |
+
import re
|
21 |
+
from abc import ABC, abstractmethod
|
22 |
+
from typing import List, Optional, Tuple, Union
|
23 |
+
|
24 |
+
import torch
|
25 |
+
import torch.nn as nn
|
26 |
+
import torch.utils.checkpoint
|
27 |
+
|
28 |
+
from transformers import AutoModel, Qwen2ForCausalLM, Qwen2Model
|
29 |
+
from transformers.generation.utils import GenerateOutput
|
30 |
+
from transformers.modeling_outputs import CausalLMOutputWithPast
|
31 |
+
|
32 |
+
try:
|
33 |
+
from .configuration_videollama3 import Videollama3Qwen2Config
|
34 |
+
except ModuleNotFoundError:
|
35 |
+
spec = importlib.util.spec_from_file_location(
|
36 |
+
"configuration_videollama3",
|
37 |
+
osp.join(osp.dirname(__file__), "configuration_videollama3.py"),
|
38 |
+
)
|
39 |
+
configuration_videollama3 = importlib.util.module_from_spec(spec)
|
40 |
+
spec.loader.exec_module(configuration_videollama3)
|
41 |
+
Videollama3Qwen2Config = getattr(
|
42 |
+
configuration_videollama3,
|
43 |
+
"Videollama3Qwen2Config",
|
44 |
+
)
|
45 |
+
|
46 |
+
|
47 |
+
def build_mlp(depth, hidden_size, output_hidden_size):
|
48 |
+
modules = [nn.Linear(hidden_size, output_hidden_size)]
|
49 |
+
for _ in range(1, depth):
|
50 |
+
modules.append(nn.GELU())
|
51 |
+
modules.append(nn.Linear(output_hidden_size, output_hidden_size))
|
52 |
+
return nn.Sequential(*modules)
|
53 |
+
|
54 |
+
|
55 |
+
def build_vision_projector(config, delay_load=False, **kwargs):
|
56 |
+
# videollama3 projector only support image-wise operation now, i.e., prohibit the temporal aggregation
|
57 |
+
projector_type = getattr(config, 'mm_projector_type', 'linear')
|
58 |
+
if projector_type == "linear":
|
59 |
+
# NOTE: for both linear and mlp2x_gelu projector type, mean pooling is adopted to aggreate video features
|
60 |
+
return nn.Linear(config.mm_hidden_size, config.hidden_size)
|
61 |
+
elif projector_type.startswith("mlp"):
|
62 |
+
return MlpGeluProjector(config, projector_type)
|
63 |
+
else:
|
64 |
+
raise ValueError(f'Unknown projector type: {projector_type}')
|
65 |
+
|
66 |
+
|
67 |
+
class MlpGeluProjector(nn.Module):
|
68 |
+
|
69 |
+
def __init__(self, config, projector_type):
|
70 |
+
super().__init__()
|
71 |
+
|
72 |
+
mlp_gelu_match = re.match(r"^mlp(\d+)x_gelu$", projector_type)
|
73 |
+
mlp_depth = int(mlp_gelu_match.group(1))
|
74 |
+
|
75 |
+
self.readout = build_mlp(mlp_depth, config.vision_encoder_config.hidden_size, config.hidden_size)
|
76 |
+
|
77 |
+
def forward(self, x):
|
78 |
+
x = self.readout(x)
|
79 |
+
return x
|
80 |
+
|
81 |
+
|
82 |
+
class Videollama3MetaModel:
|
83 |
+
|
84 |
+
def __init__(self, config):
|
85 |
+
super(Videollama3MetaModel, self).__init__(config)
|
86 |
+
if config.vision_encoder is not None:
|
87 |
+
self.vision_encoder = AutoModel.from_pretrained(
|
88 |
+
config.vision_encoder,
|
89 |
+
attn_implementation=self.config._attn_implementation,
|
90 |
+
torch_dtype=self.dtype,
|
91 |
+
)
|
92 |
+
self.config.vision_encoder_config = self.vision_encoder.config
|
93 |
+
self.config.vision_encoder = None
|
94 |
+
elif config.vision_encoder_config is not None:
|
95 |
+
self.vision_encoder = AutoModel.from_config(
|
96 |
+
self.config.vision_encoder_config,
|
97 |
+
attn_implementation=self.config._attn_implementation,
|
98 |
+
torch_dtype=self.dtype,
|
99 |
+
)
|
100 |
+
else:
|
101 |
+
raise ValueError("Vision encoder is not provided in config")
|
102 |
+
self.mm_projector = build_vision_projector(config)
|
103 |
+
|
104 |
+
def get_vision_encoder(self):
|
105 |
+
return self.vision_encoder
|
106 |
+
|
107 |
+
def get_mm_projector(self):
|
108 |
+
return self.mm_projector
|
109 |
+
|
110 |
+
|
111 |
+
class Videollama3Qwen2Model(Videollama3MetaModel, Qwen2Model):
|
112 |
+
|
113 |
+
config_class = Videollama3Qwen2Config
|
114 |
+
|
115 |
+
def __init__(self, config: Videollama3Qwen2Config):
|
116 |
+
super(Videollama3Qwen2Model, self).__init__(config)
|
117 |
+
|
118 |
+
|
119 |
+
class Videollama3MetaForCausalLM(ABC):
|
120 |
+
|
121 |
+
@abstractmethod
|
122 |
+
def get_model(self):
|
123 |
+
pass
|
124 |
+
|
125 |
+
def get_vision_encoder(self):
|
126 |
+
return self.get_model().get_vision_encoder()
|
127 |
+
|
128 |
+
def get_mm_projector(self):
|
129 |
+
return self.get_model().get_mm_projector()
|
130 |
+
|
131 |
+
def encode_images(
|
132 |
+
self,
|
133 |
+
pixel_values: torch.FloatTensor,
|
134 |
+
grid_sizes: torch.LongTensor,
|
135 |
+
merge_sizes: torch.LongTensor,
|
136 |
+
) -> torch.FloatTensor:
|
137 |
+
mm_features = self.get_model().get_vision_encoder()(
|
138 |
+
pixel_values=pixel_values,
|
139 |
+
grid_sizes=grid_sizes,
|
140 |
+
merge_sizes=merge_sizes,
|
141 |
+
)
|
142 |
+
mm_features = self.get_model().mm_projector(mm_features)
|
143 |
+
return mm_features
|
144 |
+
|
145 |
+
def _get_valid_visual_tokens(
|
146 |
+
self,
|
147 |
+
mm_features: torch.FloatTensor,
|
148 |
+
batched_num_patches: torch.LongTensor,
|
149 |
+
modals: List[str],
|
150 |
+
):
|
151 |
+
valid_masks = []
|
152 |
+
for num_patches, modal in zip(batched_num_patches, modals):
|
153 |
+
valid_mask = torch.full((num_patches, ), modal != "text", dtype=torch.bool, device=mm_features.device)
|
154 |
+
valid_masks.append(valid_mask)
|
155 |
+
mm_features = mm_features[torch.cat(valid_masks)]
|
156 |
+
return mm_features
|
157 |
+
|
158 |
+
def _maybe_truncate_visual_tokens(
|
159 |
+
self,
|
160 |
+
mm_features: torch.FloatTensor,
|
161 |
+
compression_mask: torch.BoolTensor,
|
162 |
+
batched_num_patches: torch.LongTensor,
|
163 |
+
modals: List[str],
|
164 |
+
input_ids: torch.LongTensor,
|
165 |
+
position_ids: Optional[torch.LongTensor] = None,
|
166 |
+
):
|
167 |
+
if position_ids is None or mm_features.shape[0] == input_ids.eq(self.config.image_token_index).sum():
|
168 |
+
return mm_features, compression_mask
|
169 |
+
|
170 |
+
truncation_mask = []
|
171 |
+
for num_patches, modal in zip(batched_num_patches, modals):
|
172 |
+
if modal == "text":
|
173 |
+
truncation_mask.append(torch.ones((0,), dtype=torch.bool, device=input_ids.device))
|
174 |
+
else:
|
175 |
+
truncation_mask.append(torch.ones((num_patches,), dtype=torch.bool, device=input_ids.device))
|
176 |
+
|
177 |
+
seq_end_indices = torch.nonzero(position_ids == 0)[:, 0]
|
178 |
+
seq_end_indices = seq_end_indices[seq_end_indices > 0].tolist()+ [len(input_ids)]
|
179 |
+
seq_start_indices = [0] + seq_end_indices[:-1]
|
180 |
+
num_visual_tokens = [
|
181 |
+
input_ids[start:end].eq(self.config.image_token_index).sum()
|
182 |
+
for start, end in zip(seq_start_indices, seq_end_indices)
|
183 |
+
]
|
184 |
+
|
185 |
+
for n, mask in zip(num_visual_tokens, truncation_mask):
|
186 |
+
if len(mask) > 0:
|
187 |
+
mask[n:] = False
|
188 |
+
truncation_mask = torch.cat(truncation_mask)
|
189 |
+
|
190 |
+
return mm_features[truncation_mask], compression_mask[truncation_mask]
|
191 |
+
|
192 |
+
def _get_compression_mask(
|
193 |
+
self,
|
194 |
+
pixel_values: torch.FloatTensor,
|
195 |
+
batched_num_patches: torch.LongTensor,
|
196 |
+
grid_sizes: torch.LongTensor,
|
197 |
+
merge_sizes: torch.LongTensor,
|
198 |
+
modals: List[str],
|
199 |
+
threshold: float = 0.1,
|
200 |
+
min_tokens: int = 1,
|
201 |
+
) -> torch.BoolTensor:
|
202 |
+
batched_images = pixel_values.split(grid_sizes.prod(dim=1).tolist(), dim=0)
|
203 |
+
compression_masks = []
|
204 |
+
|
205 |
+
for images, num_patches, grid_size, merge_size, modal in zip(
|
206 |
+
batched_images, batched_num_patches, grid_sizes, merge_sizes, modals
|
207 |
+
):
|
208 |
+
t, h, w = grid_size
|
209 |
+
if modal == "image" or (modal == "video" and t == 1):
|
210 |
+
compression_masks.append(torch.ones((num_patches,), dtype=torch.bool, device=images.device))
|
211 |
+
|
212 |
+
elif modal == "video":
|
213 |
+
# NOTE: video token compressor
|
214 |
+
images = images.view(t, (h // merge_size) * (w // merge_size), -1)
|
215 |
+
|
216 |
+
pixel_diff = images[1:] - images[:-1]
|
217 |
+
pixel_diff = torch.abs(pixel_diff).mean(dim=-1) * 255
|
218 |
+
pixel_diff = torch.cat([torch.full_like(pixel_diff[0:1], threshold + 1), pixel_diff], dim=0)
|
219 |
+
mask = pixel_diff > threshold
|
220 |
+
padding_ids = torch.nonzero(mask.sum(dim=1) < min_tokens)[:, 0]
|
221 |
+
# mask[padding_ids, torch.randperm(min_tokens)] = 1
|
222 |
+
mask[padding_ids, :min_tokens] = 1
|
223 |
+
compression_masks.append(mask.flatten())
|
224 |
+
|
225 |
+
else:
|
226 |
+
# in case of psuedo image
|
227 |
+
compression_masks.append(torch.ones((0,), dtype=torch.bool, device=images.device))
|
228 |
+
|
229 |
+
return torch.cat(compression_masks)
|
230 |
+
|
231 |
+
def _compress_visual_tokens(
|
232 |
+
self,
|
233 |
+
compression_mask: torch.BoolTensor,
|
234 |
+
mm_features: torch.FloatTensor,
|
235 |
+
input_ids: torch.LongTensor,
|
236 |
+
attention_mask: Optional[torch.Tensor] = None,
|
237 |
+
position_ids: Optional[torch.LongTensor] = None,
|
238 |
+
labels: Optional[torch.LongTensor] = None,
|
239 |
+
):
|
240 |
+
mm_features = mm_features[compression_mask]
|
241 |
+
image_selected = (input_ids == self.config.image_token_index)
|
242 |
+
|
243 |
+
text_masks = torch.logical_not(image_selected)
|
244 |
+
text_masks[image_selected] = compression_mask
|
245 |
+
input_ids = input_ids[text_masks]
|
246 |
+
|
247 |
+
if attention_mask is not None:
|
248 |
+
attention_mask = attention_mask[text_masks]
|
249 |
+
if labels is not None:
|
250 |
+
labels = labels[text_masks]
|
251 |
+
if position_ids is not None:
|
252 |
+
# FIXME: assume the first position_id is always 0
|
253 |
+
position_ids = position_ids[text_masks]
|
254 |
+
pos_start = [0] + torch.nonzero(position_ids == 0)[:, 0].tolist()
|
255 |
+
pos_end = pos_start[1:] + [len(input_ids)]
|
256 |
+
position_ids = torch.cat([torch.arange(end - start, device=input_ids.device) for start, end in zip(pos_start, pos_end)])
|
257 |
+
|
258 |
+
return mm_features, input_ids, attention_mask, position_ids, labels
|
259 |
+
|
260 |
+
def prepare_inputs_labels_for_multimodal(
|
261 |
+
self,
|
262 |
+
input_ids: torch.LongTensor = None,
|
263 |
+
attention_mask: Optional[torch.Tensor] = None,
|
264 |
+
position_ids: Optional[torch.LongTensor] = None,
|
265 |
+
past_key_values: Optional[List[torch.FloatTensor]] = None,
|
266 |
+
labels: Optional[torch.LongTensor] = None,
|
267 |
+
pixel_values: Optional[torch.FloatTensor] = None,
|
268 |
+
grid_sizes: Optional[torch.LongTensor] = None,
|
269 |
+
merge_sizes: Optional[torch.LongTensor] = None,
|
270 |
+
modals: Optional[List[str]] = None,
|
271 |
+
):
|
272 |
+
vision_encoder = self.get_vision_encoder()
|
273 |
+
# NOTE: text-only situation
|
274 |
+
if vision_encoder is None or pixel_values is None or input_ids.shape[1] == 1:
|
275 |
+
return input_ids, attention_mask, position_ids, past_key_values, None, labels
|
276 |
+
|
277 |
+
# 1. flatten text inputs
|
278 |
+
B, N = input_ids.shape
|
279 |
+
input_ids = input_ids.view(B * N)
|
280 |
+
if attention_mask is not None:
|
281 |
+
attention_mask = attention_mask.view(B * N)
|
282 |
+
if position_ids is not None:
|
283 |
+
position_ids = position_ids.view(B * N)
|
284 |
+
if labels is not None:
|
285 |
+
labels = labels.view(B * N)
|
286 |
+
|
287 |
+
# 2. embed visual tokens
|
288 |
+
batched_num_patches = grid_sizes.prod(dim=1).div(merge_sizes ** 2).long()
|
289 |
+
mm_features = self.encode_images(pixel_values, grid_sizes, merge_sizes)
|
290 |
+
mm_features = self._get_valid_visual_tokens(mm_features, batched_num_patches, modals)
|
291 |
+
|
292 |
+
compression_mask = self._get_compression_mask(
|
293 |
+
pixel_values, batched_num_patches, grid_sizes, merge_sizes, modals
|
294 |
+
)
|
295 |
+
mm_features, compression_mask = self._maybe_truncate_visual_tokens(
|
296 |
+
mm_features, compression_mask, batched_num_patches, modals, input_ids, position_ids
|
297 |
+
)
|
298 |
+
|
299 |
+
# 3. compress visual tokens
|
300 |
+
if self.config.use_token_compression:
|
301 |
+
assert B == 1, "Token compression is only supported for batch_size=1"
|
302 |
+
mm_features, input_ids, attention_mask, labels, position_ids = self._compress_visual_tokens(
|
303 |
+
compression_mask, mm_features, input_ids, attention_mask, labels, position_ids
|
304 |
+
)
|
305 |
+
|
306 |
+
# 4. embed text tokens
|
307 |
+
inputs_embeds = self.get_model().embed_tokens(input_ids).clone()
|
308 |
+
|
309 |
+
# 5. replace multimodal tokens with features
|
310 |
+
image_selected = (input_ids == self.config.image_token_index)
|
311 |
+
inputs_embeds[image_selected] = inputs_embeds[image_selected] * 0.0 + mm_features
|
312 |
+
|
313 |
+
# 6. reshape back to batched format
|
314 |
+
C = inputs_embeds.shape[-1]
|
315 |
+
inputs_embeds = inputs_embeds.reshape(B, -1, C)
|
316 |
+
if attention_mask is not None:
|
317 |
+
attention_mask = attention_mask.view(B, -1)
|
318 |
+
if labels is not None:
|
319 |
+
labels = labels.view(B, -1)
|
320 |
+
if position_ids is not None:
|
321 |
+
position_ids = position_ids.view(B, -1)
|
322 |
+
|
323 |
+
return None, attention_mask, position_ids, past_key_values, inputs_embeds, labels
|
324 |
+
|
325 |
+
|
326 |
+
class Videollama3Qwen2ForCausalLM(Qwen2ForCausalLM, Videollama3MetaForCausalLM):
|
327 |
+
|
328 |
+
config_class = Videollama3Qwen2Config
|
329 |
+
|
330 |
+
def __init__(self, config, **kwargs):
|
331 |
+
super(Qwen2ForCausalLM, self).__init__(config)
|
332 |
+
self.model = Videollama3Qwen2Model(config)
|
333 |
+
self.vocab_size = config.vocab_size
|
334 |
+
self.lm_head = nn.Linear(config.hidden_size, config.vocab_size, bias=False)
|
335 |
+
|
336 |
+
# Initialize weights and apply final processing
|
337 |
+
self.post_init()
|
338 |
+
|
339 |
+
def get_model(self):
|
340 |
+
return self.model
|
341 |
+
|
342 |
+
# NOTE: arguments are copied from transformers==4.46.3
|
343 |
+
def forward(
|
344 |
+
self,
|
345 |
+
input_ids: torch.LongTensor = None,
|
346 |
+
attention_mask: Optional[torch.Tensor] = None,
|
347 |
+
position_ids: Optional[torch.LongTensor] = None,
|
348 |
+
past_key_values: Optional[List[torch.FloatTensor]] = None,
|
349 |
+
inputs_embeds: Optional[torch.FloatTensor] = None,
|
350 |
+
labels: Optional[torch.LongTensor] = None,
|
351 |
+
use_cache: Optional[bool] = None,
|
352 |
+
output_attentions: Optional[bool] = None,
|
353 |
+
output_hidden_states: Optional[bool] = None,
|
354 |
+
return_dict: Optional[bool] = None,
|
355 |
+
cache_position: Optional[torch.LongTensor] = None,
|
356 |
+
num_logits_to_keep: int = 0,
|
357 |
+
# multimodal inputs
|
358 |
+
pixel_values: Optional[torch.FloatTensor] = None,
|
359 |
+
grid_sizes: Optional[torch.LongTensor] = None,
|
360 |
+
merge_sizes: Optional[torch.LongTensor] = None,
|
361 |
+
modals: Optional[List[str]] = None,
|
362 |
+
**loss_kwargs,
|
363 |
+
) -> Union[Tuple, CausalLMOutputWithPast]:
|
364 |
+
if inputs_embeds is None:
|
365 |
+
(
|
366 |
+
input_ids,
|
367 |
+
attention_mask,
|
368 |
+
position_ids,
|
369 |
+
past_key_values,
|
370 |
+
inputs_embeds,
|
371 |
+
labels,
|
372 |
+
) = self.prepare_inputs_labels_for_multimodal(
|
373 |
+
input_ids=input_ids,
|
374 |
+
attention_mask=attention_mask,
|
375 |
+
position_ids=position_ids,
|
376 |
+
past_key_values=past_key_values,
|
377 |
+
labels=labels,
|
378 |
+
pixel_values=pixel_values,
|
379 |
+
grid_sizes=grid_sizes,
|
380 |
+
merge_sizes=merge_sizes,
|
381 |
+
modals=modals,
|
382 |
+
)
|
383 |
+
|
384 |
+
return super().forward(
|
385 |
+
input_ids=input_ids,
|
386 |
+
attention_mask=attention_mask,
|
387 |
+
position_ids=position_ids,
|
388 |
+
past_key_values=past_key_values,
|
389 |
+
inputs_embeds=inputs_embeds,
|
390 |
+
labels=labels,
|
391 |
+
use_cache=use_cache,
|
392 |
+
output_attentions=output_attentions,
|
393 |
+
output_hidden_states=output_hidden_states,
|
394 |
+
return_dict=return_dict,
|
395 |
+
cache_position=cache_position,
|
396 |
+
num_logits_to_keep=num_logits_to_keep,
|
397 |
+
**loss_kwargs,
|
398 |
+
)
|
399 |
+
|
400 |
+
@torch.no_grad()
|
401 |
+
def generate(
|
402 |
+
self,
|
403 |
+
# multimodal inputs
|
404 |
+
pixel_values: Optional[torch.FloatTensor] = None,
|
405 |
+
grid_sizes: Optional[torch.LongTensor] = None,
|
406 |
+
merge_sizes: Optional[torch.LongTensor] = None,
|
407 |
+
modals: Optional[List[str]] = None,
|
408 |
+
**kwargs,
|
409 |
+
) -> Union[GenerateOutput, torch.LongTensor]:
|
410 |
+
input_ids = kwargs.pop("input_ids", None)
|
411 |
+
attention_mask = kwargs.pop("attention_mask", None)
|
412 |
+
position_ids = kwargs.pop("position_ids", None)
|
413 |
+
past_key_values = kwargs.pop("past_key_values", None)
|
414 |
+
|
415 |
+
if "inputs_embeds" in kwargs:
|
416 |
+
raise NotImplementedError("`inputs_embeds` is not supported")
|
417 |
+
|
418 |
+
if pixel_values is not None:
|
419 |
+
(
|
420 |
+
input_ids,
|
421 |
+
attention_mask,
|
422 |
+
position_ids,
|
423 |
+
past_key_values,
|
424 |
+
inputs_embeds,
|
425 |
+
labels,
|
426 |
+
) = self.prepare_inputs_labels_for_multimodal(
|
427 |
+
input_ids=input_ids,
|
428 |
+
attention_mask=attention_mask,
|
429 |
+
position_ids=position_ids,
|
430 |
+
past_key_values=past_key_values,
|
431 |
+
labels=None,
|
432 |
+
pixel_values=pixel_values,
|
433 |
+
grid_sizes=grid_sizes,
|
434 |
+
merge_sizes=merge_sizes,
|
435 |
+
modals=modals,
|
436 |
+
)
|
437 |
+
else:
|
438 |
+
inputs_embeds = self.get_model().embed_tokens(input_ids)
|
439 |
+
|
440 |
+
return super().generate(
|
441 |
+
position_ids=position_ids,
|
442 |
+
attention_mask=attention_mask,
|
443 |
+
inputs_embeds=inputs_embeds,
|
444 |
+
**kwargs
|
445 |
+
)
|
446 |
+
|
447 |
+
def prepare_inputs_for_generation(self, input_ids, past_key_values=None, inputs_embeds=None, **kwargs):
|
448 |
+
images = kwargs.pop("images", None)
|
449 |
+
_inputs = super().prepare_inputs_for_generation(
|
450 |
+
input_ids, past_key_values=past_key_values, inputs_embeds=inputs_embeds, **kwargs
|
451 |
+
)
|
452 |
+
if images is not None:
|
453 |
+
_inputs['images'] = images
|
454 |
+
return _inputs
|
modeling_videollama3_encoder.py
ADDED
@@ -0,0 +1,534 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Adopted from https://github.com/huggingface/transformers/blob/main/src/transformers/models/qwen2_vl/modeling_qwen2_vl.py.
|
2 |
+
# Below is the original copyright:
|
3 |
+
# Copyright 2024 The Qwen team, Alibaba Group and the HuggingFace Inc. team. All rights reserved.
|
4 |
+
#
|
5 |
+
# This code is based on EleutherAI's GPT-NeoX library and the GPT-NeoX
|
6 |
+
# and OPT implementations in this library. It has been modified from its
|
7 |
+
# original forms to accommodate minor architectural differences compared
|
8 |
+
# to GPT-NeoX and OPT used by the Meta AI team that trained the model.
|
9 |
+
#
|
10 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
11 |
+
# you may not use this file except in compliance with the License.
|
12 |
+
# You may obtain a copy of the License at
|
13 |
+
#
|
14 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
15 |
+
#
|
16 |
+
# Unless required by applicable law or agreed to in writing, software
|
17 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
18 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
19 |
+
# See the License for the specific language governing permissions and
|
20 |
+
# limitations under the License.
|
21 |
+
"""PyTorch VideoLLaMA3 vision encoder model."""
|
22 |
+
|
23 |
+
import importlib.util
|
24 |
+
import os.path as osp
|
25 |
+
import math
|
26 |
+
import warnings
|
27 |
+
|
28 |
+
import torch
|
29 |
+
import torch.nn as nn
|
30 |
+
import torch.nn.functional as F
|
31 |
+
import torch.utils.checkpoint
|
32 |
+
from torch.nn.init import _calculate_fan_in_and_fan_out
|
33 |
+
|
34 |
+
from transformers.activations import ACT2FN
|
35 |
+
from transformers.modeling_utils import PreTrainedModel
|
36 |
+
from transformers.utils import is_flash_attn_2_available
|
37 |
+
|
38 |
+
if is_flash_attn_2_available():
|
39 |
+
from flash_attn import flash_attn_varlen_func
|
40 |
+
else:
|
41 |
+
flash_attn_varlen_func = None
|
42 |
+
|
43 |
+
try:
|
44 |
+
from .configuration_videollama3_encoder import Videollama3VisionEncoderConfig
|
45 |
+
except ImportError:
|
46 |
+
spec = importlib.util.spec_from_file_location(
|
47 |
+
"configuration_videollama3_encoder",
|
48 |
+
osp.join(osp.dirname(__file__), "configuration_videollama3_encoder.py"),
|
49 |
+
)
|
50 |
+
configuration_videollama3_encoder = importlib.util.module_from_spec(spec)
|
51 |
+
spec.loader.exec_module(configuration_videollama3_encoder)
|
52 |
+
Videollama3VisionEncoderConfig = getattr(
|
53 |
+
configuration_videollama3_encoder,
|
54 |
+
"Videollama3VisionEncoderConfig",
|
55 |
+
)
|
56 |
+
|
57 |
+
|
58 |
+
def _trunc_normal_(tensor, mean, std, a, b):
|
59 |
+
# Cut & paste from PyTorch official master until it's in a few official releases - RW
|
60 |
+
# Method based on https://people.sc.fsu.edu/~jburkardt/presentations/truncated_normal.pdf
|
61 |
+
def norm_cdf(x):
|
62 |
+
# Computes standard normal cumulative distribution function
|
63 |
+
return (1.0 + math.erf(x / math.sqrt(2.0))) / 2.0
|
64 |
+
|
65 |
+
if (mean < a - 2 * std) or (mean > b + 2 * std):
|
66 |
+
warnings.warn(
|
67 |
+
"mean is more than 2 std from [a, b] in nn.init.trunc_normal_. "
|
68 |
+
"The distribution of values may be incorrect.",
|
69 |
+
stacklevel=2,
|
70 |
+
)
|
71 |
+
|
72 |
+
# Values are generated by using a truncated uniform distribution and
|
73 |
+
# then using the inverse CDF for the normal distribution.
|
74 |
+
# Get upper and lower cdf values
|
75 |
+
l = norm_cdf((a - mean) / std)
|
76 |
+
u = norm_cdf((b - mean) / std)
|
77 |
+
|
78 |
+
# Uniformly fill tensor with values from [l, u], then translate to
|
79 |
+
# [2l-1, 2u-1].
|
80 |
+
tensor.uniform_(2 * l - 1, 2 * u - 1)
|
81 |
+
|
82 |
+
# Use inverse cdf transform for normal distribution to get truncated
|
83 |
+
# standard normal
|
84 |
+
tensor.erfinv_()
|
85 |
+
|
86 |
+
# Transform to proper mean, std
|
87 |
+
tensor.mul_(std * math.sqrt(2.0))
|
88 |
+
tensor.add_(mean)
|
89 |
+
|
90 |
+
# Clamp to ensure it's in the proper range
|
91 |
+
tensor.clamp_(min=a, max=b)
|
92 |
+
|
93 |
+
|
94 |
+
def trunc_normal_tf_(
|
95 |
+
tensor: torch.Tensor, mean: float = 0.0, std: float = 1.0, a: float = -2.0, b: float = 2.0
|
96 |
+
) -> torch.Tensor:
|
97 |
+
"""Fills the input Tensor with values drawn from a truncated
|
98 |
+
normal distribution. The values are effectively drawn from the
|
99 |
+
normal distribution :math:`\\mathcal{N}(\text{mean}, \text{std}^2)`
|
100 |
+
with values outside :math:`[a, b]` redrawn until they are within
|
101 |
+
the bounds. The method used for generating the random values works
|
102 |
+
best when :math:`a \\leq \text{mean} \\leq b`.
|
103 |
+
|
104 |
+
NOTE: this 'tf' variant behaves closer to Tensorflow / JAX impl where the
|
105 |
+
bounds [a, b] are applied when sampling the normal distribution with mean=0, std=1.0
|
106 |
+
and the result is subsequently scaled and shifted by the mean and std args.
|
107 |
+
|
108 |
+
Args:
|
109 |
+
tensor: an n-dimensional `torch.Tensor`
|
110 |
+
mean: the mean of the normal distribution
|
111 |
+
std: the standard deviation of the normal distribution
|
112 |
+
a: the minimum cutoff value
|
113 |
+
b: the maximum cutoff value
|
114 |
+
"""
|
115 |
+
with torch.no_grad():
|
116 |
+
_trunc_normal_(tensor, 0, 1.0, a, b)
|
117 |
+
tensor.mul_(std).add_(mean)
|
118 |
+
|
119 |
+
|
120 |
+
def variance_scaling_(tensor, scale=1.0, mode="fan_in", distribution="normal"):
|
121 |
+
fan_in, fan_out = _calculate_fan_in_and_fan_out(tensor)
|
122 |
+
if mode == "fan_in":
|
123 |
+
denom = fan_in
|
124 |
+
elif mode == "fan_out":
|
125 |
+
denom = fan_out
|
126 |
+
elif mode == "fan_avg":
|
127 |
+
denom = (fan_in + fan_out) / 2
|
128 |
+
|
129 |
+
variance = scale / denom
|
130 |
+
|
131 |
+
if distribution == "truncated_normal":
|
132 |
+
# constant is stddev of standard normal truncated to (-2, 2)
|
133 |
+
trunc_normal_tf_(tensor, std=math.sqrt(variance) / 0.87962566103423978)
|
134 |
+
elif distribution == "normal":
|
135 |
+
with torch.no_grad():
|
136 |
+
tensor.normal_(std=math.sqrt(variance))
|
137 |
+
elif distribution == "uniform":
|
138 |
+
bound = math.sqrt(3 * variance)
|
139 |
+
with torch.no_grad():
|
140 |
+
tensor.uniform_(-bound, bound)
|
141 |
+
else:
|
142 |
+
raise ValueError(f"invalid distribution {distribution}")
|
143 |
+
|
144 |
+
|
145 |
+
def lecun_normal_(tensor):
|
146 |
+
variance_scaling_(tensor, mode="fan_in", distribution="truncated_normal")
|
147 |
+
|
148 |
+
|
149 |
+
def default_flax_embed_init(tensor):
|
150 |
+
variance_scaling_(tensor, mode="fan_in", distribution="normal")
|
151 |
+
|
152 |
+
|
153 |
+
# Copied from transformers.models.llama.modeling_llama.rotate_half
|
154 |
+
def rotate_half(x):
|
155 |
+
"""Rotates half the hidden dims of the input."""
|
156 |
+
x1 = x[..., : x.shape[-1] // 2]
|
157 |
+
x2 = x[..., x.shape[-1] // 2 :]
|
158 |
+
return torch.cat((-x2, x1), dim=-1)
|
159 |
+
|
160 |
+
|
161 |
+
def apply_rotary_pos_emb_vision(tensor: torch.Tensor, freqs: torch.Tensor) -> torch.Tensor:
|
162 |
+
orig_dtype = tensor.dtype
|
163 |
+
tensor = tensor.float()
|
164 |
+
cos = freqs.cos()
|
165 |
+
sin = freqs.sin()
|
166 |
+
cos = cos.unsqueeze(1).repeat(1, 1, 2).unsqueeze(0).float()
|
167 |
+
sin = sin.unsqueeze(1).repeat(1, 1, 2).unsqueeze(0).float()
|
168 |
+
output = (tensor * cos) + (rotate_half(tensor) * sin)
|
169 |
+
output = output.to(orig_dtype)
|
170 |
+
return output
|
171 |
+
|
172 |
+
|
173 |
+
class VisionRotaryEmbedding(nn.Module):
|
174 |
+
|
175 |
+
def __init__(self, dim: int, theta: float = 10000.0) -> None:
|
176 |
+
super().__init__()
|
177 |
+
inv_freq = 1.0 / (theta ** (torch.arange(0, dim, 2, dtype=torch.float) / dim))
|
178 |
+
self.register_buffer("inv_freq", inv_freq, persistent=False)
|
179 |
+
|
180 |
+
def forward(self, seqlen: int) -> torch.Tensor:
|
181 |
+
seq = torch.arange(seqlen, device=self.inv_freq.device, dtype=self.inv_freq.dtype)
|
182 |
+
freqs = torch.outer(seq, self.inv_freq)
|
183 |
+
return freqs
|
184 |
+
|
185 |
+
|
186 |
+
class Videollama3VisionEmbeddings(nn.Module):
|
187 |
+
|
188 |
+
def __init__(self, config: Videollama3VisionEncoderConfig):
|
189 |
+
super().__init__()
|
190 |
+
self.config = config
|
191 |
+
self.embed_dim = config.hidden_size
|
192 |
+
self.patch_size = config.patch_size
|
193 |
+
|
194 |
+
self.patch_embedding = nn.Conv2d(
|
195 |
+
in_channels=config.num_channels,
|
196 |
+
out_channels=self.embed_dim,
|
197 |
+
kernel_size=self.patch_size,
|
198 |
+
stride=self.patch_size,
|
199 |
+
padding="valid",
|
200 |
+
)
|
201 |
+
|
202 |
+
def forward(self, hidden_states: torch.Tensor) -> torch.Tensor:
|
203 |
+
hidden_states = hidden_states.view(
|
204 |
+
-1, self.config.num_channels, self.patch_size, self.patch_size
|
205 |
+
)
|
206 |
+
patch_embeds = self.patch_embedding(hidden_states) # shape = [*, width, grid, grid]
|
207 |
+
# embeddings = patch_embeds.flatten(2).transpose(1, 2)
|
208 |
+
embeddings = patch_embeds.view(-1, self.embed_dim)
|
209 |
+
|
210 |
+
return embeddings
|
211 |
+
|
212 |
+
|
213 |
+
class VisionAttention(nn.Module):
|
214 |
+
"""Multi-headed attention from 'Attention Is All You Need' paper"""
|
215 |
+
|
216 |
+
# Copied from transformers.models.clip.modeling_clip.CLIPAttention.__init__
|
217 |
+
def __init__(self, config):
|
218 |
+
super().__init__()
|
219 |
+
self.config = config
|
220 |
+
self.embed_dim = config.hidden_size
|
221 |
+
self.num_heads = config.num_attention_heads
|
222 |
+
self.head_dim = self.embed_dim // self.num_heads
|
223 |
+
if self.head_dim * self.num_heads != self.embed_dim:
|
224 |
+
raise ValueError(
|
225 |
+
f"embed_dim must be divisible by num_heads (got `embed_dim`: {self.embed_dim} and `num_heads`:"
|
226 |
+
f" {self.num_heads})."
|
227 |
+
)
|
228 |
+
self.scale = self.head_dim**-0.5
|
229 |
+
self.dropout = config.attention_dropout
|
230 |
+
|
231 |
+
self.k_proj = nn.Linear(self.embed_dim, self.embed_dim)
|
232 |
+
self.v_proj = nn.Linear(self.embed_dim, self.embed_dim)
|
233 |
+
self.q_proj = nn.Linear(self.embed_dim, self.embed_dim)
|
234 |
+
self.out_proj = nn.Linear(self.embed_dim, self.embed_dim)
|
235 |
+
|
236 |
+
def forward(
|
237 |
+
self,
|
238 |
+
hidden_states: torch.Tensor,
|
239 |
+
cu_seqlens: torch.Tensor,
|
240 |
+
rotary_pos_emb: torch.Tensor = None,
|
241 |
+
) -> torch.Tensor:
|
242 |
+
"""Input shape: Time x Channel"""
|
243 |
+
|
244 |
+
q_len, _ = hidden_states.size()
|
245 |
+
|
246 |
+
query_states = self.q_proj(hidden_states)
|
247 |
+
key_states = self.k_proj(hidden_states)
|
248 |
+
value_states = self.v_proj(hidden_states)
|
249 |
+
|
250 |
+
query_states = query_states.view(q_len, self.num_heads, self.head_dim)
|
251 |
+
key_states = key_states.view(q_len, self.num_heads, self.head_dim)
|
252 |
+
value_states = value_states.view(q_len, self.num_heads, self.head_dim)
|
253 |
+
|
254 |
+
query_states = apply_rotary_pos_emb_vision(query_states.unsqueeze(0), rotary_pos_emb).squeeze(0)
|
255 |
+
key_states = apply_rotary_pos_emb_vision(key_states.unsqueeze(0), rotary_pos_emb).squeeze(0)
|
256 |
+
|
257 |
+
attention_mask = torch.zeros([1, q_len, q_len], device=query_states.device, dtype=torch.bool)
|
258 |
+
for i in range(1, len(cu_seqlens)):
|
259 |
+
attention_mask[..., cu_seqlens[i - 1] : cu_seqlens[i], cu_seqlens[i - 1] : cu_seqlens[i]] = True
|
260 |
+
|
261 |
+
query_states = query_states.transpose(0, 1)
|
262 |
+
key_states = key_states.transpose(0, 1)
|
263 |
+
value_states = value_states.transpose(0, 1)
|
264 |
+
|
265 |
+
attn_weights = torch.matmul(query_states, key_states.transpose(1, 2)) / math.sqrt(self.head_dim)
|
266 |
+
attn_weights = attn_weights + attention_mask
|
267 |
+
|
268 |
+
# upcast attention to fp32
|
269 |
+
attn_weights = nn.functional.softmax(attn_weights, dim=-1, dtype=torch.float32).to(query_states.dtype)
|
270 |
+
attn_weights = nn.functional.dropout(attn_weights, p=self.dropout, training=self.training)
|
271 |
+
attn_output = torch.matmul(attn_weights, value_states)
|
272 |
+
|
273 |
+
attn_output = attn_output.transpose(0, 1)
|
274 |
+
attn_output = attn_output.reshape(q_len, -1)
|
275 |
+
attn_output = self.out_proj(attn_output)
|
276 |
+
|
277 |
+
return attn_output
|
278 |
+
|
279 |
+
|
280 |
+
class VisionFlashAttention2(VisionAttention):
|
281 |
+
|
282 |
+
def __init__(self, *args, **kwargs):
|
283 |
+
super().__init__(*args, **kwargs)
|
284 |
+
|
285 |
+
# Adapted from transformers.models.llama.modeling_llama.LlamaFlashAttention2.forward
|
286 |
+
def forward(
|
287 |
+
self,
|
288 |
+
hidden_states: torch.Tensor,
|
289 |
+
cu_seqlens: torch.Tensor,
|
290 |
+
rotary_pos_emb: torch.Tensor = None,
|
291 |
+
) -> torch.Tensor:
|
292 |
+
q_len, _ = hidden_states.size()
|
293 |
+
|
294 |
+
query_states = self.q_proj(hidden_states)
|
295 |
+
key_states = self.k_proj(hidden_states)
|
296 |
+
value_states = self.v_proj(hidden_states)
|
297 |
+
|
298 |
+
# Flash attention requires the input to have the shape
|
299 |
+
# batch_size x seq_length x head_dim x hidden_dim
|
300 |
+
# therefore we just need to keep the original shape
|
301 |
+
query_states = query_states.view(q_len, self.num_heads, self.head_dim)
|
302 |
+
key_states = key_states.view(q_len, self.num_heads, self.head_dim)
|
303 |
+
value_states = value_states.view(q_len, self.num_heads, self.head_dim)
|
304 |
+
query_states = apply_rotary_pos_emb_vision(query_states.unsqueeze(0), rotary_pos_emb).squeeze(0)
|
305 |
+
key_states = apply_rotary_pos_emb_vision(key_states.unsqueeze(0), rotary_pos_emb).squeeze(0)
|
306 |
+
|
307 |
+
max_seqlen = (cu_seqlens[1:] - cu_seqlens[:-1]).max().item()
|
308 |
+
attn_output = flash_attn_varlen_func(query_states, key_states, value_states, cu_seqlens, cu_seqlens, max_seqlen, max_seqlen).reshape(
|
309 |
+
q_len, -1
|
310 |
+
)
|
311 |
+
attn_output = self.out_proj(attn_output)
|
312 |
+
|
313 |
+
return attn_output
|
314 |
+
|
315 |
+
|
316 |
+
class VisionSdpaAttention(VisionAttention):
|
317 |
+
|
318 |
+
def forward(
|
319 |
+
self,
|
320 |
+
hidden_states: torch.Tensor,
|
321 |
+
cu_seqlens: torch.Tensor,
|
322 |
+
rotary_pos_emb: torch.Tensor = None,
|
323 |
+
) -> torch.Tensor:
|
324 |
+
seq_length = hidden_states.shape[0]
|
325 |
+
query_states = self.q_proj(hidden_states)
|
326 |
+
key_states = self.k_proj(hidden_states)
|
327 |
+
value_states = self.v_proj(hidden_states)
|
328 |
+
|
329 |
+
query_states = query_states.view(seq_length, self.num_heads, self.head_dim)
|
330 |
+
key_states = key_states.view(seq_length, self.num_heads, self.head_dim)
|
331 |
+
value_states = value_states.view(seq_length, self.num_heads, self.head_dim)
|
332 |
+
|
333 |
+
query_states = apply_rotary_pos_emb_vision(query_states.unsqueeze(0), rotary_pos_emb).squeeze(0)
|
334 |
+
key_states = apply_rotary_pos_emb_vision(key_states.unsqueeze(0), rotary_pos_emb).squeeze(0)
|
335 |
+
|
336 |
+
attention_mask = torch.zeros([1, seq_length, seq_length], device=query_states.device, dtype=torch.bool)
|
337 |
+
for i in range(1, len(cu_seqlens)):
|
338 |
+
attention_mask[..., cu_seqlens[i - 1] : cu_seqlens[i], cu_seqlens[i - 1] : cu_seqlens[i]] = True
|
339 |
+
|
340 |
+
query_states = query_states.transpose(0, 1)
|
341 |
+
key_states = key_states.transpose(0, 1)
|
342 |
+
value_states = value_states.transpose(0, 1)
|
343 |
+
attn_output = F.scaled_dot_product_attention(query_states, key_states, value_states, attention_mask, dropout_p=0.0)
|
344 |
+
attn_output = attn_output.transpose(0, 1)
|
345 |
+
attn_output = attn_output.reshape(seq_length, -1)
|
346 |
+
attn_output = self.proj(attn_output)
|
347 |
+
return attn_output
|
348 |
+
|
349 |
+
|
350 |
+
VISION_ATTENTION_CLASSES = {
|
351 |
+
"eager": VisionAttention,
|
352 |
+
"flash_attention_2": VisionFlashAttention2,
|
353 |
+
"sdpa": VisionSdpaAttention,
|
354 |
+
}
|
355 |
+
|
356 |
+
|
357 |
+
# Copied from transformers.models.clip.modeling_clip.CLIPMLP with CLIP->Videollama3
|
358 |
+
class Videollama3VisionMLP(nn.Module):
|
359 |
+
|
360 |
+
def __init__(self, config):
|
361 |
+
super().__init__()
|
362 |
+
self.config = config
|
363 |
+
self.activation_fn = ACT2FN[config.hidden_act]
|
364 |
+
self.fc1 = nn.Linear(config.hidden_size, config.intermediate_size)
|
365 |
+
self.fc2 = nn.Linear(config.intermediate_size, config.hidden_size)
|
366 |
+
|
367 |
+
def forward(self, hidden_states: torch.Tensor) -> torch.Tensor:
|
368 |
+
hidden_states = self.fc1(hidden_states)
|
369 |
+
hidden_states = self.activation_fn(hidden_states)
|
370 |
+
hidden_states = self.fc2(hidden_states)
|
371 |
+
return hidden_states
|
372 |
+
|
373 |
+
|
374 |
+
class Videollama3VisionEncoderLayer(nn.Module):
|
375 |
+
|
376 |
+
def __init__(self, config: Videollama3VisionEncoderConfig):
|
377 |
+
super().__init__()
|
378 |
+
self.embed_dim = config.hidden_size
|
379 |
+
self.self_attn = VISION_ATTENTION_CLASSES[config._attn_implementation](config=config)
|
380 |
+
self.layer_norm1 = nn.LayerNorm(self.embed_dim, eps=config.layer_norm_eps)
|
381 |
+
self.mlp = Videollama3VisionMLP(config)
|
382 |
+
self.layer_norm2 = nn.LayerNorm(self.embed_dim, eps=config.layer_norm_eps)
|
383 |
+
|
384 |
+
# Ignore copy
|
385 |
+
def forward(self, hidden_states, cu_seqlens, rotary_pos_emb) -> torch.Tensor:
|
386 |
+
hidden_states = hidden_states + self.self_attn(
|
387 |
+
self.layer_norm1(hidden_states), cu_seqlens=cu_seqlens, rotary_pos_emb=rotary_pos_emb
|
388 |
+
)
|
389 |
+
hidden_states = hidden_states + self.mlp(self.layer_norm2(hidden_states))
|
390 |
+
return hidden_states
|
391 |
+
|
392 |
+
|
393 |
+
class Videollama3VisionTransformerEncoder(nn.Module):
|
394 |
+
|
395 |
+
def __init__(self, config: Videollama3VisionEncoderConfig):
|
396 |
+
super().__init__()
|
397 |
+
self.config = config
|
398 |
+
head_dim = config.hidden_size // config.num_attention_heads
|
399 |
+
self.rotary_pos_emb = VisionRotaryEmbedding(head_dim // 2)
|
400 |
+
self.layers = nn.ModuleList([Videollama3VisionEncoderLayer(config) for _ in range(config.num_hidden_layers)])
|
401 |
+
self.gradient_checkpointing = False
|
402 |
+
|
403 |
+
def rot_pos_emb(self, grid_sizes, merge_sizes):
|
404 |
+
pos_ids = []
|
405 |
+
for (t, h, w), merge_size in zip(grid_sizes, merge_sizes):
|
406 |
+
hpos_ids = torch.arange(h).unsqueeze(1).expand(-1, w)
|
407 |
+
hpos_ids = hpos_ids.reshape(
|
408 |
+
h // merge_size,
|
409 |
+
merge_size,
|
410 |
+
w // merge_size,
|
411 |
+
merge_size,
|
412 |
+
)
|
413 |
+
hpos_ids = hpos_ids.permute(0, 2, 1, 3)
|
414 |
+
hpos_ids = hpos_ids.flatten()
|
415 |
+
|
416 |
+
wpos_ids = torch.arange(w).unsqueeze(0).expand(h, -1)
|
417 |
+
wpos_ids = wpos_ids.reshape(
|
418 |
+
h // merge_size,
|
419 |
+
merge_size,
|
420 |
+
w // merge_size,
|
421 |
+
merge_size,
|
422 |
+
)
|
423 |
+
wpos_ids = wpos_ids.permute(0, 2, 1, 3)
|
424 |
+
wpos_ids = wpos_ids.flatten()
|
425 |
+
pos_ids.append(torch.stack([hpos_ids, wpos_ids], dim=-1).repeat(t, 1))
|
426 |
+
|
427 |
+
pos_ids = torch.cat(pos_ids, dim=0)
|
428 |
+
max_grid_size = grid_sizes[:, 1:].max()
|
429 |
+
rotary_pos_emb_full = self.rotary_pos_emb(max_grid_size)
|
430 |
+
rotary_pos_emb = rotary_pos_emb_full[pos_ids].flatten(1)
|
431 |
+
|
432 |
+
return rotary_pos_emb
|
433 |
+
|
434 |
+
def forward(self, hidden_states, grid_sizes, merge_sizes) -> torch.Tensor:
|
435 |
+
rotary_pos_emb = self.rot_pos_emb(grid_sizes, merge_sizes)
|
436 |
+
|
437 |
+
cu_seqlens = torch.repeat_interleave(grid_sizes[:, 1] * grid_sizes[:, 2], grid_sizes[:, 0]).cumsum(dim=0, dtype=torch.int32)
|
438 |
+
cu_seqlens = F.pad(cu_seqlens, (1, 0), value=0)
|
439 |
+
|
440 |
+
for blk in self.layers:
|
441 |
+
if self.gradient_checkpointing and self.training:
|
442 |
+
hidden_states = self._gradient_checkpointing_func(
|
443 |
+
blk.__call__,
|
444 |
+
hidden_states,
|
445 |
+
cu_seqlens,
|
446 |
+
rotary_pos_emb
|
447 |
+
)
|
448 |
+
else:
|
449 |
+
hidden_states = blk(hidden_states, cu_seqlens=cu_seqlens, rotary_pos_emb=rotary_pos_emb)
|
450 |
+
|
451 |
+
return hidden_states
|
452 |
+
|
453 |
+
|
454 |
+
class Videollama3VisionEncoderModel(PreTrainedModel):
|
455 |
+
|
456 |
+
config_class = Videollama3VisionEncoderConfig
|
457 |
+
base_model_prefix = "videollama3"
|
458 |
+
main_input_name = "pixel_values"
|
459 |
+
supports_gradient_checkpointing = True
|
460 |
+
_no_split_modules = [
|
461 |
+
"Videollama3VisionEncoderLayer",
|
462 |
+
"Videollama3VisionEmbeddings",
|
463 |
+
]
|
464 |
+
_supports_flash_attn_2 = True
|
465 |
+
_supports_sdpa = True
|
466 |
+
|
467 |
+
def __init__(self, config: Videollama3VisionEncoderConfig):
|
468 |
+
super().__init__(config=config)
|
469 |
+
embed_dim = config.hidden_size
|
470 |
+
|
471 |
+
self.embeddings = Videollama3VisionEmbeddings(config)
|
472 |
+
self.encoder = Videollama3VisionTransformerEncoder(config)
|
473 |
+
self.post_layernorm = nn.LayerNorm(embed_dim, eps=config.layer_norm_eps)
|
474 |
+
|
475 |
+
self.post_init()
|
476 |
+
|
477 |
+
def forward(self, pixel_values, grid_sizes, merge_sizes=None) -> torch.Tensor:
|
478 |
+
hidden_states = self.embeddings(pixel_values)
|
479 |
+
hidden_states = self.encoder(hidden_states, grid_sizes, merge_sizes)
|
480 |
+
hidden_states = self.post_layernorm(hidden_states)
|
481 |
+
|
482 |
+
hidden_states_chunks = hidden_states.split(grid_sizes.prod(dim=1).tolist(), dim=0)
|
483 |
+
outputs = []
|
484 |
+
|
485 |
+
for hidden_states, grid_size, merge_size in zip(hidden_states_chunks, grid_sizes, merge_sizes):
|
486 |
+
# NOTE: previous implementation, which supports downsampling with any factor
|
487 |
+
c = hidden_states.shape[-1]
|
488 |
+
hidden_states = hidden_states.view(
|
489 |
+
grid_size[0], grid_size[1] // merge_size, grid_size[2] // merge_size, merge_size, merge_size, c
|
490 |
+
).permute(0, 1, 3, 2, 4, 5)
|
491 |
+
hidden_states = hidden_states.reshape(
|
492 |
+
grid_size[0], grid_size[1], grid_size[2], c
|
493 |
+
).permute(0, 3, 1, 2)
|
494 |
+
hidden_states = torch.nn.functional.interpolate(
|
495 |
+
hidden_states,
|
496 |
+
size=(grid_size[1] // merge_size, grid_size[2] // merge_size),
|
497 |
+
mode='bilinear'
|
498 |
+
)
|
499 |
+
hidden_states = hidden_states.permute(0, 2, 3, 1).view(-1, c)
|
500 |
+
|
501 |
+
# NOTE: simplified implementation, which only supports downsampling with integer factor
|
502 |
+
# NOTE: this implementation is mathematically equivalent to the previous one when merge_size is 1 or 2 but may cause slightly different results
|
503 |
+
# hidden_states = hidden_states.view(-1, merge_size * merge_size, hidden_states.size(-1))
|
504 |
+
# hidden_states = hidden_states.mean(dim=1)
|
505 |
+
|
506 |
+
outputs.append(hidden_states)
|
507 |
+
|
508 |
+
return torch.cat(outputs, dim=0)
|
509 |
+
|
510 |
+
def _init_weights(self, module):
|
511 |
+
"""Initialize the weights"""
|
512 |
+
if isinstance(module, nn.Embedding):
|
513 |
+
default_flax_embed_init(module.weight)
|
514 |
+
elif isinstance(module, VisionAttention):
|
515 |
+
nn.init.xavier_uniform_(module.q_proj.weight)
|
516 |
+
nn.init.xavier_uniform_(module.k_proj.weight)
|
517 |
+
nn.init.xavier_uniform_(module.v_proj.weight)
|
518 |
+
nn.init.xavier_uniform_(module.out_proj.weight)
|
519 |
+
nn.init.zeros_(module.q_proj.bias)
|
520 |
+
nn.init.zeros_(module.k_proj.bias)
|
521 |
+
nn.init.zeros_(module.v_proj.bias)
|
522 |
+
nn.init.zeros_(module.out_proj.bias)
|
523 |
+
elif isinstance(module, Videollama3VisionMLP):
|
524 |
+
nn.init.xavier_uniform_(module.fc1.weight)
|
525 |
+
nn.init.xavier_uniform_(module.fc2.weight)
|
526 |
+
nn.init.normal_(module.fc1.bias, std=1e-6)
|
527 |
+
nn.init.normal_(module.fc2.bias, std=1e-6)
|
528 |
+
elif isinstance(module, (nn.Linear, nn.Conv2d)):
|
529 |
+
lecun_normal_(module.weight)
|
530 |
+
if module.bias is not None:
|
531 |
+
nn.init.zeros_(module.bias)
|
532 |
+
elif isinstance(module, nn.LayerNorm):
|
533 |
+
module.bias.data.zero_()
|
534 |
+
module.weight.data.fill_(1.0)
|