Upload InternLM3ForCausalLM
Browse files- README.md +199 -0
- config.json +62 -0
- configuration_internlm3.py +197 -0
- generation_config.json +9 -0
- model-00001-of-00002.safetensors +3 -0
- model-00002-of-00002.safetensors +3 -0
- model.safetensors.index.json +0 -0
README.md
ADDED
@@ -0,0 +1,199 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
library_name: transformers
|
3 |
+
tags: []
|
4 |
+
---
|
5 |
+
|
6 |
+
# Model Card for Model ID
|
7 |
+
|
8 |
+
<!-- Provide a quick summary of what the model is/does. -->
|
9 |
+
|
10 |
+
|
11 |
+
|
12 |
+
## Model Details
|
13 |
+
|
14 |
+
### Model Description
|
15 |
+
|
16 |
+
<!-- Provide a longer summary of what this model is. -->
|
17 |
+
|
18 |
+
This is the model card of a 🤗 transformers model that has been pushed on the Hub. This model card has been automatically generated.
|
19 |
+
|
20 |
+
- **Developed by:** [More Information Needed]
|
21 |
+
- **Funded by [optional]:** [More Information Needed]
|
22 |
+
- **Shared by [optional]:** [More Information Needed]
|
23 |
+
- **Model type:** [More Information Needed]
|
24 |
+
- **Language(s) (NLP):** [More Information Needed]
|
25 |
+
- **License:** [More Information Needed]
|
26 |
+
- **Finetuned from model [optional]:** [More Information Needed]
|
27 |
+
|
28 |
+
### Model Sources [optional]
|
29 |
+
|
30 |
+
<!-- Provide the basic links for the model. -->
|
31 |
+
|
32 |
+
- **Repository:** [More Information Needed]
|
33 |
+
- **Paper [optional]:** [More Information Needed]
|
34 |
+
- **Demo [optional]:** [More Information Needed]
|
35 |
+
|
36 |
+
## Uses
|
37 |
+
|
38 |
+
<!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
|
39 |
+
|
40 |
+
### Direct Use
|
41 |
+
|
42 |
+
<!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
|
43 |
+
|
44 |
+
[More Information Needed]
|
45 |
+
|
46 |
+
### Downstream Use [optional]
|
47 |
+
|
48 |
+
<!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
|
49 |
+
|
50 |
+
[More Information Needed]
|
51 |
+
|
52 |
+
### Out-of-Scope Use
|
53 |
+
|
54 |
+
<!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
|
55 |
+
|
56 |
+
[More Information Needed]
|
57 |
+
|
58 |
+
## Bias, Risks, and Limitations
|
59 |
+
|
60 |
+
<!-- This section is meant to convey both technical and sociotechnical limitations. -->
|
61 |
+
|
62 |
+
[More Information Needed]
|
63 |
+
|
64 |
+
### Recommendations
|
65 |
+
|
66 |
+
<!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
|
67 |
+
|
68 |
+
Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
|
69 |
+
|
70 |
+
## How to Get Started with the Model
|
71 |
+
|
72 |
+
Use the code below to get started with the model.
|
73 |
+
|
74 |
+
[More Information Needed]
|
75 |
+
|
76 |
+
## Training Details
|
77 |
+
|
78 |
+
### Training Data
|
79 |
+
|
80 |
+
<!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
|
81 |
+
|
82 |
+
[More Information Needed]
|
83 |
+
|
84 |
+
### Training Procedure
|
85 |
+
|
86 |
+
<!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
|
87 |
+
|
88 |
+
#### Preprocessing [optional]
|
89 |
+
|
90 |
+
[More Information Needed]
|
91 |
+
|
92 |
+
|
93 |
+
#### Training Hyperparameters
|
94 |
+
|
95 |
+
- **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
|
96 |
+
|
97 |
+
#### Speeds, Sizes, Times [optional]
|
98 |
+
|
99 |
+
<!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
|
100 |
+
|
101 |
+
[More Information Needed]
|
102 |
+
|
103 |
+
## Evaluation
|
104 |
+
|
105 |
+
<!-- This section describes the evaluation protocols and provides the results. -->
|
106 |
+
|
107 |
+
### Testing Data, Factors & Metrics
|
108 |
+
|
109 |
+
#### Testing Data
|
110 |
+
|
111 |
+
<!-- This should link to a Dataset Card if possible. -->
|
112 |
+
|
113 |
+
[More Information Needed]
|
114 |
+
|
115 |
+
#### Factors
|
116 |
+
|
117 |
+
<!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
|
118 |
+
|
119 |
+
[More Information Needed]
|
120 |
+
|
121 |
+
#### Metrics
|
122 |
+
|
123 |
+
<!-- These are the evaluation metrics being used, ideally with a description of why. -->
|
124 |
+
|
125 |
+
[More Information Needed]
|
126 |
+
|
127 |
+
### Results
|
128 |
+
|
129 |
+
[More Information Needed]
|
130 |
+
|
131 |
+
#### Summary
|
132 |
+
|
133 |
+
|
134 |
+
|
135 |
+
## Model Examination [optional]
|
136 |
+
|
137 |
+
<!-- Relevant interpretability work for the model goes here -->
|
138 |
+
|
139 |
+
[More Information Needed]
|
140 |
+
|
141 |
+
## Environmental Impact
|
142 |
+
|
143 |
+
<!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
|
144 |
+
|
145 |
+
Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
|
146 |
+
|
147 |
+
- **Hardware Type:** [More Information Needed]
|
148 |
+
- **Hours used:** [More Information Needed]
|
149 |
+
- **Cloud Provider:** [More Information Needed]
|
150 |
+
- **Compute Region:** [More Information Needed]
|
151 |
+
- **Carbon Emitted:** [More Information Needed]
|
152 |
+
|
153 |
+
## Technical Specifications [optional]
|
154 |
+
|
155 |
+
### Model Architecture and Objective
|
156 |
+
|
157 |
+
[More Information Needed]
|
158 |
+
|
159 |
+
### Compute Infrastructure
|
160 |
+
|
161 |
+
[More Information Needed]
|
162 |
+
|
163 |
+
#### Hardware
|
164 |
+
|
165 |
+
[More Information Needed]
|
166 |
+
|
167 |
+
#### Software
|
168 |
+
|
169 |
+
[More Information Needed]
|
170 |
+
|
171 |
+
## Citation [optional]
|
172 |
+
|
173 |
+
<!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
|
174 |
+
|
175 |
+
**BibTeX:**
|
176 |
+
|
177 |
+
[More Information Needed]
|
178 |
+
|
179 |
+
**APA:**
|
180 |
+
|
181 |
+
[More Information Needed]
|
182 |
+
|
183 |
+
## Glossary [optional]
|
184 |
+
|
185 |
+
<!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
|
186 |
+
|
187 |
+
[More Information Needed]
|
188 |
+
|
189 |
+
## More Information [optional]
|
190 |
+
|
191 |
+
[More Information Needed]
|
192 |
+
|
193 |
+
## Model Card Authors [optional]
|
194 |
+
|
195 |
+
[More Information Needed]
|
196 |
+
|
197 |
+
## Model Card Contact
|
198 |
+
|
199 |
+
[More Information Needed]
|
config.json
ADDED
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_name_or_path": "./tmp_autoround_gptq",
|
3 |
+
"architectures": [
|
4 |
+
"InternLM3ForCausalLM"
|
5 |
+
],
|
6 |
+
"attention_dropout": 0.0,
|
7 |
+
"auto_map": {
|
8 |
+
"AutoConfig": "configuration_internlm3.InternLM3Config",
|
9 |
+
"AutoModel": "modeling_internlm3.InternLM3Model",
|
10 |
+
"AutoModelForCausalLM": "modeling_internlm3.InternLM3ForCausalLM"
|
11 |
+
},
|
12 |
+
"bias": false,
|
13 |
+
"bos_token_id": 1,
|
14 |
+
"eos_token_id": 2,
|
15 |
+
"head_dim": 128,
|
16 |
+
"hidden_act": "silu",
|
17 |
+
"hidden_size": 4096,
|
18 |
+
"initializer_range": 0.02,
|
19 |
+
"intermediate_size": 10240,
|
20 |
+
"max_position_embeddings": 32768,
|
21 |
+
"model_type": "internlm3",
|
22 |
+
"num_attention_heads": 32,
|
23 |
+
"num_hidden_layers": 48,
|
24 |
+
"num_key_value_heads": 2,
|
25 |
+
"pad_token_id": 2,
|
26 |
+
"qkv_bias": false,
|
27 |
+
"quantization_config": {
|
28 |
+
"batch_size": 4,
|
29 |
+
"bits": 4,
|
30 |
+
"block_name_to_quantize": null,
|
31 |
+
"cache_block_outputs": true,
|
32 |
+
"damp_percent": 0.01,
|
33 |
+
"dataset": null,
|
34 |
+
"desc_act": false,
|
35 |
+
"exllama_config": {
|
36 |
+
"version": 1
|
37 |
+
},
|
38 |
+
"group_size": 128,
|
39 |
+
"max_input_length": null,
|
40 |
+
"model_seqlen": null,
|
41 |
+
"module_name_preceding_first_block": null,
|
42 |
+
"modules_in_block_to_quantize": null,
|
43 |
+
"pad_token_id": null,
|
44 |
+
"quant_method": "gptq",
|
45 |
+
"sym": true,
|
46 |
+
"tokenizer": null,
|
47 |
+
"true_sequential": false,
|
48 |
+
"use_cuda_fp16": false,
|
49 |
+
"use_exllama": true
|
50 |
+
},
|
51 |
+
"rms_norm_eps": 1e-05,
|
52 |
+
"rope_scaling": {
|
53 |
+
"factor": 6.0,
|
54 |
+
"rope_type": "dynamic"
|
55 |
+
},
|
56 |
+
"rope_theta": 50000000,
|
57 |
+
"tie_word_embeddings": false,
|
58 |
+
"torch_dtype": "bfloat16",
|
59 |
+
"transformers_version": "4.48.0",
|
60 |
+
"use_cache": true,
|
61 |
+
"vocab_size": 128512
|
62 |
+
}
|
configuration_internlm3.py
ADDED
@@ -0,0 +1,197 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# coding=utf-8
|
2 |
+
# Copyright (c) The InternLM team and The HuggingFace Inc. team. All rights reserved.
|
3 |
+
#
|
4 |
+
# This code is based on transformers/src/transformers/models/llama/configuration_llama.py
|
5 |
+
#
|
6 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7 |
+
# you may not use this file except in compliance with the License.
|
8 |
+
# You may obtain a copy of the License at
|
9 |
+
#
|
10 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11 |
+
#
|
12 |
+
# Unless required by applicable law or agreed to in writing, software
|
13 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15 |
+
# See the License for the specific language governing permissions and
|
16 |
+
# limitations under the License.
|
17 |
+
""" InternLM3 model configuration"""
|
18 |
+
|
19 |
+
from transformers.configuration_utils import PretrainedConfig
|
20 |
+
from transformers.modeling_rope_utils import rope_config_validation
|
21 |
+
from transformers.utils import logging
|
22 |
+
|
23 |
+
|
24 |
+
logger = logging.get_logger(__name__)
|
25 |
+
|
26 |
+
|
27 |
+
class InternLM3Config(PretrainedConfig):
|
28 |
+
r"""
|
29 |
+
This is the configuration class to store the configuration of a [`InternLM2Model`]. It is used to instantiate
|
30 |
+
an InternLM2 model according to the specified arguments, defining the model architecture. Instantiating a
|
31 |
+
configuration with the defaults will yield a similar configuration to that of the InternLM2-7B.
|
32 |
+
|
33 |
+
Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the
|
34 |
+
documentation from [`PretrainedConfig`] for more information.
|
35 |
+
|
36 |
+
|
37 |
+
Args:
|
38 |
+
vocab_size (`int`, *optional*, defaults to 151936):
|
39 |
+
Vocabulary size of the InternLM3 model. Defines the number of different tokens that can be represented by the
|
40 |
+
`inputs_ids` passed when calling [`InternLM3Model`]
|
41 |
+
hidden_size (`int`, *optional*, defaults to 4096):
|
42 |
+
Dimension of the hidden representations.
|
43 |
+
intermediate_size (`int`, *optional*, defaults to 22016):
|
44 |
+
Dimension of the MLP representations.
|
45 |
+
num_hidden_layers (`int`, *optional*, defaults to 32):
|
46 |
+
Number of hidden layers in the Transformer encoder.
|
47 |
+
num_attention_heads (`int`, *optional*, defaults to 32):
|
48 |
+
Number of attention heads for each attention layer in the Transformer encoder.
|
49 |
+
num_key_value_heads (`int`, *optional*, defaults to 32):
|
50 |
+
This is the number of key_value heads that should be used to implement Grouped Query Attention. If
|
51 |
+
`num_key_value_heads=num_attention_heads`, the model will use Multi Head Attention (MHA), if
|
52 |
+
`num_key_value_heads=1` the model will use Multi Query Attention (MQA) otherwise GQA is used. When
|
53 |
+
converting a multi-head checkpoint to a GQA checkpoint, each group key and value head should be constructed
|
54 |
+
by meanpooling all the original heads within that group. For more details checkout [this
|
55 |
+
paper](https://arxiv.org/pdf/2305.13245.pdf). If it is not specified, will default to `32`.
|
56 |
+
hidden_act (`str` or `function`, *optional*, defaults to `"silu"`):
|
57 |
+
The non-linear activation function (function or string) in the decoder.
|
58 |
+
max_position_embeddings (`int`, *optional*, defaults to 32768):
|
59 |
+
The maximum sequence length that this model might ever be used with.
|
60 |
+
initializer_range (`float`, *optional*, defaults to 0.02):
|
61 |
+
The standard deviation of the truncated_normal_initializer for initializing all weight matrices.
|
62 |
+
rms_norm_eps (`float`, *optional*, defaults to 1e-06):
|
63 |
+
The epsilon used by the rms normalization layers.
|
64 |
+
use_cache (`bool`, *optional*, defaults to `True`):
|
65 |
+
Whether or not the model should return the last key/values attentions (not used by all models). Only
|
66 |
+
relevant if `config.is_decoder=True`.
|
67 |
+
tie_word_embeddings (`bool`, *optional*, defaults to `False`):
|
68 |
+
Whether the model's input and output word embeddings should be tied.
|
69 |
+
rope_theta (`float`, *optional*, defaults to 10000.0):
|
70 |
+
The base period of the RoPE embeddings.
|
71 |
+
rope_scaling (`Dict`, *optional*):
|
72 |
+
Dictionary containing the scaling configuration for the RoPE embeddings. NOTE: if you apply new rope type
|
73 |
+
and you expect the model to work on longer `max_position_embeddings`, we recommend you to update this value
|
74 |
+
accordingly.
|
75 |
+
Expected contents:
|
76 |
+
`rope_type` (`str`):
|
77 |
+
The sub-variant of RoPE to use. Can be one of ['default', 'linear', 'dynamic', 'yarn', 'longrope',
|
78 |
+
'llama3'], with 'default' being the original RoPE implementation.
|
79 |
+
`factor` (`float`, *optional*):
|
80 |
+
Used with all rope types except 'default'. The scaling factor to apply to the RoPE embeddings. In
|
81 |
+
most scaling types, a `factor` of x will enable the model to handle sequences of length x *
|
82 |
+
original maximum pre-trained length.
|
83 |
+
`original_max_position_embeddings` (`int`, *optional*):
|
84 |
+
Used with 'dynamic', 'longrope' and 'llama3'. The original max position embeddings used during
|
85 |
+
pretraining.
|
86 |
+
`attention_factor` (`float`, *optional*):
|
87 |
+
Used with 'yarn' and 'longrope'. The scaling factor to be applied on the attention
|
88 |
+
computation. If unspecified, it defaults to value recommended by the implementation, using the
|
89 |
+
`factor` field to infer the suggested value.
|
90 |
+
`beta_fast` (`float`, *optional*):
|
91 |
+
Only used with 'yarn'. Parameter to set the boundary for extrapolation (only) in the linear
|
92 |
+
ramp function. If unspecified, it defaults to 32.
|
93 |
+
`beta_slow` (`float`, *optional*):
|
94 |
+
Only used with 'yarn'. Parameter to set the boundary for interpolation (only) in the linear
|
95 |
+
ramp function. If unspecified, it defaults to 1.
|
96 |
+
`short_factor` (`List[float]`, *optional*):
|
97 |
+
Only used with 'longrope'. The scaling factor to be applied to short contexts (<
|
98 |
+
`original_max_position_embeddings`). Must be a list of numbers with the same length as the hidden
|
99 |
+
size divided by the number of attention heads divided by 2
|
100 |
+
`long_factor` (`List[float]`, *optional*):
|
101 |
+
Only used with 'longrope'. The scaling factor to be applied to long contexts (<
|
102 |
+
`original_max_position_embeddings`). Must be a list of numbers with the same length as the hidden
|
103 |
+
size divided by the number of attention heads divided by 2
|
104 |
+
`low_freq_factor` (`float`, *optional*):
|
105 |
+
Only used with 'llama3'. Scaling factor applied to low frequency components of the RoPE
|
106 |
+
`high_freq_factor` (`float`, *optional*):
|
107 |
+
Only used with 'llama3'. Scaling factor applied to high frequency components of the RoPE
|
108 |
+
qkv_bias (`bool`, *optional*, defaults to `False`):
|
109 |
+
Whether to use a bias in the query, key and value projection layers during self-attention.
|
110 |
+
attention_dropout (`float`, *optional*, defaults to 0.0):
|
111 |
+
The dropout ratio for the attention probabilities.
|
112 |
+
bias (`bool`, *optional*, defaults to `False`):
|
113 |
+
Whether to use a bias in o_proj, up_proj, down_proj and gate_proj layers.
|
114 |
+
head_dim (`int`, *optional*):
|
115 |
+
The attention head dimension. If None, it will default to hidden_size // num_heads
|
116 |
+
|
117 |
+
```python
|
118 |
+
>>> from transformers import InternLM3Model, InternLM3Config
|
119 |
+
|
120 |
+
>>> # Initializing a InternLM3 style configuration
|
121 |
+
>>> configuration = InternLM3Config()
|
122 |
+
|
123 |
+
>>> # Initializing a model from the InternLM3-8B style configuration
|
124 |
+
>>> model = InternLM3Model(configuration)
|
125 |
+
|
126 |
+
>>> # Accessing the model configuration
|
127 |
+
>>> configuration = model.config
|
128 |
+
```"""
|
129 |
+
|
130 |
+
model_type = "internlm3"
|
131 |
+
keys_to_ignore_at_inference = ["past_key_values"]
|
132 |
+
|
133 |
+
# Default tensor parallel plan for base model `InternLM3`
|
134 |
+
base_model_tp_plan = {
|
135 |
+
"layers.*.self_attn.q_proj": "colwise",
|
136 |
+
"layers.*.self_attn.k_proj": "colwise",
|
137 |
+
"layers.*.self_attn.v_proj": "colwise",
|
138 |
+
"layers.*.self_attn.o_proj": "rowwise",
|
139 |
+
"layers.*.mlp.gate_proj": "colwise",
|
140 |
+
"layers.*.mlp.up_proj": "colwise",
|
141 |
+
"layers.*.mlp.down_proj": "rowwise",
|
142 |
+
}
|
143 |
+
|
144 |
+
def __init__(
|
145 |
+
self,
|
146 |
+
vocab_size=128512,
|
147 |
+
hidden_size=4096,
|
148 |
+
intermediate_size=11008,
|
149 |
+
num_hidden_layers=32,
|
150 |
+
num_attention_heads=32,
|
151 |
+
num_key_value_heads=32,
|
152 |
+
hidden_act="silu",
|
153 |
+
max_position_embeddings=32768,
|
154 |
+
initializer_range=0.02,
|
155 |
+
rms_norm_eps=1e-6,
|
156 |
+
use_cache=True,
|
157 |
+
tie_word_embeddings=False,
|
158 |
+
rope_theta=10000.0,
|
159 |
+
rope_scaling=None,
|
160 |
+
qkv_bias=False,
|
161 |
+
attention_dropout=0.0,
|
162 |
+
bias=False,
|
163 |
+
head_dim=None,
|
164 |
+
**kwargs,
|
165 |
+
):
|
166 |
+
self.vocab_size = vocab_size
|
167 |
+
self.max_position_embeddings = max_position_embeddings
|
168 |
+
self.hidden_size = hidden_size
|
169 |
+
self.intermediate_size = intermediate_size
|
170 |
+
self.num_hidden_layers = num_hidden_layers
|
171 |
+
self.num_attention_heads = num_attention_heads
|
172 |
+
|
173 |
+
# for backward compatibility
|
174 |
+
if num_key_value_heads is None:
|
175 |
+
num_key_value_heads = num_attention_heads
|
176 |
+
|
177 |
+
self.num_key_value_heads = num_key_value_heads
|
178 |
+
self.hidden_act = hidden_act
|
179 |
+
self.initializer_range = initializer_range
|
180 |
+
self.rms_norm_eps = rms_norm_eps
|
181 |
+
self.use_cache = use_cache
|
182 |
+
self.rope_theta = rope_theta
|
183 |
+
self.rope_scaling = rope_scaling
|
184 |
+
self.qkv_bias = qkv_bias
|
185 |
+
self.attention_dropout = attention_dropout
|
186 |
+
self.bias = bias
|
187 |
+
self.head_dim = head_dim if head_dim is not None else self.hidden_size // self.num_attention_heads
|
188 |
+
# Validate the correctness of rotary position embeddings parameters
|
189 |
+
# BC: if there is a 'type' field, move it to 'rope_type'.
|
190 |
+
if self.rope_scaling is not None and "type" in self.rope_scaling:
|
191 |
+
self.rope_scaling["rope_type"] = self.rope_scaling["type"]
|
192 |
+
rope_config_validation(self)
|
193 |
+
|
194 |
+
super().__init__(
|
195 |
+
tie_word_embeddings=tie_word_embeddings,
|
196 |
+
**kwargs,
|
197 |
+
)
|
generation_config.json
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"bos_token_id": 1,
|
3 |
+
"eos_token_id": [
|
4 |
+
2,
|
5 |
+
128131
|
6 |
+
],
|
7 |
+
"pad_token_id": 2,
|
8 |
+
"transformers_version": "4.48.0"
|
9 |
+
}
|
model-00001-of-00002.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:4a08153833ba78a67e6887325ddc833ed6c3d14f7b0f9df4f9d7bc472bcbc857
|
3 |
+
size 4981451320
|
model-00002-of-00002.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:e43e2ac30a44d9261dc52e1660f47044a28c5e31e88f2faa0ade1f34c9c1eb0d
|
3 |
+
size 1158656104
|
model.safetensors.index.json
ADDED
The diff for this file is too large to render.
See raw diff
|
|