BAAI
/

BoyaWu10 commited on
Commit
1f7509c
1 Parent(s): e42c782

Upload checkpoints

Browse files
README.md CHANGED
@@ -1,3 +1,79 @@
1
  ---
 
2
  license: apache-2.0
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ inference: false
3
  license: apache-2.0
4
  ---
5
+
6
+ # Model Card
7
+
8
+ <p align="center">
9
+ <img src="./icon.png" alt="Logo" width="350">
10
+ </p>
11
+
12
+ 📖 [Technical report](https://arxiv.org/abs/2402.11530) | 🏠 [Code](https://github.com/BAAI-DCAI/Bunny) | 🐰 [Demo](https://wisemodel.cn/spaces/baai/Bunny)
13
+
14
+ Bunny is a family of lightweight but powerful multimodal models. It offers multiple plug-and-play vision encoders, like EVA-CLIP, SigLIP and language backbones, including Phi-1.5, StableLM-2, Qwen1.5, MiniCPM and Phi-2. To compensate for the decrease in model size, we construct more informative training data by curated selection from a broader data source. Remarkably, our Bunny-v1.0-3B model built upon SigLIP and Phi-2 outperforms the state-of-the-art MLLMs, not only in comparison with models of similar size but also against larger MLLM frameworks (7B), and even achieves performance on par with 13B models.
15
+
16
+ Bunny-v1.0-3B-zh employs [MiniCPM-2B](https://huggingface.co/openbmb/MiniCPM-2B-history) as the language model and [SigLIP](https://huggingface.co/google/siglip-so400m-patch14-384) as the vision encoder.
17
+ The model focuses on Chinese and achieves 64.9 on MMBench-CN test split.
18
+
19
+ The model is pretrained on LAION-2M and finetuned on Bunny-695K.
20
+ More details about this model can be found in [GitHub](https://github.com/BAAI-DCAI/Bunny).
21
+
22
+ # Quickstart
23
+
24
+ Here we show a code snippet to show you how to use the model with transformers.
25
+
26
+ Before running the snippet, you need to install the following dependencies:
27
+
28
+ ```shell
29
+ pip install torch transformers accelerate pillow
30
+ ```
31
+
32
+ ```python
33
+ import torch
34
+ import transformers
35
+ from transformers import AutoModelForCausalLM, AutoTokenizer
36
+ from PIL import Image
37
+ import warnings
38
+
39
+ # disable some warnings
40
+ transformers.logging.set_verbosity_error()
41
+ transformers.logging.disable_progress_bar()
42
+ warnings.filterwarnings('ignore')
43
+
44
+ # set device
45
+ torch.set_default_device('cpu') # or 'cuda'
46
+
47
+ # create model
48
+ model = AutoModelForCausalLM.from_pretrained(
49
+ 'BAAI/Bunny-v1_0-3B-zh',
50
+ torch_dtype=torch.float16,
51
+ device_map='auto',
52
+ trust_remote_code=True)
53
+ tokenizer = AutoTokenizer.from_pretrained(
54
+ 'BAAI/Bunny-v1_0-3B-zh',
55
+ trust_remote_code=True)
56
+
57
+ # text prompt
58
+ prompt = 'Why is the image funny?'
59
+ text = f"A chat between a curious user and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the user's questions. USER: <image>\n{prompt} ASSISTANT:"
60
+ text_chunks = [tokenizer(chunk).input_ids for chunk in text.split('<image>')]
61
+ input_ids = torch.tensor(text_chunks[0] + [-200] + text_chunks[1], dtype=torch.long).unsqueeze(0)
62
+
63
+ # image, sample images can be found in images folder
64
+ image = Image.open('example_2.png')
65
+ image_tensor = model.process_images([image], model.config).to(dtype=model.dtype)
66
+
67
+ # generate
68
+ output_ids = model.generate(
69
+ input_ids,
70
+ images=image_tensor,
71
+ max_new_tokens=100,
72
+ use_cache=True)[0]
73
+
74
+ print(tokenizer.decode(output_ids[input_ids.shape[1]:], skip_special_tokens=True).strip())
75
+ ```
76
+
77
+ # License
78
+ This project utilizes certain datasets and checkpoints that are subject to their respective original licenses. Users must comply with all terms and conditions of these original licenses.
79
+ The content of this project itself is licensed under the Apache license 2.0.
config.json ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "BAAI/Bunny-v1.0-3B-zh",
3
+ "architectures": [
4
+ "BunnyMiniCPMForCausalLM"
5
+ ],
6
+ "attention_bias": false,
7
+ "attention_dropout": 0.0,
8
+ "auto_map": {
9
+ "AutoConfig": "configuration_bunny_minicpm.BunnyMiniCPMConfig",
10
+ "AutoModel": "modeling_bunny_minicpm.BunnyMiniCPMModel",
11
+ "AutoModelForCausalLM": "modeling_bunny_minicpm.BunnyMiniCPMForCausalLM",
12
+ "AutoModelForSeq2SeqLM": "modeling_bunny_minicpm.MiniCPMForCausalLM",
13
+ "AutoModelForSequenceClassification": "modeling_bunny_minicpm.MiniCPMForSequenceClassification"
14
+ },
15
+ "bos_token_id": 1,
16
+ "dim_model_base": 256,
17
+ "eos_token_id": 2,
18
+ "freeze_mm_mlp_adapter": false,
19
+ "hidden_act": "silu",
20
+ "hidden_size": 2304,
21
+ "image_aspect_ratio": "pad",
22
+ "initializer_range": 0.1,
23
+ "intermediate_size": 5760,
24
+ "max_position_embeddings": 2048,
25
+ "mm_hidden_size": 1152,
26
+ "mm_projector_lr": 2e-05,
27
+ "mm_projector_type": "mlp2x_gelu",
28
+ "mm_vision_tower": "google/siglip-so400m-patch14-384",
29
+ "model_type": "bunny-minicpm",
30
+ "num_attention_heads": 36,
31
+ "num_hidden_layers": 40,
32
+ "num_key_value_heads": 36,
33
+ "pretraining_tp": 1,
34
+ "rms_norm_eps": 1e-05,
35
+ "rope_scaling": null,
36
+ "rope_theta": 10000.0,
37
+ "scale_depth": 1.4,
38
+ "scale_emb": 12,
39
+ "tokenizer_model_max_length": 2048,
40
+ "tokenizer_padding_side": "right",
41
+ "torch_dtype": "float16",
42
+ "transformers_version": "4.38.2",
43
+ "tune_mm_mlp_adapter": false,
44
+ "unfreeze_vision_tower": false,
45
+ "use_cache": true,
46
+ "use_mm_proj": true,
47
+ "vocab_size": 122753
48
+ }
configuration_bunny_minicpm.py ADDED
@@ -0,0 +1,205 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # coding=utf-8
2
+ # Copyright 2022 EleutherAI and the HuggingFace Inc. team. All rights reserved.
3
+ #
4
+ # This code is based on EleutherAI's GPT-NeoX library and the GPT-NeoX
5
+ # and OPT implementations in this library. It has been modified from its
6
+ # original forms to accommodate minor architectural differences compared
7
+ # to GPT-NeoX and OPT used by the Meta AI team that trained the model.
8
+ #
9
+ # Licensed under the Apache License, Version 2.0 (the "License");
10
+ # you may not use this file except in compliance with the License.
11
+ # You may obtain a copy of the License at
12
+ #
13
+ # http://www.apache.org/licenses/LICENSE-2.0
14
+ #
15
+ # Unless required by applicable law or agreed to in writing, software
16
+ # distributed under the License is distributed on an "AS IS" BASIS,
17
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
+ # See the License for the specific language governing permissions and
19
+ # limitations under the License.
20
+ """ MiniCPM model configuration"""
21
+
22
+ from transformers.configuration_utils import PretrainedConfig
23
+ from transformers.utils import logging
24
+
25
+ logger = logging.get_logger(__name__)
26
+
27
+ MINICPM_PRETRAINED_CONFIG_ARCHIVE_MAP = {}
28
+
29
+
30
+ class MiniCPMConfig(PretrainedConfig):
31
+ r"""
32
+ This is the configuration class to store the configuration of a [`MiniCPMModel`]. It is used to instantiate an MiniCPM
33
+ model according to the specified arguments, defining the model architecture. Instantiating a configuration with the
34
+ defaults will yield a similar configuration to that of the MiniCPM-7B.
35
+
36
+ Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the
37
+ documentation from [`PretrainedConfig`] for more information.
38
+
39
+
40
+ Args:
41
+ vocab_size (`int`, *optional*, defaults to 32000):
42
+ Vocabulary size of the MiniCPM model. Defines the number of different tokens that can be represented by the
43
+ `inputs_ids` passed when calling [`MiniCPMModel`]
44
+ hidden_size (`int`, *optional*, defaults to 4096):
45
+ Dimension of the hidden representations.
46
+ intermediate_size (`int`, *optional*, defaults to 11008):
47
+ Dimension of the MLP representations.
48
+ num_hidden_layers (`int`, *optional*, defaults to 32):
49
+ Number of hidden layers in the Transformer decoder.
50
+ num_attention_heads (`int`, *optional*, defaults to 32):
51
+ Number of attention heads for each attention layer in the Transformer decoder.
52
+ num_key_value_heads (`int`, *optional*):
53
+ This is the number of key_value heads that should be used to implement Grouped Query Attention. If
54
+ `num_key_value_heads=num_attention_heads`, the model will use Multi Head Attention (MHA), if
55
+ `num_key_value_heads=1 the model will use Multi Query Attention (MQA) otherwise GQA is used. When
56
+ converting a multi-head checkpoint to a GQA checkpoint, each group key and value head should be constructed
57
+ by meanpooling all the original heads within that group. For more details checkout [this
58
+ paper](https://arxiv.org/pdf/2305.13245.pdf). If it is not specified, will default to
59
+ `num_attention_heads`.
60
+ hidden_act (`str` or `function`, *optional*, defaults to `"silu"`):
61
+ The non-linear activation function (function or string) in the decoder.
62
+ max_position_embeddings (`int`, *optional*, defaults to 2048):
63
+ The maximum sequence length that this model might ever be used with. MiniCPM 1 supports up to 2048 tokens,
64
+ MiniCPM 2 up to 4096, CodeMiniCPM up to 16384.
65
+ initializer_range (`float`, *optional*, defaults to 0.02):
66
+ The standard deviation of the truncated_normal_initializer for initializing all weight matrices.
67
+ rms_norm_eps (`float`, *optional*, defaults to 1e-06):
68
+ The epsilon used by the rms normalization layers.
69
+ use_cache (`bool`, *optional*, defaults to `True`):
70
+ Whether or not the model should return the last key/values attentions (not used by all models). Only
71
+ relevant if `config.is_decoder=True`.
72
+ pad_token_id (`int`, *optional*):
73
+ Padding token id.
74
+ bos_token_id (`int`, *optional*, defaults to 1):
75
+ Beginning of stream token id.
76
+ eos_token_id (`int`, *optional*, defaults to 2):
77
+ End of stream token id.
78
+ pretraining_tp (`int`, *optional*, defaults to 1):
79
+ Experimental feature. Tensor parallelism rank used during pretraining. Please refer to [this
80
+ document](https://huggingface.co/docs/transformers/parallelism) to understand more about it. This value is
81
+ necessary to ensure exact reproducibility of the pretraining results. Please refer to [this
82
+ issue](https://github.com/pytorch/pytorch/issues/76232).
83
+ tie_word_embeddings (`bool`, *optional*, defaults to `False`):
84
+ Whether to tie weight embeddings
85
+ rope_theta (`float`, *optional*, defaults to 10000.0):
86
+ The base period of the RoPE embeddings.
87
+ rope_scaling (`Dict`, *optional*):
88
+ Dictionary containing the scaling configuration for the RoPE embeddings. Currently supports two scaling
89
+ strategies: linear and dynamic. Their scaling factor must be a float greater than 1. The expected format is
90
+ `{"type": strategy name, "factor": scaling factor}`. When using this flag, don't update
91
+ `max_position_embeddings` to the expected new maximum. See the following thread for more information on how
92
+ these scaling strategies behave:
93
+ https://www.reddit.com/r/LocalMiniCPM/comments/14mrgpr/dynamically_scaled_rope_further_increases/. This is an
94
+ experimental feature, subject to breaking API changes in future versions.
95
+ attention_bias (`bool`, defaults to `False`, *optional*, defaults to `False`):
96
+ Whether to use a bias in the query, key, value and output projection layers during self-attention.
97
+ attention_dropout (`float`, *optional*, defaults to 0.0):
98
+ The dropout ratio for the attention probabilities.
99
+
100
+ ```python
101
+ >>> from transformers import MiniCPMModel, MiniCPMConfig
102
+
103
+ >>> # Initializing a MiniCPM minicpm-7b style configuration
104
+ >>> configuration = MiniCPMConfig()
105
+
106
+ >>> # Initializing a model from the minicpm-7b style configuration
107
+ >>> model = MiniCPMModel(configuration)
108
+
109
+ >>> # Accessing the model configuration
110
+ >>> configuration = model.config
111
+ ```"""
112
+
113
+ model_type = "minicpm"
114
+ keys_to_ignore_at_inference = ["past_key_values"]
115
+
116
+ def __init__(
117
+ self,
118
+ vocab_size=32000,
119
+ hidden_size=4096,
120
+ intermediate_size=11008,
121
+ num_hidden_layers=32,
122
+ num_attention_heads=32,
123
+ num_key_value_heads=None,
124
+ hidden_act="silu",
125
+ max_position_embeddings=2048,
126
+ initializer_range=0.02,
127
+ rms_norm_eps=1e-6,
128
+ use_cache=True,
129
+ pad_token_id=None,
130
+ bos_token_id=1,
131
+ eos_token_id=2,
132
+ pretraining_tp=1,
133
+ tie_word_embeddings=True,
134
+ rope_theta=10000.0,
135
+ rope_scaling=None,
136
+ attention_bias=False,
137
+ attention_dropout=0.0,
138
+ scale_emb=1,
139
+ dim_model_base=1,
140
+ scale_depth=1,
141
+ **kwargs,
142
+ ):
143
+ self.vocab_size = vocab_size
144
+ self.max_position_embeddings = max_position_embeddings
145
+ self.hidden_size = hidden_size
146
+ self.intermediate_size = intermediate_size
147
+ self.num_hidden_layers = num_hidden_layers
148
+ self.num_attention_heads = num_attention_heads
149
+
150
+ # for backward compatibility
151
+ if num_key_value_heads is None:
152
+ num_key_value_heads = num_attention_heads
153
+
154
+ self.num_key_value_heads = num_key_value_heads
155
+ self.hidden_act = hidden_act
156
+ self.initializer_range = initializer_range
157
+ self.rms_norm_eps = rms_norm_eps
158
+ self.pretraining_tp = pretraining_tp
159
+ self.use_cache = use_cache
160
+ self.rope_theta = rope_theta
161
+ self.rope_scaling = rope_scaling
162
+ self._rope_scaling_validation()
163
+ self.attention_bias = attention_bias
164
+ self.attention_dropout = attention_dropout
165
+ self.scale_emb = scale_emb
166
+ self.dim_model_base = dim_model_base
167
+ self.scale_depth = scale_depth
168
+
169
+ super().__init__(
170
+ pad_token_id=pad_token_id,
171
+ bos_token_id=bos_token_id,
172
+ eos_token_id=eos_token_id,
173
+ tie_word_embeddings=tie_word_embeddings,
174
+ **kwargs,
175
+ )
176
+ try:
177
+ import flash_attn
178
+ self._attn_implementation = "flash_attention_2"
179
+ except:
180
+ pass
181
+
182
+ def _rope_scaling_validation(self):
183
+ """
184
+ Validate the `rope_scaling` configuration.
185
+ """
186
+ if self.rope_scaling is None:
187
+ return
188
+
189
+ if not isinstance(self.rope_scaling, dict) or len(self.rope_scaling) != 2:
190
+ raise ValueError(
191
+ "`rope_scaling` must be a dictionary with with two fields, `type` and `factor`, "
192
+ f"got {self.rope_scaling}"
193
+ )
194
+ rope_scaling_type = self.rope_scaling.get("type", None)
195
+ rope_scaling_factor = self.rope_scaling.get("factor", None)
196
+ if rope_scaling_type is None or rope_scaling_type not in ["linear", "dynamic"]:
197
+ raise ValueError(
198
+ f"`rope_scaling`'s type field must be one of ['linear', 'dynamic'], got {rope_scaling_type}"
199
+ )
200
+ if rope_scaling_factor is None or not isinstance(rope_scaling_factor, float) or rope_scaling_factor <= 1.0:
201
+ raise ValueError(f"`rope_scaling`'s factor field must be a float > 1, got {rope_scaling_factor}")
202
+
203
+
204
+ class BunnyMiniCPMConfig(MiniCPMConfig):
205
+ model_type = "bunny-minicpm"
generation_config.json ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token_id": 1,
3
+ "eos_token_id": 2,
4
+ "pad_token_id": 2,
5
+ "transformers_version": "4.38.2"
6
+ }
icon.png ADDED
images/example_1.png ADDED
images/example_2.png ADDED
model-00001-of-00002.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0484a26572f4bacd5bf6a2e9c25856f202cdffc9992713c84d27872fde8c9a8f
3
+ size 4993234288
model-00002-of-00002.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a06b93bac54c2bcf8d5e65adbfc717568963b2e565b03e7b3a155645500eb0db
3
+ size 1329024392
model.safetensors.index.json ADDED
@@ -0,0 +1,821 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "metadata": {
3
+ "total_size": 6322147456
4
+ },
5
+ "weight_map": {
6
+ "model.embed_tokens.weight": "model-00001-of-00002.safetensors",
7
+ "model.layers.0.input_layernorm.weight": "model-00001-of-00002.safetensors",
8
+ "model.layers.0.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
9
+ "model.layers.0.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
10
+ "model.layers.0.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
11
+ "model.layers.0.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
12
+ "model.layers.0.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
13
+ "model.layers.0.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
14
+ "model.layers.0.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
15
+ "model.layers.0.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
16
+ "model.layers.1.input_layernorm.weight": "model-00001-of-00002.safetensors",
17
+ "model.layers.1.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
18
+ "model.layers.1.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
19
+ "model.layers.1.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
20
+ "model.layers.1.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
21
+ "model.layers.1.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
22
+ "model.layers.1.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
23
+ "model.layers.1.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
24
+ "model.layers.1.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
25
+ "model.layers.10.input_layernorm.weight": "model-00001-of-00002.safetensors",
26
+ "model.layers.10.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
27
+ "model.layers.10.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
28
+ "model.layers.10.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
29
+ "model.layers.10.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
30
+ "model.layers.10.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
31
+ "model.layers.10.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
32
+ "model.layers.10.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
33
+ "model.layers.10.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
34
+ "model.layers.11.input_layernorm.weight": "model-00001-of-00002.safetensors",
35
+ "model.layers.11.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
36
+ "model.layers.11.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
37
+ "model.layers.11.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
38
+ "model.layers.11.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
39
+ "model.layers.11.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
40
+ "model.layers.11.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
41
+ "model.layers.11.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
42
+ "model.layers.11.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
43
+ "model.layers.12.input_layernorm.weight": "model-00001-of-00002.safetensors",
44
+ "model.layers.12.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
45
+ "model.layers.12.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
46
+ "model.layers.12.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
47
+ "model.layers.12.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
48
+ "model.layers.12.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
49
+ "model.layers.12.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
50
+ "model.layers.12.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
51
+ "model.layers.12.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
52
+ "model.layers.13.input_layernorm.weight": "model-00001-of-00002.safetensors",
53
+ "model.layers.13.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
54
+ "model.layers.13.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
55
+ "model.layers.13.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
56
+ "model.layers.13.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
57
+ "model.layers.13.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
58
+ "model.layers.13.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
59
+ "model.layers.13.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
60
+ "model.layers.13.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
61
+ "model.layers.14.input_layernorm.weight": "model-00001-of-00002.safetensors",
62
+ "model.layers.14.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
63
+ "model.layers.14.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
64
+ "model.layers.14.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
65
+ "model.layers.14.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
66
+ "model.layers.14.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
67
+ "model.layers.14.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
68
+ "model.layers.14.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
69
+ "model.layers.14.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
70
+ "model.layers.15.input_layernorm.weight": "model-00001-of-00002.safetensors",
71
+ "model.layers.15.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
72
+ "model.layers.15.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
73
+ "model.layers.15.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
74
+ "model.layers.15.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
75
+ "model.layers.15.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
76
+ "model.layers.15.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
77
+ "model.layers.15.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
78
+ "model.layers.15.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
79
+ "model.layers.16.input_layernorm.weight": "model-00001-of-00002.safetensors",
80
+ "model.layers.16.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
81
+ "model.layers.16.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
82
+ "model.layers.16.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
83
+ "model.layers.16.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
84
+ "model.layers.16.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
85
+ "model.layers.16.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
86
+ "model.layers.16.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
87
+ "model.layers.16.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
88
+ "model.layers.17.input_layernorm.weight": "model-00001-of-00002.safetensors",
89
+ "model.layers.17.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
90
+ "model.layers.17.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
91
+ "model.layers.17.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
92
+ "model.layers.17.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
93
+ "model.layers.17.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
94
+ "model.layers.17.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
95
+ "model.layers.17.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
96
+ "model.layers.17.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
97
+ "model.layers.18.input_layernorm.weight": "model-00001-of-00002.safetensors",
98
+ "model.layers.18.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
99
+ "model.layers.18.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
100
+ "model.layers.18.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
101
+ "model.layers.18.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
102
+ "model.layers.18.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
103
+ "model.layers.18.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
104
+ "model.layers.18.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
105
+ "model.layers.18.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
106
+ "model.layers.19.input_layernorm.weight": "model-00001-of-00002.safetensors",
107
+ "model.layers.19.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
108
+ "model.layers.19.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
109
+ "model.layers.19.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
110
+ "model.layers.19.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
111
+ "model.layers.19.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
112
+ "model.layers.19.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
113
+ "model.layers.19.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
114
+ "model.layers.19.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
115
+ "model.layers.2.input_layernorm.weight": "model-00001-of-00002.safetensors",
116
+ "model.layers.2.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
117
+ "model.layers.2.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
118
+ "model.layers.2.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
119
+ "model.layers.2.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
120
+ "model.layers.2.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
121
+ "model.layers.2.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
122
+ "model.layers.2.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
123
+ "model.layers.2.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
124
+ "model.layers.20.input_layernorm.weight": "model-00001-of-00002.safetensors",
125
+ "model.layers.20.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
126
+ "model.layers.20.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
127
+ "model.layers.20.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
128
+ "model.layers.20.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
129
+ "model.layers.20.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
130
+ "model.layers.20.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
131
+ "model.layers.20.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
132
+ "model.layers.20.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
133
+ "model.layers.21.input_layernorm.weight": "model-00001-of-00002.safetensors",
134
+ "model.layers.21.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
135
+ "model.layers.21.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
136
+ "model.layers.21.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
137
+ "model.layers.21.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
138
+ "model.layers.21.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
139
+ "model.layers.21.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
140
+ "model.layers.21.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
141
+ "model.layers.21.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
142
+ "model.layers.22.input_layernorm.weight": "model-00001-of-00002.safetensors",
143
+ "model.layers.22.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
144
+ "model.layers.22.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
145
+ "model.layers.22.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
146
+ "model.layers.22.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
147
+ "model.layers.22.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
148
+ "model.layers.22.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
149
+ "model.layers.22.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
150
+ "model.layers.22.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
151
+ "model.layers.23.input_layernorm.weight": "model-00001-of-00002.safetensors",
152
+ "model.layers.23.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
153
+ "model.layers.23.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
154
+ "model.layers.23.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
155
+ "model.layers.23.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
156
+ "model.layers.23.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
157
+ "model.layers.23.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
158
+ "model.layers.23.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
159
+ "model.layers.23.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
160
+ "model.layers.24.input_layernorm.weight": "model-00001-of-00002.safetensors",
161
+ "model.layers.24.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
162
+ "model.layers.24.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
163
+ "model.layers.24.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
164
+ "model.layers.24.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
165
+ "model.layers.24.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
166
+ "model.layers.24.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
167
+ "model.layers.24.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
168
+ "model.layers.24.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
169
+ "model.layers.25.input_layernorm.weight": "model-00001-of-00002.safetensors",
170
+ "model.layers.25.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
171
+ "model.layers.25.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
172
+ "model.layers.25.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
173
+ "model.layers.25.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
174
+ "model.layers.25.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
175
+ "model.layers.25.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
176
+ "model.layers.25.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
177
+ "model.layers.25.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
178
+ "model.layers.26.input_layernorm.weight": "model-00001-of-00002.safetensors",
179
+ "model.layers.26.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
180
+ "model.layers.26.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
181
+ "model.layers.26.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
182
+ "model.layers.26.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
183
+ "model.layers.26.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
184
+ "model.layers.26.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
185
+ "model.layers.26.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
186
+ "model.layers.26.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
187
+ "model.layers.27.input_layernorm.weight": "model-00001-of-00002.safetensors",
188
+ "model.layers.27.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
189
+ "model.layers.27.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
190
+ "model.layers.27.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
191
+ "model.layers.27.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
192
+ "model.layers.27.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
193
+ "model.layers.27.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
194
+ "model.layers.27.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
195
+ "model.layers.27.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
196
+ "model.layers.28.input_layernorm.weight": "model-00001-of-00002.safetensors",
197
+ "model.layers.28.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
198
+ "model.layers.28.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
199
+ "model.layers.28.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
200
+ "model.layers.28.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
201
+ "model.layers.28.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
202
+ "model.layers.28.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
203
+ "model.layers.28.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
204
+ "model.layers.28.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
205
+ "model.layers.29.input_layernorm.weight": "model-00001-of-00002.safetensors",
206
+ "model.layers.29.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
207
+ "model.layers.29.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
208
+ "model.layers.29.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
209
+ "model.layers.29.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
210
+ "model.layers.29.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
211
+ "model.layers.29.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
212
+ "model.layers.29.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
213
+ "model.layers.29.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
214
+ "model.layers.3.input_layernorm.weight": "model-00001-of-00002.safetensors",
215
+ "model.layers.3.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
216
+ "model.layers.3.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
217
+ "model.layers.3.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
218
+ "model.layers.3.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
219
+ "model.layers.3.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
220
+ "model.layers.3.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
221
+ "model.layers.3.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
222
+ "model.layers.3.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
223
+ "model.layers.30.input_layernorm.weight": "model-00001-of-00002.safetensors",
224
+ "model.layers.30.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
225
+ "model.layers.30.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
226
+ "model.layers.30.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
227
+ "model.layers.30.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
228
+ "model.layers.30.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
229
+ "model.layers.30.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
230
+ "model.layers.30.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
231
+ "model.layers.30.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
232
+ "model.layers.31.input_layernorm.weight": "model-00001-of-00002.safetensors",
233
+ "model.layers.31.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
234
+ "model.layers.31.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
235
+ "model.layers.31.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
236
+ "model.layers.31.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
237
+ "model.layers.31.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
238
+ "model.layers.31.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
239
+ "model.layers.31.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
240
+ "model.layers.31.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
241
+ "model.layers.32.input_layernorm.weight": "model-00001-of-00002.safetensors",
242
+ "model.layers.32.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
243
+ "model.layers.32.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
244
+ "model.layers.32.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
245
+ "model.layers.32.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
246
+ "model.layers.32.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
247
+ "model.layers.32.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
248
+ "model.layers.32.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
249
+ "model.layers.32.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
250
+ "model.layers.33.input_layernorm.weight": "model-00001-of-00002.safetensors",
251
+ "model.layers.33.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
252
+ "model.layers.33.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
253
+ "model.layers.33.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
254
+ "model.layers.33.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
255
+ "model.layers.33.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
256
+ "model.layers.33.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
257
+ "model.layers.33.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
258
+ "model.layers.33.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
259
+ "model.layers.34.input_layernorm.weight": "model-00001-of-00002.safetensors",
260
+ "model.layers.34.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
261
+ "model.layers.34.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
262
+ "model.layers.34.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
263
+ "model.layers.34.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
264
+ "model.layers.34.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
265
+ "model.layers.34.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
266
+ "model.layers.34.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
267
+ "model.layers.34.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
268
+ "model.layers.35.input_layernorm.weight": "model-00001-of-00002.safetensors",
269
+ "model.layers.35.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
270
+ "model.layers.35.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
271
+ "model.layers.35.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
272
+ "model.layers.35.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
273
+ "model.layers.35.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
274
+ "model.layers.35.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
275
+ "model.layers.35.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
276
+ "model.layers.35.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
277
+ "model.layers.36.input_layernorm.weight": "model-00002-of-00002.safetensors",
278
+ "model.layers.36.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
279
+ "model.layers.36.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
280
+ "model.layers.36.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
281
+ "model.layers.36.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
282
+ "model.layers.36.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
283
+ "model.layers.36.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
284
+ "model.layers.36.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
285
+ "model.layers.36.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
286
+ "model.layers.37.input_layernorm.weight": "model-00002-of-00002.safetensors",
287
+ "model.layers.37.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
288
+ "model.layers.37.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
289
+ "model.layers.37.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
290
+ "model.layers.37.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
291
+ "model.layers.37.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
292
+ "model.layers.37.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
293
+ "model.layers.37.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
294
+ "model.layers.37.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
295
+ "model.layers.38.input_layernorm.weight": "model-00002-of-00002.safetensors",
296
+ "model.layers.38.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
297
+ "model.layers.38.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
298
+ "model.layers.38.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
299
+ "model.layers.38.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
300
+ "model.layers.38.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
301
+ "model.layers.38.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
302
+ "model.layers.38.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
303
+ "model.layers.38.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
304
+ "model.layers.39.input_layernorm.weight": "model-00002-of-00002.safetensors",
305
+ "model.layers.39.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
306
+ "model.layers.39.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
307
+ "model.layers.39.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
308
+ "model.layers.39.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
309
+ "model.layers.39.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
310
+ "model.layers.39.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
311
+ "model.layers.39.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
312
+ "model.layers.39.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
313
+ "model.layers.4.input_layernorm.weight": "model-00001-of-00002.safetensors",
314
+ "model.layers.4.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
315
+ "model.layers.4.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
316
+ "model.layers.4.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
317
+ "model.layers.4.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
318
+ "model.layers.4.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
319
+ "model.layers.4.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
320
+ "model.layers.4.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
321
+ "model.layers.4.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
322
+ "model.layers.5.input_layernorm.weight": "model-00001-of-00002.safetensors",
323
+ "model.layers.5.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
324
+ "model.layers.5.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
325
+ "model.layers.5.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
326
+ "model.layers.5.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
327
+ "model.layers.5.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
328
+ "model.layers.5.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
329
+ "model.layers.5.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
330
+ "model.layers.5.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
331
+ "model.layers.6.input_layernorm.weight": "model-00001-of-00002.safetensors",
332
+ "model.layers.6.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
333
+ "model.layers.6.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
334
+ "model.layers.6.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
335
+ "model.layers.6.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
336
+ "model.layers.6.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
337
+ "model.layers.6.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
338
+ "model.layers.6.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
339
+ "model.layers.6.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
340
+ "model.layers.7.input_layernorm.weight": "model-00001-of-00002.safetensors",
341
+ "model.layers.7.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
342
+ "model.layers.7.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
343
+ "model.layers.7.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
344
+ "model.layers.7.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
345
+ "model.layers.7.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
346
+ "model.layers.7.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
347
+ "model.layers.7.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
348
+ "model.layers.7.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
349
+ "model.layers.8.input_layernorm.weight": "model-00001-of-00002.safetensors",
350
+ "model.layers.8.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
351
+ "model.layers.8.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
352
+ "model.layers.8.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
353
+ "model.layers.8.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
354
+ "model.layers.8.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
355
+ "model.layers.8.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
356
+ "model.layers.8.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
357
+ "model.layers.8.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
358
+ "model.layers.9.input_layernorm.weight": "model-00001-of-00002.safetensors",
359
+ "model.layers.9.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
360
+ "model.layers.9.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
361
+ "model.layers.9.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
362
+ "model.layers.9.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
363
+ "model.layers.9.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
364
+ "model.layers.9.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
365
+ "model.layers.9.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
366
+ "model.layers.9.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
367
+ "model.mm_projector.0.bias": "model-00002-of-00002.safetensors",
368
+ "model.mm_projector.0.weight": "model-00002-of-00002.safetensors",
369
+ "model.mm_projector.2.bias": "model-00002-of-00002.safetensors",
370
+ "model.mm_projector.2.weight": "model-00002-of-00002.safetensors",
371
+ "model.norm.weight": "model-00002-of-00002.safetensors",
372
+ "model.vision_tower.vision_tower.vision_model.embeddings.patch_embedding.bias": "model-00002-of-00002.safetensors",
373
+ "model.vision_tower.vision_tower.vision_model.embeddings.patch_embedding.weight": "model-00002-of-00002.safetensors",
374
+ "model.vision_tower.vision_tower.vision_model.embeddings.position_embedding.weight": "model-00002-of-00002.safetensors",
375
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.0.layer_norm1.bias": "model-00002-of-00002.safetensors",
376
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.0.layer_norm1.weight": "model-00002-of-00002.safetensors",
377
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.0.layer_norm2.bias": "model-00002-of-00002.safetensors",
378
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.0.layer_norm2.weight": "model-00002-of-00002.safetensors",
379
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.0.mlp.fc1.bias": "model-00002-of-00002.safetensors",
380
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.0.mlp.fc1.weight": "model-00002-of-00002.safetensors",
381
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.0.mlp.fc2.bias": "model-00002-of-00002.safetensors",
382
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.0.mlp.fc2.weight": "model-00002-of-00002.safetensors",
383
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.0.self_attn.k_proj.bias": "model-00002-of-00002.safetensors",
384
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.0.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
385
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.0.self_attn.out_proj.bias": "model-00002-of-00002.safetensors",
386
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.0.self_attn.out_proj.weight": "model-00002-of-00002.safetensors",
387
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.0.self_attn.q_proj.bias": "model-00002-of-00002.safetensors",
388
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.0.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
389
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.0.self_attn.v_proj.bias": "model-00002-of-00002.safetensors",
390
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.0.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
391
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.1.layer_norm1.bias": "model-00002-of-00002.safetensors",
392
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.1.layer_norm1.weight": "model-00002-of-00002.safetensors",
393
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.1.layer_norm2.bias": "model-00002-of-00002.safetensors",
394
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.1.layer_norm2.weight": "model-00002-of-00002.safetensors",
395
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.1.mlp.fc1.bias": "model-00002-of-00002.safetensors",
396
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.1.mlp.fc1.weight": "model-00002-of-00002.safetensors",
397
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.1.mlp.fc2.bias": "model-00002-of-00002.safetensors",
398
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.1.mlp.fc2.weight": "model-00002-of-00002.safetensors",
399
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.1.self_attn.k_proj.bias": "model-00002-of-00002.safetensors",
400
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.1.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
401
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.1.self_attn.out_proj.bias": "model-00002-of-00002.safetensors",
402
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.1.self_attn.out_proj.weight": "model-00002-of-00002.safetensors",
403
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.1.self_attn.q_proj.bias": "model-00002-of-00002.safetensors",
404
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.1.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
405
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.1.self_attn.v_proj.bias": "model-00002-of-00002.safetensors",
406
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.1.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
407
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.10.layer_norm1.bias": "model-00002-of-00002.safetensors",
408
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.10.layer_norm1.weight": "model-00002-of-00002.safetensors",
409
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.10.layer_norm2.bias": "model-00002-of-00002.safetensors",
410
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.10.layer_norm2.weight": "model-00002-of-00002.safetensors",
411
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.10.mlp.fc1.bias": "model-00002-of-00002.safetensors",
412
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.10.mlp.fc1.weight": "model-00002-of-00002.safetensors",
413
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.10.mlp.fc2.bias": "model-00002-of-00002.safetensors",
414
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.10.mlp.fc2.weight": "model-00002-of-00002.safetensors",
415
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.10.self_attn.k_proj.bias": "model-00002-of-00002.safetensors",
416
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.10.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
417
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.10.self_attn.out_proj.bias": "model-00002-of-00002.safetensors",
418
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.10.self_attn.out_proj.weight": "model-00002-of-00002.safetensors",
419
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.10.self_attn.q_proj.bias": "model-00002-of-00002.safetensors",
420
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.10.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
421
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.10.self_attn.v_proj.bias": "model-00002-of-00002.safetensors",
422
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.10.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
423
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.11.layer_norm1.bias": "model-00002-of-00002.safetensors",
424
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.11.layer_norm1.weight": "model-00002-of-00002.safetensors",
425
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.11.layer_norm2.bias": "model-00002-of-00002.safetensors",
426
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.11.layer_norm2.weight": "model-00002-of-00002.safetensors",
427
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.11.mlp.fc1.bias": "model-00002-of-00002.safetensors",
428
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.11.mlp.fc1.weight": "model-00002-of-00002.safetensors",
429
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.11.mlp.fc2.bias": "model-00002-of-00002.safetensors",
430
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.11.mlp.fc2.weight": "model-00002-of-00002.safetensors",
431
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.11.self_attn.k_proj.bias": "model-00002-of-00002.safetensors",
432
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.11.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
433
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.11.self_attn.out_proj.bias": "model-00002-of-00002.safetensors",
434
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.11.self_attn.out_proj.weight": "model-00002-of-00002.safetensors",
435
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.11.self_attn.q_proj.bias": "model-00002-of-00002.safetensors",
436
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.11.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
437
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.11.self_attn.v_proj.bias": "model-00002-of-00002.safetensors",
438
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.11.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
439
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.12.layer_norm1.bias": "model-00002-of-00002.safetensors",
440
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.12.layer_norm1.weight": "model-00002-of-00002.safetensors",
441
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.12.layer_norm2.bias": "model-00002-of-00002.safetensors",
442
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.12.layer_norm2.weight": "model-00002-of-00002.safetensors",
443
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.12.mlp.fc1.bias": "model-00002-of-00002.safetensors",
444
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.12.mlp.fc1.weight": "model-00002-of-00002.safetensors",
445
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.12.mlp.fc2.bias": "model-00002-of-00002.safetensors",
446
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.12.mlp.fc2.weight": "model-00002-of-00002.safetensors",
447
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.12.self_attn.k_proj.bias": "model-00002-of-00002.safetensors",
448
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.12.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
449
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.12.self_attn.out_proj.bias": "model-00002-of-00002.safetensors",
450
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.12.self_attn.out_proj.weight": "model-00002-of-00002.safetensors",
451
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.12.self_attn.q_proj.bias": "model-00002-of-00002.safetensors",
452
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.12.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
453
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.12.self_attn.v_proj.bias": "model-00002-of-00002.safetensors",
454
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.12.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
455
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.13.layer_norm1.bias": "model-00002-of-00002.safetensors",
456
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.13.layer_norm1.weight": "model-00002-of-00002.safetensors",
457
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.13.layer_norm2.bias": "model-00002-of-00002.safetensors",
458
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.13.layer_norm2.weight": "model-00002-of-00002.safetensors",
459
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.13.mlp.fc1.bias": "model-00002-of-00002.safetensors",
460
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.13.mlp.fc1.weight": "model-00002-of-00002.safetensors",
461
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.13.mlp.fc2.bias": "model-00002-of-00002.safetensors",
462
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.13.mlp.fc2.weight": "model-00002-of-00002.safetensors",
463
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.13.self_attn.k_proj.bias": "model-00002-of-00002.safetensors",
464
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.13.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
465
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.13.self_attn.out_proj.bias": "model-00002-of-00002.safetensors",
466
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.13.self_attn.out_proj.weight": "model-00002-of-00002.safetensors",
467
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.13.self_attn.q_proj.bias": "model-00002-of-00002.safetensors",
468
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.13.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
469
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.13.self_attn.v_proj.bias": "model-00002-of-00002.safetensors",
470
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.13.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
471
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.14.layer_norm1.bias": "model-00002-of-00002.safetensors",
472
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.14.layer_norm1.weight": "model-00002-of-00002.safetensors",
473
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.14.layer_norm2.bias": "model-00002-of-00002.safetensors",
474
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.14.layer_norm2.weight": "model-00002-of-00002.safetensors",
475
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.14.mlp.fc1.bias": "model-00002-of-00002.safetensors",
476
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.14.mlp.fc1.weight": "model-00002-of-00002.safetensors",
477
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.14.mlp.fc2.bias": "model-00002-of-00002.safetensors",
478
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.14.mlp.fc2.weight": "model-00002-of-00002.safetensors",
479
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.14.self_attn.k_proj.bias": "model-00002-of-00002.safetensors",
480
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.14.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
481
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.14.self_attn.out_proj.bias": "model-00002-of-00002.safetensors",
482
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.14.self_attn.out_proj.weight": "model-00002-of-00002.safetensors",
483
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.14.self_attn.q_proj.bias": "model-00002-of-00002.safetensors",
484
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.14.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
485
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.14.self_attn.v_proj.bias": "model-00002-of-00002.safetensors",
486
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.14.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
487
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.15.layer_norm1.bias": "model-00002-of-00002.safetensors",
488
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.15.layer_norm1.weight": "model-00002-of-00002.safetensors",
489
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.15.layer_norm2.bias": "model-00002-of-00002.safetensors",
490
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.15.layer_norm2.weight": "model-00002-of-00002.safetensors",
491
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.15.mlp.fc1.bias": "model-00002-of-00002.safetensors",
492
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.15.mlp.fc1.weight": "model-00002-of-00002.safetensors",
493
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.15.mlp.fc2.bias": "model-00002-of-00002.safetensors",
494
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.15.mlp.fc2.weight": "model-00002-of-00002.safetensors",
495
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.15.self_attn.k_proj.bias": "model-00002-of-00002.safetensors",
496
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.15.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
497
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.15.self_attn.out_proj.bias": "model-00002-of-00002.safetensors",
498
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.15.self_attn.out_proj.weight": "model-00002-of-00002.safetensors",
499
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.15.self_attn.q_proj.bias": "model-00002-of-00002.safetensors",
500
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.15.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
501
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.15.self_attn.v_proj.bias": "model-00002-of-00002.safetensors",
502
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.15.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
503
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.16.layer_norm1.bias": "model-00002-of-00002.safetensors",
504
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.16.layer_norm1.weight": "model-00002-of-00002.safetensors",
505
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.16.layer_norm2.bias": "model-00002-of-00002.safetensors",
506
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.16.layer_norm2.weight": "model-00002-of-00002.safetensors",
507
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.16.mlp.fc1.bias": "model-00002-of-00002.safetensors",
508
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.16.mlp.fc1.weight": "model-00002-of-00002.safetensors",
509
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.16.mlp.fc2.bias": "model-00002-of-00002.safetensors",
510
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.16.mlp.fc2.weight": "model-00002-of-00002.safetensors",
511
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.16.self_attn.k_proj.bias": "model-00002-of-00002.safetensors",
512
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.16.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
513
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.16.self_attn.out_proj.bias": "model-00002-of-00002.safetensors",
514
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.16.self_attn.out_proj.weight": "model-00002-of-00002.safetensors",
515
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.16.self_attn.q_proj.bias": "model-00002-of-00002.safetensors",
516
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.16.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
517
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.16.self_attn.v_proj.bias": "model-00002-of-00002.safetensors",
518
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.16.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
519
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.17.layer_norm1.bias": "model-00002-of-00002.safetensors",
520
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.17.layer_norm1.weight": "model-00002-of-00002.safetensors",
521
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.17.layer_norm2.bias": "model-00002-of-00002.safetensors",
522
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.17.layer_norm2.weight": "model-00002-of-00002.safetensors",
523
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.17.mlp.fc1.bias": "model-00002-of-00002.safetensors",
524
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.17.mlp.fc1.weight": "model-00002-of-00002.safetensors",
525
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.17.mlp.fc2.bias": "model-00002-of-00002.safetensors",
526
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.17.mlp.fc2.weight": "model-00002-of-00002.safetensors",
527
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.17.self_attn.k_proj.bias": "model-00002-of-00002.safetensors",
528
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.17.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
529
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.17.self_attn.out_proj.bias": "model-00002-of-00002.safetensors",
530
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.17.self_attn.out_proj.weight": "model-00002-of-00002.safetensors",
531
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.17.self_attn.q_proj.bias": "model-00002-of-00002.safetensors",
532
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.17.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
533
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.17.self_attn.v_proj.bias": "model-00002-of-00002.safetensors",
534
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.17.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
535
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.18.layer_norm1.bias": "model-00002-of-00002.safetensors",
536
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.18.layer_norm1.weight": "model-00002-of-00002.safetensors",
537
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.18.layer_norm2.bias": "model-00002-of-00002.safetensors",
538
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.18.layer_norm2.weight": "model-00002-of-00002.safetensors",
539
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.18.mlp.fc1.bias": "model-00002-of-00002.safetensors",
540
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.18.mlp.fc1.weight": "model-00002-of-00002.safetensors",
541
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.18.mlp.fc2.bias": "model-00002-of-00002.safetensors",
542
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.18.mlp.fc2.weight": "model-00002-of-00002.safetensors",
543
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.18.self_attn.k_proj.bias": "model-00002-of-00002.safetensors",
544
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.18.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
545
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.18.self_attn.out_proj.bias": "model-00002-of-00002.safetensors",
546
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.18.self_attn.out_proj.weight": "model-00002-of-00002.safetensors",
547
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.18.self_attn.q_proj.bias": "model-00002-of-00002.safetensors",
548
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.18.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
549
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.18.self_attn.v_proj.bias": "model-00002-of-00002.safetensors",
550
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.18.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
551
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.19.layer_norm1.bias": "model-00002-of-00002.safetensors",
552
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.19.layer_norm1.weight": "model-00002-of-00002.safetensors",
553
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.19.layer_norm2.bias": "model-00002-of-00002.safetensors",
554
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.19.layer_norm2.weight": "model-00002-of-00002.safetensors",
555
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.19.mlp.fc1.bias": "model-00002-of-00002.safetensors",
556
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.19.mlp.fc1.weight": "model-00002-of-00002.safetensors",
557
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.19.mlp.fc2.bias": "model-00002-of-00002.safetensors",
558
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.19.mlp.fc2.weight": "model-00002-of-00002.safetensors",
559
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.19.self_attn.k_proj.bias": "model-00002-of-00002.safetensors",
560
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.19.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
561
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.19.self_attn.out_proj.bias": "model-00002-of-00002.safetensors",
562
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.19.self_attn.out_proj.weight": "model-00002-of-00002.safetensors",
563
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.19.self_attn.q_proj.bias": "model-00002-of-00002.safetensors",
564
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.19.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
565
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.19.self_attn.v_proj.bias": "model-00002-of-00002.safetensors",
566
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.19.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
567
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.2.layer_norm1.bias": "model-00002-of-00002.safetensors",
568
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.2.layer_norm1.weight": "model-00002-of-00002.safetensors",
569
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.2.layer_norm2.bias": "model-00002-of-00002.safetensors",
570
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.2.layer_norm2.weight": "model-00002-of-00002.safetensors",
571
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.2.mlp.fc1.bias": "model-00002-of-00002.safetensors",
572
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.2.mlp.fc1.weight": "model-00002-of-00002.safetensors",
573
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.2.mlp.fc2.bias": "model-00002-of-00002.safetensors",
574
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.2.mlp.fc2.weight": "model-00002-of-00002.safetensors",
575
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.2.self_attn.k_proj.bias": "model-00002-of-00002.safetensors",
576
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.2.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
577
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.2.self_attn.out_proj.bias": "model-00002-of-00002.safetensors",
578
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.2.self_attn.out_proj.weight": "model-00002-of-00002.safetensors",
579
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.2.self_attn.q_proj.bias": "model-00002-of-00002.safetensors",
580
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.2.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
581
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.2.self_attn.v_proj.bias": "model-00002-of-00002.safetensors",
582
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.2.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
583
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.20.layer_norm1.bias": "model-00002-of-00002.safetensors",
584
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.20.layer_norm1.weight": "model-00002-of-00002.safetensors",
585
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.20.layer_norm2.bias": "model-00002-of-00002.safetensors",
586
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.20.layer_norm2.weight": "model-00002-of-00002.safetensors",
587
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.20.mlp.fc1.bias": "model-00002-of-00002.safetensors",
588
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.20.mlp.fc1.weight": "model-00002-of-00002.safetensors",
589
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.20.mlp.fc2.bias": "model-00002-of-00002.safetensors",
590
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.20.mlp.fc2.weight": "model-00002-of-00002.safetensors",
591
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.20.self_attn.k_proj.bias": "model-00002-of-00002.safetensors",
592
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.20.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
593
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.20.self_attn.out_proj.bias": "model-00002-of-00002.safetensors",
594
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.20.self_attn.out_proj.weight": "model-00002-of-00002.safetensors",
595
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.20.self_attn.q_proj.bias": "model-00002-of-00002.safetensors",
596
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.20.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
597
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.20.self_attn.v_proj.bias": "model-00002-of-00002.safetensors",
598
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.20.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
599
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.21.layer_norm1.bias": "model-00002-of-00002.safetensors",
600
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.21.layer_norm1.weight": "model-00002-of-00002.safetensors",
601
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.21.layer_norm2.bias": "model-00002-of-00002.safetensors",
602
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.21.layer_norm2.weight": "model-00002-of-00002.safetensors",
603
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.21.mlp.fc1.bias": "model-00002-of-00002.safetensors",
604
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.21.mlp.fc1.weight": "model-00002-of-00002.safetensors",
605
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.21.mlp.fc2.bias": "model-00002-of-00002.safetensors",
606
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.21.mlp.fc2.weight": "model-00002-of-00002.safetensors",
607
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.21.self_attn.k_proj.bias": "model-00002-of-00002.safetensors",
608
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.21.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
609
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.21.self_attn.out_proj.bias": "model-00002-of-00002.safetensors",
610
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.21.self_attn.out_proj.weight": "model-00002-of-00002.safetensors",
611
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.21.self_attn.q_proj.bias": "model-00002-of-00002.safetensors",
612
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.21.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
613
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.21.self_attn.v_proj.bias": "model-00002-of-00002.safetensors",
614
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.21.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
615
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.22.layer_norm1.bias": "model-00002-of-00002.safetensors",
616
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.22.layer_norm1.weight": "model-00002-of-00002.safetensors",
617
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.22.layer_norm2.bias": "model-00002-of-00002.safetensors",
618
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.22.layer_norm2.weight": "model-00002-of-00002.safetensors",
619
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.22.mlp.fc1.bias": "model-00002-of-00002.safetensors",
620
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.22.mlp.fc1.weight": "model-00002-of-00002.safetensors",
621
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.22.mlp.fc2.bias": "model-00002-of-00002.safetensors",
622
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.22.mlp.fc2.weight": "model-00002-of-00002.safetensors",
623
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.22.self_attn.k_proj.bias": "model-00002-of-00002.safetensors",
624
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.22.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
625
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.22.self_attn.out_proj.bias": "model-00002-of-00002.safetensors",
626
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.22.self_attn.out_proj.weight": "model-00002-of-00002.safetensors",
627
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.22.self_attn.q_proj.bias": "model-00002-of-00002.safetensors",
628
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.22.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
629
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.22.self_attn.v_proj.bias": "model-00002-of-00002.safetensors",
630
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.22.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
631
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.23.layer_norm1.bias": "model-00002-of-00002.safetensors",
632
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.23.layer_norm1.weight": "model-00002-of-00002.safetensors",
633
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.23.layer_norm2.bias": "model-00002-of-00002.safetensors",
634
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.23.layer_norm2.weight": "model-00002-of-00002.safetensors",
635
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.23.mlp.fc1.bias": "model-00002-of-00002.safetensors",
636
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.23.mlp.fc1.weight": "model-00002-of-00002.safetensors",
637
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.23.mlp.fc2.bias": "model-00002-of-00002.safetensors",
638
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.23.mlp.fc2.weight": "model-00002-of-00002.safetensors",
639
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.23.self_attn.k_proj.bias": "model-00002-of-00002.safetensors",
640
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.23.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
641
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.23.self_attn.out_proj.bias": "model-00002-of-00002.safetensors",
642
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.23.self_attn.out_proj.weight": "model-00002-of-00002.safetensors",
643
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.23.self_attn.q_proj.bias": "model-00002-of-00002.safetensors",
644
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.23.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
645
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.23.self_attn.v_proj.bias": "model-00002-of-00002.safetensors",
646
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.23.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
647
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.24.layer_norm1.bias": "model-00002-of-00002.safetensors",
648
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.24.layer_norm1.weight": "model-00002-of-00002.safetensors",
649
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.24.layer_norm2.bias": "model-00002-of-00002.safetensors",
650
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.24.layer_norm2.weight": "model-00002-of-00002.safetensors",
651
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.24.mlp.fc1.bias": "model-00002-of-00002.safetensors",
652
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.24.mlp.fc1.weight": "model-00002-of-00002.safetensors",
653
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.24.mlp.fc2.bias": "model-00002-of-00002.safetensors",
654
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.24.mlp.fc2.weight": "model-00002-of-00002.safetensors",
655
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.24.self_attn.k_proj.bias": "model-00002-of-00002.safetensors",
656
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.24.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
657
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.24.self_attn.out_proj.bias": "model-00002-of-00002.safetensors",
658
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.24.self_attn.out_proj.weight": "model-00002-of-00002.safetensors",
659
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.24.self_attn.q_proj.bias": "model-00002-of-00002.safetensors",
660
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.24.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
661
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.24.self_attn.v_proj.bias": "model-00002-of-00002.safetensors",
662
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.24.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
663
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.25.layer_norm1.bias": "model-00002-of-00002.safetensors",
664
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.25.layer_norm1.weight": "model-00002-of-00002.safetensors",
665
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.25.layer_norm2.bias": "model-00002-of-00002.safetensors",
666
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.25.layer_norm2.weight": "model-00002-of-00002.safetensors",
667
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.25.mlp.fc1.bias": "model-00002-of-00002.safetensors",
668
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.25.mlp.fc1.weight": "model-00002-of-00002.safetensors",
669
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.25.mlp.fc2.bias": "model-00002-of-00002.safetensors",
670
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.25.mlp.fc2.weight": "model-00002-of-00002.safetensors",
671
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.25.self_attn.k_proj.bias": "model-00002-of-00002.safetensors",
672
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.25.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
673
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.25.self_attn.out_proj.bias": "model-00002-of-00002.safetensors",
674
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.25.self_attn.out_proj.weight": "model-00002-of-00002.safetensors",
675
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.25.self_attn.q_proj.bias": "model-00002-of-00002.safetensors",
676
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.25.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
677
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.25.self_attn.v_proj.bias": "model-00002-of-00002.safetensors",
678
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.25.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
679
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.26.layer_norm1.bias": "model-00002-of-00002.safetensors",
680
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.26.layer_norm1.weight": "model-00002-of-00002.safetensors",
681
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.26.layer_norm2.bias": "model-00002-of-00002.safetensors",
682
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.26.layer_norm2.weight": "model-00002-of-00002.safetensors",
683
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.26.mlp.fc1.bias": "model-00002-of-00002.safetensors",
684
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.26.mlp.fc1.weight": "model-00002-of-00002.safetensors",
685
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.26.mlp.fc2.bias": "model-00002-of-00002.safetensors",
686
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.26.mlp.fc2.weight": "model-00002-of-00002.safetensors",
687
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.26.self_attn.k_proj.bias": "model-00002-of-00002.safetensors",
688
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.26.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
689
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.26.self_attn.out_proj.bias": "model-00002-of-00002.safetensors",
690
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.26.self_attn.out_proj.weight": "model-00002-of-00002.safetensors",
691
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.26.self_attn.q_proj.bias": "model-00002-of-00002.safetensors",
692
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.26.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
693
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.26.self_attn.v_proj.bias": "model-00002-of-00002.safetensors",
694
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.26.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
695
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.3.layer_norm1.bias": "model-00002-of-00002.safetensors",
696
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.3.layer_norm1.weight": "model-00002-of-00002.safetensors",
697
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.3.layer_norm2.bias": "model-00002-of-00002.safetensors",
698
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.3.layer_norm2.weight": "model-00002-of-00002.safetensors",
699
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.3.mlp.fc1.bias": "model-00002-of-00002.safetensors",
700
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.3.mlp.fc1.weight": "model-00002-of-00002.safetensors",
701
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.3.mlp.fc2.bias": "model-00002-of-00002.safetensors",
702
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.3.mlp.fc2.weight": "model-00002-of-00002.safetensors",
703
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.3.self_attn.k_proj.bias": "model-00002-of-00002.safetensors",
704
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.3.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
705
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.3.self_attn.out_proj.bias": "model-00002-of-00002.safetensors",
706
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.3.self_attn.out_proj.weight": "model-00002-of-00002.safetensors",
707
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.3.self_attn.q_proj.bias": "model-00002-of-00002.safetensors",
708
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.3.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
709
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.3.self_attn.v_proj.bias": "model-00002-of-00002.safetensors",
710
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.3.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
711
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.4.layer_norm1.bias": "model-00002-of-00002.safetensors",
712
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.4.layer_norm1.weight": "model-00002-of-00002.safetensors",
713
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.4.layer_norm2.bias": "model-00002-of-00002.safetensors",
714
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.4.layer_norm2.weight": "model-00002-of-00002.safetensors",
715
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.4.mlp.fc1.bias": "model-00002-of-00002.safetensors",
716
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.4.mlp.fc1.weight": "model-00002-of-00002.safetensors",
717
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.4.mlp.fc2.bias": "model-00002-of-00002.safetensors",
718
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.4.mlp.fc2.weight": "model-00002-of-00002.safetensors",
719
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.4.self_attn.k_proj.bias": "model-00002-of-00002.safetensors",
720
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.4.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
721
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.4.self_attn.out_proj.bias": "model-00002-of-00002.safetensors",
722
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.4.self_attn.out_proj.weight": "model-00002-of-00002.safetensors",
723
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.4.self_attn.q_proj.bias": "model-00002-of-00002.safetensors",
724
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.4.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
725
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.4.self_attn.v_proj.bias": "model-00002-of-00002.safetensors",
726
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.4.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
727
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.5.layer_norm1.bias": "model-00002-of-00002.safetensors",
728
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.5.layer_norm1.weight": "model-00002-of-00002.safetensors",
729
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.5.layer_norm2.bias": "model-00002-of-00002.safetensors",
730
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.5.layer_norm2.weight": "model-00002-of-00002.safetensors",
731
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.5.mlp.fc1.bias": "model-00002-of-00002.safetensors",
732
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.5.mlp.fc1.weight": "model-00002-of-00002.safetensors",
733
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.5.mlp.fc2.bias": "model-00002-of-00002.safetensors",
734
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.5.mlp.fc2.weight": "model-00002-of-00002.safetensors",
735
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.5.self_attn.k_proj.bias": "model-00002-of-00002.safetensors",
736
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.5.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
737
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.5.self_attn.out_proj.bias": "model-00002-of-00002.safetensors",
738
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.5.self_attn.out_proj.weight": "model-00002-of-00002.safetensors",
739
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.5.self_attn.q_proj.bias": "model-00002-of-00002.safetensors",
740
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.5.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
741
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.5.self_attn.v_proj.bias": "model-00002-of-00002.safetensors",
742
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.5.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
743
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.6.layer_norm1.bias": "model-00002-of-00002.safetensors",
744
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.6.layer_norm1.weight": "model-00002-of-00002.safetensors",
745
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.6.layer_norm2.bias": "model-00002-of-00002.safetensors",
746
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.6.layer_norm2.weight": "model-00002-of-00002.safetensors",
747
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.6.mlp.fc1.bias": "model-00002-of-00002.safetensors",
748
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.6.mlp.fc1.weight": "model-00002-of-00002.safetensors",
749
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.6.mlp.fc2.bias": "model-00002-of-00002.safetensors",
750
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.6.mlp.fc2.weight": "model-00002-of-00002.safetensors",
751
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.6.self_attn.k_proj.bias": "model-00002-of-00002.safetensors",
752
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.6.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
753
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.6.self_attn.out_proj.bias": "model-00002-of-00002.safetensors",
754
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.6.self_attn.out_proj.weight": "model-00002-of-00002.safetensors",
755
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.6.self_attn.q_proj.bias": "model-00002-of-00002.safetensors",
756
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.6.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
757
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.6.self_attn.v_proj.bias": "model-00002-of-00002.safetensors",
758
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.6.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
759
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.7.layer_norm1.bias": "model-00002-of-00002.safetensors",
760
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.7.layer_norm1.weight": "model-00002-of-00002.safetensors",
761
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.7.layer_norm2.bias": "model-00002-of-00002.safetensors",
762
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.7.layer_norm2.weight": "model-00002-of-00002.safetensors",
763
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.7.mlp.fc1.bias": "model-00002-of-00002.safetensors",
764
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.7.mlp.fc1.weight": "model-00002-of-00002.safetensors",
765
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.7.mlp.fc2.bias": "model-00002-of-00002.safetensors",
766
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.7.mlp.fc2.weight": "model-00002-of-00002.safetensors",
767
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.7.self_attn.k_proj.bias": "model-00002-of-00002.safetensors",
768
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.7.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
769
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.7.self_attn.out_proj.bias": "model-00002-of-00002.safetensors",
770
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.7.self_attn.out_proj.weight": "model-00002-of-00002.safetensors",
771
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.7.self_attn.q_proj.bias": "model-00002-of-00002.safetensors",
772
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.7.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
773
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.7.self_attn.v_proj.bias": "model-00002-of-00002.safetensors",
774
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.7.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
775
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.8.layer_norm1.bias": "model-00002-of-00002.safetensors",
776
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.8.layer_norm1.weight": "model-00002-of-00002.safetensors",
777
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.8.layer_norm2.bias": "model-00002-of-00002.safetensors",
778
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.8.layer_norm2.weight": "model-00002-of-00002.safetensors",
779
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.8.mlp.fc1.bias": "model-00002-of-00002.safetensors",
780
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.8.mlp.fc1.weight": "model-00002-of-00002.safetensors",
781
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.8.mlp.fc2.bias": "model-00002-of-00002.safetensors",
782
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.8.mlp.fc2.weight": "model-00002-of-00002.safetensors",
783
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.8.self_attn.k_proj.bias": "model-00002-of-00002.safetensors",
784
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.8.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
785
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.8.self_attn.out_proj.bias": "model-00002-of-00002.safetensors",
786
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.8.self_attn.out_proj.weight": "model-00002-of-00002.safetensors",
787
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.8.self_attn.q_proj.bias": "model-00002-of-00002.safetensors",
788
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.8.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
789
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.8.self_attn.v_proj.bias": "model-00002-of-00002.safetensors",
790
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.8.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
791
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.9.layer_norm1.bias": "model-00002-of-00002.safetensors",
792
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.9.layer_norm1.weight": "model-00002-of-00002.safetensors",
793
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.9.layer_norm2.bias": "model-00002-of-00002.safetensors",
794
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.9.layer_norm2.weight": "model-00002-of-00002.safetensors",
795
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.9.mlp.fc1.bias": "model-00002-of-00002.safetensors",
796
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.9.mlp.fc1.weight": "model-00002-of-00002.safetensors",
797
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.9.mlp.fc2.bias": "model-00002-of-00002.safetensors",
798
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.9.mlp.fc2.weight": "model-00002-of-00002.safetensors",
799
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.9.self_attn.k_proj.bias": "model-00002-of-00002.safetensors",
800
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.9.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
801
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.9.self_attn.out_proj.bias": "model-00002-of-00002.safetensors",
802
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.9.self_attn.out_proj.weight": "model-00002-of-00002.safetensors",
803
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.9.self_attn.q_proj.bias": "model-00002-of-00002.safetensors",
804
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.9.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
805
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.9.self_attn.v_proj.bias": "model-00002-of-00002.safetensors",
806
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.9.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
807
+ "model.vision_tower.vision_tower.vision_model.head.attention.in_proj_bias": "model-00002-of-00002.safetensors",
808
+ "model.vision_tower.vision_tower.vision_model.head.attention.in_proj_weight": "model-00002-of-00002.safetensors",
809
+ "model.vision_tower.vision_tower.vision_model.head.attention.out_proj.bias": "model-00002-of-00002.safetensors",
810
+ "model.vision_tower.vision_tower.vision_model.head.attention.out_proj.weight": "model-00002-of-00002.safetensors",
811
+ "model.vision_tower.vision_tower.vision_model.head.layernorm.bias": "model-00002-of-00002.safetensors",
812
+ "model.vision_tower.vision_tower.vision_model.head.layernorm.weight": "model-00002-of-00002.safetensors",
813
+ "model.vision_tower.vision_tower.vision_model.head.mlp.fc1.bias": "model-00002-of-00002.safetensors",
814
+ "model.vision_tower.vision_tower.vision_model.head.mlp.fc1.weight": "model-00002-of-00002.safetensors",
815
+ "model.vision_tower.vision_tower.vision_model.head.mlp.fc2.bias": "model-00002-of-00002.safetensors",
816
+ "model.vision_tower.vision_tower.vision_model.head.mlp.fc2.weight": "model-00002-of-00002.safetensors",
817
+ "model.vision_tower.vision_tower.vision_model.head.probe": "model-00002-of-00002.safetensors",
818
+ "model.vision_tower.vision_tower.vision_model.post_layernorm.bias": "model-00002-of-00002.safetensors",
819
+ "model.vision_tower.vision_tower.vision_model.post_layernorm.weight": "model-00002-of-00002.safetensors"
820
+ }
821
+ }
modeling_bunny_minicpm.py ADDED
@@ -0,0 +1,1898 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import AutoConfig, AutoModelForCausalLM
2
+ from abc import ABC, abstractmethod
3
+
4
+ import torch
5
+ import torch.nn as nn
6
+
7
+ from transformers import SiglipVisionModel, SiglipImageProcessor, SiglipVisionConfig
8
+
9
+
10
+ class SiglipVisionTower(nn.Module):
11
+ def __init__(self, vision_tower, args, delay_load=False):
12
+ super().__init__()
13
+
14
+ self.is_loaded = False
15
+
16
+ self.vision_tower_name = vision_tower
17
+ self.select_layer = -2
18
+
19
+ if not delay_load:
20
+ self.load_model()
21
+ else:
22
+ self.cfg_only = SiglipVisionConfig.from_pretrained(self.vision_tower_name)
23
+
24
+ def load_model(self):
25
+ self.image_processor = SiglipImageProcessor.from_pretrained(self.vision_tower_name)
26
+ self.image_processor.crop_size = self.image_processor.size
27
+ self.vision_tower = SiglipVisionModel.from_pretrained(self.vision_tower_name)
28
+ self.vision_tower.requires_grad_(False)
29
+
30
+ self.is_loaded = True
31
+
32
+ def feature_select(self, image_forward_outs):
33
+ image_features = image_forward_outs.hidden_states[self.select_layer]
34
+
35
+ return image_features
36
+
37
+ @torch.no_grad()
38
+ def forward(self, images):
39
+ if type(images) is list:
40
+ image_features = []
41
+ for image in images:
42
+ image_forward_out = self.vision_tower(image.to(device=self.device, dtype=self.dtype).unsqueeze(0),
43
+ output_hidden_states=True)
44
+ image_feature = self.feature_select(image_forward_out).to(image.dtype)
45
+ image_features.append(image_feature)
46
+ else:
47
+ image_forward_outs = self.vision_tower(images.to(device=self.device, dtype=self.dtype),
48
+ output_hidden_states=True)
49
+ image_features = self.feature_select(image_forward_outs).to(images.dtype)
50
+
51
+ return image_features
52
+
53
+ @property
54
+ def dummy_feature(self):
55
+ return torch.zeros(1, self.hidden_size, device=self.device, dtype=self.dtype)
56
+
57
+ @property
58
+ def dtype(self):
59
+ return self.vision_tower.dtype
60
+
61
+ @property
62
+ def device(self):
63
+ return self.vision_tower.device
64
+
65
+ @property
66
+ def config(self):
67
+ if self.is_loaded:
68
+ return self.vision_tower.config
69
+ else:
70
+ return self.cfg_only
71
+
72
+ @property
73
+ def hidden_size(self):
74
+ return self.config.hidden_size
75
+
76
+ @property
77
+ def num_patches(self):
78
+ return (self.config.image_size // self.config.patch_size) ** 2
79
+
80
+
81
+ def build_vision_tower(vision_tower_cfg, **kwargs):
82
+ vision_tower = getattr(vision_tower_cfg, 'mm_vision_tower', getattr(vision_tower_cfg, 'vision_tower', None))
83
+
84
+ if 'sig' in vision_tower.lower():
85
+ return SiglipVisionTower(vision_tower, args=vision_tower_cfg, **kwargs)
86
+
87
+
88
+ import re
89
+
90
+
91
+ def build_vision_projector(config, delay_load=False, **kwargs):
92
+ projector_type = getattr(config, 'mm_projector_type', 'mlp2x_gelu')
93
+
94
+ mlp_gelu_match = re.match(r'^mlp(\d+)x_gelu$', projector_type)
95
+ if mlp_gelu_match:
96
+ mlp_depth = int(mlp_gelu_match.group(1))
97
+ modules = [nn.Linear(config.mm_hidden_size, config.hidden_size)]
98
+ for _ in range(1, mlp_depth):
99
+ modules.append(nn.GELU())
100
+ modules.append(nn.Linear(config.hidden_size, config.hidden_size))
101
+ return nn.Sequential(*modules)
102
+
103
+
104
+ # Model Constants
105
+ IGNORE_INDEX = -100
106
+ IMAGE_TOKEN_INDEX = -200
107
+
108
+
109
+ class BunnyMetaModel:
110
+
111
+ def __init__(self, config):
112
+ super(BunnyMetaModel, self).__init__(config)
113
+
114
+ if hasattr(config, "mm_vision_tower"):
115
+ self.vision_tower = build_vision_tower(config, delay_load=True)
116
+ self.mm_projector = build_vision_projector(config)
117
+
118
+ def get_vision_tower(self):
119
+ vision_tower = getattr(self, 'vision_tower', None)
120
+ if type(vision_tower) is list:
121
+ vision_tower = vision_tower[0]
122
+ return vision_tower
123
+
124
+ def initialize_vision_modules(self, model_args):
125
+ vision_tower = model_args.vision_tower
126
+
127
+ pretrain_mm_mlp_adapter = model_args.pretrain_mm_mlp_adapter
128
+
129
+ self.config.mm_vision_tower = vision_tower
130
+
131
+ if self.get_vision_tower() is None:
132
+ vision_tower = build_vision_tower(model_args)
133
+ self.vision_tower = vision_tower
134
+ else:
135
+ vision_tower = self.vision_tower
136
+ vision_tower.load_model()
137
+
138
+ self.config.use_mm_proj = True
139
+ self.config.mm_projector_type = getattr(model_args, 'mm_projector_type')
140
+ self.config.mm_hidden_size = vision_tower.hidden_size
141
+
142
+ if getattr(self, 'mm_projector', None) is None:
143
+ self.mm_projector = build_vision_projector(self.config)
144
+ else:
145
+ # In case it is frozen by LoRA
146
+ for p in self.mm_projector.parameters():
147
+ p.requires_grad = True
148
+
149
+ if pretrain_mm_mlp_adapter is not None:
150
+ mm_projector_weights = torch.load(pretrain_mm_mlp_adapter, map_location='cpu')
151
+
152
+ def get_w(weights, keyword):
153
+ return {k.split(keyword + '.')[1]: v for k, v in weights.items() if keyword in k}
154
+
155
+ self.mm_projector.load_state_dict(get_w(mm_projector_weights, 'mm_projector'))
156
+
157
+
158
+ class BunnyMetaForCausalLM(ABC):
159
+
160
+ @abstractmethod
161
+ def get_model(self):
162
+ pass
163
+
164
+ def get_vision_tower(self):
165
+ return self.get_model().get_vision_tower()
166
+
167
+ def encode_images(self, images):
168
+ image_features = self.get_model().get_vision_tower()(images)
169
+ image_features = self.get_model().mm_projector(image_features)
170
+ return image_features
171
+
172
+ def prepare_inputs_labels_for_multimodal(
173
+ self, input_ids, position_ids, attention_mask, past_key_values, labels, images
174
+ ):
175
+ vision_tower = self.get_vision_tower()
176
+ if vision_tower is None or images is None or input_ids.shape[1] == 1:
177
+ if past_key_values is not None and vision_tower is not None and images is not None and input_ids.shape[
178
+ 1] == 1:
179
+ target_shape = past_key_values[-1][-1].shape[-2] + 1
180
+ attention_mask = torch.cat((attention_mask, torch.ones(
181
+ (attention_mask.shape[0], target_shape - attention_mask.shape[1]),
182
+ dtype=attention_mask.dtype,
183
+ device=attention_mask.device
184
+ )), dim=1)
185
+ position_ids = torch.sum(attention_mask, dim=1).unsqueeze(-1) - 1
186
+ return input_ids, position_ids, attention_mask, past_key_values, None, labels
187
+
188
+ if type(images) is list or images.ndim == 5:
189
+ concat_images = torch.cat([image for image in images], dim=0)
190
+ image_features = self.encode_images(concat_images)
191
+ split_sizes = [image.shape[0] for image in images]
192
+ image_features = torch.split(image_features, split_sizes, dim=0)
193
+ image_features = [x.flatten(0, 1).to(self.device) for x in image_features]
194
+ else:
195
+ image_features = self.encode_images(images).to(self.device)
196
+
197
+ # Let's just add dummy tensors if they do not exist,
198
+ # it is a headache to deal with None all the time.
199
+ # But it is not ideal, and if you have a better idea,
200
+ # please open an issue / submit a PR, thanks.
201
+ _labels = labels
202
+ _position_ids = position_ids
203
+ _attention_mask = attention_mask
204
+ if attention_mask is None:
205
+ attention_mask = torch.ones_like(input_ids, dtype=torch.bool)
206
+ else:
207
+ attention_mask = attention_mask.bool()
208
+ if position_ids is None:
209
+ position_ids = torch.arange(0, input_ids.shape[1], dtype=torch.long, device=input_ids.device)
210
+ if labels is None:
211
+ labels = torch.full_like(input_ids, IGNORE_INDEX)
212
+
213
+ # remove the padding using attention_mask -- TODO: double check
214
+ input_ids = [cur_input_ids[cur_attention_mask] for cur_input_ids, cur_attention_mask in
215
+ zip(input_ids, attention_mask)]
216
+ labels = [cur_labels[cur_attention_mask] for cur_labels, cur_attention_mask in zip(labels, attention_mask)]
217
+
218
+ new_input_embeds = []
219
+ new_labels = []
220
+ cur_image_idx = 0
221
+ for batch_idx, cur_input_ids in enumerate(input_ids):
222
+ num_images = (cur_input_ids == IMAGE_TOKEN_INDEX).sum()
223
+ if num_images == 0:
224
+ cur_image_features = image_features[cur_image_idx]
225
+ cur_input_embeds_1 = self.get_model().embed_tokens(cur_input_ids)
226
+ cur_input_embeds = torch.cat([cur_input_embeds_1, cur_image_features[0:0]], dim=0)
227
+ new_input_embeds.append(cur_input_embeds)
228
+ new_labels.append(labels[batch_idx])
229
+ cur_image_idx += 1
230
+ continue
231
+
232
+ image_token_indices = [-1] + torch.where(cur_input_ids == IMAGE_TOKEN_INDEX)[0].tolist() + [
233
+ cur_input_ids.shape[0]]
234
+ cur_input_ids_noim = []
235
+ cur_labels = labels[batch_idx]
236
+ cur_labels_noim = []
237
+ for i in range(len(image_token_indices) - 1):
238
+ cur_input_ids_noim.append(cur_input_ids[image_token_indices[i] + 1:image_token_indices[i + 1]])
239
+ cur_labels_noim.append(cur_labels[image_token_indices[i] + 1:image_token_indices[i + 1]])
240
+ split_sizes = [x.shape[0] for x in cur_labels_noim]
241
+ cur_input_embeds = self.get_model().embed_tokens(torch.cat(cur_input_ids_noim))
242
+ cur_input_embeds_no_im = torch.split(cur_input_embeds, split_sizes, dim=0)
243
+ cur_new_input_embeds = []
244
+ cur_new_labels = []
245
+
246
+ for i in range(num_images + 1):
247
+ cur_new_input_embeds.append(cur_input_embeds_no_im[i])
248
+ cur_new_labels.append(cur_labels_noim[i])
249
+ if i < num_images:
250
+ cur_image_features = image_features[cur_image_idx]
251
+ cur_image_idx += 1
252
+ cur_new_input_embeds.append(cur_image_features)
253
+ cur_new_labels.append(
254
+ torch.full((cur_image_features.shape[0],), IGNORE_INDEX, device=cur_labels.device,
255
+ dtype=cur_labels.dtype))
256
+
257
+ cur_new_input_embeds = torch.cat(cur_new_input_embeds)
258
+ cur_new_labels = torch.cat(cur_new_labels)
259
+
260
+ new_input_embeds.append(cur_new_input_embeds)
261
+ new_labels.append(cur_new_labels)
262
+
263
+ # Truncate sequences to max length as image embeddings can make the sequence longer
264
+ tokenizer_model_max_length = getattr(self.config, 'tokenizer_model_max_length', None)
265
+ if tokenizer_model_max_length is not None:
266
+ new_input_embeds = [x[:tokenizer_model_max_length] for x in new_input_embeds]
267
+ new_labels = [x[:tokenizer_model_max_length] for x in new_labels]
268
+
269
+ # Combine them
270
+ max_len = max(x.shape[0] for x in new_input_embeds)
271
+ batch_size = len(new_input_embeds)
272
+
273
+ new_input_embeds_padded = []
274
+ new_labels_padded = torch.full((batch_size, max_len), IGNORE_INDEX, dtype=new_labels[0].dtype,
275
+ device=new_labels[0].device)
276
+ attention_mask = torch.zeros((batch_size, max_len), dtype=attention_mask.dtype, device=attention_mask.device)
277
+ position_ids = torch.zeros((batch_size, max_len), dtype=position_ids.dtype, device=position_ids.device)
278
+
279
+ for i, (cur_new_embed, cur_new_labels) in enumerate(zip(new_input_embeds, new_labels)):
280
+ cur_len = cur_new_embed.shape[0]
281
+ if getattr(self.config, 'tokenizer_padding_side', 'right') == "left":
282
+ new_input_embeds_padded.append(torch.cat((
283
+ torch.zeros((max_len - cur_len, cur_new_embed.shape[1]), dtype=cur_new_embed.dtype,
284
+ device=cur_new_embed.device),
285
+ cur_new_embed
286
+ ), dim=0))
287
+ if cur_len > 0:
288
+ new_labels_padded[i, -cur_len:] = cur_new_labels
289
+ attention_mask[i, -cur_len:] = True
290
+ position_ids[i, -cur_len:] = torch.arange(0, cur_len, dtype=position_ids.dtype,
291
+ device=position_ids.device)
292
+ else:
293
+ new_input_embeds_padded.append(torch.cat((
294
+ cur_new_embed,
295
+ torch.zeros((max_len - cur_len, cur_new_embed.shape[1]), dtype=cur_new_embed.dtype,
296
+ device=cur_new_embed.device)
297
+ ), dim=0))
298
+ if cur_len > 0:
299
+ new_labels_padded[i, :cur_len] = cur_new_labels
300
+ attention_mask[i, :cur_len] = True
301
+ position_ids[i, :cur_len] = torch.arange(0, cur_len, dtype=position_ids.dtype,
302
+ device=position_ids.device)
303
+
304
+ new_input_embeds = torch.stack(new_input_embeds_padded, dim=0)
305
+
306
+ if _labels is None:
307
+ new_labels = None
308
+ else:
309
+ new_labels = new_labels_padded
310
+
311
+ if _attention_mask is None:
312
+ attention_mask = None
313
+ else:
314
+ attention_mask = attention_mask.to(dtype=_attention_mask.dtype)
315
+
316
+ if _position_ids is None:
317
+ position_ids = None
318
+
319
+ return None, position_ids, attention_mask, past_key_values, new_input_embeds, new_labels
320
+
321
+
322
+ # coding=utf-8
323
+ # Copyright 2022 EleutherAI and the HuggingFace Inc. team. All rights reserved.
324
+ #
325
+ # This code is based on EleutherAI's GPT-NeoX library and the GPT-NeoX
326
+ # and OPT implementations in this library. It has been modified from its
327
+ # original forms to accommodate minor architectural differences compared
328
+ # to GPT-NeoX and OPT used by the Meta AI team that trained the model.
329
+ #
330
+ # Licensed under the Apache License, Version 2.0 (the "License");
331
+ # you may not use this file except in compliance with the License.
332
+ # You may obtain a copy of the License at
333
+ #
334
+ # http://www.apache.org/licenses/LICENSE-2.0
335
+ #
336
+ # Unless required by applicable law or agreed to in writing, software
337
+ # distributed under the License is distributed on an "AS IS" BASIS,
338
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
339
+ # See the License for the specific language governing permissions and
340
+ # limitations under the License.
341
+ """ PyTorch MiniCPM model."""
342
+ import math
343
+ import warnings
344
+ from typing import List, Optional, Tuple, Union, Dict
345
+
346
+ import torch
347
+ import torch.nn.functional as F
348
+ import torch.utils.checkpoint
349
+ from torch import nn
350
+ from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss
351
+
352
+ from transformers.activations import ACT2FN
353
+ from transformers.cache_utils import Cache, DynamicCache
354
+ from transformers.modeling_attn_mask_utils import (
355
+ AttentionMaskConverter,
356
+ _prepare_4d_attention_mask,
357
+ _prepare_4d_causal_attention_mask,
358
+ _prepare_4d_causal_attention_mask_for_sdpa,
359
+ )
360
+ from transformers.modeling_outputs import BaseModelOutputWithPast, CausalLMOutputWithPast, \
361
+ SequenceClassifierOutputWithPast
362
+ from transformers.modeling_utils import PreTrainedModel
363
+ from transformers.pytorch_utils import ALL_LAYERNORM_LAYERS, is_torch_greater_or_equal_than_1_13
364
+ from transformers.utils import (
365
+ add_start_docstrings,
366
+ add_start_docstrings_to_model_forward,
367
+ is_flash_attn_2_available,
368
+ is_flash_attn_greater_or_equal_2_10,
369
+ logging,
370
+ replace_return_docstrings,
371
+ )
372
+ from transformers.utils.import_utils import is_torch_fx_available
373
+ from .configuration_bunny_minicpm import MiniCPMConfig
374
+ import re
375
+
376
+ try:
377
+ from flash_attn import flash_attn_func, flash_attn_varlen_func
378
+ from flash_attn.bert_padding import index_first_axis, pad_input, unpad_input # noqa
379
+ except:
380
+ flash_attn_func, flash_attn_varlen_func, index_first_axis, pad_input, unpad_input = None, None, None, None, None
381
+
382
+ # This makes `_prepare_4d_causal_attention_mask` a leaf function in the FX graph.
383
+ # It means that the function will not be traced through and simply appear as a node in the graph.
384
+ if is_torch_fx_available():
385
+ if not is_torch_greater_or_equal_than_1_13:
386
+ import torch.fx
387
+
388
+ _prepare_4d_causal_attention_mask = torch.fx.wrap(_prepare_4d_causal_attention_mask)
389
+
390
+ logger = logging.get_logger(__name__)
391
+
392
+ _CONFIG_FOR_DOC = "MiniCPMConfig"
393
+
394
+
395
+ def _get_unpad_data(attention_mask):
396
+ seqlens_in_batch = attention_mask.sum(dim=-1, dtype=torch.int32)
397
+ indices = torch.nonzero(attention_mask.flatten(), as_tuple=False).flatten()
398
+ max_seqlen_in_batch = seqlens_in_batch.max().item()
399
+ cu_seqlens = F.pad(torch.cumsum(seqlens_in_batch, dim=0, dtype=torch.torch.int32), (1, 0))
400
+ return (
401
+ indices,
402
+ cu_seqlens,
403
+ max_seqlen_in_batch,
404
+ )
405
+
406
+
407
+ def _expand_mask(mask: torch.Tensor, dtype: torch.dtype, tgt_len: Optional[int] = None):
408
+ warnings.warn(
409
+ "Calling `transformers.models.minicpm.modeling_minicpm._prepare_4d_attention_mask` is deprecated and will be removed in v4.37. Use `transformers.modeling_attn_mask_utils._prepare_4d_attention_mask"
410
+ )
411
+ return _prepare_4d_attention_mask(mask=mask, dtype=dtype, tgt_len=tgt_len)
412
+
413
+
414
+ def _make_causal_mask(
415
+ input_ids_shape: torch.Size, dtype: torch.dtype, device: torch.device, past_key_values_length: int = 0
416
+ ):
417
+ warnings.warn(
418
+ "Calling `transformers.models.minicpm.modeling_minicpm._make_causal_mask` is deprecated and will be removed in v4.37. Use `transformers.models.minicpm.modeling_minicpm.AttentionMaskConverter._make_causal_mask"
419
+ )
420
+ return AttentionMaskConverter._make_causal_mask(
421
+ input_ids_shape=input_ids_shape, dtype=dtype, device=device, past_key_values_length=past_key_values_length
422
+ )
423
+
424
+
425
+ # @torch.jit.script # type: ignore
426
+ def rms_layernorm(hidden: torch.Tensor, weight: torch.Tensor, eps: float):
427
+ old_dtype = hidden.dtype
428
+ variance = hidden.to(torch.float32).pow(2).mean(dim=-1, keepdim=True)
429
+ hidden = (hidden * torch.rsqrt(variance + eps)).to(old_dtype)
430
+ return hidden * weight
431
+
432
+
433
+ class MiniCPMRMSNorm(nn.Module):
434
+ def __init__(self, hidden_size, eps=1e-6):
435
+ """
436
+ MiniCPMRMSNorm is equivalent to T5LayerNorm
437
+ """
438
+ super().__init__()
439
+ self.weight = nn.Parameter(torch.ones(hidden_size))
440
+ self.variance_epsilon = eps
441
+
442
+ def forward(self, hidden_states):
443
+ return rms_layernorm(hidden_states, self.weight, self.variance_epsilon)
444
+
445
+
446
+ ALL_LAYERNORM_LAYERS.append(MiniCPMRMSNorm)
447
+
448
+
449
+ class MiniCPMRotaryEmbedding(nn.Module):
450
+ def __init__(self, dim, max_position_embeddings=2048, base=10000, device=None):
451
+ super().__init__()
452
+
453
+ self.dim = dim
454
+ self.max_position_embeddings = max_position_embeddings
455
+ self.base = base
456
+ inv_freq = 1.0 / (self.base ** (torch.arange(0, self.dim, 2).float().to(device) / self.dim))
457
+ self.register_buffer("inv_freq", inv_freq, persistent=False)
458
+
459
+ # Build here to make `torch.jit.trace` work.
460
+ self._set_cos_sin_cache(
461
+ # seq_len=max_position_embeddings, device=self.inv_freq.device, dtype=torch.get_default_dtype()
462
+ seq_len=max_position_embeddings, device=self.inv_freq.device, dtype=torch.float32
463
+ )
464
+
465
+ def _set_cos_sin_cache(self, seq_len, device, dtype):
466
+ self.max_seq_len_cached = seq_len
467
+ t = torch.arange(self.max_seq_len_cached, device=device, dtype=self.inv_freq.dtype)
468
+ freqs = torch.outer(t, self.inv_freq)
469
+ # Different from paper, but it uses a different permutation in order to obtain the same calculation
470
+ emb = torch.cat((freqs, freqs), dim=-1)
471
+
472
+ self.register_buffer("cos_cached", emb.cos().to(dtype), persistent=False)
473
+ self.register_buffer("sin_cached", emb.sin().to(dtype), persistent=False)
474
+
475
+ def forward(self, x, seq_len=None):
476
+ # x: [bs, num_attention_heads, seq_len, head_size]
477
+ if seq_len > self.max_seq_len_cached:
478
+ self._set_cos_sin_cache(seq_len=seq_len, device=x.device, dtype=x.dtype)
479
+
480
+ return (
481
+ self.cos_cached[:seq_len].to(dtype=x.dtype),
482
+ self.sin_cached[:seq_len].to(dtype=x.dtype),
483
+ )
484
+
485
+
486
+ class MiniCPMLinearScalingRotaryEmbedding(MiniCPMRotaryEmbedding):
487
+ """MiniCPMRotaryEmbedding extended with linear scaling. Credits to the Reddit user /u/kaiokendev"""
488
+
489
+ def __init__(self, dim, max_position_embeddings=2048, base=10000, device=None, scaling_factor=1.0):
490
+ self.scaling_factor = scaling_factor
491
+ super().__init__(dim, max_position_embeddings, base, device)
492
+
493
+ def _set_cos_sin_cache(self, seq_len, device, dtype):
494
+ self.max_seq_len_cached = seq_len
495
+ t = torch.arange(self.max_seq_len_cached, device=device, dtype=self.inv_freq.dtype)
496
+ t = t / self.scaling_factor
497
+
498
+ freqs = torch.outer(t, self.inv_freq)
499
+ # Different from paper, but it uses a different permutation in order to obtain the same calculation
500
+ emb = torch.cat((freqs, freqs), dim=-1)
501
+ self.register_buffer("cos_cached", emb.cos().to(dtype), persistent=False)
502
+ self.register_buffer("sin_cached", emb.sin().to(dtype), persistent=False)
503
+
504
+
505
+ class MiniCPMDynamicNTKScalingRotaryEmbedding(MiniCPMRotaryEmbedding):
506
+ """MiniCPMRotaryEmbedding extended with Dynamic NTK scaling. Credits to the Reddit users /u/bloc97 and /u/emozilla"""
507
+
508
+ def __init__(self, dim, max_position_embeddings=2048, base=10000, device=None, scaling_factor=1.0):
509
+ self.scaling_factor = scaling_factor
510
+ super().__init__(dim, max_position_embeddings, base, device)
511
+
512
+ def _set_cos_sin_cache(self, seq_len, device, dtype):
513
+ self.max_seq_len_cached = seq_len
514
+
515
+ if seq_len > self.max_position_embeddings:
516
+ base = self.base * (
517
+ (self.scaling_factor * seq_len / self.max_position_embeddings) - (self.scaling_factor - 1)
518
+ ) ** (self.dim / (self.dim - 2))
519
+ inv_freq = 1.0 / (base ** (torch.arange(0, self.dim, 2).float().to(device) / self.dim))
520
+ self.register_buffer("inv_freq", inv_freq, persistent=False)
521
+
522
+ t = torch.arange(self.max_seq_len_cached, device=device, dtype=self.inv_freq.dtype)
523
+
524
+ freqs = torch.outer(t, self.inv_freq)
525
+ # Different from paper, but it uses a different permutation in order to obtain the same calculation
526
+ emb = torch.cat((freqs, freqs), dim=-1)
527
+
528
+ self.register_buffer("cos_cached", emb.cos().to(dtype), persistent=False)
529
+ self.register_buffer("sin_cached", emb.sin().to(dtype), persistent=False)
530
+
531
+
532
+ def rotate_half(x):
533
+ """Rotates half the hidden dims of the input."""
534
+ x1 = x[..., : x.shape[-1] // 2]
535
+ x2 = x[..., x.shape[-1] // 2:]
536
+ return torch.cat((-x2, x1), dim=-1)
537
+
538
+
539
+ def apply_rotary_pos_emb(q, k, cos, sin, position_ids, unsqueeze_dim=1):
540
+ """Applies Rotary Position Embedding to the query and key tensors.
541
+
542
+ Args:
543
+ q (`torch.Tensor`): The query tensor.
544
+ k (`torch.Tensor`): The key tensor.
545
+ cos (`torch.Tensor`): The cosine part of the rotary embedding.
546
+ sin (`torch.Tensor`): The sine part of the rotary embedding.
547
+ position_ids (`torch.Tensor`):
548
+ The position indices of the tokens corresponding to the query and key tensors. For example, this can be
549
+ used to pass offsetted position ids when working with a KV-cache.
550
+ unsqueeze_dim (`int`, *optional*, defaults to 1):
551
+ The 'unsqueeze_dim' argument specifies the dimension along which to unsqueeze cos[position_ids] and
552
+ sin[position_ids] so that they can be properly broadcasted to the dimensions of q and k. For example, note
553
+ that cos[position_ids] and sin[position_ids] have the shape [batch_size, seq_len, head_dim]. Then, if q and
554
+ k have the shape [batch_size, heads, seq_len, head_dim], then setting unsqueeze_dim=1 makes
555
+ cos[position_ids] and sin[position_ids] broadcastable to the shapes of q and k. Similarly, if q and k have
556
+ the shape [batch_size, seq_len, heads, head_dim], then set unsqueeze_dim=2.
557
+ Returns:
558
+ `tuple(torch.Tensor)` comprising of the query and key tensors rotated using the Rotary Position Embedding.
559
+ """
560
+ # cos = cos[position_ids].unsqueeze(unsqueeze_dim)
561
+ # sin = sin[position_ids].unsqueeze(unsqueeze_dim)
562
+ # q_embed = (q * cos) + (rotate_half(q) * sin)
563
+ # k_embed = (k * cos) + (rotate_half(k) * sin)
564
+ orig_dtype = k.dtype
565
+ cos = cos[position_ids].unsqueeze(unsqueeze_dim) # [bs, 1, seq_len, dim]
566
+ sin = sin[position_ids].unsqueeze(unsqueeze_dim) # [bs, 1, seq_len, dim]
567
+ q_fp32 = q.to(dtype=torch.float32, device=q.device)
568
+ k_fp32 = k.to(dtype=torch.float32, device=k.device)
569
+ q_embed = (q_fp32 * cos) + (rotate_half(q_fp32) * sin)
570
+ k_embed = (k_fp32 * cos) + (rotate_half(k_fp32) * sin)
571
+ return q_embed.to(dtype=orig_dtype), k_embed.to(dtype=orig_dtype)
572
+
573
+
574
+ class MiniCPMMLP(nn.Module):
575
+ def __init__(self, config):
576
+ super().__init__()
577
+ self.config = config
578
+ self.hidden_size = config.hidden_size
579
+ self.intermediate_size = config.intermediate_size
580
+ self.gate_proj = nn.Linear(self.hidden_size, self.intermediate_size, bias=False)
581
+ self.up_proj = nn.Linear(self.hidden_size, self.intermediate_size, bias=False)
582
+ self.down_proj = nn.Linear(self.intermediate_size, self.hidden_size, bias=False)
583
+ self.act_fn = ACT2FN[config.hidden_act]
584
+
585
+ def forward(self, x):
586
+ if self.config.pretraining_tp > 1:
587
+ slice = self.intermediate_size // self.config.pretraining_tp
588
+ gate_proj_slices = self.gate_proj.weight.split(slice, dim=0)
589
+ up_proj_slices = self.up_proj.weight.split(slice, dim=0)
590
+ down_proj_slices = self.down_proj.weight.split(slice, dim=1)
591
+
592
+ gate_proj = torch.cat(
593
+ [F.linear(x, gate_proj_slices[i]) for i in range(self.config.pretraining_tp)], dim=-1
594
+ )
595
+ up_proj = torch.cat([F.linear(x, up_proj_slices[i]) for i in range(self.config.pretraining_tp)], dim=-1)
596
+
597
+ intermediate_states = (self.act_fn(gate_proj) * up_proj).split(slice, dim=2)
598
+ down_proj = [
599
+ F.linear(intermediate_states[i], down_proj_slices[i]) for i in range(self.config.pretraining_tp)
600
+ ]
601
+ down_proj = sum(down_proj)
602
+ else:
603
+ down_proj = self.down_proj(self.act_fn(self.gate_proj(x)) * self.up_proj(x))
604
+
605
+ return down_proj
606
+
607
+
608
+ def repeat_kv(hidden_states: torch.Tensor, n_rep: int) -> torch.Tensor:
609
+ """
610
+ This is the equivalent of torch.repeat_interleave(x, dim=1, repeats=n_rep). The hidden states go from (batch,
611
+ num_key_value_heads, seqlen, head_dim) to (batch, num_attention_heads, seqlen, head_dim)
612
+ """
613
+ batch, num_key_value_heads, slen, head_dim = hidden_states.shape
614
+ if n_rep == 1:
615
+ return hidden_states
616
+ hidden_states = hidden_states[:, :, None, :, :].expand(batch, num_key_value_heads, n_rep, slen, head_dim)
617
+ return hidden_states.reshape(batch, num_key_value_heads * n_rep, slen, head_dim)
618
+
619
+
620
+ class MiniCPMAttention(nn.Module):
621
+ """Multi-headed attention from 'Attention Is All You Need' paper"""
622
+
623
+ def __init__(self, config: MiniCPMConfig, layer_idx: Optional[int] = None):
624
+ super().__init__()
625
+ self.config = config
626
+ self.layer_idx = layer_idx
627
+ if layer_idx is None:
628
+ logger.warning_once(
629
+ f"Instantiating {self.__class__.__name__} without passing `layer_idx` is not recommended and will "
630
+ "to errors during the forward call, if caching is used. Please make sure to provide a `layer_idx` "
631
+ "when creating this class."
632
+ )
633
+
634
+ self.attention_dropout = config.attention_dropout
635
+ self.hidden_size = config.hidden_size
636
+ self.num_heads = config.num_attention_heads
637
+ self.head_dim = self.hidden_size // self.num_heads
638
+ self.num_key_value_heads = config.num_key_value_heads
639
+ self.num_key_value_groups = self.num_heads // self.num_key_value_heads
640
+ self.max_position_embeddings = config.max_position_embeddings
641
+ self.rope_theta = config.rope_theta
642
+ self.is_causal = True
643
+
644
+ if (self.head_dim * self.num_heads) != self.hidden_size:
645
+ raise ValueError(
646
+ f"hidden_size must be divisible by num_heads (got `hidden_size`: {self.hidden_size}"
647
+ f" and `num_heads`: {self.num_heads})."
648
+ )
649
+
650
+ self.q_proj = nn.Linear(self.hidden_size, self.num_heads * self.head_dim, bias=config.attention_bias)
651
+ self.k_proj = nn.Linear(self.hidden_size, self.num_key_value_heads * self.head_dim, bias=config.attention_bias)
652
+ self.v_proj = nn.Linear(self.hidden_size, self.num_key_value_heads * self.head_dim, bias=config.attention_bias)
653
+ self.o_proj = nn.Linear(self.num_heads * self.head_dim, self.hidden_size, bias=config.attention_bias)
654
+ self._init_rope()
655
+
656
+ def _init_rope(self):
657
+ if self.config.rope_scaling is None:
658
+ self.rotary_emb = MiniCPMRotaryEmbedding(
659
+ self.head_dim,
660
+ max_position_embeddings=self.max_position_embeddings,
661
+ base=self.rope_theta,
662
+ )
663
+ else:
664
+ scaling_type = self.config.rope_scaling["type"]
665
+ scaling_factor = self.config.rope_scaling["factor"]
666
+ if scaling_type == "linear":
667
+ self.rotary_emb = MiniCPMLinearScalingRotaryEmbedding(
668
+ self.head_dim,
669
+ max_position_embeddings=self.max_position_embeddings,
670
+ scaling_factor=scaling_factor,
671
+ base=self.rope_theta,
672
+ )
673
+ elif scaling_type == "dynamic":
674
+ self.rotary_emb = MiniCPMDynamicNTKScalingRotaryEmbedding(
675
+ self.head_dim,
676
+ max_position_embeddings=self.max_position_embeddings,
677
+ scaling_factor=scaling_factor,
678
+ base=self.rope_theta,
679
+ )
680
+ else:
681
+ raise ValueError(f"Unknown RoPE scaling type {scaling_type}")
682
+
683
+ def _shape(self, tensor: torch.Tensor, seq_len: int, bsz: int):
684
+ return tensor.view(bsz, seq_len, self.num_heads, self.head_dim).transpose(1, 2).contiguous()
685
+
686
+ def forward(
687
+ self,
688
+ hidden_states: torch.Tensor,
689
+ attention_mask: Optional[torch.Tensor] = None,
690
+ position_ids: Optional[torch.LongTensor] = None,
691
+ past_key_value: Optional[Cache] = None,
692
+ output_attentions: bool = False,
693
+ use_cache: bool = False,
694
+ **kwargs,
695
+ ) -> Tuple[torch.Tensor, Optional[torch.Tensor], Optional[Tuple[torch.Tensor]]]:
696
+ if "padding_mask" in kwargs:
697
+ warnings.warn(
698
+ "Passing `padding_mask` is deprecated and will be removed in v4.37. Please make sure use `attention_mask` instead.`"
699
+ )
700
+
701
+ bsz, q_len, _ = hidden_states.size()
702
+
703
+ if self.config.pretraining_tp > 1:
704
+ key_value_slicing = (self.num_key_value_heads * self.head_dim) // self.config.pretraining_tp
705
+ query_slices = self.q_proj.weight.split(
706
+ (self.num_heads * self.head_dim) // self.config.pretraining_tp, dim=0
707
+ )
708
+ key_slices = self.k_proj.weight.split(key_value_slicing, dim=0)
709
+ value_slices = self.v_proj.weight.split(key_value_slicing, dim=0)
710
+
711
+ query_states = [F.linear(hidden_states, query_slices[i]) for i in range(self.config.pretraining_tp)]
712
+ query_states = torch.cat(query_states, dim=-1)
713
+
714
+ key_states = [F.linear(hidden_states, key_slices[i]) for i in range(self.config.pretraining_tp)]
715
+ key_states = torch.cat(key_states, dim=-1)
716
+
717
+ value_states = [F.linear(hidden_states, value_slices[i]) for i in range(self.config.pretraining_tp)]
718
+ value_states = torch.cat(value_states, dim=-1)
719
+
720
+ else:
721
+ query_states = self.q_proj(hidden_states)
722
+ key_states = self.k_proj(hidden_states)
723
+ value_states = self.v_proj(hidden_states)
724
+
725
+ query_states = query_states.view(bsz, q_len, self.num_heads, self.head_dim).transpose(1, 2)
726
+ key_states = key_states.view(bsz, q_len, self.num_key_value_heads, self.head_dim).transpose(1, 2)
727
+ value_states = value_states.view(bsz, q_len, self.num_key_value_heads, self.head_dim).transpose(1, 2)
728
+
729
+ kv_seq_len = key_states.shape[-2]
730
+ if past_key_value is not None:
731
+ if self.layer_idx is None:
732
+ raise ValueError(
733
+ f"The cache structure has changed since version v4.36. If you are using {self.__class__.__name__} "
734
+ "for auto-regressive decoding with k/v caching, please make sure to initialize the attention class "
735
+ "with a layer index."
736
+ )
737
+ kv_seq_len += past_key_value.get_usable_length(kv_seq_len, self.layer_idx)
738
+ cos, sin = self.rotary_emb(value_states.to(torch.float32), seq_len=kv_seq_len)
739
+
740
+ query_states, key_states = apply_rotary_pos_emb(query_states, key_states, cos, sin, position_ids)
741
+
742
+ if past_key_value is not None:
743
+ cache_kwargs = {"sin": sin, "cos": cos} # Specific to RoPE models
744
+ key_states, value_states = past_key_value.update(key_states, value_states, self.layer_idx, cache_kwargs)
745
+
746
+ key_states = repeat_kv(key_states, self.num_key_value_groups)
747
+ value_states = repeat_kv(value_states, self.num_key_value_groups)
748
+
749
+ attn_weights = torch.matmul(query_states, key_states.transpose(2, 3)) / math.sqrt(self.head_dim)
750
+ if attn_weights.size() != (bsz, self.num_heads, q_len, kv_seq_len):
751
+ raise ValueError(
752
+ f"Attention weights should be of size {(bsz, self.num_heads, q_len, kv_seq_len)}, but is"
753
+ f" {attn_weights.size()}"
754
+ )
755
+
756
+ if attention_mask is not None:
757
+ if attention_mask.size() != (bsz, 1, q_len, kv_seq_len):
758
+ raise ValueError(
759
+ f"Attention mask should be of size {(bsz, 1, q_len, kv_seq_len)}, but is {attention_mask.size()}"
760
+ )
761
+ attn_weights = attn_weights + attention_mask
762
+
763
+ # upcast attention to fp32
764
+ attn_weights = nn.functional.softmax(attn_weights, dim=-1, dtype=torch.float32).to(query_states.dtype)
765
+ attn_weights = nn.functional.dropout(attn_weights, p=self.attention_dropout, training=self.training)
766
+ attn_output = torch.matmul(attn_weights, value_states)
767
+
768
+ if attn_output.size() != (bsz, self.num_heads, q_len, self.head_dim):
769
+ raise ValueError(
770
+ f"`attn_output` should be of size {(bsz, self.num_heads, q_len, self.head_dim)}, but is"
771
+ f" {attn_output.size()}"
772
+ )
773
+
774
+ attn_output = attn_output.transpose(1, 2).contiguous()
775
+
776
+ attn_output = attn_output.reshape(bsz, q_len, self.hidden_size)
777
+
778
+ if self.config.pretraining_tp > 1:
779
+ attn_output = attn_output.split(self.hidden_size // self.config.pretraining_tp, dim=2)
780
+ o_proj_slices = self.o_proj.weight.split(self.hidden_size // self.config.pretraining_tp, dim=1)
781
+ attn_output = sum([F.linear(attn_output[i], o_proj_slices[i]) for i in range(self.config.pretraining_tp)])
782
+ else:
783
+ attn_output = self.o_proj(attn_output)
784
+
785
+ if not output_attentions:
786
+ attn_weights = None
787
+
788
+ return attn_output, attn_weights, past_key_value
789
+
790
+
791
+ class MiniCPMFlashAttention2(MiniCPMAttention):
792
+ """
793
+ MiniCPM flash attention module. This module inherits from `MiniCPMAttention` as the weights of the module stays
794
+ untouched. The only required change would be on the forward pass where it needs to correctly call the public API of
795
+ flash attention and deal with padding tokens in case the input contains any of them.
796
+ """
797
+
798
+ def __init__(self, *args, **kwargs):
799
+ super().__init__(*args, **kwargs)
800
+
801
+ # TODO: Should be removed once Flash Attention for RoCm is bumped to 2.1.
802
+ # flash_attn<2.1 generates top-left aligned causal mask, while what is needed here is bottom-right alignement, that was made default for flash_attn>=2.1. This attribute is used to handle this difference. Reference: https://github.com/Dao-AILab/flash-attention/releases/tag/v2.1.0.
803
+ # Beware that with flash_attn<2.1, using q_seqlen != k_seqlen (except for the case q_seqlen == 1) produces a wrong mask (top-left).
804
+ self._flash_attn_uses_top_left_mask = not is_flash_attn_greater_or_equal_2_10()
805
+
806
+ def forward(
807
+ self,
808
+ hidden_states: torch.Tensor,
809
+ attention_mask: Optional[torch.LongTensor] = None,
810
+ position_ids: Optional[torch.LongTensor] = None,
811
+ past_key_value: Optional[Cache] = None,
812
+ output_attentions: bool = False,
813
+ use_cache: bool = False,
814
+ **kwargs,
815
+ ) -> Tuple[torch.Tensor, Optional[torch.Tensor], Optional[Tuple[torch.Tensor]]]:
816
+ # MiniCPMFlashAttention2 attention does not support output_attentions
817
+ if "padding_mask" in kwargs:
818
+ warnings.warn(
819
+ "Passing `padding_mask` is deprecated and will be removed in v4.37. Please make sure use `attention_mask` instead.`"
820
+ )
821
+
822
+ # overwrite attention_mask with padding_mask
823
+ attention_mask = kwargs.pop("padding_mask")
824
+
825
+ output_attentions = False
826
+
827
+ bsz, q_len, _ = hidden_states.size()
828
+
829
+ query_states = self.q_proj(hidden_states)
830
+ key_states = self.k_proj(hidden_states)
831
+ value_states = self.v_proj(hidden_states)
832
+
833
+ # Flash attention requires the input to have the shape
834
+ # batch_size x seq_length x head_dim x hidden_dim
835
+ # therefore we just need to keep the original shape
836
+ query_states = query_states.view(bsz, q_len, self.num_heads, self.head_dim).transpose(1, 2)
837
+ key_states = key_states.view(bsz, q_len, self.num_key_value_heads, self.head_dim).transpose(1, 2)
838
+ value_states = value_states.view(bsz, q_len, self.num_key_value_heads, self.head_dim).transpose(1, 2)
839
+
840
+ kv_seq_len = key_states.shape[-2]
841
+ if past_key_value is not None:
842
+ kv_seq_len += past_key_value.get_usable_length(kv_seq_len, self.layer_idx)
843
+ cos, sin = self.rotary_emb(value_states.to(torch.float32), seq_len=kv_seq_len)
844
+ query_states, key_states = apply_rotary_pos_emb(query_states, key_states, cos, sin, position_ids)
845
+
846
+ if past_key_value is not None:
847
+ cache_kwargs = {"sin": sin, "cos": cos} # Specific to RoPE models
848
+ key_states, value_states = past_key_value.update(key_states, value_states, self.layer_idx, cache_kwargs)
849
+
850
+ # TODO: These transpose are quite inefficient but Flash Attention requires the layout [batch_size, sequence_length, num_heads, head_dim]. We would need to refactor the KV cache
851
+ # to be able to avoid many of these transpose/reshape/view.
852
+ query_states = query_states.transpose(1, 2)
853
+ key_states = key_states.transpose(1, 2)
854
+ value_states = value_states.transpose(1, 2)
855
+
856
+ dropout_rate = self.attention_dropout if self.training else 0.0
857
+
858
+ # In PEFT, usually we cast the layer norms in float32 for training stability reasons
859
+ # therefore the input hidden states gets silently casted in float32. Hence, we need
860
+ # cast them back in the correct dtype just to be sure everything works as expected.
861
+ # This might slowdown training & inference so it is recommended to not cast the LayerNorms
862
+ # in fp32. (MiniCPMRMSNorm handles it correctly)
863
+
864
+ input_dtype = query_states.dtype
865
+ if input_dtype == torch.float32:
866
+ # Handle the case where the model is quantized
867
+ if hasattr(self.config, "_pre_quantization_dtype"):
868
+ target_dtype = self.config._pre_quantization_dtype
869
+ else:
870
+ target_dtype = self.q_proj.weight.dtype
871
+
872
+ logger.warning_once(
873
+ f"The input hidden states seems to be silently casted in float32, this might be related to"
874
+ f" the fact you have upcasted embedding or layer norm layers in float32. We will cast back the input in"
875
+ f" {target_dtype}."
876
+ )
877
+
878
+ query_states = query_states.to(target_dtype)
879
+ key_states = key_states.to(target_dtype)
880
+ value_states = value_states.to(target_dtype)
881
+
882
+ attn_output = self._flash_attention_forward(
883
+ query_states, key_states, value_states, attention_mask, q_len, dropout=dropout_rate
884
+ )
885
+
886
+ attn_output = attn_output.reshape(bsz, q_len, self.hidden_size).contiguous()
887
+ attn_output = self.o_proj(attn_output)
888
+
889
+ if not output_attentions:
890
+ attn_weights = None
891
+
892
+ return attn_output, attn_weights, past_key_value
893
+
894
+ def _flash_attention_forward(
895
+ self, query_states, key_states, value_states, attention_mask, query_length, dropout=0.0, softmax_scale=None
896
+ ):
897
+ """
898
+ Calls the forward method of Flash Attention - if the input hidden states contain at least one padding token
899
+ first unpad the input, then computes the attention scores and pad the final attention scores.
900
+
901
+ Args:
902
+ query_states (`torch.Tensor`):
903
+ Input query states to be passed to Flash Attention API
904
+ key_states (`torch.Tensor`):
905
+ Input key states to be passed to Flash Attention API
906
+ value_states (`torch.Tensor`):
907
+ Input value states to be passed to Flash Attention API
908
+ attention_mask (`torch.Tensor`):
909
+ The padding mask - corresponds to a tensor of size `(batch_size, seq_len)` where 0 stands for the
910
+ position of padding tokens and 1 for the position of non-padding tokens.
911
+ dropout (`int`, *optional*):
912
+ Attention dropout
913
+ softmax_scale (`float`, *optional*):
914
+ The scaling of QK^T before applying softmax. Default to 1 / sqrt(head_dim)
915
+ """
916
+ if not self._flash_attn_uses_top_left_mask:
917
+ causal = self.is_causal
918
+ else:
919
+ # TODO: Remove the `query_length != 1` check once Flash Attention for RoCm is bumped to 2.1. For details, please see the comment in MiniCPMFlashAttention2 __init__.
920
+ causal = self.is_causal and query_length != 1
921
+ # Contains at least one padding token in the sequence
922
+ if attention_mask is not None:
923
+ batch_size = query_states.shape[0]
924
+ query_states, key_states, value_states, indices_q, cu_seq_lens, max_seq_lens = self._upad_input(
925
+ query_states, key_states, value_states, attention_mask, query_length
926
+ )
927
+
928
+ cu_seqlens_q, cu_seqlens_k = cu_seq_lens
929
+ max_seqlen_in_batch_q, max_seqlen_in_batch_k = max_seq_lens
930
+ attn_output_unpad = flash_attn_varlen_func(
931
+ query_states,
932
+ key_states,
933
+ value_states,
934
+ cu_seqlens_q=cu_seqlens_q,
935
+ cu_seqlens_k=cu_seqlens_k,
936
+ max_seqlen_q=max_seqlen_in_batch_q,
937
+ max_seqlen_k=max_seqlen_in_batch_k,
938
+ dropout_p=dropout,
939
+ softmax_scale=softmax_scale,
940
+ causal=causal,
941
+ )
942
+
943
+ attn_output = pad_input(attn_output_unpad, indices_q, batch_size, query_length)
944
+ else:
945
+ attn_output = flash_attn_func(
946
+ query_states, key_states, value_states, dropout, softmax_scale=softmax_scale, causal=causal
947
+ )
948
+
949
+ return attn_output
950
+
951
+ def _upad_input(self, query_layer, key_layer, value_layer, attention_mask, query_length):
952
+ indices_k, cu_seqlens_k, max_seqlen_in_batch_k = _get_unpad_data(attention_mask)
953
+ batch_size, kv_seq_len, num_key_value_heads, head_dim = key_layer.shape
954
+
955
+ key_layer = index_first_axis(
956
+ key_layer.reshape(batch_size * kv_seq_len, num_key_value_heads, head_dim), indices_k
957
+ )
958
+ value_layer = index_first_axis(
959
+ value_layer.reshape(batch_size * kv_seq_len, num_key_value_heads, head_dim), indices_k
960
+ )
961
+ if query_length == kv_seq_len:
962
+ query_layer = index_first_axis(
963
+ query_layer.reshape(batch_size * kv_seq_len, self.num_heads, head_dim), indices_k
964
+ )
965
+ cu_seqlens_q = cu_seqlens_k
966
+ max_seqlen_in_batch_q = max_seqlen_in_batch_k
967
+ indices_q = indices_k
968
+ elif query_length == 1:
969
+ max_seqlen_in_batch_q = 1
970
+ cu_seqlens_q = torch.arange(
971
+ batch_size + 1, dtype=torch.int32, device=query_layer.device
972
+ ) # There is a memcpy here, that is very bad.
973
+ indices_q = cu_seqlens_q[:-1]
974
+ query_layer = query_layer.squeeze(1)
975
+ else:
976
+ # The -q_len: slice assumes left padding.
977
+ attention_mask = attention_mask[:, -query_length:]
978
+ query_layer, indices_q, cu_seqlens_q, max_seqlen_in_batch_q = unpad_input(query_layer, attention_mask)
979
+
980
+ return (
981
+ query_layer,
982
+ key_layer,
983
+ value_layer,
984
+ indices_q,
985
+ (cu_seqlens_q, cu_seqlens_k),
986
+ (max_seqlen_in_batch_q, max_seqlen_in_batch_k),
987
+ )
988
+
989
+
990
+ class MiniCPMSdpaAttention(MiniCPMAttention):
991
+ """
992
+ MiniCPM attention module using torch.nn.functional.scaled_dot_product_attention. This module inherits from
993
+ `MiniCPMAttention` as the weights of the module stays untouched. The only changes are on the forward pass to adapt to
994
+ SDPA API.
995
+ """
996
+
997
+ # Adapted from MiniCPMAttention.forward
998
+ def forward(
999
+ self,
1000
+ hidden_states: torch.Tensor,
1001
+ attention_mask: Optional[torch.Tensor] = None,
1002
+ position_ids: Optional[torch.LongTensor] = None,
1003
+ past_key_value: Optional[Cache] = None,
1004
+ output_attentions: bool = False,
1005
+ use_cache: bool = False,
1006
+ ) -> Tuple[torch.Tensor, Optional[torch.Tensor], Optional[Tuple[torch.Tensor]]]:
1007
+ if output_attentions:
1008
+ # TODO: Improve this warning with e.g. `model.config.attn_implementation = "manual"` once this is implemented.
1009
+ logger.warning_once(
1010
+ "MiniCPMModel is using MiniCPMSdpaAttention, but `torch.nn.functional.scaled_dot_product_attention` does not support `output_attentions=True`. Falling back to the manual attention implementation, "
1011
+ 'but specifying the manual implementation will be required from Transformers version v5.0.0 onwards. This warning can be removed using the argument `attn_implementation="eager"` when loading the model.'
1012
+ )
1013
+ return super().forward(
1014
+ hidden_states=hidden_states,
1015
+ attention_mask=attention_mask,
1016
+ position_ids=position_ids,
1017
+ past_key_value=past_key_value,
1018
+ output_attentions=output_attentions,
1019
+ use_cache=use_cache,
1020
+ )
1021
+
1022
+ bsz, q_len, _ = hidden_states.size()
1023
+
1024
+ query_states = self.q_proj(hidden_states)
1025
+ key_states = self.k_proj(hidden_states)
1026
+ value_states = self.v_proj(hidden_states)
1027
+
1028
+ query_states = query_states.view(bsz, q_len, self.num_heads, self.head_dim).transpose(1, 2)
1029
+ key_states = key_states.view(bsz, q_len, self.num_key_value_heads, self.head_dim).transpose(1, 2)
1030
+ value_states = value_states.view(bsz, q_len, self.num_key_value_heads, self.head_dim).transpose(1, 2)
1031
+
1032
+ kv_seq_len = key_states.shape[-2]
1033
+ if past_key_value is not None:
1034
+ kv_seq_len += past_key_value.get_usable_length(kv_seq_len, self.layer_idx)
1035
+ cos, sin = self.rotary_emb(value_states, seq_len=kv_seq_len)
1036
+
1037
+ query_states, key_states = apply_rotary_pos_emb(query_states, key_states, cos, sin, position_ids)
1038
+
1039
+ if past_key_value is not None:
1040
+ cache_kwargs = {"sin": sin, "cos": cos} # Specific to RoPE models
1041
+ key_states, value_states = past_key_value.update(key_states, value_states, self.layer_idx, cache_kwargs)
1042
+
1043
+ key_states = repeat_kv(key_states, self.num_key_value_groups)
1044
+ value_states = repeat_kv(value_states, self.num_key_value_groups)
1045
+
1046
+ if attention_mask is not None:
1047
+ if attention_mask.size() != (bsz, 1, q_len, kv_seq_len):
1048
+ raise ValueError(
1049
+ f"Attention mask should be of size {(bsz, 1, q_len, kv_seq_len)}, but is {attention_mask.size()}"
1050
+ )
1051
+
1052
+ # SDPA with memory-efficient backend is currently (torch==2.1.2) bugged with non-contiguous inputs with custom attn_mask,
1053
+ # Reference: https://github.com/pytorch/pytorch/issues/112577.
1054
+ if query_states.device.type == "cuda" and attention_mask is not None:
1055
+ query_states = query_states.contiguous()
1056
+ key_states = key_states.contiguous()
1057
+ value_states = value_states.contiguous()
1058
+
1059
+ attn_output = torch.nn.functional.scaled_dot_product_attention(
1060
+ query_states,
1061
+ key_states,
1062
+ value_states,
1063
+ attn_mask=attention_mask,
1064
+ dropout_p=self.attention_dropout if self.training else 0.0,
1065
+ # The q_len > 1 is necessary to match with AttentionMaskConverter.to_causal_4d that does not create a causal mask in case q_len == 1.
1066
+ is_causal=self.is_causal and attention_mask is None and q_len > 1,
1067
+ )
1068
+
1069
+ attn_output = attn_output.transpose(1, 2).contiguous()
1070
+ attn_output = attn_output.reshape(bsz, q_len, self.hidden_size)
1071
+
1072
+ attn_output = self.o_proj(attn_output)
1073
+
1074
+ return attn_output, None, past_key_value
1075
+
1076
+
1077
+ MINICPM_ATTENTION_CLASSES = {
1078
+ "eager": MiniCPMAttention,
1079
+ "flash_attention_2": MiniCPMFlashAttention2,
1080
+ "sdpa": MiniCPMSdpaAttention,
1081
+ }
1082
+
1083
+
1084
+ class MiniCPMDecoderLayer(nn.Module):
1085
+ def __init__(self, config: MiniCPMConfig, layer_idx: int):
1086
+ super().__init__()
1087
+ self.hidden_size = config.hidden_size
1088
+ self.self_attn = MINICPM_ATTENTION_CLASSES[config._attn_implementation](config=config, layer_idx=layer_idx)
1089
+
1090
+ self.mlp = MiniCPMMLP(config)
1091
+ self.input_layernorm = MiniCPMRMSNorm(config.hidden_size, eps=config.rms_norm_eps)
1092
+ self.post_attention_layernorm = MiniCPMRMSNorm(config.hidden_size, eps=config.rms_norm_eps)
1093
+
1094
+ self.scale_depth = config.scale_depth
1095
+ self.num_hidden_layers = config.num_hidden_layers
1096
+
1097
+ def forward(
1098
+ self,
1099
+ hidden_states: torch.Tensor,
1100
+ attention_mask: Optional[torch.Tensor] = None,
1101
+ position_ids: Optional[torch.LongTensor] = None,
1102
+ past_key_value: Optional[Tuple[torch.Tensor]] = None,
1103
+ output_attentions: Optional[bool] = False,
1104
+ use_cache: Optional[bool] = False,
1105
+ **kwargs,
1106
+ ) -> Tuple[torch.FloatTensor, Optional[Tuple[torch.FloatTensor, torch.FloatTensor]]]:
1107
+ """
1108
+ Args:
1109
+ hidden_states (`torch.FloatTensor`): input to the layer of shape `(batch, seq_len, embed_dim)`
1110
+ attention_mask (`torch.FloatTensor`, *optional*):
1111
+ attention mask of size `(batch_size, sequence_length)` if flash attention is used or `(batch_size, 1,
1112
+ query_sequence_length, key_sequence_length)` if default attention is used.
1113
+ output_attentions (`bool`, *optional*):
1114
+ Whether or not to return the attentions tensors of all attention layers. See `attentions` under
1115
+ returned tensors for more detail.
1116
+ use_cache (`bool`, *optional*):
1117
+ If set to `True`, `past_key_values` key value states are returned and can be used to speed up decoding
1118
+ (see `past_key_values`).
1119
+ past_key_value (`Tuple(torch.FloatTensor)`, *optional*): cached past key and value projection states
1120
+ """
1121
+ if "padding_mask" in kwargs:
1122
+ warnings.warn(
1123
+ "Passing `padding_mask` is deprecated and will be removed in v4.37. Please make sure use `attention_mask` instead.`"
1124
+ )
1125
+
1126
+ residual = hidden_states
1127
+ hidden_states = self.input_layernorm(hidden_states)
1128
+ # Self Attention
1129
+ hidden_states, self_attn_weights, present_key_value = self.self_attn(
1130
+ hidden_states=hidden_states,
1131
+ attention_mask=attention_mask,
1132
+ position_ids=position_ids,
1133
+ past_key_value=past_key_value,
1134
+ output_attentions=output_attentions,
1135
+ use_cache=use_cache,
1136
+ **kwargs,
1137
+ )
1138
+
1139
+ hidden_states = residual + hidden_states * (self.scale_depth / math.sqrt(self.num_hidden_layers))
1140
+
1141
+ # Fully Connected
1142
+ residual = hidden_states
1143
+ hidden_states = self.post_attention_layernorm(hidden_states)
1144
+
1145
+ hidden_states = self.mlp(hidden_states)
1146
+ hidden_states = residual + hidden_states * (self.scale_depth / math.sqrt(self.num_hidden_layers))
1147
+
1148
+ outputs = (hidden_states,)
1149
+
1150
+ if output_attentions:
1151
+ outputs += (self_attn_weights,)
1152
+
1153
+ if use_cache:
1154
+ outputs += (present_key_value,)
1155
+
1156
+ return outputs
1157
+
1158
+
1159
+ MINICPM_START_DOCSTRING = r"""
1160
+ This model inherits from [`PreTrainedModel`]. Check the superclass documentation for the generic methods the
1161
+ library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
1162
+ etc.)
1163
+
1164
+ This model is also a PyTorch [torch.nn.Module](https://pytorch.org/docs/stable/nn.html#torch.nn.Module) subclass.
1165
+ Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
1166
+ and behavior.
1167
+
1168
+ Parameters:
1169
+ config ([`MiniCPMConfig`]):
1170
+ Model configuration class with all the parameters of the model. Initializing with a config file does not
1171
+ load the weights associated with the model, only the configuration. Check out the
1172
+ [`~PreTrainedModel.from_pretrained`] method to load the model weights.
1173
+ """
1174
+
1175
+
1176
+ @add_start_docstrings(
1177
+ "The bare MiniCPM Model outputting raw hidden-states without any specific head on top.",
1178
+ MINICPM_START_DOCSTRING,
1179
+ )
1180
+ class MiniCPMPreTrainedModel(PreTrainedModel):
1181
+ config_class = MiniCPMConfig
1182
+ base_model_prefix = "model"
1183
+ supports_gradient_checkpointing = True
1184
+ _no_split_modules = ["MiniCPMDecoderLayer"]
1185
+ _skip_keys_device_placement = "past_key_values"
1186
+ _supports_flash_attn_2 = True
1187
+ _supports_sdpa = True
1188
+ _supports_cache_class = True
1189
+
1190
+ def _init_weights(self, module):
1191
+ std = self.config.initializer_range
1192
+ if isinstance(module, nn.Linear):
1193
+ module.weight.data.normal_(mean=0.0, std=std)
1194
+ if module.bias is not None:
1195
+ module.bias.data.zero_()
1196
+ elif isinstance(module, nn.Embedding):
1197
+ module.weight.data.normal_(mean=0.0, std=std)
1198
+ if module.padding_idx is not None:
1199
+ module.weight.data[module.padding_idx].zero_()
1200
+
1201
+
1202
+ MINICPM_INPUTS_DOCSTRING = r"""
1203
+ Args:
1204
+ input_ids (`torch.LongTensor` of shape `(batch_size, sequence_length)`):
1205
+ Indices of input sequence tokens in the vocabulary. Padding will be ignored by default should you provide
1206
+ it.
1207
+
1208
+ Indices can be obtained using [`AutoTokenizer`]. See [`PreTrainedTokenizer.encode`] and
1209
+ [`PreTrainedTokenizer.__call__`] for details.
1210
+
1211
+ [What are input IDs?](../glossary#input-ids)
1212
+ attention_mask (`torch.Tensor` of shape `(batch_size, sequence_length)`, *optional*):
1213
+ Mask to avoid performing attention on padding token indices. Mask values selected in `[0, 1]`:
1214
+
1215
+ - 1 for tokens that are **not masked**,
1216
+ - 0 for tokens that are **masked**.
1217
+
1218
+ [What are attention masks?](../glossary#attention-mask)
1219
+
1220
+ Indices can be obtained using [`AutoTokenizer`]. See [`PreTrainedTokenizer.encode`] and
1221
+ [`PreTrainedTokenizer.__call__`] for details.
1222
+
1223
+ If `past_key_values` is used, optionally only the last `input_ids` have to be input (see
1224
+ `past_key_values`).
1225
+
1226
+ If you want to change padding behavior, you should read [`modeling_opt._prepare_decoder_attention_mask`]
1227
+ and modify to your needs. See diagram 1 in [the paper](https://arxiv.org/abs/1910.13461) for more
1228
+ information on the default strategy.
1229
+
1230
+ - 1 indicates the head is **not masked**,
1231
+ - 0 indicates the head is **masked**.
1232
+ position_ids (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *optional*):
1233
+ Indices of positions of each input sequence tokens in the position embeddings. Selected in the range `[0,
1234
+ config.n_positions - 1]`.
1235
+
1236
+ [What are position IDs?](../glossary#position-ids)
1237
+ past_key_values (`Cache` or `tuple(tuple(torch.FloatTensor))`, *optional*):
1238
+ Pre-computed hidden-states (key and values in the self-attention blocks and in the cross-attention
1239
+ blocks) that can be used to speed up sequential decoding. This typically consists in the `past_key_values`
1240
+ returned by the model at a previous stage of decoding, when `use_cache=True` or `config.use_cache=True`.
1241
+
1242
+ Two formats are allowed:
1243
+ - a [`~cache_utils.Cache`] instance;
1244
+ - Tuple of `tuple(torch.FloatTensor)` of length `config.n_layers`, with each tuple having 2 tensors of
1245
+ shape `(batch_size, num_heads, sequence_length, embed_size_per_head)`). This is also known as the legacy
1246
+ cache format.
1247
+
1248
+ The model will output the same cache format that is fed as input. If no `past_key_values` are passed, the
1249
+ legacy cache format will be returned.
1250
+
1251
+ If `past_key_values` are used, the user can optionally input only the last `input_ids` (those that don't
1252
+ have their past key value states given to this model) of shape `(batch_size, 1)` instead of all `input_ids`
1253
+ of shape `(batch_size, sequence_length)`.
1254
+ inputs_embeds (`torch.FloatTensor` of shape `(batch_size, sequence_length, hidden_size)`, *optional*):
1255
+ Optionally, instead of passing `input_ids` you can choose to directly pass an embedded representation. This
1256
+ is useful if you want more control over how to convert `input_ids` indices into associated vectors than the
1257
+ model's internal embedding lookup matrix.
1258
+ use_cache (`bool`, *optional*):
1259
+ If set to `True`, `past_key_values` key value states are returned and can be used to speed up decoding (see
1260
+ `past_key_values`).
1261
+ output_attentions (`bool`, *optional*):
1262
+ Whether or not to return the attentions tensors of all attention layers. See `attentions` under returned
1263
+ tensors for more detail.
1264
+ output_hidden_states (`bool`, *optional*):
1265
+ Whether or not to return the hidden states of all layers. See `hidden_states` under returned tensors for
1266
+ more detail.
1267
+ return_dict (`bool`, *optional*):
1268
+ Whether or not to return a [`~utils.ModelOutput`] instead of a plain tuple.
1269
+ """
1270
+
1271
+
1272
+ @add_start_docstrings(
1273
+ "The bare MiniCPM Model outputting raw hidden-states without any specific head on top.",
1274
+ MINICPM_START_DOCSTRING,
1275
+ )
1276
+ class MiniCPMModel(MiniCPMPreTrainedModel):
1277
+ """
1278
+ Transformer decoder consisting of *config.num_hidden_layers* layers. Each layer is a [`MiniCPMDecoderLayer`]
1279
+
1280
+ Args:
1281
+ config: MiniCPMConfig
1282
+ """
1283
+
1284
+ def __init__(self, config: MiniCPMConfig):
1285
+ super().__init__(config)
1286
+ self.padding_idx = config.pad_token_id
1287
+ self.vocab_size = config.vocab_size
1288
+
1289
+ self.embed_tokens = nn.Embedding(config.vocab_size, config.hidden_size, self.padding_idx)
1290
+ self.layers = nn.ModuleList(
1291
+ [MiniCPMDecoderLayer(config, layer_idx) for layer_idx in range(config.num_hidden_layers)]
1292
+ )
1293
+ self._use_sdpa = config._attn_implementation == "sdpa"
1294
+ self._use_flash_attention_2 = config._attn_implementation == "flash_attention_2"
1295
+
1296
+ self.norm = MiniCPMRMSNorm(config.hidden_size, eps=config.rms_norm_eps)
1297
+
1298
+ self.gradient_checkpointing = False
1299
+ # Initialize weights and apply final processing
1300
+ self.post_init()
1301
+
1302
+ def get_input_embeddings(self):
1303
+ return self.embed_tokens
1304
+
1305
+ def set_input_embeddings(self, value):
1306
+ self.embed_tokens = value
1307
+
1308
+ @add_start_docstrings_to_model_forward(MINICPM_INPUTS_DOCSTRING)
1309
+ def forward(
1310
+ self,
1311
+ input_ids: torch.LongTensor = None,
1312
+ attention_mask: Optional[torch.Tensor] = None,
1313
+ position_ids: Optional[torch.LongTensor] = None,
1314
+ past_key_values: Optional[List[torch.FloatTensor]] = None,
1315
+ inputs_embeds: Optional[torch.FloatTensor] = None,
1316
+ use_cache: Optional[bool] = None,
1317
+ output_attentions: Optional[bool] = None,
1318
+ output_hidden_states: Optional[bool] = None,
1319
+ return_dict: Optional[bool] = None,
1320
+ ) -> Union[Tuple, BaseModelOutputWithPast]:
1321
+ output_attentions = output_attentions if output_attentions is not None else self.config.output_attentions
1322
+ output_hidden_states = (
1323
+ output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
1324
+ )
1325
+ use_cache = use_cache if use_cache is not None else self.config.use_cache
1326
+
1327
+ return_dict = return_dict if return_dict is not None else self.config.use_return_dict
1328
+
1329
+ # retrieve input_ids and inputs_embeds
1330
+ if input_ids is not None and inputs_embeds is not None:
1331
+ raise ValueError("You cannot specify both input_ids and inputs_embeds at the same time")
1332
+ elif input_ids is not None:
1333
+ batch_size, seq_length = input_ids.shape[:2]
1334
+ elif inputs_embeds is not None:
1335
+ batch_size, seq_length = inputs_embeds.shape[:2]
1336
+ else:
1337
+ raise ValueError("You have to specify either input_ids or inputs_embeds")
1338
+
1339
+ if self.gradient_checkpointing and self.training:
1340
+ if use_cache:
1341
+ logger.warning_once(
1342
+ "`use_cache=True` is incompatible with gradient checkpointing. Setting `use_cache=False`..."
1343
+ )
1344
+ use_cache = False
1345
+
1346
+ past_key_values_length = 0
1347
+ if use_cache:
1348
+ use_legacy_cache = not isinstance(past_key_values, Cache)
1349
+ if use_legacy_cache:
1350
+ past_key_values = DynamicCache.from_legacy_cache(past_key_values)
1351
+ past_key_values_length = past_key_values.get_usable_length(seq_length)
1352
+
1353
+ if position_ids is None:
1354
+ device = input_ids.device if input_ids is not None else inputs_embeds.device
1355
+ position_ids = torch.arange(
1356
+ past_key_values_length, seq_length + past_key_values_length, dtype=torch.long, device=device
1357
+ )
1358
+ position_ids = position_ids.unsqueeze(0)
1359
+
1360
+ if inputs_embeds is None:
1361
+ inputs_embeds = self.embed_tokens(input_ids) * self.config.scale_emb
1362
+
1363
+ if self._use_flash_attention_2:
1364
+ # 2d mask is passed through the layers
1365
+ attention_mask = attention_mask if (attention_mask is not None and 0 in attention_mask) else None
1366
+ elif self._use_sdpa and not output_attentions:
1367
+ # output_attentions=True can not be supported when using SDPA, and we fall back on
1368
+ # the manual implementation that requires a 4D causal mask in all cases.
1369
+ attention_mask = _prepare_4d_causal_attention_mask_for_sdpa(
1370
+ attention_mask,
1371
+ (batch_size, seq_length),
1372
+ inputs_embeds,
1373
+ past_key_values_length,
1374
+ )
1375
+ else:
1376
+ # 4d mask is passed through the layers
1377
+ attention_mask = _prepare_4d_causal_attention_mask(
1378
+ attention_mask, (batch_size, seq_length), inputs_embeds, past_key_values_length
1379
+ )
1380
+
1381
+ # embed positions
1382
+ hidden_states = inputs_embeds
1383
+
1384
+ # decoder layers
1385
+ all_hidden_states = () if output_hidden_states else None
1386
+ all_self_attns = () if output_attentions else None
1387
+ next_decoder_cache = None
1388
+
1389
+ for decoder_layer in self.layers:
1390
+ if output_hidden_states:
1391
+ all_hidden_states += (hidden_states,)
1392
+
1393
+ if self.gradient_checkpointing and self.training:
1394
+ layer_outputs = self._gradient_checkpointing_func(
1395
+ decoder_layer.__call__,
1396
+ hidden_states,
1397
+ attention_mask,
1398
+ position_ids,
1399
+ past_key_values,
1400
+ output_attentions,
1401
+ use_cache,
1402
+ )
1403
+ else:
1404
+ layer_outputs = decoder_layer(
1405
+ hidden_states,
1406
+ attention_mask=attention_mask,
1407
+ position_ids=position_ids,
1408
+ past_key_value=past_key_values,
1409
+ output_attentions=output_attentions,
1410
+ use_cache=use_cache,
1411
+ )
1412
+
1413
+ hidden_states = layer_outputs[0]
1414
+
1415
+ if use_cache:
1416
+ next_decoder_cache = layer_outputs[2 if output_attentions else 1]
1417
+
1418
+ if output_attentions:
1419
+ all_self_attns += (layer_outputs[1],)
1420
+
1421
+ hidden_states = self.norm(hidden_states)
1422
+
1423
+ # add hidden states from the last decoder layer
1424
+ if output_hidden_states:
1425
+ all_hidden_states += (hidden_states,)
1426
+
1427
+ next_cache = None
1428
+ if use_cache:
1429
+ next_cache = next_decoder_cache.to_legacy_cache() if use_legacy_cache else next_decoder_cache
1430
+ if not return_dict:
1431
+ return tuple(v for v in [hidden_states, next_cache, all_hidden_states, all_self_attns] if v is not None)
1432
+ return BaseModelOutputWithPast(
1433
+ last_hidden_state=hidden_states,
1434
+ past_key_values=next_cache,
1435
+ hidden_states=all_hidden_states,
1436
+ attentions=all_self_attns,
1437
+ )
1438
+
1439
+
1440
+ class MiniCPMForCausalLM(MiniCPMPreTrainedModel):
1441
+ _tied_weights_keys = ["lm_head.weight"]
1442
+
1443
+ def __init__(self, config):
1444
+ super().__init__(config)
1445
+ self.model = MiniCPMModel(config)
1446
+ self.vocab_size = config.vocab_size
1447
+ self.lm_head = nn.Linear(config.hidden_size, config.vocab_size, bias=False)
1448
+
1449
+ # Initialize weights and apply final processing
1450
+ self.post_init()
1451
+
1452
+ def get_input_embeddings(self):
1453
+ return self.model.embed_tokens
1454
+
1455
+ def set_input_embeddings(self, value):
1456
+ self.model.embed_tokens = value
1457
+
1458
+ def get_output_embeddings(self):
1459
+ return self.lm_head
1460
+
1461
+ def set_output_embeddings(self, new_embeddings):
1462
+ self.lm_head = new_embeddings
1463
+
1464
+ def set_decoder(self, decoder):
1465
+ self.model = decoder
1466
+
1467
+ def get_decoder(self):
1468
+ return self.model
1469
+
1470
+ @add_start_docstrings_to_model_forward(MINICPM_INPUTS_DOCSTRING)
1471
+ @replace_return_docstrings(output_type=CausalLMOutputWithPast, config_class=_CONFIG_FOR_DOC)
1472
+ def forward(
1473
+ self,
1474
+ input_ids: torch.LongTensor = None,
1475
+ attention_mask: Optional[torch.Tensor] = None,
1476
+ position_ids: Optional[torch.LongTensor] = None,
1477
+ past_key_values: Optional[List[torch.FloatTensor]] = None,
1478
+ inputs_embeds: Optional[torch.FloatTensor] = None,
1479
+ labels: Optional[torch.LongTensor] = None,
1480
+ use_cache: Optional[bool] = None,
1481
+ output_attentions: Optional[bool] = None,
1482
+ output_hidden_states: Optional[bool] = None,
1483
+ return_dict: Optional[bool] = None,
1484
+ ) -> Union[Tuple, CausalLMOutputWithPast]:
1485
+ r"""
1486
+ Args:
1487
+ labels (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *optional*):
1488
+ Labels for computing the masked language modeling loss. Indices should either be in `[0, ...,
1489
+ config.vocab_size]` or -100 (see `input_ids` docstring). Tokens with indices set to `-100` are ignored
1490
+ (masked), the loss is only computed for the tokens with labels in `[0, ..., config.vocab_size]`.
1491
+
1492
+ Returns:
1493
+
1494
+ Example:
1495
+
1496
+ ```python
1497
+ >>> from transformers import AutoTokenizer, MiniCPMForCausalLM
1498
+
1499
+ >>> model = MiniCPMForCausalLM.from_pretrained(PATH_TO_CONVERTED_WEIGHTS)
1500
+ >>> tokenizer = AutoTokenizer.from_pretrained(PATH_TO_CONVERTED_TOKENIZER)
1501
+
1502
+ >>> prompt = "Hey, are you conscious? Can you talk to me?"
1503
+ >>> inputs = tokenizer(prompt, return_tensors="pt")
1504
+
1505
+ >>> # Generate
1506
+ >>> generate_ids = model.generate(inputs.input_ids, max_length=30)
1507
+ >>> tokenizer.batch_decode(generate_ids, skip_special_tokens=True, clean_up_tokenization_spaces=False)[0]
1508
+ "Hey, are you conscious? Can you talk to me?\nI'm not conscious, but I can talk to you."
1509
+ ```"""
1510
+ output_attentions = output_attentions if output_attentions is not None else self.config.output_attentions
1511
+ output_hidden_states = (
1512
+ output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
1513
+ )
1514
+ return_dict = return_dict if return_dict is not None else self.config.use_return_dict
1515
+
1516
+ # decoder outputs consists of (dec_features, layer_state, dec_hidden, dec_attn)
1517
+ outputs = self.model(
1518
+ input_ids=input_ids,
1519
+ attention_mask=attention_mask,
1520
+ position_ids=position_ids,
1521
+ past_key_values=past_key_values,
1522
+ inputs_embeds=inputs_embeds,
1523
+ use_cache=use_cache,
1524
+ output_attentions=output_attentions,
1525
+ output_hidden_states=output_hidden_states,
1526
+ return_dict=return_dict,
1527
+ )
1528
+
1529
+ hidden_states = outputs[0]
1530
+ if self.config.pretraining_tp > 1:
1531
+ lm_head_slices = self.lm_head.weight.split(self.vocab_size // self.config.pretraining_tp, dim=0)
1532
+ logits = [F.linear(hidden_states, lm_head_slices[i]) for i in range(self.config.pretraining_tp)]
1533
+ logits = torch.cat(logits, dim=-1)
1534
+ else:
1535
+ logits = self.lm_head(hidden_states / (self.config.hidden_size / self.config.dim_model_base))
1536
+ logits = logits.float()
1537
+
1538
+ loss = None
1539
+ if labels is not None:
1540
+ # Shift so that tokens < n predict n
1541
+ shift_logits = logits[..., :-1, :].contiguous()
1542
+ shift_labels = labels[..., 1:].contiguous()
1543
+ # Flatten the tokens
1544
+ loss_fct = CrossEntropyLoss()
1545
+ shift_logits = shift_logits.view(-1, self.config.vocab_size)
1546
+ shift_labels = shift_labels.view(-1)
1547
+ # Enable model parallelism
1548
+ shift_labels = shift_labels.to(shift_logits.device)
1549
+ loss = loss_fct(shift_logits, shift_labels)
1550
+
1551
+ if not return_dict:
1552
+ output = (logits,) + outputs[1:]
1553
+ return (loss,) + output if loss is not None else output
1554
+
1555
+ return CausalLMOutputWithPast(
1556
+ loss=loss,
1557
+ logits=logits,
1558
+ past_key_values=outputs.past_key_values,
1559
+ hidden_states=outputs.hidden_states,
1560
+ attentions=outputs.attentions,
1561
+ )
1562
+
1563
+ def prepare_inputs_for_generation(
1564
+ self, input_ids, past_key_values=None, attention_mask=None, inputs_embeds=None, **kwargs
1565
+ ):
1566
+ if past_key_values is not None:
1567
+ if isinstance(past_key_values, Cache):
1568
+ cache_length = past_key_values.get_seq_length()
1569
+ past_length = past_key_values.seen_tokens
1570
+ max_cache_length = past_key_values.get_max_length()
1571
+ else:
1572
+ cache_length = past_length = past_key_values[0][0].shape[2]
1573
+ max_cache_length = None
1574
+
1575
+ # Keep only the unprocessed tokens:
1576
+ # 1 - If the length of the attention_mask exceeds the length of input_ids, then we are in a setting where
1577
+ # some of the inputs are exclusivelly passed as part of the cache (e.g. when passing input_embeds as
1578
+ # input)
1579
+ if attention_mask is not None and attention_mask.shape[1] > input_ids.shape[1]:
1580
+ input_ids = input_ids[:, -(attention_mask.shape[1] - past_length):]
1581
+ # 2 - If the past_length is smaller than input_ids', then input_ids holds all input tokens. We can discard
1582
+ # input_ids based on the past_length.
1583
+ elif past_length < input_ids.shape[1]:
1584
+ input_ids = input_ids[:, past_length:]
1585
+ # 3 - Otherwise (past_length >= input_ids.shape[1]), let's assume input_ids only has unprocessed tokens.
1586
+ else:
1587
+ remove_prefix_length = input_ids.shape[1] - 1
1588
+ input_ids = input_ids[:, remove_prefix_length:]
1589
+ # If we are about to go beyond the maximum cache length, we need to crop the input attention mask.
1590
+ if (
1591
+ max_cache_length is not None
1592
+ and attention_mask is not None
1593
+ and cache_length + input_ids.shape[1] > max_cache_length
1594
+ ):
1595
+ attention_mask = attention_mask[:, -max_cache_length:]
1596
+
1597
+ position_ids = kwargs.get("position_ids", None)
1598
+ if attention_mask is not None and position_ids is None:
1599
+ # create position_ids on the fly for batch generation
1600
+ position_ids = attention_mask.long().cumsum(-1) - 1
1601
+ position_ids.masked_fill_(attention_mask == 0, 1)
1602
+ if past_key_values:
1603
+ position_ids = position_ids[:, -input_ids.shape[1]:]
1604
+
1605
+ # if `inputs_embeds` are passed, we only want to use them in the 1st generation step
1606
+ if inputs_embeds is not None and past_key_values is None:
1607
+ model_inputs = {"inputs_embeds": inputs_embeds}
1608
+ else:
1609
+ model_inputs = {"input_ids": input_ids}
1610
+
1611
+ model_inputs.update(
1612
+ {
1613
+ "position_ids": position_ids,
1614
+ "past_key_values": past_key_values,
1615
+ "use_cache": kwargs.get("use_cache"),
1616
+ "attention_mask": attention_mask,
1617
+ }
1618
+ )
1619
+ return model_inputs
1620
+
1621
+ @staticmethod
1622
+ def _reorder_cache(past_key_values, beam_idx):
1623
+ reordered_past = ()
1624
+ for layer_past in past_key_values:
1625
+ reordered_past += (
1626
+ tuple(past_state.index_select(0, beam_idx.to(past_state.device)) for past_state in layer_past),
1627
+ )
1628
+ return reordered_past
1629
+
1630
+ @torch.inference_mode()
1631
+ def chat(self, tokenizer, query: str, history: List[Dict] = None, role: str = "user",
1632
+ max_length: int = 4096, num_beams=1, do_sample=True, top_p=0.8, temperature=0.3, logits_processor=None,
1633
+ **kwargs):
1634
+ if history is None:
1635
+ history = []
1636
+ if logits_processor:
1637
+ gen_kwargs = {"max_length": max_length, "num_beams": num_beams, "do_sample": do_sample, "top_p": top_p,
1638
+ "temperature": temperature, "logits_processor": logits_processor, **kwargs}
1639
+ else:
1640
+ gen_kwargs = {"max_length": max_length, "num_beams": num_beams, "do_sample": do_sample, "top_p": top_p,
1641
+ "temperature": temperature, "logits_processor": logits_processor, **kwargs}
1642
+
1643
+ history.append({"role": role, "content": query})
1644
+ history_str = tokenizer.apply_chat_template(history, tokenize=False, add_generation_prompt=False)
1645
+ inputs = tokenizer(history_str, return_tensors='pt').to(self.device)
1646
+ outputs = self.generate(**inputs, **gen_kwargs)
1647
+ outputs = outputs.tolist()[0][len(inputs["input_ids"][0]):-1]
1648
+ response = tokenizer.decode(outputs)
1649
+ pattern = re.compile(r".*?(?=<AI>|<用户>)", re.DOTALL)
1650
+ matches = pattern.findall(response)
1651
+ if len(matches) > 0:
1652
+ response = matches[0]
1653
+ history.append({"role": "assistant", "content": response})
1654
+ return response, history
1655
+
1656
+
1657
+ @add_start_docstrings(
1658
+ """
1659
+ The MiniCPM Model transformer with a sequence classification head on top (linear layer).
1660
+
1661
+ [`MiniCPMForSequenceClassification`] uses the last token in order to do the classification, as other causal models
1662
+ (e.g. GPT-2) do.
1663
+
1664
+ Since it does classification on the last token, it requires to know the position of the last token. If a
1665
+ `pad_token_id` is defined in the configuration, it finds the last token that is not a padding token in each row. If
1666
+ no `pad_token_id` is defined, it simply takes the last value in each row of the batch. Since it cannot guess the
1667
+ padding tokens when `inputs_embeds` are passed instead of `input_ids`, it does the same (take the last value in
1668
+ each row of the batch).
1669
+ """,
1670
+ MINICPM_START_DOCSTRING,
1671
+ )
1672
+ class MiniCPMForSequenceClassification(MiniCPMPreTrainedModel):
1673
+ def __init__(self, config):
1674
+ super().__init__(config)
1675
+ self.num_labels = config.num_labels
1676
+ self.model = MiniCPMModel(config)
1677
+ self.score = nn.Linear(config.hidden_size, self.num_labels, bias=False)
1678
+
1679
+ # Initialize weights and apply final processing
1680
+ self.post_init()
1681
+
1682
+ def get_input_embeddings(self):
1683
+ return self.model.embed_tokens
1684
+
1685
+ def set_input_embeddings(self, value):
1686
+ self.model.embed_tokens = value
1687
+
1688
+ @add_start_docstrings_to_model_forward(MINICPM_INPUTS_DOCSTRING)
1689
+ def forward(
1690
+ self,
1691
+ input_ids: torch.LongTensor = None,
1692
+ attention_mask: Optional[torch.Tensor] = None,
1693
+ position_ids: Optional[torch.LongTensor] = None,
1694
+ past_key_values: Optional[List[torch.FloatTensor]] = None,
1695
+ inputs_embeds: Optional[torch.FloatTensor] = None,
1696
+ labels: Optional[torch.LongTensor] = None,
1697
+ use_cache: Optional[bool] = None,
1698
+ output_attentions: Optional[bool] = None,
1699
+ output_hidden_states: Optional[bool] = None,
1700
+ return_dict: Optional[bool] = None,
1701
+ ) -> Union[Tuple, SequenceClassifierOutputWithPast]:
1702
+ r"""
1703
+ labels (`torch.LongTensor` of shape `(batch_size,)`, *optional*):
1704
+ Labels for computing the sequence classification/regression loss. Indices should be in `[0, ...,
1705
+ config.num_labels - 1]`. If `config.num_labels == 1` a regression loss is computed (Mean-Square loss), If
1706
+ `config.num_labels > 1` a classification loss is computed (Cross-Entropy).
1707
+ """
1708
+ return_dict = return_dict if return_dict is not None else self.config.use_return_dict
1709
+
1710
+ transformer_outputs = self.model(
1711
+ input_ids,
1712
+ attention_mask=attention_mask,
1713
+ position_ids=position_ids,
1714
+ past_key_values=past_key_values,
1715
+ inputs_embeds=inputs_embeds,
1716
+ use_cache=use_cache,
1717
+ output_attentions=output_attentions,
1718
+ output_hidden_states=output_hidden_states,
1719
+ return_dict=return_dict,
1720
+ )
1721
+ hidden_states = transformer_outputs[0]
1722
+ logits = self.score(hidden_states)
1723
+
1724
+ if input_ids is not None:
1725
+ batch_size = input_ids.shape[0]
1726
+ else:
1727
+ batch_size = inputs_embeds.shape[0]
1728
+
1729
+ if self.config.pad_token_id is None and batch_size != 1:
1730
+ raise ValueError("Cannot handle batch sizes > 1 if no padding token is defined.")
1731
+ if self.config.pad_token_id is None:
1732
+ sequence_lengths = -1
1733
+ else:
1734
+ if input_ids is not None:
1735
+ sequence_lengths = (torch.eq(input_ids, self.config.pad_token_id).int().argmax(-1) - 1).to(
1736
+ logits.device
1737
+ )
1738
+ else:
1739
+ sequence_lengths = -1
1740
+
1741
+ pooled_logits = logits[torch.arange(batch_size, device=logits.device), sequence_lengths]
1742
+
1743
+ loss = None
1744
+ if labels is not None:
1745
+ labels = labels.to(logits.device)
1746
+ if self.config.problem_type is None:
1747
+ if self.num_labels == 1:
1748
+ self.config.problem_type = "regression"
1749
+ elif self.num_labels > 1 and (labels.dtype == torch.long or labels.dtype == torch.int):
1750
+ self.config.problem_type = "single_label_classification"
1751
+ else:
1752
+ self.config.problem_type = "multi_label_classification"
1753
+
1754
+ if self.config.problem_type == "regression":
1755
+ loss_fct = MSELoss()
1756
+ if self.num_labels == 1:
1757
+ loss = loss_fct(pooled_logits.squeeze(), labels.squeeze())
1758
+ else:
1759
+ loss = loss_fct(pooled_logits, labels)
1760
+ elif self.config.problem_type == "single_label_classification":
1761
+ loss_fct = CrossEntropyLoss()
1762
+ loss = loss_fct(pooled_logits.view(-1, self.num_labels), labels.view(-1))
1763
+ elif self.config.problem_type == "multi_label_classification":
1764
+ loss_fct = BCEWithLogitsLoss()
1765
+ loss = loss_fct(pooled_logits, labels)
1766
+ if not return_dict:
1767
+ output = (pooled_logits,) + transformer_outputs[1:]
1768
+ return ((loss,) + output) if loss is not None else output
1769
+
1770
+ return SequenceClassifierOutputWithPast(
1771
+ loss=loss,
1772
+ logits=pooled_logits,
1773
+ past_key_values=transformer_outputs.past_key_values,
1774
+ hidden_states=transformer_outputs.hidden_states,
1775
+ attentions=transformer_outputs.attentions,
1776
+ )
1777
+
1778
+
1779
+ from .configuration_bunny_minicpm import BunnyMiniCPMConfig
1780
+ from PIL import Image
1781
+
1782
+
1783
+ class BunnyMiniCPMModel(BunnyMetaModel, MiniCPMModel):
1784
+ config_class = BunnyMiniCPMConfig
1785
+
1786
+ def __init__(self, config: MiniCPMConfig):
1787
+ super(BunnyMiniCPMModel, self).__init__(config)
1788
+
1789
+
1790
+ class BunnyMiniCPMForCausalLM(MiniCPMForCausalLM, BunnyMetaForCausalLM):
1791
+ config_class = BunnyMiniCPMConfig
1792
+
1793
+ def __init__(self, config):
1794
+ super(MiniCPMForCausalLM, self).__init__(config)
1795
+ self.model = BunnyMiniCPMModel(config)
1796
+ self.vocab_size = config.vocab_size
1797
+ self.lm_head = nn.Linear(config.hidden_size, config.vocab_size, bias=False)
1798
+
1799
+ # Initialize weights and apply final processing
1800
+ self.post_init()
1801
+
1802
+ def get_model(self):
1803
+ return self.model
1804
+
1805
+ def forward(
1806
+ self,
1807
+ input_ids: torch.LongTensor = None,
1808
+ attention_mask: Optional[torch.Tensor] = None,
1809
+ position_ids: Optional[torch.LongTensor] = None,
1810
+ past_key_values: Optional[List[torch.FloatTensor]] = None,
1811
+ inputs_embeds: Optional[torch.FloatTensor] = None,
1812
+ labels: Optional[torch.LongTensor] = None,
1813
+ use_cache: Optional[bool] = None,
1814
+ output_attentions: Optional[bool] = None,
1815
+ output_hidden_states: Optional[bool] = None,
1816
+ images: Optional[torch.FloatTensor] = None,
1817
+ return_dict: Optional[bool] = None,
1818
+ ) -> Union[Tuple, CausalLMOutputWithPast]:
1819
+
1820
+ if inputs_embeds is None:
1821
+ (
1822
+ input_ids,
1823
+ position_ids,
1824
+ attention_mask,
1825
+ past_key_values,
1826
+ inputs_embeds,
1827
+ labels
1828
+ ) = self.prepare_inputs_labels_for_multimodal(
1829
+ input_ids,
1830
+ position_ids,
1831
+ attention_mask,
1832
+ past_key_values,
1833
+ labels,
1834
+ images
1835
+ )
1836
+ if inputs_embeds is not None:
1837
+ inputs_embeds *= self.get_model().config.scale_emb
1838
+
1839
+ return super().forward(
1840
+ input_ids=input_ids,
1841
+ attention_mask=attention_mask,
1842
+ position_ids=position_ids,
1843
+ past_key_values=past_key_values,
1844
+ inputs_embeds=inputs_embeds,
1845
+ labels=labels,
1846
+ use_cache=use_cache,
1847
+ output_attentions=output_attentions,
1848
+ output_hidden_states=output_hidden_states,
1849
+ return_dict=return_dict
1850
+ )
1851
+
1852
+ def prepare_inputs_for_generation(self, input_ids, past_key_values=None, inputs_embeds=None, attention_mask=None,
1853
+ **kwargs):
1854
+ images = kwargs.pop("images", None)
1855
+
1856
+ _inputs = super().prepare_inputs_for_generation(
1857
+ input_ids, past_key_values=past_key_values, inputs_embeds=inputs_embeds, attention_mask=attention_mask,
1858
+ **kwargs
1859
+ )
1860
+
1861
+ if images is not None:
1862
+ _inputs['images'] = images
1863
+ return _inputs
1864
+
1865
+ def expand2square(self, pil_img, background_color):
1866
+ width, height = pil_img.size
1867
+ if width == height:
1868
+ return pil_img
1869
+ elif width > height:
1870
+ result = Image.new(pil_img.mode, (width, width), background_color)
1871
+ result.paste(pil_img, (0, (width - height) // 2))
1872
+ return result
1873
+ else:
1874
+ result = Image.new(pil_img.mode, (height, height), background_color)
1875
+ result.paste(pil_img, ((height - width) // 2, 0))
1876
+ return result
1877
+
1878
+ def process_images(self, images, model_cfg):
1879
+ vision_tower = self.get_vision_tower()
1880
+ if not vision_tower.is_loaded:
1881
+ vision_tower.load_model()
1882
+ image_processor = vision_tower.image_processor
1883
+ image_aspect_ratio = getattr(model_cfg, "image_aspect_ratio", None)
1884
+ new_images = []
1885
+ if image_aspect_ratio == 'pad':
1886
+ for image in images:
1887
+ image = self.expand2square(image, tuple(int(x * 255) for x in image_processor.image_mean))
1888
+ image = image_processor.preprocess(image, return_tensors='pt')['pixel_values'][0]
1889
+ new_images.append(image)
1890
+ else:
1891
+ return image_processor(images, return_tensors='pt')['pixel_values']
1892
+ if all(x.shape == new_images[0].shape for x in new_images):
1893
+ new_images = torch.stack(new_images, dim=0)
1894
+ return new_images
1895
+
1896
+
1897
+ AutoConfig.register("bunny-minicpm", BunnyMiniCPMConfig)
1898
+ AutoModelForCausalLM.register(BunnyMiniCPMConfig, BunnyMiniCPMForCausalLM)
special_tokens_map.json ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token": {
3
+ "content": "<s>",
4
+ "lstrip": false,
5
+ "normalized": false,
6
+ "rstrip": false,
7
+ "single_word": false
8
+ },
9
+ "eos_token": {
10
+ "content": "</s>",
11
+ "lstrip": false,
12
+ "normalized": false,
13
+ "rstrip": false,
14
+ "single_word": false
15
+ },
16
+ "unk_token": {
17
+ "content": "<unk>",
18
+ "lstrip": false,
19
+ "normalized": false,
20
+ "rstrip": false,
21
+ "single_word": false
22
+ }
23
+ }
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer.model ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c9aafcd7da1f5611dab6be545db74d5552a2ccc9c2a12c72ea7be63aac4a25d7
3
+ size 1994871
tokenizer_config.json ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_bos_token": true,
3
+ "add_eos_token": false,
4
+ "added_tokens_decoder": {
5
+ "0": {
6
+ "content": "<unk>",
7
+ "lstrip": false,
8
+ "normalized": false,
9
+ "rstrip": false,
10
+ "single_word": false,
11
+ "special": true
12
+ },
13
+ "1": {
14
+ "content": "<s>",
15
+ "lstrip": false,
16
+ "normalized": false,
17
+ "rstrip": false,
18
+ "single_word": false,
19
+ "special": true
20
+ },
21
+ "2": {
22
+ "content": "</s>",
23
+ "lstrip": false,
24
+ "normalized": false,
25
+ "rstrip": false,
26
+ "single_word": false,
27
+ "special": true
28
+ }
29
+ },
30
+ "bos_token": "<s>",
31
+ "chat_template": "{% for message in messages %}{% if message['role'] == 'user' %}{{'<用户>' + message['content'].strip() + '<AI>'}}{% else %}{{message['content'].strip()}}{% endif %}{% endfor %}",
32
+ "clean_up_tokenization_spaces": false,
33
+ "eos_token": "</s>",
34
+ "legacy": true,
35
+ "model_max_length": 1000000000000000019884624838656,
36
+ "pad_token": null,
37
+ "sp_model_kwargs": {},
38
+ "spaces_between_special_tokens": false,
39
+ "tokenizer_class": "LlamaTokenizer",
40
+ "unk_token": "<unk>",
41
+ "use_default_system_prompt": false
42
+ }