michaelschell commited on
Commit
4ddf83e
1 Parent(s): c4e75c9

Upload 18 files

Browse files
config.json ADDED
@@ -0,0 +1,150 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "/usr/src/data/models/phi3v",
3
+ "architectures": [
4
+ "Phi3VForCausalLM"
5
+ ],
6
+ "attention_dropout": 0.0,
7
+ "auto_map": {
8
+ "AutoConfig": "configuration_phi3_v.Phi3VConfig",
9
+ "AutoModelForCausalLM": "modeling_phi3_v.Phi3VForCausalLM"
10
+ },
11
+ "bos_token_id": 1,
12
+ "embd_layer": {
13
+ "embedding_cls": "image",
14
+ "hd_transform_order": "sub_glb",
15
+ "projection_cls": "mlp",
16
+ "use_hd_transform": true,
17
+ "with_learnable_separator": true
18
+ },
19
+ "embd_pdrop": 0.0,
20
+ "eos_token_id": 2,
21
+ "hidden_act": "silu",
22
+ "hidden_size": 3072,
23
+ "img_processor": {
24
+ "image_dim_out": 1024,
25
+ "model_name": "openai/clip-vit-large-patch14-336",
26
+ "name": "clip_vision_model",
27
+ "num_img_tokens": 144
28
+ },
29
+ "initializer_range": 0.02,
30
+ "intermediate_size": 8192,
31
+ "max_position_embeddings": 131072,
32
+ "model_type": "phi3_v",
33
+ "num_attention_heads": 32,
34
+ "num_hidden_layers": 32,
35
+ "num_key_value_heads": 32,
36
+ "original_max_position_embeddings": 4096,
37
+ "pad_token_id": 32000,
38
+ "resid_pdrop": 0.0,
39
+ "rms_norm_eps": 1e-05,
40
+ "rope_scaling": {
41
+ "long_factor": [
42
+ 1.0299999713897705,
43
+ 1.0499999523162842,
44
+ 1.0499999523162842,
45
+ 1.0799999237060547,
46
+ 1.2299998998641968,
47
+ 1.2299998998641968,
48
+ 1.2999999523162842,
49
+ 1.4499999284744263,
50
+ 1.5999999046325684,
51
+ 1.6499998569488525,
52
+ 1.8999998569488525,
53
+ 2.859999895095825,
54
+ 3.68999981880188,
55
+ 5.419999599456787,
56
+ 5.489999771118164,
57
+ 5.489999771118164,
58
+ 9.09000015258789,
59
+ 11.579999923706055,
60
+ 15.65999984741211,
61
+ 15.769999504089355,
62
+ 15.789999961853027,
63
+ 18.360000610351562,
64
+ 21.989999771118164,
65
+ 23.079999923706055,
66
+ 30.009998321533203,
67
+ 32.35000228881836,
68
+ 32.590003967285156,
69
+ 35.56000518798828,
70
+ 39.95000457763672,
71
+ 53.840003967285156,
72
+ 56.20000457763672,
73
+ 57.95000457763672,
74
+ 59.29000473022461,
75
+ 59.77000427246094,
76
+ 59.920005798339844,
77
+ 61.190006256103516,
78
+ 61.96000671386719,
79
+ 62.50000762939453,
80
+ 63.3700065612793,
81
+ 63.48000717163086,
82
+ 63.48000717163086,
83
+ 63.66000747680664,
84
+ 63.850006103515625,
85
+ 64.08000946044922,
86
+ 64.760009765625,
87
+ 64.80001068115234,
88
+ 64.81001281738281,
89
+ 64.81001281738281
90
+ ],
91
+ "short_factor": [
92
+ 1.05,
93
+ 1.05,
94
+ 1.05,
95
+ 1.1,
96
+ 1.1,
97
+ 1.1,
98
+ 1.2500000000000002,
99
+ 1.2500000000000002,
100
+ 1.4000000000000004,
101
+ 1.4500000000000004,
102
+ 1.5500000000000005,
103
+ 1.8500000000000008,
104
+ 1.9000000000000008,
105
+ 2.000000000000001,
106
+ 2.000000000000001,
107
+ 2.000000000000001,
108
+ 2.000000000000001,
109
+ 2.000000000000001,
110
+ 2.000000000000001,
111
+ 2.000000000000001,
112
+ 2.000000000000001,
113
+ 2.000000000000001,
114
+ 2.000000000000001,
115
+ 2.000000000000001,
116
+ 2.000000000000001,
117
+ 2.000000000000001,
118
+ 2.000000000000001,
119
+ 2.000000000000001,
120
+ 2.000000000000001,
121
+ 2.000000000000001,
122
+ 2.000000000000001,
123
+ 2.000000000000001,
124
+ 2.1000000000000005,
125
+ 2.1000000000000005,
126
+ 2.2,
127
+ 2.3499999999999996,
128
+ 2.3499999999999996,
129
+ 2.3499999999999996,
130
+ 2.3499999999999996,
131
+ 2.3999999999999995,
132
+ 2.3999999999999995,
133
+ 2.6499999999999986,
134
+ 2.6999999999999984,
135
+ 2.8999999999999977,
136
+ 2.9499999999999975,
137
+ 3.049999999999997,
138
+ 3.049999999999997,
139
+ 3.049999999999997
140
+ ],
141
+ "type": "su"
142
+ },
143
+ "rope_theta": 10000.0,
144
+ "sliding_window": 131072,
145
+ "tie_word_embeddings": false,
146
+ "torch_dtype": "float16",
147
+ "transformers_version": "4.43.3",
148
+ "use_cache": true,
149
+ "vocab_size": 32064
150
+ }
configuration_phi3_v.py ADDED
@@ -0,0 +1,217 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # coding=utf-8
2
+ # Copyright 2024 Microsoft and the HuggingFace Inc. team. All rights reserved.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+ """ Phi-3-V model configuration"""
17
+
18
+
19
+ from transformers.configuration_utils import PretrainedConfig
20
+ from transformers.utils import logging
21
+
22
+
23
+ logger = logging.get_logger(__name__)
24
+
25
+ PHI3V_PRETRAINED_CONFIG_ARCHIVE_MAP = {
26
+ "microsoft/Phi-3-vision-128k-instruct": "https://huggingface.co/microsoft/Phi-3-vision-128k-instruct/resolve/main/config.json",
27
+ }
28
+
29
+
30
+ class Phi3VConfig(PretrainedConfig):
31
+ r"""
32
+ This is the configuration class to store the configuration of a [`Phi3VModel`]. It is used to instantiate a Phi-3
33
+ model according to the specified arguments, defining the model architecture. Instantiating a configuration with the
34
+ defaults will yield a similar configuration to that of the
35
+ [microsoft/Phi-3-vision-128k-instruct](https://huggingface.co/microsoft/Phi-3-vision-128k-instruct).
36
+
37
+ Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the
38
+ documentation from [`PretrainedConfig`] for more information.
39
+
40
+ Args:
41
+ vocab_size (`int`, *optional*, defaults to 32064):
42
+ Vocabulary size of the Phi-3-V model. Defines the number of different tokens that can be represented by the
43
+ `inputs_ids` passed when calling [`Phi3VModel`].
44
+ hidden_size (`int`, *optional*, defaults to 3072):
45
+ Dimension of the hidden representations.
46
+ intermediate_size (`int`, *optional*, defaults to 8192):
47
+ Dimension of the MLP representations.
48
+ num_hidden_layers (`int`, *optional*, defaults to 32):
49
+ Number of hidden layers in the Transformer decoder.
50
+ num_attention_heads (`int`, *optional*, defaults to 32):
51
+ Number of attention heads for each attention layer in the Transformer decoder.
52
+ num_key_value_heads (`int`, *optional*):
53
+ This is the number of key_value heads that should be used to implement Grouped Query Attention. If
54
+ `num_key_value_heads=num_attention_heads`, the model will use Multi Head Attention (MHA), if
55
+ `num_key_value_heads=1 the model will use Multi Query Attention (MQA) otherwise GQA is used. When
56
+ converting a multi-head checkpoint to a GQA checkpoint, each group key and value head should be constructed
57
+ by meanpooling all the original heads within that group. For more details checkout [this
58
+ paper](https://arxiv.org/pdf/2305.13245.pdf). If it is not specified, will default to
59
+ `num_attention_heads`.
60
+ resid_pdrop (`float`, *optional*, defaults to 0.0):
61
+ Dropout probability for mlp outputs.
62
+ embd_pdrop (`int`, *optional*, defaults to 0.0):
63
+ The dropout ratio for the embeddings.
64
+ attention_dropout (`float`, *optional*, defaults to 0.0):
65
+ The dropout ratio after computing the attention scores.
66
+ hidden_act (`str` or `function`, *optional*, defaults to `"silu"`):
67
+ The non-linear activation function (function or string) in the decoder.
68
+ max_position_embeddings (`int`, *optional*, defaults to 4096):
69
+ The maximum sequence length that this model might ever be used with.
70
+ original_max_position_embeddings (`int`, *optional*, defaults to 4096):
71
+ The maximum sequence length that this model was trained with. This is used to determine the size of the
72
+ original RoPE embeddings when using long scaling.
73
+ initializer_range (`float`, *optional*, defaults to 0.02):
74
+ The standard deviation of the truncated_normal_initializer for initializing all weight matrices.
75
+ rms_norm_eps (`float`, *optional*, defaults to 1e-05):
76
+ The epsilon value used for the RMSNorm.
77
+ use_cache (`bool`, *optional*, defaults to `True`):
78
+ Whether or not the model should return the last key/values attentions (not used by all models). Only
79
+ relevant if `config.is_decoder=True`. Whether to tie weight embeddings or not.
80
+ tie_word_embeddings (`bool`, *optional*, defaults to `False`):
81
+ Whether to tie weight embeddings
82
+ rope_theta (`float`, *optional*, defaults to 10000.0):
83
+ The base period of the RoPE embeddings.
84
+ rope_scaling (`dict`, *optional*):
85
+ The scaling strategy for the RoPE embeddings. If `None`, no scaling is applied. If a dictionary, it must
86
+ contain the following keys: `type`, `short_factor` and `long_factor`. The `type` must be either `su` or `yarn` and
87
+ the `short_factor` and `long_factor` must be lists of numbers with the same length as the hidden size
88
+ divided by the number of attention heads divided by 2.
89
+ bos_token_id (`int`, *optional*, defaults to 1):
90
+ The id of the "beginning-of-sequence" token.
91
+ eos_token_id (`int`, *optional*, defaults to 32000):
92
+ The id of the "end-of-sequence" token.
93
+ pad_token_id (`int`, *optional*, defaults to 32000):
94
+ The id of the padding token.
95
+ sliding_window (`int`, *optional*):
96
+ Sliding window attention window size. If `None`, no sliding window is applied.
97
+ embd_layer (`str`, *optional*, defaults to `"default"`):
98
+ The embedding layer to use. Can be either `"default"` or `"image"`. "default" uses the standard embedding for text.
99
+
100
+ Example:
101
+
102
+ ```python
103
+ >>> from transformers import Phi3VModel, Phi3VConfig
104
+
105
+ >>> # Initializing a Phi-3-V style configuration
106
+ >>> configuration = Phi3Config.from_pretrained("microsoft/Phi-3-vision-128k-instruct")
107
+
108
+ >>> # Initializing a model from the configuration
109
+ >>> model = Phi3VModel(configuration)
110
+
111
+ >>> # Accessing the model configuration
112
+ >>> configuration = model.config
113
+ ```"""
114
+
115
+ model_type = "phi3_v"
116
+ keys_to_ignore_at_inference = ["past_key_values"]
117
+
118
+ def __init__(
119
+ self,
120
+ vocab_size=32064,
121
+ hidden_size=3072,
122
+ intermediate_size=8192,
123
+ num_hidden_layers=32,
124
+ num_attention_heads=32,
125
+ num_key_value_heads=None,
126
+ resid_pdrop=0.0,
127
+ embd_pdrop=0.0,
128
+ attention_dropout=0.0,
129
+ hidden_act="silu",
130
+ max_position_embeddings=4096,
131
+ original_max_position_embeddings=4096,
132
+ initializer_range=0.02,
133
+ rms_norm_eps=1e-5,
134
+ use_cache=True,
135
+ tie_word_embeddings=False,
136
+ rope_theta=10000.0,
137
+ rope_scaling=None,
138
+ bos_token_id=1,
139
+ eos_token_id=32000,
140
+ pad_token_id=32000,
141
+ sliding_window=None,
142
+ embd_layer: str = "default",
143
+ **kwargs,
144
+ ):
145
+ self.vocab_size = vocab_size
146
+ self.hidden_size = hidden_size
147
+ self.intermediate_size = intermediate_size
148
+ self.num_hidden_layers = num_hidden_layers
149
+ self.num_attention_heads = num_attention_heads
150
+
151
+ if num_key_value_heads is None:
152
+ num_key_value_heads = num_attention_heads
153
+
154
+ self.num_key_value_heads = num_key_value_heads
155
+ self.resid_pdrop = resid_pdrop
156
+ self.embd_pdrop = embd_pdrop
157
+ self.attention_dropout = attention_dropout
158
+ self.hidden_act = hidden_act
159
+ self.max_position_embeddings = max_position_embeddings
160
+ self.original_max_position_embeddings = original_max_position_embeddings
161
+ self.initializer_range = initializer_range
162
+ self.rms_norm_eps = rms_norm_eps
163
+ self.use_cache = use_cache
164
+ self.rope_theta = rope_theta
165
+ self.rope_scaling = rope_scaling
166
+ self._rope_scaling_validation()
167
+ self.sliding_window = sliding_window
168
+ self.embd_layer = embd_layer
169
+
170
+
171
+ super().__init__(
172
+ bos_token_id=bos_token_id,
173
+ eos_token_id=eos_token_id,
174
+ pad_token_id=pad_token_id,
175
+ tie_word_embeddings=tie_word_embeddings,
176
+ **kwargs,
177
+ )
178
+
179
+ def _rope_scaling_validation(self):
180
+ """
181
+ Validate the `rope_scaling` configuration.
182
+ """
183
+ if self.rope_scaling is None:
184
+ return
185
+
186
+ if not isinstance(self.rope_scaling, dict) or len(self.rope_scaling) != 3:
187
+ raise ValueError(
188
+ "`rope_scaling` must be a dictionary with three fields, `type`, `short_factor` and `long_factor`, "
189
+ f"got {self.rope_scaling}"
190
+ )
191
+ rope_scaling_type = self.rope_scaling.get("type", None)
192
+ rope_scaling_short_factor = self.rope_scaling.get("short_factor", None)
193
+ rope_scaling_long_factor = self.rope_scaling.get("long_factor", None)
194
+ if rope_scaling_type is None or rope_scaling_type not in ["su", "yarn"]:
195
+ raise ValueError(f"`rope_scaling`'s type field must be one of ['su', 'yarn'], got {rope_scaling_type}")
196
+ if not (
197
+ isinstance(rope_scaling_short_factor, list)
198
+ and all(isinstance(x, (int, float)) for x in rope_scaling_short_factor)
199
+ ):
200
+ raise ValueError(
201
+ f"`rope_scaling`'s short_factor field must be a list of numbers, got {rope_scaling_short_factor}"
202
+ )
203
+ if not len(rope_scaling_short_factor) == self.hidden_size // self.num_attention_heads // 2:
204
+ raise ValueError(
205
+ f"`rope_scaling`'s short_factor field must have length {self.hidden_size // self.num_attention_heads // 2}, got {len(rope_scaling_short_factor)}"
206
+ )
207
+ if not (
208
+ isinstance(rope_scaling_long_factor, list)
209
+ and all(isinstance(x, (int, float)) for x in rope_scaling_long_factor)
210
+ ):
211
+ raise ValueError(
212
+ f"`rope_scaling`'s long_factor field must be a list of numbers, got {rope_scaling_long_factor}"
213
+ )
214
+ if not len(rope_scaling_long_factor) == self.hidden_size // self.num_attention_heads // 2:
215
+ raise ValueError(
216
+ f"`rope_scaling`'s long_factor field must have length {self.hidden_size // self.num_attention_heads // 2}, got {len(rope_scaling_long_factor)}"
217
+ )
eval_after.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"answers_unique": [["1128 SIXTEENTH ST., N. W., WASHINGTON, D. C. 20036", "1128 sixteenth st., N. W., washington, D. C. 20036"], ["As competitor's joined the price war"], ["2"], ["2013"], ["485", "$485"], ["16"], ["ITC Limited"], ["four", "four conferences"], ["20", "20 years"], ["projects", "Projects"], ["ITC Limited"], ["34"], ["215-741-4052"], ["Maria Shulleeta", "maria shulleeta"], ["questions and answers", "Questions and Answers"], ["110-120 f", "110-120 F"], ["78.2%", "78.2"], ["8,899,947"], ["CASED, REDR BUR FOR BEST 327391"], ["Fred L. Smith, Jr.", "Fred L Smith jr."], ["NNK", "NNK or 4-(methylnitrosoamino)-1-(3-pyridyl)-1-butanone", "4-(methylnitrosoamino)-1-(3-pyridyl)-1-butanone"], ["0.57%"], ["DESCRIPTION", "Description"], ["Sehore"], ["WelcomHotel", "WelComHotel"], ["$975.00", "975.00"], ["82.85", "82.85%", "(82.85%)"], ["22"], ["50"], ["82", "82%"], ["GENERAL FOOD FUND, INC"], ["103"], ["Steering Committee Meeting", "Steering committee Meeting"], ["10:00 - 11:30 AM", "10:00 - 11:30 AM"], ["mint-o"], ["Sunfeast"], ["19,000"], ["25.9"], ["charles d. nesbit", "Charles D. Nesbit"], ["english, french and spanish", "English, French and Spanish"], ["University of Maine"], ["CAPRI"], ["administration", "Administration"], ["Consumer Dynamics GPC", "Consumer Dynamics"], ["14-3006-14"], ["4-(methylnitrosoamino)-1-(3-pyridyl)-1-butanone", "tobacco-specific nitrosamine"], ["c", "C", "consumed by control [c]", "Control [C]", "Control"], ["may 2, 1978", "May 2, 1978."], ["Madhya Pradesh"], ["WelcomHeritage"], ["TRRF Vice President", "lee a. waller"], ["20.77", "20.77%", "(20.77%)"], ["10,000"], ["Essenza Di Wills, Fiama Di Wills, Vivel and Superia"], ["Emotional Enhancement"], ["seven", "7"], ["PLATTE COUNTY VOLUNTEERS AGAINST HUNGER", "Platte county volunteers against hunger"], ["Volunteers Against Hunger Steering Committee", "Volunteers against Hunger Steering committee"], ["609/924-6648"], ["candyman", "Candyman"], ["Snacky"], ["1971"], ["18 million", "18 million order", "the 18 million order"], ["the organizing committee", "Organizing committee", "The organizing committee"], ["questions and answers", "Questions and Answers"], ["Forest Products Laboratory", "Forest Products Laboratory in Madison", "Forest Products Laboratory in Madison, Wisconsin"], ["August 31, 1963"], ["$ 3,038,444", "3,038,444"], ["89", "(89)"], ["Fred L. Smith, Jr.", "Fred L Smith .jr"], ["The levels ranged from 0.05 - 0.23 ppm", "0.05 - 0.23 ppm.", "0.05 - 0.23 ppm"], ["93-51954"], ["51092 5213"], ["vanderbilt university", "VANDERBILT UNIVERSITY"], ["Dec-08"], ["2"], ["17.15%", "17.15", "(17.15%)"], ["24,26,435"], ["Classmate and Paperkraft"], ["29"], ["40"], ["29.9"], ["Bert Shulimson", "Bert Shulimson , Executive Secretary"], ["January 18, 2005"], ["Aashirvaad"], ["Dream Cream", "Dream cream"], ["34,500"], ["Philip Morris Super Lights", "philip morris super lights"], ["international union of nutritional sciences", "International union of nutritional sciences"], ["mexico city", "Mexico city", "in mexico city"], ["proprietary cellulose acetate web", "their proprietary cellulose acetate web"], ["31", "( 31)"], ["KOOL KS", "Kool KS"], ["2.5", "2.5%"], ["BURKE", "Burke"], ["Hongkong", "HongKong"], ["1994", "October 1994"], ["hormone replacement therapy"], ["march 22, 1921", "March 22, 1921"], ["ITC-Welcomgroup"], ["2"], ["A. C. Monk"], ["70", "70%"], ["Wills Lifestyle and John Players"], ["Scissors Menthol Fresh", "Menthol Fresh"], ["30"], ["1,423"], ["Holiday Inn Downtown , Jefferson City , Missouri", "Holiday Inn Downtown, Jefferson City, Missouri", "Holiday Inn Downtown"], ["mint-o"], ["ITC Limited"], ["Carol A. Tozzi, Ph.D.", "Carol A. Tozzi"], ["stock keeping units", "Stock keeping units"], ["690"], ["september 3 to 9, 1972", "September 3 to 9, 1972.", "from September 3 to 9, 1972", "September 3 to 9, 1972"], ["charles d. nesbit", "Charles D. Nesbit", "Charles D. Nesbit, IARW Chairman"], ["research department", "Research Department"], ["$ 7,265,516", "7,265,516"], ["KOOL KS", "kool ks"], ["USMM 1/95-6/95, 12-Month Data", "USMM 1/95-6/95, 12 Month Data"], ["Sidestream Smoke Chamber"], ["240.00"], ["c", "C", "consumed by control [c]", "Control [C]", "Control"], ["For all our tomorrows", "For All Our Tomorrows"], ["1.0%"], ["10.3%"], ["6"], ["31"], ["14,000"], ["Mangaldeep"], ["February 24", "February 24 1966", "February 24 .1966"], ["5"], ["33,600"], ["candyman", "Candyman"], ["1979"], ["Sunfeast Yippee!"], ["July 26, 2000"], ["PROJECT ASSIGNMENT FORM"], ["INTER-OFFICE CORRESPONDENCE", "Inter-office correspondence"], ["charles d. nesbit", "Charles D. Nesbit", "Charles D. Nesbit, IARW Chairman"], ["february 7, 1994", "February 7, 1994"], ["research service department", "Research Service Department"], ["METH DEV"], ["1R4F REFERENCE RESULTS", "1R4F reference"], ["12427"], ["University of Maine"], ["2"], ["11/8/2001"], ["Sustainability updates", "Sustainability Updates"], ["83.4%"], ["CMRO"], ["6"], ["ITC Limited"], ["57", "57%"], ["Aim"], ["64", "64%"], ["33.0"], ["Dr. Joseph C. Hwang"], ["independent ice and cold storage co.", "Independent Ice and Cold Storage Co."], ["723"], ["mint-o Ultra mintz", "mint-o Ultra Mintz"], ["essenza di wills", "Essenza Di Wills"], ["John A. SMith, Ph.D.", "John A. Smith, Ph.D"], ["Hartsville , TN", "Hartsville, TN", "Hartsville , TN 37074"], ["international congress of nutrition", "International Congress of Nutrition", "ix international congress of nutrition"], ["approved"], ["USMM 1/95-6/95, 12-Month Data"], ["TVB"], ["AVERAGE 1R4F RESPONSES PER S9 LOT STRAIN TA100"], ["12"], ["12"], ["62272"], ["Nicotine RSM Study"], ["Mangaldeep"], ["public schools of ponca city, oklahoma", "Public schools of Ponca city, Oklahoma"], ["N. Anand"], ["3"], ["bengaluru", "Bengaluru", "in Bengaluru"], ["The Environment"], ["Responsible Luxury", "\"Responsible Luxury\""], ["Wendell Rodricks Now At Wills Lifestyle"], ["37.0"], ["Dr. Arley T. Bever"], ["Menopausal Health Publication Management"], ["candyman", "Candyman"], ["Fiama Di Wills"], ["essenza di wills", "Essenza Di Wills"], ["vivel", "Vivel"], ["21.0"], ["mexican government", "Mexican government", "the mexican government", "Mexican"], ["60-1120"], ["KOOLS"], ["1.0", "1"], ["MT-778"], ["Citrate"], ["1", "figure 1"], ["KOOL 100"], ["MAJOR STRATEGIC RESEARCH PROGRAMS", "MAJOR STRATEGIC"], ["december 1958", "December 1958"], ["6.1%"], ["1952"]], "generated_texts_unique": ["1128 Sixteenth St., N. W., Washington, D. C. 20036", "As competitor's joined the price war.\n\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n", "2.\n\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n", "2013", "$485.\n\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n", "16.\n\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n", "ITC Limited.\n\n\nThe image shows a building with a large glass facade.\n\nThe image shows a building with a large glass facade.\n\nThe image shows a building with a large glass facade.\n\nThe image shows a building with a large glass facade.\n\nThe", "4.\n\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n", "20 years.\n\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n", "Projects.\n\n1.\nProjects.\n205.0.\n17,083.\n-0-.\n153,747.\n133,333.\n20,414.\n1.\nSCN-2,", "Sunfeast.\n\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n", "34.\n\nTable. Effects of various treatments on visomotor symptoms: randomized, double-blind, placebo-controlled trials.\n\nEffective in Treating.\n\nHot Flushes vs.\n\nTreatment.\n\nPlace", "215-741-4052.\n\n\nWhat is John's Bensalem, PA 19020.\n\n\nWhat is John's Durham Place.\n\n\nWhat is John's NAME.\n\n\nWhat is John's", "Maria shulletta.\n\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n", "Questions and Answers.\n\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n", "110-120 f.\n\n2. Mix thoroughly.\n\n3. Hold at 120 f. and apply with air atomization.\n\n4. Hold at 120 f. and apply with air atomization.\n\n5. Hold at 12", "78.2%.\n\nIndex: (111).\n\nSource: USMM 1/95-6/95, 12-Month Data.\n\nSource: https://www.industrydocuments.ucsf.edu/docs/rzbj00", "$ 7,265,516.\n\nInvestments.\n\n8,899,947.\n\n11,369,878.\n\n(42,262).\n\n610,775", "Cased, redr bur for best 327391.\n\nBlend: BW-6068.\n\nThe burley is reDried.\n\nFinal (in cigarette).\n15.00 %.\n\nFlue cured strips in", "Red L. Smith, Jr.\n\nCEI CONTRIBUTORS.\nThe following foundations, corporations, and individuals support the Institute's work.\nThese supporters may, of course, differ with specific policy initiatives, however,\ntheir support indicates their recognition of", "NNK or 4-(methylnitrosoamino)-1-(3-pyridyl)-1-butanone.\n\nNNK is found in both mainstream smoke and in sidestream smoke.\n\nNNK is carcinogenic in laboratory animals", "0.57.\n\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n", "Major strategic research programs.\n\n.\n\nNicotine RSM Study.\n\n.\n\nAn interdepartmental study which:.\n\n1. Comprehensively defines the role of nicotine in smoker acceptance and physiological/pharmacological measures of", "Madhya Pradesh.\n\n\nIn which year, the Watershed Development Project at Schore has been included in the list of 47 best sites by the Rajiv Gandhi Mission for Watershed Management.\n\n\nAgarbatti Value Chain.\n\n\nNatural Resource", "WelcomHotel.\n\n45.\nITC Report and Accounts 2009.\nSource: https://www.industrydocuments.ucsf.edu/docs/lynbx0223.\n\n45.\nITC Report and Accounts", "$ 975.00.\n\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n", "82.85.\n\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n", "22.\n\n22.\n\n22.\n\n22.\n\n22.\n\n22.\n\n22.\n\n22.\n\n22.\n\n22.\n\n22.\n\n22.\n\n22", "Over 50", "82.\n\n75.\n\n68.\n\n80.\n\n27.\n\n23.\n\n70.\n\n61.\n\n64.\n\n29.\n\n7886 98ets.\n\n70", "General Foods Fund, Inc.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n", "103.\n\n#2.\n133.\n#3.\n111.\n\nTriglyceride.\n293.\n203.\n169.\n\nBlood Analysis.\nGroup.\n#1.\n#2", "Steering Committee Meeting.\n\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n", "10:00 - 11:30 AM.\n\nPage 4 of 6.\n\nJune 13, 2001.\n\nConference Room #555-6B.\n\nStatus.\nPublication.\nInvestigator/", "BINGO.\n\nBINGO.\n\nBINGO.\n\nBINGO.\n\nBINGO.\n\nBINGO.\n\nBINGO.\n\nBINGO.\n\nBINGO.\n\nBINGO.\n\nBINGO", "Sunfeast.\n\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n", "19,000.\n\nWhat is the % of poverty in Henry county.\n21.0.\n\nWhat is the % col.(3) of Henry county.\n3,990.\n\nWhat is the % col.(5) of Henry county.\n1", "25,9.\n\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n", "Charles D. Nesbit.\n\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n", "English, French and Spanish.\n\n\nThe Organizing Committee is honored to invite you to participate in the international congress of nutrition.\n\nSponsored by the Mexican government and the international union of nutritional sciences.\n\nWhich will take place in the congress unit", "University of Maine.\n\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n", "CAPRI.\n\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n", "Administration.\n\n\nIncome.\n\n\nExpenditures.\n\n\n11,369,878.\n\n\n11,938,391.\n\n\n$ 3,038,444.\n\n\n$", "Consumer Dynamics GPC", "14-3006-14.\n\n.\nSupplier: Burke.\n\n.\nTitle: 2014 NAS KANSAS CITY A/T/P Pre Wave.\n\n.\nJOB ASSIGNMENT ADDENDUM", "NNK or 4-(methylnitrosoamino)-1-(3-pyridyl)-1-butanone.\n\nNNK is a tobacco-specific nitrosamine which is formed during the curing and smoking of tobacco. Formation during cur", "TD.\n\nFigure 1.\n12.\n\nSource: https://www.industrydocuments.ucsf.edu/docs/mythv0228.\n\nWeekly diet [ml] consumed by control [c], thiamine deficient", "May 2, 1978.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n", "Madhya Pradesh.\n\n\nIn which state is Agarbatti Value Chain located.\nAnswer briefly.\n\n\nIn which state is Livestock Development located.\nAnswer briefly.\n\n\nIn which state is Natural Resource Management located.\nAnswer briefly.\n\n\nIn which", "ITC.\n\nThe ITC-Welcomegroup chain, with its globally benchmarked levels of product and service excellence and customer centricity is well positioned to not only.\n\n45.\nITC Report and Accounts 2009.\n\nSource: https", "Lee a. waller.\n\nTRRF vice president.\n\n11:39 a.m.\n\n11:39 a.m.\n\n11:39 a.m.\n\n11:39 a.m.\n\n11:3", "20.77.\n\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n", "10,000.\n\n20.\nITC Report and Accounts 2013.\nSource: https://www.industrydocuments.ucsf.edu/docs/snbx0223.\n\n20.\nITC Report and Account", "Wills, Vivel and Superia, Classmate and Paperkraft in Education & Stationery products; Wills Lifestyle and John Players in the Lifestyle Apparel business; Mangaldeep Agarbattis as well as Alim Consumes have established significant market standing and continue to delight", "Emotional enhancement.\n\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n", "Seven.\n\nTable 2.\nAge and weight of children and experimental design used for studies of milk protein dilution.\nSubject.\nAge (yrs.).\nInitial Wt.\n(lb.).\nFinal Wt.\n(lb.).\nBaseline Diet.\nDays on.\nDays", "PLATTE COUNTY VOLUNTEERS AGAINST HUNGER.\n\nMissouri Association for Social Welfare.\n\n113B West High Street.\n\nJefferson City, Missouri.\n\nSource: https://www.industrydocuments.ucsf.edu", "Volunteers against hunger steering committee.\n\nFROM: Bert shulimson, executive secretary.\n\nSUBJECT: Steering committee meeting.\n\nBS: mk.\n\nEnclosure.\n\nJune 11, 1970.\n\nTHE WELFA", "609/924-6648.\n\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n", "BINGO.\n\nBINGO.\n\nBINGO.\n\nBINGO.\n\nBINGO.\n\nBINGO.\n\nBINGO.\n\nBINGO.\n\nBINGO.\n\nBINGO.\n\nBINGO", "SMARTY.\n\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n", "1969.\n\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n", "18 million.\n\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n", "The organizing committee.\n\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n", "Questions and Answers.\n\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n", "Forest Products Laboratory.\n\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n", "August 31, 1963.\n\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n", "$ 3,038,444.\n\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n", "89.\n\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n", "Red L. Smith, Jr.\n\nCEI Contributors.\n\nCompetitive Allies.\n\nCompetitive Enterprise Institute.\n\n1001 Connecticut Avenue, NW.\n\n20036.\n\n202) 331-1", "45%.\n\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n", "93-51954.\n\n243.\n\nJob #: 2566-16.\n\nInvoice #: 62272.\n\nBilling Period: 4/4/97.\n\nPage 1", "26015.\n\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n", "VANDERBILT UNIVERSITY.\n\nWhich month is mentioned in the pledge.\nAnswer briefly.\nMARCH.\n\nWhich month is mentioned in the pledge.\nMARCH.\n\nWhich month is mentioned in the pledge.\nMAR", "Dec-08.\n\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n", "2.\n\n2.\n\n3.\n\n3.\n\n3.\n\n3.\n\n3.\n\n3.\n\n3.\n\n3.\n\n3.\n\n3.\n\n3.\n\n3.\n\n3.\n\n3", "17.15.\n\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n", "24,26,435.\n\n2,70,000.\n\nIII. INVESTORS GRIEVANCE COMMITTEE.\n\nThe Investors Grievance Committee of the Board, under the nomenclature 'Investor", "Wills lifestyle and John Players.\n\n\nWhat are the 2 wellness brands of ITC.\nAnswer briefly.\n\n\nWhat are the 2 cuisine in India brands of ITC.\nAnswer briefly.\n\n\nWhat are the 2 wellness br", "29.\n\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n", "40.\n\nTable 2.\nAge and weight of children and experimental design used for studies of milk protein dilution.\nSubject.\nAge (yrs.).\nInitial Wt.\n(lb.).\nFinal Wt.\n(lb.).\nBaseline Diet.\nDays on", "29.9.\n\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n", "Bert Shulimson, Executive Secretary.\n\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n", "January 18, 2005.\n\n.\n\n.\n\n.\n\n.\n\n.\n\n.\n\n.\n\n.\n\n.\n\n.\n\n.\n\n.\n\n.\n\n.\n\n.\n\n.\n\n", "AASHIRAAD", "Dream.\n\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n", "34,500.\n\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n", "Hong kong.\n\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n", "International Union of Nutritional Sciences.\n\n\nThe Organizing Committee.\n\n\nInternational Congress of Nutrition.\n\n\nSponsored by the Mexican Government and the International Union of Nutritional Sciences.\n\n\nwhich will take place in the Congress Unit of the Centro", "Mexico City.\n\n\nThe International Congress of Nutrition.\n\n\nThe Organizing Committee.\n\n\nThe Congress will essentially consist of symposia and colloquia.\n\n\nThe Congress will essentially consist of symposia and colloquia, by invitation and short communications", "Their proprietary cellulose acetate web.\n\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n", "1.0.\n\n(31).\n\nIndex.\n\nSource: USMM 1/95-6/95, 12-Month Data.\n\nSource: https://www.industrydocuments.ucsf.edu/docs/rzbj00", "KOOL KS.\n\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n", "2.5.\n\nindex.\n\n( 64).\n\nSource: USMM 1/95-6/95, 12-Month Data.\n\nSource: https://www.industrydocuments.ucsf.edu/docs/rzbj0", "Burke.\n\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n", "Japan.\n\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n", "1994.\n\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n", "Hormone replacement therapy.\n\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n", "March 22, 1921.\n\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n", "ITC.\n\n45.\nITC Report and Accounts 2009.\nSource: https://www.industrydocuments.ucsf.edu/docs/lynbx0223.\nReport of the Directors.\n45.\nITC Limited", "2.\n\n2.\n\n3.\n\n3.\n\n3.\n\n3.\n\n3.\n\n3.\n\n3.\n\n3.\n\n3.\n\n3.\n\n3.\n\n3.\n\n3.\n\n3", "A. C. Monk.\n\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n", "70.\n\n70.\n\n70.\n\n70.\n\n70.\n\n70.\n\n70.\n\n70.\n\n70.\n\n70.\n\n70.\n\n70.\n\n70", "Mangaldeep Agarbattis and Dil Milk.\n\n\nWhat are the 2 lifestyle & apparel brands of ITC.\nAnswer briefly.\n\n\nWhat are the 2 lifestyle & apparel brands of ITC.\nAnswer briefly", "Royal Special Filter.\n\n\nRoyal Special Filter.\n\n\nRoyal Special Filter.\n\n\nRoyal Special Filter.\n\n\nRoyal Special Filter.\n\n\nRoyal Special Filter.\n\n\nRoyal Special Filter.\n\n\nRoyal Special Filter.\n\n\nRo", "40.\n\nTable 2.\nAge and weight of children and experimental design used for studies of milk protein dilution.\nSubject.\nAge (yrs.).\nInitial Wt.\n(lb.).\nFinal Wt.\n(lb.).\nBaseline Diet.\nDays on", "1,423.\n\nPage 6 January, 1970.\nMissouri Food Donation Program.\nBy MASW Divisions and Counties.\nCOUNTY.\nPopulation.\nFamilies.\nEstimated.\nParticipants In.\nPublic", "Holiday Inn Downtown, Jefferson City, Missouri.\n\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n", "CANDYMAN.\n\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n", "Aashirvaad.\n\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n", "Carol A. Tozzi, Ph.D.\n\n2.\nDWRITE 003356.\nSource: https://www.industrydocuments.ucsf.edu/docs/xjww0217.\n\nKaren D. Mittleman,", "Stock keeping units", "690.\n\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n", "September 3 to 9, 1972.\n\n\nThe Organizing Committee.\n\n\nThe Congress will essentially consist of symposia and colloquia, by invitation and short communications.\n\n\nIn the symposia, particular attention will be given to the nutr", "Charles D. Nesbit.\n\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n", "Research Department.\n\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n", "$ 7,265,516.\n\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n", "KOOL KS.\n\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n", "1/95-6/95, 12-Month Data.\n\nSource: https://www.industrydocuments.ucsf.edu/docs/rzbj0037.\n\n314002837.\n\nConsumer Dynamics", "Sidestream Smoke Chamber.\n\n202156401.\n-2-.\nSource: https://www.industrydocuments.ucsf.edu/docs/hjxj0037.\n\n\nFILTER RESEARCH AND DEVE", "240,00.\n\nDetails of Remuneration paid to the Directors during the financial year ended 31st March, 2009.\n\nA. Singh.\n\n108,00.\n22,73.\n162", "C.\n\nFigure 1.\n\n12.\n\nSource: https://www.industrydocuments.ucsf.edu/docs/mythv0228.\n\n1.\n\n2.\n\n3.\n\n4.\n\n5", "For All Our Tomorrows", "1.0.\n\n1.0.\n\n1.0.\n\n1.0.\n\n1.0.\n\n1.0.\n\n1.0.\n\n1.0.\n\n1.0.\n\n1.0.\n\n1.0", "10.3%.\n\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n", "6.\n\n24th May, 2012: 6.\nS. H. Khan: 2.\n28th March, 2013: 7.\nAppointed Member w.a. t. 18th January, 20", "31.\n\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n", "14,000.\n\n20.\nITC Report and Accounts 2013.\nSource: https://www.industrydocuments.ucsf.edu/docs/snbx0223.\n\nThe appointment of the Executive Directors is govern", "Mangaldeep.\n\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n", "February 24, 1966.\n\n64-1.\n\nSource: https://www.industrydocuments.ucsf.edu/docs/hjfk0226.\n\nJohn J. Brennan.\n\nApplicant", "5.\n\nTable 2.\nAge and weight of children and experimental design used for studies of milk protein dilution.\nSubject.\nAge (yrs.).\nInitial Wt.\n(lb.).\nFinal Wt.\n(lb.).\nBaseline Diet.\nDays on", "33,600.\n\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n", "BINGO.\n\nCANDYMAN.\n\nMINI-O.\n\nITC Limited REPORT AND ACCOUNTS 2013.\n\nBINGO.\n\nBINGO.\n\nBINGO.\n\nBINGO.\n\nBING", "1979.\n\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n", "Sunfeast.\n\nWhat is the brand name of the instant foam wash with triple skin conditioners.\nAnswer briefly.\n\nWhat is the brand name of the instant foam wash with triple skin conditioners.\nAnswer briefly.\n\nWhat is the brand name of the instant foam", "July 26, 2000.\n\n2.\nDWRITE 003356.\nSource: https://www.industrydocuments.ucsf.edu/docs/xjw0217.\n\nConfidentiality.\nThe writer will", "Project assignment form.\n\n.\n\n.\n\n.\n\n.\n\n.\n\n.\n\n.\n\n.\n\n.\n\n.\n\n.\n\n.\n\n.\n\n.\n\n.\n\n.\n\n.\n\n.\n\n.\n\n", "INTER-OFFICE CORRESPONDENCE", "Charles D. Nesbit, IARW Chairman.\n\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n", "February 7, 1994.\n\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n", "Research Service Department.\n\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n", "Meth dev.\n\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n", "1R4F.\n\n1R4F reference results.\n\nAverage 1R4F responses per s9 lot strain ta100.\n\nAverage results for s9 lot 0329: 1159.\n\nAverage results for s", "12427.\n\n1I/1NI/5SE.\n\n1I/1NI/4SE.\n\n1NI/5SE.\n\n1NI/5SE.\n\n1NI/5SE.\n\n1NI/7NI.\n\n1", "University of Maine.\n\n-2-.\n\n202156401.\n\nSource: https://www.industrydocuments.ucsf.edu/docs/hjxj0037.\n\n-2-.\n\n2021564", "2.\n\nFigure 1.\n\n12.\n\nSource: https://www.industrydocuments.ucsf.edu/docs/mythv0228.\n\n1.\n\n2.\n\n3.\n\n4.\n\n5", "11/8/2001.\n\nLAWT021-009907.\n\nConfidential Pursuant to Confidentiality Order.\n\nPage 34 of 45.\n\nAll rights reserved.\n\nC O N", "Sustainability Updates.\n\nFor All Our Tomorrows.\n\nThe Watershed Development Project at Schore has been included in the list of 47 best sites by the Rajiv Gandhi Mission for Watershed Management, Madhya Pradesh.\n\nAgarbatti", "83.4.\n\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n", "CMRO.\n\nWhat is the abbreviation of Pharmaceutical Marketing.\nAnswer briefly.\n\nWhat is the abbreviation of Pharmaceutical Education Associates.\nAnswer briefly.\n\nWhat is the abbreviation of Pharmaceutical Marketing News.\nAnswer", "6.\n\nWhat is the committee strength for the sustainability committee meeting held on 24th May, 2012?\n6.\n\nWhat is the committee strength for the sustainability committee meeting held on 28th March, 2013.\n7", "ITC.\n\n\nWhat is the name of the report.\nAnswer briefly.\n\n\nWhat is the report and accounts 2013.\n\n\nWhat is the report and accounts 2013.\n\n\nWhat is the report and accounts 2013", "57.\n\n70.\n61.\n68.\n60.\n27.\n29.\n70.\n64.\n61.\n57.\n68.\n75.\n80.\n82.\n27", "Wills.\n\n\nWilliams.\n\n\nWilliam's.\n\n\nWilliam's Vivel and Superia.\n\n\nWilliam's Vivel and Superia are the personal care products segment.\n\n\nWilliams.\n\n\nWilliams Lifestyle and", "64.\n\n70.\n\n61.\n\n68.\n\n80.\n\n27.\n\n23.\n\n70.\n\n61.\n\n68.\n\n80.\n\n27.\n\n29", "33.0.\n\nTable 2.\nAge and weight of children and experimental design used for studies of milk protein dilution.\nSubject.\nAge (yrs.).\nInitial Wt.\n(lb.).\nFinal Wt.\n(lb.).\nBaseline Diet.\nDays", "Joseph C. Rwang.\n\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n", "Independent Ice and Cold Storage Co.\n\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n", "723.\n\n750.\n\n6,750.\n\n6,507.\n\n243.\n\n9.\n\n750.\n\n723.\n\n6,750.\n\n6,507", "Candyman Cr\u00e8me Lacto.\n\n\nAashrvaad Atta Multigrains.\n\n\nAashrvaad Atta Multigrains.\n\n\nAashrvaad Atta Multigrains.\n\n\nAashrvaad Atta Mult", "Essenza Di Wills.\n\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n", "John A. Smith, Ph.D.\n\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n", "Hartsville, TN 37074.\n\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n", "International Congress of Nutrition.\n\n\nThe Organizing Committee.\n\n\nThe Congress will essentially consist of symposia and colloquia, by invitation and short communications.\n\n\nIn the symposia, particular attention will be given to the nutritional problems of underdevelop", "Approved.\n\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n", "USMM.\n\nSource: https://www.industrydocuments.ucsf.edu/docs/rzbj0037.\n\n314002836.\n\nIndex.\n\n(103).\n\n( 97).\n\n(", "TVB.\n\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n", "Average 1R4F responses per s9 lot strain ta100.\n\n1R4F reference results.\n\nAverage results for s9 lot 0329: 1159.\n\nAverage results for s9 lot 0349:", "15.\n\n1.\n2.\n3.\n4.\n5.\n6.\n7.\n8.\n9.\n10.\n11.\n12.\n13.\n14.\n15.\n16.\n17", "12.\n\nFigure 1.\n\nSource: https://www.industrydocuments.ucsf.edu/docs/mythv0228.\n\nWeekly diet [ml] consumed by control [c], thiamine deficient [td],", "62272.\n\nPage 1.\n\nPage 1.\n\nPage 1.\n\nPage 1.\n\nPage 1.\n\nPage 1.\n\nPage 1.\n\nPage 1.\n\nPage 1.\n\nPage", "Nicotine RSM Study.\n\n.\n\nwhat is the description of the program.\nAnswer briefly.\n\n1. Comprehensively defines the role of nicotine in smoker acceptance and physiological/pharmacological measures of satisfaction.\n2. Generates learning immediately", "Mangalee.\n\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n", "Public schools of Ponca City, Oklahoma.\n\n1938.\n\nUniversity of Oklahoma.\n\nB.S. in zoology.\n1942.\n\nUniversity of Oklahoma.\n\nM.S. in Chemistry.\n1947", "N. Anand.\n\n12.\nITC Limited.\n\n13.\nREPORT AND ACCOUNTS 2014.\n\n14.\nTOTAL.\n\n15.\nA. Vijayanthi.\n\n16", "2.\n\n2.\n\n3.\n\n3.\n\n3.\n\n3.\n\n3.\n\n3.\n\n3.\n\n3.\n\n3.\n\n3.\n\n3.\n\n3.\n\n3.\n\n3", "Bangaluru.\n\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n", "The Environment.\n\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n", "\"Responsible Luxury\"", "Wendell Rodricks joins learning indian designers.\n\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n", "37.0.\n\nTable 2.\nAge and weight of children and experimental design used for studies of milk protein dilution.\nSubject Age (yrs.) Initial Wt. (lb.) Final Wt. (lb.) Baseline Diet Days on Dilution.\nP.K", "Dr. arlene brennan.\n\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n", "Menopausal Health Publication Management.\n\n\nJune 13, 2001.\n\n10:00 - 11:30 AM, Conference Room #555-6B.\n\nPage 4 of 6.\n\nStatus", "BINGO.\n\nCANDYMAN.\n\nMINI-O.\n\nSource: https://www.industrydocuments.ucsf.edu/docs/snbox0223.\n\nBINGO.\n\nCANDYMAN.\n\nMINI-O", "NOWDLES.\n\n\nIn the personal care products category, ITC has developed Liquid Crystal Freezing Technology for its Fiama Di Wills brand.\n\n\nAASHIRAAD ATTA MULTIGRAINS.\n\n\nAASHIRAAD ATTA", "Essenza Di Wills.\n\nWhich brand unites distinct craftsmanship and passion.\nAnswer briefly.\n\nEssenza Di Wills.\n\nWhich brand offers a range of expert solutions designed to make consumers look & feel young.\nAnswer briefly.\n\nFiama", "ITC.\n\n\nThis supply chain infrastructure has reforced its competitive capability significantly to ensure visibility, availability and freshness. ITC's brands are today available in more than 1000 Stock Keeping Units (SKUs) at nearly 6 million retail out", "21.0.\n\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n", "Mexican government.\n\n\nThe International Union of Nutritional Sciences.\n\n\nThe Congress will essentially consist of symposia and colloquia, by invitation and short communications.\n\n\nIn the symposia, particular attention will be given to the nutritional problems of underdevelop", "60-1120.\n\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n", "KOOLS.\n\n499150501.\n\nSource: https://www.industrydocuments.ucsf.edu/docs/mxci0037.\n\n.\n.\n.\n.\n.\n.\n.\n.\n", "1.\n\nR&D.\n\nCUSTOMER.\n\nMETH DEV.\n\n1.0.\n\nDURATION.\n\n6.\n\nPROJECT LEADER.\n\nFY.\n\n2.\n\nWater on Tobacco", "778.\n\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n", "Alkali metal.\n\nII. THE EFFECT OF RINSE OF FABRIC ON IGNITION PROPENSITY.\n\nCIG. NAME.\nRIP-4.\nRIP-6.\nKOOL KS.\nRIP-4", "1.\n\n12.\n\nFigure 1.\n\nSource: https://www.industrydocuments.ucsf.edu/docs/mythv0228.\n\n12.\n\nFigure 1.\n\nSource: https://www.indust", "KOOL 100.\n\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n", "Nicotine RSM Study.\n\n.\n\n.\n\n.\n\n.\n\n.\n\n.\n\n.\n\n.\n\n.\n\n.\n\n.\n\n.\n\n.\n\n.\n\n.\n\n.\n\n.\n\n.\n\n", "December 1958.\n\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n", "6.1.\n\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n", "1952.\n\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n"], "anls": 0.034699999999999995}
eval_before.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"answers_unique": [["1128 SIXTEENTH ST., N. W., WASHINGTON, D. C. 20036", "1128 sixteenth st., N. W., washington, D. C. 20036"], ["As competitor's joined the price war"], ["2"], ["2013"], ["485", "$485"], ["16"], ["ITC Limited"], ["four", "four conferences"], ["20", "20 years"], ["projects", "Projects"], ["ITC Limited"], ["34"], ["215-741-4052"], ["Maria Shulleeta", "maria shulleeta"], ["questions and answers", "Questions and Answers"], ["110-120 f", "110-120 F"], ["78.2%", "78.2"], ["8,899,947"], ["CASED, REDR BUR FOR BEST 327391"], ["Fred L. Smith, Jr.", "Fred L Smith jr."], ["NNK", "NNK or 4-(methylnitrosoamino)-1-(3-pyridyl)-1-butanone", "4-(methylnitrosoamino)-1-(3-pyridyl)-1-butanone"], ["0.57%"], ["DESCRIPTION", "Description"], ["Sehore"], ["WelcomHotel", "WelComHotel"], ["$975.00", "975.00"], ["82.85", "82.85%", "(82.85%)"], ["22"], ["50"], ["82", "82%"], ["GENERAL FOOD FUND, INC"], ["103"], ["Steering Committee Meeting", "Steering committee Meeting"], ["10:00 - 11:30 AM", "10:00 - 11:30 AM"], ["mint-o"], ["Sunfeast"], ["19,000"], ["25.9"], ["charles d. nesbit", "Charles D. Nesbit"], ["english, french and spanish", "English, French and Spanish"], ["University of Maine"], ["CAPRI"], ["administration", "Administration"], ["Consumer Dynamics GPC", "Consumer Dynamics"], ["14-3006-14"], ["4-(methylnitrosoamino)-1-(3-pyridyl)-1-butanone", "tobacco-specific nitrosamine"], ["c", "C", "consumed by control [c]", "Control [C]", "Control"], ["may 2, 1978", "May 2, 1978."], ["Madhya Pradesh"], ["WelcomHeritage"], ["TRRF Vice President", "lee a. waller"], ["20.77", "20.77%", "(20.77%)"], ["10,000"], ["Essenza Di Wills, Fiama Di Wills, Vivel and Superia"], ["Emotional Enhancement"], ["seven", "7"], ["PLATTE COUNTY VOLUNTEERS AGAINST HUNGER", "Platte county volunteers against hunger"], ["Volunteers Against Hunger Steering Committee", "Volunteers against Hunger Steering committee"], ["609/924-6648"], ["candyman", "Candyman"], ["Snacky"], ["1971"], ["18 million", "18 million order", "the 18 million order"], ["the organizing committee", "Organizing committee", "The organizing committee"], ["questions and answers", "Questions and Answers"], ["Forest Products Laboratory", "Forest Products Laboratory in Madison", "Forest Products Laboratory in Madison, Wisconsin"], ["August 31, 1963"], ["$ 3,038,444", "3,038,444"], ["89", "(89)"], ["Fred L. Smith, Jr.", "Fred L Smith .jr"], ["The levels ranged from 0.05 - 0.23 ppm", "0.05 - 0.23 ppm.", "0.05 - 0.23 ppm"], ["93-51954"], ["51092 5213"], ["vanderbilt university", "VANDERBILT UNIVERSITY"], ["Dec-08"], ["2"], ["17.15%", "17.15", "(17.15%)"], ["24,26,435"], ["Classmate and Paperkraft"], ["29"], ["40"], ["29.9"], ["Bert Shulimson", "Bert Shulimson , Executive Secretary"], ["January 18, 2005"], ["Aashirvaad"], ["Dream Cream", "Dream cream"], ["34,500"], ["Philip Morris Super Lights", "philip morris super lights"], ["international union of nutritional sciences", "International union of nutritional sciences"], ["mexico city", "Mexico city", "in mexico city"], ["proprietary cellulose acetate web", "their proprietary cellulose acetate web"], ["31", "( 31)"], ["KOOL KS", "Kool KS"], ["2.5", "2.5%"], ["BURKE", "Burke"], ["Hongkong", "HongKong"], ["1994", "October 1994"], ["hormone replacement therapy"], ["march 22, 1921", "March 22, 1921"], ["ITC-Welcomgroup"], ["2"], ["A. C. Monk"], ["70", "70%"], ["Wills Lifestyle and John Players"], ["Scissors Menthol Fresh", "Menthol Fresh"], ["30"], ["1,423"], ["Holiday Inn Downtown , Jefferson City , Missouri", "Holiday Inn Downtown, Jefferson City, Missouri", "Holiday Inn Downtown"], ["mint-o"], ["ITC Limited"], ["Carol A. Tozzi, Ph.D.", "Carol A. Tozzi"], ["stock keeping units", "Stock keeping units"], ["690"], ["september 3 to 9, 1972", "September 3 to 9, 1972.", "from September 3 to 9, 1972", "September 3 to 9, 1972"], ["charles d. nesbit", "Charles D. Nesbit", "Charles D. Nesbit, IARW Chairman"], ["research department", "Research Department"], ["$ 7,265,516", "7,265,516"], ["KOOL KS", "kool ks"], ["USMM 1/95-6/95, 12-Month Data", "USMM 1/95-6/95, 12 Month Data"], ["Sidestream Smoke Chamber"], ["240.00"], ["c", "C", "consumed by control [c]", "Control [C]", "Control"], ["For all our tomorrows", "For All Our Tomorrows"], ["1.0%"], ["10.3%"], ["6"], ["31"], ["14,000"], ["Mangaldeep"], ["February 24", "February 24 1966", "February 24 .1966"], ["5"], ["33,600"], ["candyman", "Candyman"], ["1979"], ["Sunfeast Yippee!"], ["July 26, 2000"], ["PROJECT ASSIGNMENT FORM"], ["INTER-OFFICE CORRESPONDENCE", "Inter-office correspondence"], ["charles d. nesbit", "Charles D. Nesbit", "Charles D. Nesbit, IARW Chairman"], ["february 7, 1994", "February 7, 1994"], ["research service department", "Research Service Department"], ["METH DEV"], ["1R4F REFERENCE RESULTS", "1R4F reference"], ["12427"], ["University of Maine"], ["2"], ["11/8/2001"], ["Sustainability updates", "Sustainability Updates"], ["83.4%"], ["CMRO"], ["6"], ["ITC Limited"], ["57", "57%"], ["Aim"], ["64", "64%"], ["33.0"], ["Dr. Joseph C. Hwang"], ["independent ice and cold storage co.", "Independent Ice and Cold Storage Co."], ["723"], ["mint-o Ultra mintz", "mint-o Ultra Mintz"], ["essenza di wills", "Essenza Di Wills"], ["John A. SMith, Ph.D.", "John A. Smith, Ph.D"], ["Hartsville , TN", "Hartsville, TN", "Hartsville , TN 37074"], ["international congress of nutrition", "International Congress of Nutrition", "ix international congress of nutrition"], ["approved"], ["USMM 1/95-6/95, 12-Month Data"], ["TVB"], ["AVERAGE 1R4F RESPONSES PER S9 LOT STRAIN TA100"], ["12"], ["12"], ["62272"], ["Nicotine RSM Study"], ["Mangaldeep"], ["public schools of ponca city, oklahoma", "Public schools of Ponca city, Oklahoma"], ["N. Anand"], ["3"], ["bengaluru", "Bengaluru", "in Bengaluru"], ["The Environment"], ["Responsible Luxury", "\"Responsible Luxury\""], ["Wendell Rodricks Now At Wills Lifestyle"], ["37.0"], ["Dr. Arley T. Bever"], ["Menopausal Health Publication Management"], ["candyman", "Candyman"], ["Fiama Di Wills"], ["essenza di wills", "Essenza Di Wills"], ["vivel", "Vivel"], ["21.0"], ["mexican government", "Mexican government", "the mexican government", "Mexican"], ["60-1120"], ["KOOLS"], ["1.0", "1"], ["MT-778"], ["Citrate"], ["1", "figure 1"], ["KOOL 100"], ["MAJOR STRATEGIC RESEARCH PROGRAMS", "MAJOR STRATEGIC"], ["december 1958", "December 1958"], ["6.1%"], ["1952"]], "generated_texts_unique": ["1128 SIXTEENTH ST., N. W., WASHINGTON, D. C. 20036", "As competitor's joined the price war, Taco Bell's strong consumer base decreased", "2", "2013", "$485", "16", "ITC Limited", "4", "20 years", "Projects", "Sunfeast", "34", "215-741-4052", "Maria Shulleeta", "Questions and Answers", "110-120 F", "78.2%", "$ 7,265,516", "cased, redr bur for best 327391", "red L. Smith, Jr", "NNK or 4-(methylnitrosoamino)-1-(3-pyridyl)-1-butanone", "0.57%", "Nicotine RSM Study", "Sehore", "Fortune", "$ 975.00", "(82.85%)", "22", "50", "82", "General Foods Fund, Inc", "103", "Steering Committee Meeting", "10:00 - 11:30 AM", "CANDYMAN", "Sunfeast", "19,000", "25.9", "Charles D. Nesbit", "English, French and Spanish", "At the University of Maine", "CAPRI", "Administration", "Consumer Dynamics GPC", "14-3006-14", "NNK or 4-(methylnitrosoamino)-1-(3-pyridyl)-1-butanone is a tobacco-specific nitrosamine which is formed during the curing and smoking of tobacco. Formation during curing occurs through nitros", "C", "may 2, 1978", "Sehore", "WelcomHeritage", "Lee A. Waller", "20.77%", "3,58,000", "Kitchens of India, Wills, Vivel and Superia", "Emotional Enhancement", "SEVEN", "PLATTE COUNTY VOLUNTEERS AGAINST HUNGER", "Volunteers Against Hunger Steering Committee", "609/924-6648", "CANDYMAN", "Delishus", "1971", "18 million order", "The Organizing Committee", "Questions and Answers", "a Forest Products Laboratory in Madison, Wisconsin", "August 31", "$ 3,038,444", "89", "red L. Smith, Jr", "45%", "93-51954", "5621", "Vanderbilt University", "18%", "2", "(17.15%)", "24,26,435", "Wills and Fiama Di Wills", "29", "40", "29.9", "Bert Shulimson, Executive Secretary", "January 18, 2005", "AASHIRVA AD", "Delishus", "34,500", "Philip Morris Super Lights Menthol", "International Union of Nutritional Sciences", "Mexico City", "their proprietary cellulose acetate web has been requested and will be sent", "31", "KOOL KS", "2.5%", "BURKE", "Hongkong", "1994", "Hormone Replacement Therapy", "March 22, 1921", "ITC", "2", "A. C. Monk", "70", "Wills and Mangaldeep", "Scissors Menthol Fresh", "30", "1,423", "Holiday Inn Downtown, Jefferson City, Missouri", "BINGO!", "AASHIRVA AD", "Carol A. Tozzi, Ph.D", "Stock Keeping Units", "690", "September 3 to 9, 1972", "Charles D. Nesbit, IARW Chairman", "Research Department", "$7,265,516", "KOOL KS", "1/95-6/95, 12-Month Data", "sidestream smoke chamber", "240,00", "C", "For All Our Tomorrows", "1.0%", "10.3%", "6", "31", "14,000", "ITC Hotels", "february 24, 1966", "5", "33,600", "BINGO!", "1979", "AASHIRVA AD", "July 26, 2000", "project assignment form", "INTER-OFFICE CORRESPONDENCE", "Charles D. Nesbit, IARW Chairman", "February 7, 1994", "Research Service Department", "METH DEV", "1R4F", "12427", "at the University of Maine", "2", "11/8/2001", "Sustainability Updates", "83.4%", "CMRO", "6", "ITC Limited", "57", "Essenza Di Wills, Fiama Di Wills, Vivel and Superia", "64", "33.0", "Dr. Joseph C. Hwang", "Independent Ice and Cold Storage Co", "723", "India's most premium, sugarfree power mints packed in a stylish black case and Candyman Cr\u00e8me Lacto which is made with the goodness of milk and caramel with a rich, delicious cr\u00e8me filling", "ESSENZA DI WILLS", "John A. Smith, Ph.D", "Hartsville, TN", "international congress of nutrition", "APPROVED", "USMM 1/95-6/95, 12-Month Data", "TVB", "1R4F REFERENCE RESULTS", "12", "12", "62272", "Nicotine RSM Study", "Mangaleep", "Public Schools of Ponca City, Oklahoma", "N. Anand", "2", "In Bengaluru", "The Environment", "\"Responsible Luxury\"", "Wendell Rodricks joins leading Indian designers - Rohit Baal, Rajesh Pratap Singh, JJ Valaya, Saty Paul, Ranna Gill, Rohit Gandhi and Rahul Khanna to present a bouquet of their offerings in collaboration with Wills Lifestyle", "37.0", "Dr. Arlene T. Beaver", "Menopausal Health Publication Management", "CANDYMAN", "Fiama Di Wills", "Personal Care Products", "Vive", "21.0%", "Mexican Government", "60-1120", "KOOLS", "1.0", "MT-778", "99103A-12 Coresta)", "1", "KOOL 100", "Nicotine RSM Study", "December 1958", "6.1%", "1952"], "anls": 0.7706196321550997}
generation_config.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "bos_token_id": 1,
4
+ "eos_token_id": 2,
5
+ "pad_token_id": 32000,
6
+ "transformers_version": "4.43.3"
7
+ }
image_embedding_phi3_v.py ADDED
@@ -0,0 +1,322 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # coding=utf-8
2
+ # Copyright 2024 Microsoft and the HuggingFace Inc. team. All rights reserved.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+ import torch
17
+ from torch import nn
18
+ from transformers import CLIPVisionConfig, CLIPVisionModel, PretrainedConfig
19
+ from transformers.models.clip.modeling_clip import CLIPAttention
20
+ from transformers.utils import logging
21
+
22
+ try:
23
+ from flash_attn import flash_attn_func
24
+ except ImportError:
25
+ pass
26
+
27
+ logger = logging.get_logger(__name__)
28
+
29
+
30
+ MAX_INPUT_ID = int(1e9)
31
+
32
+ CLIP_VIT_LARGE_PATCH14_336_CONFIG = CLIPVisionConfig(
33
+ attention_dropout=0.0,
34
+ dropout=0.0,
35
+ hidden_act="quick_gelu",
36
+ hidden_size=1024,
37
+ image_size=336,
38
+ initializer_factor=1.0,
39
+ initializer_range=0.02,
40
+ intermediate_size=4096,
41
+ layer_norm_eps=1e-05,
42
+ num_attention_heads=16,
43
+ num_channels=3,
44
+ num_hidden_layers=24,
45
+ patch_size=14,
46
+ projection_dim=768
47
+ )
48
+
49
+ class CLIPAttentionFA2(CLIPAttention):
50
+ """Add flash attention 2 to CLIPAttention. (This is only used in the vision encoder)"""
51
+
52
+ def forward(self,
53
+ hidden_states,
54
+ attention_mask=None,
55
+ causal_attention_mask=None,
56
+ output_attentions=False,
57
+ ):
58
+ """Input shape: Batch x Time x Channel"""
59
+
60
+ assert attention_mask is None, "CLIPAttentionFA2 does not support attention_mask"
61
+ assert causal_attention_mask is None, "CLIPAttentionFA2 does not support causal_attention_mask"
62
+ assert output_attentions is False, "CLIPAttentionFA2 does not support output_attentions"
63
+
64
+ bsz, tgt_len, embed_dim = hidden_states.size()
65
+ query_states = self.q_proj(hidden_states).reshape(bsz, tgt_len, self.num_heads, self.head_dim)
66
+ key_states = self.k_proj(hidden_states).reshape(bsz, tgt_len, self.num_heads, self.head_dim)
67
+ value_states = self.v_proj(hidden_states).reshape(bsz, tgt_len, self.num_heads, self.head_dim)
68
+
69
+ attn_output = flash_attn_func(
70
+ query_states,
71
+ key_states,
72
+ value_states,
73
+ dropout_p=self.dropout if self.training else 0.0,
74
+ softmax_scale=self.scale,
75
+ causal=False,
76
+ ).reshape(bsz, tgt_len, embed_dim)
77
+
78
+ attn_output = self.out_proj(attn_output)
79
+ return attn_output, None
80
+
81
+
82
+ class Phi3ImageEmbedding(nn.Module):
83
+ """Phi3 Image embedding."""
84
+
85
+ def __init__(self, config: PretrainedConfig, wte=None, **kwargs) -> None:
86
+ super().__init__()
87
+
88
+ # n_embed or hidden_size
89
+ hidden_size = config.n_embd if hasattr(config, 'n_embd') else config.hidden_size
90
+ if hasattr(config, 'embd_pdrop') or hasattr(config, 'embed_pdrop'):
91
+ embd_drop = config.embd_pdrop if hasattr(config, 'embd_pdrop') else config.embed_pdrop
92
+ self.drop = nn.Dropout(embd_drop)
93
+ else:
94
+ self.drop = None
95
+
96
+ self.wte = wte
97
+
98
+ if isinstance(config.img_processor, dict) and config.img_processor.get('name', None) == 'clip_vision_model':
99
+ assert 'model_name' in config.img_processor, 'model_name must be provided for CLIPVisionModel'
100
+ assert 'image_dim_out' in config.img_processor, 'image_dim_out must be provided for CLIPVisionModel'
101
+ assert 'num_img_tokens' in config.img_processor, 'num_img_tokens must be provided for CLIPVisionModel'
102
+ assert config.img_processor['model_name'] == 'openai/clip-vit-large-patch14-336'
103
+ clip_config = CLIP_VIT_LARGE_PATCH14_336_CONFIG
104
+ self.img_processor = CLIPVisionModel(clip_config)
105
+ image_dim_out = config.img_processor['image_dim_out']
106
+ self.num_img_tokens = config.img_processor['num_img_tokens']
107
+
108
+ # FA2 in CLIP
109
+ if config._attn_implementation == 'flash_attention_2':
110
+ for layer in self.img_processor.vision_model.encoder.layers:
111
+ clip_fa2 = CLIPAttentionFA2(clip_config)
112
+ del layer.self_attn
113
+ layer.self_attn = clip_fa2
114
+ else:
115
+ raise NotImplementedError(f'img_processor = {config.img_processor}, not implemented')
116
+
117
+ self.image_dim_out = image_dim_out
118
+ self.img_sizes = None
119
+
120
+ # global_gn and sub_gn for hd transform, serves as line separator
121
+ self.use_hd_transform = kwargs.get('use_hd_transform', False)
122
+ self.with_learnable_separator = kwargs.get('with_learnable_separator', False)
123
+ self.hd_transform_order = kwargs.get('hd_transform_order', 'glb_sub')
124
+ # with_hd_transform and with_learnable_separator should have same value
125
+ assert self.use_hd_transform == self.with_learnable_separator, 'use_hd_transform and with_learnable_separator should have same value'
126
+ if self.with_learnable_separator:
127
+ assert self.use_hd_transform, 'learnable separator is only for hd transform'
128
+ # 1024 * 4, merge spatial to channel dimension
129
+ self.glb_GN = nn.Parameter(torch.zeros([1, 1, self.image_dim_out * 4]))
130
+ self.sub_GN = nn.Parameter(torch.zeros([1, 1, 1, self.image_dim_out * 4]))
131
+ logger.info(f'learnable separator enabled for hd transform, hd_transform_order = {self.hd_transform_order}')
132
+
133
+ projection_cls = kwargs.get('projection_cls', 'linear')
134
+ if projection_cls == 'linear':
135
+ self.img_projection = nn.Linear(image_dim_out, hidden_size)
136
+ elif projection_cls == 'mlp' and self.use_hd_transform:
137
+ dim_projection = hidden_size
138
+ depth = 2
139
+ layers = [nn.Linear(image_dim_out * 4, dim_projection)]
140
+ for _ in range(1, depth):
141
+ layers.extend([nn.GELU(),
142
+ nn.Linear(dim_projection, dim_projection)])
143
+ self.img_projection = nn.Sequential(*layers)
144
+ elif projection_cls == 'mlp':
145
+ dim_projection = hidden_size
146
+ depth = 2
147
+ layers = [nn.Linear(image_dim_out, dim_projection)]
148
+ for _ in range(1, depth):
149
+ layers.extend([nn.GELU(),
150
+ nn.Linear(dim_projection, dim_projection)])
151
+ self.img_projection = nn.Sequential(*layers)
152
+ else:
153
+ raise NotImplementedError(f'projection_cls = {projection_cls}, not implemented')
154
+
155
+ self.vocab_size = config.vocab_size
156
+ self.img_features = None
157
+
158
+ if isinstance(config.img_processor, dict):
159
+ self.layer_idx = config.img_processor.get('layer_idx', -2)
160
+ self.type_feature = config.img_processor.get('type_feature', 'patch')
161
+ else:
162
+ self.layer_idx = -2
163
+ self.type_feature = 'patch'
164
+
165
+
166
+ def set_img_features(self, img_features: torch.FloatTensor) -> None:
167
+ self.img_features = img_features
168
+
169
+ def set_img_sizes(self, img_sizes: torch.LongTensor) -> None:
170
+ self.img_sizes = img_sizes
171
+
172
+ def get_img_features(self, img_embeds: torch.FloatTensor) -> torch.FloatTensor:
173
+ LAYER_IDX = self.layer_idx
174
+ TYPE_FEATURE = self.type_feature
175
+
176
+ img_processor_output = self.img_processor(img_embeds, output_hidden_states=True)
177
+ img_feature = img_processor_output.hidden_states[LAYER_IDX]
178
+
179
+ if TYPE_FEATURE == "patch":
180
+ patch_feature = img_feature[:, 1:]
181
+ return patch_feature
182
+
183
+ raise NotImplementedError
184
+
185
+ def forward(
186
+ self, input_ids: torch.LongTensor, pixel_values: torch.FloatTensor, image_sizes=None
187
+ ) -> torch.FloatTensor:
188
+ input_shape = input_ids.size()
189
+ input_ids = input_ids.view(-1, input_shape[-1])
190
+
191
+ # positions for image tokens
192
+ positions = torch.nonzero((input_ids < 0) & (input_ids > -MAX_INPUT_ID), as_tuple=True)
193
+ has_image = len(positions[0].tolist()) > 0
194
+ input_ids = input_ids.clamp_min(0).clamp_max(self.vocab_size).detach()
195
+ hidden_states = self.wte(input_ids)
196
+
197
+ if has_image:
198
+ assert self.use_hd_transform
199
+ num_images, num_crops, c, h, w = pixel_values.shape
200
+ assert c == 3 and h == w == 336
201
+ img_features = self.get_img_features(pixel_values.flatten(0, 1)).reshape(
202
+ num_images, num_crops, -1, self.image_dim_out
203
+ )
204
+ image_features_proj = self.hd_feature_transform(img_features, image_sizes)
205
+ hidden_states = hidden_states.index_put(
206
+ positions, image_features_proj, accumulate=False
207
+ )
208
+
209
+ if self.drop is not None:
210
+ hidden_states = self.drop(hidden_states)
211
+
212
+ return hidden_states
213
+
214
+ def hd_feature_transform(self, image_features, image_sizes):
215
+ """
216
+ image_features: (num_images, num_crops+1, 24*24, 1024)
217
+ """
218
+ assert (
219
+ self.hd_transform_order == 'sub_glb'
220
+ ), f'hd_transform_order `{self.hd_transform_order}` not implemented'
221
+ if isinstance(self.img_projection, nn.Sequential):
222
+ target_device = self.img_projection[0].bias.device
223
+ target_dtype = self.img_projection[0].bias.dtype
224
+ else: # It's a single nn.Linear layer
225
+ target_device = self.img_projection.bias.device
226
+ target_dtype = self.img_projection.bias.dtype
227
+
228
+ global_image_features = image_features[:, 0] # (num_images, 24*24, 1024)
229
+ # global feature can be viewed as a special HD case with num_crops 1x1
230
+ global_image_features_hd = self.reshape_hd_patches_2x2merge(global_image_features, 1, 1)
231
+ global_image_features_hd_newline = self.add_image_newline(global_image_features_hd)
232
+
233
+ all_image_embeddings = []
234
+ # need a for loop to process each image because of different image sizes
235
+ # (patch arrangement is different for each image)
236
+ for i, img_size in enumerate(image_sizes):
237
+ h, w = img_size
238
+ h_crop = h // 336
239
+ w_crop = w // 336
240
+ num_crops = h_crop * w_crop
241
+
242
+ # NOTE: real num_crops is padded
243
+ # (num_crops, 24*24, 1024)
244
+ sub_image_features = image_features[i, 1 : 1 + num_crops]
245
+ sub_image_features_hd = self.reshape_hd_patches_2x2merge(
246
+ sub_image_features, h_crop, w_crop
247
+ )
248
+ sub_image_features_hd_newline = self.add_image_newline(sub_image_features_hd)
249
+
250
+ # [sub features, separator, global features]
251
+ all_image_embeddings.extend(
252
+ [
253
+ sub_image_features_hd_newline.squeeze(0), # (h_crop*12*(w_crop*12+1), 4096)
254
+ self.glb_GN.squeeze(0),
255
+ global_image_features_hd_newline[i],
256
+ ]
257
+ )
258
+
259
+ image_features_proj = self.img_projection(
260
+ torch.cat(all_image_embeddings, dim=0).to(target_device).to(target_dtype)
261
+ )
262
+
263
+ return image_features_proj
264
+
265
+ def reshape_hd_patches_2x2merge(self, image_features, h_crop, w_crop):
266
+ """
267
+ image_features: (num_images*num_crops, 24*24, 1024)
268
+ output: (num_images, h_crop*12, w_crop*12, 4096), h_crop*w_crop == num_crops
269
+ """
270
+ N, L, C = image_features.shape
271
+ assert L == 24 * 24 and C == 1024 and N % (h_crop * w_crop) == 0
272
+ num_images = N // (h_crop * w_crop)
273
+ H = int(L**0.5)
274
+ image_features_hd = (
275
+ image_features.reshape(N, H, H, C) # N, 24, 24, 1024
276
+ .reshape(N, H // 2, 2, H // 2, 2, C) # N, 12, 2, 12, 2, 1024
277
+ .permute(0, 1, 3, 2, 4, 5) # N, 12, 12, 2, 2, 1024
278
+ .reshape(N, -1, 4 * C) # N, 144, 4096
279
+ .reshape(
280
+ num_images, h_crop, w_crop, H // 2, H // 2, -1
281
+ ) # n_img, h_crop, w_crop, 12, 12, 4096
282
+ .permute(0, 1, 3, 2, 4, 5) # n_img, h_crop, 12, w_crop, 12, 4096
283
+ .reshape(
284
+ num_images, h_crop * H // 2, w_crop * H // 2, 4 * C
285
+ ) # n_img, h_crop*12, w_crop*12, 4096
286
+ )
287
+
288
+ # alternative implementation using einops
289
+ # from einops import rearrange
290
+ # image_features_nhwc = rearrange(
291
+ # image_features,
292
+ # 'N (H W) c -> N H W c',
293
+ # H=H,
294
+ # W=H,
295
+ # )
296
+ # image_features_2x2merge = rearrange(
297
+ # image_features_nhwc,
298
+ # 'N (h h_pool) (w w_pool) c -> N h w (h_pool w_pool c)',
299
+ # h_pool=2,
300
+ # w_pool=2,
301
+ # )
302
+ # image_features_hd = rearrange(
303
+ # image_features_2x2merge,
304
+ # '(n_img h_crop w_crop) h w C -> n_img (h_crop h) (w_crop w) C',
305
+ # h_crop=h_crop,
306
+ # w_crop=w_crop,
307
+ # )
308
+
309
+ return image_features_hd
310
+
311
+ def add_image_newline(self, image_features_hd):
312
+ """
313
+ image_features_hd: (num_images, h_crop*12, w_crop*12, 4096)
314
+ output: (num_images, (h_crop*12) * (w_crop*12+1), 4096)
315
+ """
316
+ num_images, h, w, hid_dim = image_features_hd.shape
317
+ # add the newline token to the HD image feature patches
318
+ newline_embeddings = self.sub_GN.expand(num_images, h, -1, -1) # (n_img, h, 1, hid_dim)
319
+ image_features_hd_newline = torch.cat(
320
+ [image_features_hd, newline_embeddings], dim=2
321
+ ).reshape(num_images, -1, hid_dim)
322
+ return image_features_hd_newline
image_processing_phi3_v.py ADDED
@@ -0,0 +1,274 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # coding=utf-8
2
+ # Copyright 2024 Microsoft and the HuggingFace Inc. team. All rights reserved.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+ """Image processor class for Phi3-V."""
17
+
18
+ from typing import List, Optional, Union
19
+
20
+ import numpy as np
21
+
22
+ from transformers.image_processing_utils import BaseImageProcessor, BatchFeature
23
+ from transformers.image_transforms import (
24
+ convert_to_rgb,
25
+ )
26
+ from transformers.image_utils import (
27
+ OPENAI_CLIP_MEAN,
28
+ OPENAI_CLIP_STD,
29
+ ImageInput,
30
+ make_list_of_images,
31
+ valid_images,
32
+ )
33
+ from transformers.utils import TensorType, is_vision_available, logging
34
+
35
+ from transformers import AutoImageProcessor
36
+
37
+ logger = logging.get_logger(__name__)
38
+
39
+
40
+ if is_vision_available():
41
+ from PIL import Image
42
+
43
+ import torch
44
+ import torchvision
45
+
46
+ def padding_336(b):
47
+ width, height = b.size
48
+ tar = int(np.ceil(height / 336) * 336)
49
+ top_padding = int((tar - height)/2)
50
+ bottom_padding = tar - height - top_padding
51
+ left_padding = 0
52
+ right_padding = 0
53
+ b = torchvision.transforms.functional.pad(b, [left_padding, top_padding, right_padding, bottom_padding], fill=[255,255,255])
54
+
55
+ return b
56
+
57
+ def calc_padded_size(width, height, padding_unit=336):
58
+ target_height = int(np.ceil(height / padding_unit) * padding_unit)
59
+ top_padding = int((target_height - height) / 2)
60
+ bottom_padding = target_height - height - top_padding
61
+ left_padding = 0
62
+ right_padding = 0
63
+ padded_width = width + left_padding + right_padding
64
+ padded_height = height + top_padding + bottom_padding
65
+ return padded_width, padded_height
66
+
67
+ def HD_transform(img, hd_num=16):
68
+ width, height = img.size
69
+ trans = False
70
+ if width < height:
71
+ img = img.transpose(Image.TRANSPOSE)
72
+ trans = True
73
+ width, height = img.size
74
+ ratio = (width/ height)
75
+ scale = 1
76
+ while scale*np.ceil(scale/ratio) <= hd_num:
77
+ scale += 1
78
+ scale -= 1
79
+ new_w = int(scale * 336)
80
+ new_h = int(new_w / ratio)
81
+
82
+ img = torchvision.transforms.functional.resize(img, [new_h, new_w],)
83
+ img = padding_336(img)
84
+ width, height = img.size
85
+ if trans:
86
+ img = img.transpose(Image.TRANSPOSE)
87
+
88
+ return img
89
+
90
+ def calc_hd_transform_size(width, height, hd_num=16):
91
+ transposed = False
92
+ if width < height:
93
+ width, height = height, width
94
+ transposed = True
95
+
96
+ ratio = width / height
97
+ scale = 1
98
+ while scale * np.ceil(scale / ratio) <= hd_num:
99
+ scale += 1
100
+ scale -= 1
101
+
102
+ new_width = int(scale * 336)
103
+ new_height = int(new_width / ratio)
104
+
105
+ padded_width, padded_height = calc_padded_size(new_width, new_height)
106
+
107
+ if transposed:
108
+ padded_width, padded_height = padded_height, padded_width
109
+
110
+ return padded_width, padded_height
111
+
112
+ def pad_to_max_num_crops_tensor(images, max_crops=5):
113
+ """
114
+ images: B x 3 x H x W, B<=max_crops
115
+ """
116
+ B, _, H, W = images.shape
117
+ if B < max_crops:
118
+ pad = torch.zeros(max_crops - B, 3, H, W, dtype=images.dtype, device=images.device)
119
+ images = torch.cat([images, pad], dim=0)
120
+ return images
121
+
122
+
123
+ class Phi3VImageProcessor(BaseImageProcessor):
124
+ r"""
125
+ Constructs a Phi3 image processor. Based on [`CLIPImageProcessor`] with incorporation of additional techniques
126
+ for processing high resolution images as explained in the [InternLM-XComposer2-4KHD](https://arxiv.org/pdf/2404.06512)
127
+
128
+ Args:
129
+ image_mean (`float` or `List[float]`, *optional*, defaults to `[0.48145466, 0.4578275, 0.40821073]`):
130
+ Mean to use if normalizing the image. This is a float or list of floats the length of the number of
131
+ channels in the image. Can be overridden by the `image_mean` parameter in the `preprocess` method.
132
+ image_std (`float` or `List[float]`, *optional*, defaults to `[0.26862954, 0.26130258, 0.27577711]`):
133
+ Standard deviation to use if normalizing the image. This is a float or list of floats the length of the
134
+ number of channels in the image. Can be overridden by the `image_std` parameter in the `preprocess` method.
135
+ Can be overridden by the `image_std` parameter in the `preprocess` method.
136
+ do_convert_rgb (`bool`, *optional*, defaults to `True`):
137
+ Whether to convert the image to RGB.
138
+ """
139
+
140
+ model_input_names = ["pixel_values"]
141
+
142
+ def __init__(
143
+ self,
144
+ num_crops: int = 1,
145
+ image_mean: Optional[Union[float, List[float]]] = None,
146
+ image_std: Optional[Union[float, List[float]]] = None,
147
+ do_convert_rgb: bool = True,
148
+ **kwargs,
149
+ ) -> None:
150
+ super().__init__(**kwargs)
151
+ self.num_crops = num_crops
152
+ self.image_mean = image_mean if image_mean is not None else OPENAI_CLIP_MEAN
153
+ self.image_std = image_std if image_std is not None else OPENAI_CLIP_STD
154
+ self.do_convert_rgb = do_convert_rgb
155
+
156
+ def calc_num_image_tokens(
157
+ self,
158
+ images: ImageInput
159
+ ):
160
+ """ Calculate the number of image tokens for each image.
161
+ Args:
162
+ images (`ImageInput`):
163
+ Image to preprocess. Expects a single or batch of images with pixel values ranging from 0 to 255. If
164
+ passing in images with pixel values between 0 and 1, set `do_rescale=False`.
165
+ """
166
+ images = make_list_of_images(images)
167
+
168
+ if not valid_images(images):
169
+ raise ValueError(
170
+ "Invalid image type. Must be of type PIL.Image.Image, numpy.ndarray, "
171
+ "torch.Tensor, tf.Tensor or jax.ndarray."
172
+ )
173
+
174
+ images = [image.convert('RGB') for image in images]
175
+ # (H, W, C)
176
+ elems = [HD_transform(im, hd_num = self.num_crops) for im in images]
177
+ shapes = [[im.size[1], im.size[0]] for im in elems]
178
+ num_img_tokens = [int((h//336*w//336+1)*144 + 1 + (h//336+1)*12) for h, w in shapes]
179
+ return num_img_tokens
180
+
181
+ def calc_num_image_tokens_from_image_size(self, width, height):
182
+ """
183
+ Calculate the number of image tokens for a given image size.
184
+ Args:
185
+ width (`int`): Width of the image.
186
+ height (`int`): Height of the image.
187
+ """
188
+ new_width, new_height = calc_hd_transform_size(width, height, hd_num=self.num_crops)
189
+ num_img_tokens = int((new_height // 336 * new_width // 336 + 1) * 144 + 1 + (new_height // 336 + 1) * 12)
190
+ return num_img_tokens
191
+
192
+ def preprocess(
193
+ self,
194
+ images: ImageInput,
195
+ image_mean: Optional[Union[float, List[float]]] = None,
196
+ image_std: Optional[Union[float, List[float]]] = None,
197
+ do_convert_rgb: bool = None,
198
+ return_tensors: Optional[Union[str, TensorType]] = None,
199
+ ):
200
+ """
201
+ Args:
202
+ images (`ImageInput`):
203
+ Image to preprocess. Expects a single or batch of images with pixel values ranging from 0 to 255. If
204
+ passing in images with pixel values between 0 and 1, set `do_rescale=False`.
205
+ image_mean (`float` or `List[float]`, *optional*, defaults to `self.image_mean`):
206
+ Image mean to use for normalization. Only has an effect if `do_normalize` is set to `True`.
207
+ image_std (`float` or `List[float]`, *optional*, defaults to `self.image_std`):
208
+ Image standard deviation to use for normalization. Only has an effect if `do_normalize` is set to
209
+ `True`.
210
+ do_convert_rgb (`bool`, *optional*, defaults to `self.do_convert_rgb`):
211
+ Whether to convert the image to RGB.
212
+ return_tensors (`str` or `TensorType`, *optional*):
213
+ The type of tensors to return. Can be one of:
214
+ - Unset: Return a list of `np.ndarray`.
215
+ - `TensorType.TENSORFLOW` or `'tf'`: Return a batch of type `tf.Tensor`.
216
+ - `TensorType.PYTORCH` or `'pt'`: Return a batch of type `torch.Tensor`.
217
+ - `TensorType.NUMPY` or `'np'`: Return a batch of type `np.ndarray`.
218
+ - `TensorType.JAX` or `'jax'`: Return a batch of type `jax.numpy.ndarray`.
219
+ """
220
+ image_mean = image_mean if image_mean is not None else self.image_mean
221
+ image_std = image_std if image_std is not None else self.image_std
222
+ do_convert_rgb = do_convert_rgb if do_convert_rgb is not None else self.do_convert_rgb
223
+
224
+ images = make_list_of_images(images)
225
+
226
+ if not valid_images(images):
227
+ raise ValueError(
228
+ "Invalid image type. Must be of type PIL.Image.Image, numpy.ndarray, "
229
+ "torch.Tensor, tf.Tensor or jax.ndarray."
230
+ )
231
+
232
+ if do_convert_rgb:
233
+ images = [convert_to_rgb(image) for image in images]
234
+
235
+ image_sizes = []
236
+ img_processor = torchvision.transforms.Compose([
237
+ torchvision.transforms.ToTensor(),
238
+ torchvision.transforms.Normalize(image_mean, image_std)
239
+ ])
240
+
241
+ # PIL images
242
+ # HD_transform pad images to size of multiiply of 336, 336
243
+ # convert to RGB first
244
+ images = [image.convert('RGB') for image in images]
245
+ elems = [HD_transform(im, hd_num = self.num_crops) for im in images]
246
+ # tensor transform and normalize
247
+ hd_images = [img_processor(im) for im in elems]
248
+ # create global image
249
+ global_image = [torch.nn.functional.interpolate(im.unsqueeze(0).float(), size=(336, 336), mode='bicubic',).to(im.dtype) for im in hd_images]
250
+
251
+ # [(3, h, w)], where h, w is multiple of 336
252
+ shapes = [[im.size(1), im.size(2)] for im in hd_images]
253
+ num_img_tokens = [int(((h//336)*(w//336)+1)*144 + 1 + (h//336+1)*12) for h, w in shapes]
254
+ # reshape to channel dimension -> (num_images, num_crops, 3, 336, 336)
255
+ # (1, 3, h//336, 336, w//336, 336) -> (1, h//336, w//336, 3, 336, 336) -> (h//336*w//336, 3, 336, 336)
256
+ hd_images_reshape = [im.reshape(1, 3, h//336, 336, w//336, 336).permute(0,2,4,1,3,5).reshape(-1, 3, 336, 336).contiguous() for im, (h, w) in zip(hd_images, shapes)]
257
+ # concat global image and local image
258
+ hd_images_reshape = [torch.cat([_global_image] + [_im], dim=0) for _global_image, _im in zip(global_image, hd_images_reshape)]
259
+
260
+ # pad to max_num_crops
261
+ image_transformed = [pad_to_max_num_crops_tensor(im, self.num_crops+1) for im in hd_images_reshape]
262
+ image_transformed = torch.stack(image_transformed, dim=0)
263
+ image_sizes = [torch.LongTensor(_shapes) for _shapes in shapes]
264
+ padded_images = image_transformed
265
+ image_sizes = shapes
266
+
267
+ data = {"pixel_values": padded_images,
268
+ "image_sizes": image_sizes,
269
+ "num_img_tokens": num_img_tokens
270
+ }
271
+
272
+ return BatchFeature(data=data, tensor_type=return_tensors)
273
+
274
+ AutoImageProcessor.register("Phi3VImageProcessor", Phi3VImageProcessor)
model-00001-of-00002.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ba1628b4c9603f72d492d34047a878c79bc5b4994b029e11329a7a1a6f127a1e
3
+ size 4971240752
model-00002-of-00002.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2b215514162d0c3dc4c3a3c0715d6793ac3e73fc839d2c05cebc08f9655902c3
3
+ size 3519090872
model.safetensors.index.json ADDED
@@ -0,0 +1,600 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "metadata": {
3
+ "total_size": 8490244096
4
+ },
5
+ "weight_map": {
6
+ "lm_head.weight": "model-00002-of-00002.safetensors",
7
+ "model.embed_tokens.weight": "model-00001-of-00002.safetensors",
8
+ "model.layers.0.input_layernorm.weight": "model-00001-of-00002.safetensors",
9
+ "model.layers.0.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
10
+ "model.layers.0.mlp.gate_up_proj.weight": "model-00001-of-00002.safetensors",
11
+ "model.layers.0.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
12
+ "model.layers.0.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
13
+ "model.layers.0.self_attn.qkv_proj.weight": "model-00001-of-00002.safetensors",
14
+ "model.layers.1.input_layernorm.weight": "model-00001-of-00002.safetensors",
15
+ "model.layers.1.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
16
+ "model.layers.1.mlp.gate_up_proj.weight": "model-00001-of-00002.safetensors",
17
+ "model.layers.1.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
18
+ "model.layers.1.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
19
+ "model.layers.1.self_attn.qkv_proj.weight": "model-00001-of-00002.safetensors",
20
+ "model.layers.10.input_layernorm.weight": "model-00001-of-00002.safetensors",
21
+ "model.layers.10.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
22
+ "model.layers.10.mlp.gate_up_proj.weight": "model-00001-of-00002.safetensors",
23
+ "model.layers.10.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
24
+ "model.layers.10.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
25
+ "model.layers.10.self_attn.qkv_proj.weight": "model-00001-of-00002.safetensors",
26
+ "model.layers.11.input_layernorm.weight": "model-00001-of-00002.safetensors",
27
+ "model.layers.11.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
28
+ "model.layers.11.mlp.gate_up_proj.weight": "model-00001-of-00002.safetensors",
29
+ "model.layers.11.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
30
+ "model.layers.11.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
31
+ "model.layers.11.self_attn.qkv_proj.weight": "model-00001-of-00002.safetensors",
32
+ "model.layers.12.input_layernorm.weight": "model-00001-of-00002.safetensors",
33
+ "model.layers.12.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
34
+ "model.layers.12.mlp.gate_up_proj.weight": "model-00001-of-00002.safetensors",
35
+ "model.layers.12.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
36
+ "model.layers.12.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
37
+ "model.layers.12.self_attn.qkv_proj.weight": "model-00001-of-00002.safetensors",
38
+ "model.layers.13.input_layernorm.weight": "model-00001-of-00002.safetensors",
39
+ "model.layers.13.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
40
+ "model.layers.13.mlp.gate_up_proj.weight": "model-00001-of-00002.safetensors",
41
+ "model.layers.13.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
42
+ "model.layers.13.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
43
+ "model.layers.13.self_attn.qkv_proj.weight": "model-00001-of-00002.safetensors",
44
+ "model.layers.14.input_layernorm.weight": "model-00001-of-00002.safetensors",
45
+ "model.layers.14.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
46
+ "model.layers.14.mlp.gate_up_proj.weight": "model-00001-of-00002.safetensors",
47
+ "model.layers.14.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
48
+ "model.layers.14.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
49
+ "model.layers.14.self_attn.qkv_proj.weight": "model-00001-of-00002.safetensors",
50
+ "model.layers.15.input_layernorm.weight": "model-00001-of-00002.safetensors",
51
+ "model.layers.15.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
52
+ "model.layers.15.mlp.gate_up_proj.weight": "model-00001-of-00002.safetensors",
53
+ "model.layers.15.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
54
+ "model.layers.15.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
55
+ "model.layers.15.self_attn.qkv_proj.weight": "model-00001-of-00002.safetensors",
56
+ "model.layers.16.input_layernorm.weight": "model-00001-of-00002.safetensors",
57
+ "model.layers.16.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
58
+ "model.layers.16.mlp.gate_up_proj.weight": "model-00001-of-00002.safetensors",
59
+ "model.layers.16.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
60
+ "model.layers.16.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
61
+ "model.layers.16.self_attn.qkv_proj.weight": "model-00001-of-00002.safetensors",
62
+ "model.layers.17.input_layernorm.weight": "model-00002-of-00002.safetensors",
63
+ "model.layers.17.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
64
+ "model.layers.17.mlp.gate_up_proj.weight": "model-00002-of-00002.safetensors",
65
+ "model.layers.17.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
66
+ "model.layers.17.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
67
+ "model.layers.17.self_attn.qkv_proj.weight": "model-00001-of-00002.safetensors",
68
+ "model.layers.18.input_layernorm.weight": "model-00002-of-00002.safetensors",
69
+ "model.layers.18.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
70
+ "model.layers.18.mlp.gate_up_proj.weight": "model-00002-of-00002.safetensors",
71
+ "model.layers.18.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
72
+ "model.layers.18.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
73
+ "model.layers.18.self_attn.qkv_proj.weight": "model-00002-of-00002.safetensors",
74
+ "model.layers.19.input_layernorm.weight": "model-00002-of-00002.safetensors",
75
+ "model.layers.19.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
76
+ "model.layers.19.mlp.gate_up_proj.weight": "model-00002-of-00002.safetensors",
77
+ "model.layers.19.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
78
+ "model.layers.19.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
79
+ "model.layers.19.self_attn.qkv_proj.weight": "model-00002-of-00002.safetensors",
80
+ "model.layers.2.input_layernorm.weight": "model-00001-of-00002.safetensors",
81
+ "model.layers.2.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
82
+ "model.layers.2.mlp.gate_up_proj.weight": "model-00001-of-00002.safetensors",
83
+ "model.layers.2.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
84
+ "model.layers.2.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
85
+ "model.layers.2.self_attn.qkv_proj.weight": "model-00001-of-00002.safetensors",
86
+ "model.layers.20.input_layernorm.weight": "model-00002-of-00002.safetensors",
87
+ "model.layers.20.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
88
+ "model.layers.20.mlp.gate_up_proj.weight": "model-00002-of-00002.safetensors",
89
+ "model.layers.20.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
90
+ "model.layers.20.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
91
+ "model.layers.20.self_attn.qkv_proj.weight": "model-00002-of-00002.safetensors",
92
+ "model.layers.21.input_layernorm.weight": "model-00002-of-00002.safetensors",
93
+ "model.layers.21.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
94
+ "model.layers.21.mlp.gate_up_proj.weight": "model-00002-of-00002.safetensors",
95
+ "model.layers.21.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
96
+ "model.layers.21.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
97
+ "model.layers.21.self_attn.qkv_proj.weight": "model-00002-of-00002.safetensors",
98
+ "model.layers.22.input_layernorm.weight": "model-00002-of-00002.safetensors",
99
+ "model.layers.22.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
100
+ "model.layers.22.mlp.gate_up_proj.weight": "model-00002-of-00002.safetensors",
101
+ "model.layers.22.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
102
+ "model.layers.22.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
103
+ "model.layers.22.self_attn.qkv_proj.weight": "model-00002-of-00002.safetensors",
104
+ "model.layers.23.input_layernorm.weight": "model-00002-of-00002.safetensors",
105
+ "model.layers.23.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
106
+ "model.layers.23.mlp.gate_up_proj.weight": "model-00002-of-00002.safetensors",
107
+ "model.layers.23.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
108
+ "model.layers.23.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
109
+ "model.layers.23.self_attn.qkv_proj.weight": "model-00002-of-00002.safetensors",
110
+ "model.layers.24.input_layernorm.weight": "model-00002-of-00002.safetensors",
111
+ "model.layers.24.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
112
+ "model.layers.24.mlp.gate_up_proj.weight": "model-00002-of-00002.safetensors",
113
+ "model.layers.24.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
114
+ "model.layers.24.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
115
+ "model.layers.24.self_attn.qkv_proj.weight": "model-00002-of-00002.safetensors",
116
+ "model.layers.25.input_layernorm.weight": "model-00002-of-00002.safetensors",
117
+ "model.layers.25.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
118
+ "model.layers.25.mlp.gate_up_proj.weight": "model-00002-of-00002.safetensors",
119
+ "model.layers.25.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
120
+ "model.layers.25.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
121
+ "model.layers.25.self_attn.qkv_proj.weight": "model-00002-of-00002.safetensors",
122
+ "model.layers.26.input_layernorm.weight": "model-00002-of-00002.safetensors",
123
+ "model.layers.26.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
124
+ "model.layers.26.mlp.gate_up_proj.weight": "model-00002-of-00002.safetensors",
125
+ "model.layers.26.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
126
+ "model.layers.26.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
127
+ "model.layers.26.self_attn.qkv_proj.weight": "model-00002-of-00002.safetensors",
128
+ "model.layers.27.input_layernorm.weight": "model-00002-of-00002.safetensors",
129
+ "model.layers.27.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
130
+ "model.layers.27.mlp.gate_up_proj.weight": "model-00002-of-00002.safetensors",
131
+ "model.layers.27.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
132
+ "model.layers.27.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
133
+ "model.layers.27.self_attn.qkv_proj.weight": "model-00002-of-00002.safetensors",
134
+ "model.layers.28.input_layernorm.weight": "model-00002-of-00002.safetensors",
135
+ "model.layers.28.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
136
+ "model.layers.28.mlp.gate_up_proj.weight": "model-00002-of-00002.safetensors",
137
+ "model.layers.28.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
138
+ "model.layers.28.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
139
+ "model.layers.28.self_attn.qkv_proj.weight": "model-00002-of-00002.safetensors",
140
+ "model.layers.29.input_layernorm.weight": "model-00002-of-00002.safetensors",
141
+ "model.layers.29.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
142
+ "model.layers.29.mlp.gate_up_proj.weight": "model-00002-of-00002.safetensors",
143
+ "model.layers.29.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
144
+ "model.layers.29.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
145
+ "model.layers.29.self_attn.qkv_proj.weight": "model-00002-of-00002.safetensors",
146
+ "model.layers.3.input_layernorm.weight": "model-00001-of-00002.safetensors",
147
+ "model.layers.3.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
148
+ "model.layers.3.mlp.gate_up_proj.weight": "model-00001-of-00002.safetensors",
149
+ "model.layers.3.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
150
+ "model.layers.3.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
151
+ "model.layers.3.self_attn.qkv_proj.weight": "model-00001-of-00002.safetensors",
152
+ "model.layers.30.input_layernorm.weight": "model-00002-of-00002.safetensors",
153
+ "model.layers.30.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
154
+ "model.layers.30.mlp.gate_up_proj.weight": "model-00002-of-00002.safetensors",
155
+ "model.layers.30.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
156
+ "model.layers.30.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
157
+ "model.layers.30.self_attn.qkv_proj.weight": "model-00002-of-00002.safetensors",
158
+ "model.layers.31.input_layernorm.weight": "model-00002-of-00002.safetensors",
159
+ "model.layers.31.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
160
+ "model.layers.31.mlp.gate_up_proj.weight": "model-00002-of-00002.safetensors",
161
+ "model.layers.31.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
162
+ "model.layers.31.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
163
+ "model.layers.31.self_attn.qkv_proj.weight": "model-00002-of-00002.safetensors",
164
+ "model.layers.4.input_layernorm.weight": "model-00001-of-00002.safetensors",
165
+ "model.layers.4.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
166
+ "model.layers.4.mlp.gate_up_proj.weight": "model-00001-of-00002.safetensors",
167
+ "model.layers.4.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
168
+ "model.layers.4.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
169
+ "model.layers.4.self_attn.qkv_proj.weight": "model-00001-of-00002.safetensors",
170
+ "model.layers.5.input_layernorm.weight": "model-00001-of-00002.safetensors",
171
+ "model.layers.5.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
172
+ "model.layers.5.mlp.gate_up_proj.weight": "model-00001-of-00002.safetensors",
173
+ "model.layers.5.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
174
+ "model.layers.5.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
175
+ "model.layers.5.self_attn.qkv_proj.weight": "model-00001-of-00002.safetensors",
176
+ "model.layers.6.input_layernorm.weight": "model-00001-of-00002.safetensors",
177
+ "model.layers.6.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
178
+ "model.layers.6.mlp.gate_up_proj.weight": "model-00001-of-00002.safetensors",
179
+ "model.layers.6.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
180
+ "model.layers.6.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
181
+ "model.layers.6.self_attn.qkv_proj.weight": "model-00001-of-00002.safetensors",
182
+ "model.layers.7.input_layernorm.weight": "model-00001-of-00002.safetensors",
183
+ "model.layers.7.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
184
+ "model.layers.7.mlp.gate_up_proj.weight": "model-00001-of-00002.safetensors",
185
+ "model.layers.7.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
186
+ "model.layers.7.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
187
+ "model.layers.7.self_attn.qkv_proj.weight": "model-00001-of-00002.safetensors",
188
+ "model.layers.8.input_layernorm.weight": "model-00001-of-00002.safetensors",
189
+ "model.layers.8.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
190
+ "model.layers.8.mlp.gate_up_proj.weight": "model-00001-of-00002.safetensors",
191
+ "model.layers.8.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
192
+ "model.layers.8.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
193
+ "model.layers.8.self_attn.qkv_proj.weight": "model-00001-of-00002.safetensors",
194
+ "model.layers.9.input_layernorm.weight": "model-00001-of-00002.safetensors",
195
+ "model.layers.9.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
196
+ "model.layers.9.mlp.gate_up_proj.weight": "model-00001-of-00002.safetensors",
197
+ "model.layers.9.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
198
+ "model.layers.9.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
199
+ "model.layers.9.self_attn.qkv_proj.weight": "model-00001-of-00002.safetensors",
200
+ "model.norm.weight": "model-00002-of-00002.safetensors",
201
+ "model.vision_embed_tokens.glb_GN": "model-00001-of-00002.safetensors",
202
+ "model.vision_embed_tokens.img_processor.vision_model.embeddings.class_embedding": "model-00001-of-00002.safetensors",
203
+ "model.vision_embed_tokens.img_processor.vision_model.embeddings.patch_embedding.weight": "model-00001-of-00002.safetensors",
204
+ "model.vision_embed_tokens.img_processor.vision_model.embeddings.position_embedding.weight": "model-00001-of-00002.safetensors",
205
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.0.layer_norm1.bias": "model-00001-of-00002.safetensors",
206
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.0.layer_norm1.weight": "model-00001-of-00002.safetensors",
207
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.0.layer_norm2.bias": "model-00001-of-00002.safetensors",
208
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.0.layer_norm2.weight": "model-00001-of-00002.safetensors",
209
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.0.mlp.fc1.bias": "model-00001-of-00002.safetensors",
210
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.0.mlp.fc1.weight": "model-00001-of-00002.safetensors",
211
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.0.mlp.fc2.bias": "model-00001-of-00002.safetensors",
212
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.0.mlp.fc2.weight": "model-00001-of-00002.safetensors",
213
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.0.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
214
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.0.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
215
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.0.self_attn.out_proj.bias": "model-00001-of-00002.safetensors",
216
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.0.self_attn.out_proj.weight": "model-00001-of-00002.safetensors",
217
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.0.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
218
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.0.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
219
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.0.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
220
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.0.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
221
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.1.layer_norm1.bias": "model-00001-of-00002.safetensors",
222
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.1.layer_norm1.weight": "model-00001-of-00002.safetensors",
223
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.1.layer_norm2.bias": "model-00001-of-00002.safetensors",
224
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.1.layer_norm2.weight": "model-00001-of-00002.safetensors",
225
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.1.mlp.fc1.bias": "model-00001-of-00002.safetensors",
226
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.1.mlp.fc1.weight": "model-00001-of-00002.safetensors",
227
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.1.mlp.fc2.bias": "model-00001-of-00002.safetensors",
228
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.1.mlp.fc2.weight": "model-00001-of-00002.safetensors",
229
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.1.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
230
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.1.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
231
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.1.self_attn.out_proj.bias": "model-00001-of-00002.safetensors",
232
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.1.self_attn.out_proj.weight": "model-00001-of-00002.safetensors",
233
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.1.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
234
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.1.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
235
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.1.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
236
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.1.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
237
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.10.layer_norm1.bias": "model-00001-of-00002.safetensors",
238
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.10.layer_norm1.weight": "model-00001-of-00002.safetensors",
239
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.10.layer_norm2.bias": "model-00001-of-00002.safetensors",
240
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.10.layer_norm2.weight": "model-00001-of-00002.safetensors",
241
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.10.mlp.fc1.bias": "model-00001-of-00002.safetensors",
242
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.10.mlp.fc1.weight": "model-00001-of-00002.safetensors",
243
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.10.mlp.fc2.bias": "model-00001-of-00002.safetensors",
244
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.10.mlp.fc2.weight": "model-00001-of-00002.safetensors",
245
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.10.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
246
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.10.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
247
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.10.self_attn.out_proj.bias": "model-00001-of-00002.safetensors",
248
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.10.self_attn.out_proj.weight": "model-00001-of-00002.safetensors",
249
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.10.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
250
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.10.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
251
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.10.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
252
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.10.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
253
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.11.layer_norm1.bias": "model-00001-of-00002.safetensors",
254
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.11.layer_norm1.weight": "model-00001-of-00002.safetensors",
255
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.11.layer_norm2.bias": "model-00001-of-00002.safetensors",
256
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.11.layer_norm2.weight": "model-00001-of-00002.safetensors",
257
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.11.mlp.fc1.bias": "model-00001-of-00002.safetensors",
258
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.11.mlp.fc1.weight": "model-00001-of-00002.safetensors",
259
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.11.mlp.fc2.bias": "model-00001-of-00002.safetensors",
260
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.11.mlp.fc2.weight": "model-00001-of-00002.safetensors",
261
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.11.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
262
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.11.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
263
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.11.self_attn.out_proj.bias": "model-00001-of-00002.safetensors",
264
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.11.self_attn.out_proj.weight": "model-00001-of-00002.safetensors",
265
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.11.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
266
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.11.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
267
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.11.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
268
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.11.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
269
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.12.layer_norm1.bias": "model-00001-of-00002.safetensors",
270
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.12.layer_norm1.weight": "model-00001-of-00002.safetensors",
271
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.12.layer_norm2.bias": "model-00001-of-00002.safetensors",
272
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.12.layer_norm2.weight": "model-00001-of-00002.safetensors",
273
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.12.mlp.fc1.bias": "model-00001-of-00002.safetensors",
274
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.12.mlp.fc1.weight": "model-00001-of-00002.safetensors",
275
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.12.mlp.fc2.bias": "model-00001-of-00002.safetensors",
276
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.12.mlp.fc2.weight": "model-00001-of-00002.safetensors",
277
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.12.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
278
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.12.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
279
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.12.self_attn.out_proj.bias": "model-00001-of-00002.safetensors",
280
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.12.self_attn.out_proj.weight": "model-00001-of-00002.safetensors",
281
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.12.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
282
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.12.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
283
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.12.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
284
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.12.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
285
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.13.layer_norm1.bias": "model-00001-of-00002.safetensors",
286
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.13.layer_norm1.weight": "model-00001-of-00002.safetensors",
287
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.13.layer_norm2.bias": "model-00001-of-00002.safetensors",
288
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.13.layer_norm2.weight": "model-00001-of-00002.safetensors",
289
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.13.mlp.fc1.bias": "model-00001-of-00002.safetensors",
290
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.13.mlp.fc1.weight": "model-00001-of-00002.safetensors",
291
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.13.mlp.fc2.bias": "model-00001-of-00002.safetensors",
292
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.13.mlp.fc2.weight": "model-00001-of-00002.safetensors",
293
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.13.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
294
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.13.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
295
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.13.self_attn.out_proj.bias": "model-00001-of-00002.safetensors",
296
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.13.self_attn.out_proj.weight": "model-00001-of-00002.safetensors",
297
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.13.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
298
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.13.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
299
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.13.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
300
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.13.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
301
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.14.layer_norm1.bias": "model-00001-of-00002.safetensors",
302
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.14.layer_norm1.weight": "model-00001-of-00002.safetensors",
303
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.14.layer_norm2.bias": "model-00001-of-00002.safetensors",
304
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.14.layer_norm2.weight": "model-00001-of-00002.safetensors",
305
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.14.mlp.fc1.bias": "model-00001-of-00002.safetensors",
306
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.14.mlp.fc1.weight": "model-00001-of-00002.safetensors",
307
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.14.mlp.fc2.bias": "model-00001-of-00002.safetensors",
308
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.14.mlp.fc2.weight": "model-00001-of-00002.safetensors",
309
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.14.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
310
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.14.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
311
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.14.self_attn.out_proj.bias": "model-00001-of-00002.safetensors",
312
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.14.self_attn.out_proj.weight": "model-00001-of-00002.safetensors",
313
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.14.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
314
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.14.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
315
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.14.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
316
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.14.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
317
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.15.layer_norm1.bias": "model-00001-of-00002.safetensors",
318
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.15.layer_norm1.weight": "model-00001-of-00002.safetensors",
319
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.15.layer_norm2.bias": "model-00001-of-00002.safetensors",
320
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.15.layer_norm2.weight": "model-00001-of-00002.safetensors",
321
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.15.mlp.fc1.bias": "model-00001-of-00002.safetensors",
322
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.15.mlp.fc1.weight": "model-00001-of-00002.safetensors",
323
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.15.mlp.fc2.bias": "model-00001-of-00002.safetensors",
324
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.15.mlp.fc2.weight": "model-00001-of-00002.safetensors",
325
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.15.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
326
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.15.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
327
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.15.self_attn.out_proj.bias": "model-00001-of-00002.safetensors",
328
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.15.self_attn.out_proj.weight": "model-00001-of-00002.safetensors",
329
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.15.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
330
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.15.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
331
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.15.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
332
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.15.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
333
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.16.layer_norm1.bias": "model-00001-of-00002.safetensors",
334
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.16.layer_norm1.weight": "model-00001-of-00002.safetensors",
335
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.16.layer_norm2.bias": "model-00001-of-00002.safetensors",
336
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.16.layer_norm2.weight": "model-00001-of-00002.safetensors",
337
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.16.mlp.fc1.bias": "model-00001-of-00002.safetensors",
338
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.16.mlp.fc1.weight": "model-00001-of-00002.safetensors",
339
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.16.mlp.fc2.bias": "model-00001-of-00002.safetensors",
340
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.16.mlp.fc2.weight": "model-00001-of-00002.safetensors",
341
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.16.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
342
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.16.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
343
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.16.self_attn.out_proj.bias": "model-00001-of-00002.safetensors",
344
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.16.self_attn.out_proj.weight": "model-00001-of-00002.safetensors",
345
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.16.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
346
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.16.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
347
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.16.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
348
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.16.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
349
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.17.layer_norm1.bias": "model-00001-of-00002.safetensors",
350
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.17.layer_norm1.weight": "model-00001-of-00002.safetensors",
351
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.17.layer_norm2.bias": "model-00001-of-00002.safetensors",
352
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.17.layer_norm2.weight": "model-00001-of-00002.safetensors",
353
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.17.mlp.fc1.bias": "model-00001-of-00002.safetensors",
354
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.17.mlp.fc1.weight": "model-00001-of-00002.safetensors",
355
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.17.mlp.fc2.bias": "model-00001-of-00002.safetensors",
356
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.17.mlp.fc2.weight": "model-00001-of-00002.safetensors",
357
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.17.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
358
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.17.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
359
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.17.self_attn.out_proj.bias": "model-00001-of-00002.safetensors",
360
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.17.self_attn.out_proj.weight": "model-00001-of-00002.safetensors",
361
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.17.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
362
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.17.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
363
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.17.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
364
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.17.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
365
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.18.layer_norm1.bias": "model-00001-of-00002.safetensors",
366
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.18.layer_norm1.weight": "model-00001-of-00002.safetensors",
367
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.18.layer_norm2.bias": "model-00001-of-00002.safetensors",
368
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.18.layer_norm2.weight": "model-00001-of-00002.safetensors",
369
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.18.mlp.fc1.bias": "model-00001-of-00002.safetensors",
370
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.18.mlp.fc1.weight": "model-00001-of-00002.safetensors",
371
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.18.mlp.fc2.bias": "model-00001-of-00002.safetensors",
372
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.18.mlp.fc2.weight": "model-00001-of-00002.safetensors",
373
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.18.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
374
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.18.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
375
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.18.self_attn.out_proj.bias": "model-00001-of-00002.safetensors",
376
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.18.self_attn.out_proj.weight": "model-00001-of-00002.safetensors",
377
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.18.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
378
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.18.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
379
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.18.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
380
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.18.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
381
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.19.layer_norm1.bias": "model-00001-of-00002.safetensors",
382
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.19.layer_norm1.weight": "model-00001-of-00002.safetensors",
383
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.19.layer_norm2.bias": "model-00001-of-00002.safetensors",
384
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.19.layer_norm2.weight": "model-00001-of-00002.safetensors",
385
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.19.mlp.fc1.bias": "model-00001-of-00002.safetensors",
386
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.19.mlp.fc1.weight": "model-00001-of-00002.safetensors",
387
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.19.mlp.fc2.bias": "model-00001-of-00002.safetensors",
388
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.19.mlp.fc2.weight": "model-00001-of-00002.safetensors",
389
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.19.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
390
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.19.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
391
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.19.self_attn.out_proj.bias": "model-00001-of-00002.safetensors",
392
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.19.self_attn.out_proj.weight": "model-00001-of-00002.safetensors",
393
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.19.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
394
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.19.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
395
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.19.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
396
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.19.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
397
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.2.layer_norm1.bias": "model-00001-of-00002.safetensors",
398
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.2.layer_norm1.weight": "model-00001-of-00002.safetensors",
399
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.2.layer_norm2.bias": "model-00001-of-00002.safetensors",
400
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.2.layer_norm2.weight": "model-00001-of-00002.safetensors",
401
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.2.mlp.fc1.bias": "model-00001-of-00002.safetensors",
402
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.2.mlp.fc1.weight": "model-00001-of-00002.safetensors",
403
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.2.mlp.fc2.bias": "model-00001-of-00002.safetensors",
404
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.2.mlp.fc2.weight": "model-00001-of-00002.safetensors",
405
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.2.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
406
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.2.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
407
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.2.self_attn.out_proj.bias": "model-00001-of-00002.safetensors",
408
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.2.self_attn.out_proj.weight": "model-00001-of-00002.safetensors",
409
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.2.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
410
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.2.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
411
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.2.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
412
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.2.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
413
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.20.layer_norm1.bias": "model-00001-of-00002.safetensors",
414
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.20.layer_norm1.weight": "model-00001-of-00002.safetensors",
415
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.20.layer_norm2.bias": "model-00001-of-00002.safetensors",
416
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.20.layer_norm2.weight": "model-00001-of-00002.safetensors",
417
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.20.mlp.fc1.bias": "model-00001-of-00002.safetensors",
418
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.20.mlp.fc1.weight": "model-00001-of-00002.safetensors",
419
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.20.mlp.fc2.bias": "model-00001-of-00002.safetensors",
420
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.20.mlp.fc2.weight": "model-00001-of-00002.safetensors",
421
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.20.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
422
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.20.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
423
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.20.self_attn.out_proj.bias": "model-00001-of-00002.safetensors",
424
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.20.self_attn.out_proj.weight": "model-00001-of-00002.safetensors",
425
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.20.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
426
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.20.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
427
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.20.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
428
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.20.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
429
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.21.layer_norm1.bias": "model-00001-of-00002.safetensors",
430
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.21.layer_norm1.weight": "model-00001-of-00002.safetensors",
431
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.21.layer_norm2.bias": "model-00001-of-00002.safetensors",
432
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.21.layer_norm2.weight": "model-00001-of-00002.safetensors",
433
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.21.mlp.fc1.bias": "model-00001-of-00002.safetensors",
434
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.21.mlp.fc1.weight": "model-00001-of-00002.safetensors",
435
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.21.mlp.fc2.bias": "model-00001-of-00002.safetensors",
436
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.21.mlp.fc2.weight": "model-00001-of-00002.safetensors",
437
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.21.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
438
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.21.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
439
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.21.self_attn.out_proj.bias": "model-00001-of-00002.safetensors",
440
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.21.self_attn.out_proj.weight": "model-00001-of-00002.safetensors",
441
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.21.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
442
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.21.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
443
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.21.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
444
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.21.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
445
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.22.layer_norm1.bias": "model-00001-of-00002.safetensors",
446
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.22.layer_norm1.weight": "model-00001-of-00002.safetensors",
447
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.22.layer_norm2.bias": "model-00001-of-00002.safetensors",
448
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.22.layer_norm2.weight": "model-00001-of-00002.safetensors",
449
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.22.mlp.fc1.bias": "model-00001-of-00002.safetensors",
450
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.22.mlp.fc1.weight": "model-00001-of-00002.safetensors",
451
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.22.mlp.fc2.bias": "model-00001-of-00002.safetensors",
452
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.22.mlp.fc2.weight": "model-00001-of-00002.safetensors",
453
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.22.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
454
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.22.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
455
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.22.self_attn.out_proj.bias": "model-00001-of-00002.safetensors",
456
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.22.self_attn.out_proj.weight": "model-00001-of-00002.safetensors",
457
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.22.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
458
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.22.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
459
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.22.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
460
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.22.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
461
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.23.layer_norm1.bias": "model-00001-of-00002.safetensors",
462
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.23.layer_norm1.weight": "model-00001-of-00002.safetensors",
463
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.23.layer_norm2.bias": "model-00001-of-00002.safetensors",
464
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.23.layer_norm2.weight": "model-00001-of-00002.safetensors",
465
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.23.mlp.fc1.bias": "model-00001-of-00002.safetensors",
466
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.23.mlp.fc1.weight": "model-00001-of-00002.safetensors",
467
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.23.mlp.fc2.bias": "model-00001-of-00002.safetensors",
468
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.23.mlp.fc2.weight": "model-00001-of-00002.safetensors",
469
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.23.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
470
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.23.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
471
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.23.self_attn.out_proj.bias": "model-00001-of-00002.safetensors",
472
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.23.self_attn.out_proj.weight": "model-00001-of-00002.safetensors",
473
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.23.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
474
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.23.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
475
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.23.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
476
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.23.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
477
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.3.layer_norm1.bias": "model-00001-of-00002.safetensors",
478
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.3.layer_norm1.weight": "model-00001-of-00002.safetensors",
479
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.3.layer_norm2.bias": "model-00001-of-00002.safetensors",
480
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.3.layer_norm2.weight": "model-00001-of-00002.safetensors",
481
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.3.mlp.fc1.bias": "model-00001-of-00002.safetensors",
482
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.3.mlp.fc1.weight": "model-00001-of-00002.safetensors",
483
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.3.mlp.fc2.bias": "model-00001-of-00002.safetensors",
484
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.3.mlp.fc2.weight": "model-00001-of-00002.safetensors",
485
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.3.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
486
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.3.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
487
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.3.self_attn.out_proj.bias": "model-00001-of-00002.safetensors",
488
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.3.self_attn.out_proj.weight": "model-00001-of-00002.safetensors",
489
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.3.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
490
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.3.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
491
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.3.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
492
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.3.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
493
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.4.layer_norm1.bias": "model-00001-of-00002.safetensors",
494
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.4.layer_norm1.weight": "model-00001-of-00002.safetensors",
495
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.4.layer_norm2.bias": "model-00001-of-00002.safetensors",
496
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.4.layer_norm2.weight": "model-00001-of-00002.safetensors",
497
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.4.mlp.fc1.bias": "model-00001-of-00002.safetensors",
498
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.4.mlp.fc1.weight": "model-00001-of-00002.safetensors",
499
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.4.mlp.fc2.bias": "model-00001-of-00002.safetensors",
500
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.4.mlp.fc2.weight": "model-00001-of-00002.safetensors",
501
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.4.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
502
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.4.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
503
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.4.self_attn.out_proj.bias": "model-00001-of-00002.safetensors",
504
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.4.self_attn.out_proj.weight": "model-00001-of-00002.safetensors",
505
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.4.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
506
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.4.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
507
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.4.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
508
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.4.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
509
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.5.layer_norm1.bias": "model-00001-of-00002.safetensors",
510
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.5.layer_norm1.weight": "model-00001-of-00002.safetensors",
511
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.5.layer_norm2.bias": "model-00001-of-00002.safetensors",
512
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.5.layer_norm2.weight": "model-00001-of-00002.safetensors",
513
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.5.mlp.fc1.bias": "model-00001-of-00002.safetensors",
514
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.5.mlp.fc1.weight": "model-00001-of-00002.safetensors",
515
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.5.mlp.fc2.bias": "model-00001-of-00002.safetensors",
516
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.5.mlp.fc2.weight": "model-00001-of-00002.safetensors",
517
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.5.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
518
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.5.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
519
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.5.self_attn.out_proj.bias": "model-00001-of-00002.safetensors",
520
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.5.self_attn.out_proj.weight": "model-00001-of-00002.safetensors",
521
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.5.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
522
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.5.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
523
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.5.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
524
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.5.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
525
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.6.layer_norm1.bias": "model-00001-of-00002.safetensors",
526
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.6.layer_norm1.weight": "model-00001-of-00002.safetensors",
527
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.6.layer_norm2.bias": "model-00001-of-00002.safetensors",
528
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.6.layer_norm2.weight": "model-00001-of-00002.safetensors",
529
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.6.mlp.fc1.bias": "model-00001-of-00002.safetensors",
530
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.6.mlp.fc1.weight": "model-00001-of-00002.safetensors",
531
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.6.mlp.fc2.bias": "model-00001-of-00002.safetensors",
532
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.6.mlp.fc2.weight": "model-00001-of-00002.safetensors",
533
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.6.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
534
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.6.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
535
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.6.self_attn.out_proj.bias": "model-00001-of-00002.safetensors",
536
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.6.self_attn.out_proj.weight": "model-00001-of-00002.safetensors",
537
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.6.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
538
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.6.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
539
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.6.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
540
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.6.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
541
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.7.layer_norm1.bias": "model-00001-of-00002.safetensors",
542
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.7.layer_norm1.weight": "model-00001-of-00002.safetensors",
543
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.7.layer_norm2.bias": "model-00001-of-00002.safetensors",
544
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.7.layer_norm2.weight": "model-00001-of-00002.safetensors",
545
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.7.mlp.fc1.bias": "model-00001-of-00002.safetensors",
546
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.7.mlp.fc1.weight": "model-00001-of-00002.safetensors",
547
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.7.mlp.fc2.bias": "model-00001-of-00002.safetensors",
548
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.7.mlp.fc2.weight": "model-00001-of-00002.safetensors",
549
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.7.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
550
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.7.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
551
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.7.self_attn.out_proj.bias": "model-00001-of-00002.safetensors",
552
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.7.self_attn.out_proj.weight": "model-00001-of-00002.safetensors",
553
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.7.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
554
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.7.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
555
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.7.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
556
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.7.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
557
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.8.layer_norm1.bias": "model-00001-of-00002.safetensors",
558
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.8.layer_norm1.weight": "model-00001-of-00002.safetensors",
559
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.8.layer_norm2.bias": "model-00001-of-00002.safetensors",
560
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.8.layer_norm2.weight": "model-00001-of-00002.safetensors",
561
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.8.mlp.fc1.bias": "model-00001-of-00002.safetensors",
562
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.8.mlp.fc1.weight": "model-00001-of-00002.safetensors",
563
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.8.mlp.fc2.bias": "model-00001-of-00002.safetensors",
564
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.8.mlp.fc2.weight": "model-00001-of-00002.safetensors",
565
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.8.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
566
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.8.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
567
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.8.self_attn.out_proj.bias": "model-00001-of-00002.safetensors",
568
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.8.self_attn.out_proj.weight": "model-00001-of-00002.safetensors",
569
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.8.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
570
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.8.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
571
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.8.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
572
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.8.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
573
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.9.layer_norm1.bias": "model-00001-of-00002.safetensors",
574
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.9.layer_norm1.weight": "model-00001-of-00002.safetensors",
575
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.9.layer_norm2.bias": "model-00001-of-00002.safetensors",
576
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.9.layer_norm2.weight": "model-00001-of-00002.safetensors",
577
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.9.mlp.fc1.bias": "model-00001-of-00002.safetensors",
578
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.9.mlp.fc1.weight": "model-00001-of-00002.safetensors",
579
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.9.mlp.fc2.bias": "model-00001-of-00002.safetensors",
580
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.9.mlp.fc2.weight": "model-00001-of-00002.safetensors",
581
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.9.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
582
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.9.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
583
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.9.self_attn.out_proj.bias": "model-00001-of-00002.safetensors",
584
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.9.self_attn.out_proj.weight": "model-00001-of-00002.safetensors",
585
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.9.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
586
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.9.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
587
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.9.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
588
+ "model.vision_embed_tokens.img_processor.vision_model.encoder.layers.9.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
589
+ "model.vision_embed_tokens.img_processor.vision_model.post_layernorm.bias": "model-00001-of-00002.safetensors",
590
+ "model.vision_embed_tokens.img_processor.vision_model.post_layernorm.weight": "model-00001-of-00002.safetensors",
591
+ "model.vision_embed_tokens.img_processor.vision_model.pre_layrnorm.bias": "model-00001-of-00002.safetensors",
592
+ "model.vision_embed_tokens.img_processor.vision_model.pre_layrnorm.weight": "model-00001-of-00002.safetensors",
593
+ "model.vision_embed_tokens.img_projection.0.bias": "model-00001-of-00002.safetensors",
594
+ "model.vision_embed_tokens.img_projection.0.weight": "model-00001-of-00002.safetensors",
595
+ "model.vision_embed_tokens.img_projection.2.bias": "model-00001-of-00002.safetensors",
596
+ "model.vision_embed_tokens.img_projection.2.weight": "model-00001-of-00002.safetensors",
597
+ "model.vision_embed_tokens.sub_GN": "model-00001-of-00002.safetensors",
598
+ "model.vision_embed_tokens.wte.weight": "model-00001-of-00002.safetensors"
599
+ }
600
+ }
modeling_phi3_v.py ADDED
@@ -0,0 +1,1633 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # coding=utf-8
2
+ # Copyright 2024 Microsoft and the HuggingFace Inc. team. All rights reserved.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+ """ PyTorch Phi-3-V model."""
17
+
18
+ import inspect
19
+ import math
20
+ import warnings
21
+ from typing import List, Optional, Tuple, Union
22
+
23
+ import torch
24
+ import torch.nn.functional as F
25
+ import torch.utils.checkpoint
26
+ from torch import nn
27
+ from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss
28
+
29
+ from transformers.activations import ACT2FN
30
+ from transformers.cache_utils import Cache, DynamicCache
31
+ from transformers.modeling_attn_mask_utils import _prepare_4d_causal_attention_mask
32
+ from transformers.modeling_outputs import (
33
+ BaseModelOutputWithPast,
34
+ CausalLMOutputWithPast,
35
+ SequenceClassifierOutputWithPast,
36
+ TokenClassifierOutput,
37
+ )
38
+ from transformers.modeling_utils import PreTrainedModel
39
+ from transformers.utils import (
40
+ add_code_sample_docstrings,
41
+ add_start_docstrings,
42
+ add_start_docstrings_to_model_forward,
43
+ is_flash_attn_greater_or_equal_2_10,
44
+ logging,
45
+ replace_return_docstrings,
46
+ )
47
+ from .configuration_phi3_v import Phi3VConfig
48
+ from .image_embedding_phi3_v import Phi3ImageEmbedding
49
+
50
+
51
+ try:
52
+ from flash_attn import flash_attn_func, flash_attn_varlen_func
53
+ from flash_attn.bert_padding import index_first_axis, pad_input, unpad_input # noqa
54
+
55
+ _flash_supports_window_size = "window_size" in list(inspect.signature(flash_attn_func).parameters)
56
+ except ImportError:
57
+ pass
58
+
59
+ logger = logging.get_logger(__name__)
60
+
61
+ _CHECKPOINT_FOR_DOC = "microsoft/Phi-3-vision-128k-instruct"
62
+ _CONFIG_FOR_DOC = "Phi3VConfig"
63
+
64
+ PHI3V_PRETRAINED_MODEL_ARCHIVE_LIST = [
65
+ "microsoft/Phi-3-vision-128k-instruct",
66
+ # See all Phi-3 models at https://huggingface.co/models?filter=Phi-3
67
+ ]
68
+
69
+
70
+ # Copied from transformers.models.llama.modeling_llama.LlamaRMSNorm with Llama->Phi3
71
+ class Phi3RMSNorm(nn.Module):
72
+ def __init__(self, hidden_size, eps=1e-6):
73
+ """
74
+ Phi3RMSNorm is equivalent to T5LayerNorm
75
+ """
76
+ super().__init__()
77
+ self.weight = nn.Parameter(torch.ones(hidden_size))
78
+ self.variance_epsilon = eps
79
+
80
+ def forward(self, hidden_states):
81
+ input_dtype = hidden_states.dtype
82
+ hidden_states = hidden_states.to(torch.float32)
83
+ variance = hidden_states.pow(2).mean(-1, keepdim=True)
84
+ hidden_states = hidden_states * torch.rsqrt(variance + self.variance_epsilon)
85
+ return self.weight * hidden_states.to(input_dtype)
86
+
87
+
88
+ # Copied from transformers.models.llama.modeling_llama._get_unpad_data
89
+ def _get_unpad_data(attention_mask):
90
+ seqlens_in_batch = attention_mask.sum(dim=-1, dtype=torch.int32)
91
+ indices = torch.nonzero(attention_mask.flatten(), as_tuple=False).flatten()
92
+ max_seqlen_in_batch = seqlens_in_batch.max().item()
93
+ cu_seqlens = F.pad(torch.cumsum(seqlens_in_batch, dim=0, dtype=torch.int32), (1, 0))
94
+ return (
95
+ indices,
96
+ cu_seqlens,
97
+ max_seqlen_in_batch,
98
+ )
99
+
100
+
101
+ # Copied from transformers.models.gemma.modeling_gemma.GemmaRotaryEmbedding with gemma->phi3, Gemma->Phi3
102
+ class Phi3RotaryEmbedding(nn.Module):
103
+ def __init__(self, dim, max_position_embeddings=2048, base=10000, device=None):
104
+ super().__init__()
105
+
106
+ self.dim = dim
107
+ self.max_position_embeddings = max_position_embeddings
108
+ self.base = base
109
+ self.register_buffer("inv_freq", None, persistent=False)
110
+
111
+ @torch.no_grad()
112
+ def forward(self, x, position_ids, seq_len=None):
113
+ # x: [bs, num_attention_heads, seq_len, head_size]
114
+ if self.inv_freq is None:
115
+ self.inv_freq = 1.0 / (
116
+ self.base ** (torch.arange(0, self.dim, 2, dtype=torch.int64, device=x.device).float() / self.dim)
117
+ )
118
+ inv_freq_expanded = self.inv_freq[None, :, None].float().expand(position_ids.shape[0], -1, 1)
119
+ position_ids_expanded = position_ids[:, None, :].float()
120
+ # Force float32 since bfloat16 loses precision on long contexts
121
+ # See https://github.com/huggingface/transformers/pull/29285
122
+ device_type = x.device.type
123
+ device_type = device_type if isinstance(device_type, str) and device_type != "mps" else "cpu"
124
+ with torch.autocast(device_type=device_type, enabled=False):
125
+ freqs = (inv_freq_expanded.float() @ position_ids_expanded.float()).transpose(1, 2)
126
+ emb = torch.cat((freqs, freqs), dim=-1)
127
+ cos = emb.cos()
128
+ sin = emb.sin()
129
+ return cos.to(dtype=x.dtype), sin.to(dtype=x.dtype)
130
+
131
+
132
+ class Phi3SuScaledRotaryEmbedding(Phi3RotaryEmbedding):
133
+ def __init__(self, dim, config, device=None):
134
+ super().__init__(dim, config.max_position_embeddings, config.rope_theta, device)
135
+
136
+ self.short_factor = config.rope_scaling["short_factor"]
137
+ self.long_factor = config.rope_scaling["long_factor"]
138
+ self.original_max_position_embeddings = config.original_max_position_embeddings
139
+
140
+ @torch.no_grad()
141
+ def forward(self, x, position_ids, seq_len=None):
142
+ seq_len = torch.max(position_ids) + 1
143
+ if seq_len > self.original_max_position_embeddings:
144
+ ext_factors = torch.tensor(self.long_factor, dtype=torch.float32, device=x.device)
145
+ else:
146
+ ext_factors = torch.tensor(self.short_factor, dtype=torch.float32, device=x.device)
147
+
148
+ inv_freq_shape = torch.arange(0, self.dim, 2, dtype=torch.int64, device=x.device).float() / self.dim
149
+ self.inv_freq = 1.0 / (ext_factors * self.base**inv_freq_shape)
150
+
151
+ inv_freq_expanded = self.inv_freq[None, :, None].float().expand(position_ids.shape[0], -1, 1)
152
+ position_ids_expanded = position_ids[:, None, :].float()
153
+
154
+ # Force float32 since bfloat16 loses precision on long contexts
155
+ # See https://github.com/huggingface/transformers/pull/29285
156
+ device_type = x.device.type
157
+ device_type = device_type if isinstance(device_type, str) and device_type != "mps" else "cpu"
158
+ with torch.autocast(device_type=device_type, enabled=False):
159
+ freqs = (inv_freq_expanded.float() @ position_ids_expanded.float()).transpose(1, 2)
160
+ emb = torch.cat((freqs, freqs), dim=-1)
161
+
162
+ scale = self.max_position_embeddings / self.original_max_position_embeddings
163
+ if scale <= 1.0:
164
+ scaling_factor = 1.0
165
+ else:
166
+ scaling_factor = math.sqrt(1 + math.log(scale) / math.log(self.original_max_position_embeddings))
167
+
168
+ cos = emb.cos() * scaling_factor
169
+ sin = emb.sin() * scaling_factor
170
+ return cos.to(dtype=x.dtype), sin.to(dtype=x.dtype)
171
+
172
+
173
+ class Phi3YarnScaledRotaryEmbedding(Phi3RotaryEmbedding):
174
+ def __init__(self, dim, config, device=None):
175
+ super().__init__(dim, config.max_position_embeddings, config.rope_theta, device)
176
+
177
+ self.short_factor = config.rope_scaling["short_factor"]
178
+ self.long_factor = config.rope_scaling["long_factor"]
179
+ self.original_max_position_embeddings = config.original_max_position_embeddings
180
+
181
+ @torch.no_grad()
182
+ def forward(self, x, position_ids, seq_len=None):
183
+ seq_len = torch.max(position_ids) + 1
184
+ if seq_len > self.original_max_position_embeddings:
185
+ ext_factors = torch.tensor(self.long_factor, dtype=torch.float32, device=x.device)
186
+ else:
187
+ ext_factors = torch.tensor(self.short_factor, dtype=torch.float32, device=x.device)
188
+
189
+ inv_freq_shape = torch.arange(0, self.dim, 2, dtype=torch.int64, device=x.device).float() / self.dim
190
+ self.inv_freq = 1.0 / (ext_factors * self.base**inv_freq_shape)
191
+
192
+ inv_freq_expanded = self.inv_freq[None, :, None].float().expand(position_ids.shape[0], -1, 1)
193
+ position_ids_expanded = position_ids[:, None, :].float()
194
+
195
+ # Force float32 since bfloat16 loses precision on long contexts
196
+ # See https://github.com/huggingface/transformers/pull/29285
197
+ device_type = x.device.type
198
+ device_type = device_type if isinstance(device_type, str) and device_type != "mps" else "cpu"
199
+ with torch.autocast(device_type=device_type, enabled=False):
200
+ freqs = (inv_freq_expanded.float() @ position_ids_expanded.float()).transpose(1, 2)
201
+ emb = torch.cat((freqs, freqs), dim=-1)
202
+
203
+ scale = self.max_position_embeddings / self.original_max_position_embeddings
204
+ if scale <= 1.0:
205
+ scaling_factor = 1.0
206
+ else:
207
+ scaling_factor = 0.1 * math.log(scale) + 1.0
208
+
209
+ cos = emb.cos() * scaling_factor
210
+ sin = emb.sin() * scaling_factor
211
+ return cos.to(dtype=x.dtype), sin.to(dtype=x.dtype)
212
+
213
+
214
+ # Copied from transformers.models.llama.modeling_llama.rotate_half
215
+ def rotate_half(x):
216
+ """Rotates half the hidden dims of the input."""
217
+ x1 = x[..., : x.shape[-1] // 2]
218
+ x2 = x[..., x.shape[-1] // 2 :]
219
+ return torch.cat((-x2, x1), dim=-1)
220
+
221
+
222
+ # Copied from transformers.models.llama.modeling_llama.apply_rotary_pos_emb
223
+ def apply_rotary_pos_emb(q, k, cos, sin, position_ids=None, unsqueeze_dim=1):
224
+ """Applies Rotary Position Embedding to the query and key tensors.
225
+
226
+ Args:
227
+ q (`torch.Tensor`): The query tensor.
228
+ k (`torch.Tensor`): The key tensor.
229
+ cos (`torch.Tensor`): The cosine part of the rotary embedding.
230
+ sin (`torch.Tensor`): The sine part of the rotary embedding.
231
+ position_ids (`torch.Tensor`, *optional*):
232
+ Deprecated and unused.
233
+ unsqueeze_dim (`int`, *optional*, defaults to 1):
234
+ The 'unsqueeze_dim' argument specifies the dimension along which to unsqueeze cos[position_ids] and
235
+ sin[position_ids] so that they can be properly broadcasted to the dimensions of q and k. For example, note
236
+ that cos[position_ids] and sin[position_ids] have the shape [batch_size, seq_len, head_dim]. Then, if q and
237
+ k have the shape [batch_size, heads, seq_len, head_dim], then setting unsqueeze_dim=1 makes
238
+ cos[position_ids] and sin[position_ids] broadcastable to the shapes of q and k. Similarly, if q and k have
239
+ the shape [batch_size, seq_len, heads, head_dim], then set unsqueeze_dim=2.
240
+ Returns:
241
+ `tuple(torch.Tensor)` comprising of the query and key tensors rotated using the Rotary Position Embedding.
242
+ """
243
+ cos = cos.unsqueeze(unsqueeze_dim)
244
+ sin = sin.unsqueeze(unsqueeze_dim)
245
+ q_embed = (q * cos) + (rotate_half(q) * sin)
246
+ k_embed = (k * cos) + (rotate_half(k) * sin)
247
+ return q_embed, k_embed
248
+
249
+
250
+ class Phi3MLP(nn.Module):
251
+ def __init__(self, config):
252
+ super().__init__()
253
+
254
+ self.config = config
255
+ self.gate_up_proj = nn.Linear(config.hidden_size, 2 * config.intermediate_size, bias=False)
256
+ self.down_proj = nn.Linear(config.intermediate_size, config.hidden_size, bias=False)
257
+
258
+ self.activation_fn = ACT2FN[config.hidden_act]
259
+
260
+ def forward(self, hidden_states: torch.FloatTensor) -> torch.FloatTensor:
261
+ up_states = self.gate_up_proj(hidden_states)
262
+
263
+ gate, up_states = up_states.chunk(2, dim=-1)
264
+ up_states = up_states * self.activation_fn(gate)
265
+
266
+ return self.down_proj(up_states)
267
+
268
+
269
+ # Copied from transformers.models.llama.modeling_llama.repeat_kv with llama->phi
270
+ def repeat_kv(hidden_states: torch.Tensor, n_rep: int) -> torch.Tensor:
271
+ """
272
+ This is the equivalent of torch.repeat_interleave(x, dim=1, repeats=n_rep). The hidden states go from (batch,
273
+ num_key_value_heads, seqlen, head_dim) to (batch, num_attention_heads, seqlen, head_dim)
274
+ """
275
+ batch, num_key_value_heads, slen, head_dim = hidden_states.shape
276
+ if n_rep == 1:
277
+ return hidden_states
278
+ hidden_states = hidden_states[:, :, None, :, :].expand(batch, num_key_value_heads, n_rep, slen, head_dim)
279
+ return hidden_states.reshape(batch, num_key_value_heads * n_rep, slen, head_dim)
280
+
281
+
282
+ class Phi3Attention(nn.Module):
283
+ """Multi-headed attention from 'Attention Is All You Need' paper"""
284
+
285
+ def __init__(self, config: Phi3VConfig, layer_idx: Optional[int] = None):
286
+ super().__init__()
287
+ self.config = config
288
+ self.layer_idx = layer_idx
289
+ if layer_idx is None:
290
+ logger.warning_once(
291
+ f"Instantiating {self.__class__.__name__} without passing a `layer_idx` is not recommended and will "
292
+ "lead to errors during the forward call if caching is used. Please make sure to provide a `layer_idx` "
293
+ "when creating this class."
294
+ )
295
+
296
+ self.attention_dropout = config.attention_dropout
297
+ self.hidden_size = config.hidden_size
298
+ self.num_heads = config.num_attention_heads
299
+ self.head_dim = self.hidden_size // self.num_heads
300
+ self.num_key_value_heads = config.num_key_value_heads
301
+ self.num_key_value_groups = self.num_heads // self.num_key_value_heads
302
+ self.max_position_embeddings = config.max_position_embeddings
303
+ self.original_max_position_embeddings = config.original_max_position_embeddings
304
+ self.rope_theta = config.rope_theta
305
+ self.rope_scaling = config.rope_scaling
306
+ self.is_causal = True
307
+
308
+ if (self.head_dim * self.num_heads) != self.hidden_size:
309
+ raise ValueError(
310
+ f"hidden_size must be divisible by num_heads (got `hidden_size`: {self.hidden_size}"
311
+ f" and `num_heads`: {self.num_heads})."
312
+ )
313
+
314
+ op_size = self.num_heads * self.head_dim + 2 * (self.num_key_value_heads * self.head_dim)
315
+ self.o_proj = nn.Linear(self.num_heads * self.head_dim, self.hidden_size, bias=False)
316
+ self.qkv_proj = nn.Linear(self.hidden_size, op_size, bias=False)
317
+ self._init_rope()
318
+
319
+ def _init_rope(self):
320
+ if self.rope_scaling is None:
321
+ self.rotary_emb = Phi3RotaryEmbedding(
322
+ self.head_dim,
323
+ max_position_embeddings=self.max_position_embeddings,
324
+ base=self.rope_theta,
325
+ )
326
+ else:
327
+ scaling_type = self.config.rope_scaling["type"]
328
+ if scaling_type == "su":
329
+ self.rotary_emb = Phi3SuScaledRotaryEmbedding(self.head_dim, self.config)
330
+ elif scaling_type == "yarn":
331
+ self.rotary_emb = Phi3YarnScaledRotaryEmbedding(self.head_dim, self.config)
332
+ else:
333
+ raise ValueError(f"Unknown RoPE scaling type {scaling_type}")
334
+
335
+ def forward(
336
+ self,
337
+ hidden_states: torch.Tensor,
338
+ attention_mask: Optional[torch.Tensor] = None,
339
+ position_ids: Optional[torch.LongTensor] = None,
340
+ past_key_value: Optional[Cache] = None,
341
+ output_attentions: bool = False,
342
+ use_cache: bool = False,
343
+ ) -> Tuple[torch.Tensor, Optional[torch.Tensor], Optional[Tuple[torch.Tensor]]]:
344
+ logger.warning_once("You are not running the flash-attention implementation, expect numerical differences.")
345
+
346
+ bsz, q_len, _ = hidden_states.size()
347
+
348
+ qkv = self.qkv_proj(hidden_states)
349
+ query_pos = self.num_heads * self.head_dim
350
+ query_states = qkv[..., :query_pos]
351
+ key_states = qkv[..., query_pos : query_pos + self.num_key_value_heads * self.head_dim]
352
+ value_states = qkv[..., query_pos + self.num_key_value_heads * self.head_dim :]
353
+
354
+ query_states = query_states.view(bsz, q_len, self.num_heads, self.head_dim).transpose(1, 2)
355
+ key_states = key_states.view(bsz, q_len, self.num_key_value_heads, self.head_dim).transpose(1, 2)
356
+ value_states = value_states.view(bsz, q_len, self.num_key_value_heads, self.head_dim).transpose(1, 2)
357
+
358
+ kv_seq_len = key_states.shape[-2]
359
+ if past_key_value is not None:
360
+ if self.layer_idx is None:
361
+ raise ValueError(
362
+ f"The cache structure has changed since version v4.36. If you are using {self.__class__.__name__} "
363
+ "for auto-regressive decoding with k/v caching, please make sure to initialize the attention class "
364
+ "with a layer index."
365
+ )
366
+ kv_seq_len += past_key_value.get_usable_length(kv_seq_len, self.layer_idx)
367
+ cos, sin = self.rotary_emb(value_states, position_ids, seq_len=kv_seq_len)
368
+
369
+ query_states, key_states = apply_rotary_pos_emb(query_states, key_states, cos, sin, position_ids)
370
+
371
+ if past_key_value is not None:
372
+ cache_kwargs = {"sin": sin, "cos": cos} # Specific to RoPE models
373
+ key_states, value_states = past_key_value.update(key_states, value_states, self.layer_idx, cache_kwargs)
374
+
375
+ # repeat k/v heads if n_kv_heads < n_heads
376
+ key_states = repeat_kv(key_states, self.num_key_value_groups)
377
+ value_states = repeat_kv(value_states, self.num_key_value_groups)
378
+
379
+ attn_weights = torch.matmul(query_states, key_states.transpose(2, 3)) / math.sqrt(self.head_dim)
380
+
381
+ if attn_weights.size() != (bsz, self.num_heads, q_len, kv_seq_len):
382
+ raise ValueError(
383
+ f"Attention weights should be of size {(bsz, self.num_heads, q_len, kv_seq_len)}, but is"
384
+ f" {attn_weights.size()}"
385
+ )
386
+
387
+ if attention_mask is not None:
388
+ if attention_mask.size() != (bsz, 1, q_len, kv_seq_len):
389
+ raise ValueError(
390
+ f"Attention mask should be of size {(bsz, 1, q_len, kv_seq_len)}, but is {attention_mask.size()}"
391
+ )
392
+ attn_weights = attn_weights + attention_mask
393
+
394
+ # upcast attention to fp32
395
+ attn_weights = nn.functional.softmax(attn_weights, dim=-1, dtype=torch.float32).to(value_states.dtype)
396
+ attn_weights = nn.functional.dropout(attn_weights, p=self.attention_dropout, training=self.training)
397
+
398
+ attn_output = torch.matmul(attn_weights, value_states)
399
+
400
+ if attn_output.size() != (bsz, self.num_heads, q_len, self.head_dim):
401
+ raise ValueError(
402
+ f"`attn_output` should be of size {(bsz, self.num_heads, q_len, self.head_dim)}, but is"
403
+ f" {attn_output.size()}"
404
+ )
405
+
406
+ attn_output = attn_output.transpose(1, 2).contiguous()
407
+ attn_output = attn_output.reshape(bsz, q_len, self.hidden_size)
408
+
409
+ attn_output = self.o_proj(attn_output)
410
+
411
+ if not output_attentions:
412
+ attn_weights = None
413
+
414
+ return attn_output, attn_weights, past_key_value
415
+
416
+
417
+ class Phi3FlashAttention2(Phi3Attention):
418
+ """
419
+ Phi-3 flash attention module. This module inherits from `Phi3Attention` as the weights of the module stays
420
+ untouched. The only required change would be on the forward pass where it needs to correctly call the public API of
421
+ flash attention and deal with padding tokens in case the input contains any of them.
422
+ """
423
+
424
+ # Copied from transformers.models.llama.modeling_llama.LlamaFlashAttention2.__init__
425
+ def __init__(self, *args, **kwargs):
426
+ super().__init__(*args, **kwargs)
427
+
428
+ # TODO: Should be removed once Flash Attention for RoCm is bumped to 2.1.
429
+ # flash_attn<2.1 generates top-left aligned causal mask, while what is needed here is bottom-right alignement, that was made default for flash_attn>=2.1. This attribute is used to handle this difference. Reference: https://github.com/Dao-AILab/flash-attention/releases/tag/v2.1.0.
430
+ # Beware that with flash_attn<2.1, using q_seqlen != k_seqlen (except for the case q_seqlen == 1) produces a wrong mask (top-left).
431
+ self._flash_attn_uses_top_left_mask = not is_flash_attn_greater_or_equal_2_10()
432
+
433
+ def forward(
434
+ self,
435
+ hidden_states: torch.Tensor,
436
+ attention_mask: Optional[torch.LongTensor] = None,
437
+ position_ids: Optional[torch.LongTensor] = None,
438
+ past_key_value: Optional[Cache] = None,
439
+ output_attentions: bool = False,
440
+ use_cache: bool = False,
441
+ **kwargs,
442
+ ) -> Tuple[torch.Tensor, Optional[torch.Tensor], Optional[Tuple[torch.Tensor]]]:
443
+ # Phi3FlashAttention2 attention does not support output_attentions
444
+
445
+ if not _flash_supports_window_size:
446
+ logger.warning_once(
447
+ "The current flash attention version does not support sliding window attention. Please use `attn_implementation='eager'` or upgrade flash-attn library."
448
+ )
449
+ raise ValueError("The current flash attention version does not support sliding window attention.")
450
+
451
+ output_attentions = False
452
+
453
+ if "padding_mask" in kwargs:
454
+ warnings.warn(
455
+ "Passing `padding_mask` is deprecated and will be removed in v4.37. Please make sure use `attention_mask` instead.`"
456
+ )
457
+
458
+ # overwrite attention_mask with padding_mask
459
+ attention_mask = kwargs.pop("padding_mask")
460
+
461
+ bsz, q_len, _ = hidden_states.size()
462
+
463
+ qkv = self.qkv_proj(hidden_states)
464
+ query_pos = self.num_heads * self.head_dim
465
+ query_states = qkv[..., :query_pos]
466
+ key_states = qkv[..., query_pos : query_pos + self.num_key_value_heads * self.head_dim]
467
+ value_states = qkv[..., query_pos + self.num_key_value_heads * self.head_dim :]
468
+
469
+ # Flash attention requires the input to have the shape
470
+ # batch_size x seq_length x head_dim x hidden_dim
471
+ # therefore we just need to keep the original shape
472
+ query_states = query_states.view(bsz, q_len, self.num_heads, self.head_dim).transpose(1, 2)
473
+ key_states = key_states.view(bsz, q_len, self.num_key_value_heads, self.head_dim).transpose(1, 2)
474
+ value_states = value_states.view(bsz, q_len, self.num_key_value_heads, self.head_dim).transpose(1, 2)
475
+
476
+ kv_seq_len = key_states.shape[-2]
477
+ if past_key_value is not None:
478
+ if self.layer_idx is None:
479
+ raise ValueError(
480
+ f"The cache structure has changed since version v4.36. If you are using {self.__class__.__name__} "
481
+ "for auto-regressive decoding with k/v caching, please make sure to initialize the attention class "
482
+ "with a layer index."
483
+ )
484
+ kv_seq_len += past_key_value.get_usable_length(kv_seq_len, self.layer_idx)
485
+
486
+ # Because the input can be padded, the absolute sequence length depends on the max position id.
487
+ rotary_seq_len = max(kv_seq_len, position_ids[:, -1].max().item()) + 1
488
+ cos, sin = self.rotary_emb(value_states, position_ids, seq_len=rotary_seq_len)
489
+
490
+ query_states, key_states = apply_rotary_pos_emb(query_states, key_states, cos, sin, position_ids)
491
+
492
+ use_sliding_windows = (
493
+ _flash_supports_window_size
494
+ and getattr(self.config, "sliding_window", None) is not None
495
+ and kv_seq_len > self.config.sliding_window
496
+ )
497
+
498
+ if past_key_value is not None:
499
+ # Activate slicing cache only if the config has a value `sliding_windows` attribute
500
+ cache_has_contents = past_key_value.get_seq_length(self.layer_idx) > 0
501
+ if (
502
+ getattr(self.config, "sliding_window", None) is not None
503
+ and kv_seq_len > self.config.sliding_window
504
+ and cache_has_contents
505
+ ):
506
+ slicing_tokens = 1 - self.config.sliding_window
507
+
508
+ past_key = past_key_value[self.layer_idx][0]
509
+ past_value = past_key_value[self.layer_idx][1]
510
+
511
+ past_key = past_key[:, :, slicing_tokens:, :].contiguous()
512
+ past_value = past_value[:, :, slicing_tokens:, :].contiguous()
513
+
514
+ if past_key.shape[-2] != self.config.sliding_window - 1:
515
+ raise ValueError(
516
+ f"past key must have a shape of (`batch_size, num_heads, self.config.sliding_window-1, head_dim`), got"
517
+ f" {past_key.shape}"
518
+ )
519
+
520
+ if attention_mask is not None:
521
+ attention_mask = attention_mask[:, slicing_tokens:]
522
+ attention_mask = torch.cat([attention_mask, torch.ones_like(attention_mask[:, -1:])], dim=-1)
523
+
524
+ cache_kwargs = {"sin": sin, "cos": cos} # Specific to RoPE models
525
+ key_states, value_states = past_key_value.update(key_states, value_states, self.layer_idx, cache_kwargs)
526
+
527
+ # repeat k/v heads if n_kv_heads < n_heads
528
+ key_states = repeat_kv(key_states, self.num_key_value_groups)
529
+ value_states = repeat_kv(value_states, self.num_key_value_groups)
530
+
531
+ attn_dropout = self.attention_dropout if self.training else 0.0
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.
538
+
539
+ if query_states.dtype == torch.float32:
540
+ if torch.is_autocast_enabled():
541
+ target_dtype = torch.get_autocast_gpu_dtype()
542
+ # Handle the case where the model is quantized
543
+ elif hasattr(self.config, "_pre_quantization_dtype"):
544
+ target_dtype = self.config._pre_quantization_dtype
545
+ else:
546
+ target_dtype = self.qkv_proj.weight.dtype
547
+
548
+ logger.warning_once(
549
+ f"The input hidden states seems to be silently casted in float32, this might be related to"
550
+ f" the fact you have upcasted embedding or layer norm layers in float32. We will cast back the input in"
551
+ f" {target_dtype}."
552
+ )
553
+
554
+ query_states = query_states.to(target_dtype)
555
+ key_states = key_states.to(target_dtype)
556
+ value_states = value_states.to(target_dtype)
557
+
558
+ # Reashape to the expected shape for Flash Attention
559
+ query_states = query_states.transpose(1, 2)
560
+ key_states = key_states.transpose(1, 2)
561
+ value_states = value_states.transpose(1, 2)
562
+
563
+ attn_output = self._flash_attention_forward(
564
+ query_states,
565
+ key_states,
566
+ value_states,
567
+ attention_mask,
568
+ q_len,
569
+ dropout=attn_dropout,
570
+ use_sliding_windows=use_sliding_windows,
571
+ )
572
+
573
+ attn_output = attn_output.reshape(bsz, q_len, self.hidden_size).contiguous()
574
+ attn_output = self.o_proj(attn_output)
575
+
576
+ if not output_attentions:
577
+ attn_weights = None
578
+
579
+ return attn_output, attn_weights, past_key_value
580
+
581
+ # Copied from transformers.models.mistral.modeling_mistral.MistralFlashAttention2._flash_attention_forward
582
+ def _flash_attention_forward(
583
+ self,
584
+ query_states,
585
+ key_states,
586
+ value_states,
587
+ attention_mask,
588
+ query_length,
589
+ dropout=0.0,
590
+ softmax_scale=None,
591
+ use_sliding_windows=False,
592
+ ):
593
+ """
594
+ Calls the forward method of Flash Attention - if the input hidden states contain at least one padding token
595
+ first unpad the input, then computes the attention scores and pad the final attention scores.
596
+
597
+ Args:
598
+ query_states (`torch.Tensor`):
599
+ Input query states to be passed to Flash Attention API
600
+ key_states (`torch.Tensor`):
601
+ Input key states to be passed to Flash Attention API
602
+ value_states (`torch.Tensor`):
603
+ Input value states to be passed to Flash Attention API
604
+ attention_mask (`torch.Tensor`):
605
+ The padding mask - corresponds to a tensor of size `(batch_size, seq_len)` where 0 stands for the
606
+ position of padding tokens and 1 for the position of non-padding tokens.
607
+ dropout (`float`):
608
+ Attention dropout
609
+ softmax_scale (`float`, *optional*):
610
+ The scaling of QK^T before applying softmax. Default to 1 / sqrt(head_dim)
611
+ use_sliding_windows (`bool`, *optional*):
612
+ Whether to activate sliding window attention.
613
+ """
614
+ if not self._flash_attn_uses_top_left_mask:
615
+ causal = self.is_causal
616
+ else:
617
+ # TODO: Remove the `query_length != 1` check once Flash Attention for RoCm is bumped to 2.1. For details, please see the comment in LlamaFlashAttention2 __init__.
618
+ causal = self.is_causal and query_length != 1
619
+
620
+ # Contains at least one padding token in the sequence
621
+ if attention_mask is not None:
622
+ batch_size = query_states.shape[0]
623
+ query_states, key_states, value_states, indices_q, cu_seq_lens, max_seq_lens = self._upad_input(
624
+ query_states, key_states, value_states, attention_mask, query_length
625
+ )
626
+
627
+ cu_seqlens_q, cu_seqlens_k = cu_seq_lens
628
+ max_seqlen_in_batch_q, max_seqlen_in_batch_k = max_seq_lens
629
+
630
+ if not use_sliding_windows:
631
+ attn_output_unpad = flash_attn_varlen_func(
632
+ query_states,
633
+ key_states,
634
+ value_states,
635
+ cu_seqlens_q=cu_seqlens_q,
636
+ cu_seqlens_k=cu_seqlens_k,
637
+ max_seqlen_q=max_seqlen_in_batch_q,
638
+ max_seqlen_k=max_seqlen_in_batch_k,
639
+ dropout_p=dropout,
640
+ softmax_scale=softmax_scale,
641
+ causal=causal,
642
+ )
643
+ else:
644
+ attn_output_unpad = flash_attn_varlen_func(
645
+ query_states,
646
+ key_states,
647
+ value_states,
648
+ cu_seqlens_q=cu_seqlens_q,
649
+ cu_seqlens_k=cu_seqlens_k,
650
+ max_seqlen_q=max_seqlen_in_batch_q,
651
+ max_seqlen_k=max_seqlen_in_batch_k,
652
+ dropout_p=dropout,
653
+ softmax_scale=softmax_scale,
654
+ causal=causal,
655
+ window_size=(self.config.sliding_window, self.config.sliding_window),
656
+ )
657
+
658
+ attn_output = pad_input(attn_output_unpad, indices_q, batch_size, query_length)
659
+ else:
660
+ if not use_sliding_windows:
661
+ attn_output = flash_attn_func(
662
+ query_states,
663
+ key_states,
664
+ value_states,
665
+ dropout,
666
+ softmax_scale=softmax_scale,
667
+ causal=causal,
668
+ )
669
+ else:
670
+ attn_output = flash_attn_func(
671
+ query_states,
672
+ key_states,
673
+ value_states,
674
+ dropout,
675
+ softmax_scale=softmax_scale,
676
+ causal=causal,
677
+ window_size=(self.config.sliding_window, self.config.sliding_window),
678
+ )
679
+
680
+ return attn_output
681
+
682
+ # Copied from transformers.models.mistral.modeling_mistral.MistralFlashAttention2._upad_input
683
+ def _upad_input(self, query_layer, key_layer, value_layer, attention_mask, query_length):
684
+ batch_size, kv_seq_len, num_heads, head_dim = key_layer.shape
685
+
686
+ # On the first iteration we need to properly re-create the padding mask
687
+ # by slicing it on the proper place
688
+ if kv_seq_len != attention_mask.shape[-1]:
689
+ attention_mask_num_tokens = attention_mask.shape[-1]
690
+ attention_mask = attention_mask[:, attention_mask_num_tokens - kv_seq_len :]
691
+
692
+ indices_k, cu_seqlens_k, max_seqlen_in_batch_k = _get_unpad_data(attention_mask)
693
+
694
+ key_layer = index_first_axis(key_layer.reshape(batch_size * kv_seq_len, num_heads, head_dim), indices_k)
695
+ value_layer = index_first_axis(value_layer.reshape(batch_size * kv_seq_len, num_heads, head_dim), indices_k)
696
+
697
+ if query_length == kv_seq_len:
698
+ query_layer = index_first_axis(
699
+ query_layer.reshape(batch_size * kv_seq_len, num_heads, head_dim), indices_k
700
+ )
701
+ cu_seqlens_q = cu_seqlens_k
702
+ max_seqlen_in_batch_q = max_seqlen_in_batch_k
703
+ indices_q = indices_k
704
+ elif query_length == 1:
705
+ max_seqlen_in_batch_q = 1
706
+ cu_seqlens_q = torch.arange(
707
+ batch_size + 1, dtype=torch.int32, device=query_layer.device
708
+ ) # There is a memcpy here, that is very bad.
709
+ indices_q = cu_seqlens_q[:-1]
710
+ query_layer = query_layer.squeeze(1)
711
+ else:
712
+ # The -q_len: slice assumes left padding.
713
+ attention_mask = attention_mask[:, -query_length:]
714
+ query_layer, indices_q, cu_seqlens_q, max_seqlen_in_batch_q = unpad_input(query_layer, attention_mask)
715
+
716
+ return (
717
+ query_layer,
718
+ key_layer,
719
+ value_layer,
720
+ indices_q,
721
+ (cu_seqlens_q, cu_seqlens_k),
722
+ (max_seqlen_in_batch_q, max_seqlen_in_batch_k),
723
+ )
724
+
725
+
726
+ # copied from transformers.models.llama.modeling_llama.LlamaSdpaAttention with Llama->Phi3
727
+ # TODO @Arthur no longer copied from LLama after static cache
728
+ class Phi3SdpaAttention(Phi3Attention):
729
+ """
730
+ Phi3 attention module using torch.nn.functional.scaled_dot_product_attention. This module inherits from
731
+ `Phi3Attention` as the weights of the module stays untouched. The only changes are on the forward pass to adapt to
732
+ SDPA API.
733
+ """
734
+
735
+ # Adapted from Phi3Attention.forward
736
+ def forward(
737
+ self,
738
+ hidden_states: torch.Tensor,
739
+ attention_mask: Optional[torch.Tensor] = None,
740
+ position_ids: Optional[torch.LongTensor] = None,
741
+ past_key_value: Optional[Cache] = None,
742
+ output_attentions: bool = False,
743
+ use_cache: bool = False,
744
+ ) -> Tuple[torch.Tensor, Optional[torch.Tensor], Optional[Tuple[torch.Tensor]]]:
745
+ if output_attentions:
746
+ # TODO: Improve this warning with e.g. `model.config.attn_implementation = "manual"` once this is implemented.
747
+ logger.warning_once(
748
+ "Phi3Model is using Phi3SdpaAttention, but `torch.nn.functional.scaled_dot_product_attention` does not support `output_attentions=True`. Falling back to the manual attention implementation, "
749
+ 'but specifying the manual implementation will be required from Transformers version v5.0.0 onwards. This warning can be removed using the argument `attn_implementation="eager"` when loading the model.'
750
+ )
751
+ return super().forward(
752
+ hidden_states=hidden_states,
753
+ attention_mask=attention_mask,
754
+ position_ids=position_ids,
755
+ past_key_value=past_key_value,
756
+ output_attentions=output_attentions,
757
+ use_cache=use_cache,
758
+ )
759
+
760
+ bsz, q_len, _ = hidden_states.size()
761
+
762
+ qkv = self.qkv_proj(hidden_states)
763
+ query_pos = self.num_heads * self.head_dim
764
+ query_states = qkv[..., :query_pos]
765
+ key_states = qkv[..., query_pos : query_pos + self.num_key_value_heads * self.head_dim]
766
+ value_states = qkv[..., query_pos + self.num_key_value_heads * self.head_dim :]
767
+
768
+ query_states = query_states.view(bsz, q_len, self.num_heads, self.head_dim).transpose(1, 2)
769
+ key_states = key_states.view(bsz, q_len, self.num_key_value_heads, self.head_dim).transpose(1, 2)
770
+ value_states = value_states.view(bsz, q_len, self.num_key_value_heads, self.head_dim).transpose(1, 2)
771
+
772
+ kv_seq_len = key_states.shape[-2]
773
+ if past_key_value is not None:
774
+ kv_seq_len += past_key_value.get_usable_length(kv_seq_len, self.layer_idx)
775
+ cos, sin = self.rotary_emb(value_states, position_ids, seq_len=kv_seq_len)
776
+
777
+ query_states, key_states = apply_rotary_pos_emb(query_states, key_states, cos, sin, position_ids)
778
+
779
+ if past_key_value is not None:
780
+ cache_kwargs = {"sin": sin, "cos": cos} # Specific to RoPE models
781
+ key_states, value_states = past_key_value.update(key_states, value_states, self.layer_idx, cache_kwargs)
782
+
783
+ key_states = repeat_kv(key_states, self.num_key_value_groups)
784
+ value_states = repeat_kv(value_states, self.num_key_value_groups)
785
+
786
+ if attention_mask is not None:
787
+ if attention_mask.size() != (bsz, 1, q_len, kv_seq_len):
788
+ raise ValueError(
789
+ f"Attention mask should be of size {(bsz, 1, q_len, kv_seq_len)}, but is {attention_mask.size()}"
790
+ )
791
+
792
+ # SDPA with memory-efficient backend is currently (torch==2.1.2) bugged with non-contiguous inputs with custom attn_mask,
793
+ # Reference: https://github.com/pytorch/pytorch/issues/112577.
794
+ if query_states.device.type == "cuda" and attention_mask is not None:
795
+ query_states = query_states.contiguous()
796
+ key_states = key_states.contiguous()
797
+ value_states = value_states.contiguous()
798
+
799
+ attn_output = torch.nn.functional.scaled_dot_product_attention(
800
+ query_states,
801
+ key_states,
802
+ value_states,
803
+ attn_mask=attention_mask,
804
+ dropout_p=self.attention_dropout if self.training else 0.0,
805
+ # The q_len > 1 is necessary to match with AttentionMaskConverter.to_causal_4d that does not create a causal mask in case q_len == 1.
806
+ is_causal=self.is_causal and attention_mask is None and q_len > 1,
807
+ )
808
+
809
+ attn_output = attn_output.transpose(1, 2).contiguous()
810
+ attn_output = attn_output.view(bsz, q_len, self.hidden_size)
811
+
812
+ attn_output = self.o_proj(attn_output)
813
+
814
+ return attn_output, None, past_key_value
815
+
816
+
817
+ PHI3_ATTENTION_CLASSES = {
818
+ "eager": Phi3Attention,
819
+ "flash_attention_2": Phi3FlashAttention2,
820
+ "sdpa": Phi3SdpaAttention,
821
+ }
822
+
823
+
824
+ class Phi3DecoderLayer(nn.Module):
825
+ def __init__(self, config: Phi3VConfig, layer_idx: int):
826
+ super().__init__()
827
+
828
+ self.config = config
829
+ self.self_attn = PHI3_ATTENTION_CLASSES[config._attn_implementation](config, layer_idx=layer_idx)
830
+
831
+ self.mlp = Phi3MLP(config)
832
+ self.input_layernorm = Phi3RMSNorm(config.hidden_size, eps=config.rms_norm_eps)
833
+
834
+ self.resid_attn_dropout = nn.Dropout(config.resid_pdrop)
835
+ self.resid_mlp_dropout = nn.Dropout(config.resid_pdrop)
836
+ self.post_attention_layernorm = Phi3RMSNorm(config.hidden_size, eps=config.rms_norm_eps)
837
+
838
+ def forward(
839
+ self,
840
+ hidden_states: torch.Tensor,
841
+ attention_mask: Optional[torch.Tensor] = None,
842
+ position_ids: Optional[torch.LongTensor] = None,
843
+ past_key_value: Optional[Tuple[torch.Tensor]] = None,
844
+ output_attentions: Optional[bool] = False,
845
+ use_cache: Optional[bool] = False,
846
+ **kwargs,
847
+ ) -> Tuple[torch.FloatTensor, Optional[Tuple[torch.FloatTensor, torch.FloatTensor]]]:
848
+ if "padding_mask" in kwargs:
849
+ warnings.warn(
850
+ "Passing `padding_mask` is deprecated and will be removed in v4.37. Please make sure use `attention_mask` instead.`"
851
+ )
852
+ """
853
+ Args:
854
+ hidden_states (`torch.FloatTensor`):
855
+ input to the layer of shape `(batch, seq_len, embed_dim)`
856
+ attention_mask (`torch.FloatTensor`, *optional*): attention mask of size
857
+ `(batch, 1, tgt_len, src_len)` where padding elements are indicated by very large negative values.
858
+ position_ids (`torch.LongTensor` of shape `({0})`, *optional*):
859
+ Indices of positions of each input sequence tokens in the position embeddings. Selected in the range
860
+ `[0, config.n_positions - 1]`. [What are position IDs?](../glossary#position-ids)
861
+ output_attentions (`bool`, *optional*):
862
+ Whether or not to return the attentions tensors of all attention layers. See `attentions` under
863
+ returned tensors for more detail.
864
+ use_cache (`bool`, *optional*):
865
+ If set to `True`, `past_key_values` key value states are returned and can be used to speed up decoding
866
+ (see `past_key_values`).
867
+ past_key_value (`Tuple(torch.FloatTensor)`, *optional*): cached past key and value projection states
868
+ """
869
+
870
+ residual = hidden_states
871
+
872
+ hidden_states = self.input_layernorm(hidden_states)
873
+
874
+ # Self Attention
875
+ attn_outputs, self_attn_weights, present_key_value = self.self_attn(
876
+ hidden_states=hidden_states,
877
+ attention_mask=attention_mask,
878
+ position_ids=position_ids,
879
+ past_key_value=past_key_value,
880
+ output_attentions=output_attentions,
881
+ use_cache=use_cache,
882
+ )
883
+
884
+ hidden_states = residual + self.resid_attn_dropout(attn_outputs)
885
+
886
+ residual = hidden_states
887
+ hidden_states = self.post_attention_layernorm(hidden_states)
888
+ hidden_states = self.mlp(hidden_states)
889
+ hidden_states = residual + self.resid_mlp_dropout(hidden_states)
890
+
891
+ outputs = (hidden_states,)
892
+
893
+ if output_attentions:
894
+ outputs += (self_attn_weights,)
895
+
896
+ if use_cache:
897
+ outputs += (present_key_value,)
898
+
899
+ return outputs
900
+
901
+
902
+ PHI3V_START_DOCSTRING = r"""
903
+ This model inherits from [`PreTrainedModel`]. Check the superclass documentation for the generic methods the
904
+ library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
905
+ etc.)
906
+
907
+ This model is also a PyTorch [torch.nn.Module](https://pytorch.org/docs/stable/nn.html#torch.nn.Module) subclass.
908
+ Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
909
+ and behavior.
910
+
911
+ Parameters:
912
+ config ([`Phi3VConfig`]):
913
+ Model configuration class with all the parameters of the model. Initializing with a config file does not
914
+ load the weights associated with the model, only the configuration. Check out the
915
+ [`~PreTrainedModel.from_pretrained`] method to load the model weights.
916
+ """
917
+
918
+
919
+ @add_start_docstrings(
920
+ "The bare Phi-3-V model outputting raw hidden-states without any specific head on top.",
921
+ PHI3V_START_DOCSTRING,
922
+ )
923
+ class Phi3VPreTrainedModel(PreTrainedModel):
924
+ config_class = Phi3VConfig
925
+ base_model_prefix = "model"
926
+ supports_gradient_checkpointing = True
927
+ _no_split_modules = ["Phi3DecoderLayer"]
928
+ _skip_keys_device_placement = "past_key_values"
929
+ _supports_flash_attn_2 = True
930
+ _supports_sdpa = False
931
+ _supports_cache_class = True
932
+
933
+ _version = "0.0.5"
934
+
935
+ def _init_weights(self, module):
936
+ std = self.config.initializer_range
937
+ if isinstance(module, nn.Linear):
938
+ module.weight.data.normal_(mean=0.0, std=std)
939
+ if module.bias is not None:
940
+ module.bias.data.zero_()
941
+ elif isinstance(module, nn.Embedding):
942
+ module.weight.data.normal_(mean=0.0, std=std)
943
+ if module.padding_idx is not None:
944
+ module.weight.data[module.padding_idx].zero_()
945
+
946
+
947
+ PHI3V_INPUTS_DOCSTRING = r"""
948
+ Args:
949
+ input_ids (`torch.LongTensor` of shape `(batch_size, sequence_length)`):
950
+ Indices of input sequence tokens in the vocabulary. Padding will be ignored by default should you provide
951
+ it.
952
+
953
+ Indices can be obtained using [`AutoTokenizer`]. See [`PreTrainedTokenizer.encode`] and
954
+ [`PreTrainedTokenizer.__call__`] for details.
955
+
956
+ [What are input IDs?](../glossary#input-ids)
957
+ attention_mask (`torch.Tensor` of shape `(batch_size, sequence_length)`, *optional*):
958
+ Mask to avoid performing attention on padding token indices. Mask values selected in `[0, 1]`:
959
+
960
+ - 1 for tokens that are **not masked**,
961
+ - 0 for tokens that are **masked**.
962
+
963
+ [What are attention masks?](../glossary#attention-mask)
964
+
965
+ Indices can be obtained using [`AutoTokenizer`]. See [`PreTrainedTokenizer.encode`] and
966
+ [`PreTrainedTokenizer.__call__`] for details.
967
+
968
+ If `past_key_values` is used, optionally only the last `input_ids` have to be input (see
969
+ `past_key_values`).
970
+
971
+ If you want to change padding behavior, you should read [`modeling_opt._prepare_decoder_attention_mask`]
972
+ and modify to your needs. See diagram 1 in [the paper](https://arxiv.org/abs/1910.13461) for more
973
+ information on the default strategy.
974
+
975
+ - 1 indicates the head is **not masked**,
976
+ - 0 indicates the head is **masked**.
977
+ position_ids (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *optional*):
978
+ Indices of positions of each input sequence tokens in the position embeddings. Selected in the range `[0,
979
+ config.n_positions - 1]`.
980
+
981
+ [What are position IDs?](../glossary#position-ids)
982
+ past_key_values (`Cache` or `tuple(tuple(torch.FloatTensor))`, *optional*):
983
+ Pre-computed hidden-states (key and values in the self-attention blocks and in the cross-attention
984
+ blocks) that can be used to speed up sequential decoding. This typically consists in the `past_key_values`
985
+ returned by the model at a previous stage of decoding, when `use_cache=True` or `config.use_cache=True`.
986
+
987
+ Two formats are allowed:
988
+ - a [`~cache_utils.Cache`] instance;
989
+ - Tuple of `tuple(torch.FloatTensor)` of length `config.n_layers`, with each tuple having 2 tensors of
990
+ shape `(batch_size, num_heads, sequence_length, embed_size_per_head)`). This is also known as the legacy
991
+ cache format.
992
+
993
+ The model will output the same cache format that is fed as input. If no `past_key_values` are passed, the
994
+ legacy cache format will be returned.
995
+
996
+ If `past_key_values` are used, the user can optionally input only the last `input_ids` (those that don't
997
+ have their past key value states given to this model) of shape `(batch_size, 1)` instead of all `input_ids`
998
+ of shape `(batch_size, sequence_length)`.
999
+ inputs_embeds (`torch.FloatTensor` of shape `(batch_size, sequence_length, hidden_size)`, *optional*):
1000
+ Optionally, instead of passing `input_ids` you can choose to directly pass an embedded representation. This
1001
+ is useful if you want more control over how to convert `input_ids` indices into associated vectors than the
1002
+ model's internal embedding lookup matrix.
1003
+ pixel_values (`torch.FloatTensor` of shape `(batch_size, num_channels, image_size, image_size)):
1004
+ The tensors corresponding to the input images. Pixel values can be obtained using [`AutoImageProcessor`].
1005
+ See [`Phi3ImageProcessor.__call__`] for details.
1006
+ image_sizes (`torch.LongTensor` of shape `(batch_size, 2)`, *optional*):
1007
+ The sizes of the images in the batch, being (height, width) for each image.
1008
+ use_cache (`bool`, *optional*):
1009
+ If set to `True`, `past_key_values` key value states are returned and can be used to speed up decoding (see
1010
+ `past_key_values`).
1011
+ output_attentions (`bool`, *optional*):
1012
+ Whether or not to return the attentions tensors of all attention layers. See `attentions` under returned
1013
+ tensors for more detail.
1014
+ output_hidden_states (`bool`, *optional*):
1015
+ Whether or not to return the hidden states of all layers. See `hidden_states` under returned tensors for
1016
+ more detail.
1017
+ return_dict (`bool`, *optional*):
1018
+ Whether or not to return a [`~utils.ModelOutput`] instead of a plain tuple.
1019
+ """
1020
+
1021
+
1022
+ @add_start_docstrings(
1023
+ "The bare Phi-3-V model outputting raw hidden-states without any specific head on top.",
1024
+ PHI3V_START_DOCSTRING,
1025
+ )
1026
+ class Phi3VModel(Phi3VPreTrainedModel):
1027
+ """
1028
+ Transformer decoder consisting of *config.num_hidden_layers* layers. Each layer is a [`Phi3DecoderLayer`]
1029
+
1030
+ Args:
1031
+ config: Phi3Config
1032
+ """
1033
+
1034
+ def __init__(self, config: Phi3VConfig):
1035
+ super().__init__(config)
1036
+ self.padding_idx = config.pad_token_id
1037
+ self.vocab_size = config.vocab_size
1038
+
1039
+ self.embed_tokens = nn.Embedding(config.vocab_size, config.hidden_size, self.padding_idx)
1040
+ self.embed_dropout = nn.Dropout(config.embd_pdrop)
1041
+
1042
+ self.vision_embed_tokens = None
1043
+ if isinstance(config.embd_layer, dict):
1044
+ # vision embedding layer
1045
+ embedding_config = {
1046
+ 'embedding_cls': config.embd_layer['embedding_cls'],
1047
+ **config.embd_layer
1048
+ }
1049
+ self.vision_embed_tokens = Phi3ImageEmbedding(config, wte=self.embed_tokens, **embedding_config)
1050
+ # # set wte the same for vision embedding
1051
+ # self.vision_embed_tokens.wte.weight = self.embed_tokens.weight
1052
+
1053
+ self.layers = nn.ModuleList(
1054
+ [Phi3DecoderLayer(config, layer_idx) for layer_idx in range(config.num_hidden_layers)]
1055
+ )
1056
+ self._attn_implementation = config._attn_implementation
1057
+ self.norm = Phi3RMSNorm(config.hidden_size, eps=config.rms_norm_eps)
1058
+
1059
+ self.gradient_checkpointing = False
1060
+ # Initialize weights and apply final processing
1061
+ self.post_init()
1062
+
1063
+ def get_input_embeddings(self):
1064
+ return self.embed_tokens
1065
+
1066
+ def set_input_embeddings(self, value):
1067
+ self.embed_tokens = value
1068
+
1069
+ @add_start_docstrings_to_model_forward(PHI3V_INPUTS_DOCSTRING)
1070
+ def forward(
1071
+ self,
1072
+ input_ids: torch.LongTensor = None,
1073
+ attention_mask: Optional[torch.Tensor] = None,
1074
+ position_ids: Optional[torch.LongTensor] = None,
1075
+ past_key_values: Optional[List[torch.FloatTensor]] = None,
1076
+ inputs_embeds: Optional[torch.FloatTensor] = None,
1077
+ pixel_values: Optional[torch.FloatTensor] = None,
1078
+ image_sizes: Optional[torch.LongTensor] = None,
1079
+ use_cache: Optional[bool] = None,
1080
+ output_attentions: Optional[bool] = None,
1081
+ output_hidden_states: Optional[bool] = None,
1082
+ return_dict: Optional[bool] = None,
1083
+ ) -> Union[Tuple, BaseModelOutputWithPast]:
1084
+ output_attentions = output_attentions if output_attentions is not None else self.config.output_attentions
1085
+ output_hidden_states = (
1086
+ output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
1087
+ )
1088
+ use_cache = use_cache if use_cache is not None else self.config.use_cache
1089
+
1090
+ return_dict = return_dict if return_dict is not None else self.config.use_return_dict
1091
+
1092
+ # retrieve input_ids and inputs_embeds
1093
+ if input_ids is not None and inputs_embeds is not None:
1094
+ raise ValueError("You cannot specify both input_ids and inputs_embeds at the same time")
1095
+ elif input_ids is not None:
1096
+ batch_size, seq_length = input_ids.shape[:2]
1097
+ elif inputs_embeds is not None:
1098
+ batch_size, seq_length = inputs_embeds.shape[:2]
1099
+ else:
1100
+ raise ValueError("You have to specify either input_ids or inputs_embeds")
1101
+
1102
+ past_key_values_length = 0
1103
+
1104
+ if self.gradient_checkpointing and self.training:
1105
+ if use_cache:
1106
+ logger.warning_once(
1107
+ "`use_cache=True` is incompatible with gradient checkpointing. Setting `use_cache=False`..."
1108
+ )
1109
+ use_cache = False
1110
+
1111
+ if use_cache:
1112
+ use_legacy_cache = not isinstance(past_key_values, Cache)
1113
+ if use_legacy_cache:
1114
+ past_key_values = DynamicCache.from_legacy_cache(past_key_values)
1115
+ past_key_values_length = past_key_values.get_usable_length(seq_length)
1116
+
1117
+ if position_ids is None:
1118
+ device = input_ids.device if input_ids is not None else inputs_embeds.device
1119
+ position_ids = torch.arange(
1120
+ past_key_values_length, seq_length + past_key_values_length, dtype=torch.long, device=device
1121
+ )
1122
+ position_ids = position_ids.unsqueeze(0).view(-1, seq_length)
1123
+ else:
1124
+ position_ids = position_ids.view(-1, seq_length).long()
1125
+
1126
+ if inputs_embeds is None:
1127
+ if pixel_values is not None and image_sizes is not None:
1128
+ assert self.vision_embed_tokens is not None, "Vision embedding layer is not defined"
1129
+ inputs_embeds = self.vision_embed_tokens(input_ids, pixel_values=pixel_values, image_sizes=image_sizes)
1130
+ else:
1131
+ inputs_embeds = self.embed_tokens(input_ids)
1132
+
1133
+ if attention_mask is not None and self._attn_implementation == "flash_attention_2" and use_cache:
1134
+ is_padding_right = attention_mask[:, -1].sum().item() != batch_size
1135
+ if is_padding_right:
1136
+ raise ValueError(
1137
+ "You are attempting to perform batched generation with padding_side='right'"
1138
+ " this may lead to unexpected behaviour for Flash Attention version of Phi3. Make sure to "
1139
+ " call `tokenizer.padding_side = 'left'` before tokenizing the input. "
1140
+ )
1141
+
1142
+ if self._attn_implementation == "flash_attention_2":
1143
+ # 2d mask is passed through the layers
1144
+ attention_mask = attention_mask if (attention_mask is not None and 0 in attention_mask) else None
1145
+ else:
1146
+ # 4d mask is passed through the layers
1147
+ attention_mask = _prepare_4d_causal_attention_mask(
1148
+ attention_mask,
1149
+ (batch_size, seq_length),
1150
+ inputs_embeds,
1151
+ past_key_values_length,
1152
+ sliding_window=self.config.sliding_window,
1153
+ )
1154
+
1155
+ hidden_states = inputs_embeds
1156
+
1157
+ # decoder layers
1158
+ all_hidden_states = () if output_hidden_states else None
1159
+ all_self_attns = () if output_attentions else None
1160
+ next_decoder_cache = None
1161
+
1162
+ for decoder_layer in self.layers:
1163
+ if output_hidden_states:
1164
+ all_hidden_states += (hidden_states,)
1165
+
1166
+ if self.gradient_checkpointing and self.training:
1167
+ layer_outputs = self._gradient_checkpointing_func(
1168
+ decoder_layer.__call__,
1169
+ hidden_states,
1170
+ attention_mask,
1171
+ position_ids,
1172
+ past_key_values,
1173
+ output_attentions,
1174
+ use_cache,
1175
+ )
1176
+ else:
1177
+ layer_outputs = decoder_layer(
1178
+ hidden_states,
1179
+ attention_mask=attention_mask,
1180
+ position_ids=position_ids,
1181
+ past_key_value=past_key_values,
1182
+ output_attentions=output_attentions,
1183
+ use_cache=use_cache,
1184
+ )
1185
+
1186
+ hidden_states = layer_outputs[0]
1187
+
1188
+ if use_cache:
1189
+ next_decoder_cache = layer_outputs[2 if output_attentions else 1]
1190
+
1191
+ if output_attentions:
1192
+ all_self_attns += (layer_outputs[1],)
1193
+
1194
+ hidden_states = self.norm(hidden_states)
1195
+
1196
+ # add hidden states from the last decoder layer
1197
+ if output_hidden_states:
1198
+ all_hidden_states += (hidden_states,)
1199
+
1200
+ next_cache = None
1201
+ if use_cache:
1202
+ next_cache = next_decoder_cache.to_legacy_cache() if use_legacy_cache else next_decoder_cache
1203
+ if not return_dict:
1204
+ return tuple(v for v in [hidden_states, next_cache, all_hidden_states, all_self_attns] if v is not None)
1205
+ return BaseModelOutputWithPast(
1206
+ last_hidden_state=hidden_states,
1207
+ past_key_values=next_cache,
1208
+ hidden_states=all_hidden_states,
1209
+ attentions=all_self_attns,
1210
+ )
1211
+
1212
+
1213
+ class Phi3VForCausalLM(Phi3VPreTrainedModel):
1214
+ _tied_weights_keys = ["lm_head.weight"]
1215
+
1216
+ # Copied from transformers.models.llama.modeling_llama.LlamaForCausalLM.__init__ with Llama->Phi3
1217
+ def __init__(self, config):
1218
+ super().__init__(config)
1219
+ self.model = Phi3VModel(config)
1220
+ self.vocab_size = config.vocab_size
1221
+ self.lm_head = nn.Linear(config.hidden_size, config.vocab_size, bias=False)
1222
+
1223
+ # Initialize weights and apply final processing
1224
+ self.post_init()
1225
+
1226
+ # Copied from transformers.models.llama.modeling_llama.LlamaForCausalLM.get_input_embeddings
1227
+ def get_input_embeddings(self):
1228
+ return self.model.embed_tokens
1229
+
1230
+ # Copied from transformers.models.llama.modeling_llama.LlamaForCausalLM.set_input_embeddings
1231
+ def set_input_embeddings(self, value):
1232
+ self.model.embed_tokens = value
1233
+
1234
+ # Copied from transformers.models.llama.modeling_llama.LlamaForCausalLM.get_output_embeddings
1235
+ def get_output_embeddings(self):
1236
+ return self.lm_head
1237
+
1238
+ # Copied from transformers.models.llama.modeling_llama.LlamaForCausalLM.set_output_embeddings
1239
+ def set_output_embeddings(self, new_embeddings):
1240
+ self.lm_head = new_embeddings
1241
+
1242
+ # Copied from transformers.models.llama.modeling_llama.LlamaForCausalLM.set_decoder
1243
+ def set_decoder(self, decoder):
1244
+ self.model = decoder
1245
+
1246
+ # Copied from transformers.models.llama.modeling_llama.LlamaForCausalLM.get_decoder
1247
+ def get_decoder(self):
1248
+ return self.model
1249
+
1250
+ # Ignore copy
1251
+ @add_start_docstrings_to_model_forward(PHI3V_INPUTS_DOCSTRING)
1252
+ @replace_return_docstrings(output_type=CausalLMOutputWithPast, config_class=_CONFIG_FOR_DOC)
1253
+ def forward(
1254
+ self,
1255
+ input_ids: torch.LongTensor = None,
1256
+ attention_mask: Optional[torch.Tensor] = None,
1257
+ position_ids: Optional[torch.LongTensor] = None,
1258
+ past_key_values: Optional[List[torch.FloatTensor]] = None,
1259
+ inputs_embeds: Optional[torch.FloatTensor] = None,
1260
+ pixel_values: Optional[torch.FloatTensor] = None,
1261
+ image_sizes: Optional[torch.LongTensor] = None,
1262
+ labels: Optional[torch.LongTensor] = None,
1263
+ use_cache: Optional[bool] = None,
1264
+ output_attentions: Optional[bool] = None,
1265
+ output_hidden_states: Optional[bool] = None,
1266
+ return_dict: Optional[bool] = None,
1267
+ ) -> Union[Tuple, CausalLMOutputWithPast]:
1268
+ r"""
1269
+ Args:
1270
+ labels (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *optional*):
1271
+ Labels for computing the masked language modeling loss. Indices should either be in `[0, ...,
1272
+ config.vocab_size]` or -100 (see `input_ids` docstring). Tokens with indices set to `-100` are ignored
1273
+ (masked), the loss is only computed for the tokens with labels in `[0, ..., config.vocab_size]`.
1274
+
1275
+ Returns:
1276
+
1277
+ Example:
1278
+
1279
+ ```python
1280
+ >>> from transformers import AutoTokenizer, Phi3ForCausalLM
1281
+
1282
+ >>> model = Phi3ForCausalLM.from_pretrained("microsoft/phi-3-mini-4k-instruct")
1283
+ >>> tokenizer = AutoTokenizer.from_pretrained("microsoft/phi-3-mini-4k-instruct")
1284
+
1285
+ >>> prompt = "This is an example script ."
1286
+ >>> inputs = tokenizer(prompt, return_tensors="pt")
1287
+
1288
+ >>> # Generate
1289
+ >>> generate_ids = model.generate(inputs.input_ids, max_length=30)
1290
+ >>> tokenizer.batch_decode(generate_ids, skip_special_tokens=True, clean_up_tokenization_spaces=False)[0]
1291
+ 'This is an example script .\n Certainly! Below is a sample script that demonstrates a simple task, such as calculating the sum'
1292
+ ```"""
1293
+
1294
+ output_attentions = output_attentions if output_attentions is not None else self.config.output_attentions
1295
+ output_hidden_states = (
1296
+ output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
1297
+ )
1298
+ return_dict = return_dict if return_dict is not None else self.config.use_return_dict
1299
+
1300
+ # decoder outputs consists of (dec_features, layer_state, dec_hidden, dec_attn)
1301
+ outputs = self.model(
1302
+ input_ids=input_ids,
1303
+ attention_mask=attention_mask,
1304
+ position_ids=position_ids,
1305
+ past_key_values=past_key_values,
1306
+ inputs_embeds=inputs_embeds,
1307
+ pixel_values=pixel_values,
1308
+ image_sizes=image_sizes,
1309
+ use_cache=use_cache,
1310
+ output_attentions=output_attentions,
1311
+ output_hidden_states=output_hidden_states,
1312
+ return_dict=return_dict,
1313
+ )
1314
+
1315
+ hidden_states = outputs[0]
1316
+ logits = self.lm_head(hidden_states)
1317
+ logits = logits.float()
1318
+
1319
+ loss = None
1320
+ if labels is not None:
1321
+ # Shift so that tokens < n predict n
1322
+ shift_logits = logits[..., :-1, :].contiguous()
1323
+ shift_labels = labels[..., 1:].contiguous()
1324
+ # Flatten the tokens
1325
+ loss_fct = CrossEntropyLoss()
1326
+ shift_logits = shift_logits.view(-1, self.config.vocab_size)
1327
+ shift_labels = shift_labels.view(-1)
1328
+ # Enable model parallelism
1329
+ shift_labels = shift_labels.to(shift_logits.device)
1330
+ loss = loss_fct(shift_logits, shift_labels)
1331
+
1332
+ if not return_dict:
1333
+ output = (logits,) + outputs[1:]
1334
+ return (loss,) + output if loss is not None else output
1335
+
1336
+ return CausalLMOutputWithPast(
1337
+ loss=loss,
1338
+ logits=logits,
1339
+ past_key_values=outputs.past_key_values,
1340
+ hidden_states=outputs.hidden_states,
1341
+ attentions=outputs.attentions,
1342
+ )
1343
+
1344
+ # Copied from transformers.models.persimmon.modeling_persimmon.PersimmonForCausalLM.prepare_inputs_for_generation
1345
+ def prepare_inputs_for_generation(
1346
+ self, input_ids, past_key_values=None, attention_mask=None, inputs_embeds=None, pixel_values=None, image_sizes=None, **kwargs
1347
+ ):
1348
+ if past_key_values is not None:
1349
+ if isinstance(past_key_values, Cache):
1350
+ cache_length = past_key_values.get_seq_length()
1351
+ past_length = past_key_values.seen_tokens
1352
+ max_cache_length = past_key_values.get_max_length()
1353
+ else:
1354
+ cache_length = past_length = past_key_values[0][0].shape[2]
1355
+ max_cache_length = None
1356
+
1357
+ # Keep only the unprocessed tokens:
1358
+ # 1 - If the length of the attention_mask exceeds the length of input_ids, then we are in a setting where
1359
+ # some of the inputs are exclusively passed as part of the cache (e.g. when passing input_embeds as
1360
+ # input)
1361
+ if attention_mask is not None and attention_mask.shape[1] > input_ids.shape[1]:
1362
+ input_ids = input_ids[:, -(attention_mask.shape[1] - past_length) :]
1363
+ # 2 - If the past_length is smaller than input_ids', then input_ids holds all input tokens. We can discard
1364
+ # input_ids based on the past_length.
1365
+ elif past_length < input_ids.shape[1]:
1366
+ input_ids = input_ids[:, past_length:]
1367
+ # 3 - Otherwise (past_length >= input_ids.shape[1]), let's assume input_ids only has unprocessed tokens.
1368
+
1369
+ # If we are about to go beyond the maximum cache length, we need to crop the input attention mask.
1370
+ if (
1371
+ max_cache_length is not None
1372
+ and attention_mask is not None
1373
+ and cache_length + input_ids.shape[1] > max_cache_length
1374
+ ):
1375
+ attention_mask = attention_mask[:, -max_cache_length:]
1376
+
1377
+ position_ids = kwargs.get("position_ids", None)
1378
+ if attention_mask is not None and position_ids is None:
1379
+ # create position_ids on the fly for batch generation
1380
+ position_ids = attention_mask.long().cumsum(-1) - 1
1381
+ position_ids.masked_fill_(attention_mask == 0, 1)
1382
+ if past_key_values:
1383
+ position_ids = position_ids[:, -input_ids.shape[1] :]
1384
+
1385
+ # if `inputs_embeds` are passed, we only want to use them in the 1st generation step
1386
+ if inputs_embeds is not None and past_key_values is None:
1387
+ model_inputs = {"inputs_embeds": inputs_embeds}
1388
+ else:
1389
+ model_inputs = {"input_ids": input_ids}
1390
+
1391
+ model_inputs.update(
1392
+ {
1393
+ "position_ids": position_ids,
1394
+ "past_key_values": past_key_values,
1395
+ "use_cache": kwargs.get("use_cache"),
1396
+ "attention_mask": attention_mask,
1397
+ "pixel_values": pixel_values,
1398
+ "image_sizes": image_sizes,
1399
+ }
1400
+ )
1401
+ return model_inputs
1402
+
1403
+ @staticmethod
1404
+ # Copied from transformers.models.llama.modeling_llama.LlamaForCausalLM._reorder_cache
1405
+ def _reorder_cache(past_key_values, beam_idx):
1406
+ reordered_past = ()
1407
+ for layer_past in past_key_values:
1408
+ reordered_past += (
1409
+ tuple(past_state.index_select(0, beam_idx.to(past_state.device)) for past_state in layer_past),
1410
+ )
1411
+ return reordered_past
1412
+
1413
+
1414
+ @add_start_docstrings(
1415
+ """
1416
+ The [`Phi3VModel`] with a sequence classification head on top (linear layer).
1417
+
1418
+ [`Phi3VForSequenceClassification`] uses the last token in order to do the classification, as other causal models
1419
+ (e.g. GPT-2) do.
1420
+
1421
+ Since it does classification on the last token, it requires to know the position of the last token. If a
1422
+ `pad_token_id` is defined in the configuration, it finds the last token that is not a padding token in each row. If
1423
+ no `pad_token_id` is defined, it simply takes the last value in each row of the batch. Since it cannot guess the
1424
+ padding tokens when `inputs_embeds` are passed instead of `input_ids`, it does the same (take the last value in
1425
+ each row of the batch).
1426
+ """,
1427
+ PHI3V_START_DOCSTRING,
1428
+ )
1429
+ # Copied from transformers.models.llama.modeling_llama.LlamaForSequenceClassification with Llama->Phi3, LLAMA->PHI3, self.transformer->self.model, transformer_outputs->model_outputs
1430
+ class Phi3VForSequenceClassification(Phi3VPreTrainedModel):
1431
+ def __init__(self, config):
1432
+ super().__init__(config)
1433
+ self.num_labels = config.num_labels
1434
+ self.model = Phi3VModel(config)
1435
+ self.score = nn.Linear(config.hidden_size, self.num_labels, bias=False)
1436
+
1437
+ # Initialize weights and apply final processing
1438
+ self.post_init()
1439
+
1440
+ def get_input_embeddings(self):
1441
+ return self.model.embed_tokens
1442
+
1443
+ def set_input_embeddings(self, value):
1444
+ self.model.embed_tokens = value
1445
+
1446
+ @add_start_docstrings_to_model_forward(PHI3V_INPUTS_DOCSTRING)
1447
+ def forward(
1448
+ self,
1449
+ input_ids: torch.LongTensor = None,
1450
+ attention_mask: Optional[torch.Tensor] = None,
1451
+ position_ids: Optional[torch.LongTensor] = None,
1452
+ past_key_values: Optional[Union[Cache, List[torch.FloatTensor]]] = None,
1453
+ inputs_embeds: Optional[torch.FloatTensor] = None,
1454
+ pixel_values: Optional[torch.FloatTensor] = None,
1455
+ image_sizes: Optional[torch.LongTensor] = None,
1456
+ labels: Optional[torch.LongTensor] = None,
1457
+ use_cache: Optional[bool] = None,
1458
+ output_attentions: Optional[bool] = None,
1459
+ output_hidden_states: Optional[bool] = None,
1460
+ return_dict: Optional[bool] = None,
1461
+ ) -> Union[Tuple, SequenceClassifierOutputWithPast]:
1462
+ r"""
1463
+ labels (`torch.LongTensor` of shape `(batch_size,)`, *optional*):
1464
+ Labels for computing the sequence classification/regression loss. Indices should be in `[0, ...,
1465
+ config.num_labels - 1]`. If `config.num_labels == 1` a regression loss is computed (Mean-Square loss), If
1466
+ `config.num_labels > 1` a classification loss is computed (Cross-Entropy).
1467
+ """
1468
+ return_dict = return_dict if return_dict is not None else self.config.use_return_dict
1469
+
1470
+ model_outputs = self.model(
1471
+ input_ids,
1472
+ attention_mask=attention_mask,
1473
+ position_ids=position_ids,
1474
+ past_key_values=past_key_values,
1475
+ inputs_embeds=inputs_embeds,
1476
+ pixel_values=pixel_values,
1477
+ image_sizes=image_sizes,
1478
+ use_cache=use_cache,
1479
+ output_attentions=output_attentions,
1480
+ output_hidden_states=output_hidden_states,
1481
+ return_dict=return_dict,
1482
+ )
1483
+ hidden_states = model_outputs[0]
1484
+ logits = self.score(hidden_states)
1485
+
1486
+ if input_ids is not None:
1487
+ batch_size = input_ids.shape[0]
1488
+ else:
1489
+ batch_size = inputs_embeds.shape[0]
1490
+
1491
+ if self.config.pad_token_id is None and batch_size != 1:
1492
+ raise ValueError("Cannot handle batch sizes > 1 if no padding token is defined.")
1493
+ if self.config.pad_token_id is None:
1494
+ sequence_lengths = -1
1495
+ else:
1496
+ if input_ids is not None:
1497
+ # if no pad token found, use modulo instead of reverse indexing for ONNX compatibility
1498
+ sequence_lengths = torch.eq(input_ids, self.config.pad_token_id).int().argmax(-1) - 1
1499
+ sequence_lengths = sequence_lengths % input_ids.shape[-1]
1500
+ sequence_lengths = sequence_lengths.to(logits.device)
1501
+ else:
1502
+ sequence_lengths = -1
1503
+
1504
+ pooled_logits = logits[torch.arange(batch_size, device=logits.device), sequence_lengths]
1505
+
1506
+ loss = None
1507
+ if labels is not None:
1508
+ labels = labels.to(logits.device)
1509
+ if self.config.problem_type is None:
1510
+ if self.num_labels == 1:
1511
+ self.config.problem_type = "regression"
1512
+ elif self.num_labels > 1 and (labels.dtype == torch.long or labels.dtype == torch.int):
1513
+ self.config.problem_type = "single_label_classification"
1514
+ else:
1515
+ self.config.problem_type = "multi_label_classification"
1516
+
1517
+ if self.config.problem_type == "regression":
1518
+ loss_fct = MSELoss()
1519
+ if self.num_labels == 1:
1520
+ loss = loss_fct(pooled_logits.squeeze(), labels.squeeze())
1521
+ else:
1522
+ loss = loss_fct(pooled_logits, labels)
1523
+ elif self.config.problem_type == "single_label_classification":
1524
+ loss_fct = CrossEntropyLoss()
1525
+ loss = loss_fct(pooled_logits.view(-1, self.num_labels), labels.view(-1))
1526
+ elif self.config.problem_type == "multi_label_classification":
1527
+ loss_fct = BCEWithLogitsLoss()
1528
+ loss = loss_fct(pooled_logits, labels)
1529
+ if not return_dict:
1530
+ output = (pooled_logits,) + model_outputs[1:]
1531
+ return ((loss,) + output) if loss is not None else output
1532
+
1533
+ return SequenceClassifierOutputWithPast(
1534
+ loss=loss,
1535
+ logits=pooled_logits,
1536
+ past_key_values=model_outputs.past_key_values,
1537
+ hidden_states=model_outputs.hidden_states,
1538
+ attentions=model_outputs.attentions,
1539
+ )
1540
+
1541
+
1542
+ @add_start_docstrings(
1543
+ """
1544
+ [`Phi3VModel`] with a token classification head on top (a linear layer on top of the hidden-states output) e.g. for
1545
+ Named-Entity-Recognition (NER) tasks.
1546
+ """,
1547
+ PHI3V_START_DOCSTRING,
1548
+ )
1549
+ # Copied from transformers.models.mpt.modeling_mpt.MptForTokenClassification with Mpt->Phi3,MPT->PHI3,self.transformer->self.model,transformer_outputs->model_outputs
1550
+ class Phi3VForTokenClassification(Phi3VPreTrainedModel):
1551
+ def __init__(self, config: Phi3VConfig):
1552
+ super().__init__(config)
1553
+ self.num_labels = config.num_labels
1554
+
1555
+ self.model = Phi3VModel(config)
1556
+ if hasattr(config, "classifier_dropout") and config.classifier_dropout is not None:
1557
+ classifier_dropout = config.classifier_dropout
1558
+ elif hasattr(config, "hidden_dropout") and config.hidden_dropout is not None:
1559
+ classifier_dropout = config.hidden_dropout
1560
+ else:
1561
+ classifier_dropout = 0.1
1562
+ self.dropout = nn.Dropout(classifier_dropout)
1563
+ self.classifier = nn.Linear(config.hidden_size, config.num_labels)
1564
+
1565
+ # Initialize weights and apply final processing
1566
+ self.post_init()
1567
+
1568
+ @add_start_docstrings_to_model_forward(PHI3V_INPUTS_DOCSTRING)
1569
+ @add_code_sample_docstrings(
1570
+ checkpoint=_CHECKPOINT_FOR_DOC,
1571
+ output_type=TokenClassifierOutput,
1572
+ config_class=_CONFIG_FOR_DOC,
1573
+ )
1574
+ def forward(
1575
+ self,
1576
+ input_ids: Optional[torch.LongTensor] = None,
1577
+ past_key_values: Optional[Tuple[Tuple[torch.Tensor, torch.Tensor], ...]] = None,
1578
+ attention_mask: Optional[torch.Tensor] = None,
1579
+ inputs_embeds: Optional[torch.Tensor] = None,
1580
+ pixel_values: Optional[torch.FloatTensor] = None,
1581
+ image_sizes: Optional[torch.LongTensor] = None,
1582
+ labels: Optional[torch.Tensor] = None,
1583
+ use_cache: Optional[bool] = None,
1584
+ output_attentions: Optional[bool] = None,
1585
+ output_hidden_states: Optional[bool] = None,
1586
+ return_dict: Optional[bool] = None,
1587
+ **deprecated_arguments,
1588
+ ) -> Union[Tuple[torch.Tensor], TokenClassifierOutput]:
1589
+ r"""
1590
+ labels (`torch.LongTensor` of shape `(batch_size,)`, *optional*):
1591
+ Labels for computing the sequence classification/regression loss. Indices should be in `[0, ...,
1592
+ config.num_labels - 1]`. If `config.num_labels == 1` a regression loss is computed (Mean-Square loss), If
1593
+ `config.num_labels > 1` a classification loss is computed (Cross-Entropy).
1594
+ """
1595
+ return_dict = return_dict if return_dict is not None else self.config.use_return_dict
1596
+
1597
+ model_outputs = self.model(
1598
+ input_ids,
1599
+ past_key_values=past_key_values,
1600
+ attention_mask=attention_mask,
1601
+ inputs_embeds=inputs_embeds,
1602
+ pixel_values=pixel_values,
1603
+ image_sizes=image_sizes,
1604
+ use_cache=use_cache,
1605
+ output_attentions=output_attentions,
1606
+ output_hidden_states=output_hidden_states,
1607
+ return_dict=return_dict,
1608
+ )
1609
+
1610
+ hidden_states = model_outputs[0]
1611
+ hidden_states = self.dropout(hidden_states)
1612
+ logits = self.classifier(hidden_states)
1613
+
1614
+ loss = None
1615
+ if labels is not None:
1616
+ # move labels to correct device to enable model parallelism
1617
+ labels = labels.to(logits.device)
1618
+ batch_size, seq_length = labels.shape
1619
+ loss_fct = CrossEntropyLoss()
1620
+ loss = loss_fct(
1621
+ logits.view(batch_size * seq_length, self.num_labels), labels.view(batch_size * seq_length)
1622
+ )
1623
+
1624
+ if not return_dict:
1625
+ output = (logits,) + model_outputs[2:]
1626
+ return ((loss,) + output) if loss is not None else output
1627
+
1628
+ return TokenClassifierOutput(
1629
+ loss=loss,
1630
+ logits=logits,
1631
+ hidden_states=model_outputs.hidden_states,
1632
+ attentions=model_outputs.attentions,
1633
+ )
preprocessor_config.json ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "auto_map": {
3
+ "AutoImageProcessor": "image_processing_phi3_v.Phi3VImageProcessor",
4
+ "AutoProcessor": "processing_phi3_v.Phi3VProcessor"
5
+ },
6
+ "do_convert_rgb": true,
7
+ "image_mean": [
8
+ 0.48145466,
9
+ 0.4578275,
10
+ 0.40821073
11
+ ],
12
+ "image_processor_type": "Phi3VImageProcessor",
13
+ "image_std": [
14
+ 0.26862954,
15
+ 0.26130258,
16
+ 0.27577711
17
+ ],
18
+ "num_crops": 16,
19
+ "num_img_tokens": 144,
20
+ "processor_class": "Phi3VProcessor"
21
+ }
processing_phi3_v.py ADDED
@@ -0,0 +1,217 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # coding=utf-8
2
+ # Copyright 2024 Microsoft and the HuggingFace Inc. team. All rights reserved.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+ """
17
+ Processor class for Phi3-V.
18
+ """
19
+ import re
20
+ from typing import List, Optional, Union
21
+
22
+ import torch
23
+
24
+ import transformers
25
+ from transformers.feature_extraction_utils import BatchFeature
26
+ from transformers.image_utils import ImageInput
27
+ from transformers.processing_utils import ProcessorMixin
28
+ from transformers.tokenization_utils_base import PaddingStrategy, TextInput, TruncationStrategy
29
+ from transformers.utils import TensorType
30
+ from .image_processing_phi3_v import Phi3VImageProcessor
31
+ transformers.Phi3VImageProcessor = Phi3VImageProcessor
32
+
33
+ class Phi3VProcessor(ProcessorMixin):
34
+ r"""
35
+ Constructs a Phi3-V processor which wraps a Phi3-V image processor and a LLaMa tokenizer into a single processor.
36
+
37
+ [`Phi3VProcessor`] offers all the functionalities of [`Phi3VImageProcessor`] and [`LlamaTokenizerFast`]. See the
38
+ [`~Phi3VProcessor.__call__`] and [`~Phi3VProcessor.decode`] for more information.
39
+
40
+ Args:
41
+ image_processor ([`Phi3VImageProcessor`], *optional*):
42
+ The image processor is a required input.
43
+ tokenizer ([`LlamaTokenizerFast`], *optional*):
44
+ The tokenizer is a required input.
45
+ """
46
+
47
+ attributes = ["image_processor", "tokenizer"]
48
+ image_processor_class = "Phi3VImageProcessor"
49
+ tokenizer_class = ("LlamaTokenizer", "LlamaTokenizerFast")
50
+ special_image_token = "<|image|>"
51
+
52
+ def __init__(self, image_processor, tokenizer):
53
+ self.image_processor = image_processor
54
+ self.tokenizer = tokenizer
55
+ self.num_img_tokens = image_processor.num_img_tokens
56
+ self.img_tokens = [f"<|image_{i+1}|>" for i in range(1000000)]
57
+
58
+ def __call__(
59
+ self,
60
+ text: Union[TextInput, List[TextInput]],
61
+ images: ImageInput = None,
62
+ padding: Union[bool, str, PaddingStrategy] = False,
63
+ truncation: Union[bool, str, TruncationStrategy] = None,
64
+ max_length=None,
65
+ return_tensors: Optional[Union[str, TensorType]] = TensorType.PYTORCH,
66
+ ) -> BatchFeature:
67
+ """
68
+ Main method to prepare for the model one or several sequences(s) and image(s). This method forwards the `text`
69
+ and `kwargs` arguments to LlamaTokenizerFast's [`~LlamaTokenizerFast.__call__`] if `text` is not `None` to encode
70
+ the text. To prepare the image(s), this method forwards the `images` and `kwrags` arguments to
71
+ Phi3ImageProcessor's [`~Phi3ImageProcessor.__call__`] if `images` is not `None`. Please refer to the doctsring
72
+ of the above two methods for more information.
73
+
74
+ Args:
75
+ text (`str`, `List[str]`, `List[List[str]]`):
76
+ The sequence or batch of sequences to be encoded. Each sequence can be a string or a list of strings
77
+ (pretokenized string). If the sequences are provided as list of strings (pretokenized), you must set
78
+ `is_split_into_words=True` (to lift the ambiguity with a batch of sequences).
79
+ images (`PIL.Image.Image`, `np.ndarray`, `torch.Tensor`, `List[PIL.Image.Image]`, `List[np.ndarray]`, `List[torch.Tensor]`):
80
+ The image or batch of images to be prepared. Each image can be a PIL image, NumPy array or PyTorch
81
+ tensor. Both channels-first and channels-last formats are supported.
82
+ padding (`bool`, `str` or [`~utils.PaddingStrategy`], *optional*, defaults to `False`):
83
+ Select a strategy to pad the returned sequences (according to the model's padding side and padding
84
+ index) among:
85
+ - `True` or `'longest'`: Pad to the longest sequence in the batch (or no padding if only a single
86
+ sequence if provided).
87
+ - `'max_length'`: Pad to a maximum length specified with the argument `max_length` or to the maximum
88
+ acceptable input length for the model if that argument is not provided.
89
+ - `False` or `'do_not_pad'` (default): No padding (i.e., can output a batch with sequences of different
90
+ lengths).
91
+ max_length (`int`, *optional*):
92
+ Maximum length of the returned list and optionally padding length (see above).
93
+ truncation (`bool`, *optional*):
94
+ Activates truncation to cut input sequences longer than `max_length` to `max_length`.
95
+ return_tensors (`str` or [`~utils.TensorType`], *optional*):
96
+ If set, will return tensors of a particular framework. Acceptable values are:
97
+
98
+ - `'tf'`: Return TensorFlow `tf.constant` objects.
99
+ - `'pt'`: Return PyTorch `torch.Tensor` objects.
100
+ - `'np'`: Return NumPy `np.ndarray` objects.
101
+ - `'jax'`: Return JAX `jnp.ndarray` objects.
102
+
103
+ Returns:
104
+ [`BatchFeature`]: A [`BatchFeature`] with the following fields:
105
+
106
+ - **input_ids** -- List of token ids to be fed to a model. Returned when `text` is not `None`.
107
+ - **attention_mask** -- List of indices specifying which tokens should be attended to by the model (when
108
+ `return_attention_mask=True` or if *"attention_mask"* is in `self.model_input_names` and if `text` is not
109
+ `None`).
110
+ - **pixel_values** -- Pixel values to be fed to a model. Returned when `images` is not `None`.
111
+ """
112
+ if images is not None:
113
+ image_inputs = self.image_processor(images, return_tensors=return_tensors)
114
+ else:
115
+ image_inputs = {}
116
+ inputs = self._convert_images_texts_to_inputs(image_inputs, text, padding=padding, truncation=truncation, max_length=max_length, return_tensors=return_tensors)
117
+ return inputs
118
+
119
+ def calc_num_image_tokens(self, images: ImageInput):
120
+ """ Calculate the number of image tokens for each image.
121
+ Args:
122
+ images (`ImageInput`):
123
+ Image to preprocess. Expects a single or batch of images with pixel values ranging from 0 to 255. If
124
+ passing in images with pixel values between 0 and 1, set `do_rescale=False`.
125
+ """
126
+ return self.image_processor.calc_num_image_tokens(images)
127
+
128
+ def calc_num_image_tokens_from_image_size(self, width, height):
129
+ """ Calculate the number of image token for an image with given width and height.
130
+ Args:
131
+ width (`int`):
132
+ Width of the image.
133
+ height (`int`):
134
+ Height of the image.
135
+ """
136
+ return self.image_processor.calc_num_image_tokens_from_image_size(width, height)
137
+
138
+
139
+ @property
140
+ def special_image_token_id(self):
141
+ return self.tokenizer.convert_tokens_to_ids(self.special_image_token)
142
+
143
+ def get_special_image_token_id(self):
144
+ return self.tokenizer.convert_tokens_to_ids(self.special_image_token)
145
+
146
+ def _convert_images_texts_to_inputs(self, images, texts, padding=False, truncation=None, max_length=None, return_tensors=None):
147
+
148
+ if not len(images):
149
+ model_inputs = self.tokenizer(texts, return_tensors=return_tensors, padding=padding, truncation=truncation, max_length=max_length)
150
+ return BatchFeature(data={**model_inputs})
151
+
152
+ pattern = r"<\|image_\d+\|>"
153
+ prompt_chunks = [self.tokenizer(chunk).input_ids for chunk in re.split(pattern, texts)]
154
+
155
+ if 'num_img_tokens' in images:
156
+ num_img_tokens = images['num_img_tokens']
157
+ else:
158
+ assert 'num_crops' in images, 'num_crops must be provided in images if num_img_tokens is not provided'
159
+ num_crops = images['num_crops']
160
+ num_img_tokens = [_num_crops * self.num_img_tokens for _num_crops in num_crops]
161
+
162
+ images, image_sizes = images['pixel_values'], images['image_sizes']
163
+
164
+ # image_tags needs to start from 1 to n
165
+ image_tags = re.findall(pattern, texts)
166
+ # image_ids = [int(s.split("|")[1].split("_")[-1]) * -1 for s in image_tags]
167
+ # image_ids_pad = [[iid]*num_img_tokens[i] for i, iid in enumerate(image_ids)]
168
+ image_ids = [int(s.split("|")[1].split("_")[-1]) for s in image_tags]
169
+ unique_image_ids = sorted(list(set(image_ids)))
170
+ # image_ids must start from 1, and must be continuous int, e.g. [1, 2, 3], cannot be [1, 4, 5]
171
+ # check the condition
172
+ assert unique_image_ids == list(range(1, len(unique_image_ids)+1)), f"image_ids must start from 1, and must be continuous int, e.g. [1, 2, 3], cannot be {unique_image_ids}"
173
+ # total images must be the same as the number of image tags
174
+ assert len(unique_image_ids) == len(images), f"total images must be the same as the number of image tags, got {len(unique_image_ids)} image tags and {len(images)} images"
175
+
176
+ image_ids_pad = [[-iid]*num_img_tokens[iid-1] for iid in image_ids]
177
+
178
+ def insert_separator(X, sep_list):
179
+ if len(X) > len(sep_list):
180
+ sep_list.append([])
181
+ return [ele for sublist in zip(X, sep_list) for ele in sublist]
182
+ input_ids = []
183
+ offset = 0
184
+ for x in insert_separator(prompt_chunks, image_ids_pad):
185
+ input_ids.extend(x[offset:])
186
+
187
+ input_ids = torch.tensor(input_ids, dtype=torch.long).unsqueeze(0)
188
+ attention_mask = (input_ids > -1000000).to(torch.long)
189
+
190
+ return BatchFeature(data={"input_ids": input_ids,
191
+ "attention_mask": attention_mask,
192
+ "pixel_values": images,
193
+ "image_sizes": image_sizes})
194
+
195
+
196
+ # Copied from transformers.models.clip.processing_clip.CLIPProcessor.batch_decode with CLIP->Llama
197
+ def batch_decode(self, *args, **kwargs):
198
+ """
199
+ This method forwards all its arguments to LlamaTokenizerFast's [`~PreTrainedTokenizer.batch_decode`]. Please
200
+ refer to the docstring of this method for more information.
201
+ """
202
+ return self.tokenizer.batch_decode(*args, **kwargs)
203
+
204
+ # Copied from transformers.models.clip.processing_clip.CLIPProcessor.decode with CLIP->Llama
205
+ def decode(self, *args, **kwargs):
206
+ """
207
+ This method forwards all its arguments to LlamaTokenizerFast's [`~PreTrainedTokenizer.decode`]. Please refer to
208
+ the docstring of this method for more information.
209
+ """
210
+ return self.tokenizer.decode(*args, **kwargs)
211
+
212
+ @property
213
+ # Copied from transformers.models.clip.processing_clip.CLIPProcessor.model_input_names
214
+ def model_input_names(self):
215
+ tokenizer_input_names = self.tokenizer.model_input_names
216
+ image_processor_input_names = self.image_processor.model_input_names
217
+ return list(dict.fromkeys(tokenizer_input_names + image_processor_input_names))
processor_config.json ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ {
2
+ "auto_map": {
3
+ "AutoProcessor": "processing_phi3_v.Phi3VProcessor"
4
+ },
5
+ "processor_class": "Phi3VProcessor"
6
+ }
special_tokens_map.json ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "additional_special_tokens": [
3
+ "<|system|>",
4
+ "<|end|>",
5
+ "<|user|>",
6
+ "<|end|>"
7
+ ],
8
+ "bos_token": {
9
+ "content": "<s>",
10
+ "lstrip": false,
11
+ "normalized": false,
12
+ "rstrip": false,
13
+ "single_word": false
14
+ },
15
+ "eos_token": {
16
+ "content": "<|endoftext|>",
17
+ "lstrip": false,
18
+ "normalized": false,
19
+ "rstrip": false,
20
+ "single_word": false
21
+ },
22
+ "pad_token": {
23
+ "content": "<|endoftext|>",
24
+ "lstrip": false,
25
+ "normalized": false,
26
+ "rstrip": false,
27
+ "single_word": false
28
+ },
29
+ "unk_token": {
30
+ "content": "<unk>",
31
+ "lstrip": false,
32
+ "normalized": false,
33
+ "rstrip": false,
34
+ "single_word": false
35
+ }
36
+ }
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,414 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_bos_token": true,
3
+ "add_eos_token": false,
4
+ "add_prefix_space": null,
5
+ "added_tokens_decoder": {
6
+ "0": {
7
+ "content": "<unk>",
8
+ "lstrip": false,
9
+ "normalized": false,
10
+ "rstrip": false,
11
+ "single_word": false,
12
+ "special": true
13
+ },
14
+ "1": {
15
+ "content": "<s>",
16
+ "lstrip": false,
17
+ "normalized": false,
18
+ "rstrip": false,
19
+ "single_word": false,
20
+ "special": true
21
+ },
22
+ "2": {
23
+ "content": "</s>",
24
+ "lstrip": false,
25
+ "normalized": false,
26
+ "rstrip": true,
27
+ "single_word": false,
28
+ "special": false
29
+ },
30
+ "32000": {
31
+ "content": "<|endoftext|>",
32
+ "lstrip": false,
33
+ "normalized": false,
34
+ "rstrip": false,
35
+ "single_word": false,
36
+ "special": true
37
+ },
38
+ "32001": {
39
+ "content": "<|assistant|>",
40
+ "lstrip": false,
41
+ "normalized": false,
42
+ "rstrip": true,
43
+ "single_word": false,
44
+ "special": true
45
+ },
46
+ "32002": {
47
+ "content": "<|placeholder1|>",
48
+ "lstrip": false,
49
+ "normalized": false,
50
+ "rstrip": true,
51
+ "single_word": false,
52
+ "special": true
53
+ },
54
+ "32003": {
55
+ "content": "<|placeholder2|>",
56
+ "lstrip": false,
57
+ "normalized": false,
58
+ "rstrip": true,
59
+ "single_word": false,
60
+ "special": true
61
+ },
62
+ "32004": {
63
+ "content": "<|placeholder3|>",
64
+ "lstrip": false,
65
+ "normalized": false,
66
+ "rstrip": true,
67
+ "single_word": false,
68
+ "special": true
69
+ },
70
+ "32005": {
71
+ "content": "<|placeholder4|>",
72
+ "lstrip": false,
73
+ "normalized": false,
74
+ "rstrip": true,
75
+ "single_word": false,
76
+ "special": true
77
+ },
78
+ "32006": {
79
+ "content": "<|system|>",
80
+ "lstrip": false,
81
+ "normalized": false,
82
+ "rstrip": false,
83
+ "single_word": false,
84
+ "special": true
85
+ },
86
+ "32007": {
87
+ "content": "<|end|>",
88
+ "lstrip": false,
89
+ "normalized": false,
90
+ "rstrip": false,
91
+ "single_word": false,
92
+ "special": true
93
+ },
94
+ "32008": {
95
+ "content": "<|placeholder5|>",
96
+ "lstrip": false,
97
+ "normalized": false,
98
+ "rstrip": true,
99
+ "single_word": false,
100
+ "special": true
101
+ },
102
+ "32009": {
103
+ "content": "<|placeholder6|>",
104
+ "lstrip": false,
105
+ "normalized": false,
106
+ "rstrip": true,
107
+ "single_word": false,
108
+ "special": true
109
+ },
110
+ "32010": {
111
+ "content": "<|user|>",
112
+ "lstrip": false,
113
+ "normalized": false,
114
+ "rstrip": false,
115
+ "single_word": false,
116
+ "special": true
117
+ },
118
+ "32011": {
119
+ "content": "<|placeholder7|>",
120
+ "lstrip": false,
121
+ "normalized": false,
122
+ "rstrip": true,
123
+ "single_word": false,
124
+ "special": true
125
+ },
126
+ "32012": {
127
+ "content": "<|placeholder8|>",
128
+ "lstrip": false,
129
+ "normalized": false,
130
+ "rstrip": true,
131
+ "single_word": false,
132
+ "special": true
133
+ },
134
+ "32013": {
135
+ "content": "<|placeholder9|>",
136
+ "lstrip": false,
137
+ "normalized": false,
138
+ "rstrip": true,
139
+ "single_word": false,
140
+ "special": true
141
+ },
142
+ "32014": {
143
+ "content": "<|placeholder10|>",
144
+ "lstrip": false,
145
+ "normalized": false,
146
+ "rstrip": true,
147
+ "single_word": false,
148
+ "special": true
149
+ },
150
+ "32015": {
151
+ "content": "<|placeholder11|>",
152
+ "lstrip": false,
153
+ "normalized": false,
154
+ "rstrip": true,
155
+ "single_word": false,
156
+ "special": true
157
+ },
158
+ "32016": {
159
+ "content": "<|placeholder12|>",
160
+ "lstrip": false,
161
+ "normalized": false,
162
+ "rstrip": true,
163
+ "single_word": false,
164
+ "special": true
165
+ },
166
+ "32017": {
167
+ "content": "<|placeholder13|>",
168
+ "lstrip": false,
169
+ "normalized": false,
170
+ "rstrip": true,
171
+ "single_word": false,
172
+ "special": true
173
+ },
174
+ "32018": {
175
+ "content": "<|placeholder14|>",
176
+ "lstrip": false,
177
+ "normalized": false,
178
+ "rstrip": true,
179
+ "single_word": false,
180
+ "special": true
181
+ },
182
+ "32019": {
183
+ "content": "<|placeholder15|>",
184
+ "lstrip": false,
185
+ "normalized": false,
186
+ "rstrip": true,
187
+ "single_word": false,
188
+ "special": true
189
+ },
190
+ "32020": {
191
+ "content": "<|placeholder16|>",
192
+ "lstrip": false,
193
+ "normalized": false,
194
+ "rstrip": true,
195
+ "single_word": false,
196
+ "special": true
197
+ },
198
+ "32021": {
199
+ "content": "<|placeholder17|>",
200
+ "lstrip": false,
201
+ "normalized": false,
202
+ "rstrip": true,
203
+ "single_word": false,
204
+ "special": true
205
+ },
206
+ "32022": {
207
+ "content": "<|placeholder18|>",
208
+ "lstrip": false,
209
+ "normalized": false,
210
+ "rstrip": true,
211
+ "single_word": false,
212
+ "special": true
213
+ },
214
+ "32023": {
215
+ "content": "<|placeholder19|>",
216
+ "lstrip": false,
217
+ "normalized": false,
218
+ "rstrip": true,
219
+ "single_word": false,
220
+ "special": true
221
+ },
222
+ "32024": {
223
+ "content": "<|placeholder20|>",
224
+ "lstrip": false,
225
+ "normalized": false,
226
+ "rstrip": true,
227
+ "single_word": false,
228
+ "special": true
229
+ },
230
+ "32025": {
231
+ "content": "<|placeholder21|>",
232
+ "lstrip": false,
233
+ "normalized": false,
234
+ "rstrip": true,
235
+ "single_word": false,
236
+ "special": true
237
+ },
238
+ "32026": {
239
+ "content": "<|placeholder22|>",
240
+ "lstrip": false,
241
+ "normalized": false,
242
+ "rstrip": true,
243
+ "single_word": false,
244
+ "special": true
245
+ },
246
+ "32027": {
247
+ "content": "<|placeholder23|>",
248
+ "lstrip": false,
249
+ "normalized": false,
250
+ "rstrip": true,
251
+ "single_word": false,
252
+ "special": true
253
+ },
254
+ "32028": {
255
+ "content": "<|placeholder24|>",
256
+ "lstrip": false,
257
+ "normalized": false,
258
+ "rstrip": true,
259
+ "single_word": false,
260
+ "special": true
261
+ },
262
+ "32029": {
263
+ "content": "<|placeholder25|>",
264
+ "lstrip": false,
265
+ "normalized": false,
266
+ "rstrip": true,
267
+ "single_word": false,
268
+ "special": true
269
+ },
270
+ "32030": {
271
+ "content": "<|placeholder26|>",
272
+ "lstrip": false,
273
+ "normalized": false,
274
+ "rstrip": true,
275
+ "single_word": false,
276
+ "special": true
277
+ },
278
+ "32031": {
279
+ "content": "<|placeholder27|>",
280
+ "lstrip": false,
281
+ "normalized": false,
282
+ "rstrip": true,
283
+ "single_word": false,
284
+ "special": true
285
+ },
286
+ "32032": {
287
+ "content": "<|placeholder28|>",
288
+ "lstrip": false,
289
+ "normalized": false,
290
+ "rstrip": true,
291
+ "single_word": false,
292
+ "special": true
293
+ },
294
+ "32033": {
295
+ "content": "<|placeholder29|>",
296
+ "lstrip": false,
297
+ "normalized": false,
298
+ "rstrip": true,
299
+ "single_word": false,
300
+ "special": true
301
+ },
302
+ "32034": {
303
+ "content": "<|placeholder30|>",
304
+ "lstrip": false,
305
+ "normalized": false,
306
+ "rstrip": true,
307
+ "single_word": false,
308
+ "special": true
309
+ },
310
+ "32035": {
311
+ "content": "<|placeholder31|>",
312
+ "lstrip": false,
313
+ "normalized": false,
314
+ "rstrip": true,
315
+ "single_word": false,
316
+ "special": true
317
+ },
318
+ "32036": {
319
+ "content": "<|placeholder32|>",
320
+ "lstrip": false,
321
+ "normalized": false,
322
+ "rstrip": true,
323
+ "single_word": false,
324
+ "special": true
325
+ },
326
+ "32037": {
327
+ "content": "<|placeholder33|>",
328
+ "lstrip": false,
329
+ "normalized": false,
330
+ "rstrip": true,
331
+ "single_word": false,
332
+ "special": true
333
+ },
334
+ "32038": {
335
+ "content": "<|placeholder34|>",
336
+ "lstrip": false,
337
+ "normalized": false,
338
+ "rstrip": true,
339
+ "single_word": false,
340
+ "special": true
341
+ },
342
+ "32039": {
343
+ "content": "<|placeholder35|>",
344
+ "lstrip": false,
345
+ "normalized": false,
346
+ "rstrip": true,
347
+ "single_word": false,
348
+ "special": true
349
+ },
350
+ "32040": {
351
+ "content": "<|placeholder36|>",
352
+ "lstrip": false,
353
+ "normalized": false,
354
+ "rstrip": true,
355
+ "single_word": false,
356
+ "special": true
357
+ },
358
+ "32041": {
359
+ "content": "<|placeholder37|>",
360
+ "lstrip": false,
361
+ "normalized": false,
362
+ "rstrip": true,
363
+ "single_word": false,
364
+ "special": true
365
+ },
366
+ "32042": {
367
+ "content": "<|placeholder38|>",
368
+ "lstrip": false,
369
+ "normalized": false,
370
+ "rstrip": true,
371
+ "single_word": false,
372
+ "special": true
373
+ },
374
+ "32043": {
375
+ "content": "<|placeholder39|>",
376
+ "lstrip": false,
377
+ "normalized": false,
378
+ "rstrip": true,
379
+ "single_word": false,
380
+ "special": true
381
+ },
382
+ "32044": {
383
+ "content": "<|image|>",
384
+ "lstrip": false,
385
+ "normalized": false,
386
+ "rstrip": true,
387
+ "single_word": false,
388
+ "special": true
389
+ }
390
+ },
391
+ "additional_special_tokens": [
392
+ "<|system|>",
393
+ "<|end|>",
394
+ "<|user|>",
395
+ "<|end|>"
396
+ ],
397
+ "auto_map": {
398
+ "AutoProcessor": "processing_phi3_v.Phi3VProcessor"
399
+ },
400
+ "bos_token": "<s>",
401
+ "chat_template": "{% for message in messages %}{{'<|' + message['role'] + '|>' + '\n' + message['content'] + '<|end|>\n' }}{% endfor %}{% if add_generation_prompt and messages[-1]['role'] != 'assistant' %}{{- '<|assistant|>\n' -}}{% endif %}",
402
+ "clean_up_tokenization_spaces": false,
403
+ "eos_token": "<|endoftext|>",
404
+ "legacy": false,
405
+ "model_max_length": 131072,
406
+ "num_crops": 16,
407
+ "pad_token": "<|endoftext|>",
408
+ "padding_side": "right",
409
+ "processor_class": "Phi3VProcessor",
410
+ "sp_model_kwargs": {},
411
+ "tokenizer_class": "LlamaTokenizer",
412
+ "unk_token": "<unk>",
413
+ "use_default_system_prompt": false
414
+ }
training_args.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2ee8f46092f1992296e6436db3965eec29d3fc78ab1f1a64483f86f0c811d847
3
+ size 6840