trohrbaugh commited on
Commit
990122b
·
verified ·
1 Parent(s): a6e19c1

Upload IQuestCoderForCausalLM

Browse files
README.md ADDED
@@ -0,0 +1,199 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: transformers
3
+ tags: []
4
+ ---
5
+
6
+ # Model Card for Model ID
7
+
8
+ <!-- Provide a quick summary of what the model is/does. -->
9
+
10
+
11
+
12
+ ## Model Details
13
+
14
+ ### Model Description
15
+
16
+ <!-- Provide a longer summary of what this model is. -->
17
+
18
+ This is the model card of a 🤗 transformers model that has been pushed on the Hub. This model card has been automatically generated.
19
+
20
+ - **Developed by:** [More Information Needed]
21
+ - **Funded by [optional]:** [More Information Needed]
22
+ - **Shared by [optional]:** [More Information Needed]
23
+ - **Model type:** [More Information Needed]
24
+ - **Language(s) (NLP):** [More Information Needed]
25
+ - **License:** [More Information Needed]
26
+ - **Finetuned from model [optional]:** [More Information Needed]
27
+
28
+ ### Model Sources [optional]
29
+
30
+ <!-- Provide the basic links for the model. -->
31
+
32
+ - **Repository:** [More Information Needed]
33
+ - **Paper [optional]:** [More Information Needed]
34
+ - **Demo [optional]:** [More Information Needed]
35
+
36
+ ## Uses
37
+
38
+ <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
39
+
40
+ ### Direct Use
41
+
42
+ <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
43
+
44
+ [More Information Needed]
45
+
46
+ ### Downstream Use [optional]
47
+
48
+ <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
49
+
50
+ [More Information Needed]
51
+
52
+ ### Out-of-Scope Use
53
+
54
+ <!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
55
+
56
+ [More Information Needed]
57
+
58
+ ## Bias, Risks, and Limitations
59
+
60
+ <!-- This section is meant to convey both technical and sociotechnical limitations. -->
61
+
62
+ [More Information Needed]
63
+
64
+ ### Recommendations
65
+
66
+ <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
67
+
68
+ Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
69
+
70
+ ## How to Get Started with the Model
71
+
72
+ Use the code below to get started with the model.
73
+
74
+ [More Information Needed]
75
+
76
+ ## Training Details
77
+
78
+ ### Training Data
79
+
80
+ <!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
81
+
82
+ [More Information Needed]
83
+
84
+ ### Training Procedure
85
+
86
+ <!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
87
+
88
+ #### Preprocessing [optional]
89
+
90
+ [More Information Needed]
91
+
92
+
93
+ #### Training Hyperparameters
94
+
95
+ - **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
96
+
97
+ #### Speeds, Sizes, Times [optional]
98
+
99
+ <!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
100
+
101
+ [More Information Needed]
102
+
103
+ ## Evaluation
104
+
105
+ <!-- This section describes the evaluation protocols and provides the results. -->
106
+
107
+ ### Testing Data, Factors & Metrics
108
+
109
+ #### Testing Data
110
+
111
+ <!-- This should link to a Dataset Card if possible. -->
112
+
113
+ [More Information Needed]
114
+
115
+ #### Factors
116
+
117
+ <!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
118
+
119
+ [More Information Needed]
120
+
121
+ #### Metrics
122
+
123
+ <!-- These are the evaluation metrics being used, ideally with a description of why. -->
124
+
125
+ [More Information Needed]
126
+
127
+ ### Results
128
+
129
+ [More Information Needed]
130
+
131
+ #### Summary
132
+
133
+
134
+
135
+ ## Model Examination [optional]
136
+
137
+ <!-- Relevant interpretability work for the model goes here -->
138
+
139
+ [More Information Needed]
140
+
141
+ ## Environmental Impact
142
+
143
+ <!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
144
+
145
+ Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
146
+
147
+ - **Hardware Type:** [More Information Needed]
148
+ - **Hours used:** [More Information Needed]
149
+ - **Cloud Provider:** [More Information Needed]
150
+ - **Compute Region:** [More Information Needed]
151
+ - **Carbon Emitted:** [More Information Needed]
152
+
153
+ ## Technical Specifications [optional]
154
+
155
+ ### Model Architecture and Objective
156
+
157
+ [More Information Needed]
158
+
159
+ ### Compute Infrastructure
160
+
161
+ [More Information Needed]
162
+
163
+ #### Hardware
164
+
165
+ [More Information Needed]
166
+
167
+ #### Software
168
+
169
+ [More Information Needed]
170
+
171
+ ## Citation [optional]
172
+
173
+ <!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
174
+
175
+ **BibTeX:**
176
+
177
+ [More Information Needed]
178
+
179
+ **APA:**
180
+
181
+ [More Information Needed]
182
+
183
+ ## Glossary [optional]
184
+
185
+ <!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
186
+
187
+ [More Information Needed]
188
+
189
+ ## More Information [optional]
190
+
191
+ [More Information Needed]
192
+
193
+ ## Model Card Authors [optional]
194
+
195
+ [More Information Needed]
196
+
197
+ ## Model Card Contact
198
+
199
+ [More Information Needed]
config.json ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "IQuestCoderForCausalLM"
4
+ ],
5
+ "attention_bias": false,
6
+ "attention_dropout": 0.0,
7
+ "auto_map": {
8
+ "AutoConfig": "configuration_iquestcoder.IQuestCoderConfig",
9
+ "AutoModel": "modeling_iquestcoder.IQuestCoderModel",
10
+ "AutoModelForCausalLM": "modeling_iquestcoder.IQuestCoderForCausalLM",
11
+ "AutoModelForQuestionAnswering": "modeling_iquestcoder.IQuestCoderForQuestionAnswering",
12
+ "AutoModelForSequenceClassification": "modeling_iquestcoder.IQuestCoderForSequenceClassification",
13
+ "AutoModelForTokenClassification": "modeling_iquestcoder.IQuestCoderForTokenClassification"
14
+ },
15
+ "bos_token_id": 1,
16
+ "clip_qkv": null,
17
+ "dtype": "bfloat16",
18
+ "eos_token_id": [
19
+ 2,
20
+ 75864,
21
+ 75869
22
+ ],
23
+ "head_dim": 128,
24
+ "hidden_act": "silu",
25
+ "hidden_size": 5120,
26
+ "initializer_range": 0.02,
27
+ "intermediate_size": 27648,
28
+ "max_position_embeddings": 131072,
29
+ "max_window_layers": 0,
30
+ "mlp_bias": false,
31
+ "model_type": "iquestcoder",
32
+ "num_attention_heads": 40,
33
+ "num_hidden_layers": 80,
34
+ "num_key_value_heads": 8,
35
+ "pad_token_id": null,
36
+ "pretraining_tp": 1,
37
+ "rms_norm_eps": 1e-05,
38
+ "rope_parameters": {
39
+ "rope_theta": 500000.0,
40
+ "rope_type": "default"
41
+ },
42
+ "rope_theta": 500000.0,
43
+ "sliding_window": null,
44
+ "tie_word_embeddings": false,
45
+ "transformers_version": "5.4.0",
46
+ "use_cache": true,
47
+ "use_sliding_window": false,
48
+ "vocab_size": 76800
49
+ }
configuration_iquestcoder.py ADDED
@@ -0,0 +1,182 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """IQuestCoder model configuration."""
2
+
3
+ from transformers.configuration_utils import PretrainedConfig
4
+ from transformers.utils import logging
5
+
6
+
7
+ logger = logging.get_logger(__name__)
8
+
9
+
10
+ class IQuestCoderConfig(PretrainedConfig):
11
+ r"""
12
+ This is the configuration class to store the configuration of a [`IQuestCoderModel`]. It is used to instantiate
13
+ an IQuestCoder model according to the specified arguments, defining the model architecture.
14
+
15
+ Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the
16
+ documentation from [`PretrainedConfig`] for more information.
17
+
18
+ Args:
19
+ vocab_size (`int`, *optional*, defaults to 76800):
20
+ Vocabulary size of the IQuestCoder model. Defines the number of different tokens that can be represented
21
+ by the `inputs_ids` passed when calling [`IQuestCoderModel`].
22
+ hidden_size (`int`, *optional*, defaults to 5120):
23
+ Dimension of the hidden representations.
24
+ intermediate_size (`int`, *optional*, defaults to 27648):
25
+ Dimension of the MLP representations.
26
+ num_hidden_layers (`int`, *optional*, defaults to 80):
27
+ Number of hidden layers in the Transformer decoder.
28
+ num_attention_heads (`int`, *optional*, defaults to 40):
29
+ Number of attention heads for each attention layer in the Transformer decoder.
30
+ num_key_value_heads (`int`, *optional*, defaults to 8):
31
+ This is the number of key_value heads that should be used to implement Grouped Query Attention (GQA).
32
+ If `num_key_value_heads=num_attention_heads`, the model will use Multi Head Attention (MHA).
33
+ If `num_key_value_heads=1`, the model will use Multi Query Attention (MQA).
34
+ head_dim (`int`, *optional*, defaults to 128):
35
+ The dimension of each attention head. If not specified, defaults to `hidden_size // num_attention_heads`.
36
+ hidden_act (`str` or `function`, *optional*, defaults to `"silu"`):
37
+ The non-linear activation function (function or string) in the decoder.
38
+ max_position_embeddings (`int`, *optional*, defaults to 16384):
39
+ The maximum sequence length that this model might ever be used with.
40
+ initializer_range (`float`, *optional*, defaults to 0.02):
41
+ The standard deviation of the truncated_normal_initializer for initializing all weight matrices.
42
+ rms_norm_eps (`float`, *optional*, defaults to 1e-05):
43
+ The epsilon used by the rms normalization layers.
44
+ use_cache (`bool`, *optional*, defaults to `True`):
45
+ Whether or not the model should return the last key/values attentions (not used by all models).
46
+ pad_token_id (`int`, *optional*):
47
+ Padding token id.
48
+ bos_token_id (`int`, *optional*, defaults to 1):
49
+ Beginning of stream token id.
50
+ eos_token_id (`int`, *optional*, defaults to 2):
51
+ End of stream token id.
52
+ tie_word_embeddings (`bool`, *optional*, defaults to `False`):
53
+ Whether to tie weight embeddings.
54
+ rope_theta (`float`, *optional*, defaults to 500000.0):
55
+ The base period of the RoPE embeddings.
56
+ rope_scaling (`Dict`, *optional*):
57
+ Dictionary containing the scaling configuration for the RoPE embeddings. Supports various RoPE scaling
58
+ types including "linear", "dynamic", "yarn", "longrope", etc.
59
+ attention_bias (`bool`, *optional*, defaults to `False`):
60
+ Whether to use a bias in the query, key, value and output projection layers during self-attention.
61
+ attention_dropout (`float`, *optional*, defaults to 0.0):
62
+ The dropout ratio for the attention probabilities.
63
+ mlp_bias (`bool`, *optional*, defaults to `False`):
64
+ Whether to use a bias in up_proj, down_proj and gate_proj layers in the MLP layers.
65
+ clip_qkv (`float`, *optional*):
66
+ If set, clip the query, key, and value tensors to this value. Borrowed from OLMo for training stability.
67
+ use_sliding_window (`bool`, *optional*, defaults to `False`):
68
+ Whether to use sliding window attention. Borrowed from Qwen2.
69
+ sliding_window (`int`, *optional*):
70
+ The sliding window size. Only effective when `use_sliding_window=True`.
71
+ max_window_layers (`int`, *optional*, defaults to 0):
72
+ The number of layers that don't use sliding window attention. Borrowed from Qwen2.
73
+
74
+ Example:
75
+ ```python
76
+ >>> from configuration_iquestcoder import IQuestCoderConfig
77
+ >>> from modeling_iquestcoder import IQuestCoderModel
78
+
79
+ >>> # Initializing a IQuestCoder configuration
80
+ >>> configuration = IQuestCoderConfig()
81
+
82
+ >>> # Initializing a model from the configuration
83
+ >>> model = IQuestCoderModel(configuration)
84
+
85
+ >>> # Accessing the model configuration
86
+ >>> configuration = model.config
87
+ ```
88
+ """
89
+
90
+ model_type = "iquestcoder"
91
+ keys_to_ignore_at_inference = ["past_key_values"]
92
+
93
+ def __init__(
94
+ self,
95
+ vocab_size=76800,
96
+ hidden_size=5120,
97
+ intermediate_size=27648,
98
+ num_hidden_layers=80,
99
+ num_attention_heads=40,
100
+ num_key_value_heads=8,
101
+ head_dim=128,
102
+ hidden_act="silu",
103
+ max_position_embeddings=16384,
104
+ initializer_range=0.02,
105
+ rms_norm_eps=1e-5,
106
+ use_cache=True,
107
+ pad_token_id=None,
108
+ bos_token_id=1,
109
+ eos_token_id=2,
110
+ tie_word_embeddings=False,
111
+ rope_theta=500000.0,
112
+ rope_scaling=None,
113
+ attention_bias=False,
114
+ attention_dropout=0.0,
115
+ mlp_bias=False,
116
+ # IQuestCoder specific (borrowed from OLMo)
117
+ clip_qkv=None,
118
+ # IQuestCoder specific (borrowed from Qwen2)
119
+ use_sliding_window=False,
120
+ sliding_window=None,
121
+ max_window_layers=0,
122
+ **kwargs,
123
+ ):
124
+ self.vocab_size = vocab_size
125
+ self.max_position_embeddings = max_position_embeddings
126
+ self.hidden_size = hidden_size
127
+ self.intermediate_size = intermediate_size
128
+ self.num_hidden_layers = num_hidden_layers
129
+ self.num_attention_heads = num_attention_heads
130
+ self.num_key_value_heads = num_key_value_heads
131
+ self.head_dim = head_dim
132
+ self.hidden_act = hidden_act
133
+ self.initializer_range = initializer_range
134
+ self.rms_norm_eps = rms_norm_eps
135
+ self.use_cache = use_cache
136
+ self.rope_theta = rope_theta
137
+ self.rope_scaling = rope_scaling
138
+ self.attention_bias = attention_bias
139
+ self.attention_dropout = attention_dropout
140
+ self.mlp_bias = mlp_bias
141
+ # IQuestCoder specific
142
+ self.clip_qkv = clip_qkv
143
+ self.use_sliding_window = use_sliding_window
144
+ self.sliding_window = sliding_window
145
+ self.max_window_layers = max_window_layers
146
+
147
+ # Validate rope_scaling configuration
148
+ self._rope_scaling_validation()
149
+
150
+ super().__init__(
151
+ pad_token_id=pad_token_id,
152
+ bos_token_id=bos_token_id,
153
+ eos_token_id=eos_token_id,
154
+ tie_word_embeddings=tie_word_embeddings,
155
+ **kwargs,
156
+ )
157
+
158
+ def _rope_scaling_validation(self):
159
+ """Validate the `rope_scaling` configuration."""
160
+ if self.rope_scaling is None:
161
+ return
162
+
163
+ if not isinstance(self.rope_scaling, dict) or len(self.rope_scaling) < 1:
164
+ raise ValueError(
165
+ "`rope_scaling` must be a dictionary with a minimum of one field, `type` or `rope_type`."
166
+ )
167
+
168
+ rope_scaling_type = self.rope_scaling.get("type", None) or self.rope_scaling.get("rope_type", None)
169
+ if rope_scaling_type is None:
170
+ raise ValueError(
171
+ "`rope_scaling` must have a `type` or `rope_type` field."
172
+ )
173
+
174
+ valid_rope_types = ["linear", "dynamic", "yarn", "longrope", "llama3"]
175
+ if rope_scaling_type not in valid_rope_types:
176
+ raise ValueError(
177
+ f"`rope_scaling`'s type field must be one of {valid_rope_types}, got {rope_scaling_type}"
178
+ )
179
+
180
+
181
+ __all__ = ["IQuestCoderConfig"]
182
+
generation_config.json ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "bos_token_id": 1,
4
+ "eos_token_id": [
5
+ 2,
6
+ 75864,
7
+ 75869
8
+ ],
9
+ "transformers_version": "5.4.0"
10
+ }
model-00001-of-00009.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f5cb27125a0d2e92efb0da9bd5e5adfc07576584d9ae6e3c08862bade2028157
3
+ size 9940683472
model-00002-of-00009.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:beac6ac0449817fc06be0afcc463af40ee684c30fb31aa7f03a7e86c1752aff1
3
+ size 9751972104
model-00003-of-00009.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:52aa28b75354215caf9e550743d1689490f2b59fa9f36f4d6a44271ddceb09d9
3
+ size 9751972128
model-00004-of-00009.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c54c907d10c4013be78863b5aa31452b0aab126c41008e235e0191487a8b6e83
3
+ size 9751972128
model-00005-of-00009.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:092cb4820ed355ec25699540e2fb113420a13663523a8d761a2c8f4fc0b04a21
3
+ size 9751972128
model-00006-of-00009.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b55bad18cb00658c91d56a9255f09007ed616205a9069baa512ff4ed806164cd
3
+ size 9751972128
model-00007-of-00009.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a7ba083cc57b5266a6c2096da402a63a39f728e1559630ad9e9fbb5ac1e43f53
3
+ size 9751972128
model-00008-of-00009.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d6ce6415e3c3c51c0ed5a4eb2600bd574b271f8acd853e2f5c2efd358f887a20
3
+ size 9751972128
model-00009-of-00009.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:10fd4c90568d7812df44075ca0dbaf63ae581c44f7e1e7dd4b7541b66f9b19cb
3
+ size 1384163144
model.safetensors.index.json ADDED
@@ -0,0 +1,731 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "metadata": {
3
+ "total_parameters": 39794283520,
4
+ "total_size": 79588567040
5
+ },
6
+ "weight_map": {
7
+ "lm_head.weight": "model-00001-of-00009.safetensors",
8
+ "model.embed_tokens.weight": "model-00001-of-00009.safetensors",
9
+ "model.layers.0.input_layernorm.weight": "model-00001-of-00009.safetensors",
10
+ "model.layers.0.mlp.down_proj.weight": "model-00001-of-00009.safetensors",
11
+ "model.layers.0.mlp.gate_proj.weight": "model-00001-of-00009.safetensors",
12
+ "model.layers.0.mlp.up_proj.weight": "model-00001-of-00009.safetensors",
13
+ "model.layers.0.post_attention_layernorm.weight": "model-00001-of-00009.safetensors",
14
+ "model.layers.0.self_attn.k_proj.weight": "model-00001-of-00009.safetensors",
15
+ "model.layers.0.self_attn.o_proj.weight": "model-00001-of-00009.safetensors",
16
+ "model.layers.0.self_attn.q_proj.weight": "model-00001-of-00009.safetensors",
17
+ "model.layers.0.self_attn.v_proj.weight": "model-00001-of-00009.safetensors",
18
+ "model.layers.1.input_layernorm.weight": "model-00001-of-00009.safetensors",
19
+ "model.layers.1.mlp.down_proj.weight": "model-00001-of-00009.safetensors",
20
+ "model.layers.1.mlp.gate_proj.weight": "model-00001-of-00009.safetensors",
21
+ "model.layers.1.mlp.up_proj.weight": "model-00001-of-00009.safetensors",
22
+ "model.layers.1.post_attention_layernorm.weight": "model-00001-of-00009.safetensors",
23
+ "model.layers.1.self_attn.k_proj.weight": "model-00001-of-00009.safetensors",
24
+ "model.layers.1.self_attn.o_proj.weight": "model-00001-of-00009.safetensors",
25
+ "model.layers.1.self_attn.q_proj.weight": "model-00001-of-00009.safetensors",
26
+ "model.layers.1.self_attn.v_proj.weight": "model-00001-of-00009.safetensors",
27
+ "model.layers.10.input_layernorm.weight": "model-00002-of-00009.safetensors",
28
+ "model.layers.10.mlp.down_proj.weight": "model-00002-of-00009.safetensors",
29
+ "model.layers.10.mlp.gate_proj.weight": "model-00002-of-00009.safetensors",
30
+ "model.layers.10.mlp.up_proj.weight": "model-00002-of-00009.safetensors",
31
+ "model.layers.10.post_attention_layernorm.weight": "model-00002-of-00009.safetensors",
32
+ "model.layers.10.self_attn.k_proj.weight": "model-00002-of-00009.safetensors",
33
+ "model.layers.10.self_attn.o_proj.weight": "model-00002-of-00009.safetensors",
34
+ "model.layers.10.self_attn.q_proj.weight": "model-00002-of-00009.safetensors",
35
+ "model.layers.10.self_attn.v_proj.weight": "model-00002-of-00009.safetensors",
36
+ "model.layers.11.input_layernorm.weight": "model-00002-of-00009.safetensors",
37
+ "model.layers.11.mlp.down_proj.weight": "model-00002-of-00009.safetensors",
38
+ "model.layers.11.mlp.gate_proj.weight": "model-00002-of-00009.safetensors",
39
+ "model.layers.11.mlp.up_proj.weight": "model-00002-of-00009.safetensors",
40
+ "model.layers.11.post_attention_layernorm.weight": "model-00002-of-00009.safetensors",
41
+ "model.layers.11.self_attn.k_proj.weight": "model-00002-of-00009.safetensors",
42
+ "model.layers.11.self_attn.o_proj.weight": "model-00002-of-00009.safetensors",
43
+ "model.layers.11.self_attn.q_proj.weight": "model-00002-of-00009.safetensors",
44
+ "model.layers.11.self_attn.v_proj.weight": "model-00002-of-00009.safetensors",
45
+ "model.layers.12.input_layernorm.weight": "model-00002-of-00009.safetensors",
46
+ "model.layers.12.mlp.down_proj.weight": "model-00002-of-00009.safetensors",
47
+ "model.layers.12.mlp.gate_proj.weight": "model-00002-of-00009.safetensors",
48
+ "model.layers.12.mlp.up_proj.weight": "model-00002-of-00009.safetensors",
49
+ "model.layers.12.post_attention_layernorm.weight": "model-00002-of-00009.safetensors",
50
+ "model.layers.12.self_attn.k_proj.weight": "model-00002-of-00009.safetensors",
51
+ "model.layers.12.self_attn.o_proj.weight": "model-00002-of-00009.safetensors",
52
+ "model.layers.12.self_attn.q_proj.weight": "model-00002-of-00009.safetensors",
53
+ "model.layers.12.self_attn.v_proj.weight": "model-00002-of-00009.safetensors",
54
+ "model.layers.13.input_layernorm.weight": "model-00002-of-00009.safetensors",
55
+ "model.layers.13.mlp.down_proj.weight": "model-00002-of-00009.safetensors",
56
+ "model.layers.13.mlp.gate_proj.weight": "model-00002-of-00009.safetensors",
57
+ "model.layers.13.mlp.up_proj.weight": "model-00002-of-00009.safetensors",
58
+ "model.layers.13.post_attention_layernorm.weight": "model-00002-of-00009.safetensors",
59
+ "model.layers.13.self_attn.k_proj.weight": "model-00002-of-00009.safetensors",
60
+ "model.layers.13.self_attn.o_proj.weight": "model-00002-of-00009.safetensors",
61
+ "model.layers.13.self_attn.q_proj.weight": "model-00002-of-00009.safetensors",
62
+ "model.layers.13.self_attn.v_proj.weight": "model-00002-of-00009.safetensors",
63
+ "model.layers.14.input_layernorm.weight": "model-00002-of-00009.safetensors",
64
+ "model.layers.14.mlp.down_proj.weight": "model-00002-of-00009.safetensors",
65
+ "model.layers.14.mlp.gate_proj.weight": "model-00002-of-00009.safetensors",
66
+ "model.layers.14.mlp.up_proj.weight": "model-00002-of-00009.safetensors",
67
+ "model.layers.14.post_attention_layernorm.weight": "model-00002-of-00009.safetensors",
68
+ "model.layers.14.self_attn.k_proj.weight": "model-00002-of-00009.safetensors",
69
+ "model.layers.14.self_attn.o_proj.weight": "model-00002-of-00009.safetensors",
70
+ "model.layers.14.self_attn.q_proj.weight": "model-00002-of-00009.safetensors",
71
+ "model.layers.14.self_attn.v_proj.weight": "model-00002-of-00009.safetensors",
72
+ "model.layers.15.input_layernorm.weight": "model-00002-of-00009.safetensors",
73
+ "model.layers.15.mlp.down_proj.weight": "model-00002-of-00009.safetensors",
74
+ "model.layers.15.mlp.gate_proj.weight": "model-00002-of-00009.safetensors",
75
+ "model.layers.15.mlp.up_proj.weight": "model-00002-of-00009.safetensors",
76
+ "model.layers.15.post_attention_layernorm.weight": "model-00002-of-00009.safetensors",
77
+ "model.layers.15.self_attn.k_proj.weight": "model-00002-of-00009.safetensors",
78
+ "model.layers.15.self_attn.o_proj.weight": "model-00002-of-00009.safetensors",
79
+ "model.layers.15.self_attn.q_proj.weight": "model-00002-of-00009.safetensors",
80
+ "model.layers.15.self_attn.v_proj.weight": "model-00002-of-00009.safetensors",
81
+ "model.layers.16.input_layernorm.weight": "model-00002-of-00009.safetensors",
82
+ "model.layers.16.mlp.down_proj.weight": "model-00002-of-00009.safetensors",
83
+ "model.layers.16.mlp.gate_proj.weight": "model-00002-of-00009.safetensors",
84
+ "model.layers.16.mlp.up_proj.weight": "model-00002-of-00009.safetensors",
85
+ "model.layers.16.post_attention_layernorm.weight": "model-00002-of-00009.safetensors",
86
+ "model.layers.16.self_attn.k_proj.weight": "model-00002-of-00009.safetensors",
87
+ "model.layers.16.self_attn.o_proj.weight": "model-00002-of-00009.safetensors",
88
+ "model.layers.16.self_attn.q_proj.weight": "model-00002-of-00009.safetensors",
89
+ "model.layers.16.self_attn.v_proj.weight": "model-00002-of-00009.safetensors",
90
+ "model.layers.17.input_layernorm.weight": "model-00002-of-00009.safetensors",
91
+ "model.layers.17.mlp.down_proj.weight": "model-00002-of-00009.safetensors",
92
+ "model.layers.17.mlp.gate_proj.weight": "model-00002-of-00009.safetensors",
93
+ "model.layers.17.mlp.up_proj.weight": "model-00002-of-00009.safetensors",
94
+ "model.layers.17.post_attention_layernorm.weight": "model-00002-of-00009.safetensors",
95
+ "model.layers.17.self_attn.k_proj.weight": "model-00002-of-00009.safetensors",
96
+ "model.layers.17.self_attn.o_proj.weight": "model-00002-of-00009.safetensors",
97
+ "model.layers.17.self_attn.q_proj.weight": "model-00002-of-00009.safetensors",
98
+ "model.layers.17.self_attn.v_proj.weight": "model-00002-of-00009.safetensors",
99
+ "model.layers.18.input_layernorm.weight": "model-00002-of-00009.safetensors",
100
+ "model.layers.18.mlp.down_proj.weight": "model-00002-of-00009.safetensors",
101
+ "model.layers.18.mlp.gate_proj.weight": "model-00002-of-00009.safetensors",
102
+ "model.layers.18.mlp.up_proj.weight": "model-00003-of-00009.safetensors",
103
+ "model.layers.18.post_attention_layernorm.weight": "model-00003-of-00009.safetensors",
104
+ "model.layers.18.self_attn.k_proj.weight": "model-00003-of-00009.safetensors",
105
+ "model.layers.18.self_attn.o_proj.weight": "model-00003-of-00009.safetensors",
106
+ "model.layers.18.self_attn.q_proj.weight": "model-00003-of-00009.safetensors",
107
+ "model.layers.18.self_attn.v_proj.weight": "model-00003-of-00009.safetensors",
108
+ "model.layers.19.input_layernorm.weight": "model-00003-of-00009.safetensors",
109
+ "model.layers.19.mlp.down_proj.weight": "model-00003-of-00009.safetensors",
110
+ "model.layers.19.mlp.gate_proj.weight": "model-00003-of-00009.safetensors",
111
+ "model.layers.19.mlp.up_proj.weight": "model-00003-of-00009.safetensors",
112
+ "model.layers.19.post_attention_layernorm.weight": "model-00003-of-00009.safetensors",
113
+ "model.layers.19.self_attn.k_proj.weight": "model-00003-of-00009.safetensors",
114
+ "model.layers.19.self_attn.o_proj.weight": "model-00003-of-00009.safetensors",
115
+ "model.layers.19.self_attn.q_proj.weight": "model-00003-of-00009.safetensors",
116
+ "model.layers.19.self_attn.v_proj.weight": "model-00003-of-00009.safetensors",
117
+ "model.layers.2.input_layernorm.weight": "model-00001-of-00009.safetensors",
118
+ "model.layers.2.mlp.down_proj.weight": "model-00001-of-00009.safetensors",
119
+ "model.layers.2.mlp.gate_proj.weight": "model-00001-of-00009.safetensors",
120
+ "model.layers.2.mlp.up_proj.weight": "model-00001-of-00009.safetensors",
121
+ "model.layers.2.post_attention_layernorm.weight": "model-00001-of-00009.safetensors",
122
+ "model.layers.2.self_attn.k_proj.weight": "model-00001-of-00009.safetensors",
123
+ "model.layers.2.self_attn.o_proj.weight": "model-00001-of-00009.safetensors",
124
+ "model.layers.2.self_attn.q_proj.weight": "model-00001-of-00009.safetensors",
125
+ "model.layers.2.self_attn.v_proj.weight": "model-00001-of-00009.safetensors",
126
+ "model.layers.20.input_layernorm.weight": "model-00003-of-00009.safetensors",
127
+ "model.layers.20.mlp.down_proj.weight": "model-00003-of-00009.safetensors",
128
+ "model.layers.20.mlp.gate_proj.weight": "model-00003-of-00009.safetensors",
129
+ "model.layers.20.mlp.up_proj.weight": "model-00003-of-00009.safetensors",
130
+ "model.layers.20.post_attention_layernorm.weight": "model-00003-of-00009.safetensors",
131
+ "model.layers.20.self_attn.k_proj.weight": "model-00003-of-00009.safetensors",
132
+ "model.layers.20.self_attn.o_proj.weight": "model-00003-of-00009.safetensors",
133
+ "model.layers.20.self_attn.q_proj.weight": "model-00003-of-00009.safetensors",
134
+ "model.layers.20.self_attn.v_proj.weight": "model-00003-of-00009.safetensors",
135
+ "model.layers.21.input_layernorm.weight": "model-00003-of-00009.safetensors",
136
+ "model.layers.21.mlp.down_proj.weight": "model-00003-of-00009.safetensors",
137
+ "model.layers.21.mlp.gate_proj.weight": "model-00003-of-00009.safetensors",
138
+ "model.layers.21.mlp.up_proj.weight": "model-00003-of-00009.safetensors",
139
+ "model.layers.21.post_attention_layernorm.weight": "model-00003-of-00009.safetensors",
140
+ "model.layers.21.self_attn.k_proj.weight": "model-00003-of-00009.safetensors",
141
+ "model.layers.21.self_attn.o_proj.weight": "model-00003-of-00009.safetensors",
142
+ "model.layers.21.self_attn.q_proj.weight": "model-00003-of-00009.safetensors",
143
+ "model.layers.21.self_attn.v_proj.weight": "model-00003-of-00009.safetensors",
144
+ "model.layers.22.input_layernorm.weight": "model-00003-of-00009.safetensors",
145
+ "model.layers.22.mlp.down_proj.weight": "model-00003-of-00009.safetensors",
146
+ "model.layers.22.mlp.gate_proj.weight": "model-00003-of-00009.safetensors",
147
+ "model.layers.22.mlp.up_proj.weight": "model-00003-of-00009.safetensors",
148
+ "model.layers.22.post_attention_layernorm.weight": "model-00003-of-00009.safetensors",
149
+ "model.layers.22.self_attn.k_proj.weight": "model-00003-of-00009.safetensors",
150
+ "model.layers.22.self_attn.o_proj.weight": "model-00003-of-00009.safetensors",
151
+ "model.layers.22.self_attn.q_proj.weight": "model-00003-of-00009.safetensors",
152
+ "model.layers.22.self_attn.v_proj.weight": "model-00003-of-00009.safetensors",
153
+ "model.layers.23.input_layernorm.weight": "model-00003-of-00009.safetensors",
154
+ "model.layers.23.mlp.down_proj.weight": "model-00003-of-00009.safetensors",
155
+ "model.layers.23.mlp.gate_proj.weight": "model-00003-of-00009.safetensors",
156
+ "model.layers.23.mlp.up_proj.weight": "model-00003-of-00009.safetensors",
157
+ "model.layers.23.post_attention_layernorm.weight": "model-00003-of-00009.safetensors",
158
+ "model.layers.23.self_attn.k_proj.weight": "model-00003-of-00009.safetensors",
159
+ "model.layers.23.self_attn.o_proj.weight": "model-00003-of-00009.safetensors",
160
+ "model.layers.23.self_attn.q_proj.weight": "model-00003-of-00009.safetensors",
161
+ "model.layers.23.self_attn.v_proj.weight": "model-00003-of-00009.safetensors",
162
+ "model.layers.24.input_layernorm.weight": "model-00003-of-00009.safetensors",
163
+ "model.layers.24.mlp.down_proj.weight": "model-00003-of-00009.safetensors",
164
+ "model.layers.24.mlp.gate_proj.weight": "model-00003-of-00009.safetensors",
165
+ "model.layers.24.mlp.up_proj.weight": "model-00003-of-00009.safetensors",
166
+ "model.layers.24.post_attention_layernorm.weight": "model-00003-of-00009.safetensors",
167
+ "model.layers.24.self_attn.k_proj.weight": "model-00003-of-00009.safetensors",
168
+ "model.layers.24.self_attn.o_proj.weight": "model-00003-of-00009.safetensors",
169
+ "model.layers.24.self_attn.q_proj.weight": "model-00003-of-00009.safetensors",
170
+ "model.layers.24.self_attn.v_proj.weight": "model-00003-of-00009.safetensors",
171
+ "model.layers.25.input_layernorm.weight": "model-00003-of-00009.safetensors",
172
+ "model.layers.25.mlp.down_proj.weight": "model-00003-of-00009.safetensors",
173
+ "model.layers.25.mlp.gate_proj.weight": "model-00003-of-00009.safetensors",
174
+ "model.layers.25.mlp.up_proj.weight": "model-00003-of-00009.safetensors",
175
+ "model.layers.25.post_attention_layernorm.weight": "model-00003-of-00009.safetensors",
176
+ "model.layers.25.self_attn.k_proj.weight": "model-00003-of-00009.safetensors",
177
+ "model.layers.25.self_attn.o_proj.weight": "model-00003-of-00009.safetensors",
178
+ "model.layers.25.self_attn.q_proj.weight": "model-00003-of-00009.safetensors",
179
+ "model.layers.25.self_attn.v_proj.weight": "model-00003-of-00009.safetensors",
180
+ "model.layers.26.input_layernorm.weight": "model-00003-of-00009.safetensors",
181
+ "model.layers.26.mlp.down_proj.weight": "model-00003-of-00009.safetensors",
182
+ "model.layers.26.mlp.gate_proj.weight": "model-00003-of-00009.safetensors",
183
+ "model.layers.26.mlp.up_proj.weight": "model-00003-of-00009.safetensors",
184
+ "model.layers.26.post_attention_layernorm.weight": "model-00003-of-00009.safetensors",
185
+ "model.layers.26.self_attn.k_proj.weight": "model-00003-of-00009.safetensors",
186
+ "model.layers.26.self_attn.o_proj.weight": "model-00003-of-00009.safetensors",
187
+ "model.layers.26.self_attn.q_proj.weight": "model-00003-of-00009.safetensors",
188
+ "model.layers.26.self_attn.v_proj.weight": "model-00003-of-00009.safetensors",
189
+ "model.layers.27.input_layernorm.weight": "model-00003-of-00009.safetensors",
190
+ "model.layers.27.mlp.down_proj.weight": "model-00003-of-00009.safetensors",
191
+ "model.layers.27.mlp.gate_proj.weight": "model-00003-of-00009.safetensors",
192
+ "model.layers.27.mlp.up_proj.weight": "model-00003-of-00009.safetensors",
193
+ "model.layers.27.post_attention_layernorm.weight": "model-00003-of-00009.safetensors",
194
+ "model.layers.27.self_attn.k_proj.weight": "model-00003-of-00009.safetensors",
195
+ "model.layers.27.self_attn.o_proj.weight": "model-00003-of-00009.safetensors",
196
+ "model.layers.27.self_attn.q_proj.weight": "model-00003-of-00009.safetensors",
197
+ "model.layers.27.self_attn.v_proj.weight": "model-00003-of-00009.safetensors",
198
+ "model.layers.28.input_layernorm.weight": "model-00003-of-00009.safetensors",
199
+ "model.layers.28.mlp.down_proj.weight": "model-00003-of-00009.safetensors",
200
+ "model.layers.28.mlp.gate_proj.weight": "model-00003-of-00009.safetensors",
201
+ "model.layers.28.mlp.up_proj.weight": "model-00004-of-00009.safetensors",
202
+ "model.layers.28.post_attention_layernorm.weight": "model-00004-of-00009.safetensors",
203
+ "model.layers.28.self_attn.k_proj.weight": "model-00004-of-00009.safetensors",
204
+ "model.layers.28.self_attn.o_proj.weight": "model-00004-of-00009.safetensors",
205
+ "model.layers.28.self_attn.q_proj.weight": "model-00004-of-00009.safetensors",
206
+ "model.layers.28.self_attn.v_proj.weight": "model-00004-of-00009.safetensors",
207
+ "model.layers.29.input_layernorm.weight": "model-00004-of-00009.safetensors",
208
+ "model.layers.29.mlp.down_proj.weight": "model-00004-of-00009.safetensors",
209
+ "model.layers.29.mlp.gate_proj.weight": "model-00004-of-00009.safetensors",
210
+ "model.layers.29.mlp.up_proj.weight": "model-00004-of-00009.safetensors",
211
+ "model.layers.29.post_attention_layernorm.weight": "model-00004-of-00009.safetensors",
212
+ "model.layers.29.self_attn.k_proj.weight": "model-00004-of-00009.safetensors",
213
+ "model.layers.29.self_attn.o_proj.weight": "model-00004-of-00009.safetensors",
214
+ "model.layers.29.self_attn.q_proj.weight": "model-00004-of-00009.safetensors",
215
+ "model.layers.29.self_attn.v_proj.weight": "model-00004-of-00009.safetensors",
216
+ "model.layers.3.input_layernorm.weight": "model-00001-of-00009.safetensors",
217
+ "model.layers.3.mlp.down_proj.weight": "model-00001-of-00009.safetensors",
218
+ "model.layers.3.mlp.gate_proj.weight": "model-00001-of-00009.safetensors",
219
+ "model.layers.3.mlp.up_proj.weight": "model-00001-of-00009.safetensors",
220
+ "model.layers.3.post_attention_layernorm.weight": "model-00001-of-00009.safetensors",
221
+ "model.layers.3.self_attn.k_proj.weight": "model-00001-of-00009.safetensors",
222
+ "model.layers.3.self_attn.o_proj.weight": "model-00001-of-00009.safetensors",
223
+ "model.layers.3.self_attn.q_proj.weight": "model-00001-of-00009.safetensors",
224
+ "model.layers.3.self_attn.v_proj.weight": "model-00001-of-00009.safetensors",
225
+ "model.layers.30.input_layernorm.weight": "model-00004-of-00009.safetensors",
226
+ "model.layers.30.mlp.down_proj.weight": "model-00004-of-00009.safetensors",
227
+ "model.layers.30.mlp.gate_proj.weight": "model-00004-of-00009.safetensors",
228
+ "model.layers.30.mlp.up_proj.weight": "model-00004-of-00009.safetensors",
229
+ "model.layers.30.post_attention_layernorm.weight": "model-00004-of-00009.safetensors",
230
+ "model.layers.30.self_attn.k_proj.weight": "model-00004-of-00009.safetensors",
231
+ "model.layers.30.self_attn.o_proj.weight": "model-00004-of-00009.safetensors",
232
+ "model.layers.30.self_attn.q_proj.weight": "model-00004-of-00009.safetensors",
233
+ "model.layers.30.self_attn.v_proj.weight": "model-00004-of-00009.safetensors",
234
+ "model.layers.31.input_layernorm.weight": "model-00004-of-00009.safetensors",
235
+ "model.layers.31.mlp.down_proj.weight": "model-00004-of-00009.safetensors",
236
+ "model.layers.31.mlp.gate_proj.weight": "model-00004-of-00009.safetensors",
237
+ "model.layers.31.mlp.up_proj.weight": "model-00004-of-00009.safetensors",
238
+ "model.layers.31.post_attention_layernorm.weight": "model-00004-of-00009.safetensors",
239
+ "model.layers.31.self_attn.k_proj.weight": "model-00004-of-00009.safetensors",
240
+ "model.layers.31.self_attn.o_proj.weight": "model-00004-of-00009.safetensors",
241
+ "model.layers.31.self_attn.q_proj.weight": "model-00004-of-00009.safetensors",
242
+ "model.layers.31.self_attn.v_proj.weight": "model-00004-of-00009.safetensors",
243
+ "model.layers.32.input_layernorm.weight": "model-00004-of-00009.safetensors",
244
+ "model.layers.32.mlp.down_proj.weight": "model-00004-of-00009.safetensors",
245
+ "model.layers.32.mlp.gate_proj.weight": "model-00004-of-00009.safetensors",
246
+ "model.layers.32.mlp.up_proj.weight": "model-00004-of-00009.safetensors",
247
+ "model.layers.32.post_attention_layernorm.weight": "model-00004-of-00009.safetensors",
248
+ "model.layers.32.self_attn.k_proj.weight": "model-00004-of-00009.safetensors",
249
+ "model.layers.32.self_attn.o_proj.weight": "model-00004-of-00009.safetensors",
250
+ "model.layers.32.self_attn.q_proj.weight": "model-00004-of-00009.safetensors",
251
+ "model.layers.32.self_attn.v_proj.weight": "model-00004-of-00009.safetensors",
252
+ "model.layers.33.input_layernorm.weight": "model-00004-of-00009.safetensors",
253
+ "model.layers.33.mlp.down_proj.weight": "model-00004-of-00009.safetensors",
254
+ "model.layers.33.mlp.gate_proj.weight": "model-00004-of-00009.safetensors",
255
+ "model.layers.33.mlp.up_proj.weight": "model-00004-of-00009.safetensors",
256
+ "model.layers.33.post_attention_layernorm.weight": "model-00004-of-00009.safetensors",
257
+ "model.layers.33.self_attn.k_proj.weight": "model-00004-of-00009.safetensors",
258
+ "model.layers.33.self_attn.o_proj.weight": "model-00004-of-00009.safetensors",
259
+ "model.layers.33.self_attn.q_proj.weight": "model-00004-of-00009.safetensors",
260
+ "model.layers.33.self_attn.v_proj.weight": "model-00004-of-00009.safetensors",
261
+ "model.layers.34.input_layernorm.weight": "model-00004-of-00009.safetensors",
262
+ "model.layers.34.mlp.down_proj.weight": "model-00004-of-00009.safetensors",
263
+ "model.layers.34.mlp.gate_proj.weight": "model-00004-of-00009.safetensors",
264
+ "model.layers.34.mlp.up_proj.weight": "model-00004-of-00009.safetensors",
265
+ "model.layers.34.post_attention_layernorm.weight": "model-00004-of-00009.safetensors",
266
+ "model.layers.34.self_attn.k_proj.weight": "model-00004-of-00009.safetensors",
267
+ "model.layers.34.self_attn.o_proj.weight": "model-00004-of-00009.safetensors",
268
+ "model.layers.34.self_attn.q_proj.weight": "model-00004-of-00009.safetensors",
269
+ "model.layers.34.self_attn.v_proj.weight": "model-00004-of-00009.safetensors",
270
+ "model.layers.35.input_layernorm.weight": "model-00004-of-00009.safetensors",
271
+ "model.layers.35.mlp.down_proj.weight": "model-00004-of-00009.safetensors",
272
+ "model.layers.35.mlp.gate_proj.weight": "model-00004-of-00009.safetensors",
273
+ "model.layers.35.mlp.up_proj.weight": "model-00004-of-00009.safetensors",
274
+ "model.layers.35.post_attention_layernorm.weight": "model-00004-of-00009.safetensors",
275
+ "model.layers.35.self_attn.k_proj.weight": "model-00004-of-00009.safetensors",
276
+ "model.layers.35.self_attn.o_proj.weight": "model-00004-of-00009.safetensors",
277
+ "model.layers.35.self_attn.q_proj.weight": "model-00004-of-00009.safetensors",
278
+ "model.layers.35.self_attn.v_proj.weight": "model-00004-of-00009.safetensors",
279
+ "model.layers.36.input_layernorm.weight": "model-00004-of-00009.safetensors",
280
+ "model.layers.36.mlp.down_proj.weight": "model-00004-of-00009.safetensors",
281
+ "model.layers.36.mlp.gate_proj.weight": "model-00004-of-00009.safetensors",
282
+ "model.layers.36.mlp.up_proj.weight": "model-00004-of-00009.safetensors",
283
+ "model.layers.36.post_attention_layernorm.weight": "model-00004-of-00009.safetensors",
284
+ "model.layers.36.self_attn.k_proj.weight": "model-00004-of-00009.safetensors",
285
+ "model.layers.36.self_attn.o_proj.weight": "model-00004-of-00009.safetensors",
286
+ "model.layers.36.self_attn.q_proj.weight": "model-00004-of-00009.safetensors",
287
+ "model.layers.36.self_attn.v_proj.weight": "model-00004-of-00009.safetensors",
288
+ "model.layers.37.input_layernorm.weight": "model-00004-of-00009.safetensors",
289
+ "model.layers.37.mlp.down_proj.weight": "model-00004-of-00009.safetensors",
290
+ "model.layers.37.mlp.gate_proj.weight": "model-00004-of-00009.safetensors",
291
+ "model.layers.37.mlp.up_proj.weight": "model-00004-of-00009.safetensors",
292
+ "model.layers.37.post_attention_layernorm.weight": "model-00004-of-00009.safetensors",
293
+ "model.layers.37.self_attn.k_proj.weight": "model-00004-of-00009.safetensors",
294
+ "model.layers.37.self_attn.o_proj.weight": "model-00004-of-00009.safetensors",
295
+ "model.layers.37.self_attn.q_proj.weight": "model-00004-of-00009.safetensors",
296
+ "model.layers.37.self_attn.v_proj.weight": "model-00004-of-00009.safetensors",
297
+ "model.layers.38.input_layernorm.weight": "model-00004-of-00009.safetensors",
298
+ "model.layers.38.mlp.down_proj.weight": "model-00004-of-00009.safetensors",
299
+ "model.layers.38.mlp.gate_proj.weight": "model-00004-of-00009.safetensors",
300
+ "model.layers.38.mlp.up_proj.weight": "model-00005-of-00009.safetensors",
301
+ "model.layers.38.post_attention_layernorm.weight": "model-00005-of-00009.safetensors",
302
+ "model.layers.38.self_attn.k_proj.weight": "model-00005-of-00009.safetensors",
303
+ "model.layers.38.self_attn.o_proj.weight": "model-00005-of-00009.safetensors",
304
+ "model.layers.38.self_attn.q_proj.weight": "model-00005-of-00009.safetensors",
305
+ "model.layers.38.self_attn.v_proj.weight": "model-00005-of-00009.safetensors",
306
+ "model.layers.39.input_layernorm.weight": "model-00005-of-00009.safetensors",
307
+ "model.layers.39.mlp.down_proj.weight": "model-00005-of-00009.safetensors",
308
+ "model.layers.39.mlp.gate_proj.weight": "model-00005-of-00009.safetensors",
309
+ "model.layers.39.mlp.up_proj.weight": "model-00005-of-00009.safetensors",
310
+ "model.layers.39.post_attention_layernorm.weight": "model-00005-of-00009.safetensors",
311
+ "model.layers.39.self_attn.k_proj.weight": "model-00005-of-00009.safetensors",
312
+ "model.layers.39.self_attn.o_proj.weight": "model-00005-of-00009.safetensors",
313
+ "model.layers.39.self_attn.q_proj.weight": "model-00005-of-00009.safetensors",
314
+ "model.layers.39.self_attn.v_proj.weight": "model-00005-of-00009.safetensors",
315
+ "model.layers.4.input_layernorm.weight": "model-00001-of-00009.safetensors",
316
+ "model.layers.4.mlp.down_proj.weight": "model-00001-of-00009.safetensors",
317
+ "model.layers.4.mlp.gate_proj.weight": "model-00001-of-00009.safetensors",
318
+ "model.layers.4.mlp.up_proj.weight": "model-00001-of-00009.safetensors",
319
+ "model.layers.4.post_attention_layernorm.weight": "model-00001-of-00009.safetensors",
320
+ "model.layers.4.self_attn.k_proj.weight": "model-00001-of-00009.safetensors",
321
+ "model.layers.4.self_attn.o_proj.weight": "model-00001-of-00009.safetensors",
322
+ "model.layers.4.self_attn.q_proj.weight": "model-00001-of-00009.safetensors",
323
+ "model.layers.4.self_attn.v_proj.weight": "model-00001-of-00009.safetensors",
324
+ "model.layers.40.input_layernorm.weight": "model-00005-of-00009.safetensors",
325
+ "model.layers.40.mlp.down_proj.weight": "model-00005-of-00009.safetensors",
326
+ "model.layers.40.mlp.gate_proj.weight": "model-00005-of-00009.safetensors",
327
+ "model.layers.40.mlp.up_proj.weight": "model-00005-of-00009.safetensors",
328
+ "model.layers.40.post_attention_layernorm.weight": "model-00005-of-00009.safetensors",
329
+ "model.layers.40.self_attn.k_proj.weight": "model-00005-of-00009.safetensors",
330
+ "model.layers.40.self_attn.o_proj.weight": "model-00005-of-00009.safetensors",
331
+ "model.layers.40.self_attn.q_proj.weight": "model-00005-of-00009.safetensors",
332
+ "model.layers.40.self_attn.v_proj.weight": "model-00005-of-00009.safetensors",
333
+ "model.layers.41.input_layernorm.weight": "model-00005-of-00009.safetensors",
334
+ "model.layers.41.mlp.down_proj.weight": "model-00005-of-00009.safetensors",
335
+ "model.layers.41.mlp.gate_proj.weight": "model-00005-of-00009.safetensors",
336
+ "model.layers.41.mlp.up_proj.weight": "model-00005-of-00009.safetensors",
337
+ "model.layers.41.post_attention_layernorm.weight": "model-00005-of-00009.safetensors",
338
+ "model.layers.41.self_attn.k_proj.weight": "model-00005-of-00009.safetensors",
339
+ "model.layers.41.self_attn.o_proj.weight": "model-00005-of-00009.safetensors",
340
+ "model.layers.41.self_attn.q_proj.weight": "model-00005-of-00009.safetensors",
341
+ "model.layers.41.self_attn.v_proj.weight": "model-00005-of-00009.safetensors",
342
+ "model.layers.42.input_layernorm.weight": "model-00005-of-00009.safetensors",
343
+ "model.layers.42.mlp.down_proj.weight": "model-00005-of-00009.safetensors",
344
+ "model.layers.42.mlp.gate_proj.weight": "model-00005-of-00009.safetensors",
345
+ "model.layers.42.mlp.up_proj.weight": "model-00005-of-00009.safetensors",
346
+ "model.layers.42.post_attention_layernorm.weight": "model-00005-of-00009.safetensors",
347
+ "model.layers.42.self_attn.k_proj.weight": "model-00005-of-00009.safetensors",
348
+ "model.layers.42.self_attn.o_proj.weight": "model-00005-of-00009.safetensors",
349
+ "model.layers.42.self_attn.q_proj.weight": "model-00005-of-00009.safetensors",
350
+ "model.layers.42.self_attn.v_proj.weight": "model-00005-of-00009.safetensors",
351
+ "model.layers.43.input_layernorm.weight": "model-00005-of-00009.safetensors",
352
+ "model.layers.43.mlp.down_proj.weight": "model-00005-of-00009.safetensors",
353
+ "model.layers.43.mlp.gate_proj.weight": "model-00005-of-00009.safetensors",
354
+ "model.layers.43.mlp.up_proj.weight": "model-00005-of-00009.safetensors",
355
+ "model.layers.43.post_attention_layernorm.weight": "model-00005-of-00009.safetensors",
356
+ "model.layers.43.self_attn.k_proj.weight": "model-00005-of-00009.safetensors",
357
+ "model.layers.43.self_attn.o_proj.weight": "model-00005-of-00009.safetensors",
358
+ "model.layers.43.self_attn.q_proj.weight": "model-00005-of-00009.safetensors",
359
+ "model.layers.43.self_attn.v_proj.weight": "model-00005-of-00009.safetensors",
360
+ "model.layers.44.input_layernorm.weight": "model-00005-of-00009.safetensors",
361
+ "model.layers.44.mlp.down_proj.weight": "model-00005-of-00009.safetensors",
362
+ "model.layers.44.mlp.gate_proj.weight": "model-00005-of-00009.safetensors",
363
+ "model.layers.44.mlp.up_proj.weight": "model-00005-of-00009.safetensors",
364
+ "model.layers.44.post_attention_layernorm.weight": "model-00005-of-00009.safetensors",
365
+ "model.layers.44.self_attn.k_proj.weight": "model-00005-of-00009.safetensors",
366
+ "model.layers.44.self_attn.o_proj.weight": "model-00005-of-00009.safetensors",
367
+ "model.layers.44.self_attn.q_proj.weight": "model-00005-of-00009.safetensors",
368
+ "model.layers.44.self_attn.v_proj.weight": "model-00005-of-00009.safetensors",
369
+ "model.layers.45.input_layernorm.weight": "model-00005-of-00009.safetensors",
370
+ "model.layers.45.mlp.down_proj.weight": "model-00005-of-00009.safetensors",
371
+ "model.layers.45.mlp.gate_proj.weight": "model-00005-of-00009.safetensors",
372
+ "model.layers.45.mlp.up_proj.weight": "model-00005-of-00009.safetensors",
373
+ "model.layers.45.post_attention_layernorm.weight": "model-00005-of-00009.safetensors",
374
+ "model.layers.45.self_attn.k_proj.weight": "model-00005-of-00009.safetensors",
375
+ "model.layers.45.self_attn.o_proj.weight": "model-00005-of-00009.safetensors",
376
+ "model.layers.45.self_attn.q_proj.weight": "model-00005-of-00009.safetensors",
377
+ "model.layers.45.self_attn.v_proj.weight": "model-00005-of-00009.safetensors",
378
+ "model.layers.46.input_layernorm.weight": "model-00005-of-00009.safetensors",
379
+ "model.layers.46.mlp.down_proj.weight": "model-00005-of-00009.safetensors",
380
+ "model.layers.46.mlp.gate_proj.weight": "model-00005-of-00009.safetensors",
381
+ "model.layers.46.mlp.up_proj.weight": "model-00005-of-00009.safetensors",
382
+ "model.layers.46.post_attention_layernorm.weight": "model-00005-of-00009.safetensors",
383
+ "model.layers.46.self_attn.k_proj.weight": "model-00005-of-00009.safetensors",
384
+ "model.layers.46.self_attn.o_proj.weight": "model-00005-of-00009.safetensors",
385
+ "model.layers.46.self_attn.q_proj.weight": "model-00005-of-00009.safetensors",
386
+ "model.layers.46.self_attn.v_proj.weight": "model-00005-of-00009.safetensors",
387
+ "model.layers.47.input_layernorm.weight": "model-00005-of-00009.safetensors",
388
+ "model.layers.47.mlp.down_proj.weight": "model-00005-of-00009.safetensors",
389
+ "model.layers.47.mlp.gate_proj.weight": "model-00005-of-00009.safetensors",
390
+ "model.layers.47.mlp.up_proj.weight": "model-00005-of-00009.safetensors",
391
+ "model.layers.47.post_attention_layernorm.weight": "model-00005-of-00009.safetensors",
392
+ "model.layers.47.self_attn.k_proj.weight": "model-00005-of-00009.safetensors",
393
+ "model.layers.47.self_attn.o_proj.weight": "model-00005-of-00009.safetensors",
394
+ "model.layers.47.self_attn.q_proj.weight": "model-00005-of-00009.safetensors",
395
+ "model.layers.47.self_attn.v_proj.weight": "model-00005-of-00009.safetensors",
396
+ "model.layers.48.input_layernorm.weight": "model-00005-of-00009.safetensors",
397
+ "model.layers.48.mlp.down_proj.weight": "model-00005-of-00009.safetensors",
398
+ "model.layers.48.mlp.gate_proj.weight": "model-00005-of-00009.safetensors",
399
+ "model.layers.48.mlp.up_proj.weight": "model-00006-of-00009.safetensors",
400
+ "model.layers.48.post_attention_layernorm.weight": "model-00006-of-00009.safetensors",
401
+ "model.layers.48.self_attn.k_proj.weight": "model-00006-of-00009.safetensors",
402
+ "model.layers.48.self_attn.o_proj.weight": "model-00006-of-00009.safetensors",
403
+ "model.layers.48.self_attn.q_proj.weight": "model-00006-of-00009.safetensors",
404
+ "model.layers.48.self_attn.v_proj.weight": "model-00006-of-00009.safetensors",
405
+ "model.layers.49.input_layernorm.weight": "model-00006-of-00009.safetensors",
406
+ "model.layers.49.mlp.down_proj.weight": "model-00006-of-00009.safetensors",
407
+ "model.layers.49.mlp.gate_proj.weight": "model-00006-of-00009.safetensors",
408
+ "model.layers.49.mlp.up_proj.weight": "model-00006-of-00009.safetensors",
409
+ "model.layers.49.post_attention_layernorm.weight": "model-00006-of-00009.safetensors",
410
+ "model.layers.49.self_attn.k_proj.weight": "model-00006-of-00009.safetensors",
411
+ "model.layers.49.self_attn.o_proj.weight": "model-00006-of-00009.safetensors",
412
+ "model.layers.49.self_attn.q_proj.weight": "model-00006-of-00009.safetensors",
413
+ "model.layers.49.self_attn.v_proj.weight": "model-00006-of-00009.safetensors",
414
+ "model.layers.5.input_layernorm.weight": "model-00001-of-00009.safetensors",
415
+ "model.layers.5.mlp.down_proj.weight": "model-00001-of-00009.safetensors",
416
+ "model.layers.5.mlp.gate_proj.weight": "model-00001-of-00009.safetensors",
417
+ "model.layers.5.mlp.up_proj.weight": "model-00001-of-00009.safetensors",
418
+ "model.layers.5.post_attention_layernorm.weight": "model-00001-of-00009.safetensors",
419
+ "model.layers.5.self_attn.k_proj.weight": "model-00001-of-00009.safetensors",
420
+ "model.layers.5.self_attn.o_proj.weight": "model-00001-of-00009.safetensors",
421
+ "model.layers.5.self_attn.q_proj.weight": "model-00001-of-00009.safetensors",
422
+ "model.layers.5.self_attn.v_proj.weight": "model-00001-of-00009.safetensors",
423
+ "model.layers.50.input_layernorm.weight": "model-00006-of-00009.safetensors",
424
+ "model.layers.50.mlp.down_proj.weight": "model-00006-of-00009.safetensors",
425
+ "model.layers.50.mlp.gate_proj.weight": "model-00006-of-00009.safetensors",
426
+ "model.layers.50.mlp.up_proj.weight": "model-00006-of-00009.safetensors",
427
+ "model.layers.50.post_attention_layernorm.weight": "model-00006-of-00009.safetensors",
428
+ "model.layers.50.self_attn.k_proj.weight": "model-00006-of-00009.safetensors",
429
+ "model.layers.50.self_attn.o_proj.weight": "model-00006-of-00009.safetensors",
430
+ "model.layers.50.self_attn.q_proj.weight": "model-00006-of-00009.safetensors",
431
+ "model.layers.50.self_attn.v_proj.weight": "model-00006-of-00009.safetensors",
432
+ "model.layers.51.input_layernorm.weight": "model-00006-of-00009.safetensors",
433
+ "model.layers.51.mlp.down_proj.weight": "model-00006-of-00009.safetensors",
434
+ "model.layers.51.mlp.gate_proj.weight": "model-00006-of-00009.safetensors",
435
+ "model.layers.51.mlp.up_proj.weight": "model-00006-of-00009.safetensors",
436
+ "model.layers.51.post_attention_layernorm.weight": "model-00006-of-00009.safetensors",
437
+ "model.layers.51.self_attn.k_proj.weight": "model-00006-of-00009.safetensors",
438
+ "model.layers.51.self_attn.o_proj.weight": "model-00006-of-00009.safetensors",
439
+ "model.layers.51.self_attn.q_proj.weight": "model-00006-of-00009.safetensors",
440
+ "model.layers.51.self_attn.v_proj.weight": "model-00006-of-00009.safetensors",
441
+ "model.layers.52.input_layernorm.weight": "model-00006-of-00009.safetensors",
442
+ "model.layers.52.mlp.down_proj.weight": "model-00006-of-00009.safetensors",
443
+ "model.layers.52.mlp.gate_proj.weight": "model-00006-of-00009.safetensors",
444
+ "model.layers.52.mlp.up_proj.weight": "model-00006-of-00009.safetensors",
445
+ "model.layers.52.post_attention_layernorm.weight": "model-00006-of-00009.safetensors",
446
+ "model.layers.52.self_attn.k_proj.weight": "model-00006-of-00009.safetensors",
447
+ "model.layers.52.self_attn.o_proj.weight": "model-00006-of-00009.safetensors",
448
+ "model.layers.52.self_attn.q_proj.weight": "model-00006-of-00009.safetensors",
449
+ "model.layers.52.self_attn.v_proj.weight": "model-00006-of-00009.safetensors",
450
+ "model.layers.53.input_layernorm.weight": "model-00006-of-00009.safetensors",
451
+ "model.layers.53.mlp.down_proj.weight": "model-00006-of-00009.safetensors",
452
+ "model.layers.53.mlp.gate_proj.weight": "model-00006-of-00009.safetensors",
453
+ "model.layers.53.mlp.up_proj.weight": "model-00006-of-00009.safetensors",
454
+ "model.layers.53.post_attention_layernorm.weight": "model-00006-of-00009.safetensors",
455
+ "model.layers.53.self_attn.k_proj.weight": "model-00006-of-00009.safetensors",
456
+ "model.layers.53.self_attn.o_proj.weight": "model-00006-of-00009.safetensors",
457
+ "model.layers.53.self_attn.q_proj.weight": "model-00006-of-00009.safetensors",
458
+ "model.layers.53.self_attn.v_proj.weight": "model-00006-of-00009.safetensors",
459
+ "model.layers.54.input_layernorm.weight": "model-00006-of-00009.safetensors",
460
+ "model.layers.54.mlp.down_proj.weight": "model-00006-of-00009.safetensors",
461
+ "model.layers.54.mlp.gate_proj.weight": "model-00006-of-00009.safetensors",
462
+ "model.layers.54.mlp.up_proj.weight": "model-00006-of-00009.safetensors",
463
+ "model.layers.54.post_attention_layernorm.weight": "model-00006-of-00009.safetensors",
464
+ "model.layers.54.self_attn.k_proj.weight": "model-00006-of-00009.safetensors",
465
+ "model.layers.54.self_attn.o_proj.weight": "model-00006-of-00009.safetensors",
466
+ "model.layers.54.self_attn.q_proj.weight": "model-00006-of-00009.safetensors",
467
+ "model.layers.54.self_attn.v_proj.weight": "model-00006-of-00009.safetensors",
468
+ "model.layers.55.input_layernorm.weight": "model-00006-of-00009.safetensors",
469
+ "model.layers.55.mlp.down_proj.weight": "model-00006-of-00009.safetensors",
470
+ "model.layers.55.mlp.gate_proj.weight": "model-00006-of-00009.safetensors",
471
+ "model.layers.55.mlp.up_proj.weight": "model-00006-of-00009.safetensors",
472
+ "model.layers.55.post_attention_layernorm.weight": "model-00006-of-00009.safetensors",
473
+ "model.layers.55.self_attn.k_proj.weight": "model-00006-of-00009.safetensors",
474
+ "model.layers.55.self_attn.o_proj.weight": "model-00006-of-00009.safetensors",
475
+ "model.layers.55.self_attn.q_proj.weight": "model-00006-of-00009.safetensors",
476
+ "model.layers.55.self_attn.v_proj.weight": "model-00006-of-00009.safetensors",
477
+ "model.layers.56.input_layernorm.weight": "model-00006-of-00009.safetensors",
478
+ "model.layers.56.mlp.down_proj.weight": "model-00006-of-00009.safetensors",
479
+ "model.layers.56.mlp.gate_proj.weight": "model-00006-of-00009.safetensors",
480
+ "model.layers.56.mlp.up_proj.weight": "model-00006-of-00009.safetensors",
481
+ "model.layers.56.post_attention_layernorm.weight": "model-00006-of-00009.safetensors",
482
+ "model.layers.56.self_attn.k_proj.weight": "model-00006-of-00009.safetensors",
483
+ "model.layers.56.self_attn.o_proj.weight": "model-00006-of-00009.safetensors",
484
+ "model.layers.56.self_attn.q_proj.weight": "model-00006-of-00009.safetensors",
485
+ "model.layers.56.self_attn.v_proj.weight": "model-00006-of-00009.safetensors",
486
+ "model.layers.57.input_layernorm.weight": "model-00006-of-00009.safetensors",
487
+ "model.layers.57.mlp.down_proj.weight": "model-00006-of-00009.safetensors",
488
+ "model.layers.57.mlp.gate_proj.weight": "model-00006-of-00009.safetensors",
489
+ "model.layers.57.mlp.up_proj.weight": "model-00006-of-00009.safetensors",
490
+ "model.layers.57.post_attention_layernorm.weight": "model-00006-of-00009.safetensors",
491
+ "model.layers.57.self_attn.k_proj.weight": "model-00006-of-00009.safetensors",
492
+ "model.layers.57.self_attn.o_proj.weight": "model-00006-of-00009.safetensors",
493
+ "model.layers.57.self_attn.q_proj.weight": "model-00006-of-00009.safetensors",
494
+ "model.layers.57.self_attn.v_proj.weight": "model-00006-of-00009.safetensors",
495
+ "model.layers.58.input_layernorm.weight": "model-00006-of-00009.safetensors",
496
+ "model.layers.58.mlp.down_proj.weight": "model-00006-of-00009.safetensors",
497
+ "model.layers.58.mlp.gate_proj.weight": "model-00006-of-00009.safetensors",
498
+ "model.layers.58.mlp.up_proj.weight": "model-00007-of-00009.safetensors",
499
+ "model.layers.58.post_attention_layernorm.weight": "model-00007-of-00009.safetensors",
500
+ "model.layers.58.self_attn.k_proj.weight": "model-00007-of-00009.safetensors",
501
+ "model.layers.58.self_attn.o_proj.weight": "model-00007-of-00009.safetensors",
502
+ "model.layers.58.self_attn.q_proj.weight": "model-00007-of-00009.safetensors",
503
+ "model.layers.58.self_attn.v_proj.weight": "model-00007-of-00009.safetensors",
504
+ "model.layers.59.input_layernorm.weight": "model-00007-of-00009.safetensors",
505
+ "model.layers.59.mlp.down_proj.weight": "model-00007-of-00009.safetensors",
506
+ "model.layers.59.mlp.gate_proj.weight": "model-00007-of-00009.safetensors",
507
+ "model.layers.59.mlp.up_proj.weight": "model-00007-of-00009.safetensors",
508
+ "model.layers.59.post_attention_layernorm.weight": "model-00007-of-00009.safetensors",
509
+ "model.layers.59.self_attn.k_proj.weight": "model-00007-of-00009.safetensors",
510
+ "model.layers.59.self_attn.o_proj.weight": "model-00007-of-00009.safetensors",
511
+ "model.layers.59.self_attn.q_proj.weight": "model-00007-of-00009.safetensors",
512
+ "model.layers.59.self_attn.v_proj.weight": "model-00007-of-00009.safetensors",
513
+ "model.layers.6.input_layernorm.weight": "model-00001-of-00009.safetensors",
514
+ "model.layers.6.mlp.down_proj.weight": "model-00001-of-00009.safetensors",
515
+ "model.layers.6.mlp.gate_proj.weight": "model-00001-of-00009.safetensors",
516
+ "model.layers.6.mlp.up_proj.weight": "model-00001-of-00009.safetensors",
517
+ "model.layers.6.post_attention_layernorm.weight": "model-00001-of-00009.safetensors",
518
+ "model.layers.6.self_attn.k_proj.weight": "model-00001-of-00009.safetensors",
519
+ "model.layers.6.self_attn.o_proj.weight": "model-00001-of-00009.safetensors",
520
+ "model.layers.6.self_attn.q_proj.weight": "model-00001-of-00009.safetensors",
521
+ "model.layers.6.self_attn.v_proj.weight": "model-00001-of-00009.safetensors",
522
+ "model.layers.60.input_layernorm.weight": "model-00007-of-00009.safetensors",
523
+ "model.layers.60.mlp.down_proj.weight": "model-00007-of-00009.safetensors",
524
+ "model.layers.60.mlp.gate_proj.weight": "model-00007-of-00009.safetensors",
525
+ "model.layers.60.mlp.up_proj.weight": "model-00007-of-00009.safetensors",
526
+ "model.layers.60.post_attention_layernorm.weight": "model-00007-of-00009.safetensors",
527
+ "model.layers.60.self_attn.k_proj.weight": "model-00007-of-00009.safetensors",
528
+ "model.layers.60.self_attn.o_proj.weight": "model-00007-of-00009.safetensors",
529
+ "model.layers.60.self_attn.q_proj.weight": "model-00007-of-00009.safetensors",
530
+ "model.layers.60.self_attn.v_proj.weight": "model-00007-of-00009.safetensors",
531
+ "model.layers.61.input_layernorm.weight": "model-00007-of-00009.safetensors",
532
+ "model.layers.61.mlp.down_proj.weight": "model-00007-of-00009.safetensors",
533
+ "model.layers.61.mlp.gate_proj.weight": "model-00007-of-00009.safetensors",
534
+ "model.layers.61.mlp.up_proj.weight": "model-00007-of-00009.safetensors",
535
+ "model.layers.61.post_attention_layernorm.weight": "model-00007-of-00009.safetensors",
536
+ "model.layers.61.self_attn.k_proj.weight": "model-00007-of-00009.safetensors",
537
+ "model.layers.61.self_attn.o_proj.weight": "model-00007-of-00009.safetensors",
538
+ "model.layers.61.self_attn.q_proj.weight": "model-00007-of-00009.safetensors",
539
+ "model.layers.61.self_attn.v_proj.weight": "model-00007-of-00009.safetensors",
540
+ "model.layers.62.input_layernorm.weight": "model-00007-of-00009.safetensors",
541
+ "model.layers.62.mlp.down_proj.weight": "model-00007-of-00009.safetensors",
542
+ "model.layers.62.mlp.gate_proj.weight": "model-00007-of-00009.safetensors",
543
+ "model.layers.62.mlp.up_proj.weight": "model-00007-of-00009.safetensors",
544
+ "model.layers.62.post_attention_layernorm.weight": "model-00007-of-00009.safetensors",
545
+ "model.layers.62.self_attn.k_proj.weight": "model-00007-of-00009.safetensors",
546
+ "model.layers.62.self_attn.o_proj.weight": "model-00007-of-00009.safetensors",
547
+ "model.layers.62.self_attn.q_proj.weight": "model-00007-of-00009.safetensors",
548
+ "model.layers.62.self_attn.v_proj.weight": "model-00007-of-00009.safetensors",
549
+ "model.layers.63.input_layernorm.weight": "model-00007-of-00009.safetensors",
550
+ "model.layers.63.mlp.down_proj.weight": "model-00007-of-00009.safetensors",
551
+ "model.layers.63.mlp.gate_proj.weight": "model-00007-of-00009.safetensors",
552
+ "model.layers.63.mlp.up_proj.weight": "model-00007-of-00009.safetensors",
553
+ "model.layers.63.post_attention_layernorm.weight": "model-00007-of-00009.safetensors",
554
+ "model.layers.63.self_attn.k_proj.weight": "model-00007-of-00009.safetensors",
555
+ "model.layers.63.self_attn.o_proj.weight": "model-00007-of-00009.safetensors",
556
+ "model.layers.63.self_attn.q_proj.weight": "model-00007-of-00009.safetensors",
557
+ "model.layers.63.self_attn.v_proj.weight": "model-00007-of-00009.safetensors",
558
+ "model.layers.64.input_layernorm.weight": "model-00007-of-00009.safetensors",
559
+ "model.layers.64.mlp.down_proj.weight": "model-00007-of-00009.safetensors",
560
+ "model.layers.64.mlp.gate_proj.weight": "model-00007-of-00009.safetensors",
561
+ "model.layers.64.mlp.up_proj.weight": "model-00007-of-00009.safetensors",
562
+ "model.layers.64.post_attention_layernorm.weight": "model-00007-of-00009.safetensors",
563
+ "model.layers.64.self_attn.k_proj.weight": "model-00007-of-00009.safetensors",
564
+ "model.layers.64.self_attn.o_proj.weight": "model-00007-of-00009.safetensors",
565
+ "model.layers.64.self_attn.q_proj.weight": "model-00007-of-00009.safetensors",
566
+ "model.layers.64.self_attn.v_proj.weight": "model-00007-of-00009.safetensors",
567
+ "model.layers.65.input_layernorm.weight": "model-00007-of-00009.safetensors",
568
+ "model.layers.65.mlp.down_proj.weight": "model-00007-of-00009.safetensors",
569
+ "model.layers.65.mlp.gate_proj.weight": "model-00007-of-00009.safetensors",
570
+ "model.layers.65.mlp.up_proj.weight": "model-00007-of-00009.safetensors",
571
+ "model.layers.65.post_attention_layernorm.weight": "model-00007-of-00009.safetensors",
572
+ "model.layers.65.self_attn.k_proj.weight": "model-00007-of-00009.safetensors",
573
+ "model.layers.65.self_attn.o_proj.weight": "model-00007-of-00009.safetensors",
574
+ "model.layers.65.self_attn.q_proj.weight": "model-00007-of-00009.safetensors",
575
+ "model.layers.65.self_attn.v_proj.weight": "model-00007-of-00009.safetensors",
576
+ "model.layers.66.input_layernorm.weight": "model-00007-of-00009.safetensors",
577
+ "model.layers.66.mlp.down_proj.weight": "model-00007-of-00009.safetensors",
578
+ "model.layers.66.mlp.gate_proj.weight": "model-00007-of-00009.safetensors",
579
+ "model.layers.66.mlp.up_proj.weight": "model-00007-of-00009.safetensors",
580
+ "model.layers.66.post_attention_layernorm.weight": "model-00007-of-00009.safetensors",
581
+ "model.layers.66.self_attn.k_proj.weight": "model-00007-of-00009.safetensors",
582
+ "model.layers.66.self_attn.o_proj.weight": "model-00007-of-00009.safetensors",
583
+ "model.layers.66.self_attn.q_proj.weight": "model-00007-of-00009.safetensors",
584
+ "model.layers.66.self_attn.v_proj.weight": "model-00007-of-00009.safetensors",
585
+ "model.layers.67.input_layernorm.weight": "model-00007-of-00009.safetensors",
586
+ "model.layers.67.mlp.down_proj.weight": "model-00007-of-00009.safetensors",
587
+ "model.layers.67.mlp.gate_proj.weight": "model-00007-of-00009.safetensors",
588
+ "model.layers.67.mlp.up_proj.weight": "model-00007-of-00009.safetensors",
589
+ "model.layers.67.post_attention_layernorm.weight": "model-00007-of-00009.safetensors",
590
+ "model.layers.67.self_attn.k_proj.weight": "model-00007-of-00009.safetensors",
591
+ "model.layers.67.self_attn.o_proj.weight": "model-00007-of-00009.safetensors",
592
+ "model.layers.67.self_attn.q_proj.weight": "model-00007-of-00009.safetensors",
593
+ "model.layers.67.self_attn.v_proj.weight": "model-00007-of-00009.safetensors",
594
+ "model.layers.68.input_layernorm.weight": "model-00007-of-00009.safetensors",
595
+ "model.layers.68.mlp.down_proj.weight": "model-00007-of-00009.safetensors",
596
+ "model.layers.68.mlp.gate_proj.weight": "model-00007-of-00009.safetensors",
597
+ "model.layers.68.mlp.up_proj.weight": "model-00008-of-00009.safetensors",
598
+ "model.layers.68.post_attention_layernorm.weight": "model-00008-of-00009.safetensors",
599
+ "model.layers.68.self_attn.k_proj.weight": "model-00008-of-00009.safetensors",
600
+ "model.layers.68.self_attn.o_proj.weight": "model-00008-of-00009.safetensors",
601
+ "model.layers.68.self_attn.q_proj.weight": "model-00008-of-00009.safetensors",
602
+ "model.layers.68.self_attn.v_proj.weight": "model-00008-of-00009.safetensors",
603
+ "model.layers.69.input_layernorm.weight": "model-00008-of-00009.safetensors",
604
+ "model.layers.69.mlp.down_proj.weight": "model-00008-of-00009.safetensors",
605
+ "model.layers.69.mlp.gate_proj.weight": "model-00008-of-00009.safetensors",
606
+ "model.layers.69.mlp.up_proj.weight": "model-00008-of-00009.safetensors",
607
+ "model.layers.69.post_attention_layernorm.weight": "model-00008-of-00009.safetensors",
608
+ "model.layers.69.self_attn.k_proj.weight": "model-00008-of-00009.safetensors",
609
+ "model.layers.69.self_attn.o_proj.weight": "model-00008-of-00009.safetensors",
610
+ "model.layers.69.self_attn.q_proj.weight": "model-00008-of-00009.safetensors",
611
+ "model.layers.69.self_attn.v_proj.weight": "model-00008-of-00009.safetensors",
612
+ "model.layers.7.input_layernorm.weight": "model-00001-of-00009.safetensors",
613
+ "model.layers.7.mlp.down_proj.weight": "model-00001-of-00009.safetensors",
614
+ "model.layers.7.mlp.gate_proj.weight": "model-00001-of-00009.safetensors",
615
+ "model.layers.7.mlp.up_proj.weight": "model-00001-of-00009.safetensors",
616
+ "model.layers.7.post_attention_layernorm.weight": "model-00001-of-00009.safetensors",
617
+ "model.layers.7.self_attn.k_proj.weight": "model-00001-of-00009.safetensors",
618
+ "model.layers.7.self_attn.o_proj.weight": "model-00001-of-00009.safetensors",
619
+ "model.layers.7.self_attn.q_proj.weight": "model-00001-of-00009.safetensors",
620
+ "model.layers.7.self_attn.v_proj.weight": "model-00001-of-00009.safetensors",
621
+ "model.layers.70.input_layernorm.weight": "model-00008-of-00009.safetensors",
622
+ "model.layers.70.mlp.down_proj.weight": "model-00008-of-00009.safetensors",
623
+ "model.layers.70.mlp.gate_proj.weight": "model-00008-of-00009.safetensors",
624
+ "model.layers.70.mlp.up_proj.weight": "model-00008-of-00009.safetensors",
625
+ "model.layers.70.post_attention_layernorm.weight": "model-00008-of-00009.safetensors",
626
+ "model.layers.70.self_attn.k_proj.weight": "model-00008-of-00009.safetensors",
627
+ "model.layers.70.self_attn.o_proj.weight": "model-00008-of-00009.safetensors",
628
+ "model.layers.70.self_attn.q_proj.weight": "model-00008-of-00009.safetensors",
629
+ "model.layers.70.self_attn.v_proj.weight": "model-00008-of-00009.safetensors",
630
+ "model.layers.71.input_layernorm.weight": "model-00008-of-00009.safetensors",
631
+ "model.layers.71.mlp.down_proj.weight": "model-00008-of-00009.safetensors",
632
+ "model.layers.71.mlp.gate_proj.weight": "model-00008-of-00009.safetensors",
633
+ "model.layers.71.mlp.up_proj.weight": "model-00008-of-00009.safetensors",
634
+ "model.layers.71.post_attention_layernorm.weight": "model-00008-of-00009.safetensors",
635
+ "model.layers.71.self_attn.k_proj.weight": "model-00008-of-00009.safetensors",
636
+ "model.layers.71.self_attn.o_proj.weight": "model-00008-of-00009.safetensors",
637
+ "model.layers.71.self_attn.q_proj.weight": "model-00008-of-00009.safetensors",
638
+ "model.layers.71.self_attn.v_proj.weight": "model-00008-of-00009.safetensors",
639
+ "model.layers.72.input_layernorm.weight": "model-00008-of-00009.safetensors",
640
+ "model.layers.72.mlp.down_proj.weight": "model-00008-of-00009.safetensors",
641
+ "model.layers.72.mlp.gate_proj.weight": "model-00008-of-00009.safetensors",
642
+ "model.layers.72.mlp.up_proj.weight": "model-00008-of-00009.safetensors",
643
+ "model.layers.72.post_attention_layernorm.weight": "model-00008-of-00009.safetensors",
644
+ "model.layers.72.self_attn.k_proj.weight": "model-00008-of-00009.safetensors",
645
+ "model.layers.72.self_attn.o_proj.weight": "model-00008-of-00009.safetensors",
646
+ "model.layers.72.self_attn.q_proj.weight": "model-00008-of-00009.safetensors",
647
+ "model.layers.72.self_attn.v_proj.weight": "model-00008-of-00009.safetensors",
648
+ "model.layers.73.input_layernorm.weight": "model-00008-of-00009.safetensors",
649
+ "model.layers.73.mlp.down_proj.weight": "model-00008-of-00009.safetensors",
650
+ "model.layers.73.mlp.gate_proj.weight": "model-00008-of-00009.safetensors",
651
+ "model.layers.73.mlp.up_proj.weight": "model-00008-of-00009.safetensors",
652
+ "model.layers.73.post_attention_layernorm.weight": "model-00008-of-00009.safetensors",
653
+ "model.layers.73.self_attn.k_proj.weight": "model-00008-of-00009.safetensors",
654
+ "model.layers.73.self_attn.o_proj.weight": "model-00008-of-00009.safetensors",
655
+ "model.layers.73.self_attn.q_proj.weight": "model-00008-of-00009.safetensors",
656
+ "model.layers.73.self_attn.v_proj.weight": "model-00008-of-00009.safetensors",
657
+ "model.layers.74.input_layernorm.weight": "model-00008-of-00009.safetensors",
658
+ "model.layers.74.mlp.down_proj.weight": "model-00008-of-00009.safetensors",
659
+ "model.layers.74.mlp.gate_proj.weight": "model-00008-of-00009.safetensors",
660
+ "model.layers.74.mlp.up_proj.weight": "model-00008-of-00009.safetensors",
661
+ "model.layers.74.post_attention_layernorm.weight": "model-00008-of-00009.safetensors",
662
+ "model.layers.74.self_attn.k_proj.weight": "model-00008-of-00009.safetensors",
663
+ "model.layers.74.self_attn.o_proj.weight": "model-00008-of-00009.safetensors",
664
+ "model.layers.74.self_attn.q_proj.weight": "model-00008-of-00009.safetensors",
665
+ "model.layers.74.self_attn.v_proj.weight": "model-00008-of-00009.safetensors",
666
+ "model.layers.75.input_layernorm.weight": "model-00008-of-00009.safetensors",
667
+ "model.layers.75.mlp.down_proj.weight": "model-00008-of-00009.safetensors",
668
+ "model.layers.75.mlp.gate_proj.weight": "model-00008-of-00009.safetensors",
669
+ "model.layers.75.mlp.up_proj.weight": "model-00008-of-00009.safetensors",
670
+ "model.layers.75.post_attention_layernorm.weight": "model-00008-of-00009.safetensors",
671
+ "model.layers.75.self_attn.k_proj.weight": "model-00008-of-00009.safetensors",
672
+ "model.layers.75.self_attn.o_proj.weight": "model-00008-of-00009.safetensors",
673
+ "model.layers.75.self_attn.q_proj.weight": "model-00008-of-00009.safetensors",
674
+ "model.layers.75.self_attn.v_proj.weight": "model-00008-of-00009.safetensors",
675
+ "model.layers.76.input_layernorm.weight": "model-00008-of-00009.safetensors",
676
+ "model.layers.76.mlp.down_proj.weight": "model-00008-of-00009.safetensors",
677
+ "model.layers.76.mlp.gate_proj.weight": "model-00008-of-00009.safetensors",
678
+ "model.layers.76.mlp.up_proj.weight": "model-00008-of-00009.safetensors",
679
+ "model.layers.76.post_attention_layernorm.weight": "model-00008-of-00009.safetensors",
680
+ "model.layers.76.self_attn.k_proj.weight": "model-00008-of-00009.safetensors",
681
+ "model.layers.76.self_attn.o_proj.weight": "model-00008-of-00009.safetensors",
682
+ "model.layers.76.self_attn.q_proj.weight": "model-00008-of-00009.safetensors",
683
+ "model.layers.76.self_attn.v_proj.weight": "model-00008-of-00009.safetensors",
684
+ "model.layers.77.input_layernorm.weight": "model-00008-of-00009.safetensors",
685
+ "model.layers.77.mlp.down_proj.weight": "model-00008-of-00009.safetensors",
686
+ "model.layers.77.mlp.gate_proj.weight": "model-00008-of-00009.safetensors",
687
+ "model.layers.77.mlp.up_proj.weight": "model-00008-of-00009.safetensors",
688
+ "model.layers.77.post_attention_layernorm.weight": "model-00008-of-00009.safetensors",
689
+ "model.layers.77.self_attn.k_proj.weight": "model-00008-of-00009.safetensors",
690
+ "model.layers.77.self_attn.o_proj.weight": "model-00008-of-00009.safetensors",
691
+ "model.layers.77.self_attn.q_proj.weight": "model-00008-of-00009.safetensors",
692
+ "model.layers.77.self_attn.v_proj.weight": "model-00008-of-00009.safetensors",
693
+ "model.layers.78.input_layernorm.weight": "model-00008-of-00009.safetensors",
694
+ "model.layers.78.mlp.down_proj.weight": "model-00008-of-00009.safetensors",
695
+ "model.layers.78.mlp.gate_proj.weight": "model-00008-of-00009.safetensors",
696
+ "model.layers.78.mlp.up_proj.weight": "model-00009-of-00009.safetensors",
697
+ "model.layers.78.post_attention_layernorm.weight": "model-00009-of-00009.safetensors",
698
+ "model.layers.78.self_attn.k_proj.weight": "model-00009-of-00009.safetensors",
699
+ "model.layers.78.self_attn.o_proj.weight": "model-00009-of-00009.safetensors",
700
+ "model.layers.78.self_attn.q_proj.weight": "model-00009-of-00009.safetensors",
701
+ "model.layers.78.self_attn.v_proj.weight": "model-00009-of-00009.safetensors",
702
+ "model.layers.79.input_layernorm.weight": "model-00009-of-00009.safetensors",
703
+ "model.layers.79.mlp.down_proj.weight": "model-00009-of-00009.safetensors",
704
+ "model.layers.79.mlp.gate_proj.weight": "model-00009-of-00009.safetensors",
705
+ "model.layers.79.mlp.up_proj.weight": "model-00009-of-00009.safetensors",
706
+ "model.layers.79.post_attention_layernorm.weight": "model-00009-of-00009.safetensors",
707
+ "model.layers.79.self_attn.k_proj.weight": "model-00009-of-00009.safetensors",
708
+ "model.layers.79.self_attn.o_proj.weight": "model-00009-of-00009.safetensors",
709
+ "model.layers.79.self_attn.q_proj.weight": "model-00009-of-00009.safetensors",
710
+ "model.layers.79.self_attn.v_proj.weight": "model-00009-of-00009.safetensors",
711
+ "model.layers.8.input_layernorm.weight": "model-00001-of-00009.safetensors",
712
+ "model.layers.8.mlp.down_proj.weight": "model-00001-of-00009.safetensors",
713
+ "model.layers.8.mlp.gate_proj.weight": "model-00001-of-00009.safetensors",
714
+ "model.layers.8.mlp.up_proj.weight": "model-00002-of-00009.safetensors",
715
+ "model.layers.8.post_attention_layernorm.weight": "model-00002-of-00009.safetensors",
716
+ "model.layers.8.self_attn.k_proj.weight": "model-00002-of-00009.safetensors",
717
+ "model.layers.8.self_attn.o_proj.weight": "model-00002-of-00009.safetensors",
718
+ "model.layers.8.self_attn.q_proj.weight": "model-00002-of-00009.safetensors",
719
+ "model.layers.8.self_attn.v_proj.weight": "model-00002-of-00009.safetensors",
720
+ "model.layers.9.input_layernorm.weight": "model-00002-of-00009.safetensors",
721
+ "model.layers.9.mlp.down_proj.weight": "model-00002-of-00009.safetensors",
722
+ "model.layers.9.mlp.gate_proj.weight": "model-00002-of-00009.safetensors",
723
+ "model.layers.9.mlp.up_proj.weight": "model-00002-of-00009.safetensors",
724
+ "model.layers.9.post_attention_layernorm.weight": "model-00002-of-00009.safetensors",
725
+ "model.layers.9.self_attn.k_proj.weight": "model-00002-of-00009.safetensors",
726
+ "model.layers.9.self_attn.o_proj.weight": "model-00002-of-00009.safetensors",
727
+ "model.layers.9.self_attn.q_proj.weight": "model-00002-of-00009.safetensors",
728
+ "model.layers.9.self_attn.v_proj.weight": "model-00002-of-00009.safetensors",
729
+ "model.norm.weight": "model-00009-of-00009.safetensors"
730
+ }
731
+ }
modeling_iquestcoder.py ADDED
@@ -0,0 +1,1068 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Modified MIT License
3
+
4
+ Software Copyright© 2025 IQuest Research
5
+
6
+ Our only modification is that, if the Software (or any derivative works
7
+ thereof) is used for any of your commercial products or services, you shall
8
+ prominently display "IQuest Coder" on the user interface of such product or
9
+ service.
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26
+ """
27
+
28
+ from typing import Callable, List, Optional, Tuple, Union
29
+
30
+ import torch
31
+ import torch.nn as nn
32
+ import torch.nn.functional as F
33
+
34
+ from transformers.activations import ACT2FN
35
+ from transformers.cache_utils import Cache, DynamicCache, SlidingWindowCache, StaticCache
36
+ from transformers.generation import GenerationMixin
37
+ from transformers.modeling_attn_mask_utils import AttentionMaskConverter
38
+ from transformers.modeling_flash_attention_utils import FlashAttentionKwargs
39
+ from transformers.modeling_layers import GradientCheckpointingLayer
40
+ from transformers.modeling_outputs import (
41
+ BaseModelOutputWithPast,
42
+ CausalLMOutputWithPast,
43
+ QuestionAnsweringModelOutput,
44
+ SequenceClassifierOutputWithPast,
45
+ TokenClassifierOutput,
46
+ )
47
+ from transformers.modeling_rope_utils import ROPE_INIT_FUNCTIONS, dynamic_rope_update
48
+ from transformers.modeling_utils import ALL_ATTENTION_FUNCTIONS, PreTrainedModel
49
+ from transformers.processing_utils import Unpack
50
+ from transformers.utils import (
51
+ auto_docstring,
52
+ can_return_tuple,
53
+ is_torch_flex_attn_available,
54
+ logging,
55
+ )
56
+
57
+ from .configuration_iquestcoder import IQuestCoderConfig
58
+
59
+
60
+ if is_torch_flex_attn_available():
61
+ from torch.nn.attention.flex_attention import BlockMask
62
+ from transformers.integrations.flex_attention import make_flex_block_causal_mask
63
+
64
+
65
+ logger = logging.get_logger(__name__)
66
+
67
+
68
+ # =============================================================================
69
+ # Helper Functions
70
+ # =============================================================================
71
+
72
+ def rotate_half(x: torch.Tensor) -> torch.Tensor:
73
+ """Rotates half the hidden dims of the input."""
74
+ x1 = x[..., : x.shape[-1] // 2]
75
+ x2 = x[..., x.shape[-1] // 2 :]
76
+ return torch.cat((-x2, x1), dim=-1)
77
+
78
+
79
+ def apply_rotary_pos_emb(
80
+ q: torch.Tensor,
81
+ k: torch.Tensor,
82
+ cos: torch.Tensor,
83
+ sin: torch.Tensor,
84
+ position_ids: Optional[torch.Tensor] = None,
85
+ unsqueeze_dim: int = 1,
86
+ ) -> Tuple[torch.Tensor, torch.Tensor]:
87
+ """Applies Rotary Position Embedding to the query and key tensors.
88
+
89
+ Args:
90
+ q: The query tensor.
91
+ k: The key tensor.
92
+ cos: The cosine part of the rotary embedding.
93
+ sin: The sine part of the rotary embedding.
94
+ position_ids: Deprecated and unused.
95
+ unsqueeze_dim: The dimension along which to unsqueeze cos and sin.
96
+
97
+ Returns:
98
+ Tuple of query and key tensors rotated using the Rotary Position Embedding.
99
+ """
100
+ # Borrowed from OLMo: preserve original dtypes for numerical stability
101
+ q_dtype, k_dtype = q.dtype, k.dtype
102
+ cos = cos.unsqueeze(unsqueeze_dim)
103
+ sin = sin.unsqueeze(unsqueeze_dim)
104
+ q_embed = (q * cos) + (rotate_half(q) * sin)
105
+ k_embed = (k * cos) + (rotate_half(k) * sin)
106
+ return q_embed.to(q_dtype), k_embed.to(k_dtype)
107
+
108
+
109
+ def repeat_kv(hidden_states: torch.Tensor, n_rep: int) -> torch.Tensor:
110
+ """
111
+ Expands key/value heads for Grouped Query Attention.
112
+
113
+ This is the equivalent of torch.repeat_interleave(x, dim=1, repeats=n_rep).
114
+ The hidden states go from (batch, num_key_value_heads, seqlen, head_dim) to
115
+ (batch, num_attention_heads, seqlen, head_dim).
116
+ """
117
+ batch, num_key_value_heads, slen, head_dim = hidden_states.shape
118
+ if n_rep == 1:
119
+ return hidden_states
120
+ hidden_states = hidden_states[:, :, None, :, :].expand(batch, num_key_value_heads, n_rep, slen, head_dim)
121
+ return hidden_states.reshape(batch, num_key_value_heads * n_rep, slen, head_dim)
122
+
123
+
124
+ def eager_attention_forward(
125
+ module: nn.Module,
126
+ query: torch.Tensor,
127
+ key: torch.Tensor,
128
+ value: torch.Tensor,
129
+ attention_mask: Optional[torch.Tensor],
130
+ scaling: float,
131
+ dropout: float = 0.0,
132
+ **kwargs,
133
+ ) -> Tuple[torch.Tensor, torch.Tensor]:
134
+ """Standard eager attention implementation."""
135
+ key_states = repeat_kv(key, module.num_key_value_groups)
136
+ value_states = repeat_kv(value, module.num_key_value_groups)
137
+
138
+ attn_weights = torch.matmul(query, key_states.transpose(2, 3)) * scaling
139
+ if attention_mask is not None:
140
+ causal_mask = attention_mask[:, :, :, : key_states.shape[-2]]
141
+ attn_weights = attn_weights + causal_mask
142
+
143
+ attn_weights = F.softmax(attn_weights, dim=-1, dtype=torch.float32).to(query.dtype)
144
+ attn_weights = F.dropout(attn_weights, p=dropout, training=module.training)
145
+ attn_output = torch.matmul(attn_weights, value_states)
146
+ attn_output = attn_output.transpose(1, 2).contiguous()
147
+
148
+ return attn_output, attn_weights
149
+
150
+
151
+ # =============================================================================
152
+ # Model Components
153
+ # =============================================================================
154
+
155
+ class IQuestCoderRMSNorm(nn.Module):
156
+ """Root Mean Square Layer Normalization.
157
+
158
+ RMSNorm is computationally simpler than LayerNorm while achieving similar
159
+ performance. It normalizes the input by its RMS value.
160
+ """
161
+
162
+ def __init__(self, hidden_size: int, eps: float = 1e-6):
163
+ super().__init__()
164
+ self.weight = nn.Parameter(torch.ones(hidden_size))
165
+ self.variance_epsilon = eps
166
+
167
+ def forward(self, hidden_states: torch.Tensor) -> torch.Tensor:
168
+ input_dtype = hidden_states.dtype
169
+ hidden_states = hidden_states.to(torch.float32)
170
+ variance = hidden_states.pow(2).mean(-1, keepdim=True)
171
+ hidden_states = hidden_states * torch.rsqrt(variance + self.variance_epsilon)
172
+ return self.weight * hidden_states.to(input_dtype)
173
+
174
+ def extra_repr(self) -> str:
175
+ return f"{tuple(self.weight.shape)}, eps={self.variance_epsilon}"
176
+
177
+
178
+ class IQuestCoderRotaryEmbedding(nn.Module):
179
+ """Rotary Position Embedding (RoPE).
180
+
181
+ Implements rotary positional embeddings as described in the RoFormer paper.
182
+ Supports various RoPE scaling methods for extended context lengths.
183
+ """
184
+
185
+ def __init__(self, config: IQuestCoderConfig, device=None):
186
+ super().__init__()
187
+ # BC: "rope_type" was originally "type"
188
+ if hasattr(config, "rope_scaling") and config.rope_scaling is not None:
189
+ self.rope_type = config.rope_scaling.get("rope_type", config.rope_scaling.get("type"))
190
+ else:
191
+ self.rope_type = "default"
192
+ self.max_seq_len_cached = config.max_position_embeddings
193
+ self.original_max_seq_len = config.max_position_embeddings
194
+
195
+ self.config = config
196
+ self.rope_init_fn = ROPE_INIT_FUNCTIONS[self.rope_type]
197
+
198
+ inv_freq, self.attention_scaling = self.rope_init_fn(self.config, device)
199
+ self.register_buffer("inv_freq", inv_freq, persistent=False)
200
+ self.original_inv_freq = self.inv_freq
201
+
202
+ @torch.no_grad()
203
+ @dynamic_rope_update
204
+ def forward(self, x: torch.Tensor, position_ids: torch.Tensor) -> Tuple[torch.Tensor, torch.Tensor]:
205
+ # Lazy recompute: accelerate meta-device init leaves inv_freq as zeros
206
+ if self.inv_freq is not None and self.inv_freq.numel() > 0 and (self.inv_freq == 0).all():
207
+ inv_freq, self.attention_scaling = self.rope_init_fn(self.config, None)
208
+ self.inv_freq = inv_freq.to(device=x.device, dtype=self.inv_freq.dtype)
209
+ self.original_inv_freq = self.inv_freq
210
+ inv_freq_expanded = self.inv_freq[None, :, None].float().expand(position_ids.shape[0], -1, 1).to(x.device)
211
+ position_ids_expanded = position_ids[:, None, :].float()
212
+
213
+ device_type = x.device.type if isinstance(x.device.type, str) and x.device.type != "mps" else "cpu"
214
+ with torch.autocast(device_type=device_type, enabled=False):
215
+ freqs = (inv_freq_expanded.float() @ position_ids_expanded.float()).transpose(1, 2)
216
+ emb = torch.cat((freqs, freqs), dim=-1)
217
+ cos = emb.cos() * self.attention_scaling
218
+ sin = emb.sin() * self.attention_scaling
219
+
220
+ return cos.to(dtype=x.dtype), sin.to(dtype=x.dtype)
221
+
222
+
223
+ class IQuestCoderMLP(nn.Module):
224
+ """Feed-forward network with SwiGLU activation.
225
+
226
+ Uses the gated linear unit variant with SiLU activation for improved
227
+ performance compared to standard FFN.
228
+ """
229
+
230
+ def __init__(self, config: IQuestCoderConfig):
231
+ super().__init__()
232
+ self.config = config
233
+ self.hidden_size = config.hidden_size
234
+ self.intermediate_size = config.intermediate_size
235
+ self.gate_proj = nn.Linear(self.hidden_size, self.intermediate_size, bias=config.mlp_bias)
236
+ self.up_proj = nn.Linear(self.hidden_size, self.intermediate_size, bias=config.mlp_bias)
237
+ self.down_proj = nn.Linear(self.intermediate_size, self.hidden_size, bias=config.mlp_bias)
238
+ self.act_fn = ACT2FN[config.hidden_act]
239
+
240
+ def forward(self, x: torch.Tensor) -> torch.Tensor:
241
+ # SwiGLU: down_proj(act_fn(gate_proj(x)) * up_proj(x))
242
+ return self.down_proj(self.act_fn(self.gate_proj(x)) * self.up_proj(x))
243
+
244
+
245
+ class IQuestCoderAttention(nn.Module):
246
+ """Multi-headed attention with support for Grouped Query Attention (GQA).
247
+
248
+ Features:
249
+ - Grouped Query Attention for memory efficiency
250
+ - Optional QKV clipping for training stability (from OLMo)
251
+ - Optional sliding window attention (from Qwen2)
252
+ - Rotary Position Embeddings
253
+ """
254
+
255
+ def __init__(self, config: IQuestCoderConfig, layer_idx: int):
256
+ super().__init__()
257
+ self.config = config
258
+ self.layer_idx = layer_idx
259
+ self.head_dim = getattr(config, "head_dim", config.hidden_size // config.num_attention_heads)
260
+ self.num_key_value_groups = config.num_attention_heads // config.num_key_value_heads
261
+ self.scaling = self.head_dim ** -0.5
262
+ self.attention_dropout = config.attention_dropout
263
+ self.is_causal = True
264
+
265
+ # Projection layers
266
+ self.q_proj = nn.Linear(
267
+ config.hidden_size, config.num_attention_heads * self.head_dim, bias=config.attention_bias
268
+ )
269
+ self.k_proj = nn.Linear(
270
+ config.hidden_size, config.num_key_value_heads * self.head_dim, bias=config.attention_bias
271
+ )
272
+ self.v_proj = nn.Linear(
273
+ config.hidden_size, config.num_key_value_heads * self.head_dim, bias=config.attention_bias
274
+ )
275
+ self.o_proj = nn.Linear(
276
+ config.num_attention_heads * self.head_dim, config.hidden_size, bias=config.attention_bias
277
+ )
278
+
279
+ def forward(
280
+ self,
281
+ hidden_states: torch.Tensor,
282
+ position_embeddings: Tuple[torch.Tensor, torch.Tensor],
283
+ attention_mask: Optional[torch.Tensor],
284
+ past_key_value: Optional[Cache] = None,
285
+ cache_position: Optional[torch.LongTensor] = None,
286
+ **kwargs: Unpack[FlashAttentionKwargs],
287
+ ) -> Tuple[torch.Tensor, Optional[torch.Tensor], Optional[Tuple[torch.Tensor]]]:
288
+ input_shape = hidden_states.shape[:-1]
289
+ hidden_shape = (*input_shape, -1, self.head_dim)
290
+
291
+ # Compute Q, K, V projections
292
+ query_states = self.q_proj(hidden_states)
293
+ key_states = self.k_proj(hidden_states)
294
+ value_states = self.v_proj(hidden_states)
295
+
296
+ # [OLMo Feature] Optional QKV clipping for training stability
297
+ if self.config.clip_qkv is not None:
298
+ query_states = query_states.clamp(min=-self.config.clip_qkv, max=self.config.clip_qkv)
299
+ key_states = key_states.clamp(min=-self.config.clip_qkv, max=self.config.clip_qkv)
300
+ value_states = value_states.clamp(min=-self.config.clip_qkv, max=self.config.clip_qkv)
301
+
302
+ # Reshape to (batch, heads, seq_len, head_dim)
303
+ query_states = query_states.view(hidden_shape).transpose(1, 2)
304
+ key_states = key_states.view(hidden_shape).transpose(1, 2)
305
+ value_states = value_states.view(hidden_shape).transpose(1, 2)
306
+
307
+ # Apply rotary position embeddings
308
+ cos, sin = position_embeddings
309
+ query_states, key_states = apply_rotary_pos_emb(query_states, key_states, cos, sin)
310
+
311
+ # Update KV cache if provided
312
+ if past_key_value is not None:
313
+ cache_kwargs = {"sin": sin, "cos": cos, "cache_position": cache_position}
314
+ key_states, value_states = past_key_value.update(key_states, value_states, self.layer_idx, cache_kwargs)
315
+
316
+ # [Qwen2 Feature] Sliding window attention
317
+ sliding_window = None
318
+ if (
319
+ self.config.use_sliding_window
320
+ and getattr(self.config, "sliding_window", None) is not None
321
+ and self.layer_idx >= self.config.max_window_layers
322
+ ):
323
+ sliding_window = self.config.sliding_window
324
+
325
+ # Select attention implementation
326
+ attention_interface: Callable = eager_attention_forward
327
+ if self.config._attn_implementation != "eager":
328
+ if self.config._attn_implementation == "sdpa" and kwargs.get("output_attentions", False):
329
+ logger.warning_once(
330
+ "`torch.nn.functional.scaled_dot_product_attention` does not support `output_attentions=True`. "
331
+ 'Falling back to eager attention. This warning can be removed using the argument '
332
+ '`attn_implementation="eager"` when loading the model.'
333
+ )
334
+ else:
335
+ attention_interface = ALL_ATTENTION_FUNCTIONS[self.config._attn_implementation]
336
+
337
+ # Compute attention
338
+ attn_output, attn_weights = attention_interface(
339
+ self,
340
+ query_states,
341
+ key_states,
342
+ value_states,
343
+ attention_mask,
344
+ dropout=0.0 if not self.training else self.attention_dropout,
345
+ scaling=self.scaling,
346
+ sliding_window=sliding_window,
347
+ **kwargs,
348
+ )
349
+
350
+ # Reshape and project output
351
+ attn_output = attn_output.reshape(*input_shape, -1).contiguous()
352
+ attn_output = self.o_proj(attn_output)
353
+
354
+ return attn_output, attn_weights
355
+
356
+
357
+ class IQuestCoderDecoderLayer(GradientCheckpointingLayer):
358
+ """Transformer decoder layer with pre-normalization.
359
+
360
+ Architecture: Pre-RMSNorm -> Attention -> Residual -> Pre-RMSNorm -> MLP -> Residual
361
+ """
362
+
363
+ def __init__(self, config: IQuestCoderConfig, layer_idx: int):
364
+ super().__init__()
365
+ self.hidden_size = config.hidden_size
366
+ self.self_attn = IQuestCoderAttention(config=config, layer_idx=layer_idx)
367
+ self.mlp = IQuestCoderMLP(config)
368
+ self.input_layernorm = IQuestCoderRMSNorm(config.hidden_size, eps=config.rms_norm_eps)
369
+ self.post_attention_layernorm = IQuestCoderRMSNorm(config.hidden_size, eps=config.rms_norm_eps)
370
+
371
+ # Warn if sliding window is enabled but not properly supported
372
+ if config.use_sliding_window and config._attn_implementation != "flash_attention_2":
373
+ logger.warning_once(
374
+ f"Sliding Window Attention is enabled but not implemented for `{config._attn_implementation}`; "
375
+ "unexpected results may be encountered."
376
+ )
377
+
378
+ def forward(
379
+ self,
380
+ hidden_states: torch.Tensor,
381
+ attention_mask: Optional[torch.Tensor] = None,
382
+ position_ids: Optional[torch.LongTensor] = None,
383
+ past_key_value: Optional[Cache] = None,
384
+ output_attentions: Optional[bool] = False,
385
+ use_cache: Optional[bool] = False,
386
+ cache_position: Optional[torch.LongTensor] = None,
387
+ position_embeddings: Optional[Tuple[torch.Tensor, torch.Tensor]] = None,
388
+ **kwargs: Unpack[FlashAttentionKwargs],
389
+ ) -> Tuple[torch.FloatTensor, Optional[Tuple[torch.FloatTensor, torch.FloatTensor]]]:
390
+ # Pre-norm + Self Attention
391
+ residual = hidden_states
392
+ hidden_states = self.input_layernorm(hidden_states)
393
+
394
+ hidden_states, self_attn_weights = self.self_attn(
395
+ hidden_states=hidden_states,
396
+ attention_mask=attention_mask,
397
+ position_ids=position_ids,
398
+ past_key_value=past_key_value,
399
+ output_attentions=output_attentions,
400
+ use_cache=use_cache,
401
+ cache_position=cache_position,
402
+ position_embeddings=position_embeddings,
403
+ **kwargs,
404
+ )
405
+ hidden_states = residual + hidden_states
406
+
407
+ # Pre-norm + MLP
408
+ residual = hidden_states
409
+ hidden_states = self.post_attention_layernorm(hidden_states)
410
+ hidden_states = self.mlp(hidden_states)
411
+ hidden_states = residual + hidden_states
412
+
413
+ outputs = (hidden_states,)
414
+ if output_attentions:
415
+ outputs += (self_attn_weights,)
416
+
417
+ return outputs
418
+
419
+
420
+ # =============================================================================
421
+ # Base Model
422
+ # =============================================================================
423
+
424
+ @auto_docstring
425
+ class IQuestCoderPreTrainedModel(PreTrainedModel):
426
+ """Base class for IQuestCoder models."""
427
+
428
+ config_class = IQuestCoderConfig
429
+ base_model_prefix = "model"
430
+ supports_gradient_checkpointing = True
431
+ _no_split_modules = ["IQuestCoderDecoderLayer"]
432
+ _skip_keys_device_placement = ["past_key_values"]
433
+ _supports_flash_attn_2 = True
434
+ _supports_sdpa = True
435
+ _supports_flex_attn = True
436
+ _supports_cache_class = True
437
+ _supports_quantized_cache = True
438
+ _supports_static_cache = True
439
+ _supports_attention_backend = True
440
+
441
+ def _init_weights(self, module: nn.Module):
442
+ std = self.config.initializer_range
443
+ if isinstance(module, nn.Linear):
444
+ module.weight.data.normal_(mean=0.0, std=std)
445
+ if module.bias is not None:
446
+ module.bias.data.zero_()
447
+ elif isinstance(module, nn.Embedding):
448
+ module.weight.data.normal_(mean=0.0, std=std)
449
+ if module.padding_idx is not None:
450
+ module.weight.data[module.padding_idx].zero_()
451
+ elif isinstance(module, IQuestCoderRMSNorm):
452
+ module.weight.data.fill_(1.0)
453
+
454
+
455
+ @auto_docstring
456
+ class IQuestCoderModel(IQuestCoderPreTrainedModel):
457
+ """
458
+ IQuestCoder Model outputting raw hidden-states without any specific head on top.
459
+
460
+ This model is compatible with LLaMA weights while incorporating features from OLMo and Qwen2.
461
+ """
462
+
463
+ def __init__(self, config: IQuestCoderConfig):
464
+ super().__init__(config)
465
+ self.padding_idx = config.pad_token_id
466
+ self.vocab_size = config.vocab_size
467
+
468
+ self.embed_tokens = nn.Embedding(config.vocab_size, config.hidden_size, self.padding_idx)
469
+ self.layers = nn.ModuleList(
470
+ [IQuestCoderDecoderLayer(config, layer_idx) for layer_idx in range(config.num_hidden_layers)]
471
+ )
472
+ self.norm = IQuestCoderRMSNorm(config.hidden_size, eps=config.rms_norm_eps)
473
+ self.rotary_emb = IQuestCoderRotaryEmbedding(config=config)
474
+ self.gradient_checkpointing = False
475
+
476
+ # Initialize weights and apply final processing
477
+ self.post_init()
478
+
479
+ def get_input_embeddings(self) -> nn.Embedding:
480
+ return self.embed_tokens
481
+
482
+ def set_input_embeddings(self, value: nn.Embedding):
483
+ self.embed_tokens = value
484
+
485
+ @can_return_tuple
486
+ @auto_docstring
487
+ def forward(
488
+ self,
489
+ input_ids: Optional[torch.LongTensor] = None,
490
+ attention_mask: Optional[torch.Tensor] = None,
491
+ position_ids: Optional[torch.LongTensor] = None,
492
+ past_key_values: Optional[Cache] = None,
493
+ inputs_embeds: Optional[torch.FloatTensor] = None,
494
+ use_cache: Optional[bool] = None,
495
+ output_attentions: Optional[bool] = None,
496
+ output_hidden_states: Optional[bool] = None,
497
+ cache_position: Optional[torch.LongTensor] = None,
498
+ **flash_attn_kwargs: Unpack[FlashAttentionKwargs],
499
+ ) -> BaseModelOutputWithPast:
500
+ output_attentions = output_attentions if output_attentions is not None else self.config.output_attentions
501
+ output_hidden_states = (
502
+ output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
503
+ )
504
+ use_cache = use_cache if use_cache is not None else self.config.use_cache
505
+
506
+ if (input_ids is None) ^ (inputs_embeds is not None):
507
+ raise ValueError("You must specify exactly one of input_ids or inputs_embeds")
508
+
509
+ if self.gradient_checkpointing and self.training and use_cache:
510
+ logger.warning_once(
511
+ "`use_cache=True` is incompatible with gradient checkpointing. Setting `use_cache=False`."
512
+ )
513
+ use_cache = False
514
+
515
+ if not isinstance(past_key_values, (type(None), Cache)):
516
+ raise ValueError("The `past_key_values` should be either a `Cache` object or `None`.")
517
+
518
+ if inputs_embeds is None:
519
+ inputs_embeds = self.embed_tokens(input_ids)
520
+
521
+ if use_cache and past_key_values is None:
522
+ past_key_values = DynamicCache()
523
+
524
+ if cache_position is None:
525
+ past_seen_tokens = past_key_values.get_seq_length() if past_key_values is not None else 0
526
+ cache_position = torch.arange(
527
+ past_seen_tokens, past_seen_tokens + inputs_embeds.shape[1], device=inputs_embeds.device
528
+ )
529
+
530
+ if position_ids is None:
531
+ position_ids = cache_position.unsqueeze(0)
532
+
533
+ causal_mask = self._update_causal_mask(
534
+ attention_mask, inputs_embeds, cache_position, past_key_values, output_attentions
535
+ )
536
+
537
+ hidden_states = inputs_embeds
538
+
539
+ # Create position embeddings to be shared across the decoder layers
540
+ position_embeddings = self.rotary_emb(hidden_states, position_ids)
541
+
542
+ # Decoder layers
543
+ all_hidden_states = () if output_hidden_states else None
544
+ all_self_attns = () if output_attentions else None
545
+
546
+ for decoder_layer in self.layers[: self.config.num_hidden_layers]:
547
+ if output_hidden_states:
548
+ all_hidden_states += (hidden_states,)
549
+
550
+ layer_outputs = decoder_layer(
551
+ hidden_states,
552
+ attention_mask=causal_mask,
553
+ position_ids=position_ids,
554
+ past_key_value=past_key_values,
555
+ output_attentions=output_attentions,
556
+ use_cache=use_cache,
557
+ cache_position=cache_position,
558
+ position_embeddings=position_embeddings,
559
+ **flash_attn_kwargs,
560
+ )
561
+
562
+ hidden_states = layer_outputs[0]
563
+
564
+ if output_attentions:
565
+ all_self_attns += (layer_outputs[1],)
566
+
567
+ hidden_states = self.norm(hidden_states)
568
+
569
+ # Add hidden states from the last decoder layer
570
+ if output_hidden_states:
571
+ all_hidden_states += (hidden_states,)
572
+
573
+ return BaseModelOutputWithPast(
574
+ last_hidden_state=hidden_states,
575
+ past_key_values=past_key_values if use_cache else None,
576
+ hidden_states=all_hidden_states,
577
+ attentions=all_self_attns,
578
+ )
579
+
580
+ def _update_causal_mask(
581
+ self,
582
+ attention_mask: Union[torch.Tensor, "BlockMask"],
583
+ input_tensor: torch.Tensor,
584
+ cache_position: torch.Tensor,
585
+ past_key_values: Cache,
586
+ output_attentions: bool = False,
587
+ ):
588
+ if self.config._attn_implementation == "flash_attention_2":
589
+ if attention_mask is not None and past_key_values is not None:
590
+ is_padding_right = attention_mask[:, -1].sum().item() != input_tensor.size()[0]
591
+ if is_padding_right:
592
+ raise ValueError(
593
+ "You are attempting to perform batched generation with padding_side='right'. "
594
+ "This may lead to unexpected behaviour for Flash Attention version of IQuestCoder. "
595
+ "Make sure to call `tokenizer.padding_side = 'left'` before tokenizing the input."
596
+ )
597
+ if attention_mask is not None and 0.0 in attention_mask:
598
+ return attention_mask
599
+ return None
600
+
601
+ if self.config._attn_implementation == "flex_attention":
602
+ if isinstance(attention_mask, torch.Tensor):
603
+ attention_mask = make_flex_block_causal_mask(attention_mask)
604
+ return attention_mask
605
+
606
+ past_seen_tokens = past_key_values.get_seq_length() if past_key_values is not None else 0
607
+ using_static_cache = isinstance(past_key_values, StaticCache)
608
+ using_sliding_window_cache = isinstance(past_key_values, SlidingWindowCache)
609
+
610
+ if (
611
+ self.config._attn_implementation == "sdpa"
612
+ and not (using_static_cache or using_sliding_window_cache)
613
+ and not output_attentions
614
+ ):
615
+ if AttentionMaskConverter._ignore_causal_mask_sdpa(
616
+ attention_mask,
617
+ inputs_embeds=input_tensor,
618
+ past_key_values_length=past_seen_tokens,
619
+ sliding_window=self.config.sliding_window if self.config.use_sliding_window else None,
620
+ is_training=self.training,
621
+ ):
622
+ return None
623
+
624
+ dtype = input_tensor.dtype
625
+ min_dtype = torch.finfo(dtype).min
626
+ sequence_length = input_tensor.shape[1]
627
+
628
+ if using_sliding_window_cache or using_static_cache:
629
+ target_length = past_key_values.get_max_cache_shape()
630
+ else:
631
+ target_length = (
632
+ attention_mask.shape[-1]
633
+ if isinstance(attention_mask, torch.Tensor)
634
+ else past_seen_tokens + sequence_length + 1
635
+ )
636
+
637
+ causal_mask = self._prepare_4d_causal_attention_mask_with_cache_position(
638
+ attention_mask,
639
+ sequence_length=sequence_length,
640
+ target_length=target_length,
641
+ dtype=dtype,
642
+ cache_position=cache_position,
643
+ batch_size=input_tensor.shape[0],
644
+ config=self.config,
645
+ past_key_values=past_key_values,
646
+ )
647
+
648
+ if (
649
+ self.config._attn_implementation == "sdpa"
650
+ and attention_mask is not None
651
+ and attention_mask.device.type in ["cuda", "xpu", "npu"]
652
+ and not output_attentions
653
+ ):
654
+ causal_mask = AttentionMaskConverter._unmask_unattended(causal_mask, min_dtype)
655
+
656
+ return causal_mask
657
+
658
+ @staticmethod
659
+ def _prepare_4d_causal_attention_mask_with_cache_position(
660
+ attention_mask: torch.Tensor,
661
+ sequence_length: int,
662
+ target_length: int,
663
+ dtype: torch.dtype,
664
+ cache_position: torch.Tensor,
665
+ batch_size: int,
666
+ config: IQuestCoderConfig,
667
+ past_key_values: Cache,
668
+ ):
669
+ """Creates a causal 4D mask from a 2D mask, or returns the 4D mask if already provided."""
670
+ if attention_mask is not None and attention_mask.dim() == 4:
671
+ causal_mask = attention_mask
672
+ else:
673
+ min_dtype = torch.finfo(dtype).min
674
+ causal_mask = torch.full(
675
+ (sequence_length, target_length), fill_value=min_dtype, dtype=dtype, device=cache_position.device
676
+ )
677
+ diagonal_attend_mask = torch.arange(target_length, device=cache_position.device) > cache_position.reshape(
678
+ -1, 1
679
+ )
680
+
681
+ # [Qwen2 Feature] Handle sliding window mask
682
+ if getattr(config, "use_sliding_window", False) and config.sliding_window is not None:
683
+ if not isinstance(past_key_values, SlidingWindowCache) or sequence_length > target_length:
684
+ sliding_attend_mask = torch.arange(target_length, device=cache_position.device) <= (
685
+ cache_position.reshape(-1, 1) - config.sliding_window
686
+ )
687
+ diagonal_attend_mask.bitwise_or_(sliding_attend_mask)
688
+
689
+ causal_mask *= diagonal_attend_mask
690
+ causal_mask = causal_mask[None, None, :, :].expand(batch_size, 1, -1, -1)
691
+
692
+ if attention_mask is not None:
693
+ causal_mask = causal_mask.clone()
694
+ if attention_mask.shape[-1] > target_length:
695
+ attention_mask = attention_mask[:, :target_length]
696
+ mask_length = attention_mask.shape[-1]
697
+ padding_mask = causal_mask[:, :, :, :mask_length] + attention_mask[:, None, None, :].to(
698
+ causal_mask.device
699
+ )
700
+ padding_mask = padding_mask == 0
701
+ causal_mask[:, :, :, :mask_length] = causal_mask[:, :, :, :mask_length].masked_fill(
702
+ padding_mask, min_dtype
703
+ )
704
+
705
+ return causal_mask
706
+
707
+
708
+ # =============================================================================
709
+ # Model Heads
710
+ # =============================================================================
711
+
712
+ @auto_docstring
713
+ class IQuestCoderForCausalLM(IQuestCoderPreTrainedModel, GenerationMixin):
714
+ """IQuestCoder Model with a language modeling head on top for causal LM."""
715
+
716
+ _tied_weights_keys = ["lm_head.weight"]
717
+ _tp_plan = {"lm_head": "colwise_rep"}
718
+ _pp_plan = {"lm_head": (["hidden_states"], ["logits"])}
719
+
720
+ def __init__(self, config: IQuestCoderConfig):
721
+ super().__init__(config)
722
+ self.model = IQuestCoderModel(config)
723
+ self.vocab_size = config.vocab_size
724
+ self.lm_head = nn.Linear(config.hidden_size, config.vocab_size, bias=False)
725
+
726
+ # Initialize weights and apply final processing
727
+ self.post_init()
728
+
729
+ def get_input_embeddings(self) -> nn.Embedding:
730
+ return self.model.embed_tokens
731
+
732
+ def set_input_embeddings(self, value: nn.Embedding):
733
+ self.model.embed_tokens = value
734
+
735
+ def get_output_embeddings(self) -> nn.Linear:
736
+ return self.lm_head
737
+
738
+ def set_output_embeddings(self, new_embeddings: nn.Linear):
739
+ self.lm_head = new_embeddings
740
+
741
+ def set_decoder(self, decoder: IQuestCoderModel):
742
+ self.model = decoder
743
+
744
+ def get_decoder(self) -> IQuestCoderModel:
745
+ return self.model
746
+
747
+ @can_return_tuple
748
+ @auto_docstring
749
+ def forward(
750
+ self,
751
+ input_ids: Optional[torch.LongTensor] = None,
752
+ attention_mask: Optional[torch.Tensor] = None,
753
+ position_ids: Optional[torch.LongTensor] = None,
754
+ past_key_values: Optional[Cache] = None,
755
+ inputs_embeds: Optional[torch.FloatTensor] = None,
756
+ labels: Optional[torch.LongTensor] = None,
757
+ use_cache: Optional[bool] = None,
758
+ output_attentions: Optional[bool] = None,
759
+ output_hidden_states: Optional[bool] = None,
760
+ cache_position: Optional[torch.LongTensor] = None,
761
+ logits_to_keep: Union[int, torch.Tensor] = 0,
762
+ **kwargs
763
+ ) -> CausalLMOutputWithPast:
764
+ r"""
765
+ Args:
766
+ labels (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *optional*):
767
+ Labels for computing the masked language modeling loss. Indices should either be in `[0, ...,
768
+ config.vocab_size]` or -100 (see `input_ids` docstring). Tokens with indices set to `-100` are ignored
769
+ (masked), the loss is only computed for the tokens with labels in `[0, ..., config.vocab_size]`.
770
+
771
+ Example:
772
+ ```python
773
+ >>> from transformers import AutoTokenizer
774
+ >>> from modeling_iquestcoder import IQuestCoderForCausalLM
775
+
776
+ >>> model = IQuestCoderForCausalLM.from_pretrained("path/to/IQuestCoder")
777
+ >>> tokenizer = AutoTokenizer.from_pretrained("path/to/IQuestCoder")
778
+
779
+ >>> prompt = "Hey, are you conscious? Can you talk to me?"
780
+ >>> inputs = tokenizer(prompt, return_tensors="pt")
781
+
782
+ >>> # Generate
783
+ >>> generate_ids = model.generate(inputs.input_ids, max_length=30)
784
+ >>> tokenizer.batch_decode(generate_ids, skip_special_tokens=True, clean_up_tokenization_spaces=False)[0]
785
+ "Hey, are you conscious? Can you talk to me?\\nI'm not conscious, but I can talk to you."
786
+ ```
787
+ """
788
+ output_attentions = output_attentions if output_attentions is not None else self.config.output_attentions
789
+ output_hidden_states = (
790
+ output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
791
+ )
792
+
793
+ # Decoder outputs consists of (dec_features, layer_state, dec_hidden, dec_attn)
794
+ outputs: BaseModelOutputWithPast = self.model(
795
+ input_ids=input_ids,
796
+ attention_mask=attention_mask,
797
+ position_ids=position_ids,
798
+ past_key_values=past_key_values,
799
+ inputs_embeds=inputs_embeds,
800
+ use_cache=use_cache,
801
+ output_attentions=output_attentions,
802
+ output_hidden_states=output_hidden_states,
803
+ cache_position=cache_position,
804
+ **kwargs,
805
+ )
806
+
807
+ hidden_states = outputs.last_hidden_state
808
+ # Only compute necessary logits, and do not upcast them to float if we are not computing the loss
809
+ slice_indices = slice(-logits_to_keep, None) if isinstance(logits_to_keep, int) else logits_to_keep
810
+ logits = self.lm_head(hidden_states[:, slice_indices, :])
811
+
812
+ loss = None
813
+ if labels is not None:
814
+ loss = self.loss_function(logits=logits, labels=labels, vocab_size=self.config.vocab_size, **kwargs)
815
+
816
+ return CausalLMOutputWithPast(
817
+ loss=loss,
818
+ logits=logits,
819
+ past_key_values=outputs.past_key_values,
820
+ hidden_states=outputs.hidden_states,
821
+ attentions=outputs.attentions,
822
+ )
823
+
824
+
825
+ @auto_docstring(
826
+ custom_intro="""
827
+ The IQuestCoder Model transformer with a sequence classification head on top (linear layer).
828
+
829
+ [`IQuestCoderForSequenceClassification`] uses the last token in order to do the classification, as other causal
830
+ models (e.g. GPT-2) do.
831
+
832
+ Since it does classification on the last token, it requires to know the position of the last token. If a
833
+ `pad_token_id` is defined in the configuration, it finds the last token that is not a padding token in each row.
834
+ If no `pad_token_id` is defined, it simply takes the last value in each row of the batch.
835
+ """
836
+ )
837
+ class IQuestCoderForSequenceClassification(IQuestCoderPreTrainedModel):
838
+ """IQuestCoder Model with a sequence classification head."""
839
+
840
+ def __init__(self, config: IQuestCoderConfig):
841
+ super().__init__(config)
842
+ self.num_labels = config.num_labels
843
+ self.model = IQuestCoderModel(config)
844
+ self.score = nn.Linear(config.hidden_size, self.num_labels, bias=False)
845
+
846
+ # Initialize weights and apply final processing
847
+ self.post_init()
848
+
849
+ def get_input_embeddings(self) -> nn.Embedding:
850
+ return self.model.embed_tokens
851
+
852
+ def set_input_embeddings(self, value: nn.Embedding):
853
+ self.model.embed_tokens = value
854
+
855
+ @can_return_tuple
856
+ @auto_docstring
857
+ def forward(
858
+ self,
859
+ input_ids: Optional[torch.LongTensor] = None,
860
+ attention_mask: Optional[torch.Tensor] = None,
861
+ position_ids: Optional[torch.LongTensor] = None,
862
+ past_key_values: Optional[Cache] = None,
863
+ inputs_embeds: Optional[torch.FloatTensor] = None,
864
+ labels: Optional[torch.LongTensor] = None,
865
+ use_cache: Optional[bool] = None,
866
+ output_attentions: Optional[bool] = None,
867
+ output_hidden_states: Optional[bool] = None,
868
+ ) -> SequenceClassifierOutputWithPast:
869
+ r"""
870
+ labels (`torch.LongTensor` of shape `(batch_size,)`, *optional*):
871
+ Labels for computing the sequence classification/regression loss. Indices should be in `[0, ...,
872
+ config.num_labels - 1]`. If `config.num_labels == 1` a regression loss is computed (Mean-Square loss),
873
+ If `config.num_labels > 1` a classification loss is computed (Cross-Entropy).
874
+ """
875
+ transformer_outputs: BaseModelOutputWithPast = self.model(
876
+ input_ids,
877
+ attention_mask=attention_mask,
878
+ position_ids=position_ids,
879
+ past_key_values=past_key_values,
880
+ inputs_embeds=inputs_embeds,
881
+ use_cache=use_cache,
882
+ output_attentions=output_attentions,
883
+ output_hidden_states=output_hidden_states,
884
+ )
885
+ hidden_states = transformer_outputs.last_hidden_state
886
+ logits = self.score(hidden_states)
887
+
888
+ if input_ids is not None:
889
+ batch_size = input_ids.shape[0]
890
+ else:
891
+ batch_size = inputs_embeds.shape[0]
892
+
893
+ if self.config.pad_token_id is None and batch_size != 1:
894
+ raise ValueError("Cannot handle batch sizes > 1 if no padding token is defined.")
895
+ if self.config.pad_token_id is None:
896
+ last_non_pad_token = -1
897
+ elif input_ids is not None:
898
+ non_pad_mask = (input_ids != self.config.pad_token_id).to(logits.device, torch.int32)
899
+ token_indices = torch.arange(input_ids.shape[-1], device=logits.device, dtype=torch.int32)
900
+ last_non_pad_token = (token_indices * non_pad_mask).argmax(-1)
901
+ else:
902
+ last_non_pad_token = -1
903
+ logger.warning_once(
904
+ f"{self.__class__.__name__} will not detect padding tokens in `inputs_embeds`. Results may be "
905
+ "unexpected if using padding tokens in conjunction with `inputs_embeds.`"
906
+ )
907
+
908
+ pooled_logits = logits[torch.arange(batch_size, device=logits.device), last_non_pad_token]
909
+
910
+ loss = None
911
+ if labels is not None:
912
+ loss = self.loss_function(logits=logits, labels=labels, pooled_logits=pooled_logits, config=self.config)
913
+
914
+ return SequenceClassifierOutputWithPast(
915
+ loss=loss,
916
+ logits=pooled_logits,
917
+ past_key_values=transformer_outputs.past_key_values,
918
+ hidden_states=transformer_outputs.hidden_states,
919
+ attentions=transformer_outputs.attentions,
920
+ )
921
+
922
+
923
+ @auto_docstring
924
+ class IQuestCoderForTokenClassification(IQuestCoderPreTrainedModel):
925
+ """IQuestCoder Model with a token classification head."""
926
+
927
+ def __init__(self, config: IQuestCoderConfig):
928
+ super().__init__(config)
929
+ self.num_labels = config.num_labels
930
+ self.model = IQuestCoderModel(config)
931
+ if getattr(config, "classifier_dropout", None) is not None:
932
+ classifier_dropout = config.classifier_dropout
933
+ elif getattr(config, "hidden_dropout", None) is not None:
934
+ classifier_dropout = config.hidden_dropout
935
+ else:
936
+ classifier_dropout = 0.1
937
+ self.dropout = nn.Dropout(classifier_dropout)
938
+ self.score = nn.Linear(config.hidden_size, config.num_labels)
939
+
940
+ # Initialize weights and apply final processing
941
+ self.post_init()
942
+
943
+ def get_input_embeddings(self) -> nn.Embedding:
944
+ return self.model.embed_tokens
945
+
946
+ def set_input_embeddings(self, value: nn.Embedding):
947
+ self.model.embed_tokens = value
948
+
949
+ @can_return_tuple
950
+ @auto_docstring
951
+ def forward(
952
+ self,
953
+ input_ids: Optional[torch.LongTensor] = None,
954
+ attention_mask: Optional[torch.Tensor] = None,
955
+ position_ids: Optional[torch.LongTensor] = None,
956
+ past_key_values: Optional[Cache] = None,
957
+ inputs_embeds: Optional[torch.FloatTensor] = None,
958
+ labels: Optional[torch.LongTensor] = None,
959
+ use_cache: Optional[bool] = None,
960
+ output_attentions: Optional[bool] = None,
961
+ output_hidden_states: Optional[bool] = None,
962
+ ) -> TokenClassifierOutput:
963
+ r"""
964
+ labels (`torch.LongTensor` of shape `(batch_size,)`, *optional*):
965
+ Labels for computing the sequence classification/regression loss. Indices should be in `[0, ...,
966
+ config.num_labels - 1]`. If `config.num_labels == 1` a regression loss is computed (Mean-Square loss),
967
+ If `config.num_labels > 1` a classification loss is computed (Cross-Entropy).
968
+ """
969
+ outputs: BaseModelOutputWithPast = self.model(
970
+ input_ids,
971
+ attention_mask=attention_mask,
972
+ position_ids=position_ids,
973
+ past_key_values=past_key_values,
974
+ inputs_embeds=inputs_embeds,
975
+ use_cache=use_cache,
976
+ output_attentions=output_attentions,
977
+ output_hidden_states=output_hidden_states,
978
+ )
979
+ sequence_output = outputs.last_hidden_state
980
+ sequence_output = self.dropout(sequence_output)
981
+ logits = self.score(sequence_output)
982
+
983
+ loss = None
984
+ if labels is not None:
985
+ loss = self.loss_function(logits, labels, self.config)
986
+
987
+ return TokenClassifierOutput(
988
+ loss=loss,
989
+ logits=logits,
990
+ hidden_states=outputs.hidden_states,
991
+ attentions=outputs.attentions,
992
+ )
993
+
994
+
995
+ @auto_docstring
996
+ class IQuestCoderForQuestionAnswering(IQuestCoderPreTrainedModel):
997
+ """IQuestCoder Model with a span classification head for extractive question-answering."""
998
+
999
+ base_model_prefix = "transformer"
1000
+
1001
+ def __init__(self, config: IQuestCoderConfig):
1002
+ super().__init__(config)
1003
+ self.transformer = IQuestCoderModel(config)
1004
+ self.qa_outputs = nn.Linear(config.hidden_size, 2)
1005
+
1006
+ # Initialize weights and apply final processing
1007
+ self.post_init()
1008
+
1009
+ def get_input_embeddings(self) -> nn.Embedding:
1010
+ return self.transformer.embed_tokens
1011
+
1012
+ def set_input_embeddings(self, value: nn.Embedding):
1013
+ self.transformer.embed_tokens = value
1014
+
1015
+ @can_return_tuple
1016
+ @auto_docstring
1017
+ def forward(
1018
+ self,
1019
+ input_ids: Optional[torch.LongTensor] = None,
1020
+ attention_mask: Optional[torch.Tensor] = None,
1021
+ position_ids: Optional[torch.LongTensor] = None,
1022
+ past_key_values: Optional[Cache] = None,
1023
+ inputs_embeds: Optional[torch.FloatTensor] = None,
1024
+ start_positions: Optional[torch.LongTensor] = None,
1025
+ end_positions: Optional[torch.LongTensor] = None,
1026
+ output_attentions: Optional[bool] = None,
1027
+ output_hidden_states: Optional[bool] = None,
1028
+ **kwargs,
1029
+ ) -> QuestionAnsweringModelOutput:
1030
+ outputs: BaseModelOutputWithPast = self.transformer(
1031
+ input_ids,
1032
+ attention_mask=attention_mask,
1033
+ position_ids=position_ids,
1034
+ past_key_values=past_key_values,
1035
+ inputs_embeds=inputs_embeds,
1036
+ output_attentions=output_attentions,
1037
+ output_hidden_states=output_hidden_states,
1038
+ )
1039
+
1040
+ sequence_output = outputs.last_hidden_state
1041
+
1042
+ logits = self.qa_outputs(sequence_output)
1043
+ start_logits, end_logits = logits.split(1, dim=-1)
1044
+ start_logits = start_logits.squeeze(-1).contiguous()
1045
+ end_logits = end_logits.squeeze(-1).contiguous()
1046
+
1047
+ loss = None
1048
+ if start_positions is not None and end_positions is not None:
1049
+ loss = self.loss_function(start_logits, end_logits, start_positions, end_positions, **kwargs)
1050
+
1051
+ return QuestionAnsweringModelOutput(
1052
+ loss=loss,
1053
+ start_logits=start_logits,
1054
+ end_logits=end_logits,
1055
+ hidden_states=outputs.hidden_states,
1056
+ attentions=outputs.attentions,
1057
+ )
1058
+
1059
+
1060
+ __all__ = [
1061
+ "IQuestCoderPreTrainedModel",
1062
+ "IQuestCoderModel",
1063
+ "IQuestCoderForCausalLM",
1064
+ "IQuestCoderForSequenceClassification",
1065
+ "IQuestCoderForTokenClassification",
1066
+ "IQuestCoderForQuestionAnswering",
1067
+ ]
1068
+