mohan007 g-h-chen commited on
Commit
c30d23e
·
verified ·
0 Parent(s):

Duplicate from FreedomIntelligence/ALLaVA-3B-Longer

Browse files

Co-authored-by: guiminghardychen <[email protected]>

.gitattributes ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.npy filter=lfs diff=lfs merge=lfs -text
15
+ *.npz filter=lfs diff=lfs merge=lfs -text
16
+ *.onnx filter=lfs diff=lfs merge=lfs -text
17
+ *.ot filter=lfs diff=lfs merge=lfs -text
18
+ *.parquet filter=lfs diff=lfs merge=lfs -text
19
+ *.pb filter=lfs diff=lfs merge=lfs -text
20
+ *.pickle filter=lfs diff=lfs merge=lfs -text
21
+ *.pkl filter=lfs diff=lfs merge=lfs -text
22
+ *.pt filter=lfs diff=lfs merge=lfs -text
23
+ *.pth filter=lfs diff=lfs merge=lfs -text
24
+ *.rar filter=lfs diff=lfs merge=lfs -text
25
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
26
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
28
+ *.tar filter=lfs diff=lfs merge=lfs -text
29
+ *.tflite filter=lfs diff=lfs merge=lfs -text
30
+ *.tgz filter=lfs diff=lfs merge=lfs -text
31
+ *.wasm filter=lfs diff=lfs merge=lfs -text
32
+ *.xz filter=lfs diff=lfs merge=lfs -text
33
+ *.zip filter=lfs diff=lfs merge=lfs -text
34
+ *.zst filter=lfs diff=lfs merge=lfs -text
35
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,135 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ datasets:
4
+ - FreedomIntelligence/ALLaVA-4V
5
+ language:
6
+ - en
7
+ pipeline_tag: text-generation
8
+ ---
9
+
10
+
11
+ # ALLaVA: Harnessing GPT4V-synthesized Data for A Lite Vision-Language Model
12
+
13
+
14
+
15
+ <p align="center">
16
+ ⚡ALLaVA is a project that provides a large-scale GPT4V-synthesized dataset for training LVLMs.⚡
17
+ </p>
18
+
19
+ <!-- <p align="center">
20
+
21
+ ![Python 3.10](https://img.shields.io/badge/Python-3.10-lightblue) ![Pytorch 1.13.0](https://img.shields.io/badge/PyTorch-2.1.1-lightblue) ![transformers](https://img.shields.io/badge/transformers-4.37.0-lightblue)
22
+ </p> -->
23
+
24
+
25
+
26
+ <p align="center">
27
+ 📃 <a href="https://arxiv.org/abs/2402.11684" target="_blank">Paper</a> • 🌐 <a href="https://allava.freedomai.cn/#/" target="_blank">Demo</a> • 👨🏻‍💻 <a href="https://github.com/FreedomIntelligence/ALLaVA" target="_blank">Github</a>
28
+ </p>
29
+ <p align="center">
30
+ 🤗 <a href="https://huggingface.co/datasets/FreedomIntelligence/ALLaVA-4V" target="_blank">ALLaVA-4V Dataset</a>
31
+ </p>
32
+
33
+ <p align="center">
34
+ 🤗 <a href="https://huggingface.co/FreedomIntelligence/ALLaVA-3B-Longer" target="_blank">ALLaVA-3B-Longer</a> • 🤗 <a href="https://huggingface.co/FreedomIntelligence/ALLaVA-3B" target="_blank">ALLaVA-3B</a>
35
+ </p>
36
+
37
+ <!-- <p align="center">
38
+ 📃 <a href="https://arxiv.org/abs/2402.11684" target="_blank">Paper</a> • 🌐 <a href="https://allava.freedomai.cn/#/" target="_blank">Demo</a> • 🤗 <a href="https://huggingface.co/datasets/FreedomIntelligence/ALLaVA-4V" target="_blank">ALLaVA-4V Dataset</a> • 🤗 <a href="https://huggingface.co/FreedomIntelligence/ALLaVA-3B-Longer" target="_blank">ALLaVA-3B-Longer</a> • 🤗 <a href="https://huggingface.co/FreedomIntelligence/ALLaVA-3B" target="_blank">ALLaVA-3B</a>
39
+ <br> <a href="https://github.com/FreedomIntelligence/CMB/blob/main/README_zh.md"> 中文</a> | <a href="https://github.com/FreedomIntelligence/CMB/blob/main/README.md"> English
40
+ </p> -->
41
+
42
+ ## Benchmark Result
43
+
44
+ Our model [**ALLaVA-3B-Longer**](https://huggingface.co/FreedomIntelligence/ALLaVA-3B-Longer) and [**ALLaVA-3B**](https://huggingface.co/FreedomIntelligence/ALLaVA-3B) achieve competitive results on 12 benchmarks. Bold numbers denote the SOTA performance among 3B-scale models.
45
+
46
+ | Model | Backbone | Vicuna-80 | MMB | SEEDBench-v1 (img) | MM-Vet | MMMU (val) | MME | TextVQA | GQA | EMT (CIFAR10) | MLLM-Bench | TouchStone | LLaVA (In-the-Wild) |
47
+ |-------|----------|-----------|-----|-------------|--------|----------|-----|------|-----|---------|----|----|--------|
48
+ | Qwen-VL-Chat | Qwen-7B | - | 60.6 | 65.4 | - | 35.9 | 1487.5 | 61.5 | 57.5 | - | 6.2 | 711.6 | - |
49
+ | LLaVA-v1.5-7B | Vicuna-7B | - | 64.3 | - | 31.1 | - | 1510.7 | 58.2 | 62.0 | - | - | | 65.4 |
50
+ | LLaVA-v1.5-13B | Vicuna-13B | 22.50 | 67.7 | 68.2 | 35.4 | 36.4 | 1531.3 | 61.3 | 63.3 | 85.0 | 7.4 | 637.7 | 70.7 |
51
+ | ShareGPT4V-7B | Vicuna-7B | - | 68.8 | 69.7 | 37.6 | - | 1943.8 | 60.4 | 63.3 | - | - | - | 72.6 |
52
+ | TinyGPT-V | Phi2-2.7B | - | - | - | - | - | - | - | 33.6 | - | - | - | - |
53
+ | MobileVLM | MobileLLaMA-2.7B | - | 59.6 | - | - | - | 1288.9 | 47.5 | - | - | - | - | - |
54
+ | LLaVA-Phi | Phi2-2.7B | - | 59.8 | - | 28.9 | - | 1335.1 | 48.6 | - | - | - | - | - |
55
+ | **ALLaVA-3B** | Phi2-2.7B | 48.8 | 64.0 | 65.2 | 32.2 | **35.3** | **1623.2** | 49.5 | 48.8 | **90.2** | 6.7 | 632.0 | 69.4 |
56
+ | **ALLaVA-3B-Longer** | Phi2-2.7B | **52.5** | **64.6** | **65.6** | **35.5** | 33.2 | 1564.6 | **50.3** | **50.0** | 85.9 | **8.8** | **636.5** | **71.7** |
57
+
58
+ The detailed information of each benchmark is shown in Table 4 of our [technical report](https://arxiv.org/pdf/2402.11684.pdf).
59
+
60
+
61
+
62
+ ## 🏭 Inference
63
+
64
+ ### Load from 🤗 (Recommended)
65
+ See the [example script](https://github.com/FreedomIntelligence/ALLaVA/blob/main/allava/serve/huggingface_inference.py).
66
+
67
+ ### CLI
68
+ See [here](https://github.com/FreedomIntelligence/ALLaVA/tree/main?tab=readme-ov-file#cli) for CLI code snippet.
69
+
70
+
71
+
72
+ ## 🏋️‍♂️ Training
73
+
74
+ ### Data
75
+ <div align=center>
76
+ <img src="training_datasets_by_stage.jpg" width = "640" alt="training_datasets" align=center />
77
+ </div>
78
+
79
+ As shown in the table, ALLaVA-3B uses 1M and 1.5M data for PT. and FT., respectively.
80
+ ALLaVA-3B-Longer trains one more epoch (i.e. 3M in total) for the FT. stage.
81
+
82
+ ### Code
83
+ The training code is largely based on [LLaVA-v1.5](https://github.com/haotian-liu/LLaVA).
84
+ We wholeheartedly express our gratitude for their invaluable contributions to open-sourcing LVLMs.
85
+
86
+ ### Cost
87
+ We train our models on 8*A800 GPUs.
88
+ [ALLaVA-3B-Longer](https://huggingface.co/FreedomIntelligence/ALLaVA-3B-Longer) takes 8.3h for PT and 21.3h for FT.
89
+ [ALLaVA-3B](https://huggingface.co/FreedomIntelligence/ALLaVA-3B) takes 8.3h for PT and 10.6h for FT.
90
+ These two models share the same PT procedure.
91
+
92
+
93
+ ### Hyperparameters
94
+
95
+ | Global Batch Size| ZeRO Stage| Optimizer | Max LR| Min LR | Scheduler | Max length | Weight decay |
96
+ | ---: | ---: |--:| ---: | ---: | ---: | ---: | ---: |
97
+ | 256 (PT) / 128 (FT) | 1| AdamW | 2e-5 | 2e-6 | CosineAnnealingWarmRestarts | 2048 | 0 |
98
+
99
+ The LM backbone, projector are trainable, while the vision encoder is kept frozen.
100
+ **The trainabilities of each module are the same for both stages.**
101
+
102
+
103
+ ## 📚 ALLaVA-4V Data
104
+
105
+ The majority part of training data is [ALLaVA-4V](https://huggingface.co/datasets/FreedomIntelligence/ALLaVA-4V). See [here](https://github.com/FreedomIntelligence/ALLaVA/tree/main?tab=readme-ov-file#data-preparation) to prepare it for training.
106
+
107
+
108
+ ## 🙌 Contributors
109
+
110
+ - Project Leader: [Guiming Hardy Chen](https://g-h-chen.github.io/)
111
+
112
+ - Data: Shunian Chen, [Junying Chen](https://jymchen.github.io/), Xiangbo Wu
113
+
114
+ - Evaluation: [Ruifei Zhang](https://scholar.google.com/citations?user=W4zOhmEAAAAJ&hl=zh-CN)
115
+
116
+ - Deployment: Xiangbo Wu, Zhiyi Zhang
117
+
118
+ - Advising: [Zhihong Chen](https://zhjohnchan.github.io/), [Benyou Wang](https://wabyking.github.io/old.html)
119
+
120
+ - Others: Jianquan Li, [Xiang Wan](https://scholar.google.com/citations?user=e3_kWigAAAAJ&hl=zh-CN)
121
+
122
+
123
+
124
+
125
+
126
+ ## 📝 Citation
127
+ If you find our data useful, please consider citing our work! We are FreedomIntelligence from [Shenzhen Research Institute of Big Data](http://sribd.cn/en) and [The Chinese University of Hong Kong, Shenzhen](https://sds.cuhk.edu.cn/en)
128
+ ```
129
+ @article{chen2024allava,
130
+ title={ALLaVA: Harnessing GPT4V-synthesized Data for A Lite Vision-Language Model},
131
+ author={Chen, Guiming Hardy and Chen, Shunian and Zhang, Ruifei and Chen, Junying and Wu, Xiangbo and Zhang, Zhiyi and Chen, Zhihong and Li, Jianquan and Wan, Xiang and Wang, Benyou},
132
+ journal={arXiv preprint arXiv:2402.11684},
133
+ year={2024}
134
+ }
135
+ ```
added_tokens.json ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "\t\t": 50294,
3
+ "\t\t\t": 50293,
4
+ "\t\t\t\t": 50292,
5
+ "\t\t\t\t\t": 50291,
6
+ "\t\t\t\t\t\t": 50290,
7
+ "\t\t\t\t\t\t\t": 50289,
8
+ "\t\t\t\t\t\t\t\t": 50288,
9
+ "\t\t\t\t\t\t\t\t\t": 50287,
10
+ " ": 50286,
11
+ " ": 50285,
12
+ " ": 50284,
13
+ " ": 50283,
14
+ " ": 50282,
15
+ " ": 50281,
16
+ " ": 50280,
17
+ " ": 50279,
18
+ " ": 50278,
19
+ " ": 50277,
20
+ " ": 50276,
21
+ " ": 50275,
22
+ " ": 50274,
23
+ " ": 50273,
24
+ " ": 50272,
25
+ " ": 50271,
26
+ " ": 50270,
27
+ " ": 50269,
28
+ " ": 50268,
29
+ " ": 50267,
30
+ " ": 50266,
31
+ " ": 50265,
32
+ " ": 50264,
33
+ " ": 50263,
34
+ " ": 50262,
35
+ " ": 50261,
36
+ " ": 50260,
37
+ " ": 50259,
38
+ " ": 50258,
39
+ " ": 50257
40
+ }
config.json ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "FreedomIntelligence/ALLaVA-3B-Longer",
3
+ "architectures": [
4
+ "LlavaPhiForCausalLM"
5
+ ],
6
+ "attention_dropout": 0.0,
7
+ "auto_map": {
8
+ "AutoConfig": "configuration_phi.PhiConfig",
9
+ "AutoModelForCausalLM": "modeling_llava_phi.LlavaPhiForCausalLM"
10
+ },
11
+ "bos_token_id": null,
12
+ "embd_pdrop": 0.0,
13
+ "eos_token_id": null,
14
+ "flash_attn": true,
15
+ "flash_rotary": true,
16
+ "fused_dense": true,
17
+ "hidden_act": "gelu_new",
18
+ "hidden_size": 2560,
19
+ "image_aspect_ratio": "pad",
20
+ "initializer_range": 0.02,
21
+ "intermediate_size": 10240,
22
+ "layer_norm_eps": 1e-05,
23
+ "max_position_embeddings": 2048,
24
+ "mm_hidden_size": 1024,
25
+ "mm_projector_lr": null,
26
+ "mm_projector_type": "mlp2x_gelu",
27
+ "mm_use_im_patch_token": false,
28
+ "mm_use_im_start_end": false,
29
+ "mm_vision_select_feature": "patch",
30
+ "mm_vision_select_layer": -2,
31
+ "mm_vision_tower": "openai/clip-vit-large-patch14-336",
32
+ "model_type": "llava_phi",
33
+ "num_attention_heads": 32,
34
+ "num_hidden_layers": 32,
35
+ "num_key_value_heads": 32,
36
+ "partial_rotary_factor": 0.4,
37
+ "qk_layernorm": false,
38
+ "resid_pdrop": 0.1,
39
+ "rope_scaling": null,
40
+ "rope_theta": 10000.0,
41
+ "tie_word_embeddings": false,
42
+ "tokenizer_model_max_length": 2048,
43
+ "tokenizer_padding_side": "right",
44
+ "torch_dtype": "bfloat16",
45
+ "transformers_version": "4.37.0.dev0",
46
+ "tune_mm_mlp_adapter": false,
47
+ "use_cache": true,
48
+ "use_mm_proj": true,
49
+ "vocab_size": 51200
50
+ }
configuration_phi.py ADDED
@@ -0,0 +1,193 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # coding=utf-8
2
+ # Copyright 2023 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 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
+ PHI_PRETRAINED_CONFIG_ARCHIVE_MAP = {
26
+ "microsoft/phi-2": "https://huggingface.co/microsoft/phi-2/resolve/main/config.json",
27
+ }
28
+
29
+
30
+ class PhiConfig(PretrainedConfig):
31
+ r"""
32
+ This is the configuration class to store the configuration of a [`PhiModel`]. It is used to instantiate an Phi
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 Phi
35
+ [microsoft/phi-1](https://huggingface.co/microsoft/phi-1).
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 51200):
42
+ Vocabulary size of the Phi model. Defines the number of different tokens that can be represented by the
43
+ `inputs_ids` passed when calling [`PhiModel`].
44
+ hidden_size (`int`, *optional*, defaults to 2048):
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 24):
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 `"gelu_new"`):
67
+ The non-linear activation function (function or string) in the decoder.
68
+ max_position_embeddings (`int`, *optional*, defaults to 2048):
69
+ The maximum sequence length that this model might ever be used with. Phi-1 and Phi-1.5 supports up to 2048
70
+ tokens.
71
+ initializer_range (`float`, *optional*, defaults to 0.02):
72
+ The standard deviation of the truncated_normal_initializer for initializing all weight matrices.
73
+ layer_norm_eps (`float`, *optional*, defaults to 1e-05):
74
+ The epsilon used by the rms normalization layers.
75
+ use_cache (`bool`, *optional*, defaults to `True`):
76
+ Whether or not the model should return the last key/values attentions (not used by all models). Only
77
+ relevant if `config.is_decoder=True`. Whether to tie weight embeddings or not.
78
+ tie_word_embeddings (`bool`, *optional*, defaults to `False`):
79
+ Whether to tie weight embeddings
80
+ rope_theta (`float`, *optional*, defaults to 10000.0):
81
+ The base period of the RoPE embeddings.
82
+ rope_scaling (`Dict`, *optional*):
83
+ Dictionary containing the scaling configuration for the RoPE embeddings. Currently supports two scaling
84
+ strategies: linear and dynamic. Their scaling factor must be an float greater than 1. The expected format
85
+ is `{"type": strategy name, "factor": scaling factor}`. When using this flag, don't update
86
+ `max_position_embeddings` to the expected new maximum. See the following thread for more information on how
87
+ these scaling strategies behave:
88
+ https://www.reddit.com/r/LocalPersimmon/comments/14mrgpr/dynamically_scaled_rope_further_increases/. This
89
+ is an experimental feature, subject to breaking API changes in future versions.
90
+ partial_rotary_factor (`float`, *optional*, defaults to 0.5):
91
+ Percentage of the query and keys which will have rotary embedding.
92
+ qk_layernorm (`bool`, *optional*, defaults to `False`):
93
+ Whether or not to normalize the Queries and Keys after projecting the hidden states.
94
+ bos_token_id (`int`, *optional*, defaults to 1):
95
+ Denotes beginning of sequences token id.
96
+ eos_token_id (`int`, *optional*, defaults to 2):
97
+ Denotes end of sequences token id.
98
+
99
+ Example:
100
+
101
+ ```python
102
+ >>> from transformers import PhiModel, PhiConfig
103
+
104
+ >>> # Initializing a Phi-1 style configuration
105
+ >>> configuration = PhiConfig.from_pretrained("microsoft/phi-1")
106
+
107
+ >>> # Initializing a model from the configuration
108
+ >>> model = PhiModel(configuration)
109
+
110
+ >>> # Accessing the model configuration
111
+ >>> configuration = model.config
112
+ ```"""
113
+
114
+ model_type = "phi"
115
+ keys_to_ignore_at_inference = ["past_key_values"]
116
+
117
+ def __init__(
118
+ self,
119
+ vocab_size=51200,
120
+ hidden_size=2048,
121
+ intermediate_size=8192,
122
+ num_hidden_layers=24,
123
+ num_attention_heads=32,
124
+ num_key_value_heads=None,
125
+ resid_pdrop=0.0,
126
+ embd_pdrop=0.0,
127
+ attention_dropout=0.0,
128
+ hidden_act="gelu_new",
129
+ max_position_embeddings=2048,
130
+ initializer_range=0.02,
131
+ layer_norm_eps=1e-5,
132
+ use_cache=True,
133
+ tie_word_embeddings=False,
134
+ rope_theta=10000.0,
135
+ rope_scaling=None,
136
+ partial_rotary_factor=0.5,
137
+ qk_layernorm=False,
138
+ bos_token_id=1,
139
+ eos_token_id=2,
140
+ **kwargs,
141
+ ):
142
+ self.vocab_size = vocab_size
143
+ self.hidden_size = hidden_size
144
+ self.intermediate_size = intermediate_size
145
+ self.num_hidden_layers = num_hidden_layers
146
+ self.num_attention_heads = num_attention_heads
147
+
148
+ if num_key_value_heads is None:
149
+ num_key_value_heads = num_attention_heads
150
+
151
+ self.num_key_value_heads = num_key_value_heads
152
+ self.resid_pdrop = resid_pdrop
153
+ self.embd_pdrop = embd_pdrop
154
+ self.attention_dropout = attention_dropout
155
+ self.hidden_act = hidden_act
156
+ self.max_position_embeddings = max_position_embeddings
157
+ self.initializer_range = initializer_range
158
+ self.layer_norm_eps = layer_norm_eps
159
+ self.use_cache = use_cache
160
+ self.rope_theta = rope_theta
161
+ self.rope_scaling = rope_scaling
162
+ self.partial_rotary_factor = partial_rotary_factor
163
+ self.qk_layernorm = qk_layernorm
164
+ self._rope_scaling_validation()
165
+
166
+ super().__init__(
167
+ bos_token_id=bos_token_id,
168
+ eos_token_id=eos_token_id,
169
+ tie_word_embeddings=tie_word_embeddings,
170
+ **kwargs,
171
+ )
172
+
173
+ # Copied from transformers.models.llama.configuration_llama.LlamaConfig._rope_scaling_validation
174
+ def _rope_scaling_validation(self):
175
+ """
176
+ Validate the `rope_scaling` configuration.
177
+ """
178
+ if self.rope_scaling is None:
179
+ return
180
+
181
+ if not isinstance(self.rope_scaling, dict) or len(self.rope_scaling) != 2:
182
+ raise ValueError(
183
+ "`rope_scaling` must be a dictionary with with two fields, `type` and `factor`, "
184
+ f"got {self.rope_scaling}"
185
+ )
186
+ rope_scaling_type = self.rope_scaling.get("type", None)
187
+ rope_scaling_factor = self.rope_scaling.get("factor", None)
188
+ if rope_scaling_type is None or rope_scaling_type not in ["linear", "dynamic"]:
189
+ raise ValueError(
190
+ f"`rope_scaling`'s type field must be one of ['linear', 'dynamic'], got {rope_scaling_type}"
191
+ )
192
+ if rope_scaling_factor is None or not isinstance(rope_scaling_factor, float) or rope_scaling_factor <= 1.0:
193
+ raise ValueError(f"`rope_scaling`'s factor field must be a float > 1, got {rope_scaling_factor}")
generation_config.json ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "transformers_version": "4.37.0.dev0"
4
+ }
generation_utils.py ADDED
@@ -0,0 +1,287 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from typing import List
2
+ from queue import Queue
3
+
4
+ import torch
5
+ from PIL import Image
6
+ from copy import deepcopy
7
+ import requests, os
8
+
9
+ IMAGE_TOKEN_INDEX=-200
10
+ blacklist = ['<image>', '<s>', '</s>']
11
+ max_num_images = 3 # phi has a context length limit of 2048 and each image occupies 576 tokens.
12
+
13
+ def input_moderation(texts: list[list[str]]):
14
+ # perform input moderation on each message
15
+ for text_pair in texts:
16
+ # in-place operation
17
+ for b in blacklist:
18
+ text_pair[0] = text_pair[0].replace(b, '')
19
+ if text_pair[1] is not None:
20
+ text_pair[1] = text_pair[1].replace(b, '')
21
+
22
+ return texts
23
+
24
+ def insert_image_placeholder(t, num_images, placeholder='<image>', sep='\n'):
25
+ for _ in range(num_images):
26
+ t = f"{placeholder}{sep}" + t
27
+ return t
28
+
29
+ def get_conv(texts):
30
+ ret = []
31
+
32
+ for conv in texts:
33
+ ret.append({'from': 'human', 'value': conv[0]})
34
+ ret.append({'from': 'gpt', 'value': conv[1]}) # this is None for the last one
35
+
36
+ return ret
37
+
38
+ # copied from llava
39
+ def tokenizer_image_token(prompt, tokenizer, image_token_index=IMAGE_TOKEN_INDEX, return_tensors=None):
40
+ prompt_chunks = [tokenizer(chunk, add_special_tokens=False).input_ids for chunk in prompt.split('<image>')]
41
+
42
+ def insert_separator(X, sep):
43
+ return [ele for sublist in zip(X, [sep]*len(X)) for ele in sublist][:-1]
44
+
45
+ input_ids = []
46
+ offset = 0
47
+ if len(prompt_chunks) > 0 and len(prompt_chunks[0]) > 0 and prompt_chunks[0][0] == tokenizer.bos_token_id:
48
+ offset = 1
49
+ input_ids.append(prompt_chunks[0][0])
50
+
51
+ for x in insert_separator(prompt_chunks, [image_token_index] * (offset + 1)):
52
+ input_ids.extend(x[offset:])
53
+
54
+ if return_tensors is not None:
55
+ if return_tensors == 'pt':
56
+ return torch.tensor(input_ids, dtype=torch.long)
57
+ raise ValueError(f'Unsupported tensor type: {return_tensors}')
58
+ return input_ids
59
+
60
+ def preprocess(tokenizer, data: list, return_tensors='pt'):
61
+ '''
62
+ [
63
+ {
64
+ 'from': 'human',
65
+ 'value': xxx,
66
+ },
67
+ {
68
+ 'from': 'gpt',
69
+ 'value': xxx
70
+ }
71
+ ]
72
+ '''
73
+ # needs update
74
+ if not isinstance(data, list):
75
+ raise ValueError('must be a list')
76
+
77
+ # this is per model (tokenizer)
78
+ return preprocess_allava(tokenizer, data, return_tensors=return_tensors)
79
+
80
+
81
+
82
+ def preprocess_vicuna_v1(self, convs: list, return_tensors) -> list: # tokenize and concat the coversations
83
+ input_ids = None
84
+ for ind, conv in enumerate(convs):
85
+ if ind % 2 == 0: # human
86
+ h = conv['value'].strip()
87
+ h = f"USER: {h} "
88
+ cur_input_ids = self.tokenizer_image_token(prompt=h, return_tensors=return_tensors)
89
+
90
+ if input_ids is None:
91
+ input_ids = cur_input_ids
92
+ else:
93
+ input_ids = torch.cat([input_ids, cur_input_ids])
94
+
95
+ else: # gpt
96
+ g = conv['value']
97
+ if g is not None:
98
+ cur_input_ids = self.tokenizer(f"ASSISTANT: {g}</s>", add_special_tokens= False, max_length=self.maxlen, truncation=True, return_tensors='pt').input_ids[0]
99
+ input_ids = torch.cat([input_ids, cur_input_ids])
100
+ else:
101
+ cur_input_ids = self.tokenizer(f"ASSISTANT:", add_special_tokens= False, max_length=self.maxlen, truncation=True, return_tensors='pt').input_ids[0]
102
+ input_ids = torch.cat([input_ids, cur_input_ids])
103
+
104
+
105
+ return input_ids
106
+
107
+ def preprocess_allava(tokenizer, convs: list, return_tensors) -> list: # tokenize and concat the coversations
108
+ input_ids = None
109
+
110
+ for ind, conv in enumerate(convs):
111
+ if ind % 2 == 0: # human
112
+ h = conv['value'].strip()
113
+ h = f"[INST] {h} [/INST] "
114
+ cur_input_ids = tokenizer_image_token(prompt=h, tokenizer=tokenizer, return_tensors=return_tensors)
115
+
116
+ if input_ids is None:
117
+ input_ids = cur_input_ids
118
+ else:
119
+ input_ids = torch.cat([input_ids, cur_input_ids])
120
+
121
+ else: # gpt
122
+ g = conv['value']
123
+ if g is not None:
124
+ cur_input_ids = tokenizer(f"{g}{tokenizer.eos_token}", add_special_tokens= False, truncation=True, return_tensors='pt').input_ids[0]
125
+ input_ids = torch.cat([input_ids, cur_input_ids])
126
+
127
+ return input_ids
128
+
129
+
130
+ # copied from llava
131
+ def get_image_tensors(processor, images, device):
132
+ list_image_tensors = []
133
+ crop_size = processor.crop_size
134
+ for fp in images:
135
+ if fp is None: # None is used as a placeholder
136
+ list_image_tensors.append(torch.zeros(3, crop_size['height'], crop_size['width']).to(device))
137
+ continue
138
+ elif isinstance(fp, str):
139
+ image = Image.open(fp).convert('RGB')
140
+ elif isinstance(fp, Image.Image):
141
+ image = fp # already an image
142
+ else:
143
+ raise TypeError(f'Unsupported type {type(fp)}')
144
+
145
+ # this is the way of preprocessing images we used in training, so we impose it here
146
+ if True:
147
+ # self.data_args.image_aspect_ratio == 'pad'
148
+ def expand2square(pil_img, background_color):
149
+ width, height = pil_img.size
150
+ if pil_img.mode == 'L':
151
+ pil_img = pil_img.convert('RGB')
152
+
153
+ if width == height:
154
+ return pil_img
155
+ elif width > height:
156
+ result = Image.new(pil_img.mode, (width, width), background_color)
157
+ result.paste(pil_img, (0, (width - height) // 2))
158
+ return result
159
+ else:
160
+ result = Image.new(pil_img.mode, (height, height), background_color)
161
+ result.paste(pil_img, ((height - width) // 2, 0))
162
+ return result
163
+
164
+ image = expand2square(image, tuple(int(x*255) for x in processor.image_mean))
165
+ image = processor.preprocess(image, return_tensors='pt')['pixel_values'][0]
166
+ else:
167
+ image = processor.preprocess(image, return_tensors='pt')['pixel_values'][0] # a tensor
168
+ list_image_tensors.append(image.to(device))
169
+ # list_image_tensors.append(image)
170
+ return list_image_tensors
171
+
172
+
173
+
174
+
175
+ def build_allava_input(tokenizer, processor, texts, images, history=None, return_history=False, device='cuda'):
176
+ '''
177
+ texts: [[]]
178
+ '''
179
+
180
+ ############################
181
+ # 1. preprocess texts
182
+ ############################
183
+ if isinstance(texts, str):
184
+ texts = [[texts, None]]
185
+ else:
186
+ assert isinstance(texts, list) and isinstance(texts[0], list) , 'texts must be a list of list'
187
+
188
+ if history is not None:
189
+ texts = history + texts # concat them together
190
+
191
+ texts = input_moderation(texts)
192
+
193
+
194
+ ############################
195
+ # 2. preprocess images
196
+ ############################
197
+ if isinstance(images, str) or isinstance(images, Image.Image):
198
+ images = [images]
199
+
200
+ valid_images = []
201
+ if images is None:
202
+ images = [None]
203
+
204
+ for img in images:
205
+ try:
206
+ if os.path.exists(img): # make sure that the path exists
207
+ img = Image.open(img).convert('RGB')
208
+ else: # else it must be a URL
209
+ img = Image.open(requests.get(img, stream=True).raw)
210
+
211
+ valid_images.append(img)
212
+ except:
213
+ continue
214
+
215
+ images = valid_images
216
+
217
+ if images == []:
218
+ images = [None]
219
+
220
+
221
+ assert len(images) < max_num_images, f'Currently at most {max_num_images} images are supported'
222
+
223
+ ############################
224
+ # 3. collate conv
225
+ ############################
226
+
227
+ history = deepcopy(texts) # history is the texts without <image> placeholders
228
+
229
+ # insert <image>
230
+ image_place_holder_inserted = insert_image_placeholder(texts[0][0], len(images) if None not in images else 0) # only insert the placeholders for user input at the 1st round
231
+ texts[0][0] = image_place_holder_inserted
232
+
233
+ # collate strings into conv
234
+ conv = get_conv(texts)
235
+
236
+ # make input ids
237
+ input_ids = preprocess(tokenizer, conv, return_tensors='pt').unsqueeze(0).to(device)
238
+
239
+ list_image_tensors = get_image_tensors(processor, images, device)
240
+ image_tensors = torch.stack(list_image_tensors)
241
+
242
+ try:
243
+ dtype = torch.bfloat16
244
+ # if your hardware does not support bf16, the following line raises an error
245
+ torch.tensor(1, dtype=dtype).cuda()
246
+ except:
247
+ # default using fp16
248
+ dtype = torch.float16
249
+
250
+ if return_history:
251
+ return input_ids, image_tensors, history
252
+
253
+ return input_ids, image_tensors, None
254
+
255
+
256
+
257
+ class TextIterStreamer:
258
+ def __init__(self, tokenizer, skip_prompt=False, skip_special_tokens=False):
259
+ self.tokenizer = tokenizer
260
+ self.skip_prompt = skip_prompt
261
+ self.skip_special_tokens = skip_special_tokens
262
+ self.tokens = []
263
+ self.text_queue = Queue()
264
+ self.next_tokens_are_prompt = True
265
+
266
+ def put(self, value):
267
+ if self.skip_prompt and self.next_tokens_are_prompt:
268
+ self.next_tokens_are_prompt = False
269
+ else:
270
+ if len(value.shape) > 1:
271
+ value = value[0]
272
+ self.tokens.extend(value.tolist())
273
+ self.text_queue.put(
274
+ self.tokenizer.decode(self.tokens, skip_special_tokens=self.skip_special_tokens))
275
+
276
+ def end(self):
277
+ self.text_queue.put(None)
278
+
279
+ def __iter__(self):
280
+ return self
281
+
282
+ def __next__(self):
283
+ value = self.text_queue.get()
284
+ if value is None:
285
+ raise StopIteration()
286
+ else:
287
+ return value
llava_arch.py ADDED
@@ -0,0 +1,531 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2023 Haotian Liu
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+
16
+ from abc import ABC, abstractmethod
17
+
18
+ import torch
19
+ import torch.nn as nn
20
+
21
+ # from .multimodal_encoder.builder import build_vision_tower
22
+ # from .multimodal_projector.builder import build_vision_projector
23
+
24
+ # from .builders import build_vision_tower, build_vision_projector
25
+ # from .constants import IGNORE_INDEX, IMAGE_TOKEN_INDEX, DEFAULT_IMAGE_PATCH_TOKEN, DEFAULT_IM_START_TOKEN, DEFAULT_IM_END_TOKEN
26
+ import pdb
27
+
28
+
29
+ #############################################################################
30
+ # builders
31
+ #############################################################################
32
+
33
+ ###################################################################
34
+
35
+ import torch
36
+ import torch.nn as nn
37
+ import re
38
+
39
+
40
+ class IdentityMap(nn.Module):
41
+ def __init__(self):
42
+ super().__init__()
43
+
44
+ def forward(self, x, *args, **kwargs):
45
+ return x
46
+
47
+ @property
48
+ def config(self):
49
+ return {"mm_projector_type": 'identity'}
50
+
51
+
52
+ class SimpleResBlock(nn.Module):
53
+ def __init__(self, channels):
54
+ super().__init__()
55
+ self.pre_norm = nn.LayerNorm(channels)
56
+
57
+ self.proj = nn.Sequential(
58
+ nn.Linear(channels, channels),
59
+ nn.GELU(),
60
+ nn.Linear(channels, channels)
61
+ )
62
+ def forward(self, x):
63
+ x = self.pre_norm(x)
64
+ return x + self.proj(x)
65
+
66
+
67
+ def build_vision_projector(config, delay_load=False, **kwargs):
68
+ projector_type = getattr(config, 'mm_projector_type', 'linear')
69
+
70
+ if projector_type == 'linear':
71
+ return nn.Linear(config.mm_hidden_size, config.hidden_size)
72
+
73
+ mlp_gelu_match = re.match(r'^mlp(\d+)x_gelu$', projector_type)
74
+ if mlp_gelu_match:
75
+ mlp_depth = int(mlp_gelu_match.group(1))
76
+ modules = [nn.Linear(config.mm_hidden_size, config.hidden_size)]
77
+ for _ in range(1, mlp_depth):
78
+ modules.append(nn.GELU())
79
+ modules.append(nn.Linear(config.hidden_size, config.hidden_size))
80
+ return nn.Sequential(*modules)
81
+
82
+ if projector_type == 'identity':
83
+ return IdentityMap()
84
+
85
+ raise ValueError(f'Unknown projector type: {projector_type}')
86
+ ###################################################################
87
+
88
+
89
+
90
+ ###################################################################
91
+
92
+ import os
93
+ from transformers import CLIPVisionModel, CLIPImageProcessor, CLIPVisionConfig
94
+ from transformers import AutoModel
95
+
96
+
97
+ class CLIPVisionTower(nn.Module):
98
+ def __init__(self, vision_tower, args, delay_load=False):
99
+ super().__init__()
100
+
101
+ self.is_loaded = False
102
+
103
+ self.vision_tower_name = vision_tower
104
+ self.select_layer = args.mm_vision_select_layer
105
+ self.select_feature = getattr(args, 'mm_vision_select_feature', 'patch')
106
+
107
+ if not delay_load:
108
+ self.load_model()
109
+ else:
110
+ self.cfg_only = CLIPVisionConfig.from_pretrained(self.vision_tower_name)
111
+
112
+ def load_model(self):
113
+ print(f'loading vision model from {self.vision_tower_name}')
114
+ self.image_processor = CLIPImageProcessor.from_pretrained(self.vision_tower_name)
115
+ if 'clip' in self.vision_tower_name.lower():
116
+ self.vision_tower = CLIPVisionModel.from_pretrained(self.vision_tower_name)
117
+
118
+ elif 'internvit' in self.vision_tower_name.lower():
119
+ self.vision_tower = AutoModel.from_pretrained(self.vision_tower_name, trust_remote_code=True)
120
+ else:
121
+ raise ValueError(f'Please implement the loading of vision encoder here')
122
+
123
+ self.vision_tower.requires_grad_(False)
124
+
125
+ self.is_loaded = True
126
+
127
+ def feature_select(self, image_forward_outs):
128
+ image_features = image_forward_outs.hidden_states[self.select_layer]
129
+ if self.select_feature == 'patch':
130
+ image_features = image_features[:, 1:]
131
+ elif self.select_feature == 'cls_patch':
132
+ image_features = image_features
133
+ else:
134
+ raise ValueError(f'Unexpected select feature: {self.select_feature}')
135
+ return image_features
136
+
137
+ @torch.no_grad()
138
+ def forward(self, images):
139
+ if type(images) is list:
140
+ image_features = []
141
+ for image in images:
142
+ image_forward_out = self.vision_tower(image.to(device=self.device, dtype=self.dtype).unsqueeze(0), output_hidden_states=True)
143
+ image_feature = self.feature_select(image_forward_out).to(image.dtype)
144
+ image_features.append(image_feature)
145
+ else:
146
+ image_forward_outs = self.vision_tower(images.to(device=self.device, dtype=self.dtype), output_hidden_states=True)
147
+ image_features = self.feature_select(image_forward_outs).to(images.dtype)
148
+
149
+ return image_features
150
+
151
+ @property
152
+ def dummy_feature(self):
153
+ return torch.zeros(1, self.hidden_size, device=self.device, dtype=self.dtype)
154
+
155
+ @property
156
+ def dtype(self):
157
+ return self.vision_tower.dtype
158
+
159
+ @property
160
+ def device(self):
161
+ return self.vision_tower.device
162
+
163
+ @property
164
+ def config(self):
165
+ if self.is_loaded:
166
+ return self.vision_tower.config
167
+ else:
168
+ return self.cfg_only
169
+
170
+ @property
171
+ def hidden_size(self):
172
+ return self.config.hidden_size
173
+
174
+ @property
175
+ def num_patches(self):
176
+ return (self.config.image_size // self.config.patch_size) ** 2
177
+
178
+
179
+
180
+ def build_vision_tower(vision_tower_cfg, **kwargs):
181
+ vision_tower = getattr(vision_tower_cfg, 'mm_vision_tower', getattr(vision_tower_cfg, 'vision_tower', None))
182
+ is_absolute_path_exists = os.path.exists(vision_tower)
183
+ if is_absolute_path_exists or vision_tower.startswith("openai") or vision_tower.startswith("laion"):
184
+ return CLIPVisionTower(vision_tower, args=vision_tower_cfg, **kwargs)
185
+
186
+ raise ValueError(f'Unknown vision tower: {vision_tower}')
187
+
188
+
189
+ #############################################################################
190
+ # builders
191
+ #############################################################################
192
+
193
+
194
+
195
+ #############################################################################
196
+ # constants
197
+ #############################################################################
198
+
199
+ CONTROLLER_HEART_BEAT_EXPIRATION = 30
200
+ WORKER_HEART_BEAT_INTERVAL = 15
201
+
202
+ LOGDIR = "."
203
+
204
+ # Model Constants
205
+ IGNORE_INDEX = -100
206
+ IMAGE_TOKEN_INDEX = -200
207
+ DEFAULT_IMAGE_TOKEN = "<image>"
208
+ DEFAULT_IMAGE_PATCH_TOKEN = "<im_patch>"
209
+ DEFAULT_IM_START_TOKEN = "<im_start>"
210
+ DEFAULT_IM_END_TOKEN = "<im_end>"
211
+ IMAGE_PLACEHOLDER = "<image-placeholder>"
212
+
213
+ #############################################################################
214
+ # constants
215
+ #############################################################################
216
+
217
+
218
+ class LlavaMetaModel:
219
+
220
+ def __init__(self, config):
221
+ super(LlavaMetaModel, self).__init__(config)
222
+
223
+ if hasattr(config, "mm_vision_tower"):
224
+ self.vision_tower = build_vision_tower(config, delay_load=True)
225
+ self.mm_projector = build_vision_projector(config)
226
+
227
+ def get_vision_tower(self):
228
+ vision_tower = getattr(self, 'vision_tower', None)
229
+ if type(vision_tower) is list:
230
+ vision_tower = vision_tower[0]
231
+ return vision_tower
232
+
233
+ def initialize_vision_modules(self, model_args, fsdp=None):
234
+ vision_tower = model_args.vision_tower
235
+ mm_vision_select_layer = model_args.mm_vision_select_layer
236
+ mm_vision_select_feature = model_args.mm_vision_select_feature
237
+ pretrain_mm_mlp_adapter = model_args.pretrain_mm_mlp_adapter
238
+
239
+ self.config.mm_vision_tower = vision_tower
240
+
241
+ if self.get_vision_tower() is None:
242
+ vision_tower = build_vision_tower(model_args)
243
+
244
+ if fsdp is not None and len(fsdp) > 0:
245
+ self.vision_tower = [vision_tower]
246
+ else:
247
+ self.vision_tower = vision_tower
248
+ else:
249
+ if fsdp is not None and len(fsdp) > 0:
250
+ vision_tower = self.vision_tower[0]
251
+ else:
252
+ vision_tower = self.vision_tower
253
+ vision_tower.load_model()
254
+
255
+ self.config.use_mm_proj = True
256
+ self.config.mm_projector_type = getattr(model_args, 'mm_projector_type', 'linear')
257
+ self.config.mm_hidden_size = vision_tower.hidden_size
258
+ self.config.mm_vision_select_layer = mm_vision_select_layer
259
+ self.config.mm_vision_select_feature = mm_vision_select_feature
260
+
261
+ if getattr(self, 'mm_projector', None) is None:
262
+ self.mm_projector = build_vision_projector(self.config)
263
+ else:
264
+ # In case it is frozen by LoRA
265
+ for p in self.mm_projector.parameters():
266
+ p.requires_grad = True
267
+
268
+ if pretrain_mm_mlp_adapter is not None:
269
+ mm_projector_weights = torch.load(pretrain_mm_mlp_adapter, map_location='cpu')
270
+ def get_w(weights, keyword):
271
+ return {k.split(keyword + '.')[1]: v for k, v in weights.items() if keyword in k}
272
+
273
+ self.mm_projector.load_state_dict(get_w(mm_projector_weights, 'mm_projector'))
274
+
275
+
276
+ class LlavaMetaForCausalLM(ABC):
277
+
278
+ @abstractmethod
279
+ def get_model(self):
280
+ pass
281
+
282
+ @abstractmethod
283
+ def get_tokenizer(self):
284
+ pass
285
+
286
+ def get_vision_tower(self):
287
+ return self.get_model().get_vision_tower()
288
+
289
+ def encode_images(self, images):
290
+ image_features = self.get_model().get_vision_tower()(images)
291
+ image_features = self.get_model().mm_projector(image_features)
292
+ return image_features
293
+
294
+ def prepare_inputs_labels_for_multimodal_new(
295
+ self, input_ids: list[torch.tensor], position_ids, attention_mask: list[torch.tensor], past_key_values, labels, images
296
+ ):
297
+ vision_tower = self.get_vision_tower()
298
+ if not self.training: # TODO: check this out!!
299
+ # pdb.set_trace()
300
+ if vision_tower is None or images is None or input_ids.shape[1] == 1:
301
+ if past_key_values is not None and vision_tower is not None and images is not None and input_ids.shape[1] == 1:
302
+
303
+ if attention_mask is None:
304
+ # only happen for qwen at inference
305
+ # raise ValueError(f'should not be here except for Qwen!')
306
+ return input_ids, None, attention_mask, past_key_values, None, labels
307
+
308
+ target_shape = past_key_values[-1][-1].shape[-2] + 1
309
+ attention_mask = torch.cat((attention_mask, torch.ones(
310
+ (attention_mask.shape[0], target_shape - attention_mask.shape[1]),
311
+ dtype=attention_mask.dtype,
312
+ device=attention_mask.device
313
+ )), dim=1)
314
+ position_ids = torch.sum(attention_mask, dim=1).unsqueeze(-1) - 1
315
+ return input_ids, position_ids, attention_mask, past_key_values, None, labels
316
+
317
+
318
+ # ####################### this block must be optimized! #######################
319
+ # if type(images) is list or images.ndim == 5:
320
+ # concat_images = torch.cat([image for image in images], dim=0)
321
+ # image_features = self.encode_images(concat_images)
322
+ # split_sizes = [image.shape[0] for image in images]
323
+ # image_features = torch.split(image_features, split_sizes, dim=0)
324
+ # image_features = [x.flatten(0, 1).to(self.device) for x in image_features]
325
+ # else:
326
+ # image_features = self.encode_images(images).to(self.device)
327
+ # ####################### this block must be optimized! #######################
328
+
329
+ # ####################### optimized #######################
330
+ if getattr(self, 'cached_image_features', None) is None:
331
+ # this attribute should be cleared in bot.clear_history()
332
+ if type(images) is list or images.ndim == 5:
333
+ concat_images = torch.cat([image for image in images], dim=0)
334
+ image_features = self.encode_images(concat_images)
335
+ split_sizes = [image.shape[0] for image in images]
336
+ image_features = torch.split(image_features, split_sizes, dim=0)
337
+ image_features = [x.flatten(0, 1).to(self.device) for x in image_features]
338
+ else:
339
+ image_features = self.encode_images(images).to(self.device)
340
+ self.cached_image_features = image_features
341
+ image_features = self.cached_image_features
342
+ # ####################### optimized #######################
343
+
344
+
345
+ # TODO: image start / end is not implemented here to support pretraining.
346
+ if getattr(self.config, 'tune_mm_mlp_adapter', False) and getattr(self.config, 'mm_use_im_start_end', False):
347
+ raise NotImplementedError
348
+
349
+ # Let's just add dummy tensors if they do not exist,
350
+ # it is a headache to deal with None all the time.
351
+ # But it is not ideal, and if you have a better idea,
352
+ # please open an issue / submit a PR, thanks.
353
+ _labels = labels
354
+ _position_ids = position_ids
355
+ _attention_mask = attention_mask
356
+ if attention_mask is None:
357
+ # attention_mask = torch.ones_like(input_ids, dtype=torch.bool)
358
+ attention_mask = [torch.tensor([1]*l).to(input_ids).bool() for l in map(len, [ip for ip in input_ids])]
359
+ else:
360
+ # attention_mask = attention_mask.bool()
361
+ attention_mask = [att.bool() for att in attention_mask]
362
+
363
+ # if position_ids is None:
364
+ # position_ids = torch.arange(0, input_ids.shape[1], dtype=torch.long, device=input_ids.device)
365
+
366
+ if labels is None:
367
+ labels = [torch.tensor([IGNORE_INDEX]*l).to(input_ids) for l in map(len, [ip for ip in input_ids])]
368
+ # labels = torch.full_like(input_ids, IGNORE_INDEX)
369
+ else:
370
+ labels = [cur_labels[cur_attention_mask] for cur_labels, cur_attention_mask in zip(labels, attention_mask)]
371
+ # remove the padding using attention_mask -- TODO: double check
372
+ # pdb.set_trace()
373
+ input_ids = [cur_input_ids[cur_attention_mask] for cur_input_ids, cur_attention_mask in zip(input_ids, attention_mask)]
374
+
375
+ new_input_embeds = []
376
+ new_labels = []
377
+ cur_image_idx = 0
378
+ for batch_idx, cur_input_ids in enumerate(input_ids):
379
+ num_images = (cur_input_ids == IMAGE_TOKEN_INDEX).sum()
380
+ if num_images == 0:
381
+
382
+ ############### FIXME ###############
383
+ if cur_image_idx > len(image_features)-1:
384
+ cur_image_idx = len(image_features)-1
385
+ print(f'warning: {input_ids}')
386
+ ############### FIXME ###############
387
+
388
+ cur_image_features = image_features[cur_image_idx]
389
+ cur_input_embeds_1 = self.get_model().embed_tokens(cur_input_ids)
390
+ cur_input_embeds = torch.cat([cur_input_embeds_1, cur_image_features[0:0]], dim=0)
391
+ new_input_embeds.append(cur_input_embeds)
392
+ new_labels.append(labels[batch_idx])
393
+ cur_image_idx += 1
394
+ continue
395
+
396
+ image_token_indices = [-1] + torch.where(cur_input_ids == IMAGE_TOKEN_INDEX)[0].tolist() + [cur_input_ids.shape[0]]
397
+ cur_input_ids_noim = []
398
+ cur_labels = labels[batch_idx]
399
+ cur_labels_noim = []
400
+ for i in range(len(image_token_indices) - 1):
401
+ cur_input_ids_noim.append(cur_input_ids[image_token_indices[i]+1:image_token_indices[i+1]])
402
+ cur_labels_noim.append(cur_labels[image_token_indices[i]+1:image_token_indices[i+1]])
403
+ split_sizes = [x.shape[0] for x in cur_labels_noim]
404
+ cur_input_embeds = self.get_model().embed_tokens(torch.cat(cur_input_ids_noim))
405
+ cur_input_embeds_no_im = torch.split(cur_input_embeds, split_sizes, dim=0)
406
+ cur_new_input_embeds = []
407
+ cur_new_labels = []
408
+
409
+ # you have 10 images, but you have 11 placeholders
410
+ for i in range(num_images + 1):
411
+ cur_new_input_embeds.append(cur_input_embeds_no_im[i])
412
+ cur_new_labels.append(cur_labels_noim[i])
413
+ if i < num_images:
414
+ ############### FIXME ###############
415
+ if cur_image_idx > len(image_features)-1:
416
+ cur_image_idx = len(image_features)-1
417
+ print(f'warning: {input_ids}')
418
+ ############### FIXME ###############
419
+
420
+ cur_image_features = image_features[cur_image_idx]
421
+ cur_image_idx += 1
422
+ cur_new_input_embeds.append(cur_image_features)
423
+ cur_new_labels.append(torch.full((cur_image_features.shape[0],), IGNORE_INDEX, device=cur_labels.device, dtype=cur_labels.dtype))
424
+
425
+ cur_new_input_embeds = torch.cat(cur_new_input_embeds)
426
+ cur_new_labels = torch.cat(cur_new_labels)
427
+
428
+ new_input_embeds.append(cur_new_input_embeds)
429
+ new_labels.append(cur_new_labels)
430
+
431
+ # Truncate sequences to max length as image embeddings can make the sequence longer
432
+ tokenizer_model_max_length = getattr(self.config, 'tokenizer_model_max_length', None)
433
+ if tokenizer_model_max_length is not None:
434
+ new_input_embeds = [x[:tokenizer_model_max_length] for x in new_input_embeds]
435
+ new_labels = [x[:tokenizer_model_max_length] for x in new_labels]
436
+
437
+ # Combine them
438
+ max_len = max(x.shape[0] for x in new_input_embeds)
439
+ batch_size = len(new_input_embeds)
440
+
441
+ new_input_embeds_padded = []
442
+ new_labels_padded = torch.full((batch_size, max_len), IGNORE_INDEX, dtype=new_labels[0].dtype, device=new_labels[0].device)
443
+ attention_mask = torch.zeros((batch_size, max_len), dtype=torch.bool, device=attention_mask[0].device)
444
+ position_ids = torch.zeros((batch_size, max_len), dtype=torch.long, device=attention_mask[0].device)
445
+
446
+ for i, (cur_new_embed, cur_new_labels) in enumerate(zip(new_input_embeds, new_labels)):
447
+ cur_len = cur_new_embed.shape[0]
448
+ # print(f'cur_len[{i}]before padding: {cur_len}')
449
+ # if i==0:
450
+ # print(f"{getattr(self.config, 'tokenizer_padding_side', 'right')} {self.get_tokenizer().padding_side}")
451
+ if getattr(self.config, 'tokenizer_padding_side', 'right') == "left": # checked, this is correct
452
+ # if self.get_tokenizer().padding_side == 'left':
453
+ new_input_embeds_padded.append(torch.cat((
454
+ torch.zeros((max_len - cur_len, cur_new_embed.shape[1]), dtype=cur_new_embed.dtype, device=cur_new_embed.device),
455
+ cur_new_embed
456
+ ), dim=0))
457
+ if cur_len > 0:
458
+ new_labels_padded[i, -cur_len:] = cur_new_labels
459
+ attention_mask[i, -cur_len:] = True
460
+ position_ids[i, -cur_len:] = torch.arange(0, cur_len, dtype=position_ids.dtype, device=position_ids.device)
461
+ else:
462
+ new_input_embeds_padded.append(torch.cat((
463
+ cur_new_embed,
464
+ torch.zeros((max_len - cur_len, cur_new_embed.shape[1]), dtype=cur_new_embed.dtype, device=cur_new_embed.device)
465
+ ), dim=0))
466
+ if cur_len > 0:
467
+ new_labels_padded[i, :cur_len] = cur_new_labels
468
+ attention_mask[i, :cur_len] = True
469
+ position_ids[i, :cur_len] = torch.arange(0, cur_len, dtype=position_ids.dtype, device=position_ids.device)
470
+
471
+ new_input_embeds = torch.stack(new_input_embeds_padded, dim=0)
472
+
473
+ if _labels is None:
474
+ new_labels = None
475
+ else:
476
+ new_labels = new_labels_padded
477
+
478
+ if _attention_mask is None:
479
+ attention_mask = None
480
+ else:
481
+ # attention_mask = attention_mask.to(dtype=_attention_mask.dtype)
482
+ attention_mask = attention_mask.to(dtype=torch.bool)
483
+
484
+ if _position_ids is None:
485
+ position_ids = None
486
+
487
+ return None, position_ids, attention_mask, past_key_values, new_input_embeds, new_labels
488
+
489
+ def initialize_vision_tokenizer(self, model_args, tokenizer):
490
+ if model_args.mm_use_im_patch_token:
491
+ tokenizer.add_tokens([DEFAULT_IMAGE_PATCH_TOKEN], special_tokens=True)
492
+ self.resize_token_embeddings(len(tokenizer))
493
+
494
+ if model_args.mm_use_im_start_end:
495
+ num_new_tokens = tokenizer.add_tokens([DEFAULT_IM_START_TOKEN, DEFAULT_IM_END_TOKEN], special_tokens=True)
496
+ self.resize_token_embeddings(len(tokenizer))
497
+
498
+ if num_new_tokens > 0:
499
+ input_embeddings = self.get_input_embeddings().weight.data
500
+ output_embeddings = self.get_output_embeddings().weight.data
501
+
502
+ input_embeddings_avg = input_embeddings[:-num_new_tokens].mean(
503
+ dim=0, keepdim=True)
504
+ output_embeddings_avg = output_embeddings[:-num_new_tokens].mean(
505
+ dim=0, keepdim=True)
506
+
507
+ input_embeddings[-num_new_tokens:] = input_embeddings_avg
508
+ output_embeddings[-num_new_tokens:] = output_embeddings_avg
509
+
510
+ if model_args.tune_mm_mlp_adapter:
511
+ for p in self.get_input_embeddings().parameters():
512
+ p.requires_grad = True
513
+ for p in self.get_output_embeddings().parameters():
514
+ p.requires_grad = False
515
+
516
+ if model_args.pretrain_mm_mlp_adapter:
517
+ mm_projector_weights = torch.load(model_args.pretrain_mm_mlp_adapter, map_location='cpu')
518
+ embed_tokens_weight = mm_projector_weights['model.embed_tokens.weight']
519
+ assert num_new_tokens == 2
520
+ if input_embeddings.shape == embed_tokens_weight.shape:
521
+ input_embeddings[-num_new_tokens:] = embed_tokens_weight[-num_new_tokens:]
522
+ elif embed_tokens_weight.shape[0] == num_new_tokens:
523
+ input_embeddings[-num_new_tokens:] = embed_tokens_weight
524
+ else:
525
+ raise ValueError(f"Unexpected embed_tokens_weight shape. Pretrained: {embed_tokens_weight.shape}. Current: {input_embeddings.shape}. Numer of new tokens: {num_new_tokens}.")
526
+ elif model_args.mm_use_im_patch_token:
527
+ if model_args.tune_mm_mlp_adapter:
528
+ for p in self.get_input_embeddings().parameters():
529
+ p.requires_grad = False
530
+ for p in self.get_output_embeddings().parameters():
531
+ p.requires_grad = False
merges.txt ADDED
The diff for this file is too large to render. See raw diff
 
model-00001-of-00002.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d64556d4c1c702af723fbc8697f1d71ef5218fa64e1d7e6cbfd30725119c09e0
3
+ size 4995584848
model-00002-of-00002.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a1605c57e327cfaf2f22c45a927b62512f8572e7ec9a661f8b30da8240267df6
3
+ size 1189167008
model.safetensors.index.json ADDED
@@ -0,0 +1,854 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "metadata": {
3
+ "total_size": 6184640512
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.final_layernorm.bias": "model-00002-of-00002.safetensors",
9
+ "model.final_layernorm.weight": "model-00002-of-00002.safetensors",
10
+ "model.layers.0.input_layernorm.bias": "model-00001-of-00002.safetensors",
11
+ "model.layers.0.input_layernorm.weight": "model-00001-of-00002.safetensors",
12
+ "model.layers.0.mlp.fc1.bias": "model-00001-of-00002.safetensors",
13
+ "model.layers.0.mlp.fc1.weight": "model-00001-of-00002.safetensors",
14
+ "model.layers.0.mlp.fc2.bias": "model-00001-of-00002.safetensors",
15
+ "model.layers.0.mlp.fc2.weight": "model-00001-of-00002.safetensors",
16
+ "model.layers.0.self_attn.dense.bias": "model-00001-of-00002.safetensors",
17
+ "model.layers.0.self_attn.dense.weight": "model-00001-of-00002.safetensors",
18
+ "model.layers.0.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
19
+ "model.layers.0.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
20
+ "model.layers.0.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
21
+ "model.layers.0.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
22
+ "model.layers.0.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
23
+ "model.layers.0.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
24
+ "model.layers.1.input_layernorm.bias": "model-00001-of-00002.safetensors",
25
+ "model.layers.1.input_layernorm.weight": "model-00001-of-00002.safetensors",
26
+ "model.layers.1.mlp.fc1.bias": "model-00001-of-00002.safetensors",
27
+ "model.layers.1.mlp.fc1.weight": "model-00001-of-00002.safetensors",
28
+ "model.layers.1.mlp.fc2.bias": "model-00001-of-00002.safetensors",
29
+ "model.layers.1.mlp.fc2.weight": "model-00001-of-00002.safetensors",
30
+ "model.layers.1.self_attn.dense.bias": "model-00001-of-00002.safetensors",
31
+ "model.layers.1.self_attn.dense.weight": "model-00001-of-00002.safetensors",
32
+ "model.layers.1.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
33
+ "model.layers.1.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
34
+ "model.layers.1.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
35
+ "model.layers.1.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
36
+ "model.layers.1.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
37
+ "model.layers.1.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
38
+ "model.layers.10.input_layernorm.bias": "model-00001-of-00002.safetensors",
39
+ "model.layers.10.input_layernorm.weight": "model-00001-of-00002.safetensors",
40
+ "model.layers.10.mlp.fc1.bias": "model-00001-of-00002.safetensors",
41
+ "model.layers.10.mlp.fc1.weight": "model-00001-of-00002.safetensors",
42
+ "model.layers.10.mlp.fc2.bias": "model-00001-of-00002.safetensors",
43
+ "model.layers.10.mlp.fc2.weight": "model-00001-of-00002.safetensors",
44
+ "model.layers.10.self_attn.dense.bias": "model-00001-of-00002.safetensors",
45
+ "model.layers.10.self_attn.dense.weight": "model-00001-of-00002.safetensors",
46
+ "model.layers.10.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
47
+ "model.layers.10.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
48
+ "model.layers.10.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
49
+ "model.layers.10.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
50
+ "model.layers.10.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
51
+ "model.layers.10.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
52
+ "model.layers.11.input_layernorm.bias": "model-00001-of-00002.safetensors",
53
+ "model.layers.11.input_layernorm.weight": "model-00001-of-00002.safetensors",
54
+ "model.layers.11.mlp.fc1.bias": "model-00001-of-00002.safetensors",
55
+ "model.layers.11.mlp.fc1.weight": "model-00001-of-00002.safetensors",
56
+ "model.layers.11.mlp.fc2.bias": "model-00001-of-00002.safetensors",
57
+ "model.layers.11.mlp.fc2.weight": "model-00001-of-00002.safetensors",
58
+ "model.layers.11.self_attn.dense.bias": "model-00001-of-00002.safetensors",
59
+ "model.layers.11.self_attn.dense.weight": "model-00001-of-00002.safetensors",
60
+ "model.layers.11.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
61
+ "model.layers.11.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
62
+ "model.layers.11.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
63
+ "model.layers.11.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
64
+ "model.layers.11.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
65
+ "model.layers.11.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
66
+ "model.layers.12.input_layernorm.bias": "model-00001-of-00002.safetensors",
67
+ "model.layers.12.input_layernorm.weight": "model-00001-of-00002.safetensors",
68
+ "model.layers.12.mlp.fc1.bias": "model-00001-of-00002.safetensors",
69
+ "model.layers.12.mlp.fc1.weight": "model-00001-of-00002.safetensors",
70
+ "model.layers.12.mlp.fc2.bias": "model-00001-of-00002.safetensors",
71
+ "model.layers.12.mlp.fc2.weight": "model-00001-of-00002.safetensors",
72
+ "model.layers.12.self_attn.dense.bias": "model-00001-of-00002.safetensors",
73
+ "model.layers.12.self_attn.dense.weight": "model-00001-of-00002.safetensors",
74
+ "model.layers.12.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
75
+ "model.layers.12.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
76
+ "model.layers.12.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
77
+ "model.layers.12.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
78
+ "model.layers.12.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
79
+ "model.layers.12.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
80
+ "model.layers.13.input_layernorm.bias": "model-00001-of-00002.safetensors",
81
+ "model.layers.13.input_layernorm.weight": "model-00001-of-00002.safetensors",
82
+ "model.layers.13.mlp.fc1.bias": "model-00001-of-00002.safetensors",
83
+ "model.layers.13.mlp.fc1.weight": "model-00001-of-00002.safetensors",
84
+ "model.layers.13.mlp.fc2.bias": "model-00001-of-00002.safetensors",
85
+ "model.layers.13.mlp.fc2.weight": "model-00001-of-00002.safetensors",
86
+ "model.layers.13.self_attn.dense.bias": "model-00001-of-00002.safetensors",
87
+ "model.layers.13.self_attn.dense.weight": "model-00001-of-00002.safetensors",
88
+ "model.layers.13.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
89
+ "model.layers.13.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
90
+ "model.layers.13.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
91
+ "model.layers.13.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
92
+ "model.layers.13.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
93
+ "model.layers.13.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
94
+ "model.layers.14.input_layernorm.bias": "model-00001-of-00002.safetensors",
95
+ "model.layers.14.input_layernorm.weight": "model-00001-of-00002.safetensors",
96
+ "model.layers.14.mlp.fc1.bias": "model-00001-of-00002.safetensors",
97
+ "model.layers.14.mlp.fc1.weight": "model-00001-of-00002.safetensors",
98
+ "model.layers.14.mlp.fc2.bias": "model-00001-of-00002.safetensors",
99
+ "model.layers.14.mlp.fc2.weight": "model-00001-of-00002.safetensors",
100
+ "model.layers.14.self_attn.dense.bias": "model-00001-of-00002.safetensors",
101
+ "model.layers.14.self_attn.dense.weight": "model-00001-of-00002.safetensors",
102
+ "model.layers.14.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
103
+ "model.layers.14.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
104
+ "model.layers.14.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
105
+ "model.layers.14.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
106
+ "model.layers.14.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
107
+ "model.layers.14.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
108
+ "model.layers.15.input_layernorm.bias": "model-00001-of-00002.safetensors",
109
+ "model.layers.15.input_layernorm.weight": "model-00001-of-00002.safetensors",
110
+ "model.layers.15.mlp.fc1.bias": "model-00001-of-00002.safetensors",
111
+ "model.layers.15.mlp.fc1.weight": "model-00001-of-00002.safetensors",
112
+ "model.layers.15.mlp.fc2.bias": "model-00001-of-00002.safetensors",
113
+ "model.layers.15.mlp.fc2.weight": "model-00001-of-00002.safetensors",
114
+ "model.layers.15.self_attn.dense.bias": "model-00001-of-00002.safetensors",
115
+ "model.layers.15.self_attn.dense.weight": "model-00001-of-00002.safetensors",
116
+ "model.layers.15.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
117
+ "model.layers.15.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
118
+ "model.layers.15.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
119
+ "model.layers.15.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
120
+ "model.layers.15.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
121
+ "model.layers.15.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
122
+ "model.layers.16.input_layernorm.bias": "model-00001-of-00002.safetensors",
123
+ "model.layers.16.input_layernorm.weight": "model-00001-of-00002.safetensors",
124
+ "model.layers.16.mlp.fc1.bias": "model-00001-of-00002.safetensors",
125
+ "model.layers.16.mlp.fc1.weight": "model-00001-of-00002.safetensors",
126
+ "model.layers.16.mlp.fc2.bias": "model-00001-of-00002.safetensors",
127
+ "model.layers.16.mlp.fc2.weight": "model-00001-of-00002.safetensors",
128
+ "model.layers.16.self_attn.dense.bias": "model-00001-of-00002.safetensors",
129
+ "model.layers.16.self_attn.dense.weight": "model-00001-of-00002.safetensors",
130
+ "model.layers.16.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
131
+ "model.layers.16.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
132
+ "model.layers.16.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
133
+ "model.layers.16.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
134
+ "model.layers.16.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
135
+ "model.layers.16.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
136
+ "model.layers.17.input_layernorm.bias": "model-00001-of-00002.safetensors",
137
+ "model.layers.17.input_layernorm.weight": "model-00001-of-00002.safetensors",
138
+ "model.layers.17.mlp.fc1.bias": "model-00001-of-00002.safetensors",
139
+ "model.layers.17.mlp.fc1.weight": "model-00001-of-00002.safetensors",
140
+ "model.layers.17.mlp.fc2.bias": "model-00001-of-00002.safetensors",
141
+ "model.layers.17.mlp.fc2.weight": "model-00001-of-00002.safetensors",
142
+ "model.layers.17.self_attn.dense.bias": "model-00001-of-00002.safetensors",
143
+ "model.layers.17.self_attn.dense.weight": "model-00001-of-00002.safetensors",
144
+ "model.layers.17.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
145
+ "model.layers.17.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
146
+ "model.layers.17.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
147
+ "model.layers.17.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
148
+ "model.layers.17.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
149
+ "model.layers.17.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
150
+ "model.layers.18.input_layernorm.bias": "model-00001-of-00002.safetensors",
151
+ "model.layers.18.input_layernorm.weight": "model-00001-of-00002.safetensors",
152
+ "model.layers.18.mlp.fc1.bias": "model-00001-of-00002.safetensors",
153
+ "model.layers.18.mlp.fc1.weight": "model-00001-of-00002.safetensors",
154
+ "model.layers.18.mlp.fc2.bias": "model-00001-of-00002.safetensors",
155
+ "model.layers.18.mlp.fc2.weight": "model-00001-of-00002.safetensors",
156
+ "model.layers.18.self_attn.dense.bias": "model-00001-of-00002.safetensors",
157
+ "model.layers.18.self_attn.dense.weight": "model-00001-of-00002.safetensors",
158
+ "model.layers.18.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
159
+ "model.layers.18.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
160
+ "model.layers.18.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
161
+ "model.layers.18.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
162
+ "model.layers.18.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
163
+ "model.layers.18.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
164
+ "model.layers.19.input_layernorm.bias": "model-00001-of-00002.safetensors",
165
+ "model.layers.19.input_layernorm.weight": "model-00001-of-00002.safetensors",
166
+ "model.layers.19.mlp.fc1.bias": "model-00001-of-00002.safetensors",
167
+ "model.layers.19.mlp.fc1.weight": "model-00001-of-00002.safetensors",
168
+ "model.layers.19.mlp.fc2.bias": "model-00001-of-00002.safetensors",
169
+ "model.layers.19.mlp.fc2.weight": "model-00001-of-00002.safetensors",
170
+ "model.layers.19.self_attn.dense.bias": "model-00001-of-00002.safetensors",
171
+ "model.layers.19.self_attn.dense.weight": "model-00001-of-00002.safetensors",
172
+ "model.layers.19.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
173
+ "model.layers.19.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
174
+ "model.layers.19.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
175
+ "model.layers.19.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
176
+ "model.layers.19.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
177
+ "model.layers.19.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
178
+ "model.layers.2.input_layernorm.bias": "model-00001-of-00002.safetensors",
179
+ "model.layers.2.input_layernorm.weight": "model-00001-of-00002.safetensors",
180
+ "model.layers.2.mlp.fc1.bias": "model-00001-of-00002.safetensors",
181
+ "model.layers.2.mlp.fc1.weight": "model-00001-of-00002.safetensors",
182
+ "model.layers.2.mlp.fc2.bias": "model-00001-of-00002.safetensors",
183
+ "model.layers.2.mlp.fc2.weight": "model-00001-of-00002.safetensors",
184
+ "model.layers.2.self_attn.dense.bias": "model-00001-of-00002.safetensors",
185
+ "model.layers.2.self_attn.dense.weight": "model-00001-of-00002.safetensors",
186
+ "model.layers.2.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
187
+ "model.layers.2.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
188
+ "model.layers.2.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
189
+ "model.layers.2.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
190
+ "model.layers.2.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
191
+ "model.layers.2.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
192
+ "model.layers.20.input_layernorm.bias": "model-00001-of-00002.safetensors",
193
+ "model.layers.20.input_layernorm.weight": "model-00001-of-00002.safetensors",
194
+ "model.layers.20.mlp.fc1.bias": "model-00001-of-00002.safetensors",
195
+ "model.layers.20.mlp.fc1.weight": "model-00001-of-00002.safetensors",
196
+ "model.layers.20.mlp.fc2.bias": "model-00001-of-00002.safetensors",
197
+ "model.layers.20.mlp.fc2.weight": "model-00001-of-00002.safetensors",
198
+ "model.layers.20.self_attn.dense.bias": "model-00001-of-00002.safetensors",
199
+ "model.layers.20.self_attn.dense.weight": "model-00001-of-00002.safetensors",
200
+ "model.layers.20.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
201
+ "model.layers.20.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
202
+ "model.layers.20.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
203
+ "model.layers.20.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
204
+ "model.layers.20.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
205
+ "model.layers.20.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
206
+ "model.layers.21.input_layernorm.bias": "model-00001-of-00002.safetensors",
207
+ "model.layers.21.input_layernorm.weight": "model-00001-of-00002.safetensors",
208
+ "model.layers.21.mlp.fc1.bias": "model-00001-of-00002.safetensors",
209
+ "model.layers.21.mlp.fc1.weight": "model-00001-of-00002.safetensors",
210
+ "model.layers.21.mlp.fc2.bias": "model-00001-of-00002.safetensors",
211
+ "model.layers.21.mlp.fc2.weight": "model-00001-of-00002.safetensors",
212
+ "model.layers.21.self_attn.dense.bias": "model-00001-of-00002.safetensors",
213
+ "model.layers.21.self_attn.dense.weight": "model-00001-of-00002.safetensors",
214
+ "model.layers.21.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
215
+ "model.layers.21.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
216
+ "model.layers.21.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
217
+ "model.layers.21.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
218
+ "model.layers.21.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
219
+ "model.layers.21.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
220
+ "model.layers.22.input_layernorm.bias": "model-00001-of-00002.safetensors",
221
+ "model.layers.22.input_layernorm.weight": "model-00001-of-00002.safetensors",
222
+ "model.layers.22.mlp.fc1.bias": "model-00001-of-00002.safetensors",
223
+ "model.layers.22.mlp.fc1.weight": "model-00001-of-00002.safetensors",
224
+ "model.layers.22.mlp.fc2.bias": "model-00001-of-00002.safetensors",
225
+ "model.layers.22.mlp.fc2.weight": "model-00001-of-00002.safetensors",
226
+ "model.layers.22.self_attn.dense.bias": "model-00001-of-00002.safetensors",
227
+ "model.layers.22.self_attn.dense.weight": "model-00001-of-00002.safetensors",
228
+ "model.layers.22.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
229
+ "model.layers.22.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
230
+ "model.layers.22.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
231
+ "model.layers.22.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
232
+ "model.layers.22.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
233
+ "model.layers.22.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
234
+ "model.layers.23.input_layernorm.bias": "model-00001-of-00002.safetensors",
235
+ "model.layers.23.input_layernorm.weight": "model-00001-of-00002.safetensors",
236
+ "model.layers.23.mlp.fc1.bias": "model-00001-of-00002.safetensors",
237
+ "model.layers.23.mlp.fc1.weight": "model-00001-of-00002.safetensors",
238
+ "model.layers.23.mlp.fc2.bias": "model-00001-of-00002.safetensors",
239
+ "model.layers.23.mlp.fc2.weight": "model-00001-of-00002.safetensors",
240
+ "model.layers.23.self_attn.dense.bias": "model-00001-of-00002.safetensors",
241
+ "model.layers.23.self_attn.dense.weight": "model-00001-of-00002.safetensors",
242
+ "model.layers.23.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
243
+ "model.layers.23.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
244
+ "model.layers.23.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
245
+ "model.layers.23.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
246
+ "model.layers.23.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
247
+ "model.layers.23.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
248
+ "model.layers.24.input_layernorm.bias": "model-00001-of-00002.safetensors",
249
+ "model.layers.24.input_layernorm.weight": "model-00001-of-00002.safetensors",
250
+ "model.layers.24.mlp.fc1.bias": "model-00001-of-00002.safetensors",
251
+ "model.layers.24.mlp.fc1.weight": "model-00001-of-00002.safetensors",
252
+ "model.layers.24.mlp.fc2.bias": "model-00001-of-00002.safetensors",
253
+ "model.layers.24.mlp.fc2.weight": "model-00001-of-00002.safetensors",
254
+ "model.layers.24.self_attn.dense.bias": "model-00001-of-00002.safetensors",
255
+ "model.layers.24.self_attn.dense.weight": "model-00001-of-00002.safetensors",
256
+ "model.layers.24.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
257
+ "model.layers.24.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
258
+ "model.layers.24.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
259
+ "model.layers.24.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
260
+ "model.layers.24.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
261
+ "model.layers.24.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
262
+ "model.layers.25.input_layernorm.bias": "model-00001-of-00002.safetensors",
263
+ "model.layers.25.input_layernorm.weight": "model-00001-of-00002.safetensors",
264
+ "model.layers.25.mlp.fc1.bias": "model-00001-of-00002.safetensors",
265
+ "model.layers.25.mlp.fc1.weight": "model-00001-of-00002.safetensors",
266
+ "model.layers.25.mlp.fc2.bias": "model-00001-of-00002.safetensors",
267
+ "model.layers.25.mlp.fc2.weight": "model-00001-of-00002.safetensors",
268
+ "model.layers.25.self_attn.dense.bias": "model-00001-of-00002.safetensors",
269
+ "model.layers.25.self_attn.dense.weight": "model-00001-of-00002.safetensors",
270
+ "model.layers.25.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
271
+ "model.layers.25.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
272
+ "model.layers.25.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
273
+ "model.layers.25.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
274
+ "model.layers.25.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
275
+ "model.layers.25.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
276
+ "model.layers.26.input_layernorm.bias": "model-00001-of-00002.safetensors",
277
+ "model.layers.26.input_layernorm.weight": "model-00001-of-00002.safetensors",
278
+ "model.layers.26.mlp.fc1.bias": "model-00001-of-00002.safetensors",
279
+ "model.layers.26.mlp.fc1.weight": "model-00001-of-00002.safetensors",
280
+ "model.layers.26.mlp.fc2.bias": "model-00001-of-00002.safetensors",
281
+ "model.layers.26.mlp.fc2.weight": "model-00001-of-00002.safetensors",
282
+ "model.layers.26.self_attn.dense.bias": "model-00001-of-00002.safetensors",
283
+ "model.layers.26.self_attn.dense.weight": "model-00001-of-00002.safetensors",
284
+ "model.layers.26.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
285
+ "model.layers.26.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
286
+ "model.layers.26.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
287
+ "model.layers.26.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
288
+ "model.layers.26.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
289
+ "model.layers.26.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
290
+ "model.layers.27.input_layernorm.bias": "model-00001-of-00002.safetensors",
291
+ "model.layers.27.input_layernorm.weight": "model-00001-of-00002.safetensors",
292
+ "model.layers.27.mlp.fc1.bias": "model-00001-of-00002.safetensors",
293
+ "model.layers.27.mlp.fc1.weight": "model-00001-of-00002.safetensors",
294
+ "model.layers.27.mlp.fc2.bias": "model-00001-of-00002.safetensors",
295
+ "model.layers.27.mlp.fc2.weight": "model-00001-of-00002.safetensors",
296
+ "model.layers.27.self_attn.dense.bias": "model-00001-of-00002.safetensors",
297
+ "model.layers.27.self_attn.dense.weight": "model-00001-of-00002.safetensors",
298
+ "model.layers.27.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
299
+ "model.layers.27.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
300
+ "model.layers.27.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
301
+ "model.layers.27.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
302
+ "model.layers.27.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
303
+ "model.layers.27.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
304
+ "model.layers.28.input_layernorm.bias": "model-00001-of-00002.safetensors",
305
+ "model.layers.28.input_layernorm.weight": "model-00001-of-00002.safetensors",
306
+ "model.layers.28.mlp.fc1.bias": "model-00001-of-00002.safetensors",
307
+ "model.layers.28.mlp.fc1.weight": "model-00001-of-00002.safetensors",
308
+ "model.layers.28.mlp.fc2.bias": "model-00001-of-00002.safetensors",
309
+ "model.layers.28.mlp.fc2.weight": "model-00001-of-00002.safetensors",
310
+ "model.layers.28.self_attn.dense.bias": "model-00001-of-00002.safetensors",
311
+ "model.layers.28.self_attn.dense.weight": "model-00001-of-00002.safetensors",
312
+ "model.layers.28.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
313
+ "model.layers.28.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
314
+ "model.layers.28.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
315
+ "model.layers.28.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
316
+ "model.layers.28.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
317
+ "model.layers.28.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
318
+ "model.layers.29.input_layernorm.bias": "model-00001-of-00002.safetensors",
319
+ "model.layers.29.input_layernorm.weight": "model-00001-of-00002.safetensors",
320
+ "model.layers.29.mlp.fc1.bias": "model-00001-of-00002.safetensors",
321
+ "model.layers.29.mlp.fc1.weight": "model-00001-of-00002.safetensors",
322
+ "model.layers.29.mlp.fc2.bias": "model-00001-of-00002.safetensors",
323
+ "model.layers.29.mlp.fc2.weight": "model-00001-of-00002.safetensors",
324
+ "model.layers.29.self_attn.dense.bias": "model-00001-of-00002.safetensors",
325
+ "model.layers.29.self_attn.dense.weight": "model-00001-of-00002.safetensors",
326
+ "model.layers.29.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
327
+ "model.layers.29.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
328
+ "model.layers.29.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
329
+ "model.layers.29.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
330
+ "model.layers.29.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
331
+ "model.layers.29.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
332
+ "model.layers.3.input_layernorm.bias": "model-00001-of-00002.safetensors",
333
+ "model.layers.3.input_layernorm.weight": "model-00001-of-00002.safetensors",
334
+ "model.layers.3.mlp.fc1.bias": "model-00001-of-00002.safetensors",
335
+ "model.layers.3.mlp.fc1.weight": "model-00001-of-00002.safetensors",
336
+ "model.layers.3.mlp.fc2.bias": "model-00001-of-00002.safetensors",
337
+ "model.layers.3.mlp.fc2.weight": "model-00001-of-00002.safetensors",
338
+ "model.layers.3.self_attn.dense.bias": "model-00001-of-00002.safetensors",
339
+ "model.layers.3.self_attn.dense.weight": "model-00001-of-00002.safetensors",
340
+ "model.layers.3.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
341
+ "model.layers.3.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
342
+ "model.layers.3.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
343
+ "model.layers.3.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
344
+ "model.layers.3.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
345
+ "model.layers.3.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
346
+ "model.layers.30.input_layernorm.bias": "model-00002-of-00002.safetensors",
347
+ "model.layers.30.input_layernorm.weight": "model-00002-of-00002.safetensors",
348
+ "model.layers.30.mlp.fc1.bias": "model-00002-of-00002.safetensors",
349
+ "model.layers.30.mlp.fc1.weight": "model-00002-of-00002.safetensors",
350
+ "model.layers.30.mlp.fc2.bias": "model-00002-of-00002.safetensors",
351
+ "model.layers.30.mlp.fc2.weight": "model-00002-of-00002.safetensors",
352
+ "model.layers.30.self_attn.dense.bias": "model-00002-of-00002.safetensors",
353
+ "model.layers.30.self_attn.dense.weight": "model-00002-of-00002.safetensors",
354
+ "model.layers.30.self_attn.k_proj.bias": "model-00002-of-00002.safetensors",
355
+ "model.layers.30.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
356
+ "model.layers.30.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
357
+ "model.layers.30.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
358
+ "model.layers.30.self_attn.v_proj.bias": "model-00002-of-00002.safetensors",
359
+ "model.layers.30.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
360
+ "model.layers.31.input_layernorm.bias": "model-00002-of-00002.safetensors",
361
+ "model.layers.31.input_layernorm.weight": "model-00002-of-00002.safetensors",
362
+ "model.layers.31.mlp.fc1.bias": "model-00002-of-00002.safetensors",
363
+ "model.layers.31.mlp.fc1.weight": "model-00002-of-00002.safetensors",
364
+ "model.layers.31.mlp.fc2.bias": "model-00002-of-00002.safetensors",
365
+ "model.layers.31.mlp.fc2.weight": "model-00002-of-00002.safetensors",
366
+ "model.layers.31.self_attn.dense.bias": "model-00002-of-00002.safetensors",
367
+ "model.layers.31.self_attn.dense.weight": "model-00002-of-00002.safetensors",
368
+ "model.layers.31.self_attn.k_proj.bias": "model-00002-of-00002.safetensors",
369
+ "model.layers.31.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
370
+ "model.layers.31.self_attn.q_proj.bias": "model-00002-of-00002.safetensors",
371
+ "model.layers.31.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
372
+ "model.layers.31.self_attn.v_proj.bias": "model-00002-of-00002.safetensors",
373
+ "model.layers.31.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
374
+ "model.layers.4.input_layernorm.bias": "model-00001-of-00002.safetensors",
375
+ "model.layers.4.input_layernorm.weight": "model-00001-of-00002.safetensors",
376
+ "model.layers.4.mlp.fc1.bias": "model-00001-of-00002.safetensors",
377
+ "model.layers.4.mlp.fc1.weight": "model-00001-of-00002.safetensors",
378
+ "model.layers.4.mlp.fc2.bias": "model-00001-of-00002.safetensors",
379
+ "model.layers.4.mlp.fc2.weight": "model-00001-of-00002.safetensors",
380
+ "model.layers.4.self_attn.dense.bias": "model-00001-of-00002.safetensors",
381
+ "model.layers.4.self_attn.dense.weight": "model-00001-of-00002.safetensors",
382
+ "model.layers.4.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
383
+ "model.layers.4.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
384
+ "model.layers.4.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
385
+ "model.layers.4.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
386
+ "model.layers.4.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
387
+ "model.layers.4.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
388
+ "model.layers.5.input_layernorm.bias": "model-00001-of-00002.safetensors",
389
+ "model.layers.5.input_layernorm.weight": "model-00001-of-00002.safetensors",
390
+ "model.layers.5.mlp.fc1.bias": "model-00001-of-00002.safetensors",
391
+ "model.layers.5.mlp.fc1.weight": "model-00001-of-00002.safetensors",
392
+ "model.layers.5.mlp.fc2.bias": "model-00001-of-00002.safetensors",
393
+ "model.layers.5.mlp.fc2.weight": "model-00001-of-00002.safetensors",
394
+ "model.layers.5.self_attn.dense.bias": "model-00001-of-00002.safetensors",
395
+ "model.layers.5.self_attn.dense.weight": "model-00001-of-00002.safetensors",
396
+ "model.layers.5.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
397
+ "model.layers.5.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
398
+ "model.layers.5.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
399
+ "model.layers.5.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
400
+ "model.layers.5.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
401
+ "model.layers.5.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
402
+ "model.layers.6.input_layernorm.bias": "model-00001-of-00002.safetensors",
403
+ "model.layers.6.input_layernorm.weight": "model-00001-of-00002.safetensors",
404
+ "model.layers.6.mlp.fc1.bias": "model-00001-of-00002.safetensors",
405
+ "model.layers.6.mlp.fc1.weight": "model-00001-of-00002.safetensors",
406
+ "model.layers.6.mlp.fc2.bias": "model-00001-of-00002.safetensors",
407
+ "model.layers.6.mlp.fc2.weight": "model-00001-of-00002.safetensors",
408
+ "model.layers.6.self_attn.dense.bias": "model-00001-of-00002.safetensors",
409
+ "model.layers.6.self_attn.dense.weight": "model-00001-of-00002.safetensors",
410
+ "model.layers.6.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
411
+ "model.layers.6.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
412
+ "model.layers.6.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
413
+ "model.layers.6.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
414
+ "model.layers.6.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
415
+ "model.layers.6.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
416
+ "model.layers.7.input_layernorm.bias": "model-00001-of-00002.safetensors",
417
+ "model.layers.7.input_layernorm.weight": "model-00001-of-00002.safetensors",
418
+ "model.layers.7.mlp.fc1.bias": "model-00001-of-00002.safetensors",
419
+ "model.layers.7.mlp.fc1.weight": "model-00001-of-00002.safetensors",
420
+ "model.layers.7.mlp.fc2.bias": "model-00001-of-00002.safetensors",
421
+ "model.layers.7.mlp.fc2.weight": "model-00001-of-00002.safetensors",
422
+ "model.layers.7.self_attn.dense.bias": "model-00001-of-00002.safetensors",
423
+ "model.layers.7.self_attn.dense.weight": "model-00001-of-00002.safetensors",
424
+ "model.layers.7.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
425
+ "model.layers.7.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
426
+ "model.layers.7.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
427
+ "model.layers.7.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
428
+ "model.layers.7.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
429
+ "model.layers.7.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
430
+ "model.layers.8.input_layernorm.bias": "model-00001-of-00002.safetensors",
431
+ "model.layers.8.input_layernorm.weight": "model-00001-of-00002.safetensors",
432
+ "model.layers.8.mlp.fc1.bias": "model-00001-of-00002.safetensors",
433
+ "model.layers.8.mlp.fc1.weight": "model-00001-of-00002.safetensors",
434
+ "model.layers.8.mlp.fc2.bias": "model-00001-of-00002.safetensors",
435
+ "model.layers.8.mlp.fc2.weight": "model-00001-of-00002.safetensors",
436
+ "model.layers.8.self_attn.dense.bias": "model-00001-of-00002.safetensors",
437
+ "model.layers.8.self_attn.dense.weight": "model-00001-of-00002.safetensors",
438
+ "model.layers.8.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
439
+ "model.layers.8.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
440
+ "model.layers.8.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
441
+ "model.layers.8.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
442
+ "model.layers.8.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
443
+ "model.layers.8.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
444
+ "model.layers.9.input_layernorm.bias": "model-00001-of-00002.safetensors",
445
+ "model.layers.9.input_layernorm.weight": "model-00001-of-00002.safetensors",
446
+ "model.layers.9.mlp.fc1.bias": "model-00001-of-00002.safetensors",
447
+ "model.layers.9.mlp.fc1.weight": "model-00001-of-00002.safetensors",
448
+ "model.layers.9.mlp.fc2.bias": "model-00001-of-00002.safetensors",
449
+ "model.layers.9.mlp.fc2.weight": "model-00001-of-00002.safetensors",
450
+ "model.layers.9.self_attn.dense.bias": "model-00001-of-00002.safetensors",
451
+ "model.layers.9.self_attn.dense.weight": "model-00001-of-00002.safetensors",
452
+ "model.layers.9.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
453
+ "model.layers.9.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
454
+ "model.layers.9.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
455
+ "model.layers.9.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
456
+ "model.layers.9.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
457
+ "model.layers.9.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
458
+ "model.mm_projector.0.bias": "model-00002-of-00002.safetensors",
459
+ "model.mm_projector.0.weight": "model-00002-of-00002.safetensors",
460
+ "model.mm_projector.2.bias": "model-00002-of-00002.safetensors",
461
+ "model.mm_projector.2.weight": "model-00002-of-00002.safetensors",
462
+ "model.vision_tower.vision_tower.vision_model.embeddings.class_embedding": "model-00002-of-00002.safetensors",
463
+ "model.vision_tower.vision_tower.vision_model.embeddings.patch_embedding.weight": "model-00002-of-00002.safetensors",
464
+ "model.vision_tower.vision_tower.vision_model.embeddings.position_embedding.weight": "model-00002-of-00002.safetensors",
465
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.0.layer_norm1.bias": "model-00002-of-00002.safetensors",
466
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.0.layer_norm1.weight": "model-00002-of-00002.safetensors",
467
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.0.layer_norm2.bias": "model-00002-of-00002.safetensors",
468
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.0.layer_norm2.weight": "model-00002-of-00002.safetensors",
469
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.0.mlp.fc1.bias": "model-00002-of-00002.safetensors",
470
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.0.mlp.fc1.weight": "model-00002-of-00002.safetensors",
471
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.0.mlp.fc2.bias": "model-00002-of-00002.safetensors",
472
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.0.mlp.fc2.weight": "model-00002-of-00002.safetensors",
473
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.0.self_attn.k_proj.bias": "model-00002-of-00002.safetensors",
474
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.0.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
475
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.0.self_attn.out_proj.bias": "model-00002-of-00002.safetensors",
476
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.0.self_attn.out_proj.weight": "model-00002-of-00002.safetensors",
477
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.0.self_attn.q_proj.bias": "model-00002-of-00002.safetensors",
478
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.0.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
479
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.0.self_attn.v_proj.bias": "model-00002-of-00002.safetensors",
480
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.0.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
481
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.1.layer_norm1.bias": "model-00002-of-00002.safetensors",
482
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.1.layer_norm1.weight": "model-00002-of-00002.safetensors",
483
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.1.layer_norm2.bias": "model-00002-of-00002.safetensors",
484
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.1.layer_norm2.weight": "model-00002-of-00002.safetensors",
485
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.1.mlp.fc1.bias": "model-00002-of-00002.safetensors",
486
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.1.mlp.fc1.weight": "model-00002-of-00002.safetensors",
487
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.1.mlp.fc2.bias": "model-00002-of-00002.safetensors",
488
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.1.mlp.fc2.weight": "model-00002-of-00002.safetensors",
489
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.1.self_attn.k_proj.bias": "model-00002-of-00002.safetensors",
490
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.1.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
491
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.1.self_attn.out_proj.bias": "model-00002-of-00002.safetensors",
492
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.1.self_attn.out_proj.weight": "model-00002-of-00002.safetensors",
493
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.1.self_attn.q_proj.bias": "model-00002-of-00002.safetensors",
494
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.1.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
495
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.1.self_attn.v_proj.bias": "model-00002-of-00002.safetensors",
496
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.1.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
497
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.10.layer_norm1.bias": "model-00002-of-00002.safetensors",
498
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.10.layer_norm1.weight": "model-00002-of-00002.safetensors",
499
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.10.layer_norm2.bias": "model-00002-of-00002.safetensors",
500
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.10.layer_norm2.weight": "model-00002-of-00002.safetensors",
501
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.10.mlp.fc1.bias": "model-00002-of-00002.safetensors",
502
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.10.mlp.fc1.weight": "model-00002-of-00002.safetensors",
503
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.10.mlp.fc2.bias": "model-00002-of-00002.safetensors",
504
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.10.mlp.fc2.weight": "model-00002-of-00002.safetensors",
505
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.10.self_attn.k_proj.bias": "model-00002-of-00002.safetensors",
506
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.10.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
507
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.10.self_attn.out_proj.bias": "model-00002-of-00002.safetensors",
508
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.10.self_attn.out_proj.weight": "model-00002-of-00002.safetensors",
509
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.10.self_attn.q_proj.bias": "model-00002-of-00002.safetensors",
510
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.10.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
511
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.10.self_attn.v_proj.bias": "model-00002-of-00002.safetensors",
512
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.10.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
513
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.11.layer_norm1.bias": "model-00002-of-00002.safetensors",
514
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.11.layer_norm1.weight": "model-00002-of-00002.safetensors",
515
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.11.layer_norm2.bias": "model-00002-of-00002.safetensors",
516
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.11.layer_norm2.weight": "model-00002-of-00002.safetensors",
517
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.11.mlp.fc1.bias": "model-00002-of-00002.safetensors",
518
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.11.mlp.fc1.weight": "model-00002-of-00002.safetensors",
519
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.11.mlp.fc2.bias": "model-00002-of-00002.safetensors",
520
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.11.mlp.fc2.weight": "model-00002-of-00002.safetensors",
521
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.11.self_attn.k_proj.bias": "model-00002-of-00002.safetensors",
522
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.11.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
523
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.11.self_attn.out_proj.bias": "model-00002-of-00002.safetensors",
524
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.11.self_attn.out_proj.weight": "model-00002-of-00002.safetensors",
525
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.11.self_attn.q_proj.bias": "model-00002-of-00002.safetensors",
526
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.11.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
527
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.11.self_attn.v_proj.bias": "model-00002-of-00002.safetensors",
528
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.11.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
529
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.12.layer_norm1.bias": "model-00002-of-00002.safetensors",
530
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.12.layer_norm1.weight": "model-00002-of-00002.safetensors",
531
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.12.layer_norm2.bias": "model-00002-of-00002.safetensors",
532
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.12.layer_norm2.weight": "model-00002-of-00002.safetensors",
533
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.12.mlp.fc1.bias": "model-00002-of-00002.safetensors",
534
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.12.mlp.fc1.weight": "model-00002-of-00002.safetensors",
535
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.12.mlp.fc2.bias": "model-00002-of-00002.safetensors",
536
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.12.mlp.fc2.weight": "model-00002-of-00002.safetensors",
537
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.12.self_attn.k_proj.bias": "model-00002-of-00002.safetensors",
538
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.12.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
539
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.12.self_attn.out_proj.bias": "model-00002-of-00002.safetensors",
540
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.12.self_attn.out_proj.weight": "model-00002-of-00002.safetensors",
541
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.12.self_attn.q_proj.bias": "model-00002-of-00002.safetensors",
542
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.12.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
543
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.12.self_attn.v_proj.bias": "model-00002-of-00002.safetensors",
544
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.12.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
545
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.13.layer_norm1.bias": "model-00002-of-00002.safetensors",
546
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.13.layer_norm1.weight": "model-00002-of-00002.safetensors",
547
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.13.layer_norm2.bias": "model-00002-of-00002.safetensors",
548
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.13.layer_norm2.weight": "model-00002-of-00002.safetensors",
549
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.13.mlp.fc1.bias": "model-00002-of-00002.safetensors",
550
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.13.mlp.fc1.weight": "model-00002-of-00002.safetensors",
551
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.13.mlp.fc2.bias": "model-00002-of-00002.safetensors",
552
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.13.mlp.fc2.weight": "model-00002-of-00002.safetensors",
553
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.13.self_attn.k_proj.bias": "model-00002-of-00002.safetensors",
554
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.13.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
555
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.13.self_attn.out_proj.bias": "model-00002-of-00002.safetensors",
556
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.13.self_attn.out_proj.weight": "model-00002-of-00002.safetensors",
557
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.13.self_attn.q_proj.bias": "model-00002-of-00002.safetensors",
558
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.13.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
559
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.13.self_attn.v_proj.bias": "model-00002-of-00002.safetensors",
560
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.13.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
561
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.14.layer_norm1.bias": "model-00002-of-00002.safetensors",
562
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.14.layer_norm1.weight": "model-00002-of-00002.safetensors",
563
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.14.layer_norm2.bias": "model-00002-of-00002.safetensors",
564
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.14.layer_norm2.weight": "model-00002-of-00002.safetensors",
565
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.14.mlp.fc1.bias": "model-00002-of-00002.safetensors",
566
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.14.mlp.fc1.weight": "model-00002-of-00002.safetensors",
567
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.14.mlp.fc2.bias": "model-00002-of-00002.safetensors",
568
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.14.mlp.fc2.weight": "model-00002-of-00002.safetensors",
569
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.14.self_attn.k_proj.bias": "model-00002-of-00002.safetensors",
570
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.14.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
571
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.14.self_attn.out_proj.bias": "model-00002-of-00002.safetensors",
572
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.14.self_attn.out_proj.weight": "model-00002-of-00002.safetensors",
573
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.14.self_attn.q_proj.bias": "model-00002-of-00002.safetensors",
574
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.14.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
575
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.14.self_attn.v_proj.bias": "model-00002-of-00002.safetensors",
576
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.14.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
577
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.15.layer_norm1.bias": "model-00002-of-00002.safetensors",
578
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.15.layer_norm1.weight": "model-00002-of-00002.safetensors",
579
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.15.layer_norm2.bias": "model-00002-of-00002.safetensors",
580
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.15.layer_norm2.weight": "model-00002-of-00002.safetensors",
581
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.15.mlp.fc1.bias": "model-00002-of-00002.safetensors",
582
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.15.mlp.fc1.weight": "model-00002-of-00002.safetensors",
583
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.15.mlp.fc2.bias": "model-00002-of-00002.safetensors",
584
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.15.mlp.fc2.weight": "model-00002-of-00002.safetensors",
585
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.15.self_attn.k_proj.bias": "model-00002-of-00002.safetensors",
586
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.15.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
587
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.15.self_attn.out_proj.bias": "model-00002-of-00002.safetensors",
588
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.15.self_attn.out_proj.weight": "model-00002-of-00002.safetensors",
589
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.15.self_attn.q_proj.bias": "model-00002-of-00002.safetensors",
590
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.15.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
591
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.15.self_attn.v_proj.bias": "model-00002-of-00002.safetensors",
592
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.15.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
593
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.16.layer_norm1.bias": "model-00002-of-00002.safetensors",
594
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.16.layer_norm1.weight": "model-00002-of-00002.safetensors",
595
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.16.layer_norm2.bias": "model-00002-of-00002.safetensors",
596
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.16.layer_norm2.weight": "model-00002-of-00002.safetensors",
597
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.16.mlp.fc1.bias": "model-00002-of-00002.safetensors",
598
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.16.mlp.fc1.weight": "model-00002-of-00002.safetensors",
599
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.16.mlp.fc2.bias": "model-00002-of-00002.safetensors",
600
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.16.mlp.fc2.weight": "model-00002-of-00002.safetensors",
601
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.16.self_attn.k_proj.bias": "model-00002-of-00002.safetensors",
602
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.16.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
603
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.16.self_attn.out_proj.bias": "model-00002-of-00002.safetensors",
604
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.16.self_attn.out_proj.weight": "model-00002-of-00002.safetensors",
605
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.16.self_attn.q_proj.bias": "model-00002-of-00002.safetensors",
606
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.16.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
607
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.16.self_attn.v_proj.bias": "model-00002-of-00002.safetensors",
608
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.16.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
609
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.17.layer_norm1.bias": "model-00002-of-00002.safetensors",
610
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.17.layer_norm1.weight": "model-00002-of-00002.safetensors",
611
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.17.layer_norm2.bias": "model-00002-of-00002.safetensors",
612
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.17.layer_norm2.weight": "model-00002-of-00002.safetensors",
613
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.17.mlp.fc1.bias": "model-00002-of-00002.safetensors",
614
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.17.mlp.fc1.weight": "model-00002-of-00002.safetensors",
615
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.17.mlp.fc2.bias": "model-00002-of-00002.safetensors",
616
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.17.mlp.fc2.weight": "model-00002-of-00002.safetensors",
617
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.17.self_attn.k_proj.bias": "model-00002-of-00002.safetensors",
618
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.17.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
619
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.17.self_attn.out_proj.bias": "model-00002-of-00002.safetensors",
620
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.17.self_attn.out_proj.weight": "model-00002-of-00002.safetensors",
621
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.17.self_attn.q_proj.bias": "model-00002-of-00002.safetensors",
622
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.17.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
623
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.17.self_attn.v_proj.bias": "model-00002-of-00002.safetensors",
624
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.17.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
625
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.18.layer_norm1.bias": "model-00002-of-00002.safetensors",
626
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.18.layer_norm1.weight": "model-00002-of-00002.safetensors",
627
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.18.layer_norm2.bias": "model-00002-of-00002.safetensors",
628
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.18.layer_norm2.weight": "model-00002-of-00002.safetensors",
629
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.18.mlp.fc1.bias": "model-00002-of-00002.safetensors",
630
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.18.mlp.fc1.weight": "model-00002-of-00002.safetensors",
631
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.18.mlp.fc2.bias": "model-00002-of-00002.safetensors",
632
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.18.mlp.fc2.weight": "model-00002-of-00002.safetensors",
633
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.18.self_attn.k_proj.bias": "model-00002-of-00002.safetensors",
634
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.18.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
635
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.18.self_attn.out_proj.bias": "model-00002-of-00002.safetensors",
636
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.18.self_attn.out_proj.weight": "model-00002-of-00002.safetensors",
637
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.18.self_attn.q_proj.bias": "model-00002-of-00002.safetensors",
638
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.18.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
639
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.18.self_attn.v_proj.bias": "model-00002-of-00002.safetensors",
640
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.18.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
641
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.19.layer_norm1.bias": "model-00002-of-00002.safetensors",
642
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.19.layer_norm1.weight": "model-00002-of-00002.safetensors",
643
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.19.layer_norm2.bias": "model-00002-of-00002.safetensors",
644
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.19.layer_norm2.weight": "model-00002-of-00002.safetensors",
645
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.19.mlp.fc1.bias": "model-00002-of-00002.safetensors",
646
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.19.mlp.fc1.weight": "model-00002-of-00002.safetensors",
647
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.19.mlp.fc2.bias": "model-00002-of-00002.safetensors",
648
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.19.mlp.fc2.weight": "model-00002-of-00002.safetensors",
649
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.19.self_attn.k_proj.bias": "model-00002-of-00002.safetensors",
650
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.19.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
651
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.19.self_attn.out_proj.bias": "model-00002-of-00002.safetensors",
652
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.19.self_attn.out_proj.weight": "model-00002-of-00002.safetensors",
653
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.19.self_attn.q_proj.bias": "model-00002-of-00002.safetensors",
654
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.19.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
655
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.19.self_attn.v_proj.bias": "model-00002-of-00002.safetensors",
656
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.19.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
657
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.2.layer_norm1.bias": "model-00002-of-00002.safetensors",
658
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.2.layer_norm1.weight": "model-00002-of-00002.safetensors",
659
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.2.layer_norm2.bias": "model-00002-of-00002.safetensors",
660
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.2.layer_norm2.weight": "model-00002-of-00002.safetensors",
661
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.2.mlp.fc1.bias": "model-00002-of-00002.safetensors",
662
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.2.mlp.fc1.weight": "model-00002-of-00002.safetensors",
663
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.2.mlp.fc2.bias": "model-00002-of-00002.safetensors",
664
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.2.mlp.fc2.weight": "model-00002-of-00002.safetensors",
665
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.2.self_attn.k_proj.bias": "model-00002-of-00002.safetensors",
666
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.2.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
667
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.2.self_attn.out_proj.bias": "model-00002-of-00002.safetensors",
668
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.2.self_attn.out_proj.weight": "model-00002-of-00002.safetensors",
669
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.2.self_attn.q_proj.bias": "model-00002-of-00002.safetensors",
670
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.2.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
671
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.2.self_attn.v_proj.bias": "model-00002-of-00002.safetensors",
672
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.2.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
673
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.20.layer_norm1.bias": "model-00002-of-00002.safetensors",
674
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.20.layer_norm1.weight": "model-00002-of-00002.safetensors",
675
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.20.layer_norm2.bias": "model-00002-of-00002.safetensors",
676
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.20.layer_norm2.weight": "model-00002-of-00002.safetensors",
677
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.20.mlp.fc1.bias": "model-00002-of-00002.safetensors",
678
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.20.mlp.fc1.weight": "model-00002-of-00002.safetensors",
679
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.20.mlp.fc2.bias": "model-00002-of-00002.safetensors",
680
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.20.mlp.fc2.weight": "model-00002-of-00002.safetensors",
681
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.20.self_attn.k_proj.bias": "model-00002-of-00002.safetensors",
682
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.20.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
683
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.20.self_attn.out_proj.bias": "model-00002-of-00002.safetensors",
684
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.20.self_attn.out_proj.weight": "model-00002-of-00002.safetensors",
685
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.20.self_attn.q_proj.bias": "model-00002-of-00002.safetensors",
686
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.20.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
687
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.20.self_attn.v_proj.bias": "model-00002-of-00002.safetensors",
688
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.20.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
689
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.21.layer_norm1.bias": "model-00002-of-00002.safetensors",
690
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.21.layer_norm1.weight": "model-00002-of-00002.safetensors",
691
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.21.layer_norm2.bias": "model-00002-of-00002.safetensors",
692
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.21.layer_norm2.weight": "model-00002-of-00002.safetensors",
693
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.21.mlp.fc1.bias": "model-00002-of-00002.safetensors",
694
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.21.mlp.fc1.weight": "model-00002-of-00002.safetensors",
695
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.21.mlp.fc2.bias": "model-00002-of-00002.safetensors",
696
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.21.mlp.fc2.weight": "model-00002-of-00002.safetensors",
697
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.21.self_attn.k_proj.bias": "model-00002-of-00002.safetensors",
698
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.21.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
699
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.21.self_attn.out_proj.bias": "model-00002-of-00002.safetensors",
700
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.21.self_attn.out_proj.weight": "model-00002-of-00002.safetensors",
701
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.21.self_attn.q_proj.bias": "model-00002-of-00002.safetensors",
702
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.21.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
703
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.21.self_attn.v_proj.bias": "model-00002-of-00002.safetensors",
704
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.21.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
705
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.22.layer_norm1.bias": "model-00002-of-00002.safetensors",
706
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.22.layer_norm1.weight": "model-00002-of-00002.safetensors",
707
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.22.layer_norm2.bias": "model-00002-of-00002.safetensors",
708
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.22.layer_norm2.weight": "model-00002-of-00002.safetensors",
709
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.22.mlp.fc1.bias": "model-00002-of-00002.safetensors",
710
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.22.mlp.fc1.weight": "model-00002-of-00002.safetensors",
711
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.22.mlp.fc2.bias": "model-00002-of-00002.safetensors",
712
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.22.mlp.fc2.weight": "model-00002-of-00002.safetensors",
713
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.22.self_attn.k_proj.bias": "model-00002-of-00002.safetensors",
714
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.22.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
715
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.22.self_attn.out_proj.bias": "model-00002-of-00002.safetensors",
716
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.22.self_attn.out_proj.weight": "model-00002-of-00002.safetensors",
717
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.22.self_attn.q_proj.bias": "model-00002-of-00002.safetensors",
718
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.22.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
719
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.22.self_attn.v_proj.bias": "model-00002-of-00002.safetensors",
720
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.22.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
721
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.23.layer_norm1.bias": "model-00002-of-00002.safetensors",
722
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.23.layer_norm1.weight": "model-00002-of-00002.safetensors",
723
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.23.layer_norm2.bias": "model-00002-of-00002.safetensors",
724
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.23.layer_norm2.weight": "model-00002-of-00002.safetensors",
725
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.23.mlp.fc1.bias": "model-00002-of-00002.safetensors",
726
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.23.mlp.fc1.weight": "model-00002-of-00002.safetensors",
727
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.23.mlp.fc2.bias": "model-00002-of-00002.safetensors",
728
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.23.mlp.fc2.weight": "model-00002-of-00002.safetensors",
729
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.23.self_attn.k_proj.bias": "model-00002-of-00002.safetensors",
730
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.23.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
731
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.23.self_attn.out_proj.bias": "model-00002-of-00002.safetensors",
732
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.23.self_attn.out_proj.weight": "model-00002-of-00002.safetensors",
733
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.23.self_attn.q_proj.bias": "model-00002-of-00002.safetensors",
734
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.23.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
735
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.23.self_attn.v_proj.bias": "model-00002-of-00002.safetensors",
736
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.23.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
737
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.3.layer_norm1.bias": "model-00002-of-00002.safetensors",
738
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.3.layer_norm1.weight": "model-00002-of-00002.safetensors",
739
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.3.layer_norm2.bias": "model-00002-of-00002.safetensors",
740
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.3.layer_norm2.weight": "model-00002-of-00002.safetensors",
741
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.3.mlp.fc1.bias": "model-00002-of-00002.safetensors",
742
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.3.mlp.fc1.weight": "model-00002-of-00002.safetensors",
743
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.3.mlp.fc2.bias": "model-00002-of-00002.safetensors",
744
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.3.mlp.fc2.weight": "model-00002-of-00002.safetensors",
745
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.3.self_attn.k_proj.bias": "model-00002-of-00002.safetensors",
746
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.3.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
747
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.3.self_attn.out_proj.bias": "model-00002-of-00002.safetensors",
748
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.3.self_attn.out_proj.weight": "model-00002-of-00002.safetensors",
749
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.3.self_attn.q_proj.bias": "model-00002-of-00002.safetensors",
750
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.3.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
751
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.3.self_attn.v_proj.bias": "model-00002-of-00002.safetensors",
752
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.3.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
753
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.4.layer_norm1.bias": "model-00002-of-00002.safetensors",
754
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.4.layer_norm1.weight": "model-00002-of-00002.safetensors",
755
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.4.layer_norm2.bias": "model-00002-of-00002.safetensors",
756
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.4.layer_norm2.weight": "model-00002-of-00002.safetensors",
757
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.4.mlp.fc1.bias": "model-00002-of-00002.safetensors",
758
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.4.mlp.fc1.weight": "model-00002-of-00002.safetensors",
759
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.4.mlp.fc2.bias": "model-00002-of-00002.safetensors",
760
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.4.mlp.fc2.weight": "model-00002-of-00002.safetensors",
761
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.4.self_attn.k_proj.bias": "model-00002-of-00002.safetensors",
762
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.4.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
763
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.4.self_attn.out_proj.bias": "model-00002-of-00002.safetensors",
764
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.4.self_attn.out_proj.weight": "model-00002-of-00002.safetensors",
765
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.4.self_attn.q_proj.bias": "model-00002-of-00002.safetensors",
766
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.4.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
767
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.4.self_attn.v_proj.bias": "model-00002-of-00002.safetensors",
768
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.4.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
769
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.5.layer_norm1.bias": "model-00002-of-00002.safetensors",
770
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.5.layer_norm1.weight": "model-00002-of-00002.safetensors",
771
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.5.layer_norm2.bias": "model-00002-of-00002.safetensors",
772
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.5.layer_norm2.weight": "model-00002-of-00002.safetensors",
773
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.5.mlp.fc1.bias": "model-00002-of-00002.safetensors",
774
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.5.mlp.fc1.weight": "model-00002-of-00002.safetensors",
775
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.5.mlp.fc2.bias": "model-00002-of-00002.safetensors",
776
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.5.mlp.fc2.weight": "model-00002-of-00002.safetensors",
777
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.5.self_attn.k_proj.bias": "model-00002-of-00002.safetensors",
778
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.5.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
779
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.5.self_attn.out_proj.bias": "model-00002-of-00002.safetensors",
780
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.5.self_attn.out_proj.weight": "model-00002-of-00002.safetensors",
781
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.5.self_attn.q_proj.bias": "model-00002-of-00002.safetensors",
782
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.5.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
783
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.5.self_attn.v_proj.bias": "model-00002-of-00002.safetensors",
784
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.5.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
785
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.6.layer_norm1.bias": "model-00002-of-00002.safetensors",
786
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.6.layer_norm1.weight": "model-00002-of-00002.safetensors",
787
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.6.layer_norm2.bias": "model-00002-of-00002.safetensors",
788
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.6.layer_norm2.weight": "model-00002-of-00002.safetensors",
789
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.6.mlp.fc1.bias": "model-00002-of-00002.safetensors",
790
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.6.mlp.fc1.weight": "model-00002-of-00002.safetensors",
791
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.6.mlp.fc2.bias": "model-00002-of-00002.safetensors",
792
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.6.mlp.fc2.weight": "model-00002-of-00002.safetensors",
793
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.6.self_attn.k_proj.bias": "model-00002-of-00002.safetensors",
794
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.6.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
795
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.6.self_attn.out_proj.bias": "model-00002-of-00002.safetensors",
796
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.6.self_attn.out_proj.weight": "model-00002-of-00002.safetensors",
797
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.6.self_attn.q_proj.bias": "model-00002-of-00002.safetensors",
798
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.6.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
799
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.6.self_attn.v_proj.bias": "model-00002-of-00002.safetensors",
800
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.6.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
801
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.7.layer_norm1.bias": "model-00002-of-00002.safetensors",
802
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.7.layer_norm1.weight": "model-00002-of-00002.safetensors",
803
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.7.layer_norm2.bias": "model-00002-of-00002.safetensors",
804
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.7.layer_norm2.weight": "model-00002-of-00002.safetensors",
805
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.7.mlp.fc1.bias": "model-00002-of-00002.safetensors",
806
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.7.mlp.fc1.weight": "model-00002-of-00002.safetensors",
807
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.7.mlp.fc2.bias": "model-00002-of-00002.safetensors",
808
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.7.mlp.fc2.weight": "model-00002-of-00002.safetensors",
809
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.7.self_attn.k_proj.bias": "model-00002-of-00002.safetensors",
810
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.7.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
811
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.7.self_attn.out_proj.bias": "model-00002-of-00002.safetensors",
812
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.7.self_attn.out_proj.weight": "model-00002-of-00002.safetensors",
813
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.7.self_attn.q_proj.bias": "model-00002-of-00002.safetensors",
814
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.7.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
815
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.7.self_attn.v_proj.bias": "model-00002-of-00002.safetensors",
816
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.7.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
817
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.8.layer_norm1.bias": "model-00002-of-00002.safetensors",
818
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.8.layer_norm1.weight": "model-00002-of-00002.safetensors",
819
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.8.layer_norm2.bias": "model-00002-of-00002.safetensors",
820
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.8.layer_norm2.weight": "model-00002-of-00002.safetensors",
821
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.8.mlp.fc1.bias": "model-00002-of-00002.safetensors",
822
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.8.mlp.fc1.weight": "model-00002-of-00002.safetensors",
823
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.8.mlp.fc2.bias": "model-00002-of-00002.safetensors",
824
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.8.mlp.fc2.weight": "model-00002-of-00002.safetensors",
825
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.8.self_attn.k_proj.bias": "model-00002-of-00002.safetensors",
826
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.8.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
827
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.8.self_attn.out_proj.bias": "model-00002-of-00002.safetensors",
828
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.8.self_attn.out_proj.weight": "model-00002-of-00002.safetensors",
829
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.8.self_attn.q_proj.bias": "model-00002-of-00002.safetensors",
830
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.8.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
831
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.8.self_attn.v_proj.bias": "model-00002-of-00002.safetensors",
832
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.8.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
833
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.9.layer_norm1.bias": "model-00002-of-00002.safetensors",
834
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.9.layer_norm1.weight": "model-00002-of-00002.safetensors",
835
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.9.layer_norm2.bias": "model-00002-of-00002.safetensors",
836
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.9.layer_norm2.weight": "model-00002-of-00002.safetensors",
837
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.9.mlp.fc1.bias": "model-00002-of-00002.safetensors",
838
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.9.mlp.fc1.weight": "model-00002-of-00002.safetensors",
839
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.9.mlp.fc2.bias": "model-00002-of-00002.safetensors",
840
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.9.mlp.fc2.weight": "model-00002-of-00002.safetensors",
841
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.9.self_attn.k_proj.bias": "model-00002-of-00002.safetensors",
842
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.9.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
843
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.9.self_attn.out_proj.bias": "model-00002-of-00002.safetensors",
844
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.9.self_attn.out_proj.weight": "model-00002-of-00002.safetensors",
845
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.9.self_attn.q_proj.bias": "model-00002-of-00002.safetensors",
846
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.9.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
847
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.9.self_attn.v_proj.bias": "model-00002-of-00002.safetensors",
848
+ "model.vision_tower.vision_tower.vision_model.encoder.layers.9.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
849
+ "model.vision_tower.vision_tower.vision_model.post_layernorm.bias": "model-00002-of-00002.safetensors",
850
+ "model.vision_tower.vision_tower.vision_model.post_layernorm.weight": "model-00002-of-00002.safetensors",
851
+ "model.vision_tower.vision_tower.vision_model.pre_layrnorm.bias": "model-00002-of-00002.safetensors",
852
+ "model.vision_tower.vision_tower.vision_model.pre_layrnorm.weight": "model-00002-of-00002.safetensors"
853
+ }
854
+ }
modeling_llava_phi.py ADDED
@@ -0,0 +1,252 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from typing import List, Optional, Tuple, Union
2
+
3
+ import torch
4
+ import torch.nn as nn
5
+ import math
6
+ import pdb
7
+ from typing import Dict, Any
8
+ from PIL import Image
9
+
10
+ from transformers import AutoConfig, AutoModelForCausalLM, PretrainedConfig, PreTrainedModel
11
+
12
+
13
+ from transformers.modeling_outputs import CausalLMOutputWithPast
14
+
15
+ from .llava_arch import LlavaMetaModel, LlavaMetaForCausalLM
16
+
17
+ from transformers.cache_utils import Cache, DynamicCache
18
+
19
+ from transformers.generation.utils import GenerationConfig
20
+
21
+ import sys
22
+ from .modeling_phi import PhiForCausalLM, PhiModel, PhiConfig
23
+ from .generation_utils import build_allava_input
24
+
25
+
26
+
27
+
28
+ ################ Phi ###############################
29
+
30
+ class LlavaPhiConfig(PhiConfig):
31
+ model_type = "llava_phi"
32
+
33
+ class LlavaPhiModel(LlavaMetaModel, PhiModel):
34
+ config_class = LlavaPhiConfig
35
+
36
+ def __init__(self, config: PhiConfig):
37
+ super(LlavaPhiModel, self).__init__(config)
38
+
39
+
40
+
41
+ class LlavaPhiForCausalLM(PhiForCausalLM, LlavaMetaForCausalLM):
42
+ config_class = LlavaPhiConfig
43
+
44
+ def __init__(self, config, init_vision_encoder_from_ckpt=True):
45
+ # note that the default value is set to True for this inference version. In training `init_vision_encoder_from_ckpt` is default to be True.
46
+ config._attn_implementation = "flash_attention_2"
47
+
48
+ super(PhiForCausalLM, self).__init__(config)
49
+ # self.model is used in LlavaMetaForCausalLM.get_model(); self.transformer is used in PhiForCausalLM.forward()
50
+ self.model = LlavaPhiModel(config)
51
+ if hasattr(self.model, '_use_flash_attention_2'):
52
+ assert self.model._use_flash_attention_2, 'flash attn is not enabled. check it out!'
53
+ self.vocab_size = config.vocab_size
54
+ self.lm_head = nn.Linear(config.hidden_size, config.vocab_size, bias=False)
55
+
56
+ if init_vision_encoder_from_ckpt:
57
+ vision_tower = self.get_vision_tower()
58
+ print(f'loading from CLIP first. This should only be used at inference!!!')
59
+ vision_tower.load_model() #
60
+
61
+ # Initialize weights and apply final processing
62
+ self.post_init()
63
+
64
+ def get_model(self):
65
+ return self.model
66
+
67
+ def get_tokenizer(self):
68
+ return self.tokenizer
69
+
70
+ def get_processor(self):
71
+ return self.model.vision_tower.image_processor
72
+
73
+
74
+ def forward(
75
+ self,
76
+ input_ids: torch.LongTensor = None,
77
+ attention_mask: Optional[torch.Tensor] = None,
78
+ position_ids: Optional[torch.LongTensor] = None,
79
+ past_key_values: Optional[List[torch.FloatTensor]] = None,
80
+ inputs_embeds: Optional[torch.FloatTensor] = None,
81
+ labels: Optional[torch.LongTensor] = None,
82
+ use_cache: Optional[bool] = None,
83
+ output_attentions: Optional[bool] = None,
84
+ output_hidden_states: Optional[bool] = None,
85
+ images: Optional[torch.FloatTensor] = None,
86
+ return_dict: Optional[bool] = None,
87
+ ) -> Union[Tuple, CausalLMOutputWithPast]:
88
+
89
+
90
+ if inputs_embeds is None:
91
+ (
92
+ input_ids,
93
+ position_ids,
94
+ attention_mask,
95
+ past_key_values,
96
+ inputs_embeds,
97
+ labels
98
+ # ) = self.prepare_inputs_labels_for_multimodal(
99
+ ) = self.prepare_inputs_labels_for_multimodal_new(
100
+ input_ids,
101
+ position_ids,
102
+ attention_mask,
103
+ past_key_values,
104
+ labels,
105
+ images
106
+ )
107
+
108
+ # pdb.set_trace()
109
+ return super().forward(
110
+ input_ids=input_ids,
111
+ attention_mask=attention_mask,
112
+ position_ids=position_ids,
113
+ past_key_values=past_key_values,
114
+ inputs_embeds=inputs_embeds,
115
+ labels=labels,
116
+ use_cache=use_cache,
117
+ output_attentions=output_attentions,
118
+ output_hidden_states=output_hidden_states,
119
+ return_dict=return_dict
120
+ )
121
+
122
+ def prepare_inputs_for_generation(self, input_ids, past_key_values=None, attention_mask=None, inputs_embeds=None, **kwargs):
123
+ '''
124
+ This function is called for each token at inference
125
+ '''
126
+ # pdb.set_trace()
127
+ images = kwargs.pop("images", None)
128
+
129
+ ####################################################
130
+ # lines from modeling_phi.py
131
+ ####################################################
132
+
133
+ if past_key_values is not None:
134
+ if isinstance(past_key_values, Cache):
135
+ cache_length = past_key_values.get_seq_length()
136
+ past_length = past_key_values.seen_tokens
137
+ max_cache_length = past_key_values.get_max_length()
138
+ else:
139
+ cache_length = past_length = past_key_values[0][0].shape[2]
140
+ max_cache_length = None
141
+
142
+ # Keep only the unprocessed tokens:
143
+ # 1 - If the length of the attention_mask exceeds the length of input_ids, then we are in a setting where
144
+ # some of the inputs are exclusively passed as part of the cache (e.g. when passing input_embeds as
145
+ # input)
146
+ if attention_mask is not None and attention_mask.shape[1] > input_ids.shape[1]:
147
+ input_ids = input_ids[:, -(attention_mask.shape[1] - past_length) :]
148
+ # 2 - If the past_length is smaller than input_ids', then input_ids holds all input tokens. We can discard
149
+ # input_ids based on the past_length.
150
+ elif past_length < input_ids.shape[1]:
151
+ input_ids = input_ids[:, past_length:]
152
+ # 3 - Otherwise (past_length >= input_ids.shape[1]), let's assume input_ids only has unprocessed tokens.
153
+ elif past_length >= input_ids.shape[1]:
154
+ input_ids = input_ids[:, [-1]] # only keep the last one!
155
+
156
+ # If we are about to go beyond the maximum cache length, we need to crop the input attention mask.
157
+ if (
158
+ max_cache_length is not None
159
+ and attention_mask is not None
160
+ and cache_length + input_ids.shape[1] > max_cache_length
161
+ ):
162
+ attention_mask = attention_mask[:, -max_cache_length:]
163
+
164
+ position_ids = kwargs.get("position_ids", None)
165
+ if attention_mask is not None and position_ids is None:
166
+ # create position_ids on the fly for batch generation
167
+ position_ids = attention_mask.long().cumsum(-1) - 1
168
+ position_ids.masked_fill_(attention_mask == 0, 1)
169
+ if past_key_values:
170
+ position_ids = position_ids[:, -input_ids.shape[1] :]
171
+
172
+ # if `inputs_embeds` are passed, we only want to use them in the 1st generation step
173
+ if inputs_embeds is not None and past_key_values is None:
174
+ model_inputs = {"inputs_embeds": inputs_embeds}
175
+ else:
176
+ model_inputs = {"input_ids": input_ids}
177
+
178
+ model_inputs.update(
179
+ {
180
+ "position_ids": position_ids,
181
+ "past_key_values": past_key_values,
182
+ "use_cache": kwargs.get("use_cache"),
183
+ "attention_mask": attention_mask,
184
+ }
185
+ )
186
+ ####################################################
187
+ # end of lines from modeling_phi.py
188
+ ####################################################
189
+
190
+
191
+ if images is not None:
192
+ model_inputs['images'] = images
193
+ return model_inputs
194
+
195
+
196
+
197
+
198
+ def chat(
199
+ self,
200
+ texts: Optional[str | list[list[str, str]]],
201
+ images: Optional[str | list[str]] = None,
202
+ history: Optional[list[str]] = None,
203
+ stream = False,
204
+ return_history = False,
205
+ **kwargs
206
+ ):
207
+ '''
208
+ texts: if `str`, then generate for a single round; if list[dict],
209
+ images: str (optional), local path to an image.
210
+ '''
211
+ use_cache = kwargs.pop('use_cache', True)
212
+
213
+
214
+ ############################
215
+ # merge history
216
+ ############################
217
+ input_ids, image_tensors, history = build_allava_input(
218
+ tokenizer = self.get_tokenizer(),
219
+ processor = self.get_processor(),
220
+ texts = texts,
221
+ images = images,
222
+ history=history,
223
+ return_history=return_history,
224
+ device = self.device
225
+ )
226
+
227
+ ############################
228
+ # generate response
229
+ ############################
230
+ # with torch.autocast(device_type='cuda'):
231
+ if 'cuda' in str(self.device):
232
+ device_type = 'cuda'
233
+ else:
234
+ device_type = 'cpu'
235
+
236
+ with torch.autocast(device_type=device_type, dtype=self.dtype):
237
+ output_ids = self.generate(
238
+ inputs=input_ids,
239
+ images=image_tensors,
240
+ use_cache=use_cache,
241
+ **kwargs)
242
+
243
+ answer = self.get_tokenizer().decode(output_ids[0, input_ids.shape[1]:], skip_special_tokens=True).strip()
244
+
245
+ if return_history:
246
+ history[-1][-1] = answer
247
+ return answer, history
248
+ return answer
249
+
250
+
251
+ AutoConfig.register("llava_phi", LlavaPhiConfig)
252
+ AutoModelForCausalLM.register(LlavaPhiConfig, LlavaPhiForCausalLM)
modeling_phi.py ADDED
@@ -0,0 +1,1383 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # coding=utf-8
2
+ # Copyright 2023 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 model."""
17
+
18
+
19
+ import math
20
+ from typing import List, Optional, Tuple, Union
21
+
22
+ import torch
23
+ import torch.nn.functional as F
24
+ import torch.utils.checkpoint
25
+ from torch import nn
26
+ from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss
27
+
28
+ from transformers.activations import ACT2FN
29
+ # try:
30
+ from transformers.cache_utils import Cache, DynamicCache
31
+ # except:
32
+ # Cache, DynamicCache = None, None
33
+ from transformers.modeling_attn_mask_utils import _prepare_4d_causal_attention_mask
34
+ from transformers.modeling_outputs import (
35
+ BaseModelOutputWithPast,
36
+ CausalLMOutputWithPast,
37
+ SequenceClassifierOutputWithPast,
38
+ TokenClassifierOutput,
39
+ )
40
+ from transformers.modeling_utils import PreTrainedModel
41
+ from transformers.utils import (
42
+ add_code_sample_docstrings,
43
+ add_start_docstrings,
44
+ add_start_docstrings_to_model_forward,
45
+ is_flash_attn_2_available,
46
+ is_flash_attn_greater_or_equal_2_10, # dbg
47
+ logging,
48
+ replace_return_docstrings,
49
+ )
50
+
51
+ # is_flash_attn_greater_or_equal_2_10 = lambda:True # dbg
52
+
53
+ try:
54
+ from configuration_phi import PhiConfig
55
+ except:
56
+ from .configuration_phi import PhiConfig
57
+
58
+ try:
59
+ from flash_attn import flash_attn_func, flash_attn_varlen_func
60
+ from flash_attn.bert_padding import index_first_axis, pad_input, unpad_input # noqa
61
+ except:
62
+ pass
63
+
64
+ import pdb
65
+
66
+ logger = logging.get_logger(__name__)
67
+
68
+ _CHECKPOINT_FOR_DOC = "microsoft/phi-2"
69
+ _CONFIG_FOR_DOC = "PhiConfig"
70
+
71
+ PHI_PRETRAINED_MODEL_ARCHIVE_LIST = [
72
+ "microsoft/phi-2",
73
+ # See all Phi models at https://huggingface.co/models?filter=phi
74
+ ]
75
+
76
+
77
+ # Copied from transformers.models.llama.modeling_llama._get_unpad_data
78
+ def _get_unpad_data(attention_mask):
79
+ seqlens_in_batch = attention_mask.sum(dim=-1, dtype=torch.int32)
80
+ indices = torch.nonzero(attention_mask.flatten(), as_tuple=False).flatten()
81
+ max_seqlen_in_batch = seqlens_in_batch.max().item()
82
+ cu_seqlens = F.pad(torch.cumsum(seqlens_in_batch, dim=0, dtype=torch.torch.int32), (1, 0))
83
+ return (
84
+ indices,
85
+ cu_seqlens,
86
+ max_seqlen_in_batch,
87
+ )
88
+
89
+
90
+ # Copied from transformers.models.llama.modeling_llama.LlamaRotaryEmbedding with Llama->Phi
91
+ class PhiRotaryEmbedding(nn.Module):
92
+ def __init__(self, dim, max_position_embeddings=2048, base=10000, device=None):
93
+ super().__init__()
94
+
95
+ self.dim = dim
96
+ self.max_position_embeddings = max_position_embeddings
97
+ self.base = base
98
+ inv_freq = 1.0 / (self.base ** (torch.arange(0, self.dim, 2).float().to(device) / self.dim))
99
+ self.register_buffer("inv_freq", inv_freq, persistent=False)
100
+
101
+ # Build here to make `torch.jit.trace` work.
102
+ self._set_cos_sin_cache(
103
+ seq_len=max_position_embeddings, device=self.inv_freq.device, dtype=torch.get_default_dtype()
104
+ )
105
+
106
+ def _set_cos_sin_cache(self, seq_len, device, dtype):
107
+ self.max_seq_len_cached = seq_len
108
+ t = torch.arange(self.max_seq_len_cached, device=device, dtype=self.inv_freq.dtype)
109
+
110
+ freqs = torch.outer(t, self.inv_freq)
111
+ # Different from paper, but it uses a different permutation in order to obtain the same calculation
112
+ emb = torch.cat((freqs, freqs), dim=-1)
113
+ self.register_buffer("cos_cached", emb.cos().to(dtype), persistent=False)
114
+ self.register_buffer("sin_cached", emb.sin().to(dtype), persistent=False)
115
+
116
+ def forward(self, x, seq_len=None):
117
+ # x: [bs, num_attention_heads, seq_len, head_size]
118
+ if seq_len > self.max_seq_len_cached:
119
+ self._set_cos_sin_cache(seq_len=seq_len, device=x.device, dtype=x.dtype)
120
+
121
+ return (
122
+ self.cos_cached[:seq_len].to(dtype=x.dtype),
123
+ self.sin_cached[:seq_len].to(dtype=x.dtype),
124
+ )
125
+
126
+
127
+ # Copied from transformers.models.llama.modeling_llama.LlamaLinearScalingRotaryEmbedding with Llama->Phi
128
+ class PhiLinearScalingRotaryEmbedding(PhiRotaryEmbedding):
129
+ """PhiRotaryEmbedding extended with linear scaling. Credits to the Reddit user /u/kaiokendev"""
130
+
131
+ def __init__(self, dim, max_position_embeddings=2048, base=10000, device=None, scaling_factor=1.0):
132
+ self.scaling_factor = scaling_factor
133
+ super().__init__(dim, max_position_embeddings, base, device)
134
+
135
+ def _set_cos_sin_cache(self, seq_len, device, dtype):
136
+ self.max_seq_len_cached = seq_len
137
+ t = torch.arange(self.max_seq_len_cached, device=device, dtype=self.inv_freq.dtype)
138
+ t = t / self.scaling_factor
139
+
140
+ freqs = torch.outer(t, self.inv_freq)
141
+ # Different from paper, but it uses a different permutation in order to obtain the same calculation
142
+ emb = torch.cat((freqs, freqs), dim=-1)
143
+ self.register_buffer("cos_cached", emb.cos().to(dtype), persistent=False)
144
+ self.register_buffer("sin_cached", emb.sin().to(dtype), persistent=False)
145
+
146
+
147
+ # Copied from transformers.models.llama.modeling_llama.LlamaDynamicNTKScalingRotaryEmbedding with Llama->Phi
148
+ class PhiDynamicNTKScalingRotaryEmbedding(PhiRotaryEmbedding):
149
+ """PhiRotaryEmbedding extended with Dynamic NTK scaling. Credits to the Reddit users /u/bloc97 and /u/emozilla"""
150
+
151
+ def __init__(self, dim, max_position_embeddings=2048, base=10000, device=None, scaling_factor=1.0):
152
+ self.scaling_factor = scaling_factor
153
+ super().__init__(dim, max_position_embeddings, base, device)
154
+
155
+ def _set_cos_sin_cache(self, seq_len, device, dtype):
156
+ self.max_seq_len_cached = seq_len
157
+
158
+ if seq_len > self.max_position_embeddings:
159
+ base = self.base * (
160
+ (self.scaling_factor * seq_len / self.max_position_embeddings) - (self.scaling_factor - 1)
161
+ ) ** (self.dim / (self.dim - 2))
162
+ inv_freq = 1.0 / (base ** (torch.arange(0, self.dim, 2).float().to(device) / self.dim))
163
+ self.register_buffer("inv_freq", inv_freq, persistent=False)
164
+
165
+ t = torch.arange(self.max_seq_len_cached, device=device, dtype=self.inv_freq.dtype)
166
+
167
+ freqs = torch.outer(t, self.inv_freq)
168
+ # Different from paper, but it uses a different permutation in order to obtain the same calculation
169
+ emb = torch.cat((freqs, freqs), dim=-1)
170
+ self.register_buffer("cos_cached", emb.cos().to(dtype), persistent=False)
171
+ self.register_buffer("sin_cached", emb.sin().to(dtype), persistent=False)
172
+
173
+
174
+ # Copied from transformers.models.llama.modeling_llama.rotate_half
175
+ def rotate_half(x):
176
+ """Rotates half the hidden dims of the input."""
177
+ x1 = x[..., : x.shape[-1] // 2]
178
+ x2 = x[..., x.shape[-1] // 2 :]
179
+ return torch.cat((-x2, x1), dim=-1)
180
+
181
+
182
+ # Copied from transformers.models.llama.modeling_llama.apply_rotary_pos_emb
183
+ def apply_rotary_pos_emb(q, k, cos, sin, position_ids, unsqueeze_dim=1):
184
+ """Applies Rotary Position Embedding to the query and key tensors.
185
+
186
+ Args:
187
+ q (`torch.Tensor`): The query tensor.
188
+ k (`torch.Tensor`): The key tensor.
189
+ cos (`torch.Tensor`): The cosine part of the rotary embedding.
190
+ sin (`torch.Tensor`): The sine part of the rotary embedding.
191
+ position_ids (`torch.Tensor`):
192
+ The position indices of the tokens corresponding to the query and key tensors. For example, this can be
193
+ used to pass offsetted position ids when working with a KV-cache.
194
+ unsqueeze_dim (`int`, *optional*, defaults to 1):
195
+ The 'unsqueeze_dim' argument specifies the dimension along which to unsqueeze cos[position_ids] and
196
+ sin[position_ids] so that they can be properly broadcasted to the dimensions of q and k. For example, note
197
+ that cos[position_ids] and sin[position_ids] have the shape [batch_size, seq_len, head_dim]. Then, if q and
198
+ k have the shape [batch_size, heads, seq_len, head_dim], then setting unsqueeze_dim=1 makes
199
+ cos[position_ids] and sin[position_ids] broadcastable to the shapes of q and k. Similarly, if q and k have
200
+ the shape [batch_size, seq_len, heads, head_dim], then set unsqueeze_dim=2.
201
+ Returns:
202
+ `tuple(torch.Tensor)` comprising of the query and key tensors rotated using the Rotary Position Embedding.
203
+ """
204
+ cos = cos[position_ids].unsqueeze(unsqueeze_dim)
205
+ sin = sin[position_ids].unsqueeze(unsqueeze_dim)
206
+ q_embed = (q * cos) + (rotate_half(q) * sin)
207
+ k_embed = (k * cos) + (rotate_half(k) * sin)
208
+ return q_embed, k_embed
209
+
210
+
211
+ # Copied from transformers.models.clip.modeling_clip.CLIPMLP with CLIP->Phi
212
+ class PhiMLP(nn.Module):
213
+ def __init__(self, config):
214
+ super().__init__()
215
+ self.config = config
216
+ self.activation_fn = ACT2FN[config.hidden_act]
217
+ self.fc1 = nn.Linear(config.hidden_size, config.intermediate_size)
218
+ self.fc2 = nn.Linear(config.intermediate_size, config.hidden_size)
219
+
220
+ def forward(self, hidden_states: torch.Tensor) -> torch.Tensor:
221
+ hidden_states = self.fc1(hidden_states)
222
+ hidden_states = self.activation_fn(hidden_states)
223
+ hidden_states = self.fc2(hidden_states)
224
+ return hidden_states
225
+
226
+
227
+ # Copied from transformers.models.llama.modeling_llama.repeat_kv with llama->phi
228
+ def repeat_kv(hidden_states: torch.Tensor, n_rep: int) -> torch.Tensor:
229
+ """
230
+ This is the equivalent of torch.repeat_interleave(x, dim=1, repeats=n_rep). The hidden states go from (batch,
231
+ num_key_value_heads, seqlen, head_dim) to (batch, num_attention_heads, seqlen, head_dim)
232
+ """
233
+ batch, num_key_value_heads, slen, head_dim = hidden_states.shape
234
+ if n_rep == 1:
235
+ return hidden_states
236
+ hidden_states = hidden_states[:, :, None, :, :].expand(batch, num_key_value_heads, n_rep, slen, head_dim)
237
+ return hidden_states.reshape(batch, num_key_value_heads * n_rep, slen, head_dim)
238
+
239
+
240
+ class PhiAttention(nn.Module):
241
+ """Multi-headed attention from 'Attention Is All You Need' paper"""
242
+
243
+ def __init__(self, config: PhiConfig, layer_idx: Optional[int] = None):
244
+ super().__init__()
245
+ self.config = config
246
+ self.layer_idx = layer_idx
247
+ if layer_idx is None:
248
+ logger.warning_once(
249
+ f"Instantiating {self.__class__.__name__} without passing `layer_idx` is not recommended and will "
250
+ "to errors during the forward call, if caching is used. Please make sure to provide a `layer_idx` "
251
+ "when creating this class."
252
+ )
253
+
254
+ self.attention_dropout = config.attention_dropout
255
+ self.hidden_size = config.hidden_size
256
+ self.num_heads = config.num_attention_heads
257
+ self.head_dim = self.hidden_size // self.num_heads
258
+ self.num_key_value_heads = config.num_key_value_heads
259
+ self.num_key_value_groups = self.num_heads // self.num_key_value_heads
260
+ self.max_position_embeddings = config.max_position_embeddings
261
+ self.rope_theta = config.rope_theta
262
+ self.partial_rotary_factor = config.partial_rotary_factor
263
+ self.is_causal = True
264
+
265
+ if (self.head_dim * self.num_heads) != self.hidden_size:
266
+ raise ValueError(
267
+ f"hidden_size must be divisible by num_heads (got `hidden_size`: {self.hidden_size}"
268
+ f" and `num_heads`: {self.num_heads})."
269
+ )
270
+
271
+ self.q_proj = nn.Linear(self.hidden_size, self.num_heads * self.head_dim, bias=True)
272
+ self.k_proj = nn.Linear(self.hidden_size, self.num_key_value_heads * self.head_dim, bias=True)
273
+ self.v_proj = nn.Linear(self.hidden_size, self.num_key_value_heads * self.head_dim, bias=True)
274
+ self.dense = nn.Linear(self.num_heads * self.head_dim, self.hidden_size, bias=True)
275
+
276
+ self.qk_layernorm = config.qk_layernorm
277
+ if self.qk_layernorm:
278
+ self.q_layernorm = nn.LayerNorm(
279
+ config.hidden_size // self.num_heads, eps=config.layer_norm_eps, elementwise_affine=True
280
+ )
281
+ self.k_layernorm = nn.LayerNorm(
282
+ config.hidden_size // self.num_heads, eps=config.layer_norm_eps, elementwise_affine=True
283
+ )
284
+
285
+ self._init_rope()
286
+
287
+ def _init_rope(self):
288
+ if self.config.rope_scaling is None:
289
+ self.rotary_emb = PhiRotaryEmbedding(
290
+ int(self.partial_rotary_factor * self.head_dim),
291
+ max_position_embeddings=self.max_position_embeddings,
292
+ base=self.rope_theta,
293
+ )
294
+ else:
295
+ scaling_type = self.config.rope_scaling["type"]
296
+ scaling_factor = self.config.rope_scaling["factor"]
297
+ if scaling_type == "linear":
298
+ self.rotary_emb = PhiLinearScalingRotaryEmbedding(
299
+ int(self.partial_rotary_factor * self.head_dim),
300
+ max_position_embeddings=self.max_position_embeddings,
301
+ scaling_factor=scaling_factor,
302
+ base=self.rope_theta,
303
+ )
304
+ elif scaling_type == "dynamic":
305
+ self.rotary_emb = PhiDynamicNTKScalingRotaryEmbedding(
306
+ int(self.partial_rotary_factor * self.head_dim),
307
+ max_position_embeddings=self.max_position_embeddings,
308
+ scaling_factor=scaling_factor,
309
+ base=self.rope_theta,
310
+ )
311
+ else:
312
+ raise ValueError(f"Unknown RoPE scaling type {scaling_type}")
313
+
314
+ # Phi-2 has an attention overflow issue (with FP16) and requires autocast to be disabled
315
+ @torch.autocast("cpu", enabled=False)
316
+ @torch.autocast("cuda", enabled=False)
317
+ def forward(
318
+ self,
319
+ hidden_states: torch.Tensor,
320
+ attention_mask: Optional[torch.Tensor] = None,
321
+ position_ids: Optional[torch.LongTensor] = None,
322
+ past_key_value: Optional[Cache] = None,
323
+ output_attentions: bool = False,
324
+ use_cache: bool = False,
325
+ ) -> Tuple[torch.Tensor, Optional[torch.Tensor], Optional[Tuple[torch.Tensor]]]:
326
+ bsz, q_len, _ = hidden_states.size()
327
+
328
+ query_states = self.q_proj(hidden_states)
329
+ key_states = self.k_proj(hidden_states)
330
+ value_states = self.v_proj(hidden_states)
331
+
332
+ if self.qk_layernorm:
333
+ query_states = self.q_layernorm(query_states)
334
+ key_states = self.k_layernorm(key_states)
335
+
336
+ query_states = query_states.view(bsz, q_len, self.num_heads, self.head_dim).transpose(1, 2)
337
+ key_states = key_states.view(bsz, q_len, self.num_key_value_heads, self.head_dim).transpose(1, 2)
338
+ value_states = value_states.view(bsz, q_len, self.num_key_value_heads, self.head_dim).transpose(1, 2)
339
+
340
+ kv_seq_len = key_states.shape[-2]
341
+ if past_key_value is not None:
342
+ if self.layer_idx is None:
343
+ raise ValueError(
344
+ f"The cache structure has changed since version v4.36. If you are using {self.__class__.__name__} "
345
+ "for auto-regressive decoding with k/v caching, please make sure to initialize the attention class "
346
+ "with a layer index."
347
+ )
348
+ kv_seq_len += past_key_value.get_usable_length(kv_seq_len, self.layer_idx)
349
+ cos, sin = self.rotary_emb(value_states, seq_len=kv_seq_len)
350
+
351
+ # Partial rotary embedding
352
+ query_rot, query_pass = (
353
+ query_states[..., : self.rotary_emb.dim],
354
+ query_states[..., self.rotary_emb.dim :],
355
+ )
356
+ key_rot, key_pass = (
357
+ key_states[..., : self.rotary_emb.dim],
358
+ key_states[..., self.rotary_emb.dim :],
359
+ )
360
+ # [batch_size, seq_length, num_heads, head_dim // config.partial_rotary_factor]
361
+ query_rot, key_rot = apply_rotary_pos_emb(query_rot, key_rot, cos, sin, position_ids)
362
+
363
+ # [batch_size, seq_length, num_heads, head_dim]
364
+ query_states = torch.cat((query_rot, query_pass), dim=-1)
365
+ key_states = torch.cat((key_rot, key_pass), dim=-1)
366
+
367
+ if past_key_value is not None:
368
+ cache_kwargs = {"sin": sin, "cos": cos, "partial_rotation_size": self.rotary_emb.dim}
369
+ key_states, value_states = past_key_value.update(key_states, value_states, self.layer_idx, cache_kwargs)
370
+
371
+ key_states = repeat_kv(key_states, self.num_key_value_groups)
372
+ value_states = repeat_kv(value_states, self.num_key_value_groups)
373
+
374
+ # Queries and keys upcast to fp32 is required by Phi-2 to avoid overflow
375
+ attn_weights = torch.matmul(
376
+ query_states.to(torch.float32), key_states.to(torch.float32).transpose(2, 3)
377
+ ) / math.sqrt(self.head_dim)
378
+
379
+ if attn_weights.size() != (bsz, self.num_heads, q_len, kv_seq_len):
380
+ raise ValueError(
381
+ f"Attention weights should be of size {(bsz, self.num_heads, q_len, kv_seq_len)}, but is"
382
+ f" {attn_weights.size()}"
383
+ )
384
+
385
+ if attention_mask is not None:
386
+ if attention_mask.size() != (bsz, 1, q_len, kv_seq_len):
387
+ raise ValueError(
388
+ f"Attention mask should be of size {(bsz, 1, q_len, kv_seq_len)}, but is {attention_mask.size()}"
389
+ )
390
+ attn_weights = attn_weights + attention_mask
391
+
392
+ # upcast attention to fp32
393
+ attn_weights = nn.functional.softmax(attn_weights, dim=-1, dtype=torch.float32).to(value_states.dtype)
394
+ attn_weights = nn.functional.dropout(attn_weights, p=self.attention_dropout, training=self.training)
395
+
396
+ attn_output = torch.matmul(attn_weights, value_states)
397
+
398
+ if attn_output.size() != (bsz, self.num_heads, q_len, self.head_dim):
399
+ raise ValueError(
400
+ f"`attn_output` should be of size {(bsz, self.num_heads, q_len, self.head_dim)}, but is"
401
+ f" {attn_output.size()}"
402
+ )
403
+
404
+ attn_output = attn_output.transpose(1, 2).contiguous()
405
+ attn_output = attn_output.reshape(bsz, q_len, self.hidden_size)
406
+
407
+ attn_output = self.dense(attn_output)
408
+
409
+ if not output_attentions:
410
+ attn_weights = None
411
+
412
+ return attn_output, attn_weights, past_key_value
413
+
414
+
415
+ class PhiFlashAttention2(PhiAttention):
416
+ """
417
+ Phi flash attention module. This module inherits from `PhiAttention` as the weights of the module stays
418
+ untouched. The only required change would be on the forward pass where it needs to correctly call the public API of
419
+ flash attention and deal with padding tokens in case the input contains any of them.
420
+ """
421
+
422
+ # Copied from transformers.models.llama.modeling_llama.LlamaFlashAttention2.__init__
423
+ def __init__(self, *args, **kwargs):
424
+ super().__init__(*args, **kwargs)
425
+
426
+ # TODO: Should be removed once Flash Attention for RoCm is bumped to 2.1.
427
+ # 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.
428
+ # 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).
429
+ self._flash_attn_uses_top_left_mask = not is_flash_attn_greater_or_equal_2_10()
430
+
431
+ def forward(
432
+ self,
433
+ hidden_states: torch.Tensor,
434
+ attention_mask: Optional[torch.LongTensor] = None,
435
+ position_ids: Optional[torch.LongTensor] = None,
436
+ past_key_value: Optional[Cache] = None,
437
+ output_attentions: bool = False,
438
+ use_cache: bool = False,
439
+ **kwargs,
440
+ ) -> Tuple[torch.Tensor, Optional[torch.Tensor], Optional[Tuple[torch.Tensor]]]:
441
+ # PhiFlashAttention2 attention does not support output_attentions
442
+
443
+ output_attentions = False
444
+
445
+ bsz, q_len, _ = hidden_states.size()
446
+
447
+ query_states = self.q_proj(hidden_states)
448
+ key_states = self.k_proj(hidden_states)
449
+ value_states = self.v_proj(hidden_states)
450
+
451
+ if self.qk_layernorm:
452
+ query_states = self.q_layernorm(query_states)
453
+ key_states = self.k_layernorm(key_states)
454
+
455
+ # Flash attention requires the input to have the shape
456
+ # batch_size x seq_length x head_dim x hidden_dim
457
+ # therefore we just need to keep the original shape
458
+ query_states = query_states.view(bsz, q_len, self.num_heads, self.head_dim).transpose(1, 2)
459
+ key_states = key_states.view(bsz, q_len, self.num_key_value_heads, self.head_dim).transpose(1, 2)
460
+ value_states = value_states.view(bsz, q_len, self.num_key_value_heads, self.head_dim).transpose(1, 2)
461
+
462
+ kv_seq_len = key_states.shape[-2]
463
+ if past_key_value is not None:
464
+ kv_seq_len += past_key_value.get_usable_length(kv_seq_len, self.layer_idx)
465
+ cos, sin = self.rotary_emb(value_states, seq_len=kv_seq_len)
466
+
467
+ # Partial rotary embedding
468
+ query_rot, query_pass = (
469
+ query_states[..., : self.rotary_emb.dim],
470
+ query_states[..., self.rotary_emb.dim :],
471
+ )
472
+ key_rot, key_pass = (
473
+ key_states[..., : self.rotary_emb.dim],
474
+ key_states[..., self.rotary_emb.dim :],
475
+ )
476
+ # [batch_size, seq_length, num_heads, head_dim // config.partial_rotary_factor]
477
+ query_rot, key_rot = apply_rotary_pos_emb(query_rot, key_rot, cos, sin, position_ids)
478
+
479
+ # [batch_size, seq_length, num_heads, head_dim]
480
+ query_states = torch.cat((query_rot, query_pass), dim=-1)
481
+ key_states = torch.cat((key_rot, key_pass), dim=-1)
482
+
483
+ if past_key_value is not None:
484
+ cache_kwargs = {"sin": sin, "cos": cos, "partial_rotation_size": self.rotary_emb.dim}
485
+ key_states, value_states = past_key_value.update(key_states, value_states, self.layer_idx, cache_kwargs)
486
+
487
+ # TODO: These transpose are quite inefficient but Flash Attention requires the layout [batch_size, sequence_length, num_heads, head_dim]. We would need to refactor the KV cache
488
+ # to be able to avoid many of these transpose/reshape/view.
489
+ query_states = query_states.transpose(1, 2)
490
+ key_states = key_states.transpose(1, 2)
491
+ value_states = value_states.transpose(1, 2)
492
+
493
+ attn_dropout = self.attention_dropout if self.training else 0.0
494
+
495
+ # In PEFT, usually we cast the layer norms in float32 for training stability reasons
496
+ # therefore the input hidden states gets silently casted in float32. Hence, we need
497
+ # cast them back in the correct dtype just to be sure everything works as expected.
498
+ # This might slowdown training & inference so it is recommended to not cast the LayerNorms
499
+ # in fp32.
500
+
501
+ if query_states.dtype == torch.float32:
502
+ if torch.is_autocast_enabled():
503
+ target_dtype = torch.get_autocast_gpu_dtype()
504
+ # Handle the case where the model is quantized
505
+ elif hasattr(self.config, "_pre_quantization_dtype"):
506
+ target_dtype = self.config._pre_quantization_dtype
507
+ else:
508
+ target_dtype = self.q_proj.weight.dtype
509
+
510
+ logger.warning_once(
511
+ f"The input hidden states seems to be silently casted in float32, this might be related to"
512
+ f" the fact you have upcasted embedding or layer norm layers in float32. We will cast back the input in"
513
+ f" {target_dtype}."
514
+ )
515
+
516
+ query_states = query_states.to(target_dtype)
517
+ key_states = key_states.to(target_dtype)
518
+ value_states = value_states.to(target_dtype)
519
+
520
+ attn_output = self._flash_attention_forward(
521
+ query_states, key_states, value_states, attention_mask, q_len, dropout=attn_dropout, softmax_scale=None
522
+ )
523
+
524
+ attn_output = attn_output.reshape(bsz, q_len, self.hidden_size).contiguous()
525
+ attn_output = self.dense(attn_output)
526
+
527
+ if not output_attentions:
528
+ attn_weights = None
529
+
530
+ return attn_output, attn_weights, past_key_value
531
+
532
+ # Copied from transformers.models.llama.modeling_llama.LlamaFlashAttention2._flash_attention_forward
533
+ def _flash_attention_forward(
534
+ self, query_states, key_states, value_states, attention_mask, query_length, dropout=0.0, softmax_scale=None
535
+ ):
536
+ """
537
+ Calls the forward method of Flash Attention - if the input hidden states contain at least one padding token
538
+ first unpad the input, then computes the attention scores and pad the final attention scores.
539
+
540
+ Args:
541
+ query_states (`torch.Tensor`):
542
+ Input query states to be passed to Flash Attention API
543
+ key_states (`torch.Tensor`):
544
+ Input key states to be passed to Flash Attention API
545
+ value_states (`torch.Tensor`):
546
+ Input value states to be passed to Flash Attention API
547
+ attention_mask (`torch.Tensor`):
548
+ The padding mask - corresponds to a tensor of size `(batch_size, seq_len)` where 0 stands for the
549
+ position of padding tokens and 1 for the position of non-padding tokens.
550
+ dropout (`int`, *optional*):
551
+ Attention dropout
552
+ softmax_scale (`float`, *optional*):
553
+ The scaling of QK^T before applying softmax. Default to 1 / sqrt(head_dim)
554
+ """
555
+ if not self._flash_attn_uses_top_left_mask:
556
+ causal = self.is_causal
557
+ else:
558
+ # 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__.
559
+ causal = self.is_causal and query_length != 1
560
+
561
+ # Contains at least one padding token in the sequence
562
+ if attention_mask is not None:
563
+ batch_size = query_states.shape[0]
564
+ query_states, key_states, value_states, indices_q, cu_seq_lens, max_seq_lens = self._upad_input(
565
+ query_states, key_states, value_states, attention_mask, query_length
566
+ )
567
+
568
+ cu_seqlens_q, cu_seqlens_k = cu_seq_lens
569
+ max_seqlen_in_batch_q, max_seqlen_in_batch_k = max_seq_lens
570
+
571
+ attn_output_unpad = flash_attn_varlen_func(
572
+ query_states,
573
+ key_states,
574
+ value_states,
575
+ cu_seqlens_q=cu_seqlens_q,
576
+ cu_seqlens_k=cu_seqlens_k,
577
+ max_seqlen_q=max_seqlen_in_batch_q,
578
+ max_seqlen_k=max_seqlen_in_batch_k,
579
+ dropout_p=dropout,
580
+ softmax_scale=softmax_scale,
581
+ causal=causal,
582
+ )
583
+
584
+ attn_output = pad_input(attn_output_unpad, indices_q, batch_size, query_length)
585
+ else:
586
+ attn_output = flash_attn_func(
587
+ query_states, key_states, value_states, dropout, softmax_scale=softmax_scale, causal=causal
588
+ )
589
+
590
+ return attn_output
591
+
592
+ # Copied from transformers.models.llama.modeling_llama.LlamaFlashAttention2._upad_input
593
+ def _upad_input(self, query_layer, key_layer, value_layer, attention_mask, query_length):
594
+ indices_k, cu_seqlens_k, max_seqlen_in_batch_k = _get_unpad_data(attention_mask)
595
+ batch_size, kv_seq_len, num_key_value_heads, head_dim = key_layer.shape
596
+
597
+ key_layer = index_first_axis(
598
+ key_layer.reshape(batch_size * kv_seq_len, num_key_value_heads, head_dim), indices_k
599
+ )
600
+ value_layer = index_first_axis(
601
+ value_layer.reshape(batch_size * kv_seq_len, num_key_value_heads, head_dim), indices_k
602
+ )
603
+ if query_length == kv_seq_len:
604
+ query_layer = index_first_axis(
605
+ query_layer.reshape(batch_size * kv_seq_len, self.num_heads, head_dim), indices_k
606
+ )
607
+ cu_seqlens_q = cu_seqlens_k
608
+ max_seqlen_in_batch_q = max_seqlen_in_batch_k
609
+ indices_q = indices_k
610
+ elif query_length == 1:
611
+ max_seqlen_in_batch_q = 1
612
+ cu_seqlens_q = torch.arange(
613
+ batch_size + 1, dtype=torch.int32, device=query_layer.device
614
+ ) # There is a memcpy here, that is very bad.
615
+ indices_q = cu_seqlens_q[:-1]
616
+ query_layer = query_layer.squeeze(1)
617
+ else:
618
+ # The -q_len: slice assumes left padding.
619
+ attention_mask = attention_mask[:, -query_length:]
620
+ query_layer, indices_q, cu_seqlens_q, max_seqlen_in_batch_q = unpad_input(query_layer, attention_mask)
621
+
622
+ return (
623
+ query_layer,
624
+ key_layer,
625
+ value_layer,
626
+ indices_q,
627
+ (cu_seqlens_q, cu_seqlens_k),
628
+ (max_seqlen_in_batch_q, max_seqlen_in_batch_k),
629
+ )
630
+
631
+
632
+ PHI_ATTENTION_CLASSES = {
633
+ "eager": PhiAttention,
634
+ "flash_attention_2": PhiFlashAttention2,
635
+ }
636
+
637
+
638
+ class PhiDecoderLayer(nn.Module):
639
+ def __init__(self, config: PhiConfig, layer_idx: int):
640
+ super().__init__()
641
+ self.self_attn = PHI_ATTENTION_CLASSES[config._attn_implementation](config, layer_idx=layer_idx)
642
+ self.mlp = PhiMLP(config)
643
+ self.input_layernorm = nn.LayerNorm(config.hidden_size, eps=config.layer_norm_eps)
644
+ self.resid_dropout = nn.Dropout(config.resid_pdrop)
645
+
646
+ def forward(
647
+ self,
648
+ hidden_states: torch.Tensor,
649
+ attention_mask: Optional[torch.Tensor] = None,
650
+ position_ids: Optional[torch.LongTensor] = None,
651
+ output_attentions: Optional[bool] = False,
652
+ use_cache: Optional[bool] = False,
653
+ past_key_value: Optional[Tuple[torch.Tensor]] = None,
654
+ ) -> Tuple[torch.FloatTensor, Optional[Tuple[torch.FloatTensor, torch.FloatTensor]]]:
655
+ """
656
+ Args:
657
+ hidden_states (`torch.FloatTensor`):
658
+ input to the layer of shape `(batch, seq_len, embed_dim)`
659
+ attention_mask (`torch.FloatTensor`, *optional*): attention mask of size
660
+ `(batch, 1, tgt_len, src_len)` where padding elements are indicated by very large negative values.
661
+ position_ids (`torch.LongTensor` of shape `({0})`, *optional*):
662
+ Indices of positions of each input sequence tokens in the position embeddings. Selected in the range
663
+ `[0, config.n_positions - 1]`. [What are position IDs?](../glossary#position-ids)
664
+ output_attentions (`bool`, *optional*):
665
+ Whether or not to return the attentions tensors of all attention layers. See `attentions` under
666
+ returned tensors for more detail.
667
+ use_cache (`bool`, *optional*):
668
+ If set to `True`, `past_key_values` key value states are returned and can be used to speed up decoding
669
+ (see `past_key_values`).
670
+ past_key_value (`Tuple(torch.FloatTensor)`, *optional*): cached past key and value projection states
671
+ """
672
+
673
+ residual = hidden_states
674
+
675
+ hidden_states = self.input_layernorm(hidden_states)
676
+
677
+ # Self Attention
678
+ attn_outputs, self_attn_weights, present_key_value = self.self_attn(
679
+ hidden_states=hidden_states,
680
+ attention_mask=attention_mask,
681
+ position_ids=position_ids,
682
+ past_key_value=past_key_value,
683
+ output_attentions=output_attentions,
684
+ use_cache=use_cache,
685
+ )
686
+ attn_outputs = self.resid_dropout(attn_outputs)
687
+
688
+ feed_forward_hidden_states = self.resid_dropout(self.mlp(hidden_states))
689
+ hidden_states = attn_outputs + feed_forward_hidden_states + residual
690
+ outputs = (hidden_states,)
691
+
692
+ if output_attentions:
693
+ outputs += (self_attn_weights,)
694
+
695
+ if use_cache:
696
+ outputs += (present_key_value,)
697
+
698
+ return outputs
699
+
700
+
701
+ PHI_START_DOCSTRING = r"""
702
+ This model inherits from [`PreTrainedModel`]. Check the superclass documentation for the generic methods the
703
+ library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
704
+ etc.)
705
+
706
+ This model is also a PyTorch [torch.nn.Module](https://pytorch.org/docs/stable/nn.html#torch.nn.Module) subclass.
707
+ Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
708
+ and behavior.
709
+
710
+ Parameters:
711
+ config ([`PhiConfig`]):
712
+ Model configuration class with all the parameters of the model. Initializing with a config file does not
713
+ load the weights associated with the model, only the configuration. Check out the
714
+ [`~PreTrainedModel.from_pretrained`] method to load the model weights.
715
+ """
716
+
717
+
718
+ @add_start_docstrings(
719
+ "The bare Phi Model outputting raw hidden-states without any specific head on top.",
720
+ PHI_START_DOCSTRING,
721
+ )
722
+ class PhiPreTrainedModel(PreTrainedModel):
723
+ config_class = PhiConfig
724
+ base_model_prefix = "model"
725
+ supports_gradient_checkpointing = True
726
+ _no_split_modules = ["PhiDecoderLayer"]
727
+ _skip_keys_device_placement = "past_key_values"
728
+ _supports_flash_attn_2 = True
729
+ _supports_cache_class = True
730
+
731
+ def _init_weights(self, module):
732
+ std = self.config.initializer_range
733
+ if isinstance(module, nn.Linear):
734
+ module.weight.data.normal_(mean=0.0, std=std)
735
+ if module.bias is not None:
736
+ module.bias.data.zero_()
737
+ elif isinstance(module, nn.Embedding):
738
+ module.weight.data.normal_(mean=0.0, std=std)
739
+ if module.padding_idx is not None:
740
+ module.weight.data[module.padding_idx].zero_()
741
+
742
+
743
+ PHI_INPUTS_DOCSTRING = r"""
744
+ Args:
745
+ input_ids (`torch.LongTensor` of shape `(batch_size, sequence_length)`):
746
+ Indices of input sequence tokens in the vocabulary. Padding will be ignored by default should you provide
747
+ it.
748
+
749
+ Indices can be obtained using [`AutoTokenizer`]. See [`PreTrainedTokenizer.encode`] and
750
+ [`PreTrainedTokenizer.__call__`] for details.
751
+
752
+ [What are input IDs?](../glossary#input-ids)
753
+ attention_mask (`torch.Tensor` of shape `(batch_size, sequence_length)`, *optional*):
754
+ Mask to avoid performing attention on padding token indices. Mask values selected in `[0, 1]`:
755
+
756
+ - 1 for tokens that are **not masked**,
757
+ - 0 for tokens that are **masked**.
758
+
759
+ [What are attention masks?](../glossary#attention-mask)
760
+
761
+ Indices can be obtained using [`AutoTokenizer`]. See [`PreTrainedTokenizer.encode`] and
762
+ [`PreTrainedTokenizer.__call__`] for details.
763
+
764
+ If `past_key_values` is used, optionally only the last `input_ids` have to be input (see
765
+ `past_key_values`).
766
+
767
+ If you want to change padding behavior, you should read [`modeling_opt._prepare_decoder_attention_mask`]
768
+ and modify to your needs. See diagram 1 in [the paper](https://arxiv.org/abs/1910.13461) for more
769
+ information on the default strategy.
770
+
771
+ - 1 indicates the head is **not masked**,
772
+ - 0 indicates the head is **masked**.
773
+ position_ids (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *optional*):
774
+ Indices of positions of each input sequence tokens in the position embeddings. Selected in the range `[0,
775
+ config.n_positions - 1]`.
776
+
777
+ [What are position IDs?](../glossary#position-ids)
778
+ past_key_values (`Cache` or `tuple(tuple(torch.FloatTensor))`, *optional*):
779
+ Pre-computed hidden-states (key and values in the self-attention blocks and in the cross-attention
780
+ blocks) that can be used to speed up sequential decoding. This typically consists in the `past_key_values`
781
+ returned by the model at a previous stage of decoding, when `use_cache=True` or `config.use_cache=True`.
782
+
783
+ Two formats are allowed:
784
+ - a [`~cache_utils.Cache`] instance;
785
+ - Tuple of `tuple(torch.FloatTensor)` of length `config.n_layers`, with each tuple having 2 tensors of
786
+ shape `(batch_size, num_heads, sequence_length, embed_size_per_head)`). This is also known as the legacy
787
+ cache format.
788
+
789
+ The model will output the same cache format that is fed as input. If no `past_key_values` are passed, the
790
+ legacy cache format will be returned.
791
+
792
+ If `past_key_values` are used, the user can optionally input only the last `input_ids` (those that don't
793
+ have their past key value states given to this model) of shape `(batch_size, 1)` instead of all `input_ids`
794
+ of shape `(batch_size, sequence_length)`.
795
+ inputs_embeds (`torch.FloatTensor` of shape `(batch_size, sequence_length, hidden_size)`, *optional*):
796
+ Optionally, instead of passing `input_ids` you can choose to directly pass an embedded representation. This
797
+ is useful if you want more control over how to convert `input_ids` indices into associated vectors than the
798
+ model's internal embedding lookup matrix.
799
+ use_cache (`bool`, *optional*):
800
+ If set to `True`, `past_key_values` key value states are returned and can be used to speed up decoding (see
801
+ `past_key_values`).
802
+ output_attentions (`bool`, *optional*):
803
+ Whether or not to return the attentions tensors of all attention layers. See `attentions` under returned
804
+ tensors for more detail.
805
+ output_hidden_states (`bool`, *optional*):
806
+ Whether or not to return the hidden states of all layers. See `hidden_states` under returned tensors for
807
+ more detail.
808
+ return_dict (`bool`, *optional*):
809
+ Whether or not to return a [`~utils.ModelOutput`] instead of a plain tuple.
810
+ """
811
+
812
+
813
+ @add_start_docstrings(
814
+ "The bare Phi Model outputting raw hidden-states without any specific head on top.",
815
+ PHI_START_DOCSTRING,
816
+ )
817
+ class PhiModel(PhiPreTrainedModel):
818
+ """
819
+ Transformer decoder consisting of *config.num_hidden_layers* layers. Each layer is a [`PhiDecoderLayer`]
820
+
821
+ Args:
822
+ config: PhiConfig
823
+ """
824
+
825
+ def __init__(self, config: PhiConfig):
826
+ super().__init__(config)
827
+ self.padding_idx = config.pad_token_id
828
+ self.vocab_size = config.vocab_size
829
+
830
+ self.embed_tokens = nn.Embedding(config.vocab_size, config.hidden_size, self.padding_idx)
831
+ self.embed_dropout = nn.Dropout(config.embd_pdrop)
832
+ self.layers = nn.ModuleList(
833
+ [PhiDecoderLayer(config, layer_idx) for layer_idx in range(config.num_hidden_layers)]
834
+ )
835
+ self.final_layernorm = nn.LayerNorm(config.hidden_size, eps=config.layer_norm_eps)
836
+ self._use_flash_attention_2 = config._attn_implementation == "flash_attention_2"
837
+
838
+ self.gradient_checkpointing = False
839
+ # Initialize weights and apply final processing
840
+ self.post_init()
841
+
842
+ def get_input_embeddings(self):
843
+ return self.embed_tokens
844
+
845
+ def set_input_embeddings(self, value):
846
+ self.embed_tokens = value
847
+
848
+ @add_start_docstrings_to_model_forward(PHI_INPUTS_DOCSTRING)
849
+ def forward(
850
+ self,
851
+ input_ids: torch.LongTensor = None,
852
+ attention_mask: Optional[torch.Tensor] = None,
853
+ position_ids: Optional[torch.LongTensor] = None,
854
+ past_key_values: Optional[List[torch.FloatTensor]] = None,
855
+ inputs_embeds: Optional[torch.FloatTensor] = None,
856
+ use_cache: Optional[bool] = None,
857
+ output_attentions: Optional[bool] = None,
858
+ output_hidden_states: Optional[bool] = None,
859
+ return_dict: Optional[bool] = None,
860
+ ) -> Union[Tuple, BaseModelOutputWithPast]:
861
+ output_attentions = output_attentions if output_attentions is not None else self.config.output_attentions
862
+ output_hidden_states = (
863
+ output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
864
+ )
865
+ use_cache = use_cache if use_cache is not None else self.config.use_cache
866
+
867
+ return_dict = return_dict if return_dict is not None else self.config.use_return_dict
868
+
869
+ # retrieve input_ids and inputs_embeds
870
+ if input_ids is not None and inputs_embeds is not None:
871
+ raise ValueError("You cannot specify both input_ids and inputs_embeds at the same time")
872
+ elif input_ids is not None:
873
+ batch_size, seq_length = input_ids.shape[:2]
874
+ elif inputs_embeds is not None:
875
+ batch_size, seq_length = inputs_embeds.shape[:2]
876
+ else:
877
+ raise ValueError("You have to specify either input_ids or inputs_embeds")
878
+
879
+ past_key_values_length = 0
880
+
881
+ if self.gradient_checkpointing and self.training:
882
+ if use_cache:
883
+ logger.warning_once(
884
+ "`use_cache=True` is incompatible with gradient checkpointing. Setting `use_cache=False`..."
885
+ )
886
+ use_cache = False
887
+
888
+ if use_cache:
889
+ # dbg: uncomment is original
890
+ use_legacy_cache = not isinstance(past_key_values, Cache)
891
+ if use_legacy_cache:
892
+ past_key_values = DynamicCache.from_legacy_cache(past_key_values)
893
+
894
+ past_key_values_length = past_key_values.get_usable_length(seq_length)
895
+
896
+ if position_ids is None:
897
+ device = input_ids.device if input_ids is not None else inputs_embeds.device
898
+ position_ids = torch.arange(
899
+ past_key_values_length, seq_length + past_key_values_length, dtype=torch.long, device=device
900
+ )
901
+ position_ids = position_ids.unsqueeze(0)
902
+
903
+ if inputs_embeds is None:
904
+ inputs_embeds = self.embed_tokens(input_ids)
905
+
906
+ inputs_embeds = self.embed_dropout(inputs_embeds)
907
+
908
+ # Attention mask.
909
+ if self._use_flash_attention_2:
910
+ # 2d mask is passed through the layers
911
+ attention_mask = attention_mask if (attention_mask is not None and 0 in attention_mask) else None
912
+ else:
913
+ # 4d mask is passed through the layers
914
+ attention_mask = _prepare_4d_causal_attention_mask(
915
+ attention_mask, (batch_size, seq_length), inputs_embeds, past_key_values_length
916
+ )
917
+
918
+ hidden_states = inputs_embeds
919
+
920
+ # decoder layers
921
+ all_hidden_states = () if output_hidden_states else None
922
+ all_self_attns = () if output_attentions else None
923
+ next_decoder_cache = None
924
+
925
+ for decoder_layer in self.layers:
926
+ if output_hidden_states:
927
+ all_hidden_states += (hidden_states,)
928
+
929
+ if self.gradient_checkpointing and self.training:
930
+ layer_outputs = self._gradient_checkpointing_func(
931
+ decoder_layer.__call__,
932
+ hidden_states,
933
+ attention_mask,
934
+ position_ids,
935
+ past_key_values,
936
+ output_attentions,
937
+ )
938
+ else:
939
+ layer_outputs = decoder_layer(
940
+ hidden_states,
941
+ attention_mask=attention_mask,
942
+ position_ids=position_ids,
943
+ past_key_value=past_key_values,
944
+ output_attentions=output_attentions,
945
+ use_cache=use_cache,
946
+ )
947
+
948
+ hidden_states = layer_outputs[0]
949
+
950
+ if use_cache:
951
+ next_decoder_cache = layer_outputs[2 if output_attentions else 1]
952
+
953
+ if output_attentions:
954
+ all_self_attns += (layer_outputs[1],)
955
+
956
+ hidden_states = self.final_layernorm(hidden_states)
957
+
958
+ # add hidden states from the last decoder layer
959
+ if output_hidden_states:
960
+ all_hidden_states += (hidden_states,)
961
+
962
+ next_cache = None
963
+ if use_cache:
964
+ next_cache = next_decoder_cache.to_legacy_cache() if use_legacy_cache else next_decoder_cache
965
+ if not return_dict:
966
+ return tuple(v for v in [hidden_states, next_cache, all_hidden_states, all_self_attns] if v is not None)
967
+ return BaseModelOutputWithPast(
968
+ last_hidden_state=hidden_states,
969
+ past_key_values=next_cache,
970
+ hidden_states=all_hidden_states,
971
+ attentions=all_self_attns,
972
+ )
973
+
974
+
975
+ class PhiForCausalLM(PhiPreTrainedModel):
976
+ _tied_weights_keys = ["lm_head.weight"]
977
+
978
+ # Copied from transformers.models.llama.modeling_llama.LlamaForCausalLM.__init__ with Llama->Phi,bias=False->bias=True
979
+ def __init__(self, config):
980
+ super().__init__(config)
981
+ self.model = PhiModel(config)
982
+ self.vocab_size = config.vocab_size
983
+ self.lm_head = nn.Linear(config.hidden_size, config.vocab_size, bias=True)
984
+
985
+ # Initialize weights and apply final processing
986
+ self.post_init()
987
+
988
+ # Copied from transformers.models.llama.modeling_llama.LlamaForCausalLM.get_input_embeddings
989
+ def get_input_embeddings(self):
990
+ return self.model.embed_tokens
991
+
992
+ # Copied from transformers.models.llama.modeling_llama.LlamaForCausalLM.set_input_embeddings
993
+ def set_input_embeddings(self, value):
994
+ self.model.embed_tokens = value
995
+
996
+ # Copied from transformers.models.llama.modeling_llama.LlamaForCausalLM.get_output_embeddings
997
+ def get_output_embeddings(self):
998
+ return self.lm_head
999
+
1000
+ # Copied from transformers.models.llama.modeling_llama.LlamaForCausalLM.set_output_embeddings
1001
+ def set_output_embeddings(self, new_embeddings):
1002
+ self.lm_head = new_embeddings
1003
+
1004
+ # Copied from transformers.models.llama.modeling_llama.LlamaForCausalLM.set_decoder
1005
+ def set_decoder(self, decoder):
1006
+ self.model = decoder
1007
+
1008
+ # Copied from transformers.models.llama.modeling_llama.LlamaForCausalLM.get_decoder
1009
+ def get_decoder(self):
1010
+ return self.model
1011
+
1012
+ @add_start_docstrings_to_model_forward(PHI_INPUTS_DOCSTRING)
1013
+ @replace_return_docstrings(output_type=CausalLMOutputWithPast, config_class=_CONFIG_FOR_DOC)
1014
+ def forward(
1015
+ self,
1016
+ input_ids: torch.LongTensor = None,
1017
+ attention_mask: Optional[torch.Tensor] = None,
1018
+ position_ids: Optional[torch.LongTensor] = None,
1019
+ past_key_values: Optional[List[torch.FloatTensor]] = None,
1020
+ inputs_embeds: Optional[torch.FloatTensor] = None,
1021
+ labels: Optional[torch.LongTensor] = None,
1022
+ use_cache: Optional[bool] = None,
1023
+ output_attentions: Optional[bool] = None,
1024
+ output_hidden_states: Optional[bool] = None,
1025
+ return_dict: Optional[bool] = None,
1026
+ ) -> Union[Tuple, CausalLMOutputWithPast]:
1027
+ r"""
1028
+ Args:
1029
+ labels (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *optional*):
1030
+ Labels for computing the masked language modeling loss. Indices should either be in `[0, ...,
1031
+ config.vocab_size]` or -100 (see `input_ids` docstring). Tokens with indices set to `-100` are ignored
1032
+ (masked), the loss is only computed for the tokens with labels in `[0, ..., config.vocab_size]`.
1033
+
1034
+ Returns:
1035
+
1036
+ Example:
1037
+
1038
+ ```python
1039
+ >>> from transformers import AutoTokenizer, PhiForCausalLM
1040
+
1041
+ >>> model = PhiForCausalLM.from_pretrained("microsoft/phi-1")
1042
+ >>> tokenizer = AutoTokenizer.from_pretrained("microsoft/phi-1")
1043
+
1044
+ >>> prompt = "This is an example script ."
1045
+ >>> inputs = tokenizer(prompt, return_tensors="pt")
1046
+
1047
+ >>> # Generate
1048
+ >>> generate_ids = model.generate(inputs.input_ids, max_length=30)
1049
+ >>> tokenizer.batch_decode(generate_ids, skip_special_tokens=True, clean_up_tokenization_spaces=False)[0]
1050
+ 'This is an example script .\n\n\n\nfrom typing import List\n\ndef find_most_common_letter(words: List[str'
1051
+ ```"""
1052
+
1053
+ output_attentions = output_attentions if output_attentions is not None else self.config.output_attentions
1054
+ output_hidden_states = (
1055
+ output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
1056
+ )
1057
+ return_dict = return_dict if return_dict is not None else self.config.use_return_dict
1058
+
1059
+ # decoder outputs consists of (dec_features, layer_state, dec_hidden, dec_attn)
1060
+ outputs = self.model(
1061
+ input_ids=input_ids,
1062
+ attention_mask=attention_mask,
1063
+ position_ids=position_ids,
1064
+ past_key_values=past_key_values,
1065
+ inputs_embeds=inputs_embeds,
1066
+ use_cache=use_cache,
1067
+ output_attentions=output_attentions,
1068
+ output_hidden_states=output_hidden_states,
1069
+ return_dict=return_dict,
1070
+ )
1071
+
1072
+
1073
+ # concat the feature back?
1074
+
1075
+ hidden_states = outputs[0]
1076
+ logits = self.lm_head(hidden_states)
1077
+ logits = logits.float()
1078
+
1079
+ loss = None
1080
+ if labels is not None:
1081
+ # Shift so that tokens < n predict n
1082
+ shift_logits = logits[..., :-1, :].contiguous()
1083
+ shift_labels = labels[..., 1:].contiguous()
1084
+ # Flatten the tokens
1085
+ loss_fct = CrossEntropyLoss()
1086
+ shift_logits = shift_logits.view(-1, self.config.vocab_size)
1087
+ shift_labels = shift_labels.view(-1)
1088
+ # Enable model parallelism
1089
+ shift_labels = shift_labels.to(shift_logits.device)
1090
+ loss = loss_fct(shift_logits, shift_labels)
1091
+
1092
+ if not return_dict:
1093
+ output = (logits,) + outputs[1:]
1094
+ return (loss,) + output if loss is not None else output
1095
+
1096
+ return CausalLMOutputWithPast(
1097
+ loss=loss,
1098
+ logits=logits,
1099
+ past_key_values=outputs.past_key_values,
1100
+ hidden_states=outputs.hidden_states,
1101
+ attentions=outputs.attentions,
1102
+ )
1103
+
1104
+ # Copied from transformers.models.llama.modeling_llama.LlamaForCausalLM.prepare_inputs_for_generation
1105
+ def prepare_inputs_for_generation(
1106
+ self, input_ids, past_key_values=None, attention_mask=None, inputs_embeds=None, **kwargs
1107
+ ):
1108
+ if past_key_values is not None:
1109
+ if isinstance(past_key_values, Cache):
1110
+ cache_length = past_key_values.get_seq_length()
1111
+ past_length = past_key_values.seen_tokens
1112
+ max_cache_length = past_key_values.get_max_length()
1113
+ else:
1114
+ cache_length = past_length = past_key_values[0][0].shape[2]
1115
+ max_cache_length = None
1116
+
1117
+ # Keep only the unprocessed tokens:
1118
+ # 1 - If the length of the attention_mask exceeds the length of input_ids, then we are in a setting where
1119
+ # some of the inputs are exclusively passed as part of the cache (e.g. when passing input_embeds as
1120
+ # input)
1121
+ if attention_mask is not None and attention_mask.shape[1] > input_ids.shape[1]:
1122
+ input_ids = input_ids[:, -(attention_mask.shape[1] - past_length) :]
1123
+ # 2 - If the past_length is smaller than input_ids', then input_ids holds all input tokens. We can discard
1124
+ # input_ids based on the past_length.
1125
+ elif past_length < input_ids.shape[1]:
1126
+ input_ids = input_ids[:, past_length:]
1127
+ # 3 - Otherwise (past_length >= input_ids.shape[1]), let's assume input_ids only has unprocessed tokens.
1128
+
1129
+ # If we are about to go beyond the maximum cache length, we need to crop the input attention mask.
1130
+ if (
1131
+ max_cache_length is not None
1132
+ and attention_mask is not None
1133
+ and cache_length + input_ids.shape[1] > max_cache_length
1134
+ ):
1135
+ attention_mask = attention_mask[:, -max_cache_length:]
1136
+
1137
+ position_ids = kwargs.get("position_ids", None)
1138
+ if attention_mask is not None and position_ids is None:
1139
+ # create position_ids on the fly for batch generation
1140
+ position_ids = attention_mask.long().cumsum(-1) - 1
1141
+ position_ids.masked_fill_(attention_mask == 0, 1)
1142
+ if past_key_values:
1143
+ position_ids = position_ids[:, -input_ids.shape[1] :]
1144
+
1145
+ # if `inputs_embeds` are passed, we only want to use them in the 1st generation step
1146
+ if inputs_embeds is not None and past_key_values is None:
1147
+ model_inputs = {"inputs_embeds": inputs_embeds}
1148
+ else:
1149
+ model_inputs = {"input_ids": input_ids}
1150
+
1151
+ model_inputs.update(
1152
+ {
1153
+ "position_ids": position_ids,
1154
+ "past_key_values": past_key_values,
1155
+ "use_cache": kwargs.get("use_cache"),
1156
+ "attention_mask": attention_mask,
1157
+ }
1158
+ )
1159
+ return model_inputs
1160
+
1161
+ @staticmethod
1162
+ # Copied from transformers.models.llama.modeling_llama.LlamaForCausalLM._reorder_cache
1163
+ def _reorder_cache(past_key_values, beam_idx):
1164
+ reordered_past = ()
1165
+ for layer_past in past_key_values:
1166
+ reordered_past += (
1167
+ tuple(past_state.index_select(0, beam_idx.to(past_state.device)) for past_state in layer_past),
1168
+ )
1169
+ return reordered_past
1170
+
1171
+
1172
+ @add_start_docstrings(
1173
+ """
1174
+ The PhiModel with a sequence classification head on top (linear layer).
1175
+
1176
+ [`PhiForSequenceClassification`] uses the last token in order to do the classification, as other causal models
1177
+ (e.g. GPT-2) do.
1178
+
1179
+ Since it does classification on the last token, it requires to know the position of the last token. If a
1180
+ `pad_token_id` is defined in the configuration, it finds the last token that is not a padding token in each row. If
1181
+ no `pad_token_id` is defined, it simply takes the last value in each row of the batch. Since it cannot guess the
1182
+ padding tokens when `inputs_embeds` are passed instead of `input_ids`, it does the same (take the last value in
1183
+ each row of the batch).
1184
+ """,
1185
+ PHI_START_DOCSTRING,
1186
+ )
1187
+ # Copied from transformers.models.llama.modeling_llama.LlamaForSequenceClassification with LLAMA->PHI,Llama->Phi with self.transformer->self.model, transformer_outputs->model_outputs
1188
+ class PhiForSequenceClassification(PhiPreTrainedModel):
1189
+ def __init__(self, config):
1190
+ super().__init__(config)
1191
+ self.num_labels = config.num_labels
1192
+ self.model = PhiModel(config)
1193
+ self.score = nn.Linear(config.hidden_size, self.num_labels, bias=False)
1194
+
1195
+ # Initialize weights and apply final processing
1196
+ self.post_init()
1197
+
1198
+ def get_input_embeddings(self):
1199
+ return self.model.embed_tokens
1200
+
1201
+ def set_input_embeddings(self, value):
1202
+ self.model.embed_tokens = value
1203
+
1204
+ @add_start_docstrings_to_model_forward(PHI_INPUTS_DOCSTRING)
1205
+ def forward(
1206
+ self,
1207
+ input_ids: torch.LongTensor = None,
1208
+ attention_mask: Optional[torch.Tensor] = None,
1209
+ position_ids: Optional[torch.LongTensor] = None,
1210
+ past_key_values: Optional[List[torch.FloatTensor]] = None,
1211
+ inputs_embeds: Optional[torch.FloatTensor] = None,
1212
+ labels: Optional[torch.LongTensor] = None,
1213
+ use_cache: Optional[bool] = None,
1214
+ output_attentions: Optional[bool] = None,
1215
+ output_hidden_states: Optional[bool] = None,
1216
+ return_dict: Optional[bool] = None,
1217
+ ) -> Union[Tuple, SequenceClassifierOutputWithPast]:
1218
+ r"""
1219
+ labels (`torch.LongTensor` of shape `(batch_size,)`, *optional*):
1220
+ Labels for computing the sequence classification/regression loss. Indices should be in `[0, ...,
1221
+ config.num_labels - 1]`. If `config.num_labels == 1` a regression loss is computed (Mean-Square loss), If
1222
+ `config.num_labels > 1` a classification loss is computed (Cross-Entropy).
1223
+ """
1224
+ return_dict = return_dict if return_dict is not None else self.config.use_return_dict
1225
+
1226
+ model_outputs = self.model(
1227
+ input_ids,
1228
+ attention_mask=attention_mask,
1229
+ position_ids=position_ids,
1230
+ past_key_values=past_key_values,
1231
+ inputs_embeds=inputs_embeds,
1232
+ use_cache=use_cache,
1233
+ output_attentions=output_attentions,
1234
+ output_hidden_states=output_hidden_states,
1235
+ return_dict=return_dict,
1236
+ )
1237
+ hidden_states = model_outputs[0]
1238
+ logits = self.score(hidden_states)
1239
+
1240
+ if input_ids is not None:
1241
+ batch_size = input_ids.shape[0]
1242
+ else:
1243
+ batch_size = inputs_embeds.shape[0]
1244
+
1245
+ if self.config.pad_token_id is None and batch_size != 1:
1246
+ raise ValueError("Cannot handle batch sizes > 1 if no padding token is defined.")
1247
+ if self.config.pad_token_id is None:
1248
+ sequence_lengths = -1
1249
+ else:
1250
+ if input_ids is not None:
1251
+ # if no pad token found, use modulo instead of reverse indexing for ONNX compatibility
1252
+ sequence_lengths = torch.eq(input_ids, self.config.pad_token_id).int().argmax(-1) - 1
1253
+ sequence_lengths = sequence_lengths % input_ids.shape[-1]
1254
+ sequence_lengths = sequence_lengths.to(logits.device)
1255
+ else:
1256
+ sequence_lengths = -1
1257
+
1258
+ pooled_logits = logits[torch.arange(batch_size, device=logits.device), sequence_lengths]
1259
+
1260
+ loss = None
1261
+ if labels is not None:
1262
+ labels = labels.to(logits.device)
1263
+ if self.config.problem_type is None:
1264
+ if self.num_labels == 1:
1265
+ self.config.problem_type = "regression"
1266
+ elif self.num_labels > 1 and (labels.dtype == torch.long or labels.dtype == torch.int):
1267
+ self.config.problem_type = "single_label_classification"
1268
+ else:
1269
+ self.config.problem_type = "multi_label_classification"
1270
+
1271
+ if self.config.problem_type == "regression":
1272
+ loss_fct = MSELoss()
1273
+ if self.num_labels == 1:
1274
+ loss = loss_fct(pooled_logits.squeeze(), labels.squeeze())
1275
+ else:
1276
+ loss = loss_fct(pooled_logits, labels)
1277
+ elif self.config.problem_type == "single_label_classification":
1278
+ loss_fct = CrossEntropyLoss()
1279
+ loss = loss_fct(pooled_logits.view(-1, self.num_labels), labels.view(-1))
1280
+ elif self.config.problem_type == "multi_label_classification":
1281
+ loss_fct = BCEWithLogitsLoss()
1282
+ loss = loss_fct(pooled_logits, labels)
1283
+ if not return_dict:
1284
+ output = (pooled_logits,) + model_outputs[1:]
1285
+ return ((loss,) + output) if loss is not None else output
1286
+
1287
+ return SequenceClassifierOutputWithPast(
1288
+ loss=loss,
1289
+ logits=pooled_logits,
1290
+ past_key_values=model_outputs.past_key_values,
1291
+ hidden_states=model_outputs.hidden_states,
1292
+ attentions=model_outputs.attentions,
1293
+ )
1294
+
1295
+
1296
+ @add_start_docstrings(
1297
+ """
1298
+ PhiModel with a token classification head on top (a linear layer on top of the hidden-states output) e.g. for
1299
+ Named-Entity-Recognition (NER) tasks.
1300
+ """,
1301
+ PHI_START_DOCSTRING,
1302
+ )
1303
+ # Copied from transformers.models.mpt.modeling_mpt.MptForTokenClassification with MPT->PHI,Mpt->Phi,self.transformer->self.model,transformer_outputs->model_outputs
1304
+ class PhiForTokenClassification(PhiPreTrainedModel):
1305
+ def __init__(self, config: PhiConfig):
1306
+ super().__init__(config)
1307
+ self.num_labels = config.num_labels
1308
+
1309
+ self.model = PhiModel(config)
1310
+ if hasattr(config, "classifier_dropout") and config.classifier_dropout is not None:
1311
+ classifier_dropout = config.classifier_dropout
1312
+ elif hasattr(config, "hidden_dropout") and config.hidden_dropout is not None:
1313
+ classifier_dropout = config.hidden_dropout
1314
+ else:
1315
+ classifier_dropout = 0.1
1316
+ self.dropout = nn.Dropout(classifier_dropout)
1317
+ self.classifier = nn.Linear(config.hidden_size, config.num_labels)
1318
+
1319
+ # Initialize weights and apply final processing
1320
+ self.post_init()
1321
+
1322
+ @add_start_docstrings_to_model_forward(PHI_INPUTS_DOCSTRING)
1323
+ @add_code_sample_docstrings(
1324
+ checkpoint=_CHECKPOINT_FOR_DOC,
1325
+ output_type=TokenClassifierOutput,
1326
+ config_class=_CONFIG_FOR_DOC,
1327
+ )
1328
+ def forward(
1329
+ self,
1330
+ input_ids: Optional[torch.LongTensor] = None,
1331
+ past_key_values: Optional[Tuple[Tuple[torch.Tensor, torch.Tensor], ...]] = None,
1332
+ attention_mask: Optional[torch.Tensor] = None,
1333
+ inputs_embeds: Optional[torch.Tensor] = None,
1334
+ labels: Optional[torch.Tensor] = None,
1335
+ use_cache: Optional[bool] = None,
1336
+ output_attentions: Optional[bool] = None,
1337
+ output_hidden_states: Optional[bool] = None,
1338
+ return_dict: Optional[bool] = None,
1339
+ **deprecated_arguments,
1340
+ ) -> Union[Tuple[torch.Tensor], TokenClassifierOutput]:
1341
+ r"""
1342
+ labels (`torch.LongTensor` of shape `(batch_size,)`, *optional*):
1343
+ Labels for computing the sequence classification/regression loss. Indices should be in `[0, ...,
1344
+ config.num_labels - 1]`. If `config.num_labels == 1` a regression loss is computed (Mean-Square loss), If
1345
+ `config.num_labels > 1` a classification loss is computed (Cross-Entropy).
1346
+ """
1347
+ return_dict = return_dict if return_dict is not None else self.config.use_return_dict
1348
+
1349
+ model_outputs = self.model(
1350
+ input_ids,
1351
+ past_key_values=past_key_values,
1352
+ attention_mask=attention_mask,
1353
+ inputs_embeds=inputs_embeds,
1354
+ use_cache=use_cache,
1355
+ output_attentions=output_attentions,
1356
+ output_hidden_states=output_hidden_states,
1357
+ return_dict=return_dict,
1358
+ )
1359
+
1360
+ hidden_states = model_outputs[0]
1361
+ hidden_states = self.dropout(hidden_states)
1362
+ logits = self.classifier(hidden_states)
1363
+
1364
+ loss = None
1365
+ if labels is not None:
1366
+ # move labels to correct device to enable model parallelism
1367
+ labels = labels.to(logits.device)
1368
+ batch_size, seq_length = labels.shape
1369
+ loss_fct = CrossEntropyLoss()
1370
+ loss = loss_fct(
1371
+ logits.view(batch_size * seq_length, self.num_labels), labels.view(batch_size * seq_length)
1372
+ )
1373
+
1374
+ if not return_dict:
1375
+ output = (logits,) + model_outputs[2:]
1376
+ return ((loss,) + output) if loss is not None else output
1377
+
1378
+ return TokenClassifierOutput(
1379
+ loss=loss,
1380
+ logits=logits,
1381
+ hidden_states=model_outputs.hidden_states,
1382
+ attentions=model_outputs.attentions,
1383
+ )
special_tokens_map.json ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token": {
3
+ "content": "<|endoftext|>",
4
+ "lstrip": false,
5
+ "normalized": false,
6
+ "rstrip": false,
7
+ "single_word": false
8
+ },
9
+ "eos_token": {
10
+ "content": "<|endoftext|>",
11
+ "lstrip": false,
12
+ "normalized": false,
13
+ "rstrip": false,
14
+ "single_word": false
15
+ },
16
+ "pad_token": "<|endoftext|>",
17
+ "unk_token": {
18
+ "content": "<|endoftext|>",
19
+ "lstrip": false,
20
+ "normalized": false,
21
+ "rstrip": false,
22
+ "single_word": false
23
+ }
24
+ }
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,324 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_prefix_space": false,
3
+ "added_tokens_decoder": {
4
+ "50256": {
5
+ "content": "<|endoftext|>",
6
+ "lstrip": false,
7
+ "normalized": false,
8
+ "rstrip": false,
9
+ "single_word": false,
10
+ "special": true
11
+ },
12
+ "50257": {
13
+ "content": " ",
14
+ "lstrip": false,
15
+ "normalized": true,
16
+ "rstrip": false,
17
+ "single_word": false,
18
+ "special": false
19
+ },
20
+ "50258": {
21
+ "content": " ",
22
+ "lstrip": false,
23
+ "normalized": true,
24
+ "rstrip": false,
25
+ "single_word": false,
26
+ "special": false
27
+ },
28
+ "50259": {
29
+ "content": " ",
30
+ "lstrip": false,
31
+ "normalized": true,
32
+ "rstrip": false,
33
+ "single_word": false,
34
+ "special": false
35
+ },
36
+ "50260": {
37
+ "content": " ",
38
+ "lstrip": false,
39
+ "normalized": true,
40
+ "rstrip": false,
41
+ "single_word": false,
42
+ "special": false
43
+ },
44
+ "50261": {
45
+ "content": " ",
46
+ "lstrip": false,
47
+ "normalized": true,
48
+ "rstrip": false,
49
+ "single_word": false,
50
+ "special": false
51
+ },
52
+ "50262": {
53
+ "content": " ",
54
+ "lstrip": false,
55
+ "normalized": true,
56
+ "rstrip": false,
57
+ "single_word": false,
58
+ "special": false
59
+ },
60
+ "50263": {
61
+ "content": " ",
62
+ "lstrip": false,
63
+ "normalized": true,
64
+ "rstrip": false,
65
+ "single_word": false,
66
+ "special": false
67
+ },
68
+ "50264": {
69
+ "content": " ",
70
+ "lstrip": false,
71
+ "normalized": true,
72
+ "rstrip": false,
73
+ "single_word": false,
74
+ "special": false
75
+ },
76
+ "50265": {
77
+ "content": " ",
78
+ "lstrip": false,
79
+ "normalized": true,
80
+ "rstrip": false,
81
+ "single_word": false,
82
+ "special": false
83
+ },
84
+ "50266": {
85
+ "content": " ",
86
+ "lstrip": false,
87
+ "normalized": true,
88
+ "rstrip": false,
89
+ "single_word": false,
90
+ "special": false
91
+ },
92
+ "50267": {
93
+ "content": " ",
94
+ "lstrip": false,
95
+ "normalized": true,
96
+ "rstrip": false,
97
+ "single_word": false,
98
+ "special": false
99
+ },
100
+ "50268": {
101
+ "content": " ",
102
+ "lstrip": false,
103
+ "normalized": true,
104
+ "rstrip": false,
105
+ "single_word": false,
106
+ "special": false
107
+ },
108
+ "50269": {
109
+ "content": " ",
110
+ "lstrip": false,
111
+ "normalized": true,
112
+ "rstrip": false,
113
+ "single_word": false,
114
+ "special": false
115
+ },
116
+ "50270": {
117
+ "content": " ",
118
+ "lstrip": false,
119
+ "normalized": true,
120
+ "rstrip": false,
121
+ "single_word": false,
122
+ "special": false
123
+ },
124
+ "50271": {
125
+ "content": " ",
126
+ "lstrip": false,
127
+ "normalized": true,
128
+ "rstrip": false,
129
+ "single_word": false,
130
+ "special": false
131
+ },
132
+ "50272": {
133
+ "content": " ",
134
+ "lstrip": false,
135
+ "normalized": true,
136
+ "rstrip": false,
137
+ "single_word": false,
138
+ "special": false
139
+ },
140
+ "50273": {
141
+ "content": " ",
142
+ "lstrip": false,
143
+ "normalized": true,
144
+ "rstrip": false,
145
+ "single_word": false,
146
+ "special": false
147
+ },
148
+ "50274": {
149
+ "content": " ",
150
+ "lstrip": false,
151
+ "normalized": true,
152
+ "rstrip": false,
153
+ "single_word": false,
154
+ "special": false
155
+ },
156
+ "50275": {
157
+ "content": " ",
158
+ "lstrip": false,
159
+ "normalized": true,
160
+ "rstrip": false,
161
+ "single_word": false,
162
+ "special": false
163
+ },
164
+ "50276": {
165
+ "content": " ",
166
+ "lstrip": false,
167
+ "normalized": true,
168
+ "rstrip": false,
169
+ "single_word": false,
170
+ "special": false
171
+ },
172
+ "50277": {
173
+ "content": " ",
174
+ "lstrip": false,
175
+ "normalized": true,
176
+ "rstrip": false,
177
+ "single_word": false,
178
+ "special": false
179
+ },
180
+ "50278": {
181
+ "content": " ",
182
+ "lstrip": false,
183
+ "normalized": true,
184
+ "rstrip": false,
185
+ "single_word": false,
186
+ "special": false
187
+ },
188
+ "50279": {
189
+ "content": " ",
190
+ "lstrip": false,
191
+ "normalized": true,
192
+ "rstrip": false,
193
+ "single_word": false,
194
+ "special": false
195
+ },
196
+ "50280": {
197
+ "content": " ",
198
+ "lstrip": false,
199
+ "normalized": true,
200
+ "rstrip": false,
201
+ "single_word": false,
202
+ "special": false
203
+ },
204
+ "50281": {
205
+ "content": " ",
206
+ "lstrip": false,
207
+ "normalized": true,
208
+ "rstrip": false,
209
+ "single_word": false,
210
+ "special": false
211
+ },
212
+ "50282": {
213
+ "content": " ",
214
+ "lstrip": false,
215
+ "normalized": true,
216
+ "rstrip": false,
217
+ "single_word": false,
218
+ "special": false
219
+ },
220
+ "50283": {
221
+ "content": " ",
222
+ "lstrip": false,
223
+ "normalized": true,
224
+ "rstrip": false,
225
+ "single_word": false,
226
+ "special": false
227
+ },
228
+ "50284": {
229
+ "content": " ",
230
+ "lstrip": false,
231
+ "normalized": true,
232
+ "rstrip": false,
233
+ "single_word": false,
234
+ "special": false
235
+ },
236
+ "50285": {
237
+ "content": " ",
238
+ "lstrip": false,
239
+ "normalized": true,
240
+ "rstrip": false,
241
+ "single_word": false,
242
+ "special": false
243
+ },
244
+ "50286": {
245
+ "content": " ",
246
+ "lstrip": false,
247
+ "normalized": true,
248
+ "rstrip": false,
249
+ "single_word": false,
250
+ "special": false
251
+ },
252
+ "50287": {
253
+ "content": "\t\t\t\t\t\t\t\t\t",
254
+ "lstrip": false,
255
+ "normalized": true,
256
+ "rstrip": false,
257
+ "single_word": false,
258
+ "special": false
259
+ },
260
+ "50288": {
261
+ "content": "\t\t\t\t\t\t\t\t",
262
+ "lstrip": false,
263
+ "normalized": true,
264
+ "rstrip": false,
265
+ "single_word": false,
266
+ "special": false
267
+ },
268
+ "50289": {
269
+ "content": "\t\t\t\t\t\t\t",
270
+ "lstrip": false,
271
+ "normalized": true,
272
+ "rstrip": false,
273
+ "single_word": false,
274
+ "special": false
275
+ },
276
+ "50290": {
277
+ "content": "\t\t\t\t\t\t",
278
+ "lstrip": false,
279
+ "normalized": true,
280
+ "rstrip": false,
281
+ "single_word": false,
282
+ "special": false
283
+ },
284
+ "50291": {
285
+ "content": "\t\t\t\t\t",
286
+ "lstrip": false,
287
+ "normalized": true,
288
+ "rstrip": false,
289
+ "single_word": false,
290
+ "special": false
291
+ },
292
+ "50292": {
293
+ "content": "\t\t\t\t",
294
+ "lstrip": false,
295
+ "normalized": true,
296
+ "rstrip": false,
297
+ "single_word": false,
298
+ "special": false
299
+ },
300
+ "50293": {
301
+ "content": "\t\t\t",
302
+ "lstrip": false,
303
+ "normalized": true,
304
+ "rstrip": false,
305
+ "single_word": false,
306
+ "special": false
307
+ },
308
+ "50294": {
309
+ "content": "\t\t",
310
+ "lstrip": false,
311
+ "normalized": true,
312
+ "rstrip": false,
313
+ "single_word": false,
314
+ "special": false
315
+ }
316
+ },
317
+ "bos_token": "<|endoftext|>",
318
+ "clean_up_tokenization_spaces": true,
319
+ "eos_token": "<|endoftext|>",
320
+ "model_max_length": 2048,
321
+ "pad_token": "<|endoftext|>",
322
+ "tokenizer_class": "CodeGenTokenizer",
323
+ "unk_token": "<|endoftext|>"
324
+ }
trainer_state.json ADDED
The diff for this file is too large to render. See raw diff
 
training_args.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:593a382665bfb7061d5870a24d40892a6ce3424a5ab23a33ecb708768b07fa71
3
+ size 6776
training_datasets_by_stage.jpg ADDED
vocab.json ADDED
The diff for this file is too large to render. See raw diff