Upload InternLMXComposer2ForCausalLM
Browse files- README.md +199 -0
- build_mlp.py +217 -0
- config.json +39 -0
- configuration_internlm_xcomposer2.py +159 -0
- generation_config.json +9 -0
- model-00001-of-00004.safetensors +3 -0
- model-00002-of-00004.safetensors +3 -0
- model-00003-of-00004.safetensors +3 -0
- model-00004-of-00004.safetensors +3 -0
- model.safetensors.index.json +949 -0
- modeling_internlm2.py +965 -0
- modeling_internlm_xcomposer2.py +612 -0
README.md
ADDED
@@ -0,0 +1,199 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
library_name: transformers
|
3 |
+
tags: []
|
4 |
+
---
|
5 |
+
|
6 |
+
# Model Card for Model ID
|
7 |
+
|
8 |
+
<!-- Provide a quick summary of what the model is/does. -->
|
9 |
+
|
10 |
+
|
11 |
+
|
12 |
+
## Model Details
|
13 |
+
|
14 |
+
### Model Description
|
15 |
+
|
16 |
+
<!-- Provide a longer summary of what this model is. -->
|
17 |
+
|
18 |
+
This is the model card of a 🤗 transformers model that has been pushed on the Hub. This model card has been automatically generated.
|
19 |
+
|
20 |
+
- **Developed by:** [More Information Needed]
|
21 |
+
- **Funded by [optional]:** [More Information Needed]
|
22 |
+
- **Shared by [optional]:** [More Information Needed]
|
23 |
+
- **Model type:** [More Information Needed]
|
24 |
+
- **Language(s) (NLP):** [More Information Needed]
|
25 |
+
- **License:** [More Information Needed]
|
26 |
+
- **Finetuned from model [optional]:** [More Information Needed]
|
27 |
+
|
28 |
+
### Model Sources [optional]
|
29 |
+
|
30 |
+
<!-- Provide the basic links for the model. -->
|
31 |
+
|
32 |
+
- **Repository:** [More Information Needed]
|
33 |
+
- **Paper [optional]:** [More Information Needed]
|
34 |
+
- **Demo [optional]:** [More Information Needed]
|
35 |
+
|
36 |
+
## Uses
|
37 |
+
|
38 |
+
<!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
|
39 |
+
|
40 |
+
### Direct Use
|
41 |
+
|
42 |
+
<!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
|
43 |
+
|
44 |
+
[More Information Needed]
|
45 |
+
|
46 |
+
### Downstream Use [optional]
|
47 |
+
|
48 |
+
<!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
|
49 |
+
|
50 |
+
[More Information Needed]
|
51 |
+
|
52 |
+
### Out-of-Scope Use
|
53 |
+
|
54 |
+
<!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
|
55 |
+
|
56 |
+
[More Information Needed]
|
57 |
+
|
58 |
+
## Bias, Risks, and Limitations
|
59 |
+
|
60 |
+
<!-- This section is meant to convey both technical and sociotechnical limitations. -->
|
61 |
+
|
62 |
+
[More Information Needed]
|
63 |
+
|
64 |
+
### Recommendations
|
65 |
+
|
66 |
+
<!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
|
67 |
+
|
68 |
+
Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
|
69 |
+
|
70 |
+
## How to Get Started with the Model
|
71 |
+
|
72 |
+
Use the code below to get started with the model.
|
73 |
+
|
74 |
+
[More Information Needed]
|
75 |
+
|
76 |
+
## Training Details
|
77 |
+
|
78 |
+
### Training Data
|
79 |
+
|
80 |
+
<!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
|
81 |
+
|
82 |
+
[More Information Needed]
|
83 |
+
|
84 |
+
### Training Procedure
|
85 |
+
|
86 |
+
<!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
|
87 |
+
|
88 |
+
#### Preprocessing [optional]
|
89 |
+
|
90 |
+
[More Information Needed]
|
91 |
+
|
92 |
+
|
93 |
+
#### Training Hyperparameters
|
94 |
+
|
95 |
+
- **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
|
96 |
+
|
97 |
+
#### Speeds, Sizes, Times [optional]
|
98 |
+
|
99 |
+
<!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
|
100 |
+
|
101 |
+
[More Information Needed]
|
102 |
+
|
103 |
+
## Evaluation
|
104 |
+
|
105 |
+
<!-- This section describes the evaluation protocols and provides the results. -->
|
106 |
+
|
107 |
+
### Testing Data, Factors & Metrics
|
108 |
+
|
109 |
+
#### Testing Data
|
110 |
+
|
111 |
+
<!-- This should link to a Dataset Card if possible. -->
|
112 |
+
|
113 |
+
[More Information Needed]
|
114 |
+
|
115 |
+
#### Factors
|
116 |
+
|
117 |
+
<!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
|
118 |
+
|
119 |
+
[More Information Needed]
|
120 |
+
|
121 |
+
#### Metrics
|
122 |
+
|
123 |
+
<!-- These are the evaluation metrics being used, ideally with a description of why. -->
|
124 |
+
|
125 |
+
[More Information Needed]
|
126 |
+
|
127 |
+
### Results
|
128 |
+
|
129 |
+
[More Information Needed]
|
130 |
+
|
131 |
+
#### Summary
|
132 |
+
|
133 |
+
|
134 |
+
|
135 |
+
## Model Examination [optional]
|
136 |
+
|
137 |
+
<!-- Relevant interpretability work for the model goes here -->
|
138 |
+
|
139 |
+
[More Information Needed]
|
140 |
+
|
141 |
+
## Environmental Impact
|
142 |
+
|
143 |
+
<!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
|
144 |
+
|
145 |
+
Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
|
146 |
+
|
147 |
+
- **Hardware Type:** [More Information Needed]
|
148 |
+
- **Hours used:** [More Information Needed]
|
149 |
+
- **Cloud Provider:** [More Information Needed]
|
150 |
+
- **Compute Region:** [More Information Needed]
|
151 |
+
- **Carbon Emitted:** [More Information Needed]
|
152 |
+
|
153 |
+
## Technical Specifications [optional]
|
154 |
+
|
155 |
+
### Model Architecture and Objective
|
156 |
+
|
157 |
+
[More Information Needed]
|
158 |
+
|
159 |
+
### Compute Infrastructure
|
160 |
+
|
161 |
+
[More Information Needed]
|
162 |
+
|
163 |
+
#### Hardware
|
164 |
+
|
165 |
+
[More Information Needed]
|
166 |
+
|
167 |
+
#### Software
|
168 |
+
|
169 |
+
[More Information Needed]
|
170 |
+
|
171 |
+
## Citation [optional]
|
172 |
+
|
173 |
+
<!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
|
174 |
+
|
175 |
+
**BibTeX:**
|
176 |
+
|
177 |
+
[More Information Needed]
|
178 |
+
|
179 |
+
**APA:**
|
180 |
+
|
181 |
+
[More Information Needed]
|
182 |
+
|
183 |
+
## Glossary [optional]
|
184 |
+
|
185 |
+
<!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
|
186 |
+
|
187 |
+
[More Information Needed]
|
188 |
+
|
189 |
+
## More Information [optional]
|
190 |
+
|
191 |
+
[More Information Needed]
|
192 |
+
|
193 |
+
## Model Card Authors [optional]
|
194 |
+
|
195 |
+
[More Information Needed]
|
196 |
+
|
197 |
+
## Model Card Contact
|
198 |
+
|
199 |
+
[More Information Needed]
|
build_mlp.py
ADDED
@@ -0,0 +1,217 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import math
|
2 |
+
import re
|
3 |
+
|
4 |
+
import torch
|
5 |
+
import torch.nn as nn
|
6 |
+
from transformers import CLIPVisionModel
|
7 |
+
|
8 |
+
|
9 |
+
def build_vision_tower():
|
10 |
+
vision_tower = 'openai/clip-vit-large-patch14-336'
|
11 |
+
return CLIPVisionTower(vision_tower)
|
12 |
+
|
13 |
+
|
14 |
+
def build_vision_projector():
|
15 |
+
projector_type = 'mlp2x_gelu'
|
16 |
+
mm_hidden_size = 1024
|
17 |
+
hidden_size = 4096
|
18 |
+
|
19 |
+
mlp_gelu_match = re.match(r'^mlp(\d+)x_gelu$', projector_type)
|
20 |
+
if mlp_gelu_match:
|
21 |
+
mlp_depth = int(mlp_gelu_match.group(1))
|
22 |
+
modules = [nn.Linear(mm_hidden_size, hidden_size)]
|
23 |
+
for _ in range(1, mlp_depth):
|
24 |
+
modules.append(nn.GELU())
|
25 |
+
modules.append(nn.Linear(hidden_size, hidden_size))
|
26 |
+
return nn.Sequential(*modules)
|
27 |
+
|
28 |
+
if projector_type == 'identity':
|
29 |
+
return IdentityMap()
|
30 |
+
|
31 |
+
raise ValueError(f'Unknown projector type: {projector_type}')
|
32 |
+
|
33 |
+
|
34 |
+
class IdentityMap(nn.Module):
|
35 |
+
|
36 |
+
def __init__(self):
|
37 |
+
super().__init__()
|
38 |
+
|
39 |
+
def forward(self, x, *args, **kwargs):
|
40 |
+
return x
|
41 |
+
|
42 |
+
@property
|
43 |
+
def config(self):
|
44 |
+
return {'mm_projector_type': 'identity'}
|
45 |
+
|
46 |
+
|
47 |
+
class CLIPVisionTower(nn.Module):
|
48 |
+
|
49 |
+
def __init__(self, vision_tower):
|
50 |
+
super().__init__()
|
51 |
+
|
52 |
+
self.is_loaded = False
|
53 |
+
self.is_resize_pos = False
|
54 |
+
|
55 |
+
self.vision_tower_name = vision_tower
|
56 |
+
self.select_layer = -1
|
57 |
+
self.select_feature = 'patch'
|
58 |
+
self.load_model()
|
59 |
+
self.resize_pos()
|
60 |
+
|
61 |
+
def load_model(self):
|
62 |
+
self.vision_tower = CLIPVisionModel.from_pretrained(
|
63 |
+
self.vision_tower_name)
|
64 |
+
self.vision_tower.requires_grad_(False)
|
65 |
+
|
66 |
+
self.is_loaded = True
|
67 |
+
|
68 |
+
def resize_pos(self):
|
69 |
+
pos_embed_checkpoint = self.vision_tower.vision_model.embeddings.position_embedding.weight
|
70 |
+
pos_embed_checkpoint = pos_embed_checkpoint.unsqueeze(0)
|
71 |
+
orig_size = 24
|
72 |
+
new_size = 35
|
73 |
+
|
74 |
+
if pos_embed_checkpoint.shape[1] == new_size**2 + 1:
|
75 |
+
self.is_resize_pos = True
|
76 |
+
else:
|
77 |
+
embedding_size = pos_embed_checkpoint.shape[-1]
|
78 |
+
num_extra_tokens = 1
|
79 |
+
new_num = new_size**2 + num_extra_tokens
|
80 |
+
#print('Position interpolate from %dx%d to %dx%d' %
|
81 |
+
# (orig_size, orig_size, new_size, new_size))
|
82 |
+
extra_tokens = pos_embed_checkpoint[:, :num_extra_tokens]
|
83 |
+
# only the position tokens are interpolated
|
84 |
+
pos_tokens = pos_embed_checkpoint[:, num_extra_tokens:]
|
85 |
+
pos_tokens = pos_tokens.reshape(-1, orig_size, orig_size,
|
86 |
+
embedding_size).permute(
|
87 |
+
0, 3, 1, 2)
|
88 |
+
pos_tokens = torch.nn.functional.interpolate(
|
89 |
+
pos_tokens,
|
90 |
+
size=(new_size, new_size),
|
91 |
+
mode='bicubic',
|
92 |
+
align_corners=False)
|
93 |
+
pos_tokens = pos_tokens.permute(0, 2, 3, 1).flatten(1, 2)
|
94 |
+
new_pos_embed = torch.cat((extra_tokens, pos_tokens), dim=1)
|
95 |
+
|
96 |
+
new_pos_embed = new_pos_embed.squeeze(0)
|
97 |
+
|
98 |
+
self.vision_tower.vision_model.embeddings.position_embedding = torch.nn.Embedding(
|
99 |
+
new_num, 1024)
|
100 |
+
self.vision_tower.vision_model.embeddings.position_embedding.weight = torch.nn.Parameter(
|
101 |
+
new_pos_embed.to(pos_embed_checkpoint.dtype))
|
102 |
+
self.vision_tower.vision_model.embeddings.position_ids = torch.arange(
|
103 |
+
new_num).expand((1, -1))
|
104 |
+
|
105 |
+
self.is_resize_pos = True
|
106 |
+
|
107 |
+
def feature_select(self, image_forward_outs):
|
108 |
+
image_features = image_forward_outs.hidden_states[self.select_layer]
|
109 |
+
if self.select_feature == 'patch':
|
110 |
+
image_features = image_features[:, 1:]
|
111 |
+
elif self.select_feature == 'cls_patch':
|
112 |
+
image_features = image_features
|
113 |
+
else:
|
114 |
+
raise ValueError(
|
115 |
+
f'Unexpected select feature: {self.select_feature}')
|
116 |
+
return image_features
|
117 |
+
|
118 |
+
def forward(self, images):
|
119 |
+
if not self.is_loaded:
|
120 |
+
self.load_model()
|
121 |
+
if type(images) is list:
|
122 |
+
image_features = []
|
123 |
+
for image in images:
|
124 |
+
image_forward_out = self.vision_tower(
|
125 |
+
image.to(device=self.device,
|
126 |
+
dtype=self.dtype).unsqueeze(0),
|
127 |
+
output_hidden_states=True)
|
128 |
+
image_feature = self.feature_select(image_forward_out).to(
|
129 |
+
image.dtype)
|
130 |
+
image_features.append(image_feature)
|
131 |
+
else:
|
132 |
+
image_forward_outs = self.vision_tower(
|
133 |
+
images.to(device=self.device, dtype=self.dtype),
|
134 |
+
output_hidden_states=True)
|
135 |
+
image_features = self.feature_select(image_forward_outs).to(
|
136 |
+
images.dtype)
|
137 |
+
|
138 |
+
return image_features
|
139 |
+
|
140 |
+
@property
|
141 |
+
def dummy_feature(self):
|
142 |
+
return torch.zeros(
|
143 |
+
1, self.hidden_size, device=self.device, dtype=self.dtype)
|
144 |
+
|
145 |
+
@property
|
146 |
+
def dtype(self):
|
147 |
+
return self.vision_tower.dtype
|
148 |
+
|
149 |
+
@property
|
150 |
+
def device(self):
|
151 |
+
return self.vision_tower.device
|
152 |
+
|
153 |
+
@property
|
154 |
+
def config(self):
|
155 |
+
if self.is_loaded:
|
156 |
+
return self.vision_tower.config
|
157 |
+
else:
|
158 |
+
return self.cfg_only
|
159 |
+
|
160 |
+
@property
|
161 |
+
def hidden_size(self):
|
162 |
+
return self.config.hidden_size
|
163 |
+
|
164 |
+
@property
|
165 |
+
def num_patches(self):
|
166 |
+
return (self.config.image_size // self.config.patch_size)**2
|
167 |
+
|
168 |
+
|
169 |
+
class PLoRA(nn.Linear):
|
170 |
+
|
171 |
+
def __init__(self,
|
172 |
+
in_features: int,
|
173 |
+
out_features: int,
|
174 |
+
bias: bool = True,
|
175 |
+
device=None,
|
176 |
+
dtype=None,
|
177 |
+
lora_r=8,
|
178 |
+
lora_alpha=16,
|
179 |
+
lora_dropout=0.05,
|
180 |
+
lora_len=0,
|
181 |
+
**kwargs) -> None:
|
182 |
+
super().__init__(in_features, out_features, bias, device, dtype)
|
183 |
+
self.lora_r = lora_r
|
184 |
+
self.lora_alpha = lora_alpha
|
185 |
+
self.lora_len = lora_len
|
186 |
+
if lora_dropout > 0.:
|
187 |
+
self.lora_dropout = nn.Dropout(p=lora_dropout)
|
188 |
+
else:
|
189 |
+
self.lora_dropout = lambda x: x
|
190 |
+
self.lora_scaling = self.lora_alpha / self.lora_r
|
191 |
+
|
192 |
+
self.Plora_A = nn.Linear(
|
193 |
+
in_features, self.lora_r, bias=False, device=device, dtype=dtype)
|
194 |
+
self.Plora_B = nn.Linear(
|
195 |
+
self.lora_r, out_features, bias=False, device=device, dtype=dtype)
|
196 |
+
|
197 |
+
self.reset_parameters()
|
198 |
+
|
199 |
+
def reset_parameters(self):
|
200 |
+
if hasattr(self, 'lora_A'):
|
201 |
+
# initialize A the same way as the default for nn.Linear and B to zero
|
202 |
+
nn.init.kaiming_uniform_(self.lora_A.weight, a=math.sqrt(5))
|
203 |
+
nn.init.zeros_(self.lora_B.weight)
|
204 |
+
|
205 |
+
def forward(self, x, im_mask=None):
|
206 |
+
res = super().forward(x)
|
207 |
+
if im_mask is not None:
|
208 |
+
if torch.sum(im_mask) > 0:
|
209 |
+
part_x = x[im_mask]
|
210 |
+
res[im_mask] += self.Plora_B(
|
211 |
+
self.Plora_A(
|
212 |
+
self.lora_dropout(part_x))) * self.lora_scaling
|
213 |
+
else:
|
214 |
+
part_x = x[:, :1]
|
215 |
+
res[:, :1] += self.Plora_B(
|
216 |
+
self.Plora_A(self.lora_dropout(part_x))) * 0
|
217 |
+
return res
|
config.json
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_name_or_path": "ckpts/internlm-xcomposer2-vl-7b-dpo/bs128_ep1_mg0_bt0.1_lr1e-5_VLFeedback/merged",
|
3 |
+
"architectures": [
|
4 |
+
"InternLMXComposer2ForCausalLM"
|
5 |
+
],
|
6 |
+
"auto_map": {
|
7 |
+
"AutoConfig": "configuration_internlm_xcomposer2.InternLMXcomposer2Config",
|
8 |
+
"AutoModel": "modeling_internlm_xcomposer2.InternLMXComposer2ForCausalLM",
|
9 |
+
"AutoModelForCausalLM": "modeling_internlm_xcomposer2.InternLMXComposer2ForCausalLM"
|
10 |
+
},
|
11 |
+
"bias": false,
|
12 |
+
"bos_token_id": 1,
|
13 |
+
"eos_token_id": 2,
|
14 |
+
"hidden_act": "silu",
|
15 |
+
"hidden_size": 4096,
|
16 |
+
"ignore_index": -100,
|
17 |
+
"image_token_index": 92544,
|
18 |
+
"img_size": 490,
|
19 |
+
"initializer_range": 0.02,
|
20 |
+
"intermediate_size": 14336,
|
21 |
+
"max_length": 4096,
|
22 |
+
"max_position_embeddings": 32768,
|
23 |
+
"model_type": "internlm",
|
24 |
+
"num_attention_heads": 32,
|
25 |
+
"num_hidden_layers": 32,
|
26 |
+
"num_key_value_heads": 8,
|
27 |
+
"pad_token_id": 2,
|
28 |
+
"rms_norm_eps": 1e-05,
|
29 |
+
"rope_scaling": {
|
30 |
+
"factor": 1.0,
|
31 |
+
"type": "dynamic"
|
32 |
+
},
|
33 |
+
"rope_theta": 1000000,
|
34 |
+
"tie_word_embeddings": false,
|
35 |
+
"torch_dtype": "float16",
|
36 |
+
"transformers_version": "4.41.0",
|
37 |
+
"use_cache": false,
|
38 |
+
"vocab_size": 92544
|
39 |
+
}
|
configuration_internlm_xcomposer2.py
ADDED
@@ -0,0 +1,159 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# coding=utf-8
|
2 |
+
# Copyright (c) InternLM. 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 |
+
""" InternLM 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 |
+
INTERNLM_PRETRAINED_CONFIG_ARCHIVE_MAP = {}
|
28 |
+
|
29 |
+
|
30 |
+
class InternLMXcomposer2Config(PretrainedConfig):
|
31 |
+
r"""
|
32 |
+
This is the configuration class to store the configuration of a [`InternLMModel`]. It is used to instantiate
|
33 |
+
an InternLM model according to the specified arguments, defining the model architecture. Instantiating a
|
34 |
+
configuration with the defaults will yield a similar configuration to that of the InternLM-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 InternLM model. Defines the number of different tokens that can be represented by the
|
43 |
+
`inputs_ids` passed when calling [`InternLMModel`]
|
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 encoder.
|
50 |
+
num_attention_heads (`int`, *optional*, defaults to 32):
|
51 |
+
Number of attention heads for each attention layer in the Transformer encoder.
|
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. Typically set this to something large
|
64 |
+
just in case (e.g., 512 or 1024 or 2048).
|
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-12):
|
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 |
+
tie_word_embeddings(`bool`, *optional*, defaults to `False`):
|
73 |
+
Whether to tie weight embeddings
|
74 |
+
Example:
|
75 |
+
|
76 |
+
```python
|
77 |
+
>>> from transformers import InternLMModel, InternLMConfig
|
78 |
+
|
79 |
+
>>> # Initializing a InternLM internlm-7b style configuration
|
80 |
+
>>> configuration = InternLMConfig()
|
81 |
+
|
82 |
+
>>> # Initializing a model from the internlm-7b style configuration
|
83 |
+
>>> model = InternLMModel(configuration)
|
84 |
+
|
85 |
+
>>> # Accessing the model configuration
|
86 |
+
>>> configuration = model.config
|
87 |
+
```"""
|
88 |
+
model_type = "internlm"
|
89 |
+
_auto_class = "AutoConfig"
|
90 |
+
|
91 |
+
def __init__( # pylint: disable=W0102
|
92 |
+
self,
|
93 |
+
vocab_size=103168,
|
94 |
+
hidden_size=4096,
|
95 |
+
intermediate_size=11008,
|
96 |
+
num_hidden_layers=32,
|
97 |
+
num_attention_heads=32,
|
98 |
+
num_key_value_heads=None,
|
99 |
+
hidden_act="silu",
|
100 |
+
max_position_embeddings=2048,
|
101 |
+
initializer_range=0.02,
|
102 |
+
rms_norm_eps=1e-6,
|
103 |
+
use_cache=True,
|
104 |
+
pad_token_id=0,
|
105 |
+
bos_token_id=1,
|
106 |
+
eos_token_id=2,
|
107 |
+
tie_word_embeddings=False,
|
108 |
+
bias=True,
|
109 |
+
rope_theta=10000,
|
110 |
+
rope_scaling=None,
|
111 |
+
**kwargs,
|
112 |
+
):
|
113 |
+
self.vocab_size = vocab_size
|
114 |
+
self.max_position_embeddings = max_position_embeddings
|
115 |
+
self.hidden_size = hidden_size
|
116 |
+
self.intermediate_size = intermediate_size
|
117 |
+
self.num_hidden_layers = num_hidden_layers
|
118 |
+
self.num_attention_heads = num_attention_heads
|
119 |
+
self.bias = bias
|
120 |
+
|
121 |
+
if num_key_value_heads is None:
|
122 |
+
num_key_value_heads = num_attention_heads
|
123 |
+
self.num_key_value_heads = num_key_value_heads
|
124 |
+
|
125 |
+
self.hidden_act = hidden_act
|
126 |
+
self.initializer_range = initializer_range
|
127 |
+
self.rms_norm_eps = rms_norm_eps
|
128 |
+
self.use_cache = use_cache
|
129 |
+
self.rope_theta = rope_theta
|
130 |
+
self.rope_scaling = rope_scaling
|
131 |
+
self._rope_scaling_validation()
|
132 |
+
super().__init__(
|
133 |
+
pad_token_id=pad_token_id,
|
134 |
+
bos_token_id=bos_token_id,
|
135 |
+
eos_token_id=eos_token_id,
|
136 |
+
tie_word_embeddings=tie_word_embeddings,
|
137 |
+
**kwargs,
|
138 |
+
)
|
139 |
+
|
140 |
+
def _rope_scaling_validation(self):
|
141 |
+
"""
|
142 |
+
Validate the `rope_scaling` configuration.
|
143 |
+
"""
|
144 |
+
if self.rope_scaling is None:
|
145 |
+
return
|
146 |
+
|
147 |
+
if not isinstance(self.rope_scaling, dict) or len(self.rope_scaling) != 2:
|
148 |
+
raise ValueError(
|
149 |
+
"`rope_scaling` must be a dictionary with with two fields, `type` and `factor`, "
|
150 |
+
f"got {self.rope_scaling}"
|
151 |
+
)
|
152 |
+
rope_scaling_type = self.rope_scaling.get("type", None)
|
153 |
+
rope_scaling_factor = self.rope_scaling.get("factor", None)
|
154 |
+
if rope_scaling_type is None or rope_scaling_type not in ["linear", "dynamic"]:
|
155 |
+
raise ValueError(
|
156 |
+
f"`rope_scaling`'s type field must be one of ['linear', 'dynamic'], got {rope_scaling_type}"
|
157 |
+
)
|
158 |
+
if rope_scaling_factor is None or not isinstance(rope_scaling_factor, float) or rope_scaling_factor < 1.0:
|
159 |
+
raise ValueError(f"`rope_scaling`'s factor field must be a float >= 1, got {rope_scaling_factor}")
|
generation_config.json
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_from_model_config": true,
|
3 |
+
"bos_token_id": 1,
|
4 |
+
"eos_token_id": 2,
|
5 |
+
"max_length": 1600,
|
6 |
+
"pad_token_id": 2,
|
7 |
+
"transformers_version": "4.41.0",
|
8 |
+
"use_cache": false
|
9 |
+
}
|
model-00001-of-00004.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:7ed08aac7bbabceb9cd2918b2475878451908206b5ce54cc4a48f15adf2648f4
|
3 |
+
size 4896998472
|
model-00002-of-00004.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:fd8be693b323a516a80269ee7459b4a231a1793450c0e9145f211432e35ceac4
|
3 |
+
size 4959966088
|
model-00003-of-00004.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:881c6614d536c81c46cdb6757b2935263390e60cd5db76003fd9ae7e457b347e
|
3 |
+
size 4993503600
|
model-00004-of-00004.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:95c2d0daaa83b0d8666f5aadce6269cca5faed7db902163b3ccfa6600dc009b3
|
3 |
+
size 2483331928
|
model.safetensors.index.json
ADDED
@@ -0,0 +1,949 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"metadata": {
|
3 |
+
"total_size": 17333680128
|
4 |
+
},
|
5 |
+
"weight_map": {
|
6 |
+
"model.layers.0.attention.wo.Plora_A.weight": "model-00001-of-00004.safetensors",
|
7 |
+
"model.layers.0.attention.wo.Plora_B.weight": "model-00001-of-00004.safetensors",
|
8 |
+
"model.layers.0.attention.wo.weight": "model-00001-of-00004.safetensors",
|
9 |
+
"model.layers.0.attention.wqkv.Plora_A.weight": "model-00001-of-00004.safetensors",
|
10 |
+
"model.layers.0.attention.wqkv.Plora_B.weight": "model-00001-of-00004.safetensors",
|
11 |
+
"model.layers.0.attention.wqkv.weight": "model-00001-of-00004.safetensors",
|
12 |
+
"model.layers.0.attention_norm.weight": "model-00001-of-00004.safetensors",
|
13 |
+
"model.layers.0.feed_forward.w1.Plora_A.weight": "model-00001-of-00004.safetensors",
|
14 |
+
"model.layers.0.feed_forward.w1.Plora_B.weight": "model-00001-of-00004.safetensors",
|
15 |
+
"model.layers.0.feed_forward.w1.weight": "model-00001-of-00004.safetensors",
|
16 |
+
"model.layers.0.feed_forward.w2.Plora_A.weight": "model-00001-of-00004.safetensors",
|
17 |
+
"model.layers.0.feed_forward.w2.Plora_B.weight": "model-00001-of-00004.safetensors",
|
18 |
+
"model.layers.0.feed_forward.w2.weight": "model-00001-of-00004.safetensors",
|
19 |
+
"model.layers.0.feed_forward.w3.Plora_A.weight": "model-00001-of-00004.safetensors",
|
20 |
+
"model.layers.0.feed_forward.w3.Plora_B.weight": "model-00001-of-00004.safetensors",
|
21 |
+
"model.layers.0.feed_forward.w3.weight": "model-00001-of-00004.safetensors",
|
22 |
+
"model.layers.0.ffn_norm.weight": "model-00001-of-00004.safetensors",
|
23 |
+
"model.layers.1.attention.wo.Plora_A.weight": "model-00001-of-00004.safetensors",
|
24 |
+
"model.layers.1.attention.wo.Plora_B.weight": "model-00001-of-00004.safetensors",
|
25 |
+
"model.layers.1.attention.wo.weight": "model-00001-of-00004.safetensors",
|
26 |
+
"model.layers.1.attention.wqkv.Plora_A.weight": "model-00001-of-00004.safetensors",
|
27 |
+
"model.layers.1.attention.wqkv.Plora_B.weight": "model-00001-of-00004.safetensors",
|
28 |
+
"model.layers.1.attention.wqkv.weight": "model-00001-of-00004.safetensors",
|
29 |
+
"model.layers.1.attention_norm.weight": "model-00001-of-00004.safetensors",
|
30 |
+
"model.layers.1.feed_forward.w1.Plora_A.weight": "model-00001-of-00004.safetensors",
|
31 |
+
"model.layers.1.feed_forward.w1.Plora_B.weight": "model-00001-of-00004.safetensors",
|
32 |
+
"model.layers.1.feed_forward.w1.weight": "model-00001-of-00004.safetensors",
|
33 |
+
"model.layers.1.feed_forward.w2.Plora_A.weight": "model-00001-of-00004.safetensors",
|
34 |
+
"model.layers.1.feed_forward.w2.Plora_B.weight": "model-00001-of-00004.safetensors",
|
35 |
+
"model.layers.1.feed_forward.w2.weight": "model-00001-of-00004.safetensors",
|
36 |
+
"model.layers.1.feed_forward.w3.Plora_A.weight": "model-00001-of-00004.safetensors",
|
37 |
+
"model.layers.1.feed_forward.w3.Plora_B.weight": "model-00001-of-00004.safetensors",
|
38 |
+
"model.layers.1.feed_forward.w3.weight": "model-00001-of-00004.safetensors",
|
39 |
+
"model.layers.1.ffn_norm.weight": "model-00001-of-00004.safetensors",
|
40 |
+
"model.layers.10.attention.wo.Plora_A.weight": "model-00002-of-00004.safetensors",
|
41 |
+
"model.layers.10.attention.wo.Plora_B.weight": "model-00002-of-00004.safetensors",
|
42 |
+
"model.layers.10.attention.wo.weight": "model-00002-of-00004.safetensors",
|
43 |
+
"model.layers.10.attention.wqkv.Plora_A.weight": "model-00002-of-00004.safetensors",
|
44 |
+
"model.layers.10.attention.wqkv.Plora_B.weight": "model-00002-of-00004.safetensors",
|
45 |
+
"model.layers.10.attention.wqkv.weight": "model-00002-of-00004.safetensors",
|
46 |
+
"model.layers.10.attention_norm.weight": "model-00002-of-00004.safetensors",
|
47 |
+
"model.layers.10.feed_forward.w1.Plora_A.weight": "model-00002-of-00004.safetensors",
|
48 |
+
"model.layers.10.feed_forward.w1.Plora_B.weight": "model-00002-of-00004.safetensors",
|
49 |
+
"model.layers.10.feed_forward.w1.weight": "model-00002-of-00004.safetensors",
|
50 |
+
"model.layers.10.feed_forward.w2.Plora_A.weight": "model-00002-of-00004.safetensors",
|
51 |
+
"model.layers.10.feed_forward.w2.Plora_B.weight": "model-00002-of-00004.safetensors",
|
52 |
+
"model.layers.10.feed_forward.w2.weight": "model-00002-of-00004.safetensors",
|
53 |
+
"model.layers.10.feed_forward.w3.Plora_A.weight": "model-00002-of-00004.safetensors",
|
54 |
+
"model.layers.10.feed_forward.w3.Plora_B.weight": "model-00002-of-00004.safetensors",
|
55 |
+
"model.layers.10.feed_forward.w3.weight": "model-00002-of-00004.safetensors",
|
56 |
+
"model.layers.10.ffn_norm.weight": "model-00002-of-00004.safetensors",
|
57 |
+
"model.layers.11.attention.wo.Plora_A.weight": "model-00002-of-00004.safetensors",
|
58 |
+
"model.layers.11.attention.wo.Plora_B.weight": "model-00002-of-00004.safetensors",
|
59 |
+
"model.layers.11.attention.wo.weight": "model-00002-of-00004.safetensors",
|
60 |
+
"model.layers.11.attention.wqkv.Plora_A.weight": "model-00002-of-00004.safetensors",
|
61 |
+
"model.layers.11.attention.wqkv.Plora_B.weight": "model-00002-of-00004.safetensors",
|
62 |
+
"model.layers.11.attention.wqkv.weight": "model-00002-of-00004.safetensors",
|
63 |
+
"model.layers.11.attention_norm.weight": "model-00002-of-00004.safetensors",
|
64 |
+
"model.layers.11.feed_forward.w1.Plora_A.weight": "model-00002-of-00004.safetensors",
|
65 |
+
"model.layers.11.feed_forward.w1.Plora_B.weight": "model-00002-of-00004.safetensors",
|
66 |
+
"model.layers.11.feed_forward.w1.weight": "model-00002-of-00004.safetensors",
|
67 |
+
"model.layers.11.feed_forward.w2.Plora_A.weight": "model-00002-of-00004.safetensors",
|
68 |
+
"model.layers.11.feed_forward.w2.Plora_B.weight": "model-00002-of-00004.safetensors",
|
69 |
+
"model.layers.11.feed_forward.w2.weight": "model-00002-of-00004.safetensors",
|
70 |
+
"model.layers.11.feed_forward.w3.Plora_A.weight": "model-00002-of-00004.safetensors",
|
71 |
+
"model.layers.11.feed_forward.w3.Plora_B.weight": "model-00002-of-00004.safetensors",
|
72 |
+
"model.layers.11.feed_forward.w3.weight": "model-00002-of-00004.safetensors",
|
73 |
+
"model.layers.11.ffn_norm.weight": "model-00002-of-00004.safetensors",
|
74 |
+
"model.layers.12.attention.wo.Plora_A.weight": "model-00002-of-00004.safetensors",
|
75 |
+
"model.layers.12.attention.wo.Plora_B.weight": "model-00002-of-00004.safetensors",
|
76 |
+
"model.layers.12.attention.wo.weight": "model-00002-of-00004.safetensors",
|
77 |
+
"model.layers.12.attention.wqkv.Plora_A.weight": "model-00002-of-00004.safetensors",
|
78 |
+
"model.layers.12.attention.wqkv.Plora_B.weight": "model-00002-of-00004.safetensors",
|
79 |
+
"model.layers.12.attention.wqkv.weight": "model-00002-of-00004.safetensors",
|
80 |
+
"model.layers.12.attention_norm.weight": "model-00002-of-00004.safetensors",
|
81 |
+
"model.layers.12.feed_forward.w1.Plora_A.weight": "model-00002-of-00004.safetensors",
|
82 |
+
"model.layers.12.feed_forward.w1.Plora_B.weight": "model-00002-of-00004.safetensors",
|
83 |
+
"model.layers.12.feed_forward.w1.weight": "model-00002-of-00004.safetensors",
|
84 |
+
"model.layers.12.feed_forward.w2.Plora_A.weight": "model-00002-of-00004.safetensors",
|
85 |
+
"model.layers.12.feed_forward.w2.Plora_B.weight": "model-00002-of-00004.safetensors",
|
86 |
+
"model.layers.12.feed_forward.w2.weight": "model-00002-of-00004.safetensors",
|
87 |
+
"model.layers.12.feed_forward.w3.Plora_A.weight": "model-00002-of-00004.safetensors",
|
88 |
+
"model.layers.12.feed_forward.w3.Plora_B.weight": "model-00002-of-00004.safetensors",
|
89 |
+
"model.layers.12.feed_forward.w3.weight": "model-00002-of-00004.safetensors",
|
90 |
+
"model.layers.12.ffn_norm.weight": "model-00002-of-00004.safetensors",
|
91 |
+
"model.layers.13.attention.wo.Plora_A.weight": "model-00002-of-00004.safetensors",
|
92 |
+
"model.layers.13.attention.wo.Plora_B.weight": "model-00002-of-00004.safetensors",
|
93 |
+
"model.layers.13.attention.wo.weight": "model-00002-of-00004.safetensors",
|
94 |
+
"model.layers.13.attention.wqkv.Plora_A.weight": "model-00002-of-00004.safetensors",
|
95 |
+
"model.layers.13.attention.wqkv.Plora_B.weight": "model-00002-of-00004.safetensors",
|
96 |
+
"model.layers.13.attention.wqkv.weight": "model-00002-of-00004.safetensors",
|
97 |
+
"model.layers.13.attention_norm.weight": "model-00002-of-00004.safetensors",
|
98 |
+
"model.layers.13.feed_forward.w1.Plora_A.weight": "model-00002-of-00004.safetensors",
|
99 |
+
"model.layers.13.feed_forward.w1.Plora_B.weight": "model-00002-of-00004.safetensors",
|
100 |
+
"model.layers.13.feed_forward.w1.weight": "model-00002-of-00004.safetensors",
|
101 |
+
"model.layers.13.feed_forward.w2.Plora_A.weight": "model-00002-of-00004.safetensors",
|
102 |
+
"model.layers.13.feed_forward.w2.Plora_B.weight": "model-00002-of-00004.safetensors",
|
103 |
+
"model.layers.13.feed_forward.w2.weight": "model-00002-of-00004.safetensors",
|
104 |
+
"model.layers.13.feed_forward.w3.Plora_A.weight": "model-00002-of-00004.safetensors",
|
105 |
+
"model.layers.13.feed_forward.w3.Plora_B.weight": "model-00002-of-00004.safetensors",
|
106 |
+
"model.layers.13.feed_forward.w3.weight": "model-00002-of-00004.safetensors",
|
107 |
+
"model.layers.13.ffn_norm.weight": "model-00002-of-00004.safetensors",
|
108 |
+
"model.layers.14.attention.wo.Plora_A.weight": "model-00002-of-00004.safetensors",
|
109 |
+
"model.layers.14.attention.wo.Plora_B.weight": "model-00002-of-00004.safetensors",
|
110 |
+
"model.layers.14.attention.wo.weight": "model-00002-of-00004.safetensors",
|
111 |
+
"model.layers.14.attention.wqkv.Plora_A.weight": "model-00002-of-00004.safetensors",
|
112 |
+
"model.layers.14.attention.wqkv.Plora_B.weight": "model-00002-of-00004.safetensors",
|
113 |
+
"model.layers.14.attention.wqkv.weight": "model-00002-of-00004.safetensors",
|
114 |
+
"model.layers.14.attention_norm.weight": "model-00002-of-00004.safetensors",
|
115 |
+
"model.layers.14.feed_forward.w1.Plora_A.weight": "model-00002-of-00004.safetensors",
|
116 |
+
"model.layers.14.feed_forward.w1.Plora_B.weight": "model-00002-of-00004.safetensors",
|
117 |
+
"model.layers.14.feed_forward.w1.weight": "model-00002-of-00004.safetensors",
|
118 |
+
"model.layers.14.feed_forward.w2.Plora_A.weight": "model-00002-of-00004.safetensors",
|
119 |
+
"model.layers.14.feed_forward.w2.Plora_B.weight": "model-00002-of-00004.safetensors",
|
120 |
+
"model.layers.14.feed_forward.w2.weight": "model-00002-of-00004.safetensors",
|
121 |
+
"model.layers.14.feed_forward.w3.Plora_A.weight": "model-00002-of-00004.safetensors",
|
122 |
+
"model.layers.14.feed_forward.w3.Plora_B.weight": "model-00002-of-00004.safetensors",
|
123 |
+
"model.layers.14.feed_forward.w3.weight": "model-00002-of-00004.safetensors",
|
124 |
+
"model.layers.14.ffn_norm.weight": "model-00002-of-00004.safetensors",
|
125 |
+
"model.layers.15.attention.wo.Plora_A.weight": "model-00002-of-00004.safetensors",
|
126 |
+
"model.layers.15.attention.wo.Plora_B.weight": "model-00002-of-00004.safetensors",
|
127 |
+
"model.layers.15.attention.wo.weight": "model-00002-of-00004.safetensors",
|
128 |
+
"model.layers.15.attention.wqkv.Plora_A.weight": "model-00002-of-00004.safetensors",
|
129 |
+
"model.layers.15.attention.wqkv.Plora_B.weight": "model-00002-of-00004.safetensors",
|
130 |
+
"model.layers.15.attention.wqkv.weight": "model-00002-of-00004.safetensors",
|
131 |
+
"model.layers.15.attention_norm.weight": "model-00002-of-00004.safetensors",
|
132 |
+
"model.layers.15.feed_forward.w1.Plora_A.weight": "model-00002-of-00004.safetensors",
|
133 |
+
"model.layers.15.feed_forward.w1.Plora_B.weight": "model-00002-of-00004.safetensors",
|
134 |
+
"model.layers.15.feed_forward.w1.weight": "model-00002-of-00004.safetensors",
|
135 |
+
"model.layers.15.feed_forward.w2.Plora_A.weight": "model-00002-of-00004.safetensors",
|
136 |
+
"model.layers.15.feed_forward.w2.Plora_B.weight": "model-00002-of-00004.safetensors",
|
137 |
+
"model.layers.15.feed_forward.w2.weight": "model-00002-of-00004.safetensors",
|
138 |
+
"model.layers.15.feed_forward.w3.Plora_A.weight": "model-00002-of-00004.safetensors",
|
139 |
+
"model.layers.15.feed_forward.w3.Plora_B.weight": "model-00002-of-00004.safetensors",
|
140 |
+
"model.layers.15.feed_forward.w3.weight": "model-00002-of-00004.safetensors",
|
141 |
+
"model.layers.15.ffn_norm.weight": "model-00002-of-00004.safetensors",
|
142 |
+
"model.layers.16.attention.wo.Plora_A.weight": "model-00002-of-00004.safetensors",
|
143 |
+
"model.layers.16.attention.wo.Plora_B.weight": "model-00002-of-00004.safetensors",
|
144 |
+
"model.layers.16.attention.wo.weight": "model-00002-of-00004.safetensors",
|
145 |
+
"model.layers.16.attention.wqkv.Plora_A.weight": "model-00002-of-00004.safetensors",
|
146 |
+
"model.layers.16.attention.wqkv.Plora_B.weight": "model-00002-of-00004.safetensors",
|
147 |
+
"model.layers.16.attention.wqkv.weight": "model-00002-of-00004.safetensors",
|
148 |
+
"model.layers.16.attention_norm.weight": "model-00002-of-00004.safetensors",
|
149 |
+
"model.layers.16.feed_forward.w1.Plora_A.weight": "model-00002-of-00004.safetensors",
|
150 |
+
"model.layers.16.feed_forward.w1.Plora_B.weight": "model-00002-of-00004.safetensors",
|
151 |
+
"model.layers.16.feed_forward.w1.weight": "model-00002-of-00004.safetensors",
|
152 |
+
"model.layers.16.feed_forward.w2.Plora_A.weight": "model-00002-of-00004.safetensors",
|
153 |
+
"model.layers.16.feed_forward.w2.Plora_B.weight": "model-00002-of-00004.safetensors",
|
154 |
+
"model.layers.16.feed_forward.w2.weight": "model-00002-of-00004.safetensors",
|
155 |
+
"model.layers.16.feed_forward.w3.Plora_A.weight": "model-00002-of-00004.safetensors",
|
156 |
+
"model.layers.16.feed_forward.w3.Plora_B.weight": "model-00002-of-00004.safetensors",
|
157 |
+
"model.layers.16.feed_forward.w3.weight": "model-00002-of-00004.safetensors",
|
158 |
+
"model.layers.16.ffn_norm.weight": "model-00002-of-00004.safetensors",
|
159 |
+
"model.layers.17.attention.wo.Plora_A.weight": "model-00002-of-00004.safetensors",
|
160 |
+
"model.layers.17.attention.wo.Plora_B.weight": "model-00002-of-00004.safetensors",
|
161 |
+
"model.layers.17.attention.wo.weight": "model-00002-of-00004.safetensors",
|
162 |
+
"model.layers.17.attention.wqkv.Plora_A.weight": "model-00002-of-00004.safetensors",
|
163 |
+
"model.layers.17.attention.wqkv.Plora_B.weight": "model-00002-of-00004.safetensors",
|
164 |
+
"model.layers.17.attention.wqkv.weight": "model-00002-of-00004.safetensors",
|
165 |
+
"model.layers.17.attention_norm.weight": "model-00002-of-00004.safetensors",
|
166 |
+
"model.layers.17.feed_forward.w1.Plora_A.weight": "model-00002-of-00004.safetensors",
|
167 |
+
"model.layers.17.feed_forward.w1.Plora_B.weight": "model-00002-of-00004.safetensors",
|
168 |
+
"model.layers.17.feed_forward.w1.weight": "model-00002-of-00004.safetensors",
|
169 |
+
"model.layers.17.feed_forward.w2.Plora_A.weight": "model-00002-of-00004.safetensors",
|
170 |
+
"model.layers.17.feed_forward.w2.Plora_B.weight": "model-00002-of-00004.safetensors",
|
171 |
+
"model.layers.17.feed_forward.w2.weight": "model-00002-of-00004.safetensors",
|
172 |
+
"model.layers.17.feed_forward.w3.Plora_A.weight": "model-00002-of-00004.safetensors",
|
173 |
+
"model.layers.17.feed_forward.w3.Plora_B.weight": "model-00002-of-00004.safetensors",
|
174 |
+
"model.layers.17.feed_forward.w3.weight": "model-00002-of-00004.safetensors",
|
175 |
+
"model.layers.17.ffn_norm.weight": "model-00002-of-00004.safetensors",
|
176 |
+
"model.layers.18.attention.wo.Plora_A.weight": "model-00002-of-00004.safetensors",
|
177 |
+
"model.layers.18.attention.wo.Plora_B.weight": "model-00002-of-00004.safetensors",
|
178 |
+
"model.layers.18.attention.wo.weight": "model-00002-of-00004.safetensors",
|
179 |
+
"model.layers.18.attention.wqkv.Plora_A.weight": "model-00002-of-00004.safetensors",
|
180 |
+
"model.layers.18.attention.wqkv.Plora_B.weight": "model-00002-of-00004.safetensors",
|
181 |
+
"model.layers.18.attention.wqkv.weight": "model-00002-of-00004.safetensors",
|
182 |
+
"model.layers.18.attention_norm.weight": "model-00002-of-00004.safetensors",
|
183 |
+
"model.layers.18.feed_forward.w1.Plora_A.weight": "model-00002-of-00004.safetensors",
|
184 |
+
"model.layers.18.feed_forward.w1.Plora_B.weight": "model-00002-of-00004.safetensors",
|
185 |
+
"model.layers.18.feed_forward.w1.weight": "model-00002-of-00004.safetensors",
|
186 |
+
"model.layers.18.feed_forward.w2.Plora_A.weight": "model-00002-of-00004.safetensors",
|
187 |
+
"model.layers.18.feed_forward.w2.Plora_B.weight": "model-00002-of-00004.safetensors",
|
188 |
+
"model.layers.18.feed_forward.w2.weight": "model-00002-of-00004.safetensors",
|
189 |
+
"model.layers.18.feed_forward.w3.Plora_A.weight": "model-00002-of-00004.safetensors",
|
190 |
+
"model.layers.18.feed_forward.w3.Plora_B.weight": "model-00002-of-00004.safetensors",
|
191 |
+
"model.layers.18.feed_forward.w3.weight": "model-00002-of-00004.safetensors",
|
192 |
+
"model.layers.18.ffn_norm.weight": "model-00002-of-00004.safetensors",
|
193 |
+
"model.layers.19.attention.wo.Plora_A.weight": "model-00002-of-00004.safetensors",
|
194 |
+
"model.layers.19.attention.wo.Plora_B.weight": "model-00002-of-00004.safetensors",
|
195 |
+
"model.layers.19.attention.wo.weight": "model-00002-of-00004.safetensors",
|
196 |
+
"model.layers.19.attention.wqkv.Plora_A.weight": "model-00002-of-00004.safetensors",
|
197 |
+
"model.layers.19.attention.wqkv.Plora_B.weight": "model-00002-of-00004.safetensors",
|
198 |
+
"model.layers.19.attention.wqkv.weight": "model-00002-of-00004.safetensors",
|
199 |
+
"model.layers.19.attention_norm.weight": "model-00003-of-00004.safetensors",
|
200 |
+
"model.layers.19.feed_forward.w1.Plora_A.weight": "model-00003-of-00004.safetensors",
|
201 |
+
"model.layers.19.feed_forward.w1.Plora_B.weight": "model-00003-of-00004.safetensors",
|
202 |
+
"model.layers.19.feed_forward.w1.weight": "model-00003-of-00004.safetensors",
|
203 |
+
"model.layers.19.feed_forward.w2.Plora_A.weight": "model-00003-of-00004.safetensors",
|
204 |
+
"model.layers.19.feed_forward.w2.Plora_B.weight": "model-00003-of-00004.safetensors",
|
205 |
+
"model.layers.19.feed_forward.w2.weight": "model-00003-of-00004.safetensors",
|
206 |
+
"model.layers.19.feed_forward.w3.Plora_A.weight": "model-00003-of-00004.safetensors",
|
207 |
+
"model.layers.19.feed_forward.w3.Plora_B.weight": "model-00003-of-00004.safetensors",
|
208 |
+
"model.layers.19.feed_forward.w3.weight": "model-00003-of-00004.safetensors",
|
209 |
+
"model.layers.19.ffn_norm.weight": "model-00003-of-00004.safetensors",
|
210 |
+
"model.layers.2.attention.wo.Plora_A.weight": "model-00001-of-00004.safetensors",
|
211 |
+
"model.layers.2.attention.wo.Plora_B.weight": "model-00001-of-00004.safetensors",
|
212 |
+
"model.layers.2.attention.wo.weight": "model-00001-of-00004.safetensors",
|
213 |
+
"model.layers.2.attention.wqkv.Plora_A.weight": "model-00001-of-00004.safetensors",
|
214 |
+
"model.layers.2.attention.wqkv.Plora_B.weight": "model-00001-of-00004.safetensors",
|
215 |
+
"model.layers.2.attention.wqkv.weight": "model-00001-of-00004.safetensors",
|
216 |
+
"model.layers.2.attention_norm.weight": "model-00001-of-00004.safetensors",
|
217 |
+
"model.layers.2.feed_forward.w1.Plora_A.weight": "model-00001-of-00004.safetensors",
|
218 |
+
"model.layers.2.feed_forward.w1.Plora_B.weight": "model-00001-of-00004.safetensors",
|
219 |
+
"model.layers.2.feed_forward.w1.weight": "model-00001-of-00004.safetensors",
|
220 |
+
"model.layers.2.feed_forward.w2.Plora_A.weight": "model-00001-of-00004.safetensors",
|
221 |
+
"model.layers.2.feed_forward.w2.Plora_B.weight": "model-00001-of-00004.safetensors",
|
222 |
+
"model.layers.2.feed_forward.w2.weight": "model-00001-of-00004.safetensors",
|
223 |
+
"model.layers.2.feed_forward.w3.Plora_A.weight": "model-00001-of-00004.safetensors",
|
224 |
+
"model.layers.2.feed_forward.w3.Plora_B.weight": "model-00001-of-00004.safetensors",
|
225 |
+
"model.layers.2.feed_forward.w3.weight": "model-00001-of-00004.safetensors",
|
226 |
+
"model.layers.2.ffn_norm.weight": "model-00001-of-00004.safetensors",
|
227 |
+
"model.layers.20.attention.wo.Plora_A.weight": "model-00003-of-00004.safetensors",
|
228 |
+
"model.layers.20.attention.wo.Plora_B.weight": "model-00003-of-00004.safetensors",
|
229 |
+
"model.layers.20.attention.wo.weight": "model-00003-of-00004.safetensors",
|
230 |
+
"model.layers.20.attention.wqkv.Plora_A.weight": "model-00003-of-00004.safetensors",
|
231 |
+
"model.layers.20.attention.wqkv.Plora_B.weight": "model-00003-of-00004.safetensors",
|
232 |
+
"model.layers.20.attention.wqkv.weight": "model-00003-of-00004.safetensors",
|
233 |
+
"model.layers.20.attention_norm.weight": "model-00003-of-00004.safetensors",
|
234 |
+
"model.layers.20.feed_forward.w1.Plora_A.weight": "model-00003-of-00004.safetensors",
|
235 |
+
"model.layers.20.feed_forward.w1.Plora_B.weight": "model-00003-of-00004.safetensors",
|
236 |
+
"model.layers.20.feed_forward.w1.weight": "model-00003-of-00004.safetensors",
|
237 |
+
"model.layers.20.feed_forward.w2.Plora_A.weight": "model-00003-of-00004.safetensors",
|
238 |
+
"model.layers.20.feed_forward.w2.Plora_B.weight": "model-00003-of-00004.safetensors",
|
239 |
+
"model.layers.20.feed_forward.w2.weight": "model-00003-of-00004.safetensors",
|
240 |
+
"model.layers.20.feed_forward.w3.Plora_A.weight": "model-00003-of-00004.safetensors",
|
241 |
+
"model.layers.20.feed_forward.w3.Plora_B.weight": "model-00003-of-00004.safetensors",
|
242 |
+
"model.layers.20.feed_forward.w3.weight": "model-00003-of-00004.safetensors",
|
243 |
+
"model.layers.20.ffn_norm.weight": "model-00003-of-00004.safetensors",
|
244 |
+
"model.layers.21.attention.wo.Plora_A.weight": "model-00003-of-00004.safetensors",
|
245 |
+
"model.layers.21.attention.wo.Plora_B.weight": "model-00003-of-00004.safetensors",
|
246 |
+
"model.layers.21.attention.wo.weight": "model-00003-of-00004.safetensors",
|
247 |
+
"model.layers.21.attention.wqkv.Plora_A.weight": "model-00003-of-00004.safetensors",
|
248 |
+
"model.layers.21.attention.wqkv.Plora_B.weight": "model-00003-of-00004.safetensors",
|
249 |
+
"model.layers.21.attention.wqkv.weight": "model-00003-of-00004.safetensors",
|
250 |
+
"model.layers.21.attention_norm.weight": "model-00003-of-00004.safetensors",
|
251 |
+
"model.layers.21.feed_forward.w1.Plora_A.weight": "model-00003-of-00004.safetensors",
|
252 |
+
"model.layers.21.feed_forward.w1.Plora_B.weight": "model-00003-of-00004.safetensors",
|
253 |
+
"model.layers.21.feed_forward.w1.weight": "model-00003-of-00004.safetensors",
|
254 |
+
"model.layers.21.feed_forward.w2.Plora_A.weight": "model-00003-of-00004.safetensors",
|
255 |
+
"model.layers.21.feed_forward.w2.Plora_B.weight": "model-00003-of-00004.safetensors",
|
256 |
+
"model.layers.21.feed_forward.w2.weight": "model-00003-of-00004.safetensors",
|
257 |
+
"model.layers.21.feed_forward.w3.Plora_A.weight": "model-00003-of-00004.safetensors",
|
258 |
+
"model.layers.21.feed_forward.w3.Plora_B.weight": "model-00003-of-00004.safetensors",
|
259 |
+
"model.layers.21.feed_forward.w3.weight": "model-00003-of-00004.safetensors",
|
260 |
+
"model.layers.21.ffn_norm.weight": "model-00003-of-00004.safetensors",
|
261 |
+
"model.layers.22.attention.wo.Plora_A.weight": "model-00003-of-00004.safetensors",
|
262 |
+
"model.layers.22.attention.wo.Plora_B.weight": "model-00003-of-00004.safetensors",
|
263 |
+
"model.layers.22.attention.wo.weight": "model-00003-of-00004.safetensors",
|
264 |
+
"model.layers.22.attention.wqkv.Plora_A.weight": "model-00003-of-00004.safetensors",
|
265 |
+
"model.layers.22.attention.wqkv.Plora_B.weight": "model-00003-of-00004.safetensors",
|
266 |
+
"model.layers.22.attention.wqkv.weight": "model-00003-of-00004.safetensors",
|
267 |
+
"model.layers.22.attention_norm.weight": "model-00003-of-00004.safetensors",
|
268 |
+
"model.layers.22.feed_forward.w1.Plora_A.weight": "model-00003-of-00004.safetensors",
|
269 |
+
"model.layers.22.feed_forward.w1.Plora_B.weight": "model-00003-of-00004.safetensors",
|
270 |
+
"model.layers.22.feed_forward.w1.weight": "model-00003-of-00004.safetensors",
|
271 |
+
"model.layers.22.feed_forward.w2.Plora_A.weight": "model-00003-of-00004.safetensors",
|
272 |
+
"model.layers.22.feed_forward.w2.Plora_B.weight": "model-00003-of-00004.safetensors",
|
273 |
+
"model.layers.22.feed_forward.w2.weight": "model-00003-of-00004.safetensors",
|
274 |
+
"model.layers.22.feed_forward.w3.Plora_A.weight": "model-00003-of-00004.safetensors",
|
275 |
+
"model.layers.22.feed_forward.w3.Plora_B.weight": "model-00003-of-00004.safetensors",
|
276 |
+
"model.layers.22.feed_forward.w3.weight": "model-00003-of-00004.safetensors",
|
277 |
+
"model.layers.22.ffn_norm.weight": "model-00003-of-00004.safetensors",
|
278 |
+
"model.layers.23.attention.wo.Plora_A.weight": "model-00003-of-00004.safetensors",
|
279 |
+
"model.layers.23.attention.wo.Plora_B.weight": "model-00003-of-00004.safetensors",
|
280 |
+
"model.layers.23.attention.wo.weight": "model-00003-of-00004.safetensors",
|
281 |
+
"model.layers.23.attention.wqkv.Plora_A.weight": "model-00003-of-00004.safetensors",
|
282 |
+
"model.layers.23.attention.wqkv.Plora_B.weight": "model-00003-of-00004.safetensors",
|
283 |
+
"model.layers.23.attention.wqkv.weight": "model-00003-of-00004.safetensors",
|
284 |
+
"model.layers.23.attention_norm.weight": "model-00003-of-00004.safetensors",
|
285 |
+
"model.layers.23.feed_forward.w1.Plora_A.weight": "model-00003-of-00004.safetensors",
|
286 |
+
"model.layers.23.feed_forward.w1.Plora_B.weight": "model-00003-of-00004.safetensors",
|
287 |
+
"model.layers.23.feed_forward.w1.weight": "model-00003-of-00004.safetensors",
|
288 |
+
"model.layers.23.feed_forward.w2.Plora_A.weight": "model-00003-of-00004.safetensors",
|
289 |
+
"model.layers.23.feed_forward.w2.Plora_B.weight": "model-00003-of-00004.safetensors",
|
290 |
+
"model.layers.23.feed_forward.w2.weight": "model-00003-of-00004.safetensors",
|
291 |
+
"model.layers.23.feed_forward.w3.Plora_A.weight": "model-00003-of-00004.safetensors",
|
292 |
+
"model.layers.23.feed_forward.w3.Plora_B.weight": "model-00003-of-00004.safetensors",
|
293 |
+
"model.layers.23.feed_forward.w3.weight": "model-00003-of-00004.safetensors",
|
294 |
+
"model.layers.23.ffn_norm.weight": "model-00003-of-00004.safetensors",
|
295 |
+
"model.layers.24.attention.wo.Plora_A.weight": "model-00003-of-00004.safetensors",
|
296 |
+
"model.layers.24.attention.wo.Plora_B.weight": "model-00003-of-00004.safetensors",
|
297 |
+
"model.layers.24.attention.wo.weight": "model-00003-of-00004.safetensors",
|
298 |
+
"model.layers.24.attention.wqkv.Plora_A.weight": "model-00003-of-00004.safetensors",
|
299 |
+
"model.layers.24.attention.wqkv.Plora_B.weight": "model-00003-of-00004.safetensors",
|
300 |
+
"model.layers.24.attention.wqkv.weight": "model-00003-of-00004.safetensors",
|
301 |
+
"model.layers.24.attention_norm.weight": "model-00003-of-00004.safetensors",
|
302 |
+
"model.layers.24.feed_forward.w1.Plora_A.weight": "model-00003-of-00004.safetensors",
|
303 |
+
"model.layers.24.feed_forward.w1.Plora_B.weight": "model-00003-of-00004.safetensors",
|
304 |
+
"model.layers.24.feed_forward.w1.weight": "model-00003-of-00004.safetensors",
|
305 |
+
"model.layers.24.feed_forward.w2.Plora_A.weight": "model-00003-of-00004.safetensors",
|
306 |
+
"model.layers.24.feed_forward.w2.Plora_B.weight": "model-00003-of-00004.safetensors",
|
307 |
+
"model.layers.24.feed_forward.w2.weight": "model-00003-of-00004.safetensors",
|
308 |
+
"model.layers.24.feed_forward.w3.Plora_A.weight": "model-00003-of-00004.safetensors",
|
309 |
+
"model.layers.24.feed_forward.w3.Plora_B.weight": "model-00003-of-00004.safetensors",
|
310 |
+
"model.layers.24.feed_forward.w3.weight": "model-00003-of-00004.safetensors",
|
311 |
+
"model.layers.24.ffn_norm.weight": "model-00003-of-00004.safetensors",
|
312 |
+
"model.layers.25.attention.wo.Plora_A.weight": "model-00003-of-00004.safetensors",
|
313 |
+
"model.layers.25.attention.wo.Plora_B.weight": "model-00003-of-00004.safetensors",
|
314 |
+
"model.layers.25.attention.wo.weight": "model-00003-of-00004.safetensors",
|
315 |
+
"model.layers.25.attention.wqkv.Plora_A.weight": "model-00003-of-00004.safetensors",
|
316 |
+
"model.layers.25.attention.wqkv.Plora_B.weight": "model-00003-of-00004.safetensors",
|
317 |
+
"model.layers.25.attention.wqkv.weight": "model-00003-of-00004.safetensors",
|
318 |
+
"model.layers.25.attention_norm.weight": "model-00003-of-00004.safetensors",
|
319 |
+
"model.layers.25.feed_forward.w1.Plora_A.weight": "model-00003-of-00004.safetensors",
|
320 |
+
"model.layers.25.feed_forward.w1.Plora_B.weight": "model-00003-of-00004.safetensors",
|
321 |
+
"model.layers.25.feed_forward.w1.weight": "model-00003-of-00004.safetensors",
|
322 |
+
"model.layers.25.feed_forward.w2.Plora_A.weight": "model-00003-of-00004.safetensors",
|
323 |
+
"model.layers.25.feed_forward.w2.Plora_B.weight": "model-00003-of-00004.safetensors",
|
324 |
+
"model.layers.25.feed_forward.w2.weight": "model-00003-of-00004.safetensors",
|
325 |
+
"model.layers.25.feed_forward.w3.Plora_A.weight": "model-00003-of-00004.safetensors",
|
326 |
+
"model.layers.25.feed_forward.w3.Plora_B.weight": "model-00003-of-00004.safetensors",
|
327 |
+
"model.layers.25.feed_forward.w3.weight": "model-00003-of-00004.safetensors",
|
328 |
+
"model.layers.25.ffn_norm.weight": "model-00003-of-00004.safetensors",
|
329 |
+
"model.layers.26.attention.wo.Plora_A.weight": "model-00003-of-00004.safetensors",
|
330 |
+
"model.layers.26.attention.wo.Plora_B.weight": "model-00003-of-00004.safetensors",
|
331 |
+
"model.layers.26.attention.wo.weight": "model-00003-of-00004.safetensors",
|
332 |
+
"model.layers.26.attention.wqkv.Plora_A.weight": "model-00003-of-00004.safetensors",
|
333 |
+
"model.layers.26.attention.wqkv.Plora_B.weight": "model-00003-of-00004.safetensors",
|
334 |
+
"model.layers.26.attention.wqkv.weight": "model-00003-of-00004.safetensors",
|
335 |
+
"model.layers.26.attention_norm.weight": "model-00003-of-00004.safetensors",
|
336 |
+
"model.layers.26.feed_forward.w1.Plora_A.weight": "model-00003-of-00004.safetensors",
|
337 |
+
"model.layers.26.feed_forward.w1.Plora_B.weight": "model-00003-of-00004.safetensors",
|
338 |
+
"model.layers.26.feed_forward.w1.weight": "model-00003-of-00004.safetensors",
|
339 |
+
"model.layers.26.feed_forward.w2.Plora_A.weight": "model-00003-of-00004.safetensors",
|
340 |
+
"model.layers.26.feed_forward.w2.Plora_B.weight": "model-00003-of-00004.safetensors",
|
341 |
+
"model.layers.26.feed_forward.w2.weight": "model-00003-of-00004.safetensors",
|
342 |
+
"model.layers.26.feed_forward.w3.Plora_A.weight": "model-00003-of-00004.safetensors",
|
343 |
+
"model.layers.26.feed_forward.w3.Plora_B.weight": "model-00003-of-00004.safetensors",
|
344 |
+
"model.layers.26.feed_forward.w3.weight": "model-00003-of-00004.safetensors",
|
345 |
+
"model.layers.26.ffn_norm.weight": "model-00003-of-00004.safetensors",
|
346 |
+
"model.layers.27.attention.wo.Plora_A.weight": "model-00003-of-00004.safetensors",
|
347 |
+
"model.layers.27.attention.wo.Plora_B.weight": "model-00003-of-00004.safetensors",
|
348 |
+
"model.layers.27.attention.wo.weight": "model-00003-of-00004.safetensors",
|
349 |
+
"model.layers.27.attention.wqkv.Plora_A.weight": "model-00003-of-00004.safetensors",
|
350 |
+
"model.layers.27.attention.wqkv.Plora_B.weight": "model-00003-of-00004.safetensors",
|
351 |
+
"model.layers.27.attention.wqkv.weight": "model-00003-of-00004.safetensors",
|
352 |
+
"model.layers.27.attention_norm.weight": "model-00003-of-00004.safetensors",
|
353 |
+
"model.layers.27.feed_forward.w1.Plora_A.weight": "model-00003-of-00004.safetensors",
|
354 |
+
"model.layers.27.feed_forward.w1.Plora_B.weight": "model-00003-of-00004.safetensors",
|
355 |
+
"model.layers.27.feed_forward.w1.weight": "model-00003-of-00004.safetensors",
|
356 |
+
"model.layers.27.feed_forward.w2.Plora_A.weight": "model-00003-of-00004.safetensors",
|
357 |
+
"model.layers.27.feed_forward.w2.Plora_B.weight": "model-00003-of-00004.safetensors",
|
358 |
+
"model.layers.27.feed_forward.w2.weight": "model-00003-of-00004.safetensors",
|
359 |
+
"model.layers.27.feed_forward.w3.Plora_A.weight": "model-00003-of-00004.safetensors",
|
360 |
+
"model.layers.27.feed_forward.w3.Plora_B.weight": "model-00003-of-00004.safetensors",
|
361 |
+
"model.layers.27.feed_forward.w3.weight": "model-00003-of-00004.safetensors",
|
362 |
+
"model.layers.27.ffn_norm.weight": "model-00003-of-00004.safetensors",
|
363 |
+
"model.layers.28.attention.wo.Plora_A.weight": "model-00003-of-00004.safetensors",
|
364 |
+
"model.layers.28.attention.wo.Plora_B.weight": "model-00003-of-00004.safetensors",
|
365 |
+
"model.layers.28.attention.wo.weight": "model-00003-of-00004.safetensors",
|
366 |
+
"model.layers.28.attention.wqkv.Plora_A.weight": "model-00003-of-00004.safetensors",
|
367 |
+
"model.layers.28.attention.wqkv.Plora_B.weight": "model-00003-of-00004.safetensors",
|
368 |
+
"model.layers.28.attention.wqkv.weight": "model-00003-of-00004.safetensors",
|
369 |
+
"model.layers.28.attention_norm.weight": "model-00003-of-00004.safetensors",
|
370 |
+
"model.layers.28.feed_forward.w1.Plora_A.weight": "model-00003-of-00004.safetensors",
|
371 |
+
"model.layers.28.feed_forward.w1.Plora_B.weight": "model-00003-of-00004.safetensors",
|
372 |
+
"model.layers.28.feed_forward.w1.weight": "model-00003-of-00004.safetensors",
|
373 |
+
"model.layers.28.feed_forward.w2.Plora_A.weight": "model-00003-of-00004.safetensors",
|
374 |
+
"model.layers.28.feed_forward.w2.Plora_B.weight": "model-00003-of-00004.safetensors",
|
375 |
+
"model.layers.28.feed_forward.w2.weight": "model-00003-of-00004.safetensors",
|
376 |
+
"model.layers.28.feed_forward.w3.Plora_A.weight": "model-00003-of-00004.safetensors",
|
377 |
+
"model.layers.28.feed_forward.w3.Plora_B.weight": "model-00003-of-00004.safetensors",
|
378 |
+
"model.layers.28.feed_forward.w3.weight": "model-00003-of-00004.safetensors",
|
379 |
+
"model.layers.28.ffn_norm.weight": "model-00003-of-00004.safetensors",
|
380 |
+
"model.layers.29.attention.wo.Plora_A.weight": "model-00003-of-00004.safetensors",
|
381 |
+
"model.layers.29.attention.wo.Plora_B.weight": "model-00003-of-00004.safetensors",
|
382 |
+
"model.layers.29.attention.wo.weight": "model-00003-of-00004.safetensors",
|
383 |
+
"model.layers.29.attention.wqkv.Plora_A.weight": "model-00003-of-00004.safetensors",
|
384 |
+
"model.layers.29.attention.wqkv.Plora_B.weight": "model-00003-of-00004.safetensors",
|
385 |
+
"model.layers.29.attention.wqkv.weight": "model-00003-of-00004.safetensors",
|
386 |
+
"model.layers.29.attention_norm.weight": "model-00004-of-00004.safetensors",
|
387 |
+
"model.layers.29.feed_forward.w1.Plora_A.weight": "model-00003-of-00004.safetensors",
|
388 |
+
"model.layers.29.feed_forward.w1.Plora_B.weight": "model-00003-of-00004.safetensors",
|
389 |
+
"model.layers.29.feed_forward.w1.weight": "model-00003-of-00004.safetensors",
|
390 |
+
"model.layers.29.feed_forward.w2.Plora_A.weight": "model-00004-of-00004.safetensors",
|
391 |
+
"model.layers.29.feed_forward.w2.Plora_B.weight": "model-00004-of-00004.safetensors",
|
392 |
+
"model.layers.29.feed_forward.w2.weight": "model-00004-of-00004.safetensors",
|
393 |
+
"model.layers.29.feed_forward.w3.Plora_A.weight": "model-00003-of-00004.safetensors",
|
394 |
+
"model.layers.29.feed_forward.w3.Plora_B.weight": "model-00003-of-00004.safetensors",
|
395 |
+
"model.layers.29.feed_forward.w3.weight": "model-00003-of-00004.safetensors",
|
396 |
+
"model.layers.29.ffn_norm.weight": "model-00004-of-00004.safetensors",
|
397 |
+
"model.layers.3.attention.wo.Plora_A.weight": "model-00001-of-00004.safetensors",
|
398 |
+
"model.layers.3.attention.wo.Plora_B.weight": "model-00001-of-00004.safetensors",
|
399 |
+
"model.layers.3.attention.wo.weight": "model-00001-of-00004.safetensors",
|
400 |
+
"model.layers.3.attention.wqkv.Plora_A.weight": "model-00001-of-00004.safetensors",
|
401 |
+
"model.layers.3.attention.wqkv.Plora_B.weight": "model-00001-of-00004.safetensors",
|
402 |
+
"model.layers.3.attention.wqkv.weight": "model-00001-of-00004.safetensors",
|
403 |
+
"model.layers.3.attention_norm.weight": "model-00001-of-00004.safetensors",
|
404 |
+
"model.layers.3.feed_forward.w1.Plora_A.weight": "model-00001-of-00004.safetensors",
|
405 |
+
"model.layers.3.feed_forward.w1.Plora_B.weight": "model-00001-of-00004.safetensors",
|
406 |
+
"model.layers.3.feed_forward.w1.weight": "model-00001-of-00004.safetensors",
|
407 |
+
"model.layers.3.feed_forward.w2.Plora_A.weight": "model-00001-of-00004.safetensors",
|
408 |
+
"model.layers.3.feed_forward.w2.Plora_B.weight": "model-00001-of-00004.safetensors",
|
409 |
+
"model.layers.3.feed_forward.w2.weight": "model-00001-of-00004.safetensors",
|
410 |
+
"model.layers.3.feed_forward.w3.Plora_A.weight": "model-00001-of-00004.safetensors",
|
411 |
+
"model.layers.3.feed_forward.w3.Plora_B.weight": "model-00001-of-00004.safetensors",
|
412 |
+
"model.layers.3.feed_forward.w3.weight": "model-00001-of-00004.safetensors",
|
413 |
+
"model.layers.3.ffn_norm.weight": "model-00001-of-00004.safetensors",
|
414 |
+
"model.layers.30.attention.wo.Plora_A.weight": "model-00004-of-00004.safetensors",
|
415 |
+
"model.layers.30.attention.wo.Plora_B.weight": "model-00004-of-00004.safetensors",
|
416 |
+
"model.layers.30.attention.wo.weight": "model-00004-of-00004.safetensors",
|
417 |
+
"model.layers.30.attention.wqkv.Plora_A.weight": "model-00004-of-00004.safetensors",
|
418 |
+
"model.layers.30.attention.wqkv.Plora_B.weight": "model-00004-of-00004.safetensors",
|
419 |
+
"model.layers.30.attention.wqkv.weight": "model-00004-of-00004.safetensors",
|
420 |
+
"model.layers.30.attention_norm.weight": "model-00004-of-00004.safetensors",
|
421 |
+
"model.layers.30.feed_forward.w1.Plora_A.weight": "model-00004-of-00004.safetensors",
|
422 |
+
"model.layers.30.feed_forward.w1.Plora_B.weight": "model-00004-of-00004.safetensors",
|
423 |
+
"model.layers.30.feed_forward.w1.weight": "model-00004-of-00004.safetensors",
|
424 |
+
"model.layers.30.feed_forward.w2.Plora_A.weight": "model-00004-of-00004.safetensors",
|
425 |
+
"model.layers.30.feed_forward.w2.Plora_B.weight": "model-00004-of-00004.safetensors",
|
426 |
+
"model.layers.30.feed_forward.w2.weight": "model-00004-of-00004.safetensors",
|
427 |
+
"model.layers.30.feed_forward.w3.Plora_A.weight": "model-00004-of-00004.safetensors",
|
428 |
+
"model.layers.30.feed_forward.w3.Plora_B.weight": "model-00004-of-00004.safetensors",
|
429 |
+
"model.layers.30.feed_forward.w3.weight": "model-00004-of-00004.safetensors",
|
430 |
+
"model.layers.30.ffn_norm.weight": "model-00004-of-00004.safetensors",
|
431 |
+
"model.layers.31.attention.wo.Plora_A.weight": "model-00004-of-00004.safetensors",
|
432 |
+
"model.layers.31.attention.wo.Plora_B.weight": "model-00004-of-00004.safetensors",
|
433 |
+
"model.layers.31.attention.wo.weight": "model-00004-of-00004.safetensors",
|
434 |
+
"model.layers.31.attention.wqkv.Plora_A.weight": "model-00004-of-00004.safetensors",
|
435 |
+
"model.layers.31.attention.wqkv.Plora_B.weight": "model-00004-of-00004.safetensors",
|
436 |
+
"model.layers.31.attention.wqkv.weight": "model-00004-of-00004.safetensors",
|
437 |
+
"model.layers.31.attention_norm.weight": "model-00004-of-00004.safetensors",
|
438 |
+
"model.layers.31.feed_forward.w1.Plora_A.weight": "model-00004-of-00004.safetensors",
|
439 |
+
"model.layers.31.feed_forward.w1.Plora_B.weight": "model-00004-of-00004.safetensors",
|
440 |
+
"model.layers.31.feed_forward.w1.weight": "model-00004-of-00004.safetensors",
|
441 |
+
"model.layers.31.feed_forward.w2.Plora_A.weight": "model-00004-of-00004.safetensors",
|
442 |
+
"model.layers.31.feed_forward.w2.Plora_B.weight": "model-00004-of-00004.safetensors",
|
443 |
+
"model.layers.31.feed_forward.w2.weight": "model-00004-of-00004.safetensors",
|
444 |
+
"model.layers.31.feed_forward.w3.Plora_A.weight": "model-00004-of-00004.safetensors",
|
445 |
+
"model.layers.31.feed_forward.w3.Plora_B.weight": "model-00004-of-00004.safetensors",
|
446 |
+
"model.layers.31.feed_forward.w3.weight": "model-00004-of-00004.safetensors",
|
447 |
+
"model.layers.31.ffn_norm.weight": "model-00004-of-00004.safetensors",
|
448 |
+
"model.layers.4.attention.wo.Plora_A.weight": "model-00001-of-00004.safetensors",
|
449 |
+
"model.layers.4.attention.wo.Plora_B.weight": "model-00001-of-00004.safetensors",
|
450 |
+
"model.layers.4.attention.wo.weight": "model-00001-of-00004.safetensors",
|
451 |
+
"model.layers.4.attention.wqkv.Plora_A.weight": "model-00001-of-00004.safetensors",
|
452 |
+
"model.layers.4.attention.wqkv.Plora_B.weight": "model-00001-of-00004.safetensors",
|
453 |
+
"model.layers.4.attention.wqkv.weight": "model-00001-of-00004.safetensors",
|
454 |
+
"model.layers.4.attention_norm.weight": "model-00001-of-00004.safetensors",
|
455 |
+
"model.layers.4.feed_forward.w1.Plora_A.weight": "model-00001-of-00004.safetensors",
|
456 |
+
"model.layers.4.feed_forward.w1.Plora_B.weight": "model-00001-of-00004.safetensors",
|
457 |
+
"model.layers.4.feed_forward.w1.weight": "model-00001-of-00004.safetensors",
|
458 |
+
"model.layers.4.feed_forward.w2.Plora_A.weight": "model-00001-of-00004.safetensors",
|
459 |
+
"model.layers.4.feed_forward.w2.Plora_B.weight": "model-00001-of-00004.safetensors",
|
460 |
+
"model.layers.4.feed_forward.w2.weight": "model-00001-of-00004.safetensors",
|
461 |
+
"model.layers.4.feed_forward.w3.Plora_A.weight": "model-00001-of-00004.safetensors",
|
462 |
+
"model.layers.4.feed_forward.w3.Plora_B.weight": "model-00001-of-00004.safetensors",
|
463 |
+
"model.layers.4.feed_forward.w3.weight": "model-00001-of-00004.safetensors",
|
464 |
+
"model.layers.4.ffn_norm.weight": "model-00001-of-00004.safetensors",
|
465 |
+
"model.layers.5.attention.wo.Plora_A.weight": "model-00001-of-00004.safetensors",
|
466 |
+
"model.layers.5.attention.wo.Plora_B.weight": "model-00001-of-00004.safetensors",
|
467 |
+
"model.layers.5.attention.wo.weight": "model-00001-of-00004.safetensors",
|
468 |
+
"model.layers.5.attention.wqkv.Plora_A.weight": "model-00001-of-00004.safetensors",
|
469 |
+
"model.layers.5.attention.wqkv.Plora_B.weight": "model-00001-of-00004.safetensors",
|
470 |
+
"model.layers.5.attention.wqkv.weight": "model-00001-of-00004.safetensors",
|
471 |
+
"model.layers.5.attention_norm.weight": "model-00001-of-00004.safetensors",
|
472 |
+
"model.layers.5.feed_forward.w1.Plora_A.weight": "model-00001-of-00004.safetensors",
|
473 |
+
"model.layers.5.feed_forward.w1.Plora_B.weight": "model-00001-of-00004.safetensors",
|
474 |
+
"model.layers.5.feed_forward.w1.weight": "model-00001-of-00004.safetensors",
|
475 |
+
"model.layers.5.feed_forward.w2.Plora_A.weight": "model-00001-of-00004.safetensors",
|
476 |
+
"model.layers.5.feed_forward.w2.Plora_B.weight": "model-00001-of-00004.safetensors",
|
477 |
+
"model.layers.5.feed_forward.w2.weight": "model-00001-of-00004.safetensors",
|
478 |
+
"model.layers.5.feed_forward.w3.Plora_A.weight": "model-00001-of-00004.safetensors",
|
479 |
+
"model.layers.5.feed_forward.w3.Plora_B.weight": "model-00001-of-00004.safetensors",
|
480 |
+
"model.layers.5.feed_forward.w3.weight": "model-00001-of-00004.safetensors",
|
481 |
+
"model.layers.5.ffn_norm.weight": "model-00001-of-00004.safetensors",
|
482 |
+
"model.layers.6.attention.wo.Plora_A.weight": "model-00001-of-00004.safetensors",
|
483 |
+
"model.layers.6.attention.wo.Plora_B.weight": "model-00001-of-00004.safetensors",
|
484 |
+
"model.layers.6.attention.wo.weight": "model-00001-of-00004.safetensors",
|
485 |
+
"model.layers.6.attention.wqkv.Plora_A.weight": "model-00001-of-00004.safetensors",
|
486 |
+
"model.layers.6.attention.wqkv.Plora_B.weight": "model-00001-of-00004.safetensors",
|
487 |
+
"model.layers.6.attention.wqkv.weight": "model-00001-of-00004.safetensors",
|
488 |
+
"model.layers.6.attention_norm.weight": "model-00001-of-00004.safetensors",
|
489 |
+
"model.layers.6.feed_forward.w1.Plora_A.weight": "model-00001-of-00004.safetensors",
|
490 |
+
"model.layers.6.feed_forward.w1.Plora_B.weight": "model-00001-of-00004.safetensors",
|
491 |
+
"model.layers.6.feed_forward.w1.weight": "model-00001-of-00004.safetensors",
|
492 |
+
"model.layers.6.feed_forward.w2.Plora_A.weight": "model-00001-of-00004.safetensors",
|
493 |
+
"model.layers.6.feed_forward.w2.Plora_B.weight": "model-00001-of-00004.safetensors",
|
494 |
+
"model.layers.6.feed_forward.w2.weight": "model-00001-of-00004.safetensors",
|
495 |
+
"model.layers.6.feed_forward.w3.Plora_A.weight": "model-00001-of-00004.safetensors",
|
496 |
+
"model.layers.6.feed_forward.w3.Plora_B.weight": "model-00001-of-00004.safetensors",
|
497 |
+
"model.layers.6.feed_forward.w3.weight": "model-00001-of-00004.safetensors",
|
498 |
+
"model.layers.6.ffn_norm.weight": "model-00001-of-00004.safetensors",
|
499 |
+
"model.layers.7.attention.wo.Plora_A.weight": "model-00001-of-00004.safetensors",
|
500 |
+
"model.layers.7.attention.wo.Plora_B.weight": "model-00001-of-00004.safetensors",
|
501 |
+
"model.layers.7.attention.wo.weight": "model-00001-of-00004.safetensors",
|
502 |
+
"model.layers.7.attention.wqkv.Plora_A.weight": "model-00001-of-00004.safetensors",
|
503 |
+
"model.layers.7.attention.wqkv.Plora_B.weight": "model-00001-of-00004.safetensors",
|
504 |
+
"model.layers.7.attention.wqkv.weight": "model-00001-of-00004.safetensors",
|
505 |
+
"model.layers.7.attention_norm.weight": "model-00001-of-00004.safetensors",
|
506 |
+
"model.layers.7.feed_forward.w1.Plora_A.weight": "model-00001-of-00004.safetensors",
|
507 |
+
"model.layers.7.feed_forward.w1.Plora_B.weight": "model-00001-of-00004.safetensors",
|
508 |
+
"model.layers.7.feed_forward.w1.weight": "model-00001-of-00004.safetensors",
|
509 |
+
"model.layers.7.feed_forward.w2.Plora_A.weight": "model-00001-of-00004.safetensors",
|
510 |
+
"model.layers.7.feed_forward.w2.Plora_B.weight": "model-00001-of-00004.safetensors",
|
511 |
+
"model.layers.7.feed_forward.w2.weight": "model-00001-of-00004.safetensors",
|
512 |
+
"model.layers.7.feed_forward.w3.Plora_A.weight": "model-00001-of-00004.safetensors",
|
513 |
+
"model.layers.7.feed_forward.w3.Plora_B.weight": "model-00001-of-00004.safetensors",
|
514 |
+
"model.layers.7.feed_forward.w3.weight": "model-00001-of-00004.safetensors",
|
515 |
+
"model.layers.7.ffn_norm.weight": "model-00001-of-00004.safetensors",
|
516 |
+
"model.layers.8.attention.wo.Plora_A.weight": "model-00001-of-00004.safetensors",
|
517 |
+
"model.layers.8.attention.wo.Plora_B.weight": "model-00001-of-00004.safetensors",
|
518 |
+
"model.layers.8.attention.wo.weight": "model-00001-of-00004.safetensors",
|
519 |
+
"model.layers.8.attention.wqkv.Plora_A.weight": "model-00001-of-00004.safetensors",
|
520 |
+
"model.layers.8.attention.wqkv.Plora_B.weight": "model-00001-of-00004.safetensors",
|
521 |
+
"model.layers.8.attention.wqkv.weight": "model-00001-of-00004.safetensors",
|
522 |
+
"model.layers.8.attention_norm.weight": "model-00002-of-00004.safetensors",
|
523 |
+
"model.layers.8.feed_forward.w1.Plora_A.weight": "model-00001-of-00004.safetensors",
|
524 |
+
"model.layers.8.feed_forward.w1.Plora_B.weight": "model-00001-of-00004.safetensors",
|
525 |
+
"model.layers.8.feed_forward.w1.weight": "model-00001-of-00004.safetensors",
|
526 |
+
"model.layers.8.feed_forward.w2.Plora_A.weight": "model-00002-of-00004.safetensors",
|
527 |
+
"model.layers.8.feed_forward.w2.Plora_B.weight": "model-00002-of-00004.safetensors",
|
528 |
+
"model.layers.8.feed_forward.w2.weight": "model-00002-of-00004.safetensors",
|
529 |
+
"model.layers.8.feed_forward.w3.Plora_A.weight": "model-00001-of-00004.safetensors",
|
530 |
+
"model.layers.8.feed_forward.w3.Plora_B.weight": "model-00001-of-00004.safetensors",
|
531 |
+
"model.layers.8.feed_forward.w3.weight": "model-00001-of-00004.safetensors",
|
532 |
+
"model.layers.8.ffn_norm.weight": "model-00002-of-00004.safetensors",
|
533 |
+
"model.layers.9.attention.wo.Plora_A.weight": "model-00002-of-00004.safetensors",
|
534 |
+
"model.layers.9.attention.wo.Plora_B.weight": "model-00002-of-00004.safetensors",
|
535 |
+
"model.layers.9.attention.wo.weight": "model-00002-of-00004.safetensors",
|
536 |
+
"model.layers.9.attention.wqkv.Plora_A.weight": "model-00002-of-00004.safetensors",
|
537 |
+
"model.layers.9.attention.wqkv.Plora_B.weight": "model-00002-of-00004.safetensors",
|
538 |
+
"model.layers.9.attention.wqkv.weight": "model-00002-of-00004.safetensors",
|
539 |
+
"model.layers.9.attention_norm.weight": "model-00002-of-00004.safetensors",
|
540 |
+
"model.layers.9.feed_forward.w1.Plora_A.weight": "model-00002-of-00004.safetensors",
|
541 |
+
"model.layers.9.feed_forward.w1.Plora_B.weight": "model-00002-of-00004.safetensors",
|
542 |
+
"model.layers.9.feed_forward.w1.weight": "model-00002-of-00004.safetensors",
|
543 |
+
"model.layers.9.feed_forward.w2.Plora_A.weight": "model-00002-of-00004.safetensors",
|
544 |
+
"model.layers.9.feed_forward.w2.Plora_B.weight": "model-00002-of-00004.safetensors",
|
545 |
+
"model.layers.9.feed_forward.w2.weight": "model-00002-of-00004.safetensors",
|
546 |
+
"model.layers.9.feed_forward.w3.Plora_A.weight": "model-00002-of-00004.safetensors",
|
547 |
+
"model.layers.9.feed_forward.w3.Plora_B.weight": "model-00002-of-00004.safetensors",
|
548 |
+
"model.layers.9.feed_forward.w3.weight": "model-00002-of-00004.safetensors",
|
549 |
+
"model.layers.9.ffn_norm.weight": "model-00002-of-00004.safetensors",
|
550 |
+
"model.norm.weight": "model-00004-of-00004.safetensors",
|
551 |
+
"model.tok_embeddings.weight": "model-00001-of-00004.safetensors",
|
552 |
+
"output.weight": "model-00004-of-00004.safetensors",
|
553 |
+
"vision_proj.0.bias": "model-00004-of-00004.safetensors",
|
554 |
+
"vision_proj.0.weight": "model-00004-of-00004.safetensors",
|
555 |
+
"vision_proj.2.bias": "model-00004-of-00004.safetensors",
|
556 |
+
"vision_proj.2.weight": "model-00004-of-00004.safetensors",
|
557 |
+
"vit.vision_tower.vision_model.embeddings.class_embedding": "model-00004-of-00004.safetensors",
|
558 |
+
"vit.vision_tower.vision_model.embeddings.patch_embedding.weight": "model-00004-of-00004.safetensors",
|
559 |
+
"vit.vision_tower.vision_model.embeddings.position_embedding.weight": "model-00004-of-00004.safetensors",
|
560 |
+
"vit.vision_tower.vision_model.encoder.layers.0.layer_norm1.bias": "model-00004-of-00004.safetensors",
|
561 |
+
"vit.vision_tower.vision_model.encoder.layers.0.layer_norm1.weight": "model-00004-of-00004.safetensors",
|
562 |
+
"vit.vision_tower.vision_model.encoder.layers.0.layer_norm2.bias": "model-00004-of-00004.safetensors",
|
563 |
+
"vit.vision_tower.vision_model.encoder.layers.0.layer_norm2.weight": "model-00004-of-00004.safetensors",
|
564 |
+
"vit.vision_tower.vision_model.encoder.layers.0.mlp.fc1.bias": "model-00004-of-00004.safetensors",
|
565 |
+
"vit.vision_tower.vision_model.encoder.layers.0.mlp.fc1.weight": "model-00004-of-00004.safetensors",
|
566 |
+
"vit.vision_tower.vision_model.encoder.layers.0.mlp.fc2.bias": "model-00004-of-00004.safetensors",
|
567 |
+
"vit.vision_tower.vision_model.encoder.layers.0.mlp.fc2.weight": "model-00004-of-00004.safetensors",
|
568 |
+
"vit.vision_tower.vision_model.encoder.layers.0.self_attn.k_proj.bias": "model-00004-of-00004.safetensors",
|
569 |
+
"vit.vision_tower.vision_model.encoder.layers.0.self_attn.k_proj.weight": "model-00004-of-00004.safetensors",
|
570 |
+
"vit.vision_tower.vision_model.encoder.layers.0.self_attn.out_proj.bias": "model-00004-of-00004.safetensors",
|
571 |
+
"vit.vision_tower.vision_model.encoder.layers.0.self_attn.out_proj.weight": "model-00004-of-00004.safetensors",
|
572 |
+
"vit.vision_tower.vision_model.encoder.layers.0.self_attn.q_proj.bias": "model-00004-of-00004.safetensors",
|
573 |
+
"vit.vision_tower.vision_model.encoder.layers.0.self_attn.q_proj.weight": "model-00004-of-00004.safetensors",
|
574 |
+
"vit.vision_tower.vision_model.encoder.layers.0.self_attn.v_proj.bias": "model-00004-of-00004.safetensors",
|
575 |
+
"vit.vision_tower.vision_model.encoder.layers.0.self_attn.v_proj.weight": "model-00004-of-00004.safetensors",
|
576 |
+
"vit.vision_tower.vision_model.encoder.layers.1.layer_norm1.bias": "model-00004-of-00004.safetensors",
|
577 |
+
"vit.vision_tower.vision_model.encoder.layers.1.layer_norm1.weight": "model-00004-of-00004.safetensors",
|
578 |
+
"vit.vision_tower.vision_model.encoder.layers.1.layer_norm2.bias": "model-00004-of-00004.safetensors",
|
579 |
+
"vit.vision_tower.vision_model.encoder.layers.1.layer_norm2.weight": "model-00004-of-00004.safetensors",
|
580 |
+
"vit.vision_tower.vision_model.encoder.layers.1.mlp.fc1.bias": "model-00004-of-00004.safetensors",
|
581 |
+
"vit.vision_tower.vision_model.encoder.layers.1.mlp.fc1.weight": "model-00004-of-00004.safetensors",
|
582 |
+
"vit.vision_tower.vision_model.encoder.layers.1.mlp.fc2.bias": "model-00004-of-00004.safetensors",
|
583 |
+
"vit.vision_tower.vision_model.encoder.layers.1.mlp.fc2.weight": "model-00004-of-00004.safetensors",
|
584 |
+
"vit.vision_tower.vision_model.encoder.layers.1.self_attn.k_proj.bias": "model-00004-of-00004.safetensors",
|
585 |
+
"vit.vision_tower.vision_model.encoder.layers.1.self_attn.k_proj.weight": "model-00004-of-00004.safetensors",
|
586 |
+
"vit.vision_tower.vision_model.encoder.layers.1.self_attn.out_proj.bias": "model-00004-of-00004.safetensors",
|
587 |
+
"vit.vision_tower.vision_model.encoder.layers.1.self_attn.out_proj.weight": "model-00004-of-00004.safetensors",
|
588 |
+
"vit.vision_tower.vision_model.encoder.layers.1.self_attn.q_proj.bias": "model-00004-of-00004.safetensors",
|
589 |
+
"vit.vision_tower.vision_model.encoder.layers.1.self_attn.q_proj.weight": "model-00004-of-00004.safetensors",
|
590 |
+
"vit.vision_tower.vision_model.encoder.layers.1.self_attn.v_proj.bias": "model-00004-of-00004.safetensors",
|
591 |
+
"vit.vision_tower.vision_model.encoder.layers.1.self_attn.v_proj.weight": "model-00004-of-00004.safetensors",
|
592 |
+
"vit.vision_tower.vision_model.encoder.layers.10.layer_norm1.bias": "model-00004-of-00004.safetensors",
|
593 |
+
"vit.vision_tower.vision_model.encoder.layers.10.layer_norm1.weight": "model-00004-of-00004.safetensors",
|
594 |
+
"vit.vision_tower.vision_model.encoder.layers.10.layer_norm2.bias": "model-00004-of-00004.safetensors",
|
595 |
+
"vit.vision_tower.vision_model.encoder.layers.10.layer_norm2.weight": "model-00004-of-00004.safetensors",
|
596 |
+
"vit.vision_tower.vision_model.encoder.layers.10.mlp.fc1.bias": "model-00004-of-00004.safetensors",
|
597 |
+
"vit.vision_tower.vision_model.encoder.layers.10.mlp.fc1.weight": "model-00004-of-00004.safetensors",
|
598 |
+
"vit.vision_tower.vision_model.encoder.layers.10.mlp.fc2.bias": "model-00004-of-00004.safetensors",
|
599 |
+
"vit.vision_tower.vision_model.encoder.layers.10.mlp.fc2.weight": "model-00004-of-00004.safetensors",
|
600 |
+
"vit.vision_tower.vision_model.encoder.layers.10.self_attn.k_proj.bias": "model-00004-of-00004.safetensors",
|
601 |
+
"vit.vision_tower.vision_model.encoder.layers.10.self_attn.k_proj.weight": "model-00004-of-00004.safetensors",
|
602 |
+
"vit.vision_tower.vision_model.encoder.layers.10.self_attn.out_proj.bias": "model-00004-of-00004.safetensors",
|
603 |
+
"vit.vision_tower.vision_model.encoder.layers.10.self_attn.out_proj.weight": "model-00004-of-00004.safetensors",
|
604 |
+
"vit.vision_tower.vision_model.encoder.layers.10.self_attn.q_proj.bias": "model-00004-of-00004.safetensors",
|
605 |
+
"vit.vision_tower.vision_model.encoder.layers.10.self_attn.q_proj.weight": "model-00004-of-00004.safetensors",
|
606 |
+
"vit.vision_tower.vision_model.encoder.layers.10.self_attn.v_proj.bias": "model-00004-of-00004.safetensors",
|
607 |
+
"vit.vision_tower.vision_model.encoder.layers.10.self_attn.v_proj.weight": "model-00004-of-00004.safetensors",
|
608 |
+
"vit.vision_tower.vision_model.encoder.layers.11.layer_norm1.bias": "model-00004-of-00004.safetensors",
|
609 |
+
"vit.vision_tower.vision_model.encoder.layers.11.layer_norm1.weight": "model-00004-of-00004.safetensors",
|
610 |
+
"vit.vision_tower.vision_model.encoder.layers.11.layer_norm2.bias": "model-00004-of-00004.safetensors",
|
611 |
+
"vit.vision_tower.vision_model.encoder.layers.11.layer_norm2.weight": "model-00004-of-00004.safetensors",
|
612 |
+
"vit.vision_tower.vision_model.encoder.layers.11.mlp.fc1.bias": "model-00004-of-00004.safetensors",
|
613 |
+
"vit.vision_tower.vision_model.encoder.layers.11.mlp.fc1.weight": "model-00004-of-00004.safetensors",
|
614 |
+
"vit.vision_tower.vision_model.encoder.layers.11.mlp.fc2.bias": "model-00004-of-00004.safetensors",
|
615 |
+
"vit.vision_tower.vision_model.encoder.layers.11.mlp.fc2.weight": "model-00004-of-00004.safetensors",
|
616 |
+
"vit.vision_tower.vision_model.encoder.layers.11.self_attn.k_proj.bias": "model-00004-of-00004.safetensors",
|
617 |
+
"vit.vision_tower.vision_model.encoder.layers.11.self_attn.k_proj.weight": "model-00004-of-00004.safetensors",
|
618 |
+
"vit.vision_tower.vision_model.encoder.layers.11.self_attn.out_proj.bias": "model-00004-of-00004.safetensors",
|
619 |
+
"vit.vision_tower.vision_model.encoder.layers.11.self_attn.out_proj.weight": "model-00004-of-00004.safetensors",
|
620 |
+
"vit.vision_tower.vision_model.encoder.layers.11.self_attn.q_proj.bias": "model-00004-of-00004.safetensors",
|
621 |
+
"vit.vision_tower.vision_model.encoder.layers.11.self_attn.q_proj.weight": "model-00004-of-00004.safetensors",
|
622 |
+
"vit.vision_tower.vision_model.encoder.layers.11.self_attn.v_proj.bias": "model-00004-of-00004.safetensors",
|
623 |
+
"vit.vision_tower.vision_model.encoder.layers.11.self_attn.v_proj.weight": "model-00004-of-00004.safetensors",
|
624 |
+
"vit.vision_tower.vision_model.encoder.layers.12.layer_norm1.bias": "model-00004-of-00004.safetensors",
|
625 |
+
"vit.vision_tower.vision_model.encoder.layers.12.layer_norm1.weight": "model-00004-of-00004.safetensors",
|
626 |
+
"vit.vision_tower.vision_model.encoder.layers.12.layer_norm2.bias": "model-00004-of-00004.safetensors",
|
627 |
+
"vit.vision_tower.vision_model.encoder.layers.12.layer_norm2.weight": "model-00004-of-00004.safetensors",
|
628 |
+
"vit.vision_tower.vision_model.encoder.layers.12.mlp.fc1.bias": "model-00004-of-00004.safetensors",
|
629 |
+
"vit.vision_tower.vision_model.encoder.layers.12.mlp.fc1.weight": "model-00004-of-00004.safetensors",
|
630 |
+
"vit.vision_tower.vision_model.encoder.layers.12.mlp.fc2.bias": "model-00004-of-00004.safetensors",
|
631 |
+
"vit.vision_tower.vision_model.encoder.layers.12.mlp.fc2.weight": "model-00004-of-00004.safetensors",
|
632 |
+
"vit.vision_tower.vision_model.encoder.layers.12.self_attn.k_proj.bias": "model-00004-of-00004.safetensors",
|
633 |
+
"vit.vision_tower.vision_model.encoder.layers.12.self_attn.k_proj.weight": "model-00004-of-00004.safetensors",
|
634 |
+
"vit.vision_tower.vision_model.encoder.layers.12.self_attn.out_proj.bias": "model-00004-of-00004.safetensors",
|
635 |
+
"vit.vision_tower.vision_model.encoder.layers.12.self_attn.out_proj.weight": "model-00004-of-00004.safetensors",
|
636 |
+
"vit.vision_tower.vision_model.encoder.layers.12.self_attn.q_proj.bias": "model-00004-of-00004.safetensors",
|
637 |
+
"vit.vision_tower.vision_model.encoder.layers.12.self_attn.q_proj.weight": "model-00004-of-00004.safetensors",
|
638 |
+
"vit.vision_tower.vision_model.encoder.layers.12.self_attn.v_proj.bias": "model-00004-of-00004.safetensors",
|
639 |
+
"vit.vision_tower.vision_model.encoder.layers.12.self_attn.v_proj.weight": "model-00004-of-00004.safetensors",
|
640 |
+
"vit.vision_tower.vision_model.encoder.layers.13.layer_norm1.bias": "model-00004-of-00004.safetensors",
|
641 |
+
"vit.vision_tower.vision_model.encoder.layers.13.layer_norm1.weight": "model-00004-of-00004.safetensors",
|
642 |
+
"vit.vision_tower.vision_model.encoder.layers.13.layer_norm2.bias": "model-00004-of-00004.safetensors",
|
643 |
+
"vit.vision_tower.vision_model.encoder.layers.13.layer_norm2.weight": "model-00004-of-00004.safetensors",
|
644 |
+
"vit.vision_tower.vision_model.encoder.layers.13.mlp.fc1.bias": "model-00004-of-00004.safetensors",
|
645 |
+
"vit.vision_tower.vision_model.encoder.layers.13.mlp.fc1.weight": "model-00004-of-00004.safetensors",
|
646 |
+
"vit.vision_tower.vision_model.encoder.layers.13.mlp.fc2.bias": "model-00004-of-00004.safetensors",
|
647 |
+
"vit.vision_tower.vision_model.encoder.layers.13.mlp.fc2.weight": "model-00004-of-00004.safetensors",
|
648 |
+
"vit.vision_tower.vision_model.encoder.layers.13.self_attn.k_proj.bias": "model-00004-of-00004.safetensors",
|
649 |
+
"vit.vision_tower.vision_model.encoder.layers.13.self_attn.k_proj.weight": "model-00004-of-00004.safetensors",
|
650 |
+
"vit.vision_tower.vision_model.encoder.layers.13.self_attn.out_proj.bias": "model-00004-of-00004.safetensors",
|
651 |
+
"vit.vision_tower.vision_model.encoder.layers.13.self_attn.out_proj.weight": "model-00004-of-00004.safetensors",
|
652 |
+
"vit.vision_tower.vision_model.encoder.layers.13.self_attn.q_proj.bias": "model-00004-of-00004.safetensors",
|
653 |
+
"vit.vision_tower.vision_model.encoder.layers.13.self_attn.q_proj.weight": "model-00004-of-00004.safetensors",
|
654 |
+
"vit.vision_tower.vision_model.encoder.layers.13.self_attn.v_proj.bias": "model-00004-of-00004.safetensors",
|
655 |
+
"vit.vision_tower.vision_model.encoder.layers.13.self_attn.v_proj.weight": "model-00004-of-00004.safetensors",
|
656 |
+
"vit.vision_tower.vision_model.encoder.layers.14.layer_norm1.bias": "model-00004-of-00004.safetensors",
|
657 |
+
"vit.vision_tower.vision_model.encoder.layers.14.layer_norm1.weight": "model-00004-of-00004.safetensors",
|
658 |
+
"vit.vision_tower.vision_model.encoder.layers.14.layer_norm2.bias": "model-00004-of-00004.safetensors",
|
659 |
+
"vit.vision_tower.vision_model.encoder.layers.14.layer_norm2.weight": "model-00004-of-00004.safetensors",
|
660 |
+
"vit.vision_tower.vision_model.encoder.layers.14.mlp.fc1.bias": "model-00004-of-00004.safetensors",
|
661 |
+
"vit.vision_tower.vision_model.encoder.layers.14.mlp.fc1.weight": "model-00004-of-00004.safetensors",
|
662 |
+
"vit.vision_tower.vision_model.encoder.layers.14.mlp.fc2.bias": "model-00004-of-00004.safetensors",
|
663 |
+
"vit.vision_tower.vision_model.encoder.layers.14.mlp.fc2.weight": "model-00004-of-00004.safetensors",
|
664 |
+
"vit.vision_tower.vision_model.encoder.layers.14.self_attn.k_proj.bias": "model-00004-of-00004.safetensors",
|
665 |
+
"vit.vision_tower.vision_model.encoder.layers.14.self_attn.k_proj.weight": "model-00004-of-00004.safetensors",
|
666 |
+
"vit.vision_tower.vision_model.encoder.layers.14.self_attn.out_proj.bias": "model-00004-of-00004.safetensors",
|
667 |
+
"vit.vision_tower.vision_model.encoder.layers.14.self_attn.out_proj.weight": "model-00004-of-00004.safetensors",
|
668 |
+
"vit.vision_tower.vision_model.encoder.layers.14.self_attn.q_proj.bias": "model-00004-of-00004.safetensors",
|
669 |
+
"vit.vision_tower.vision_model.encoder.layers.14.self_attn.q_proj.weight": "model-00004-of-00004.safetensors",
|
670 |
+
"vit.vision_tower.vision_model.encoder.layers.14.self_attn.v_proj.bias": "model-00004-of-00004.safetensors",
|
671 |
+
"vit.vision_tower.vision_model.encoder.layers.14.self_attn.v_proj.weight": "model-00004-of-00004.safetensors",
|
672 |
+
"vit.vision_tower.vision_model.encoder.layers.15.layer_norm1.bias": "model-00004-of-00004.safetensors",
|
673 |
+
"vit.vision_tower.vision_model.encoder.layers.15.layer_norm1.weight": "model-00004-of-00004.safetensors",
|
674 |
+
"vit.vision_tower.vision_model.encoder.layers.15.layer_norm2.bias": "model-00004-of-00004.safetensors",
|
675 |
+
"vit.vision_tower.vision_model.encoder.layers.15.layer_norm2.weight": "model-00004-of-00004.safetensors",
|
676 |
+
"vit.vision_tower.vision_model.encoder.layers.15.mlp.fc1.bias": "model-00004-of-00004.safetensors",
|
677 |
+
"vit.vision_tower.vision_model.encoder.layers.15.mlp.fc1.weight": "model-00004-of-00004.safetensors",
|
678 |
+
"vit.vision_tower.vision_model.encoder.layers.15.mlp.fc2.bias": "model-00004-of-00004.safetensors",
|
679 |
+
"vit.vision_tower.vision_model.encoder.layers.15.mlp.fc2.weight": "model-00004-of-00004.safetensors",
|
680 |
+
"vit.vision_tower.vision_model.encoder.layers.15.self_attn.k_proj.bias": "model-00004-of-00004.safetensors",
|
681 |
+
"vit.vision_tower.vision_model.encoder.layers.15.self_attn.k_proj.weight": "model-00004-of-00004.safetensors",
|
682 |
+
"vit.vision_tower.vision_model.encoder.layers.15.self_attn.out_proj.bias": "model-00004-of-00004.safetensors",
|
683 |
+
"vit.vision_tower.vision_model.encoder.layers.15.self_attn.out_proj.weight": "model-00004-of-00004.safetensors",
|
684 |
+
"vit.vision_tower.vision_model.encoder.layers.15.self_attn.q_proj.bias": "model-00004-of-00004.safetensors",
|
685 |
+
"vit.vision_tower.vision_model.encoder.layers.15.self_attn.q_proj.weight": "model-00004-of-00004.safetensors",
|
686 |
+
"vit.vision_tower.vision_model.encoder.layers.15.self_attn.v_proj.bias": "model-00004-of-00004.safetensors",
|
687 |
+
"vit.vision_tower.vision_model.encoder.layers.15.self_attn.v_proj.weight": "model-00004-of-00004.safetensors",
|
688 |
+
"vit.vision_tower.vision_model.encoder.layers.16.layer_norm1.bias": "model-00004-of-00004.safetensors",
|
689 |
+
"vit.vision_tower.vision_model.encoder.layers.16.layer_norm1.weight": "model-00004-of-00004.safetensors",
|
690 |
+
"vit.vision_tower.vision_model.encoder.layers.16.layer_norm2.bias": "model-00004-of-00004.safetensors",
|
691 |
+
"vit.vision_tower.vision_model.encoder.layers.16.layer_norm2.weight": "model-00004-of-00004.safetensors",
|
692 |
+
"vit.vision_tower.vision_model.encoder.layers.16.mlp.fc1.bias": "model-00004-of-00004.safetensors",
|
693 |
+
"vit.vision_tower.vision_model.encoder.layers.16.mlp.fc1.weight": "model-00004-of-00004.safetensors",
|
694 |
+
"vit.vision_tower.vision_model.encoder.layers.16.mlp.fc2.bias": "model-00004-of-00004.safetensors",
|
695 |
+
"vit.vision_tower.vision_model.encoder.layers.16.mlp.fc2.weight": "model-00004-of-00004.safetensors",
|
696 |
+
"vit.vision_tower.vision_model.encoder.layers.16.self_attn.k_proj.bias": "model-00004-of-00004.safetensors",
|
697 |
+
"vit.vision_tower.vision_model.encoder.layers.16.self_attn.k_proj.weight": "model-00004-of-00004.safetensors",
|
698 |
+
"vit.vision_tower.vision_model.encoder.layers.16.self_attn.out_proj.bias": "model-00004-of-00004.safetensors",
|
699 |
+
"vit.vision_tower.vision_model.encoder.layers.16.self_attn.out_proj.weight": "model-00004-of-00004.safetensors",
|
700 |
+
"vit.vision_tower.vision_model.encoder.layers.16.self_attn.q_proj.bias": "model-00004-of-00004.safetensors",
|
701 |
+
"vit.vision_tower.vision_model.encoder.layers.16.self_attn.q_proj.weight": "model-00004-of-00004.safetensors",
|
702 |
+
"vit.vision_tower.vision_model.encoder.layers.16.self_attn.v_proj.bias": "model-00004-of-00004.safetensors",
|
703 |
+
"vit.vision_tower.vision_model.encoder.layers.16.self_attn.v_proj.weight": "model-00004-of-00004.safetensors",
|
704 |
+
"vit.vision_tower.vision_model.encoder.layers.17.layer_norm1.bias": "model-00004-of-00004.safetensors",
|
705 |
+
"vit.vision_tower.vision_model.encoder.layers.17.layer_norm1.weight": "model-00004-of-00004.safetensors",
|
706 |
+
"vit.vision_tower.vision_model.encoder.layers.17.layer_norm2.bias": "model-00004-of-00004.safetensors",
|
707 |
+
"vit.vision_tower.vision_model.encoder.layers.17.layer_norm2.weight": "model-00004-of-00004.safetensors",
|
708 |
+
"vit.vision_tower.vision_model.encoder.layers.17.mlp.fc1.bias": "model-00004-of-00004.safetensors",
|
709 |
+
"vit.vision_tower.vision_model.encoder.layers.17.mlp.fc1.weight": "model-00004-of-00004.safetensors",
|
710 |
+
"vit.vision_tower.vision_model.encoder.layers.17.mlp.fc2.bias": "model-00004-of-00004.safetensors",
|
711 |
+
"vit.vision_tower.vision_model.encoder.layers.17.mlp.fc2.weight": "model-00004-of-00004.safetensors",
|
712 |
+
"vit.vision_tower.vision_model.encoder.layers.17.self_attn.k_proj.bias": "model-00004-of-00004.safetensors",
|
713 |
+
"vit.vision_tower.vision_model.encoder.layers.17.self_attn.k_proj.weight": "model-00004-of-00004.safetensors",
|
714 |
+
"vit.vision_tower.vision_model.encoder.layers.17.self_attn.out_proj.bias": "model-00004-of-00004.safetensors",
|
715 |
+
"vit.vision_tower.vision_model.encoder.layers.17.self_attn.out_proj.weight": "model-00004-of-00004.safetensors",
|
716 |
+
"vit.vision_tower.vision_model.encoder.layers.17.self_attn.q_proj.bias": "model-00004-of-00004.safetensors",
|
717 |
+
"vit.vision_tower.vision_model.encoder.layers.17.self_attn.q_proj.weight": "model-00004-of-00004.safetensors",
|
718 |
+
"vit.vision_tower.vision_model.encoder.layers.17.self_attn.v_proj.bias": "model-00004-of-00004.safetensors",
|
719 |
+
"vit.vision_tower.vision_model.encoder.layers.17.self_attn.v_proj.weight": "model-00004-of-00004.safetensors",
|
720 |
+
"vit.vision_tower.vision_model.encoder.layers.18.layer_norm1.bias": "model-00004-of-00004.safetensors",
|
721 |
+
"vit.vision_tower.vision_model.encoder.layers.18.layer_norm1.weight": "model-00004-of-00004.safetensors",
|
722 |
+
"vit.vision_tower.vision_model.encoder.layers.18.layer_norm2.bias": "model-00004-of-00004.safetensors",
|
723 |
+
"vit.vision_tower.vision_model.encoder.layers.18.layer_norm2.weight": "model-00004-of-00004.safetensors",
|
724 |
+
"vit.vision_tower.vision_model.encoder.layers.18.mlp.fc1.bias": "model-00004-of-00004.safetensors",
|
725 |
+
"vit.vision_tower.vision_model.encoder.layers.18.mlp.fc1.weight": "model-00004-of-00004.safetensors",
|
726 |
+
"vit.vision_tower.vision_model.encoder.layers.18.mlp.fc2.bias": "model-00004-of-00004.safetensors",
|
727 |
+
"vit.vision_tower.vision_model.encoder.layers.18.mlp.fc2.weight": "model-00004-of-00004.safetensors",
|
728 |
+
"vit.vision_tower.vision_model.encoder.layers.18.self_attn.k_proj.bias": "model-00004-of-00004.safetensors",
|
729 |
+
"vit.vision_tower.vision_model.encoder.layers.18.self_attn.k_proj.weight": "model-00004-of-00004.safetensors",
|
730 |
+
"vit.vision_tower.vision_model.encoder.layers.18.self_attn.out_proj.bias": "model-00004-of-00004.safetensors",
|
731 |
+
"vit.vision_tower.vision_model.encoder.layers.18.self_attn.out_proj.weight": "model-00004-of-00004.safetensors",
|
732 |
+
"vit.vision_tower.vision_model.encoder.layers.18.self_attn.q_proj.bias": "model-00004-of-00004.safetensors",
|
733 |
+
"vit.vision_tower.vision_model.encoder.layers.18.self_attn.q_proj.weight": "model-00004-of-00004.safetensors",
|
734 |
+
"vit.vision_tower.vision_model.encoder.layers.18.self_attn.v_proj.bias": "model-00004-of-00004.safetensors",
|
735 |
+
"vit.vision_tower.vision_model.encoder.layers.18.self_attn.v_proj.weight": "model-00004-of-00004.safetensors",
|
736 |
+
"vit.vision_tower.vision_model.encoder.layers.19.layer_norm1.bias": "model-00004-of-00004.safetensors",
|
737 |
+
"vit.vision_tower.vision_model.encoder.layers.19.layer_norm1.weight": "model-00004-of-00004.safetensors",
|
738 |
+
"vit.vision_tower.vision_model.encoder.layers.19.layer_norm2.bias": "model-00004-of-00004.safetensors",
|
739 |
+
"vit.vision_tower.vision_model.encoder.layers.19.layer_norm2.weight": "model-00004-of-00004.safetensors",
|
740 |
+
"vit.vision_tower.vision_model.encoder.layers.19.mlp.fc1.bias": "model-00004-of-00004.safetensors",
|
741 |
+
"vit.vision_tower.vision_model.encoder.layers.19.mlp.fc1.weight": "model-00004-of-00004.safetensors",
|
742 |
+
"vit.vision_tower.vision_model.encoder.layers.19.mlp.fc2.bias": "model-00004-of-00004.safetensors",
|
743 |
+
"vit.vision_tower.vision_model.encoder.layers.19.mlp.fc2.weight": "model-00004-of-00004.safetensors",
|
744 |
+
"vit.vision_tower.vision_model.encoder.layers.19.self_attn.k_proj.bias": "model-00004-of-00004.safetensors",
|
745 |
+
"vit.vision_tower.vision_model.encoder.layers.19.self_attn.k_proj.weight": "model-00004-of-00004.safetensors",
|
746 |
+
"vit.vision_tower.vision_model.encoder.layers.19.self_attn.out_proj.bias": "model-00004-of-00004.safetensors",
|
747 |
+
"vit.vision_tower.vision_model.encoder.layers.19.self_attn.out_proj.weight": "model-00004-of-00004.safetensors",
|
748 |
+
"vit.vision_tower.vision_model.encoder.layers.19.self_attn.q_proj.bias": "model-00004-of-00004.safetensors",
|
749 |
+
"vit.vision_tower.vision_model.encoder.layers.19.self_attn.q_proj.weight": "model-00004-of-00004.safetensors",
|
750 |
+
"vit.vision_tower.vision_model.encoder.layers.19.self_attn.v_proj.bias": "model-00004-of-00004.safetensors",
|
751 |
+
"vit.vision_tower.vision_model.encoder.layers.19.self_attn.v_proj.weight": "model-00004-of-00004.safetensors",
|
752 |
+
"vit.vision_tower.vision_model.encoder.layers.2.layer_norm1.bias": "model-00004-of-00004.safetensors",
|
753 |
+
"vit.vision_tower.vision_model.encoder.layers.2.layer_norm1.weight": "model-00004-of-00004.safetensors",
|
754 |
+
"vit.vision_tower.vision_model.encoder.layers.2.layer_norm2.bias": "model-00004-of-00004.safetensors",
|
755 |
+
"vit.vision_tower.vision_model.encoder.layers.2.layer_norm2.weight": "model-00004-of-00004.safetensors",
|
756 |
+
"vit.vision_tower.vision_model.encoder.layers.2.mlp.fc1.bias": "model-00004-of-00004.safetensors",
|
757 |
+
"vit.vision_tower.vision_model.encoder.layers.2.mlp.fc1.weight": "model-00004-of-00004.safetensors",
|
758 |
+
"vit.vision_tower.vision_model.encoder.layers.2.mlp.fc2.bias": "model-00004-of-00004.safetensors",
|
759 |
+
"vit.vision_tower.vision_model.encoder.layers.2.mlp.fc2.weight": "model-00004-of-00004.safetensors",
|
760 |
+
"vit.vision_tower.vision_model.encoder.layers.2.self_attn.k_proj.bias": "model-00004-of-00004.safetensors",
|
761 |
+
"vit.vision_tower.vision_model.encoder.layers.2.self_attn.k_proj.weight": "model-00004-of-00004.safetensors",
|
762 |
+
"vit.vision_tower.vision_model.encoder.layers.2.self_attn.out_proj.bias": "model-00004-of-00004.safetensors",
|
763 |
+
"vit.vision_tower.vision_model.encoder.layers.2.self_attn.out_proj.weight": "model-00004-of-00004.safetensors",
|
764 |
+
"vit.vision_tower.vision_model.encoder.layers.2.self_attn.q_proj.bias": "model-00004-of-00004.safetensors",
|
765 |
+
"vit.vision_tower.vision_model.encoder.layers.2.self_attn.q_proj.weight": "model-00004-of-00004.safetensors",
|
766 |
+
"vit.vision_tower.vision_model.encoder.layers.2.self_attn.v_proj.bias": "model-00004-of-00004.safetensors",
|
767 |
+
"vit.vision_tower.vision_model.encoder.layers.2.self_attn.v_proj.weight": "model-00004-of-00004.safetensors",
|
768 |
+
"vit.vision_tower.vision_model.encoder.layers.20.layer_norm1.bias": "model-00004-of-00004.safetensors",
|
769 |
+
"vit.vision_tower.vision_model.encoder.layers.20.layer_norm1.weight": "model-00004-of-00004.safetensors",
|
770 |
+
"vit.vision_tower.vision_model.encoder.layers.20.layer_norm2.bias": "model-00004-of-00004.safetensors",
|
771 |
+
"vit.vision_tower.vision_model.encoder.layers.20.layer_norm2.weight": "model-00004-of-00004.safetensors",
|
772 |
+
"vit.vision_tower.vision_model.encoder.layers.20.mlp.fc1.bias": "model-00004-of-00004.safetensors",
|
773 |
+
"vit.vision_tower.vision_model.encoder.layers.20.mlp.fc1.weight": "model-00004-of-00004.safetensors",
|
774 |
+
"vit.vision_tower.vision_model.encoder.layers.20.mlp.fc2.bias": "model-00004-of-00004.safetensors",
|
775 |
+
"vit.vision_tower.vision_model.encoder.layers.20.mlp.fc2.weight": "model-00004-of-00004.safetensors",
|
776 |
+
"vit.vision_tower.vision_model.encoder.layers.20.self_attn.k_proj.bias": "model-00004-of-00004.safetensors",
|
777 |
+
"vit.vision_tower.vision_model.encoder.layers.20.self_attn.k_proj.weight": "model-00004-of-00004.safetensors",
|
778 |
+
"vit.vision_tower.vision_model.encoder.layers.20.self_attn.out_proj.bias": "model-00004-of-00004.safetensors",
|
779 |
+
"vit.vision_tower.vision_model.encoder.layers.20.self_attn.out_proj.weight": "model-00004-of-00004.safetensors",
|
780 |
+
"vit.vision_tower.vision_model.encoder.layers.20.self_attn.q_proj.bias": "model-00004-of-00004.safetensors",
|
781 |
+
"vit.vision_tower.vision_model.encoder.layers.20.self_attn.q_proj.weight": "model-00004-of-00004.safetensors",
|
782 |
+
"vit.vision_tower.vision_model.encoder.layers.20.self_attn.v_proj.bias": "model-00004-of-00004.safetensors",
|
783 |
+
"vit.vision_tower.vision_model.encoder.layers.20.self_attn.v_proj.weight": "model-00004-of-00004.safetensors",
|
784 |
+
"vit.vision_tower.vision_model.encoder.layers.21.layer_norm1.bias": "model-00004-of-00004.safetensors",
|
785 |
+
"vit.vision_tower.vision_model.encoder.layers.21.layer_norm1.weight": "model-00004-of-00004.safetensors",
|
786 |
+
"vit.vision_tower.vision_model.encoder.layers.21.layer_norm2.bias": "model-00004-of-00004.safetensors",
|
787 |
+
"vit.vision_tower.vision_model.encoder.layers.21.layer_norm2.weight": "model-00004-of-00004.safetensors",
|
788 |
+
"vit.vision_tower.vision_model.encoder.layers.21.mlp.fc1.bias": "model-00004-of-00004.safetensors",
|
789 |
+
"vit.vision_tower.vision_model.encoder.layers.21.mlp.fc1.weight": "model-00004-of-00004.safetensors",
|
790 |
+
"vit.vision_tower.vision_model.encoder.layers.21.mlp.fc2.bias": "model-00004-of-00004.safetensors",
|
791 |
+
"vit.vision_tower.vision_model.encoder.layers.21.mlp.fc2.weight": "model-00004-of-00004.safetensors",
|
792 |
+
"vit.vision_tower.vision_model.encoder.layers.21.self_attn.k_proj.bias": "model-00004-of-00004.safetensors",
|
793 |
+
"vit.vision_tower.vision_model.encoder.layers.21.self_attn.k_proj.weight": "model-00004-of-00004.safetensors",
|
794 |
+
"vit.vision_tower.vision_model.encoder.layers.21.self_attn.out_proj.bias": "model-00004-of-00004.safetensors",
|
795 |
+
"vit.vision_tower.vision_model.encoder.layers.21.self_attn.out_proj.weight": "model-00004-of-00004.safetensors",
|
796 |
+
"vit.vision_tower.vision_model.encoder.layers.21.self_attn.q_proj.bias": "model-00004-of-00004.safetensors",
|
797 |
+
"vit.vision_tower.vision_model.encoder.layers.21.self_attn.q_proj.weight": "model-00004-of-00004.safetensors",
|
798 |
+
"vit.vision_tower.vision_model.encoder.layers.21.self_attn.v_proj.bias": "model-00004-of-00004.safetensors",
|
799 |
+
"vit.vision_tower.vision_model.encoder.layers.21.self_attn.v_proj.weight": "model-00004-of-00004.safetensors",
|
800 |
+
"vit.vision_tower.vision_model.encoder.layers.22.layer_norm1.bias": "model-00004-of-00004.safetensors",
|
801 |
+
"vit.vision_tower.vision_model.encoder.layers.22.layer_norm1.weight": "model-00004-of-00004.safetensors",
|
802 |
+
"vit.vision_tower.vision_model.encoder.layers.22.layer_norm2.bias": "model-00004-of-00004.safetensors",
|
803 |
+
"vit.vision_tower.vision_model.encoder.layers.22.layer_norm2.weight": "model-00004-of-00004.safetensors",
|
804 |
+
"vit.vision_tower.vision_model.encoder.layers.22.mlp.fc1.bias": "model-00004-of-00004.safetensors",
|
805 |
+
"vit.vision_tower.vision_model.encoder.layers.22.mlp.fc1.weight": "model-00004-of-00004.safetensors",
|
806 |
+
"vit.vision_tower.vision_model.encoder.layers.22.mlp.fc2.bias": "model-00004-of-00004.safetensors",
|
807 |
+
"vit.vision_tower.vision_model.encoder.layers.22.mlp.fc2.weight": "model-00004-of-00004.safetensors",
|
808 |
+
"vit.vision_tower.vision_model.encoder.layers.22.self_attn.k_proj.bias": "model-00004-of-00004.safetensors",
|
809 |
+
"vit.vision_tower.vision_model.encoder.layers.22.self_attn.k_proj.weight": "model-00004-of-00004.safetensors",
|
810 |
+
"vit.vision_tower.vision_model.encoder.layers.22.self_attn.out_proj.bias": "model-00004-of-00004.safetensors",
|
811 |
+
"vit.vision_tower.vision_model.encoder.layers.22.self_attn.out_proj.weight": "model-00004-of-00004.safetensors",
|
812 |
+
"vit.vision_tower.vision_model.encoder.layers.22.self_attn.q_proj.bias": "model-00004-of-00004.safetensors",
|
813 |
+
"vit.vision_tower.vision_model.encoder.layers.22.self_attn.q_proj.weight": "model-00004-of-00004.safetensors",
|
814 |
+
"vit.vision_tower.vision_model.encoder.layers.22.self_attn.v_proj.bias": "model-00004-of-00004.safetensors",
|
815 |
+
"vit.vision_tower.vision_model.encoder.layers.22.self_attn.v_proj.weight": "model-00004-of-00004.safetensors",
|
816 |
+
"vit.vision_tower.vision_model.encoder.layers.23.layer_norm1.bias": "model-00004-of-00004.safetensors",
|
817 |
+
"vit.vision_tower.vision_model.encoder.layers.23.layer_norm1.weight": "model-00004-of-00004.safetensors",
|
818 |
+
"vit.vision_tower.vision_model.encoder.layers.23.layer_norm2.bias": "model-00004-of-00004.safetensors",
|
819 |
+
"vit.vision_tower.vision_model.encoder.layers.23.layer_norm2.weight": "model-00004-of-00004.safetensors",
|
820 |
+
"vit.vision_tower.vision_model.encoder.layers.23.mlp.fc1.bias": "model-00004-of-00004.safetensors",
|
821 |
+
"vit.vision_tower.vision_model.encoder.layers.23.mlp.fc1.weight": "model-00004-of-00004.safetensors",
|
822 |
+
"vit.vision_tower.vision_model.encoder.layers.23.mlp.fc2.bias": "model-00004-of-00004.safetensors",
|
823 |
+
"vit.vision_tower.vision_model.encoder.layers.23.mlp.fc2.weight": "model-00004-of-00004.safetensors",
|
824 |
+
"vit.vision_tower.vision_model.encoder.layers.23.self_attn.k_proj.bias": "model-00004-of-00004.safetensors",
|
825 |
+
"vit.vision_tower.vision_model.encoder.layers.23.self_attn.k_proj.weight": "model-00004-of-00004.safetensors",
|
826 |
+
"vit.vision_tower.vision_model.encoder.layers.23.self_attn.out_proj.bias": "model-00004-of-00004.safetensors",
|
827 |
+
"vit.vision_tower.vision_model.encoder.layers.23.self_attn.out_proj.weight": "model-00004-of-00004.safetensors",
|
828 |
+
"vit.vision_tower.vision_model.encoder.layers.23.self_attn.q_proj.bias": "model-00004-of-00004.safetensors",
|
829 |
+
"vit.vision_tower.vision_model.encoder.layers.23.self_attn.q_proj.weight": "model-00004-of-00004.safetensors",
|
830 |
+
"vit.vision_tower.vision_model.encoder.layers.23.self_attn.v_proj.bias": "model-00004-of-00004.safetensors",
|
831 |
+
"vit.vision_tower.vision_model.encoder.layers.23.self_attn.v_proj.weight": "model-00004-of-00004.safetensors",
|
832 |
+
"vit.vision_tower.vision_model.encoder.layers.3.layer_norm1.bias": "model-00004-of-00004.safetensors",
|
833 |
+
"vit.vision_tower.vision_model.encoder.layers.3.layer_norm1.weight": "model-00004-of-00004.safetensors",
|
834 |
+
"vit.vision_tower.vision_model.encoder.layers.3.layer_norm2.bias": "model-00004-of-00004.safetensors",
|
835 |
+
"vit.vision_tower.vision_model.encoder.layers.3.layer_norm2.weight": "model-00004-of-00004.safetensors",
|
836 |
+
"vit.vision_tower.vision_model.encoder.layers.3.mlp.fc1.bias": "model-00004-of-00004.safetensors",
|
837 |
+
"vit.vision_tower.vision_model.encoder.layers.3.mlp.fc1.weight": "model-00004-of-00004.safetensors",
|
838 |
+
"vit.vision_tower.vision_model.encoder.layers.3.mlp.fc2.bias": "model-00004-of-00004.safetensors",
|
839 |
+
"vit.vision_tower.vision_model.encoder.layers.3.mlp.fc2.weight": "model-00004-of-00004.safetensors",
|
840 |
+
"vit.vision_tower.vision_model.encoder.layers.3.self_attn.k_proj.bias": "model-00004-of-00004.safetensors",
|
841 |
+
"vit.vision_tower.vision_model.encoder.layers.3.self_attn.k_proj.weight": "model-00004-of-00004.safetensors",
|
842 |
+
"vit.vision_tower.vision_model.encoder.layers.3.self_attn.out_proj.bias": "model-00004-of-00004.safetensors",
|
843 |
+
"vit.vision_tower.vision_model.encoder.layers.3.self_attn.out_proj.weight": "model-00004-of-00004.safetensors",
|
844 |
+
"vit.vision_tower.vision_model.encoder.layers.3.self_attn.q_proj.bias": "model-00004-of-00004.safetensors",
|
845 |
+
"vit.vision_tower.vision_model.encoder.layers.3.self_attn.q_proj.weight": "model-00004-of-00004.safetensors",
|
846 |
+
"vit.vision_tower.vision_model.encoder.layers.3.self_attn.v_proj.bias": "model-00004-of-00004.safetensors",
|
847 |
+
"vit.vision_tower.vision_model.encoder.layers.3.self_attn.v_proj.weight": "model-00004-of-00004.safetensors",
|
848 |
+
"vit.vision_tower.vision_model.encoder.layers.4.layer_norm1.bias": "model-00004-of-00004.safetensors",
|
849 |
+
"vit.vision_tower.vision_model.encoder.layers.4.layer_norm1.weight": "model-00004-of-00004.safetensors",
|
850 |
+
"vit.vision_tower.vision_model.encoder.layers.4.layer_norm2.bias": "model-00004-of-00004.safetensors",
|
851 |
+
"vit.vision_tower.vision_model.encoder.layers.4.layer_norm2.weight": "model-00004-of-00004.safetensors",
|
852 |
+
"vit.vision_tower.vision_model.encoder.layers.4.mlp.fc1.bias": "model-00004-of-00004.safetensors",
|
853 |
+
"vit.vision_tower.vision_model.encoder.layers.4.mlp.fc1.weight": "model-00004-of-00004.safetensors",
|
854 |
+
"vit.vision_tower.vision_model.encoder.layers.4.mlp.fc2.bias": "model-00004-of-00004.safetensors",
|
855 |
+
"vit.vision_tower.vision_model.encoder.layers.4.mlp.fc2.weight": "model-00004-of-00004.safetensors",
|
856 |
+
"vit.vision_tower.vision_model.encoder.layers.4.self_attn.k_proj.bias": "model-00004-of-00004.safetensors",
|
857 |
+
"vit.vision_tower.vision_model.encoder.layers.4.self_attn.k_proj.weight": "model-00004-of-00004.safetensors",
|
858 |
+
"vit.vision_tower.vision_model.encoder.layers.4.self_attn.out_proj.bias": "model-00004-of-00004.safetensors",
|
859 |
+
"vit.vision_tower.vision_model.encoder.layers.4.self_attn.out_proj.weight": "model-00004-of-00004.safetensors",
|
860 |
+
"vit.vision_tower.vision_model.encoder.layers.4.self_attn.q_proj.bias": "model-00004-of-00004.safetensors",
|
861 |
+
"vit.vision_tower.vision_model.encoder.layers.4.self_attn.q_proj.weight": "model-00004-of-00004.safetensors",
|
862 |
+
"vit.vision_tower.vision_model.encoder.layers.4.self_attn.v_proj.bias": "model-00004-of-00004.safetensors",
|
863 |
+
"vit.vision_tower.vision_model.encoder.layers.4.self_attn.v_proj.weight": "model-00004-of-00004.safetensors",
|
864 |
+
"vit.vision_tower.vision_model.encoder.layers.5.layer_norm1.bias": "model-00004-of-00004.safetensors",
|
865 |
+
"vit.vision_tower.vision_model.encoder.layers.5.layer_norm1.weight": "model-00004-of-00004.safetensors",
|
866 |
+
"vit.vision_tower.vision_model.encoder.layers.5.layer_norm2.bias": "model-00004-of-00004.safetensors",
|
867 |
+
"vit.vision_tower.vision_model.encoder.layers.5.layer_norm2.weight": "model-00004-of-00004.safetensors",
|
868 |
+
"vit.vision_tower.vision_model.encoder.layers.5.mlp.fc1.bias": "model-00004-of-00004.safetensors",
|
869 |
+
"vit.vision_tower.vision_model.encoder.layers.5.mlp.fc1.weight": "model-00004-of-00004.safetensors",
|
870 |
+
"vit.vision_tower.vision_model.encoder.layers.5.mlp.fc2.bias": "model-00004-of-00004.safetensors",
|
871 |
+
"vit.vision_tower.vision_model.encoder.layers.5.mlp.fc2.weight": "model-00004-of-00004.safetensors",
|
872 |
+
"vit.vision_tower.vision_model.encoder.layers.5.self_attn.k_proj.bias": "model-00004-of-00004.safetensors",
|
873 |
+
"vit.vision_tower.vision_model.encoder.layers.5.self_attn.k_proj.weight": "model-00004-of-00004.safetensors",
|
874 |
+
"vit.vision_tower.vision_model.encoder.layers.5.self_attn.out_proj.bias": "model-00004-of-00004.safetensors",
|
875 |
+
"vit.vision_tower.vision_model.encoder.layers.5.self_attn.out_proj.weight": "model-00004-of-00004.safetensors",
|
876 |
+
"vit.vision_tower.vision_model.encoder.layers.5.self_attn.q_proj.bias": "model-00004-of-00004.safetensors",
|
877 |
+
"vit.vision_tower.vision_model.encoder.layers.5.self_attn.q_proj.weight": "model-00004-of-00004.safetensors",
|
878 |
+
"vit.vision_tower.vision_model.encoder.layers.5.self_attn.v_proj.bias": "model-00004-of-00004.safetensors",
|
879 |
+
"vit.vision_tower.vision_model.encoder.layers.5.self_attn.v_proj.weight": "model-00004-of-00004.safetensors",
|
880 |
+
"vit.vision_tower.vision_model.encoder.layers.6.layer_norm1.bias": "model-00004-of-00004.safetensors",
|
881 |
+
"vit.vision_tower.vision_model.encoder.layers.6.layer_norm1.weight": "model-00004-of-00004.safetensors",
|
882 |
+
"vit.vision_tower.vision_model.encoder.layers.6.layer_norm2.bias": "model-00004-of-00004.safetensors",
|
883 |
+
"vit.vision_tower.vision_model.encoder.layers.6.layer_norm2.weight": "model-00004-of-00004.safetensors",
|
884 |
+
"vit.vision_tower.vision_model.encoder.layers.6.mlp.fc1.bias": "model-00004-of-00004.safetensors",
|
885 |
+
"vit.vision_tower.vision_model.encoder.layers.6.mlp.fc1.weight": "model-00004-of-00004.safetensors",
|
886 |
+
"vit.vision_tower.vision_model.encoder.layers.6.mlp.fc2.bias": "model-00004-of-00004.safetensors",
|
887 |
+
"vit.vision_tower.vision_model.encoder.layers.6.mlp.fc2.weight": "model-00004-of-00004.safetensors",
|
888 |
+
"vit.vision_tower.vision_model.encoder.layers.6.self_attn.k_proj.bias": "model-00004-of-00004.safetensors",
|
889 |
+
"vit.vision_tower.vision_model.encoder.layers.6.self_attn.k_proj.weight": "model-00004-of-00004.safetensors",
|
890 |
+
"vit.vision_tower.vision_model.encoder.layers.6.self_attn.out_proj.bias": "model-00004-of-00004.safetensors",
|
891 |
+
"vit.vision_tower.vision_model.encoder.layers.6.self_attn.out_proj.weight": "model-00004-of-00004.safetensors",
|
892 |
+
"vit.vision_tower.vision_model.encoder.layers.6.self_attn.q_proj.bias": "model-00004-of-00004.safetensors",
|
893 |
+
"vit.vision_tower.vision_model.encoder.layers.6.self_attn.q_proj.weight": "model-00004-of-00004.safetensors",
|
894 |
+
"vit.vision_tower.vision_model.encoder.layers.6.self_attn.v_proj.bias": "model-00004-of-00004.safetensors",
|
895 |
+
"vit.vision_tower.vision_model.encoder.layers.6.self_attn.v_proj.weight": "model-00004-of-00004.safetensors",
|
896 |
+
"vit.vision_tower.vision_model.encoder.layers.7.layer_norm1.bias": "model-00004-of-00004.safetensors",
|
897 |
+
"vit.vision_tower.vision_model.encoder.layers.7.layer_norm1.weight": "model-00004-of-00004.safetensors",
|
898 |
+
"vit.vision_tower.vision_model.encoder.layers.7.layer_norm2.bias": "model-00004-of-00004.safetensors",
|
899 |
+
"vit.vision_tower.vision_model.encoder.layers.7.layer_norm2.weight": "model-00004-of-00004.safetensors",
|
900 |
+
"vit.vision_tower.vision_model.encoder.layers.7.mlp.fc1.bias": "model-00004-of-00004.safetensors",
|
901 |
+
"vit.vision_tower.vision_model.encoder.layers.7.mlp.fc1.weight": "model-00004-of-00004.safetensors",
|
902 |
+
"vit.vision_tower.vision_model.encoder.layers.7.mlp.fc2.bias": "model-00004-of-00004.safetensors",
|
903 |
+
"vit.vision_tower.vision_model.encoder.layers.7.mlp.fc2.weight": "model-00004-of-00004.safetensors",
|
904 |
+
"vit.vision_tower.vision_model.encoder.layers.7.self_attn.k_proj.bias": "model-00004-of-00004.safetensors",
|
905 |
+
"vit.vision_tower.vision_model.encoder.layers.7.self_attn.k_proj.weight": "model-00004-of-00004.safetensors",
|
906 |
+
"vit.vision_tower.vision_model.encoder.layers.7.self_attn.out_proj.bias": "model-00004-of-00004.safetensors",
|
907 |
+
"vit.vision_tower.vision_model.encoder.layers.7.self_attn.out_proj.weight": "model-00004-of-00004.safetensors",
|
908 |
+
"vit.vision_tower.vision_model.encoder.layers.7.self_attn.q_proj.bias": "model-00004-of-00004.safetensors",
|
909 |
+
"vit.vision_tower.vision_model.encoder.layers.7.self_attn.q_proj.weight": "model-00004-of-00004.safetensors",
|
910 |
+
"vit.vision_tower.vision_model.encoder.layers.7.self_attn.v_proj.bias": "model-00004-of-00004.safetensors",
|
911 |
+
"vit.vision_tower.vision_model.encoder.layers.7.self_attn.v_proj.weight": "model-00004-of-00004.safetensors",
|
912 |
+
"vit.vision_tower.vision_model.encoder.layers.8.layer_norm1.bias": "model-00004-of-00004.safetensors",
|
913 |
+
"vit.vision_tower.vision_model.encoder.layers.8.layer_norm1.weight": "model-00004-of-00004.safetensors",
|
914 |
+
"vit.vision_tower.vision_model.encoder.layers.8.layer_norm2.bias": "model-00004-of-00004.safetensors",
|
915 |
+
"vit.vision_tower.vision_model.encoder.layers.8.layer_norm2.weight": "model-00004-of-00004.safetensors",
|
916 |
+
"vit.vision_tower.vision_model.encoder.layers.8.mlp.fc1.bias": "model-00004-of-00004.safetensors",
|
917 |
+
"vit.vision_tower.vision_model.encoder.layers.8.mlp.fc1.weight": "model-00004-of-00004.safetensors",
|
918 |
+
"vit.vision_tower.vision_model.encoder.layers.8.mlp.fc2.bias": "model-00004-of-00004.safetensors",
|
919 |
+
"vit.vision_tower.vision_model.encoder.layers.8.mlp.fc2.weight": "model-00004-of-00004.safetensors",
|
920 |
+
"vit.vision_tower.vision_model.encoder.layers.8.self_attn.k_proj.bias": "model-00004-of-00004.safetensors",
|
921 |
+
"vit.vision_tower.vision_model.encoder.layers.8.self_attn.k_proj.weight": "model-00004-of-00004.safetensors",
|
922 |
+
"vit.vision_tower.vision_model.encoder.layers.8.self_attn.out_proj.bias": "model-00004-of-00004.safetensors",
|
923 |
+
"vit.vision_tower.vision_model.encoder.layers.8.self_attn.out_proj.weight": "model-00004-of-00004.safetensors",
|
924 |
+
"vit.vision_tower.vision_model.encoder.layers.8.self_attn.q_proj.bias": "model-00004-of-00004.safetensors",
|
925 |
+
"vit.vision_tower.vision_model.encoder.layers.8.self_attn.q_proj.weight": "model-00004-of-00004.safetensors",
|
926 |
+
"vit.vision_tower.vision_model.encoder.layers.8.self_attn.v_proj.bias": "model-00004-of-00004.safetensors",
|
927 |
+
"vit.vision_tower.vision_model.encoder.layers.8.self_attn.v_proj.weight": "model-00004-of-00004.safetensors",
|
928 |
+
"vit.vision_tower.vision_model.encoder.layers.9.layer_norm1.bias": "model-00004-of-00004.safetensors",
|
929 |
+
"vit.vision_tower.vision_model.encoder.layers.9.layer_norm1.weight": "model-00004-of-00004.safetensors",
|
930 |
+
"vit.vision_tower.vision_model.encoder.layers.9.layer_norm2.bias": "model-00004-of-00004.safetensors",
|
931 |
+
"vit.vision_tower.vision_model.encoder.layers.9.layer_norm2.weight": "model-00004-of-00004.safetensors",
|
932 |
+
"vit.vision_tower.vision_model.encoder.layers.9.mlp.fc1.bias": "model-00004-of-00004.safetensors",
|
933 |
+
"vit.vision_tower.vision_model.encoder.layers.9.mlp.fc1.weight": "model-00004-of-00004.safetensors",
|
934 |
+
"vit.vision_tower.vision_model.encoder.layers.9.mlp.fc2.bias": "model-00004-of-00004.safetensors",
|
935 |
+
"vit.vision_tower.vision_model.encoder.layers.9.mlp.fc2.weight": "model-00004-of-00004.safetensors",
|
936 |
+
"vit.vision_tower.vision_model.encoder.layers.9.self_attn.k_proj.bias": "model-00004-of-00004.safetensors",
|
937 |
+
"vit.vision_tower.vision_model.encoder.layers.9.self_attn.k_proj.weight": "model-00004-of-00004.safetensors",
|
938 |
+
"vit.vision_tower.vision_model.encoder.layers.9.self_attn.out_proj.bias": "model-00004-of-00004.safetensors",
|
939 |
+
"vit.vision_tower.vision_model.encoder.layers.9.self_attn.out_proj.weight": "model-00004-of-00004.safetensors",
|
940 |
+
"vit.vision_tower.vision_model.encoder.layers.9.self_attn.q_proj.bias": "model-00004-of-00004.safetensors",
|
941 |
+
"vit.vision_tower.vision_model.encoder.layers.9.self_attn.q_proj.weight": "model-00004-of-00004.safetensors",
|
942 |
+
"vit.vision_tower.vision_model.encoder.layers.9.self_attn.v_proj.bias": "model-00004-of-00004.safetensors",
|
943 |
+
"vit.vision_tower.vision_model.encoder.layers.9.self_attn.v_proj.weight": "model-00004-of-00004.safetensors",
|
944 |
+
"vit.vision_tower.vision_model.post_layernorm.bias": "model-00004-of-00004.safetensors",
|
945 |
+
"vit.vision_tower.vision_model.post_layernorm.weight": "model-00004-of-00004.safetensors",
|
946 |
+
"vit.vision_tower.vision_model.pre_layrnorm.bias": "model-00004-of-00004.safetensors",
|
947 |
+
"vit.vision_tower.vision_model.pre_layrnorm.weight": "model-00004-of-00004.safetensors"
|
948 |
+
}
|
949 |
+
}
|
modeling_internlm2.py
ADDED
@@ -0,0 +1,965 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# # Copyright (c) InternLM. All rights reserved.
|
2 |
+
#
|
3 |
+
# This code is based on EleutherAI's GPT-NeoX library and the GPT-NeoX
|
4 |
+
# and OPT implementations in this library. It has been modified from its
|
5 |
+
# original forms to accommodate minor architectural differences compared
|
6 |
+
# to GPT-NeoX and OPT used by the Meta AI team that trained the model.
|
7 |
+
#
|
8 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
9 |
+
# you may not use this file except in compliance with the License.
|
10 |
+
# You may obtain a copy of the License at
|
11 |
+
#
|
12 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
13 |
+
#
|
14 |
+
# Unless required by applicable law or agreed to in writing, software
|
15 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
16 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
17 |
+
# See the License for the specific language governing permissions and
|
18 |
+
# limitations under the License.
|
19 |
+
"""PyTorch InternLM2 model."""
|
20 |
+
import math
|
21 |
+
import warnings
|
22 |
+
from typing import List, Optional, Tuple, Union
|
23 |
+
|
24 |
+
import torch
|
25 |
+
import torch.utils.checkpoint
|
26 |
+
from einops import rearrange
|
27 |
+
from torch import nn
|
28 |
+
from transformers.activations import ACT2FN
|
29 |
+
from transformers.modeling_outputs import BaseModelOutputWithPast
|
30 |
+
from transformers.modeling_utils import PreTrainedModel
|
31 |
+
from transformers.utils import (add_start_docstrings,
|
32 |
+
add_start_docstrings_to_model_forward, logging)
|
33 |
+
|
34 |
+
try:
|
35 |
+
from transformers.generation.streamers import BaseStreamer
|
36 |
+
except: # noqa # pylint: disable=bare-except
|
37 |
+
BaseStreamer = None
|
38 |
+
|
39 |
+
from .build_mlp import PLoRA
|
40 |
+
from .configuration_internlm_xcomposer2 import InternLMXcomposer2Config as InternLM2Config
|
41 |
+
logger = logging.get_logger(__name__)
|
42 |
+
|
43 |
+
_CONFIG_FOR_DOC = 'InternLM2Config'
|
44 |
+
|
45 |
+
|
46 |
+
# Copied from transformers.models.bart.modeling_bart._make_causal_mask
|
47 |
+
def _make_causal_mask(input_ids_shape: torch.Size,
|
48 |
+
dtype: torch.dtype,
|
49 |
+
device: torch.device,
|
50 |
+
past_key_values_length: int = 0):
|
51 |
+
"""Make causal mask used for bi-directional self-attention."""
|
52 |
+
bsz, tgt_len = input_ids_shape
|
53 |
+
mask = torch.full((tgt_len, tgt_len),
|
54 |
+
torch.tensor(torch.finfo(dtype).min, device=device),
|
55 |
+
device=device)
|
56 |
+
mask_cond = torch.arange(mask.size(-1), device=device)
|
57 |
+
mask.masked_fill_(mask_cond < (mask_cond + 1).view(mask.size(-1), 1), 0)
|
58 |
+
mask = mask.to(dtype)
|
59 |
+
|
60 |
+
if past_key_values_length > 0:
|
61 |
+
mask = torch.cat([
|
62 |
+
torch.zeros(
|
63 |
+
tgt_len, past_key_values_length, dtype=dtype, device=device),
|
64 |
+
mask
|
65 |
+
],
|
66 |
+
dim=-1)
|
67 |
+
return mask[None, None, :, :].expand(bsz, 1, tgt_len,
|
68 |
+
tgt_len + past_key_values_length)
|
69 |
+
|
70 |
+
|
71 |
+
# Copied from transformers.models.bart.modeling_bart._expand_mask
|
72 |
+
def _expand_mask(mask: torch.Tensor,
|
73 |
+
dtype: torch.dtype,
|
74 |
+
tgt_len: Optional[int] = None):
|
75 |
+
"""Expands attention_mask from `[bsz, seq_len]` to `[bsz, 1, tgt_seq_len,
|
76 |
+
src_seq_len]`."""
|
77 |
+
bsz, src_len = mask.size()
|
78 |
+
tgt_len = tgt_len if tgt_len is not None else src_len
|
79 |
+
|
80 |
+
expanded_mask = mask[:, None, None, :].expand(bsz, 1, tgt_len,
|
81 |
+
src_len).to(dtype)
|
82 |
+
|
83 |
+
inverted_mask = 1.0 - expanded_mask
|
84 |
+
|
85 |
+
return inverted_mask.masked_fill(
|
86 |
+
inverted_mask.to(torch.bool),
|
87 |
+
torch.finfo(dtype).min)
|
88 |
+
|
89 |
+
|
90 |
+
class InternLM2RMSNorm(nn.Module):
|
91 |
+
|
92 |
+
def __init__(self, hidden_size, eps=1e-6):
|
93 |
+
"""InternLM2RMSNorm is equivalent to T5LayerNorm."""
|
94 |
+
super().__init__()
|
95 |
+
self.weight = nn.Parameter(torch.ones(hidden_size))
|
96 |
+
self.variance_epsilon = eps
|
97 |
+
|
98 |
+
def forward(self, hidden_states):
|
99 |
+
input_dtype = hidden_states.dtype
|
100 |
+
hidden_states = hidden_states.to(torch.float32)
|
101 |
+
variance = hidden_states.pow(2).mean(-1, keepdim=True)
|
102 |
+
hidden_states = hidden_states * torch.rsqrt(variance +
|
103 |
+
self.variance_epsilon)
|
104 |
+
return self.weight * hidden_states.to(input_dtype)
|
105 |
+
|
106 |
+
|
107 |
+
class InternLM2RotaryEmbedding(nn.Module):
|
108 |
+
|
109 |
+
def __init__(self,
|
110 |
+
dim,
|
111 |
+
max_position_embeddings=2048,
|
112 |
+
base=10000,
|
113 |
+
device=None):
|
114 |
+
super().__init__()
|
115 |
+
|
116 |
+
self.dim = dim
|
117 |
+
self.max_position_embeddings = max_position_embeddings
|
118 |
+
self.base = base
|
119 |
+
inv_freq = 1.0 / (
|
120 |
+
self.base
|
121 |
+
**(torch.arange(0, self.dim, 2).float().to(device) / self.dim))
|
122 |
+
self.register_buffer('inv_freq', inv_freq, persistent=False)
|
123 |
+
|
124 |
+
# Build here to make `torch.jit.trace` work.
|
125 |
+
self._set_cos_sin_cache(
|
126 |
+
seq_len=max_position_embeddings,
|
127 |
+
device=self.inv_freq.device,
|
128 |
+
dtype=torch.get_default_dtype())
|
129 |
+
|
130 |
+
def _set_cos_sin_cache(self, seq_len, device, dtype):
|
131 |
+
self.max_seq_len_cached = seq_len
|
132 |
+
t = torch.arange(
|
133 |
+
self.max_seq_len_cached, device=device, dtype=self.inv_freq.dtype)
|
134 |
+
|
135 |
+
freqs = torch.einsum('i,j->ij', t, self.inv_freq)
|
136 |
+
# Different from paper, but it uses a different permutation in order to obtain the same calculation
|
137 |
+
emb = torch.cat((freqs, freqs), dim=-1)
|
138 |
+
self.register_buffer(
|
139 |
+
'cos_cached', emb.cos().to(dtype), persistent=False)
|
140 |
+
self.register_buffer(
|
141 |
+
'sin_cached', emb.sin().to(dtype), persistent=False)
|
142 |
+
|
143 |
+
def forward(self, x, seq_len=None):
|
144 |
+
# x: [bs, num_attention_heads, seq_len, head_size]
|
145 |
+
if seq_len > self.max_seq_len_cached:
|
146 |
+
self._set_cos_sin_cache(
|
147 |
+
seq_len=seq_len, device=x.device, dtype=x.dtype)
|
148 |
+
|
149 |
+
return (
|
150 |
+
self.cos_cached[:seq_len].to(dtype=x.dtype),
|
151 |
+
self.sin_cached[:seq_len].to(dtype=x.dtype),
|
152 |
+
)
|
153 |
+
|
154 |
+
|
155 |
+
class InternLM2LinearScalingRotaryEmbedding(InternLM2RotaryEmbedding):
|
156 |
+
"""InternLM2RotaryEmbedding extended with linear scaling.
|
157 |
+
|
158 |
+
Credits to the Reddit user /u/kaiokendev
|
159 |
+
"""
|
160 |
+
|
161 |
+
def __init__(self,
|
162 |
+
dim,
|
163 |
+
max_position_embeddings=2048,
|
164 |
+
base=10000,
|
165 |
+
device=None,
|
166 |
+
scaling_factor=1.0):
|
167 |
+
self.scaling_factor = scaling_factor
|
168 |
+
super().__init__(dim, max_position_embeddings, base, device)
|
169 |
+
|
170 |
+
def _set_cos_sin_cache(self, seq_len, device, dtype):
|
171 |
+
self.max_seq_len_cached = seq_len
|
172 |
+
t = torch.arange(
|
173 |
+
self.max_seq_len_cached, device=device, dtype=self.inv_freq.dtype)
|
174 |
+
t = t / self.scaling_factor
|
175 |
+
|
176 |
+
freqs = torch.einsum('i,j->ij', t, self.inv_freq)
|
177 |
+
# Different from paper, but it uses a different permutation in order to obtain the same calculation
|
178 |
+
emb = torch.cat((freqs, freqs), dim=-1)
|
179 |
+
self.register_buffer(
|
180 |
+
'cos_cached', emb.cos().to(dtype), persistent=False)
|
181 |
+
self.register_buffer(
|
182 |
+
'sin_cached', emb.sin().to(dtype), persistent=False)
|
183 |
+
|
184 |
+
|
185 |
+
class InternLM2DynamicNTKScalingRotaryEmbedding(InternLM2RotaryEmbedding):
|
186 |
+
"""InternLM2RotaryEmbedding extended with Dynamic NTK scaling.
|
187 |
+
|
188 |
+
Credits to the Reddit users /u/bloc97 and /u/emozilla.
|
189 |
+
"""
|
190 |
+
|
191 |
+
def __init__(self,
|
192 |
+
dim,
|
193 |
+
max_position_embeddings=2048,
|
194 |
+
base=10000,
|
195 |
+
device=None,
|
196 |
+
scaling_factor=1.0):
|
197 |
+
self.scaling_factor = scaling_factor
|
198 |
+
super().__init__(dim, max_position_embeddings, base, device)
|
199 |
+
|
200 |
+
def _set_cos_sin_cache(self, seq_len, device, dtype):
|
201 |
+
self.max_seq_len_cached = seq_len
|
202 |
+
|
203 |
+
if seq_len > self.max_position_embeddings:
|
204 |
+
base = self.base * ((self.scaling_factor * seq_len /
|
205 |
+
self.max_position_embeddings) -
|
206 |
+
(self.scaling_factor - 1))**(
|
207 |
+
self.dim / (self.dim - 2))
|
208 |
+
inv_freq = 1.0 / (
|
209 |
+
base
|
210 |
+
**(torch.arange(0, self.dim, 2).float().to(device) / self.dim))
|
211 |
+
self.register_buffer('inv_freq', inv_freq, persistent=False)
|
212 |
+
|
213 |
+
t = torch.arange(
|
214 |
+
self.max_seq_len_cached, device=device, dtype=self.inv_freq.dtype)
|
215 |
+
|
216 |
+
freqs = torch.einsum('i,j->ij', t, self.inv_freq)
|
217 |
+
# Different from paper, but it uses a different permutation in order to obtain the same calculation
|
218 |
+
emb = torch.cat((freqs, freqs), dim=-1)
|
219 |
+
self.register_buffer(
|
220 |
+
'cos_cached', emb.cos().to(dtype), persistent=False)
|
221 |
+
self.register_buffer(
|
222 |
+
'sin_cached', emb.sin().to(dtype), persistent=False)
|
223 |
+
|
224 |
+
|
225 |
+
def rotate_half(x):
|
226 |
+
"""Rotates half the hidden dims of the input."""
|
227 |
+
x1 = x[..., :x.shape[-1] // 2]
|
228 |
+
x2 = x[..., x.shape[-1] // 2:]
|
229 |
+
return torch.cat((-x2, x1), dim=-1)
|
230 |
+
|
231 |
+
|
232 |
+
def apply_rotary_pos_emb(q, k, cos, sin, position_ids):
|
233 |
+
# The first two dimensions of cos and sin are always 1, so we can `squeeze` them.
|
234 |
+
cos = cos.squeeze(1).squeeze(0) # [seq_len, dim]
|
235 |
+
sin = sin.squeeze(1).squeeze(0) # [seq_len, dim]
|
236 |
+
cos = cos.unsqueeze(0).unsqueeze(0).expand(len(position_ids), -1, -1, -1)
|
237 |
+
sin = sin.unsqueeze(0).unsqueeze(0).expand(len(position_ids), -1, -1, -1)
|
238 |
+
if q.size(2) == 1:
|
239 |
+
q_embed = (q * cos[:, :, -1:, :]) + (
|
240 |
+
rotate_half(q) * sin[:, :, -1:, :])
|
241 |
+
else:
|
242 |
+
q_embed = (q * cos) + (rotate_half(q) * sin)
|
243 |
+
|
244 |
+
if k.size(2) == 1:
|
245 |
+
k_embed = (k * cos[:, :, -1:, :]) + (
|
246 |
+
rotate_half(k) * sin[:, :, -1:, :])
|
247 |
+
else:
|
248 |
+
k_embed = (k * cos) + (rotate_half(k) * sin)
|
249 |
+
|
250 |
+
return q_embed, k_embed
|
251 |
+
|
252 |
+
|
253 |
+
class InternLM2MLP(nn.Module):
|
254 |
+
|
255 |
+
def __init__(self, config):
|
256 |
+
super().__init__()
|
257 |
+
self.config = config
|
258 |
+
self.hidden_size = config.hidden_size
|
259 |
+
self.intermediate_size = config.intermediate_size
|
260 |
+
|
261 |
+
self.w1 = PLoRA(
|
262 |
+
self.hidden_size,
|
263 |
+
self.intermediate_size,
|
264 |
+
bias=False,
|
265 |
+
lora_r=256,
|
266 |
+
lora_alpha=256,
|
267 |
+
lora_len=576)
|
268 |
+
self.w3 = PLoRA(
|
269 |
+
self.hidden_size,
|
270 |
+
self.intermediate_size,
|
271 |
+
bias=False,
|
272 |
+
lora_r=256,
|
273 |
+
lora_alpha=256,
|
274 |
+
lora_len=576)
|
275 |
+
self.w2 = PLoRA(
|
276 |
+
self.intermediate_size,
|
277 |
+
self.hidden_size,
|
278 |
+
bias=False,
|
279 |
+
lora_r=256,
|
280 |
+
lora_alpha=256,
|
281 |
+
lora_len=576)
|
282 |
+
|
283 |
+
self.act_fn = ACT2FN[config.hidden_act]
|
284 |
+
|
285 |
+
def forward(self, x, im_mask):
|
286 |
+
down_proj = self.w2(
|
287 |
+
self.act_fn(self.w1(x, im_mask)) * self.w3(x, im_mask), im_mask)
|
288 |
+
|
289 |
+
return down_proj
|
290 |
+
|
291 |
+
|
292 |
+
def repeat_kv(hidden_states: torch.Tensor, n_rep: int) -> torch.Tensor:
|
293 |
+
"""This is the equivalent of torch.repeat_interleave(x, dim=1,
|
294 |
+
repeats=n_rep).
|
295 |
+
|
296 |
+
The hidden states go from (batch, num_key_value_heads, seqlen, head_dim) to
|
297 |
+
(batch, num_attention_heads, seqlen, head_dim)
|
298 |
+
"""
|
299 |
+
batch, num_key_value_heads, slen, head_dim = hidden_states.shape
|
300 |
+
if n_rep == 1:
|
301 |
+
return hidden_states
|
302 |
+
hidden_states = hidden_states[:, :,
|
303 |
+
None, :, :].expand(batch,
|
304 |
+
num_key_value_heads,
|
305 |
+
n_rep, slen, head_dim)
|
306 |
+
return hidden_states.reshape(batch, num_key_value_heads * n_rep, slen,
|
307 |
+
head_dim)
|
308 |
+
|
309 |
+
|
310 |
+
class InternLM2Attention(nn.Module):
|
311 |
+
"""Multi-headed attention from 'Attention Is All You Need' paper."""
|
312 |
+
|
313 |
+
def __init__(self, config: InternLM2Config):
|
314 |
+
super().__init__()
|
315 |
+
self.config = config
|
316 |
+
self.hidden_size = config.hidden_size
|
317 |
+
self.num_heads = config.num_attention_heads
|
318 |
+
self.head_dim = self.hidden_size // self.num_heads
|
319 |
+
self.num_key_value_heads = config.num_key_value_heads
|
320 |
+
self.num_key_value_groups = self.num_heads // self.num_key_value_heads
|
321 |
+
self.max_position_embeddings = config.max_position_embeddings
|
322 |
+
self.is_causal = True
|
323 |
+
|
324 |
+
if (self.head_dim * self.num_heads) != self.hidden_size:
|
325 |
+
raise ValueError(
|
326 |
+
f'hidden_size must be divisible by num_heads (got `hidden_size`: {self.hidden_size}'
|
327 |
+
f' and `num_heads`: {self.num_heads}).')
|
328 |
+
|
329 |
+
self.wqkv = PLoRA(
|
330 |
+
self.hidden_size,
|
331 |
+
(self.num_heads + 2 * self.num_key_value_heads) * self.head_dim,
|
332 |
+
bias=config.bias,
|
333 |
+
lora_r=256,
|
334 |
+
lora_alpha=256,
|
335 |
+
lora_len=576)
|
336 |
+
|
337 |
+
self.wo = PLoRA(
|
338 |
+
self.num_heads * self.head_dim,
|
339 |
+
self.hidden_size,
|
340 |
+
bias=config.bias,
|
341 |
+
lora_r=256,
|
342 |
+
lora_alpha=256,
|
343 |
+
lora_len=576)
|
344 |
+
self._init_rope()
|
345 |
+
|
346 |
+
def _init_rope(self):
|
347 |
+
if self.config.rope_scaling is None:
|
348 |
+
self.rotary_emb = InternLM2RotaryEmbedding(
|
349 |
+
self.head_dim,
|
350 |
+
max_position_embeddings=self.max_position_embeddings,
|
351 |
+
base=self.config.rope_theta,
|
352 |
+
)
|
353 |
+
else:
|
354 |
+
scaling_type = self.config.rope_scaling['type']
|
355 |
+
scaling_factor = self.config.rope_scaling['factor']
|
356 |
+
if scaling_type == 'dynamic':
|
357 |
+
self.rotary_emb = InternLM2DynamicNTKScalingRotaryEmbedding(
|
358 |
+
self.head_dim,
|
359 |
+
max_position_embeddings=self.max_position_embeddings,
|
360 |
+
base=self.config.rope_theta,
|
361 |
+
scaling_factor=scaling_factor)
|
362 |
+
else:
|
363 |
+
raise ValueError(
|
364 |
+
"Currently we only support rotary embedding's type being 'dynamic'."
|
365 |
+
)
|
366 |
+
return self.rotary_emb
|
367 |
+
|
368 |
+
def _shape(self, tensor: torch.Tensor, seq_len: int, bsz: int):
|
369 |
+
return tensor.view(bsz, seq_len, self.num_heads,
|
370 |
+
self.head_dim).transpose(1, 2).contiguous()
|
371 |
+
|
372 |
+
def forward(
|
373 |
+
self,
|
374 |
+
hidden_states: torch.Tensor,
|
375 |
+
attention_mask: Optional[torch.Tensor] = None,
|
376 |
+
position_ids: Optional[torch.LongTensor] = None,
|
377 |
+
past_key_value: Optional[Tuple[torch.Tensor]] = None,
|
378 |
+
output_attentions: bool = False,
|
379 |
+
use_cache: bool = False,
|
380 |
+
im_mask: Optional[Tuple[torch.Tensor]] = None,
|
381 |
+
**kwargs,
|
382 |
+
) -> Tuple[torch.Tensor, Optional[torch.Tensor],
|
383 |
+
Optional[Tuple[torch.Tensor]]]:
|
384 |
+
if 'padding_mask' in kwargs:
|
385 |
+
warnings.warn(
|
386 |
+
'Passing `padding_mask` is deprecated and will be removed in v4.37. '
|
387 |
+
'Please make sure use `attention_mask` instead.`')
|
388 |
+
|
389 |
+
bsz, q_len, _ = hidden_states.size()
|
390 |
+
|
391 |
+
qkv_states = self.wqkv(hidden_states, im_mask)
|
392 |
+
|
393 |
+
qkv_states = rearrange(
|
394 |
+
qkv_states,
|
395 |
+
'b q (h gs d) -> b q h gs d',
|
396 |
+
gs=2 + self.num_key_value_groups,
|
397 |
+
d=self.head_dim,
|
398 |
+
)
|
399 |
+
|
400 |
+
query_states = qkv_states[..., :self.num_key_value_groups, :]
|
401 |
+
query_states = rearrange(query_states, 'b q h gs d -> b q (h gs) d')
|
402 |
+
key_states = qkv_states[..., -2, :]
|
403 |
+
value_states = qkv_states[..., -1, :]
|
404 |
+
|
405 |
+
query_states = query_states.transpose(1, 2)
|
406 |
+
key_states = key_states.transpose(1, 2)
|
407 |
+
value_states = value_states.transpose(1, 2)
|
408 |
+
|
409 |
+
kv_seq_len = key_states.shape[-2]
|
410 |
+
if past_key_value is not None:
|
411 |
+
kv_seq_len += past_key_value[0].shape[-2]
|
412 |
+
cos, sin = self.rotary_emb(value_states, seq_len=kv_seq_len)
|
413 |
+
query_states, key_states = apply_rotary_pos_emb(
|
414 |
+
query_states, key_states, cos, sin, position_ids)
|
415 |
+
|
416 |
+
if past_key_value is not None:
|
417 |
+
# reuse k, v, self_attention
|
418 |
+
key_states = torch.cat([past_key_value[0], key_states], dim=2)
|
419 |
+
value_states = torch.cat([past_key_value[1], value_states], dim=2)
|
420 |
+
|
421 |
+
past_key_value = (key_states, value_states) if use_cache else None
|
422 |
+
|
423 |
+
key_states = repeat_kv(key_states, self.num_key_value_groups)
|
424 |
+
value_states = repeat_kv(value_states, self.num_key_value_groups)
|
425 |
+
|
426 |
+
attn_weights = torch.matmul(query_states, key_states.transpose(
|
427 |
+
2, 3)) / math.sqrt(self.head_dim)
|
428 |
+
|
429 |
+
if attn_weights.size() != (bsz, self.num_heads, q_len, kv_seq_len):
|
430 |
+
raise ValueError(
|
431 |
+
f'Attention weights should be of size {(bsz, self.num_heads, q_len, kv_seq_len)}, but is'
|
432 |
+
f' {attn_weights.size()}')
|
433 |
+
|
434 |
+
if attention_mask is not None:
|
435 |
+
if attention_mask.size() != (bsz, 1, q_len, kv_seq_len):
|
436 |
+
raise ValueError(
|
437 |
+
f'Attention mask should be of size {(bsz, 1, q_len, kv_seq_len)}, but is {attention_mask.size()}'
|
438 |
+
)
|
439 |
+
attn_weights = attn_weights + attention_mask
|
440 |
+
|
441 |
+
# upcast attention to fp32
|
442 |
+
attn_weights = nn.functional.softmax(
|
443 |
+
attn_weights, dim=-1, dtype=torch.float32).to(query_states.dtype)
|
444 |
+
attn_output = torch.matmul(attn_weights, value_states)
|
445 |
+
|
446 |
+
if attn_output.size() != (bsz, self.num_heads, q_len, self.head_dim):
|
447 |
+
raise ValueError(
|
448 |
+
f'`attn_output` should be of size {(bsz, self.num_heads, q_len, self.head_dim)}, but is'
|
449 |
+
f' {attn_output.size()}')
|
450 |
+
|
451 |
+
attn_output = attn_output.transpose(1, 2).contiguous()
|
452 |
+
attn_output = attn_output.reshape(bsz, q_len, self.hidden_size)
|
453 |
+
|
454 |
+
attn_output = self.wo(attn_output, im_mask)
|
455 |
+
|
456 |
+
if not output_attentions:
|
457 |
+
attn_weights = None
|
458 |
+
|
459 |
+
return attn_output, attn_weights, past_key_value
|
460 |
+
|
461 |
+
|
462 |
+
class InternLM2FlashAttention2(InternLM2Attention):
|
463 |
+
"""InternLM2 flash attention module.
|
464 |
+
|
465 |
+
This module inherits from `InternLM2Attention` as the weights of the module
|
466 |
+
stays untouched. The only required change would be on the forward pass
|
467 |
+
where it needs to correctly call the public API of flash attention and deal
|
468 |
+
with padding tokens in case the input contains any of them.
|
469 |
+
"""
|
470 |
+
|
471 |
+
def forward(
|
472 |
+
self,
|
473 |
+
hidden_states: torch.Tensor,
|
474 |
+
attention_mask: Optional[torch.LongTensor] = None,
|
475 |
+
position_ids: Optional[torch.LongTensor] = None,
|
476 |
+
past_key_value: Optional[Tuple[torch.Tensor]] = None,
|
477 |
+
output_attentions: bool = False,
|
478 |
+
use_cache: bool = False,
|
479 |
+
im_mask: Optional[Tuple[torch.Tensor]] = None,
|
480 |
+
**kwargs,
|
481 |
+
) -> Tuple[torch.Tensor, Optional[torch.Tensor],
|
482 |
+
Optional[Tuple[torch.Tensor]]]:
|
483 |
+
# InternLM2FlashAttention2 attention does not support output_attentions
|
484 |
+
if 'padding_mask' in kwargs:
|
485 |
+
warnings.warn(
|
486 |
+
'Passing `padding_mask` is deprecated and will be removed in v4.37. '
|
487 |
+
'Please make sure use `attention_mask` instead.`')
|
488 |
+
|
489 |
+
# overwrite attention_mask with padding_mask
|
490 |
+
attention_mask = kwargs.pop('padding_mask')
|
491 |
+
|
492 |
+
output_attentions = False
|
493 |
+
|
494 |
+
bsz, q_len, _ = hidden_states.size()
|
495 |
+
|
496 |
+
qkv_states = self.wqkv(hidden_states, im_mask)
|
497 |
+
|
498 |
+
qkv_states = rearrange(
|
499 |
+
qkv_states,
|
500 |
+
'b q (h gs d) -> b q h gs d',
|
501 |
+
gs=self.num_heads + 2 * self.num_key_value_heads,
|
502 |
+
d=self.head_dim,
|
503 |
+
q=q_len,
|
504 |
+
)
|
505 |
+
|
506 |
+
query_states = qkv_states[..., :self.num_key_value_groups, :]
|
507 |
+
query_states = rearrange(query_states, 'b q h gs d -> b q (h gs) d')
|
508 |
+
key_states = qkv_states[..., -2, :]
|
509 |
+
value_states = qkv_states[..., -1, :]
|
510 |
+
|
511 |
+
kv_seq_len = key_states.shape[-2]
|
512 |
+
if past_key_value is not None:
|
513 |
+
kv_seq_len += past_key_value[0].shape[-2]
|
514 |
+
|
515 |
+
cos, sin = self.rotary_emb(value_states, seq_len=kv_seq_len)
|
516 |
+
|
517 |
+
query_states, key_states = apply_rotary_pos_emb(
|
518 |
+
query_states, key_states, cos, sin, position_ids)
|
519 |
+
|
520 |
+
if past_key_value is not None:
|
521 |
+
# reuse k, v, self_attention
|
522 |
+
key_states = torch.cat([past_key_value[0], key_states], dim=2)
|
523 |
+
value_states = torch.cat([past_key_value[1], value_states], dim=2)
|
524 |
+
|
525 |
+
past_key_value = (key_states, value_states) if use_cache else None
|
526 |
+
|
527 |
+
query_states = query_states.transpose(1, 2)
|
528 |
+
key_states = key_states.transpose(1, 2)
|
529 |
+
value_states = value_states.transpose(1, 2)
|
530 |
+
|
531 |
+
dropout_rate = 0.0 if not self.training else self.attention_dropout
|
532 |
+
|
533 |
+
# In PEFT, usually we cast the layer norms in float32 for training stability reasons
|
534 |
+
# therefore the input hidden states gets silently casted in float32. Hence, we need
|
535 |
+
# cast them back in the correct dtype just to be sure everything works as expected.
|
536 |
+
# This might slowdown training & inference so it is recommended to not cast the LayerNorms
|
537 |
+
# in fp32. (InternLM2RMSNorm handles it correctly)
|
538 |
+
|
539 |
+
input_dtype = query_states.dtype
|
540 |
+
if input_dtype == torch.float32:
|
541 |
+
# Handle the case where the model is quantized
|
542 |
+
if hasattr(self.config, '_pre_quantization_dtype'):
|
543 |
+
target_dtype = self.config._pre_quantization_dtype
|
544 |
+
else:
|
545 |
+
target_dtype = self.q_proj.weight.dtype
|
546 |
+
|
547 |
+
logger.warning_once(
|
548 |
+
f'The input hidden states seems to be silently casted in float32, this might be related to'
|
549 |
+
f' the fact you have upcasted embedding or layer norm layers in float32. We will cast back '
|
550 |
+
f'the input in {target_dtype}.')
|
551 |
+
|
552 |
+
query_states = query_states.to(target_dtype)
|
553 |
+
key_states = key_states.to(target_dtype)
|
554 |
+
value_states = value_states.to(target_dtype)
|
555 |
+
|
556 |
+
attn_output = self._flash_attention_forward(
|
557 |
+
query_states,
|
558 |
+
key_states,
|
559 |
+
value_states,
|
560 |
+
attention_mask,
|
561 |
+
q_len,
|
562 |
+
dropout=dropout_rate)
|
563 |
+
|
564 |
+
attn_output = attn_output.reshape(bsz, q_len,
|
565 |
+
self.hidden_size).contiguous()
|
566 |
+
attn_output = self.wo(attn_output, im_mask)
|
567 |
+
|
568 |
+
if not output_attentions:
|
569 |
+
attn_weights = None
|
570 |
+
|
571 |
+
return attn_output, attn_weights, past_key_value
|
572 |
+
|
573 |
+
|
574 |
+
class InternLM2DecoderLayer(nn.Module):
|
575 |
+
|
576 |
+
def __init__(self, config: InternLM2Config):
|
577 |
+
super().__init__()
|
578 |
+
self.hidden_size = config.hidden_size
|
579 |
+
self.attention = (
|
580 |
+
InternLM2Attention(config=config)
|
581 |
+
if not getattr(config, '_flash_attn_2_enabled', False) else
|
582 |
+
InternLM2FlashAttention2(config=config))
|
583 |
+
self.feed_forward = InternLM2MLP(config)
|
584 |
+
self.attention_norm = InternLM2RMSNorm(
|
585 |
+
config.hidden_size, eps=config.rms_norm_eps)
|
586 |
+
self.ffn_norm = InternLM2RMSNorm(
|
587 |
+
config.hidden_size, eps=config.rms_norm_eps)
|
588 |
+
|
589 |
+
def forward(
|
590 |
+
self,
|
591 |
+
hidden_states: torch.Tensor,
|
592 |
+
attention_mask: Optional[torch.Tensor] = None,
|
593 |
+
position_ids: Optional[torch.LongTensor] = None,
|
594 |
+
past_key_value: Optional[Tuple[torch.Tensor]] = None,
|
595 |
+
output_attentions: Optional[bool] = False,
|
596 |
+
use_cache: Optional[bool] = False,
|
597 |
+
im_mask: Optional[Tuple[torch.Tensor]] = None,
|
598 |
+
**kwargs,
|
599 |
+
) -> Tuple[torch.FloatTensor, Optional[Tuple[torch.FloatTensor,
|
600 |
+
torch.FloatTensor]]]:
|
601 |
+
"""
|
602 |
+
Args:
|
603 |
+
hidden_states (`torch.FloatTensor`): input to the layer of shape `(batch, seq_len, embed_dim)`
|
604 |
+
attention_mask (`torch.FloatTensor`, *optional*):
|
605 |
+
attention mask of size `(batch_size, sequence_length)` if flash attention is used or `(batch_size, 1,
|
606 |
+
query_sequence_length, key_sequence_length)` if default attention is used.
|
607 |
+
output_attentions (`bool`, *optional*):
|
608 |
+
Whether or not to return the attentions tensors of all attention layers. See `attentions` under
|
609 |
+
returned tensors for more detail.
|
610 |
+
use_cache (`bool`, *optional*):
|
611 |
+
If set to `True`, `past_key_values` key value states are returned and can be used to speed up decoding
|
612 |
+
(see `past_key_values`).
|
613 |
+
past_key_value (`Tuple(torch.FloatTensor)`, *optional*): cached past key and value projection states
|
614 |
+
"""
|
615 |
+
if 'padding_mask' in kwargs:
|
616 |
+
warnings.warn(
|
617 |
+
'Passing `padding_mask` is deprecated and will be removed in v4.37. '
|
618 |
+
'Please make sure use `attention_mask` instead.`')
|
619 |
+
|
620 |
+
residual = hidden_states
|
621 |
+
|
622 |
+
hidden_states = self.attention_norm(hidden_states)
|
623 |
+
|
624 |
+
# Self Attention
|
625 |
+
hidden_states, self_attn_weights, present_key_value = self.attention(
|
626 |
+
hidden_states=hidden_states,
|
627 |
+
attention_mask=attention_mask,
|
628 |
+
position_ids=position_ids,
|
629 |
+
past_key_value=past_key_value,
|
630 |
+
output_attentions=output_attentions,
|
631 |
+
use_cache=use_cache,
|
632 |
+
im_mask=im_mask,
|
633 |
+
**kwargs,
|
634 |
+
)
|
635 |
+
hidden_states = residual + hidden_states
|
636 |
+
|
637 |
+
# Fully Connected
|
638 |
+
residual = hidden_states
|
639 |
+
hidden_states = self.ffn_norm(hidden_states)
|
640 |
+
hidden_states = self.feed_forward(hidden_states, im_mask)
|
641 |
+
hidden_states = residual + hidden_states
|
642 |
+
|
643 |
+
outputs = (hidden_states, )
|
644 |
+
|
645 |
+
if output_attentions:
|
646 |
+
outputs += (self_attn_weights, )
|
647 |
+
|
648 |
+
if use_cache:
|
649 |
+
outputs += (present_key_value, )
|
650 |
+
|
651 |
+
return outputs
|
652 |
+
|
653 |
+
|
654 |
+
InternLM2_START_DOCSTRING = r"""
|
655 |
+
This model inherits from [`PreTrainedModel`]. Check the superclass documentation for the generic methods the
|
656 |
+
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
|
657 |
+
etc.)
|
658 |
+
|
659 |
+
This model is also a PyTorch [torch.nn.Module](https://pytorch.org/docs/stable/nn.html#torch.nn.Module) subclass.
|
660 |
+
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
|
661 |
+
and behavior.
|
662 |
+
|
663 |
+
Parameters:
|
664 |
+
config ([`InternLM2Config`]):
|
665 |
+
Model configuration class with all the parameters of the model. Initializing with a config file does not
|
666 |
+
load the weights associated with the model, only the configuration. Check out the
|
667 |
+
[`~PreTrainedModel.from_pretrained`] method to load the model weights.
|
668 |
+
"""
|
669 |
+
|
670 |
+
|
671 |
+
@add_start_docstrings(
|
672 |
+
'The bare InternLM2 Model outputting raw hidden-states without any specific head on top.',
|
673 |
+
InternLM2_START_DOCSTRING,
|
674 |
+
)
|
675 |
+
class InternLM2PreTrainedModel(PreTrainedModel):
|
676 |
+
config_class = InternLM2Config
|
677 |
+
base_model_prefix = 'model'
|
678 |
+
supports_gradient_checkpointing = True
|
679 |
+
_no_split_modules = ['InternLM2DecoderLayer']
|
680 |
+
_skip_keys_device_placement = 'past_key_values'
|
681 |
+
_supports_flash_attn_2 = True
|
682 |
+
|
683 |
+
def _init_weights(self, module):
|
684 |
+
std = self.config.initializer_range
|
685 |
+
if isinstance(module, nn.Linear):
|
686 |
+
module.weight.data.normal_(mean=0.0, std=std)
|
687 |
+
if module.bias is not None:
|
688 |
+
module.bias.data.zero_()
|
689 |
+
elif isinstance(module, nn.Embedding):
|
690 |
+
module.weight.data.normal_(mean=0.0, std=std)
|
691 |
+
if module.padding_idx is not None:
|
692 |
+
module.weight.data[module.padding_idx].zero_()
|
693 |
+
|
694 |
+
|
695 |
+
InternLM2_INPUTS_DOCSTRING = r"""
|
696 |
+
Args:
|
697 |
+
input_ids (`torch.LongTensor` of shape `(batch_size, sequence_length)`):
|
698 |
+
Indices of input sequence tokens in the vocabulary. Padding will be ignored by default should you provide
|
699 |
+
it.
|
700 |
+
|
701 |
+
Indices can be obtained using [`AutoTokenizer`]. See [`PreTrainedTokenizer.encode`] and
|
702 |
+
[`PreTrainedTokenizer.__call__`] for details.
|
703 |
+
|
704 |
+
[What are input IDs?](../glossary#input-ids)
|
705 |
+
attention_mask (`torch.Tensor` of shape `(batch_size, sequence_length)`, *optional*):
|
706 |
+
Mask to avoid performing attention on padding token indices. Mask values selected in `[0, 1]`:
|
707 |
+
|
708 |
+
- 1 for tokens that are **not masked**,
|
709 |
+
- 0 for tokens that are **masked**.
|
710 |
+
|
711 |
+
[What are attention masks?](../glossary#attention-mask)
|
712 |
+
|
713 |
+
Indices can be obtained using [`AutoTokenizer`]. See [`PreTrainedTokenizer.encode`] and
|
714 |
+
[`PreTrainedTokenizer.__call__`] for details.
|
715 |
+
|
716 |
+
If `past_key_values` is used, optionally only the last `input_ids` have to be input (see
|
717 |
+
`past_key_values`).
|
718 |
+
|
719 |
+
If you want to change padding behavior, you should read [`modeling_opt._prepare_decoder_attention_mask`]
|
720 |
+
and modify to your needs. See diagram 1 in [the paper](https://arxiv.org/abs/1910.13461) for more
|
721 |
+
information on the default strategy.
|
722 |
+
|
723 |
+
- 1 indicates the head is **not masked**,
|
724 |
+
- 0 indicates the head is **masked**.
|
725 |
+
position_ids (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *optional*):
|
726 |
+
Indices of positions of each input sequence tokens in the position embeddings. Selected in the range `[0,
|
727 |
+
config.n_positions - 1]`.
|
728 |
+
|
729 |
+
[What are position IDs?](../glossary#position-ids)
|
730 |
+
past_key_values (`tuple(tuple(torch.FloatTensor))`, *optional*, returned when `use_cache=True` is passed or
|
731 |
+
when `config.use_cache=True`):
|
732 |
+
Tuple of `tuple(torch.FloatTensor)` of length `config.n_layers`, with each tuple having 2 tensors of shape
|
733 |
+
`(batch_size, num_heads, sequence_length, embed_size_per_head)`) and 2 additional tensors of shape
|
734 |
+
`(batch_size, num_heads, decoder_sequence_length, embed_size_per_head)`.
|
735 |
+
|
736 |
+
Contains pre-computed hidden-states (key and values in the self-attention blocks and in the cross-attention
|
737 |
+
blocks) that can be used (see `past_key_values` input) to speed up sequential decoding.
|
738 |
+
|
739 |
+
If `past_key_values` are used, the user can optionally input only the last `input_ids` (those that don't
|
740 |
+
have their past key value states given to this model) of shape `(batch_size, 1)` instead of all `input_ids`
|
741 |
+
of shape `(batch_size, sequence_length)`.
|
742 |
+
inputs_embeds (`torch.FloatTensor` of shape `(batch_size, sequence_length, hidden_size)`, *optional*):
|
743 |
+
Optionally, instead of passing `input_ids` you can choose to directly pass an embedded representation. This
|
744 |
+
is useful if you want more control over how to convert `input_ids` indices into associated vectors than the
|
745 |
+
model's internal embedding lookup matrix.
|
746 |
+
use_cache (`bool`, *optional*):
|
747 |
+
If set to `True`, `past_key_values` key value states are returned and can be used to speed up decoding (see
|
748 |
+
`past_key_values`).
|
749 |
+
output_attentions (`bool`, *optional*):
|
750 |
+
Whether or not to return the attentions tensors of all attention layers. See `attentions` under returned
|
751 |
+
tensors for more detail.
|
752 |
+
output_hidden_states (`bool`, *optional*):
|
753 |
+
Whether or not to return the hidden states of all layers. See `hidden_states` under returned tensors for
|
754 |
+
more detail.
|
755 |
+
return_dict (`bool`, *optional*):
|
756 |
+
Whether or not to return a [`~utils.ModelOutput`] instead of a plain tuple.
|
757 |
+
"""
|
758 |
+
|
759 |
+
|
760 |
+
@add_start_docstrings(
|
761 |
+
'The bare InternLM2 Model outputting raw hidden-states without any specific head on top.',
|
762 |
+
InternLM2_START_DOCSTRING,
|
763 |
+
)
|
764 |
+
class InternLM2Model(InternLM2PreTrainedModel):
|
765 |
+
"""Transformer decoder consisting of *config.num_hidden_layers* layers.
|
766 |
+
Each layer is a [`InternLM2DecoderLayer`]
|
767 |
+
|
768 |
+
Args:
|
769 |
+
config: InternLM2Config
|
770 |
+
"""
|
771 |
+
|
772 |
+
_auto_class = 'AutoModel'
|
773 |
+
|
774 |
+
def __init__(self, config: InternLM2Config):
|
775 |
+
super().__init__(config)
|
776 |
+
self.padding_idx = config.pad_token_id
|
777 |
+
self.vocab_size = config.vocab_size
|
778 |
+
|
779 |
+
self.tok_embeddings = nn.Embedding(config.vocab_size,
|
780 |
+
config.hidden_size,
|
781 |
+
self.padding_idx)
|
782 |
+
self.layers = nn.ModuleList([
|
783 |
+
InternLM2DecoderLayer(config)
|
784 |
+
for _ in range(config.num_hidden_layers)
|
785 |
+
])
|
786 |
+
self.norm = InternLM2RMSNorm(
|
787 |
+
config.hidden_size, eps=config.rms_norm_eps)
|
788 |
+
|
789 |
+
self.gradient_checkpointing = False
|
790 |
+
# Initialize weights and apply final processing
|
791 |
+
self.post_init()
|
792 |
+
|
793 |
+
def get_input_embeddings(self):
|
794 |
+
return self.tok_embeddings
|
795 |
+
|
796 |
+
def set_input_embeddings(self, value):
|
797 |
+
self.tok_embeddings = value
|
798 |
+
|
799 |
+
# Copied from transformers.models.bart.modeling_bart.BartDecoder._prepare_decoder_attention_mask
|
800 |
+
def _prepare_decoder_attention_mask(self, attention_mask, input_shape,
|
801 |
+
inputs_embeds, past_key_values_length):
|
802 |
+
# create causal mask
|
803 |
+
# [bsz, seq_len] -> [bsz, 1, tgt_seq_len, src_seq_len]
|
804 |
+
combined_attention_mask = None
|
805 |
+
if input_shape[-1] > 1:
|
806 |
+
combined_attention_mask = _make_causal_mask(
|
807 |
+
input_shape,
|
808 |
+
inputs_embeds.dtype,
|
809 |
+
device=inputs_embeds.device,
|
810 |
+
past_key_values_length=past_key_values_length,
|
811 |
+
)
|
812 |
+
|
813 |
+
if attention_mask is not None:
|
814 |
+
# [bsz, seq_len] -> [bsz, 1, tgt_seq_len, src_seq_len]
|
815 |
+
expanded_attn_mask = _expand_mask(
|
816 |
+
attention_mask, inputs_embeds.dtype,
|
817 |
+
tgt_len=input_shape[-1]).to(inputs_embeds.device)
|
818 |
+
combined_attention_mask = (
|
819 |
+
expanded_attn_mask if combined_attention_mask is None else
|
820 |
+
expanded_attn_mask + combined_attention_mask)
|
821 |
+
|
822 |
+
return combined_attention_mask
|
823 |
+
|
824 |
+
@add_start_docstrings_to_model_forward(InternLM2_INPUTS_DOCSTRING)
|
825 |
+
def forward(self,
|
826 |
+
input_ids: torch.LongTensor = None,
|
827 |
+
attention_mask: Optional[torch.Tensor] = None,
|
828 |
+
position_ids: Optional[torch.LongTensor] = None,
|
829 |
+
past_key_values: Optional[List[torch.FloatTensor]] = None,
|
830 |
+
inputs_embeds: Optional[torch.FloatTensor] = None,
|
831 |
+
use_cache: Optional[bool] = None,
|
832 |
+
output_attentions: Optional[bool] = None,
|
833 |
+
output_hidden_states: Optional[bool] = None,
|
834 |
+
return_dict: Optional[bool] = None,
|
835 |
+
**kwargs) -> Union[Tuple, BaseModelOutputWithPast]:
|
836 |
+
|
837 |
+
im_mask = kwargs.get('im_mask', None)
|
838 |
+
|
839 |
+
output_attentions = output_attentions if output_attentions is not None else self.config.output_attentions
|
840 |
+
output_hidden_states = (
|
841 |
+
output_hidden_states if output_hidden_states is not None else
|
842 |
+
self.config.output_hidden_states)
|
843 |
+
use_cache = use_cache if use_cache is not None else self.config.use_cache
|
844 |
+
|
845 |
+
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
846 |
+
|
847 |
+
# retrieve input_ids and inputs_embeds
|
848 |
+
if input_ids is not None and inputs_embeds is not None:
|
849 |
+
raise ValueError(
|
850 |
+
'You cannot specify both input_ids and inputs_embeds at the same time'
|
851 |
+
)
|
852 |
+
elif input_ids is not None:
|
853 |
+
batch_size, seq_length = input_ids.shape[:2]
|
854 |
+
elif inputs_embeds is not None:
|
855 |
+
batch_size, seq_length = inputs_embeds.shape[:2]
|
856 |
+
else:
|
857 |
+
raise ValueError(
|
858 |
+
'You have to specify either input_ids or inputs_embeds')
|
859 |
+
|
860 |
+
seq_length_with_past = seq_length
|
861 |
+
past_key_values_length = 0
|
862 |
+
if past_key_values is not None:
|
863 |
+
past_key_values_length = past_key_values[0][0].shape[2]
|
864 |
+
seq_length_with_past = seq_length_with_past + past_key_values_length
|
865 |
+
|
866 |
+
if position_ids is None:
|
867 |
+
device = input_ids.device if input_ids is not None else inputs_embeds.device
|
868 |
+
position_ids = torch.arange(
|
869 |
+
past_key_values_length,
|
870 |
+
seq_length + past_key_values_length,
|
871 |
+
dtype=torch.long,
|
872 |
+
device=device)
|
873 |
+
position_ids = position_ids.unsqueeze(0)
|
874 |
+
|
875 |
+
if inputs_embeds is None:
|
876 |
+
inputs_embeds = self.tok_embeddings(input_ids)
|
877 |
+
im_mask = torch.zeros(inputs_embeds.shape[:2]).to(
|
878 |
+
inputs_embeds.device).bool()
|
879 |
+
# embed positions
|
880 |
+
if attention_mask is None:
|
881 |
+
attention_mask = torch.ones((batch_size, seq_length_with_past),
|
882 |
+
dtype=torch.bool,
|
883 |
+
device=inputs_embeds.device)
|
884 |
+
attention_mask = self._prepare_decoder_attention_mask(
|
885 |
+
attention_mask, (batch_size, seq_length), inputs_embeds,
|
886 |
+
past_key_values_length)
|
887 |
+
|
888 |
+
# embed positions
|
889 |
+
hidden_states = inputs_embeds
|
890 |
+
|
891 |
+
if self.gradient_checkpointing and self.training:
|
892 |
+
if use_cache:
|
893 |
+
logger.warning_once(
|
894 |
+
'`use_cache=True` is incompatible with gradient checkpointing. Setting `use_cache=False`...'
|
895 |
+
)
|
896 |
+
use_cache = False
|
897 |
+
|
898 |
+
# decoder layers
|
899 |
+
all_hidden_states = () if output_hidden_states else None
|
900 |
+
all_self_attns = () if output_attentions else None
|
901 |
+
next_decoder_cache = () if use_cache else None
|
902 |
+
|
903 |
+
for idx, decoder_layer in enumerate(self.layers):
|
904 |
+
if output_hidden_states:
|
905 |
+
all_hidden_states += (hidden_states, )
|
906 |
+
|
907 |
+
past_key_value = past_key_values[
|
908 |
+
idx] if past_key_values is not None else None
|
909 |
+
|
910 |
+
if self.gradient_checkpointing and self.training:
|
911 |
+
|
912 |
+
def create_custom_forward(module):
|
913 |
+
|
914 |
+
def custom_forward(*inputs):
|
915 |
+
# None for past_key_value
|
916 |
+
return module(*inputs, output_attentions, None,
|
917 |
+
im_mask)
|
918 |
+
|
919 |
+
return custom_forward
|
920 |
+
|
921 |
+
layer_outputs = torch.utils.checkpoint.checkpoint(
|
922 |
+
create_custom_forward(decoder_layer),
|
923 |
+
hidden_states,
|
924 |
+
attention_mask,
|
925 |
+
position_ids,
|
926 |
+
None,
|
927 |
+
)
|
928 |
+
else:
|
929 |
+
layer_outputs = decoder_layer(
|
930 |
+
hidden_states,
|
931 |
+
attention_mask=attention_mask,
|
932 |
+
position_ids=position_ids,
|
933 |
+
past_key_value=past_key_value,
|
934 |
+
output_attentions=output_attentions,
|
935 |
+
use_cache=use_cache,
|
936 |
+
im_mask=im_mask,
|
937 |
+
)
|
938 |
+
|
939 |
+
hidden_states = layer_outputs[0]
|
940 |
+
|
941 |
+
if use_cache:
|
942 |
+
next_decoder_cache += (
|
943 |
+
layer_outputs[2 if output_attentions else 1], )
|
944 |
+
|
945 |
+
if output_attentions:
|
946 |
+
all_self_attns += (layer_outputs[1], )
|
947 |
+
|
948 |
+
hidden_states = self.norm(hidden_states)
|
949 |
+
|
950 |
+
# add hidden states from the last decoder layer
|
951 |
+
if output_hidden_states:
|
952 |
+
all_hidden_states += (hidden_states, )
|
953 |
+
|
954 |
+
next_cache = next_decoder_cache if use_cache else None
|
955 |
+
if not return_dict:
|
956 |
+
return tuple(
|
957 |
+
v for v in
|
958 |
+
[hidden_states, next_cache, all_hidden_states, all_self_attns]
|
959 |
+
if v is not None)
|
960 |
+
return BaseModelOutputWithPast(
|
961 |
+
last_hidden_state=hidden_states,
|
962 |
+
past_key_values=next_cache,
|
963 |
+
hidden_states=all_hidden_states,
|
964 |
+
attentions=all_self_attns,
|
965 |
+
)
|
modeling_internlm_xcomposer2.py
ADDED
@@ -0,0 +1,612 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# # Copyright (c) InternLM. All rights reserved.
|
2 |
+
#
|
3 |
+
# This code is based on EleutherAI's GPT-NeoX library and the GPT-NeoX
|
4 |
+
# and OPT implementations in this library. It has been modified from its
|
5 |
+
# original forms to accommodate minor architectural differences compared
|
6 |
+
# to GPT-NeoX and OPT used by the Meta AI team that trained the model.
|
7 |
+
#
|
8 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
9 |
+
# you may not use this file except in compliance with the License.
|
10 |
+
# You may obtain a copy of the License at
|
11 |
+
#
|
12 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
13 |
+
#
|
14 |
+
# Unless required by applicable law or agreed to in writing, software
|
15 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
16 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
17 |
+
# See the License for the specific language governing permissions and
|
18 |
+
# limitations under the License.
|
19 |
+
"""PyTorch InternLMXComposer2 model."""
|
20 |
+
import copy
|
21 |
+
import queue
|
22 |
+
import threading
|
23 |
+
from typing import List, Optional, Tuple, Union
|
24 |
+
|
25 |
+
import torch
|
26 |
+
import torch.utils.checkpoint
|
27 |
+
from PIL import Image
|
28 |
+
from torch import nn
|
29 |
+
from torch.nn import CrossEntropyLoss
|
30 |
+
from torchvision import transforms
|
31 |
+
from torchvision.transforms.functional import InterpolationMode
|
32 |
+
from transformers.modeling_outputs import CausalLMOutputWithPast
|
33 |
+
from transformers.utils import (add_start_docstrings_to_model_forward,
|
34 |
+
replace_return_docstrings)
|
35 |
+
|
36 |
+
try:
|
37 |
+
from transformers.generation.streamers import BaseStreamer
|
38 |
+
except: # noqa # pylint: disable=bare-except
|
39 |
+
BaseStreamer = None
|
40 |
+
|
41 |
+
from .build_mlp import build_vision_projector, build_vision_tower
|
42 |
+
from .configuration_internlm_xcomposer2 import InternLMXcomposer2Config
|
43 |
+
from .modeling_internlm2 import (InternLM2_INPUTS_DOCSTRING, InternLM2Model,
|
44 |
+
InternLM2PreTrainedModel)
|
45 |
+
|
46 |
+
_CONFIG_FOR_DOC = 'InternLMXcomposer2Config'
|
47 |
+
|
48 |
+
|
49 |
+
class InternLMXComposer2ForCausalLM(InternLM2PreTrainedModel):
|
50 |
+
_auto_class = 'AutoModelForCausalLM'
|
51 |
+
|
52 |
+
_tied_weights_keys = ['output.weight']
|
53 |
+
|
54 |
+
def __init__(self, config):
|
55 |
+
super().__init__(config)
|
56 |
+
self.model = InternLM2Model(config)
|
57 |
+
self.vocab_size = config.vocab_size
|
58 |
+
self.output = nn.Linear(
|
59 |
+
config.hidden_size, config.vocab_size, bias=False)
|
60 |
+
self.tokenizer = None
|
61 |
+
|
62 |
+
self.max_length = config.max_length
|
63 |
+
print(f'Set max length to {self.max_length}')
|
64 |
+
# Initialize weights and apply final processing
|
65 |
+
self.post_init()
|
66 |
+
|
67 |
+
self.vit = build_vision_tower()
|
68 |
+
self.vision_proj = build_vision_projector()
|
69 |
+
|
70 |
+
self.vis_processor = transforms.Compose([
|
71 |
+
transforms.Resize((config.img_size, config.img_size),
|
72 |
+
interpolation=InterpolationMode.BICUBIC),
|
73 |
+
transforms.ToTensor(),
|
74 |
+
transforms.Normalize((0.48145466, 0.4578275, 0.40821073),
|
75 |
+
(0.26862954, 0.26130258, 0.27577711)),
|
76 |
+
])
|
77 |
+
|
78 |
+
def _set_gradient_checkpointing(self, module, value=False):
|
79 |
+
if isinstance(module, InternLM2Model):
|
80 |
+
module.gradient_checkpointing = value
|
81 |
+
if value:
|
82 |
+
self.vit.vision_tower.vision_model.encoder.gradient_checkpointing = value
|
83 |
+
|
84 |
+
def get_input_embeddings(self):
|
85 |
+
return self.model.tok_embeddings
|
86 |
+
|
87 |
+
def set_input_embeddings(self, value):
|
88 |
+
self.model.tok_embeddings = value
|
89 |
+
|
90 |
+
def get_output_embeddings(self):
|
91 |
+
return self.output
|
92 |
+
|
93 |
+
def set_output_embeddings(self, new_embeddings):
|
94 |
+
self.output = new_embeddings
|
95 |
+
|
96 |
+
def set_decoder(self, decoder):
|
97 |
+
self.model = decoder
|
98 |
+
|
99 |
+
def get_decoder(self):
|
100 |
+
return self.model
|
101 |
+
|
102 |
+
def encode_text(self, text, add_special_tokens=False):
|
103 |
+
token = self.tokenizer(
|
104 |
+
text, return_tensors='pt',
|
105 |
+
add_special_tokens=add_special_tokens).input_ids.to(self.device)
|
106 |
+
embs = self.model.tok_embeddings(token)
|
107 |
+
return embs
|
108 |
+
|
109 |
+
def encode_img(self, image):
|
110 |
+
if image is None:
|
111 |
+
return None
|
112 |
+
if isinstance(image, str):
|
113 |
+
image = Image.open(image).convert('RGB')
|
114 |
+
image = self.vis_processor(image).unsqueeze(0).to(self.device)
|
115 |
+
else:
|
116 |
+
assert isinstance(image, torch.Tensor)
|
117 |
+
|
118 |
+
img_embeds, atts_img, img_target = self.img2emb(image)
|
119 |
+
return img_embeds
|
120 |
+
|
121 |
+
def img2emb(self, image):
|
122 |
+
img_embeds = self.vision_proj(self.vit(image.to(self.device)))
|
123 |
+
atts_img = torch.ones(
|
124 |
+
img_embeds.size()[:-1], dtype=torch.long).to(img_embeds.device)
|
125 |
+
|
126 |
+
img_target = torch.ones(
|
127 |
+
img_embeds.size()[:2], dtype=torch.long).to(
|
128 |
+
img_embeds.device) * -100
|
129 |
+
|
130 |
+
return img_embeds, atts_img, img_target
|
131 |
+
|
132 |
+
def prompt_wrap(self, img_embeds, prompt):
|
133 |
+
batch_size = img_embeds.shape[0]
|
134 |
+
p_before, p_after = prompt.split('<ImageHere>')
|
135 |
+
p_before_tokens = self.tokenizer(
|
136 |
+
p_before, return_tensors='pt',
|
137 |
+
add_special_tokens=True).to(img_embeds.device)
|
138 |
+
|
139 |
+
p_before_embeds = self.model.tok_embeddings(
|
140 |
+
p_before_tokens.input_ids).expand(batch_size, -1, -1)
|
141 |
+
wrapped_img_embeds = torch.cat([p_before_embeds, img_embeds], dim=1)
|
142 |
+
|
143 |
+
wrapped_atts_img = torch.ones(
|
144 |
+
wrapped_img_embeds.size()[:-1],
|
145 |
+
dtype=torch.long).to(img_embeds.device)
|
146 |
+
|
147 |
+
wrapped_target = torch.ones(
|
148 |
+
batch_size, wrapped_img_embeds.shape[1], dtype=torch.long).to(
|
149 |
+
img_embeds.device) * -100
|
150 |
+
|
151 |
+
return wrapped_img_embeds, wrapped_atts_img, wrapped_target
|
152 |
+
|
153 |
+
def text2emb(self, text, add_special=False):
|
154 |
+
to_regress_tokens = self.tokenizer(
|
155 |
+
text,
|
156 |
+
return_tensors='pt',
|
157 |
+
padding='longest',
|
158 |
+
truncation=True,
|
159 |
+
max_length=self.max_length,
|
160 |
+
add_special_tokens=add_special).to(self.device)
|
161 |
+
|
162 |
+
targets = self.mask_human_targets(to_regress_tokens.input_ids)
|
163 |
+
targets = targets.to(self.device)
|
164 |
+
return to_regress_tokens, targets
|
165 |
+
|
166 |
+
def interleav_wrap_chat(self, tokenizer, query, image, history, meta_instruction):
|
167 |
+
prompt = ''
|
168 |
+
if meta_instruction:
|
169 |
+
prompt += f"""[UNUSED_TOKEN_146]system\n{meta_instruction}[UNUSED_TOKEN_145]\n"""
|
170 |
+
for record in history:
|
171 |
+
prompt += f"""[UNUSED_TOKEN_146]user\n{record[0]}[UNUSED_TOKEN_145]\n[UNUSED_TOKEN_146]assistant\n{record[1]}[UNUSED_TOKEN_145]\n"""
|
172 |
+
prompt += f"""[UNUSED_TOKEN_146]user\n{query}[UNUSED_TOKEN_145]\n[UNUSED_TOKEN_146]assistant\n"""
|
173 |
+
|
174 |
+
im_len = image.shape[1]
|
175 |
+
image_nums = len(image)
|
176 |
+
parts = prompt.split('<ImageHere>')
|
177 |
+
wrap_embeds, wrap_im_mask = [], []
|
178 |
+
temp_len = 0
|
179 |
+
|
180 |
+
if len(parts) != image_nums + 1:
|
181 |
+
raise ValueError('Invalid <ImageHere> prompt format.')
|
182 |
+
|
183 |
+
for idx, part in enumerate(parts):
|
184 |
+
if len(part) > 0:
|
185 |
+
part_tokens = tokenizer(part, return_tensors='pt').to(self.device)
|
186 |
+
part_embeds = self.model.tok_embeddings(
|
187 |
+
part_tokens.input_ids)
|
188 |
+
wrap_embeds.append(part_embeds)
|
189 |
+
wrap_im_mask.append(torch.zeros(part_embeds.shape[:2]))
|
190 |
+
temp_len += part_embeds.shape[1]
|
191 |
+
if idx < image_nums:
|
192 |
+
wrap_embeds.append(image[idx].unsqueeze(0))
|
193 |
+
wrap_im_mask.append(torch.ones(1, image[idx].shape[0]))
|
194 |
+
temp_len += im_len
|
195 |
+
|
196 |
+
if temp_len > self.max_length:
|
197 |
+
break
|
198 |
+
|
199 |
+
wrap_embeds = torch.cat(wrap_embeds, dim=1)
|
200 |
+
wrap_im_mask = torch.cat(wrap_im_mask, dim=1)
|
201 |
+
wrap_embeds = wrap_embeds[:, :self.max_length].to(self.device)
|
202 |
+
wrap_im_mask = wrap_im_mask[:, :self.max_length].to(self.device).bool()
|
203 |
+
inputs = {
|
204 |
+
'inputs_embeds': wrap_embeds
|
205 |
+
}
|
206 |
+
return inputs, wrap_im_mask
|
207 |
+
|
208 |
+
def interleav_wrap(self, img_list, text_list):
|
209 |
+
wrap_embeds_list, wrap_atts_list = [], []
|
210 |
+
wrap_target_list, wrap_im_mask_list = [], []
|
211 |
+
|
212 |
+
for image, text in zip(img_list, text_list):
|
213 |
+
img_embeds, atts_img, img_target = self.img2emb(image)
|
214 |
+
text = text[0]
|
215 |
+
parts = text.split('<ImageHere>')
|
216 |
+
wrap_tokens, wrap_embeds, wrap_atts, wrap_im_mask = [], [], [], []
|
217 |
+
temp_len = 0
|
218 |
+
image_nums, im_len = img_embeds.shape[:2]
|
219 |
+
need_bos = True
|
220 |
+
for idx, part in enumerate(parts):
|
221 |
+
if len(part) > 0:
|
222 |
+
part_tokens = self.tokenizer(
|
223 |
+
part,
|
224 |
+
return_tensors='pt',
|
225 |
+
padding='longest',
|
226 |
+
add_special_tokens=need_bos).to(self.device)
|
227 |
+
if need_bos:
|
228 |
+
need_bos = False
|
229 |
+
wrap_tokens.append(part_tokens.input_ids)
|
230 |
+
part_embeds = self.model.tok_embeddings(
|
231 |
+
part_tokens.input_ids)
|
232 |
+
wrap_embeds.append(part_embeds)
|
233 |
+
wrap_atts.append(part_tokens.attention_mask)
|
234 |
+
wrap_im_mask.append(
|
235 |
+
torch.zeros(part_embeds.shape[:2]).to(self.device))
|
236 |
+
|
237 |
+
temp_len += part_embeds.shape[1]
|
238 |
+
if idx < image_nums:
|
239 |
+
wrap_tokens.append(img_target[idx].unsqueeze(0))
|
240 |
+
wrap_embeds.append(img_embeds[idx].unsqueeze(0))
|
241 |
+
wrap_atts.append(atts_img[idx].unsqueeze(0))
|
242 |
+
wrap_im_mask.append(
|
243 |
+
torch.ones_like(atts_img[idx].unsqueeze(0)))
|
244 |
+
|
245 |
+
temp_len += im_len
|
246 |
+
if temp_len > self.max_length:
|
247 |
+
break
|
248 |
+
|
249 |
+
wrap_tokens = torch.cat(wrap_tokens, dim=1)
|
250 |
+
wrap_embeds = torch.cat(wrap_embeds, dim=1)
|
251 |
+
wrap_atts = torch.cat(wrap_atts, dim=1)
|
252 |
+
wrap_im_mask = torch.cat(wrap_im_mask, dim=1)
|
253 |
+
|
254 |
+
wrap_target = self.mask_human_targets(wrap_tokens).to(self.device)
|
255 |
+
|
256 |
+
wrap_embeds = wrap_embeds[:, :self.max_length].to(self.device)
|
257 |
+
wrap_atts = wrap_atts[:, :self.max_length].to(self.device)
|
258 |
+
wrap_target = wrap_target[:, :self.max_length].to(self.device)
|
259 |
+
wrap_im_mask = wrap_im_mask[:, :self.max_length].to(self.device)
|
260 |
+
|
261 |
+
wrap_embeds_list.append(wrap_embeds)
|
262 |
+
wrap_atts_list.append(wrap_atts)
|
263 |
+
wrap_target_list.append(wrap_target)
|
264 |
+
wrap_im_mask_list.append(wrap_im_mask)
|
265 |
+
|
266 |
+
wrap_embeds = torch.cat(wrap_embeds_list)
|
267 |
+
wrap_atts = torch.cat(wrap_atts_list)
|
268 |
+
wrap_target = torch.cat(wrap_target_list)
|
269 |
+
wrap_im_mask = torch.cat(wrap_im_mask_list)
|
270 |
+
return wrap_embeds, wrap_atts, wrap_target, wrap_im_mask
|
271 |
+
|
272 |
+
def mask_human_targets(self, input_ids, pure=False):
|
273 |
+
target_batch = []
|
274 |
+
for bs in range(input_ids.shape[0]):
|
275 |
+
ids = input_ids[bs]
|
276 |
+
targets = copy.deepcopy(ids)
|
277 |
+
end_count = 0
|
278 |
+
last_eoa = 0
|
279 |
+
for i, temp_id in enumerate(ids):
|
280 |
+
if temp_id == 92542:
|
281 |
+
if end_count % 2 == 0:
|
282 |
+
targets[last_eoa:i + 6] = -100
|
283 |
+
else:
|
284 |
+
last_eoa = i + 1
|
285 |
+
end_count += 1
|
286 |
+
# # eos and following pad
|
287 |
+
elif temp_id == 2:
|
288 |
+
# loss on eos, but not on pad
|
289 |
+
targets[i + 1:] = -100
|
290 |
+
break
|
291 |
+
# trunction, end at last question
|
292 |
+
if temp_id != 2 and end_count % 2 == 0:
|
293 |
+
# mask all after the last answer
|
294 |
+
targets[last_eoa + 1:] = -100
|
295 |
+
target_batch.append(targets.unsqueeze(0))
|
296 |
+
target_batch = torch.cat(target_batch, dim=0)
|
297 |
+
return target_batch
|
298 |
+
|
299 |
+
@add_start_docstrings_to_model_forward(InternLM2_INPUTS_DOCSTRING)
|
300 |
+
@replace_return_docstrings(
|
301 |
+
output_type=CausalLMOutputWithPast, config_class=_CONFIG_FOR_DOC)
|
302 |
+
def forward(self,
|
303 |
+
input_ids: torch.LongTensor = None,
|
304 |
+
attention_mask: Optional[torch.Tensor] = None,
|
305 |
+
position_ids: Optional[torch.LongTensor] = None,
|
306 |
+
past_key_values: Optional[List[torch.FloatTensor]] = None,
|
307 |
+
inputs_embeds: Optional[torch.FloatTensor] = None,
|
308 |
+
labels: Optional[torch.LongTensor] = None,
|
309 |
+
use_cache: Optional[bool] = None,
|
310 |
+
output_attentions: Optional[bool] = None,
|
311 |
+
output_hidden_states: Optional[bool] = None,
|
312 |
+
return_dict: Optional[bool] = None,
|
313 |
+
**kwargs) -> Union[Tuple, CausalLMOutputWithPast]:
|
314 |
+
r"""
|
315 |
+
Args:
|
316 |
+
labels (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *optional*):
|
317 |
+
Labels for computing the masked language modeling loss. Indices should either be in `[0, ...,
|
318 |
+
config.vocab_size]` or -100 (see `input_ids` docstring). Tokens with indices set to `-100` are ignored
|
319 |
+
(masked), the loss is only computed for the tokens with labels in `[0, ..., config.vocab_size]`.
|
320 |
+
Returns:
|
321 |
+
"""
|
322 |
+
|
323 |
+
samples = kwargs.get('samples', None)
|
324 |
+
if samples:
|
325 |
+
if samples['data_type'][0] == 'text':
|
326 |
+
has_img = False
|
327 |
+
elif samples['data_type'][0] == 'multi':
|
328 |
+
has_img = True
|
329 |
+
else:
|
330 |
+
raise NotImplementedError
|
331 |
+
|
332 |
+
# encode text
|
333 |
+
text = samples['text_input']
|
334 |
+
# encode image
|
335 |
+
if has_img:
|
336 |
+
image = samples['image']
|
337 |
+
to_regress_embeds, attention_mask, targets, im_mask = self.interleav_wrap(
|
338 |
+
image, text)
|
339 |
+
else:
|
340 |
+
to_regress_tokens, targets = self.text2emb(
|
341 |
+
text, add_special=True)
|
342 |
+
to_regress_embeds = self.model.tok_embeddings(
|
343 |
+
to_regress_tokens.input_ids)
|
344 |
+
attention_mask = to_regress_tokens.attention_mask
|
345 |
+
im_mask = torch.zeros(to_regress_embeds.shape[:2]).cuda()
|
346 |
+
|
347 |
+
inputs_embeds = to_regress_embeds[:, :self.max_length]
|
348 |
+
attention_mask = attention_mask[:, :self.max_length]
|
349 |
+
targets = targets[:, :self.max_length]
|
350 |
+
im_mask = im_mask[:, :self.max_length].bool()
|
351 |
+
labels = targets
|
352 |
+
else:
|
353 |
+
im_mask = kwargs.get('im_mask', None)
|
354 |
+
if im_mask is None and inputs_embeds is not None:
|
355 |
+
im_mask = torch.zeros(inputs_embeds.shape[:2]).to(
|
356 |
+
inputs_embeds.device)
|
357 |
+
im_mask = im_mask.bool()
|
358 |
+
|
359 |
+
output_attentions = output_attentions if output_attentions is not None else self.config.output_attentions
|
360 |
+
output_hidden_states = (
|
361 |
+
output_hidden_states if output_hidden_states is not None else
|
362 |
+
self.config.output_hidden_states)
|
363 |
+
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
364 |
+
|
365 |
+
# decoder outputs consists of (dec_features, layer_state, dec_hidden, dec_attn)
|
366 |
+
outputs = self.model(
|
367 |
+
input_ids=input_ids,
|
368 |
+
attention_mask=attention_mask,
|
369 |
+
position_ids=position_ids,
|
370 |
+
past_key_values=past_key_values,
|
371 |
+
inputs_embeds=inputs_embeds,
|
372 |
+
use_cache=use_cache,
|
373 |
+
output_attentions=output_attentions,
|
374 |
+
output_hidden_states=output_hidden_states,
|
375 |
+
return_dict=return_dict,
|
376 |
+
im_mask=im_mask,
|
377 |
+
)
|
378 |
+
|
379 |
+
hidden_states = outputs[0]
|
380 |
+
logits = self.output(hidden_states)
|
381 |
+
logits = logits.float()
|
382 |
+
|
383 |
+
loss = None
|
384 |
+
if labels is not None:
|
385 |
+
# Shift so that tokens < n predict n
|
386 |
+
shift_logits = logits[..., :-1, :].contiguous()
|
387 |
+
shift_labels = labels[..., 1:].contiguous()
|
388 |
+
# Flatten the tokens
|
389 |
+
loss_fct = CrossEntropyLoss()
|
390 |
+
shift_logits = shift_logits.view(-1, self.config.vocab_size)
|
391 |
+
shift_labels = shift_labels.view(-1)
|
392 |
+
# Enable model parallelism
|
393 |
+
shift_labels = shift_labels.to(shift_logits.device)
|
394 |
+
loss = loss_fct(shift_logits, shift_labels)
|
395 |
+
|
396 |
+
if not return_dict:
|
397 |
+
output = (logits, ) + outputs[1:]
|
398 |
+
return (loss, ) + output if loss is not None else output
|
399 |
+
|
400 |
+
return CausalLMOutputWithPast(
|
401 |
+
loss=loss,
|
402 |
+
logits=logits,
|
403 |
+
past_key_values=outputs.past_key_values,
|
404 |
+
hidden_states=outputs.hidden_states,
|
405 |
+
attentions=outputs.attentions,
|
406 |
+
)
|
407 |
+
|
408 |
+
def prepare_inputs_for_generation(self,
|
409 |
+
input_ids,
|
410 |
+
past_key_values=None,
|
411 |
+
attention_mask=None,
|
412 |
+
inputs_embeds=None,
|
413 |
+
im_mask=None,
|
414 |
+
**kwargs):
|
415 |
+
if past_key_values is not None:
|
416 |
+
past_length = past_key_values[0][0].shape[2]
|
417 |
+
|
418 |
+
# Some generation methods already pass only the last input ID
|
419 |
+
if input_ids.shape[1] > past_length:
|
420 |
+
remove_prefix_length = past_length
|
421 |
+
else:
|
422 |
+
# Default to old behavior: keep only final ID
|
423 |
+
remove_prefix_length = input_ids.shape[1] - 1
|
424 |
+
|
425 |
+
input_ids = input_ids[:, remove_prefix_length:]
|
426 |
+
|
427 |
+
position_ids = kwargs.get('position_ids', None)
|
428 |
+
if attention_mask is not None and position_ids is None:
|
429 |
+
# create position_ids on the fly for batch generation
|
430 |
+
position_ids = attention_mask.long().cumsum(-1) - 1
|
431 |
+
position_ids.masked_fill_(attention_mask == 0, 1)
|
432 |
+
if past_key_values:
|
433 |
+
position_ids = position_ids[:, -input_ids.shape[1]:]
|
434 |
+
|
435 |
+
# if `inputs_embeds` are passed, we only want to use them in the 1st generation step
|
436 |
+
if inputs_embeds is not None and past_key_values is None:
|
437 |
+
model_inputs = {'inputs_embeds': inputs_embeds}
|
438 |
+
else:
|
439 |
+
model_inputs = {'input_ids': input_ids}
|
440 |
+
|
441 |
+
im_mask = im_mask
|
442 |
+
|
443 |
+
model_inputs.update({
|
444 |
+
'position_ids': position_ids,
|
445 |
+
'past_key_values': past_key_values,
|
446 |
+
'use_cache': kwargs.get('use_cache'),
|
447 |
+
'attention_mask': attention_mask,
|
448 |
+
'im_mask': im_mask,
|
449 |
+
})
|
450 |
+
return model_inputs
|
451 |
+
|
452 |
+
@staticmethod
|
453 |
+
def _reorder_cache(past_key_values, beam_idx):
|
454 |
+
reordered_past = ()
|
455 |
+
for layer_past in past_key_values:
|
456 |
+
reordered_past += (tuple(
|
457 |
+
past_state.index_select(0, beam_idx.to(past_state.device))
|
458 |
+
for past_state in layer_past), )
|
459 |
+
return reordered_past
|
460 |
+
|
461 |
+
def build_inputs(self,
|
462 |
+
tokenizer,
|
463 |
+
query: str,
|
464 |
+
history: List[Tuple[str, str]] = [],
|
465 |
+
meta_instruction=''):
|
466 |
+
prompt = ''
|
467 |
+
if meta_instruction:
|
468 |
+
prompt += f"""<s>[UNUSED_TOKEN_146]system\n{meta_instruction}[UNUSED_TOKEN_145]\n"""
|
469 |
+
else:
|
470 |
+
prompt += '<s>'
|
471 |
+
for record in history:
|
472 |
+
prompt += f"""[UNUSED_TOKEN_146]user\n{record[0]}[UNUSED_TOKEN_145]\n[UNUSED_TOKEN_146]assistant\n{record[1]}[UNUSED_TOKEN_145]\n"""
|
473 |
+
prompt += f"""[UNUSED_TOKEN_146]user\n{query}[UNUSED_TOKEN_145]\n[UNUSED_TOKEN_146]assistant\n"""
|
474 |
+
return tokenizer([prompt], return_tensors='pt')
|
475 |
+
|
476 |
+
@torch.no_grad()
|
477 |
+
def chat(
|
478 |
+
self,
|
479 |
+
tokenizer,
|
480 |
+
query: str,
|
481 |
+
image: torch.Tensor = None,
|
482 |
+
history: List[Tuple[str, str]] = [],
|
483 |
+
streamer: Optional[BaseStreamer] = None,
|
484 |
+
max_new_tokens: int = 1024,
|
485 |
+
do_sample: bool = True,
|
486 |
+
temperature: float = 1.0,
|
487 |
+
top_p: float = 0.8,
|
488 |
+
repetition_penalty: float=1.005,
|
489 |
+
meta_instruction:
|
490 |
+
str = 'You are an AI assistant whose name is InternLM-XComposer (浦语·灵笔).\n'
|
491 |
+
'- InternLM-XComposer (浦语·灵笔) is a multi-modality conversational language model that is developed by Shanghai AI Laboratory (上海人工智能实验室). It is designed to be helpful, honest, and harmless.\n'
|
492 |
+
'- InternLM-XComposer (浦语·灵笔) can understand and communicate fluently in the language chosen by the user such as English and 中文.\n'
|
493 |
+
'- InternLM-XComposer (浦语·灵笔) is capable of comprehending and articulating responses effectively based on the provided image.',
|
494 |
+
**kwargs,
|
495 |
+
):
|
496 |
+
if image is None:
|
497 |
+
inputs = self.build_inputs(tokenizer, query, history, meta_instruction)
|
498 |
+
im_mask = torch.zeros(inputs['input_ids'].shape[:2]).cuda().bool()
|
499 |
+
else:
|
500 |
+
image = self.encode_img(image)
|
501 |
+
inputs, im_mask = self.interleav_wrap_chat(tokenizer, query, image, history, meta_instruction)
|
502 |
+
inputs = {
|
503 |
+
k: v.to(self.device)
|
504 |
+
for k, v in inputs.items() if torch.is_tensor(v)
|
505 |
+
}
|
506 |
+
# also add end-of-assistant token in eos token id to avoid unnecessary generation
|
507 |
+
eos_token_id = [
|
508 |
+
tokenizer.eos_token_id,
|
509 |
+
tokenizer.convert_tokens_to_ids(['[UNUSED_TOKEN_145]'])[0]
|
510 |
+
]
|
511 |
+
outputs = self.generate(
|
512 |
+
**inputs,
|
513 |
+
streamer=streamer,
|
514 |
+
max_new_tokens=max_new_tokens,
|
515 |
+
do_sample=do_sample,
|
516 |
+
temperature=temperature,
|
517 |
+
top_p=top_p,
|
518 |
+
eos_token_id=eos_token_id,
|
519 |
+
repetition_penalty=repetition_penalty,
|
520 |
+
im_mask=im_mask,
|
521 |
+
**kwargs,
|
522 |
+
)
|
523 |
+
if image is None:
|
524 |
+
outputs = outputs[0].cpu().tolist()[len(inputs['input_ids'][0]):]
|
525 |
+
else:
|
526 |
+
outputs = outputs[0].cpu().tolist()
|
527 |
+
response = tokenizer.decode(outputs, skip_special_tokens=True)
|
528 |
+
response = response.split('[UNUSED_TOKEN_145]')[0]
|
529 |
+
history = history + [(query, response)]
|
530 |
+
return response, history
|
531 |
+
|
532 |
+
@torch.no_grad()
|
533 |
+
def stream_chat(
|
534 |
+
self,
|
535 |
+
tokenizer,
|
536 |
+
query: str,
|
537 |
+
history: List[Tuple[str, str]] = [],
|
538 |
+
max_new_tokens: int = 1024,
|
539 |
+
do_sample: bool = True,
|
540 |
+
temperature: float = 0.8,
|
541 |
+
top_p: float = 0.8,
|
542 |
+
**kwargs,
|
543 |
+
):
|
544 |
+
"""Return a generator in format: (response, history) Eg.
|
545 |
+
|
546 |
+
('你好,有什么可以帮助您的吗', [('你好', '你好,有什么可以帮助您的吗')]) ('你好,有什么可以帮助您的吗?', [('你好',
|
547 |
+
'你好,有什么可以帮助您的吗?')])
|
548 |
+
"""
|
549 |
+
if BaseStreamer is None:
|
550 |
+
raise ModuleNotFoundError(
|
551 |
+
'The version of `transformers` is too low. Please make sure '
|
552 |
+
'that you have installed `transformers>=4.28.0`.')
|
553 |
+
|
554 |
+
response_queue = queue.Queue(maxsize=20)
|
555 |
+
|
556 |
+
class ChatStreamer(BaseStreamer):
|
557 |
+
|
558 |
+
def __init__(self, tokenizer) -> None:
|
559 |
+
super().__init__()
|
560 |
+
self.tokenizer = tokenizer
|
561 |
+
self.queue = response_queue
|
562 |
+
self.query = query
|
563 |
+
self.history = history
|
564 |
+
self.response = ''
|
565 |
+
self.received_inputs = False
|
566 |
+
self.queue.put(
|
567 |
+
(self.response, history + [(self.query, self.response)]))
|
568 |
+
|
569 |
+
def put(self, value):
|
570 |
+
if len(value.shape) > 1 and value.shape[0] > 1:
|
571 |
+
raise ValueError('ChatStreamer only supports batch size 1')
|
572 |
+
elif len(value.shape) > 1:
|
573 |
+
value = value[0]
|
574 |
+
|
575 |
+
if not self.received_inputs:
|
576 |
+
# The first received value is input_ids, ignore here
|
577 |
+
self.received_inputs = True
|
578 |
+
return
|
579 |
+
|
580 |
+
token = self.tokenizer.decode([value[-1]],
|
581 |
+
skip_special_tokens=True)
|
582 |
+
if token.strip() != '[UNUSED_TOKEN_145]':
|
583 |
+
self.response = self.response + token
|
584 |
+
history = self.history + [(self.query, self.response)]
|
585 |
+
self.queue.put((self.response, history))
|
586 |
+
|
587 |
+
def end(self):
|
588 |
+
self.queue.put(None)
|
589 |
+
|
590 |
+
def stream_producer():
|
591 |
+
return self.chat(
|
592 |
+
tokenizer=tokenizer,
|
593 |
+
query=query,
|
594 |
+
streamer=ChatStreamer(tokenizer=tokenizer),
|
595 |
+
history=history,
|
596 |
+
max_new_tokens=max_new_tokens,
|
597 |
+
do_sample=do_sample,
|
598 |
+
temperature=temperature,
|
599 |
+
top_p=top_p,
|
600 |
+
**kwargs,
|
601 |
+
)
|
602 |
+
|
603 |
+
def consumer():
|
604 |
+
producer = threading.Thread(target=stream_producer)
|
605 |
+
producer.start()
|
606 |
+
while True:
|
607 |
+
res = response_queue.get()
|
608 |
+
if res is None:
|
609 |
+
return
|
610 |
+
yield res
|
611 |
+
|
612 |
+
return consumer()
|