phuongnv commited on
Commit
595707a
1 Parent(s): e0b2f30

Upload InternLM2ForCausalLM

Browse files
config.json ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "AI4Chem/ChemLLM-7B-Chat-1.5-SFT",
3
+ "architectures": [
4
+ "InternLM2ForCausalLM"
5
+ ],
6
+ "auto_map": {
7
+ "AutoConfig": "configuration_internlm.InternLMConfig",
8
+ "AutoModel": "AI4Chem/ChemLLM-7B-Chat-1.5-SFT--modeling_internlm2.InternLM2ForCausalLM",
9
+ "AutoModelForCausalLM": "modeling_internlm2.InternLM2ForCausalLM"
10
+ },
11
+ "bias": false,
12
+ "bos_token_id": 1,
13
+ "eos_token_id": 2,
14
+ "hidden_act": "silu",
15
+ "hidden_size": 4096,
16
+ "initializer_range": 0.02,
17
+ "intermediate_size": 14336,
18
+ "max_position_embeddings": 32768,
19
+ "model_type": "internlm",
20
+ "num_attention_heads": 32,
21
+ "num_hidden_layers": 32,
22
+ "num_key_value_heads": 8,
23
+ "pad_token_id": 2,
24
+ "quantization_config": {
25
+ "_load_in_4bit": true,
26
+ "_load_in_8bit": false,
27
+ "bnb_4bit_compute_dtype": "float16",
28
+ "bnb_4bit_quant_storage": "uint8",
29
+ "bnb_4bit_quant_type": "nf4",
30
+ "bnb_4bit_use_double_quant": false,
31
+ "llm_int8_enable_fp32_cpu_offload": false,
32
+ "llm_int8_has_fp16_weight": false,
33
+ "llm_int8_skip_modules": null,
34
+ "llm_int8_threshold": 6.0,
35
+ "load_in_4bit": true,
36
+ "load_in_8bit": false,
37
+ "quant_method": "bitsandbytes"
38
+ },
39
+ "rms_norm_eps": 1e-05,
40
+ "rope_scaling": {
41
+ "base": 1000000,
42
+ "type": "dynamic"
43
+ },
44
+ "rotary": {
45
+ "base": 1000000,
46
+ "type": "dynamic"
47
+ },
48
+ "tie_word_embeddings": false,
49
+ "torch_dtype": "float16",
50
+ "transformers_version": "4.40.0",
51
+ "use_cache": true,
52
+ "vocab_size": 92544
53
+ }
configuration_internlm.py ADDED
@@ -0,0 +1,135 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # coding=utf-8
2
+ # Copyright (c) InternLM. All rights reserved.
3
+ #
4
+ # This code is based on EleutherAI's GPT-NeoX library and the GPT-NeoX
5
+ # and OPT implementations in this library. It has been modified from its
6
+ # original forms to accommodate minor architectural differences compared
7
+ # to GPT-NeoX and OPT used by the Meta AI team that trained the model.
8
+ #
9
+ # Licensed under the Apache License, Version 2.0 (the "License");
10
+ # you may not use this file except in compliance with the License.
11
+ # You may obtain a copy of the License at
12
+ #
13
+ # http://www.apache.org/licenses/LICENSE-2.0
14
+ #
15
+ # Unless required by applicable law or agreed to in writing, software
16
+ # distributed under the License is distributed on an "AS IS" BASIS,
17
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
+ # See the License for the specific language governing permissions and
19
+ # limitations under the License.
20
+ """ InternLM model configuration"""
21
+
22
+ from transformers.configuration_utils import PretrainedConfig
23
+ from transformers.utils import logging
24
+
25
+ logger = logging.get_logger(__name__)
26
+
27
+ INTERNLM_PRETRAINED_CONFIG_ARCHIVE_MAP = {}
28
+
29
+
30
+ class InternLMConfig(PretrainedConfig):
31
+ r"""
32
+ This is the configuration class to store the configuration of a [`InternLMModel`]. It is used to instantiate
33
+ an InternLM model according to the specified arguments, defining the model architecture. Instantiating a
34
+ configuration with the defaults will yield a similar configuration to that of the InternLM-7B.
35
+
36
+ Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the
37
+ documentation from [`PretrainedConfig`] for more information.
38
+
39
+
40
+ Args:
41
+ vocab_size (`int`, *optional*, defaults to 32000):
42
+ Vocabulary size of the InternLM model. Defines the number of different tokens that can be represented by the
43
+ `inputs_ids` passed when calling [`InternLMModel`]
44
+ hidden_size (`int`, *optional*, defaults to 4096):
45
+ Dimension of the hidden representations.
46
+ intermediate_size (`int`, *optional*, defaults to 11008):
47
+ Dimension of the MLP representations.
48
+ num_hidden_layers (`int`, *optional*, defaults to 32):
49
+ Number of hidden layers in the Transformer encoder.
50
+ num_attention_heads (`int`, *optional*, defaults to 32):
51
+ Number of attention heads for each attention layer in the Transformer encoder.
52
+ num_key_value_heads (`int`, *optional*):
53
+ This is the number of key_value heads that should be used to implement Grouped Query Attention. If
54
+ `num_key_value_heads=num_attention_heads`, the model will use Multi Head Attention (MHA), if
55
+ `num_key_value_heads=1 the model will use Multi Query Attention (MQA) otherwise GQA is used. When
56
+ converting a multi-head checkpoint to a GQA checkpoint, each group key and value head should be constructed
57
+ by meanpooling all the original heads within that group. For more details checkout [this
58
+ paper](https://arxiv.org/pdf/2305.13245.pdf). If it is not specified, will default to
59
+ `num_attention_heads`.
60
+ hidden_act (`str` or `function`, *optional*, defaults to `"silu"`):
61
+ The non-linear activation function (function or string) in the decoder.
62
+ max_position_embeddings (`int`, *optional*, defaults to 2048):
63
+ The maximum sequence length that this model might ever be used with. Typically set this to something large
64
+ just in case (e.g., 512 or 1024 or 2048).
65
+ initializer_range (`float`, *optional*, defaults to 0.02):
66
+ The standard deviation of the truncated_normal_initializer for initializing all weight matrices.
67
+ rms_norm_eps (`float`, *optional*, defaults to 1e-12):
68
+ The epsilon used by the rms normalization layers.
69
+ use_cache (`bool`, *optional*, defaults to `True`):
70
+ Whether or not the model should return the last key/values attentions (not used by all models). Only
71
+ relevant if `config.is_decoder=True`.
72
+ tie_word_embeddings(`bool`, *optional*, defaults to `False`):
73
+ Whether to tie weight embeddings
74
+ Example:
75
+
76
+ ```python
77
+ >>> from transformers import InternLMModel, InternLMConfig
78
+
79
+ >>> # Initializing a InternLM internlm-7b style configuration
80
+ >>> configuration = InternLMConfig()
81
+
82
+ >>> # Initializing a model from the internlm-7b style configuration
83
+ >>> model = InternLMModel(configuration)
84
+
85
+ >>> # Accessing the model configuration
86
+ >>> configuration = model.config
87
+ ```"""
88
+ model_type = "internlm"
89
+ _auto_class = "AutoConfig"
90
+
91
+ def __init__( # pylint: disable=W0102
92
+ self,
93
+ vocab_size=103168,
94
+ hidden_size=4096,
95
+ intermediate_size=11008,
96
+ num_hidden_layers=32,
97
+ num_attention_heads=32,
98
+ num_key_value_heads=None,
99
+ hidden_act="silu",
100
+ max_position_embeddings=2048,
101
+ initializer_range=0.02,
102
+ rms_norm_eps=1e-6,
103
+ use_cache=True,
104
+ pad_token_id=0,
105
+ bos_token_id=1,
106
+ eos_token_id=2,
107
+ tie_word_embeddings=False,
108
+ bias=True,
109
+ rotary={"base": 10000, "type": "dynamic"}, # pylint: disable=W0102
110
+ **kwargs,
111
+ ):
112
+ self.vocab_size = vocab_size
113
+ self.max_position_embeddings = max_position_embeddings
114
+ self.hidden_size = hidden_size
115
+ self.intermediate_size = intermediate_size
116
+ self.num_hidden_layers = num_hidden_layers
117
+ self.num_attention_heads = num_attention_heads
118
+
119
+ if num_key_value_heads is None:
120
+ num_key_value_heads = num_attention_heads
121
+ self.num_key_value_heads = num_key_value_heads
122
+
123
+ self.hidden_act = hidden_act
124
+ self.initializer_range = initializer_range
125
+ self.rms_norm_eps = rms_norm_eps
126
+ self.use_cache = use_cache
127
+ self.bias = bias
128
+ self.rotary = self.rope_scaling = rotary
129
+ super().__init__(
130
+ pad_token_id=pad_token_id,
131
+ bos_token_id=bos_token_id,
132
+ eos_token_id=eos_token_id,
133
+ tie_word_embeddings=tie_word_embeddings,
134
+ **kwargs,
135
+ )
generation_config.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "bos_token_id": 1,
4
+ "eos_token_id": 2,
5
+ "pad_token_id": 2,
6
+ "transformers_version": "4.40.0"
7
+ }
model-00001-of-00003.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d85637a38f8403535475bd70571cd8a34c5e29504f1b233117a6a8636014d3dc
3
+ size 1999308009
model-00002-of-00003.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:89ad05979748373dbc9c1542f1d6355af5e53dbcda125585cf4f30f9b20c7cb2
3
+ size 1972687809
model-00003-of-00003.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ca7134150eb009ed705e27efbd12bdf7ce7e72a9d19933570667bdda122a516b
3
+ size 1470753326
model.safetensors.index.json ADDED
@@ -0,0 +1,714 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "metadata": {
3
+ "total_size": 5442665216
4
+ },
5
+ "weight_map": {
6
+ "model.layers.0.attention.wo.weight": "model-00001-of-00003.safetensors",
7
+ "model.layers.0.attention.wo.weight.absmax": "model-00001-of-00003.safetensors",
8
+ "model.layers.0.attention.wo.weight.quant_map": "model-00001-of-00003.safetensors",
9
+ "model.layers.0.attention.wo.weight.quant_state.bitsandbytes__nf4": "model-00001-of-00003.safetensors",
10
+ "model.layers.0.attention.wqkv.weight": "model-00001-of-00003.safetensors",
11
+ "model.layers.0.attention.wqkv.weight.absmax": "model-00001-of-00003.safetensors",
12
+ "model.layers.0.attention.wqkv.weight.quant_map": "model-00001-of-00003.safetensors",
13
+ "model.layers.0.attention.wqkv.weight.quant_state.bitsandbytes__nf4": "model-00001-of-00003.safetensors",
14
+ "model.layers.0.attention_norm.weight": "model-00001-of-00003.safetensors",
15
+ "model.layers.0.feed_forward.w1.weight": "model-00001-of-00003.safetensors",
16
+ "model.layers.0.feed_forward.w1.weight.absmax": "model-00001-of-00003.safetensors",
17
+ "model.layers.0.feed_forward.w1.weight.quant_map": "model-00001-of-00003.safetensors",
18
+ "model.layers.0.feed_forward.w1.weight.quant_state.bitsandbytes__nf4": "model-00001-of-00003.safetensors",
19
+ "model.layers.0.feed_forward.w2.weight": "model-00001-of-00003.safetensors",
20
+ "model.layers.0.feed_forward.w2.weight.absmax": "model-00001-of-00003.safetensors",
21
+ "model.layers.0.feed_forward.w2.weight.quant_map": "model-00001-of-00003.safetensors",
22
+ "model.layers.0.feed_forward.w2.weight.quant_state.bitsandbytes__nf4": "model-00001-of-00003.safetensors",
23
+ "model.layers.0.feed_forward.w3.weight": "model-00001-of-00003.safetensors",
24
+ "model.layers.0.feed_forward.w3.weight.absmax": "model-00001-of-00003.safetensors",
25
+ "model.layers.0.feed_forward.w3.weight.quant_map": "model-00001-of-00003.safetensors",
26
+ "model.layers.0.feed_forward.w3.weight.quant_state.bitsandbytes__nf4": "model-00001-of-00003.safetensors",
27
+ "model.layers.0.ffn_norm.weight": "model-00001-of-00003.safetensors",
28
+ "model.layers.1.attention.wo.weight": "model-00001-of-00003.safetensors",
29
+ "model.layers.1.attention.wo.weight.absmax": "model-00001-of-00003.safetensors",
30
+ "model.layers.1.attention.wo.weight.quant_map": "model-00001-of-00003.safetensors",
31
+ "model.layers.1.attention.wo.weight.quant_state.bitsandbytes__nf4": "model-00001-of-00003.safetensors",
32
+ "model.layers.1.attention.wqkv.weight": "model-00001-of-00003.safetensors",
33
+ "model.layers.1.attention.wqkv.weight.absmax": "model-00001-of-00003.safetensors",
34
+ "model.layers.1.attention.wqkv.weight.quant_map": "model-00001-of-00003.safetensors",
35
+ "model.layers.1.attention.wqkv.weight.quant_state.bitsandbytes__nf4": "model-00001-of-00003.safetensors",
36
+ "model.layers.1.attention_norm.weight": "model-00001-of-00003.safetensors",
37
+ "model.layers.1.feed_forward.w1.weight": "model-00001-of-00003.safetensors",
38
+ "model.layers.1.feed_forward.w1.weight.absmax": "model-00001-of-00003.safetensors",
39
+ "model.layers.1.feed_forward.w1.weight.quant_map": "model-00001-of-00003.safetensors",
40
+ "model.layers.1.feed_forward.w1.weight.quant_state.bitsandbytes__nf4": "model-00001-of-00003.safetensors",
41
+ "model.layers.1.feed_forward.w2.weight": "model-00001-of-00003.safetensors",
42
+ "model.layers.1.feed_forward.w2.weight.absmax": "model-00001-of-00003.safetensors",
43
+ "model.layers.1.feed_forward.w2.weight.quant_map": "model-00001-of-00003.safetensors",
44
+ "model.layers.1.feed_forward.w2.weight.quant_state.bitsandbytes__nf4": "model-00001-of-00003.safetensors",
45
+ "model.layers.1.feed_forward.w3.weight": "model-00001-of-00003.safetensors",
46
+ "model.layers.1.feed_forward.w3.weight.absmax": "model-00001-of-00003.safetensors",
47
+ "model.layers.1.feed_forward.w3.weight.quant_map": "model-00001-of-00003.safetensors",
48
+ "model.layers.1.feed_forward.w3.weight.quant_state.bitsandbytes__nf4": "model-00001-of-00003.safetensors",
49
+ "model.layers.1.ffn_norm.weight": "model-00001-of-00003.safetensors",
50
+ "model.layers.10.attention.wo.weight": "model-00002-of-00003.safetensors",
51
+ "model.layers.10.attention.wo.weight.absmax": "model-00002-of-00003.safetensors",
52
+ "model.layers.10.attention.wo.weight.quant_map": "model-00002-of-00003.safetensors",
53
+ "model.layers.10.attention.wo.weight.quant_state.bitsandbytes__nf4": "model-00002-of-00003.safetensors",
54
+ "model.layers.10.attention.wqkv.weight": "model-00001-of-00003.safetensors",
55
+ "model.layers.10.attention.wqkv.weight.absmax": "model-00001-of-00003.safetensors",
56
+ "model.layers.10.attention.wqkv.weight.quant_map": "model-00001-of-00003.safetensors",
57
+ "model.layers.10.attention.wqkv.weight.quant_state.bitsandbytes__nf4": "model-00001-of-00003.safetensors",
58
+ "model.layers.10.attention_norm.weight": "model-00002-of-00003.safetensors",
59
+ "model.layers.10.feed_forward.w1.weight": "model-00002-of-00003.safetensors",
60
+ "model.layers.10.feed_forward.w1.weight.absmax": "model-00002-of-00003.safetensors",
61
+ "model.layers.10.feed_forward.w1.weight.quant_map": "model-00002-of-00003.safetensors",
62
+ "model.layers.10.feed_forward.w1.weight.quant_state.bitsandbytes__nf4": "model-00002-of-00003.safetensors",
63
+ "model.layers.10.feed_forward.w2.weight": "model-00002-of-00003.safetensors",
64
+ "model.layers.10.feed_forward.w2.weight.absmax": "model-00002-of-00003.safetensors",
65
+ "model.layers.10.feed_forward.w2.weight.quant_map": "model-00002-of-00003.safetensors",
66
+ "model.layers.10.feed_forward.w2.weight.quant_state.bitsandbytes__nf4": "model-00002-of-00003.safetensors",
67
+ "model.layers.10.feed_forward.w3.weight": "model-00002-of-00003.safetensors",
68
+ "model.layers.10.feed_forward.w3.weight.absmax": "model-00002-of-00003.safetensors",
69
+ "model.layers.10.feed_forward.w3.weight.quant_map": "model-00002-of-00003.safetensors",
70
+ "model.layers.10.feed_forward.w3.weight.quant_state.bitsandbytes__nf4": "model-00002-of-00003.safetensors",
71
+ "model.layers.10.ffn_norm.weight": "model-00002-of-00003.safetensors",
72
+ "model.layers.11.attention.wo.weight": "model-00002-of-00003.safetensors",
73
+ "model.layers.11.attention.wo.weight.absmax": "model-00002-of-00003.safetensors",
74
+ "model.layers.11.attention.wo.weight.quant_map": "model-00002-of-00003.safetensors",
75
+ "model.layers.11.attention.wo.weight.quant_state.bitsandbytes__nf4": "model-00002-of-00003.safetensors",
76
+ "model.layers.11.attention.wqkv.weight": "model-00002-of-00003.safetensors",
77
+ "model.layers.11.attention.wqkv.weight.absmax": "model-00002-of-00003.safetensors",
78
+ "model.layers.11.attention.wqkv.weight.quant_map": "model-00002-of-00003.safetensors",
79
+ "model.layers.11.attention.wqkv.weight.quant_state.bitsandbytes__nf4": "model-00002-of-00003.safetensors",
80
+ "model.layers.11.attention_norm.weight": "model-00002-of-00003.safetensors",
81
+ "model.layers.11.feed_forward.w1.weight": "model-00002-of-00003.safetensors",
82
+ "model.layers.11.feed_forward.w1.weight.absmax": "model-00002-of-00003.safetensors",
83
+ "model.layers.11.feed_forward.w1.weight.quant_map": "model-00002-of-00003.safetensors",
84
+ "model.layers.11.feed_forward.w1.weight.quant_state.bitsandbytes__nf4": "model-00002-of-00003.safetensors",
85
+ "model.layers.11.feed_forward.w2.weight": "model-00002-of-00003.safetensors",
86
+ "model.layers.11.feed_forward.w2.weight.absmax": "model-00002-of-00003.safetensors",
87
+ "model.layers.11.feed_forward.w2.weight.quant_map": "model-00002-of-00003.safetensors",
88
+ "model.layers.11.feed_forward.w2.weight.quant_state.bitsandbytes__nf4": "model-00002-of-00003.safetensors",
89
+ "model.layers.11.feed_forward.w3.weight": "model-00002-of-00003.safetensors",
90
+ "model.layers.11.feed_forward.w3.weight.absmax": "model-00002-of-00003.safetensors",
91
+ "model.layers.11.feed_forward.w3.weight.quant_map": "model-00002-of-00003.safetensors",
92
+ "model.layers.11.feed_forward.w3.weight.quant_state.bitsandbytes__nf4": "model-00002-of-00003.safetensors",
93
+ "model.layers.11.ffn_norm.weight": "model-00002-of-00003.safetensors",
94
+ "model.layers.12.attention.wo.weight": "model-00002-of-00003.safetensors",
95
+ "model.layers.12.attention.wo.weight.absmax": "model-00002-of-00003.safetensors",
96
+ "model.layers.12.attention.wo.weight.quant_map": "model-00002-of-00003.safetensors",
97
+ "model.layers.12.attention.wo.weight.quant_state.bitsandbytes__nf4": "model-00002-of-00003.safetensors",
98
+ "model.layers.12.attention.wqkv.weight": "model-00002-of-00003.safetensors",
99
+ "model.layers.12.attention.wqkv.weight.absmax": "model-00002-of-00003.safetensors",
100
+ "model.layers.12.attention.wqkv.weight.quant_map": "model-00002-of-00003.safetensors",
101
+ "model.layers.12.attention.wqkv.weight.quant_state.bitsandbytes__nf4": "model-00002-of-00003.safetensors",
102
+ "model.layers.12.attention_norm.weight": "model-00002-of-00003.safetensors",
103
+ "model.layers.12.feed_forward.w1.weight": "model-00002-of-00003.safetensors",
104
+ "model.layers.12.feed_forward.w1.weight.absmax": "model-00002-of-00003.safetensors",
105
+ "model.layers.12.feed_forward.w1.weight.quant_map": "model-00002-of-00003.safetensors",
106
+ "model.layers.12.feed_forward.w1.weight.quant_state.bitsandbytes__nf4": "model-00002-of-00003.safetensors",
107
+ "model.layers.12.feed_forward.w2.weight": "model-00002-of-00003.safetensors",
108
+ "model.layers.12.feed_forward.w2.weight.absmax": "model-00002-of-00003.safetensors",
109
+ "model.layers.12.feed_forward.w2.weight.quant_map": "model-00002-of-00003.safetensors",
110
+ "model.layers.12.feed_forward.w2.weight.quant_state.bitsandbytes__nf4": "model-00002-of-00003.safetensors",
111
+ "model.layers.12.feed_forward.w3.weight": "model-00002-of-00003.safetensors",
112
+ "model.layers.12.feed_forward.w3.weight.absmax": "model-00002-of-00003.safetensors",
113
+ "model.layers.12.feed_forward.w3.weight.quant_map": "model-00002-of-00003.safetensors",
114
+ "model.layers.12.feed_forward.w3.weight.quant_state.bitsandbytes__nf4": "model-00002-of-00003.safetensors",
115
+ "model.layers.12.ffn_norm.weight": "model-00002-of-00003.safetensors",
116
+ "model.layers.13.attention.wo.weight": "model-00002-of-00003.safetensors",
117
+ "model.layers.13.attention.wo.weight.absmax": "model-00002-of-00003.safetensors",
118
+ "model.layers.13.attention.wo.weight.quant_map": "model-00002-of-00003.safetensors",
119
+ "model.layers.13.attention.wo.weight.quant_state.bitsandbytes__nf4": "model-00002-of-00003.safetensors",
120
+ "model.layers.13.attention.wqkv.weight": "model-00002-of-00003.safetensors",
121
+ "model.layers.13.attention.wqkv.weight.absmax": "model-00002-of-00003.safetensors",
122
+ "model.layers.13.attention.wqkv.weight.quant_map": "model-00002-of-00003.safetensors",
123
+ "model.layers.13.attention.wqkv.weight.quant_state.bitsandbytes__nf4": "model-00002-of-00003.safetensors",
124
+ "model.layers.13.attention_norm.weight": "model-00002-of-00003.safetensors",
125
+ "model.layers.13.feed_forward.w1.weight": "model-00002-of-00003.safetensors",
126
+ "model.layers.13.feed_forward.w1.weight.absmax": "model-00002-of-00003.safetensors",
127
+ "model.layers.13.feed_forward.w1.weight.quant_map": "model-00002-of-00003.safetensors",
128
+ "model.layers.13.feed_forward.w1.weight.quant_state.bitsandbytes__nf4": "model-00002-of-00003.safetensors",
129
+ "model.layers.13.feed_forward.w2.weight": "model-00002-of-00003.safetensors",
130
+ "model.layers.13.feed_forward.w2.weight.absmax": "model-00002-of-00003.safetensors",
131
+ "model.layers.13.feed_forward.w2.weight.quant_map": "model-00002-of-00003.safetensors",
132
+ "model.layers.13.feed_forward.w2.weight.quant_state.bitsandbytes__nf4": "model-00002-of-00003.safetensors",
133
+ "model.layers.13.feed_forward.w3.weight": "model-00002-of-00003.safetensors",
134
+ "model.layers.13.feed_forward.w3.weight.absmax": "model-00002-of-00003.safetensors",
135
+ "model.layers.13.feed_forward.w3.weight.quant_map": "model-00002-of-00003.safetensors",
136
+ "model.layers.13.feed_forward.w3.weight.quant_state.bitsandbytes__nf4": "model-00002-of-00003.safetensors",
137
+ "model.layers.13.ffn_norm.weight": "model-00002-of-00003.safetensors",
138
+ "model.layers.14.attention.wo.weight": "model-00002-of-00003.safetensors",
139
+ "model.layers.14.attention.wo.weight.absmax": "model-00002-of-00003.safetensors",
140
+ "model.layers.14.attention.wo.weight.quant_map": "model-00002-of-00003.safetensors",
141
+ "model.layers.14.attention.wo.weight.quant_state.bitsandbytes__nf4": "model-00002-of-00003.safetensors",
142
+ "model.layers.14.attention.wqkv.weight": "model-00002-of-00003.safetensors",
143
+ "model.layers.14.attention.wqkv.weight.absmax": "model-00002-of-00003.safetensors",
144
+ "model.layers.14.attention.wqkv.weight.quant_map": "model-00002-of-00003.safetensors",
145
+ "model.layers.14.attention.wqkv.weight.quant_state.bitsandbytes__nf4": "model-00002-of-00003.safetensors",
146
+ "model.layers.14.attention_norm.weight": "model-00002-of-00003.safetensors",
147
+ "model.layers.14.feed_forward.w1.weight": "model-00002-of-00003.safetensors",
148
+ "model.layers.14.feed_forward.w1.weight.absmax": "model-00002-of-00003.safetensors",
149
+ "model.layers.14.feed_forward.w1.weight.quant_map": "model-00002-of-00003.safetensors",
150
+ "model.layers.14.feed_forward.w1.weight.quant_state.bitsandbytes__nf4": "model-00002-of-00003.safetensors",
151
+ "model.layers.14.feed_forward.w2.weight": "model-00002-of-00003.safetensors",
152
+ "model.layers.14.feed_forward.w2.weight.absmax": "model-00002-of-00003.safetensors",
153
+ "model.layers.14.feed_forward.w2.weight.quant_map": "model-00002-of-00003.safetensors",
154
+ "model.layers.14.feed_forward.w2.weight.quant_state.bitsandbytes__nf4": "model-00002-of-00003.safetensors",
155
+ "model.layers.14.feed_forward.w3.weight": "model-00002-of-00003.safetensors",
156
+ "model.layers.14.feed_forward.w3.weight.absmax": "model-00002-of-00003.safetensors",
157
+ "model.layers.14.feed_forward.w3.weight.quant_map": "model-00002-of-00003.safetensors",
158
+ "model.layers.14.feed_forward.w3.weight.quant_state.bitsandbytes__nf4": "model-00002-of-00003.safetensors",
159
+ "model.layers.14.ffn_norm.weight": "model-00002-of-00003.safetensors",
160
+ "model.layers.15.attention.wo.weight": "model-00002-of-00003.safetensors",
161
+ "model.layers.15.attention.wo.weight.absmax": "model-00002-of-00003.safetensors",
162
+ "model.layers.15.attention.wo.weight.quant_map": "model-00002-of-00003.safetensors",
163
+ "model.layers.15.attention.wo.weight.quant_state.bitsandbytes__nf4": "model-00002-of-00003.safetensors",
164
+ "model.layers.15.attention.wqkv.weight": "model-00002-of-00003.safetensors",
165
+ "model.layers.15.attention.wqkv.weight.absmax": "model-00002-of-00003.safetensors",
166
+ "model.layers.15.attention.wqkv.weight.quant_map": "model-00002-of-00003.safetensors",
167
+ "model.layers.15.attention.wqkv.weight.quant_state.bitsandbytes__nf4": "model-00002-of-00003.safetensors",
168
+ "model.layers.15.attention_norm.weight": "model-00002-of-00003.safetensors",
169
+ "model.layers.15.feed_forward.w1.weight": "model-00002-of-00003.safetensors",
170
+ "model.layers.15.feed_forward.w1.weight.absmax": "model-00002-of-00003.safetensors",
171
+ "model.layers.15.feed_forward.w1.weight.quant_map": "model-00002-of-00003.safetensors",
172
+ "model.layers.15.feed_forward.w1.weight.quant_state.bitsandbytes__nf4": "model-00002-of-00003.safetensors",
173
+ "model.layers.15.feed_forward.w2.weight": "model-00002-of-00003.safetensors",
174
+ "model.layers.15.feed_forward.w2.weight.absmax": "model-00002-of-00003.safetensors",
175
+ "model.layers.15.feed_forward.w2.weight.quant_map": "model-00002-of-00003.safetensors",
176
+ "model.layers.15.feed_forward.w2.weight.quant_state.bitsandbytes__nf4": "model-00002-of-00003.safetensors",
177
+ "model.layers.15.feed_forward.w3.weight": "model-00002-of-00003.safetensors",
178
+ "model.layers.15.feed_forward.w3.weight.absmax": "model-00002-of-00003.safetensors",
179
+ "model.layers.15.feed_forward.w3.weight.quant_map": "model-00002-of-00003.safetensors",
180
+ "model.layers.15.feed_forward.w3.weight.quant_state.bitsandbytes__nf4": "model-00002-of-00003.safetensors",
181
+ "model.layers.15.ffn_norm.weight": "model-00002-of-00003.safetensors",
182
+ "model.layers.16.attention.wo.weight": "model-00002-of-00003.safetensors",
183
+ "model.layers.16.attention.wo.weight.absmax": "model-00002-of-00003.safetensors",
184
+ "model.layers.16.attention.wo.weight.quant_map": "model-00002-of-00003.safetensors",
185
+ "model.layers.16.attention.wo.weight.quant_state.bitsandbytes__nf4": "model-00002-of-00003.safetensors",
186
+ "model.layers.16.attention.wqkv.weight": "model-00002-of-00003.safetensors",
187
+ "model.layers.16.attention.wqkv.weight.absmax": "model-00002-of-00003.safetensors",
188
+ "model.layers.16.attention.wqkv.weight.quant_map": "model-00002-of-00003.safetensors",
189
+ "model.layers.16.attention.wqkv.weight.quant_state.bitsandbytes__nf4": "model-00002-of-00003.safetensors",
190
+ "model.layers.16.attention_norm.weight": "model-00002-of-00003.safetensors",
191
+ "model.layers.16.feed_forward.w1.weight": "model-00002-of-00003.safetensors",
192
+ "model.layers.16.feed_forward.w1.weight.absmax": "model-00002-of-00003.safetensors",
193
+ "model.layers.16.feed_forward.w1.weight.quant_map": "model-00002-of-00003.safetensors",
194
+ "model.layers.16.feed_forward.w1.weight.quant_state.bitsandbytes__nf4": "model-00002-of-00003.safetensors",
195
+ "model.layers.16.feed_forward.w2.weight": "model-00002-of-00003.safetensors",
196
+ "model.layers.16.feed_forward.w2.weight.absmax": "model-00002-of-00003.safetensors",
197
+ "model.layers.16.feed_forward.w2.weight.quant_map": "model-00002-of-00003.safetensors",
198
+ "model.layers.16.feed_forward.w2.weight.quant_state.bitsandbytes__nf4": "model-00002-of-00003.safetensors",
199
+ "model.layers.16.feed_forward.w3.weight": "model-00002-of-00003.safetensors",
200
+ "model.layers.16.feed_forward.w3.weight.absmax": "model-00002-of-00003.safetensors",
201
+ "model.layers.16.feed_forward.w3.weight.quant_map": "model-00002-of-00003.safetensors",
202
+ "model.layers.16.feed_forward.w3.weight.quant_state.bitsandbytes__nf4": "model-00002-of-00003.safetensors",
203
+ "model.layers.16.ffn_norm.weight": "model-00002-of-00003.safetensors",
204
+ "model.layers.17.attention.wo.weight": "model-00002-of-00003.safetensors",
205
+ "model.layers.17.attention.wo.weight.absmax": "model-00002-of-00003.safetensors",
206
+ "model.layers.17.attention.wo.weight.quant_map": "model-00002-of-00003.safetensors",
207
+ "model.layers.17.attention.wo.weight.quant_state.bitsandbytes__nf4": "model-00002-of-00003.safetensors",
208
+ "model.layers.17.attention.wqkv.weight": "model-00002-of-00003.safetensors",
209
+ "model.layers.17.attention.wqkv.weight.absmax": "model-00002-of-00003.safetensors",
210
+ "model.layers.17.attention.wqkv.weight.quant_map": "model-00002-of-00003.safetensors",
211
+ "model.layers.17.attention.wqkv.weight.quant_state.bitsandbytes__nf4": "model-00002-of-00003.safetensors",
212
+ "model.layers.17.attention_norm.weight": "model-00002-of-00003.safetensors",
213
+ "model.layers.17.feed_forward.w1.weight": "model-00002-of-00003.safetensors",
214
+ "model.layers.17.feed_forward.w1.weight.absmax": "model-00002-of-00003.safetensors",
215
+ "model.layers.17.feed_forward.w1.weight.quant_map": "model-00002-of-00003.safetensors",
216
+ "model.layers.17.feed_forward.w1.weight.quant_state.bitsandbytes__nf4": "model-00002-of-00003.safetensors",
217
+ "model.layers.17.feed_forward.w2.weight": "model-00002-of-00003.safetensors",
218
+ "model.layers.17.feed_forward.w2.weight.absmax": "model-00002-of-00003.safetensors",
219
+ "model.layers.17.feed_forward.w2.weight.quant_map": "model-00002-of-00003.safetensors",
220
+ "model.layers.17.feed_forward.w2.weight.quant_state.bitsandbytes__nf4": "model-00002-of-00003.safetensors",
221
+ "model.layers.17.feed_forward.w3.weight": "model-00002-of-00003.safetensors",
222
+ "model.layers.17.feed_forward.w3.weight.absmax": "model-00002-of-00003.safetensors",
223
+ "model.layers.17.feed_forward.w3.weight.quant_map": "model-00002-of-00003.safetensors",
224
+ "model.layers.17.feed_forward.w3.weight.quant_state.bitsandbytes__nf4": "model-00002-of-00003.safetensors",
225
+ "model.layers.17.ffn_norm.weight": "model-00002-of-00003.safetensors",
226
+ "model.layers.18.attention.wo.weight": "model-00002-of-00003.safetensors",
227
+ "model.layers.18.attention.wo.weight.absmax": "model-00002-of-00003.safetensors",
228
+ "model.layers.18.attention.wo.weight.quant_map": "model-00002-of-00003.safetensors",
229
+ "model.layers.18.attention.wo.weight.quant_state.bitsandbytes__nf4": "model-00002-of-00003.safetensors",
230
+ "model.layers.18.attention.wqkv.weight": "model-00002-of-00003.safetensors",
231
+ "model.layers.18.attention.wqkv.weight.absmax": "model-00002-of-00003.safetensors",
232
+ "model.layers.18.attention.wqkv.weight.quant_map": "model-00002-of-00003.safetensors",
233
+ "model.layers.18.attention.wqkv.weight.quant_state.bitsandbytes__nf4": "model-00002-of-00003.safetensors",
234
+ "model.layers.18.attention_norm.weight": "model-00002-of-00003.safetensors",
235
+ "model.layers.18.feed_forward.w1.weight": "model-00002-of-00003.safetensors",
236
+ "model.layers.18.feed_forward.w1.weight.absmax": "model-00002-of-00003.safetensors",
237
+ "model.layers.18.feed_forward.w1.weight.quant_map": "model-00002-of-00003.safetensors",
238
+ "model.layers.18.feed_forward.w1.weight.quant_state.bitsandbytes__nf4": "model-00002-of-00003.safetensors",
239
+ "model.layers.18.feed_forward.w2.weight": "model-00002-of-00003.safetensors",
240
+ "model.layers.18.feed_forward.w2.weight.absmax": "model-00002-of-00003.safetensors",
241
+ "model.layers.18.feed_forward.w2.weight.quant_map": "model-00002-of-00003.safetensors",
242
+ "model.layers.18.feed_forward.w2.weight.quant_state.bitsandbytes__nf4": "model-00002-of-00003.safetensors",
243
+ "model.layers.18.feed_forward.w3.weight": "model-00002-of-00003.safetensors",
244
+ "model.layers.18.feed_forward.w3.weight.absmax": "model-00002-of-00003.safetensors",
245
+ "model.layers.18.feed_forward.w3.weight.quant_map": "model-00002-of-00003.safetensors",
246
+ "model.layers.18.feed_forward.w3.weight.quant_state.bitsandbytes__nf4": "model-00002-of-00003.safetensors",
247
+ "model.layers.18.ffn_norm.weight": "model-00002-of-00003.safetensors",
248
+ "model.layers.19.attention.wo.weight": "model-00002-of-00003.safetensors",
249
+ "model.layers.19.attention.wo.weight.absmax": "model-00002-of-00003.safetensors",
250
+ "model.layers.19.attention.wo.weight.quant_map": "model-00002-of-00003.safetensors",
251
+ "model.layers.19.attention.wo.weight.quant_state.bitsandbytes__nf4": "model-00002-of-00003.safetensors",
252
+ "model.layers.19.attention.wqkv.weight": "model-00002-of-00003.safetensors",
253
+ "model.layers.19.attention.wqkv.weight.absmax": "model-00002-of-00003.safetensors",
254
+ "model.layers.19.attention.wqkv.weight.quant_map": "model-00002-of-00003.safetensors",
255
+ "model.layers.19.attention.wqkv.weight.quant_state.bitsandbytes__nf4": "model-00002-of-00003.safetensors",
256
+ "model.layers.19.attention_norm.weight": "model-00002-of-00003.safetensors",
257
+ "model.layers.19.feed_forward.w1.weight": "model-00002-of-00003.safetensors",
258
+ "model.layers.19.feed_forward.w1.weight.absmax": "model-00002-of-00003.safetensors",
259
+ "model.layers.19.feed_forward.w1.weight.quant_map": "model-00002-of-00003.safetensors",
260
+ "model.layers.19.feed_forward.w1.weight.quant_state.bitsandbytes__nf4": "model-00002-of-00003.safetensors",
261
+ "model.layers.19.feed_forward.w2.weight": "model-00002-of-00003.safetensors",
262
+ "model.layers.19.feed_forward.w2.weight.absmax": "model-00002-of-00003.safetensors",
263
+ "model.layers.19.feed_forward.w2.weight.quant_map": "model-00002-of-00003.safetensors",
264
+ "model.layers.19.feed_forward.w2.weight.quant_state.bitsandbytes__nf4": "model-00002-of-00003.safetensors",
265
+ "model.layers.19.feed_forward.w3.weight": "model-00002-of-00003.safetensors",
266
+ "model.layers.19.feed_forward.w3.weight.absmax": "model-00002-of-00003.safetensors",
267
+ "model.layers.19.feed_forward.w3.weight.quant_map": "model-00002-of-00003.safetensors",
268
+ "model.layers.19.feed_forward.w3.weight.quant_state.bitsandbytes__nf4": "model-00002-of-00003.safetensors",
269
+ "model.layers.19.ffn_norm.weight": "model-00002-of-00003.safetensors",
270
+ "model.layers.2.attention.wo.weight": "model-00001-of-00003.safetensors",
271
+ "model.layers.2.attention.wo.weight.absmax": "model-00001-of-00003.safetensors",
272
+ "model.layers.2.attention.wo.weight.quant_map": "model-00001-of-00003.safetensors",
273
+ "model.layers.2.attention.wo.weight.quant_state.bitsandbytes__nf4": "model-00001-of-00003.safetensors",
274
+ "model.layers.2.attention.wqkv.weight": "model-00001-of-00003.safetensors",
275
+ "model.layers.2.attention.wqkv.weight.absmax": "model-00001-of-00003.safetensors",
276
+ "model.layers.2.attention.wqkv.weight.quant_map": "model-00001-of-00003.safetensors",
277
+ "model.layers.2.attention.wqkv.weight.quant_state.bitsandbytes__nf4": "model-00001-of-00003.safetensors",
278
+ "model.layers.2.attention_norm.weight": "model-00001-of-00003.safetensors",
279
+ "model.layers.2.feed_forward.w1.weight": "model-00001-of-00003.safetensors",
280
+ "model.layers.2.feed_forward.w1.weight.absmax": "model-00001-of-00003.safetensors",
281
+ "model.layers.2.feed_forward.w1.weight.quant_map": "model-00001-of-00003.safetensors",
282
+ "model.layers.2.feed_forward.w1.weight.quant_state.bitsandbytes__nf4": "model-00001-of-00003.safetensors",
283
+ "model.layers.2.feed_forward.w2.weight": "model-00001-of-00003.safetensors",
284
+ "model.layers.2.feed_forward.w2.weight.absmax": "model-00001-of-00003.safetensors",
285
+ "model.layers.2.feed_forward.w2.weight.quant_map": "model-00001-of-00003.safetensors",
286
+ "model.layers.2.feed_forward.w2.weight.quant_state.bitsandbytes__nf4": "model-00001-of-00003.safetensors",
287
+ "model.layers.2.feed_forward.w3.weight": "model-00001-of-00003.safetensors",
288
+ "model.layers.2.feed_forward.w3.weight.absmax": "model-00001-of-00003.safetensors",
289
+ "model.layers.2.feed_forward.w3.weight.quant_map": "model-00001-of-00003.safetensors",
290
+ "model.layers.2.feed_forward.w3.weight.quant_state.bitsandbytes__nf4": "model-00001-of-00003.safetensors",
291
+ "model.layers.2.ffn_norm.weight": "model-00001-of-00003.safetensors",
292
+ "model.layers.20.attention.wo.weight": "model-00002-of-00003.safetensors",
293
+ "model.layers.20.attention.wo.weight.absmax": "model-00002-of-00003.safetensors",
294
+ "model.layers.20.attention.wo.weight.quant_map": "model-00002-of-00003.safetensors",
295
+ "model.layers.20.attention.wo.weight.quant_state.bitsandbytes__nf4": "model-00002-of-00003.safetensors",
296
+ "model.layers.20.attention.wqkv.weight": "model-00002-of-00003.safetensors",
297
+ "model.layers.20.attention.wqkv.weight.absmax": "model-00002-of-00003.safetensors",
298
+ "model.layers.20.attention.wqkv.weight.quant_map": "model-00002-of-00003.safetensors",
299
+ "model.layers.20.attention.wqkv.weight.quant_state.bitsandbytes__nf4": "model-00002-of-00003.safetensors",
300
+ "model.layers.20.attention_norm.weight": "model-00002-of-00003.safetensors",
301
+ "model.layers.20.feed_forward.w1.weight": "model-00002-of-00003.safetensors",
302
+ "model.layers.20.feed_forward.w1.weight.absmax": "model-00002-of-00003.safetensors",
303
+ "model.layers.20.feed_forward.w1.weight.quant_map": "model-00002-of-00003.safetensors",
304
+ "model.layers.20.feed_forward.w1.weight.quant_state.bitsandbytes__nf4": "model-00002-of-00003.safetensors",
305
+ "model.layers.20.feed_forward.w2.weight": "model-00002-of-00003.safetensors",
306
+ "model.layers.20.feed_forward.w2.weight.absmax": "model-00002-of-00003.safetensors",
307
+ "model.layers.20.feed_forward.w2.weight.quant_map": "model-00002-of-00003.safetensors",
308
+ "model.layers.20.feed_forward.w2.weight.quant_state.bitsandbytes__nf4": "model-00002-of-00003.safetensors",
309
+ "model.layers.20.feed_forward.w3.weight": "model-00002-of-00003.safetensors",
310
+ "model.layers.20.feed_forward.w3.weight.absmax": "model-00002-of-00003.safetensors",
311
+ "model.layers.20.feed_forward.w3.weight.quant_map": "model-00002-of-00003.safetensors",
312
+ "model.layers.20.feed_forward.w3.weight.quant_state.bitsandbytes__nf4": "model-00002-of-00003.safetensors",
313
+ "model.layers.20.ffn_norm.weight": "model-00002-of-00003.safetensors",
314
+ "model.layers.21.attention.wo.weight": "model-00002-of-00003.safetensors",
315
+ "model.layers.21.attention.wo.weight.absmax": "model-00002-of-00003.safetensors",
316
+ "model.layers.21.attention.wo.weight.quant_map": "model-00002-of-00003.safetensors",
317
+ "model.layers.21.attention.wo.weight.quant_state.bitsandbytes__nf4": "model-00002-of-00003.safetensors",
318
+ "model.layers.21.attention.wqkv.weight": "model-00002-of-00003.safetensors",
319
+ "model.layers.21.attention.wqkv.weight.absmax": "model-00002-of-00003.safetensors",
320
+ "model.layers.21.attention.wqkv.weight.quant_map": "model-00002-of-00003.safetensors",
321
+ "model.layers.21.attention.wqkv.weight.quant_state.bitsandbytes__nf4": "model-00002-of-00003.safetensors",
322
+ "model.layers.21.attention_norm.weight": "model-00002-of-00003.safetensors",
323
+ "model.layers.21.feed_forward.w1.weight": "model-00002-of-00003.safetensors",
324
+ "model.layers.21.feed_forward.w1.weight.absmax": "model-00002-of-00003.safetensors",
325
+ "model.layers.21.feed_forward.w1.weight.quant_map": "model-00002-of-00003.safetensors",
326
+ "model.layers.21.feed_forward.w1.weight.quant_state.bitsandbytes__nf4": "model-00002-of-00003.safetensors",
327
+ "model.layers.21.feed_forward.w2.weight": "model-00002-of-00003.safetensors",
328
+ "model.layers.21.feed_forward.w2.weight.absmax": "model-00002-of-00003.safetensors",
329
+ "model.layers.21.feed_forward.w2.weight.quant_map": "model-00002-of-00003.safetensors",
330
+ "model.layers.21.feed_forward.w2.weight.quant_state.bitsandbytes__nf4": "model-00002-of-00003.safetensors",
331
+ "model.layers.21.feed_forward.w3.weight": "model-00002-of-00003.safetensors",
332
+ "model.layers.21.feed_forward.w3.weight.absmax": "model-00002-of-00003.safetensors",
333
+ "model.layers.21.feed_forward.w3.weight.quant_map": "model-00002-of-00003.safetensors",
334
+ "model.layers.21.feed_forward.w3.weight.quant_state.bitsandbytes__nf4": "model-00002-of-00003.safetensors",
335
+ "model.layers.21.ffn_norm.weight": "model-00002-of-00003.safetensors",
336
+ "model.layers.22.attention.wo.weight": "model-00002-of-00003.safetensors",
337
+ "model.layers.22.attention.wo.weight.absmax": "model-00002-of-00003.safetensors",
338
+ "model.layers.22.attention.wo.weight.quant_map": "model-00002-of-00003.safetensors",
339
+ "model.layers.22.attention.wo.weight.quant_state.bitsandbytes__nf4": "model-00002-of-00003.safetensors",
340
+ "model.layers.22.attention.wqkv.weight": "model-00002-of-00003.safetensors",
341
+ "model.layers.22.attention.wqkv.weight.absmax": "model-00002-of-00003.safetensors",
342
+ "model.layers.22.attention.wqkv.weight.quant_map": "model-00002-of-00003.safetensors",
343
+ "model.layers.22.attention.wqkv.weight.quant_state.bitsandbytes__nf4": "model-00002-of-00003.safetensors",
344
+ "model.layers.22.attention_norm.weight": "model-00002-of-00003.safetensors",
345
+ "model.layers.22.feed_forward.w1.weight": "model-00002-of-00003.safetensors",
346
+ "model.layers.22.feed_forward.w1.weight.absmax": "model-00002-of-00003.safetensors",
347
+ "model.layers.22.feed_forward.w1.weight.quant_map": "model-00002-of-00003.safetensors",
348
+ "model.layers.22.feed_forward.w1.weight.quant_state.bitsandbytes__nf4": "model-00002-of-00003.safetensors",
349
+ "model.layers.22.feed_forward.w2.weight": "model-00002-of-00003.safetensors",
350
+ "model.layers.22.feed_forward.w2.weight.absmax": "model-00002-of-00003.safetensors",
351
+ "model.layers.22.feed_forward.w2.weight.quant_map": "model-00002-of-00003.safetensors",
352
+ "model.layers.22.feed_forward.w2.weight.quant_state.bitsandbytes__nf4": "model-00002-of-00003.safetensors",
353
+ "model.layers.22.feed_forward.w3.weight": "model-00002-of-00003.safetensors",
354
+ "model.layers.22.feed_forward.w3.weight.absmax": "model-00002-of-00003.safetensors",
355
+ "model.layers.22.feed_forward.w3.weight.quant_map": "model-00002-of-00003.safetensors",
356
+ "model.layers.22.feed_forward.w3.weight.quant_state.bitsandbytes__nf4": "model-00002-of-00003.safetensors",
357
+ "model.layers.22.ffn_norm.weight": "model-00002-of-00003.safetensors",
358
+ "model.layers.23.attention.wo.weight": "model-00002-of-00003.safetensors",
359
+ "model.layers.23.attention.wo.weight.absmax": "model-00002-of-00003.safetensors",
360
+ "model.layers.23.attention.wo.weight.quant_map": "model-00002-of-00003.safetensors",
361
+ "model.layers.23.attention.wo.weight.quant_state.bitsandbytes__nf4": "model-00002-of-00003.safetensors",
362
+ "model.layers.23.attention.wqkv.weight": "model-00002-of-00003.safetensors",
363
+ "model.layers.23.attention.wqkv.weight.absmax": "model-00002-of-00003.safetensors",
364
+ "model.layers.23.attention.wqkv.weight.quant_map": "model-00002-of-00003.safetensors",
365
+ "model.layers.23.attention.wqkv.weight.quant_state.bitsandbytes__nf4": "model-00002-of-00003.safetensors",
366
+ "model.layers.23.attention_norm.weight": "model-00002-of-00003.safetensors",
367
+ "model.layers.23.feed_forward.w1.weight": "model-00002-of-00003.safetensors",
368
+ "model.layers.23.feed_forward.w1.weight.absmax": "model-00002-of-00003.safetensors",
369
+ "model.layers.23.feed_forward.w1.weight.quant_map": "model-00002-of-00003.safetensors",
370
+ "model.layers.23.feed_forward.w1.weight.quant_state.bitsandbytes__nf4": "model-00002-of-00003.safetensors",
371
+ "model.layers.23.feed_forward.w2.weight": "model-00002-of-00003.safetensors",
372
+ "model.layers.23.feed_forward.w2.weight.absmax": "model-00002-of-00003.safetensors",
373
+ "model.layers.23.feed_forward.w2.weight.quant_map": "model-00002-of-00003.safetensors",
374
+ "model.layers.23.feed_forward.w2.weight.quant_state.bitsandbytes__nf4": "model-00002-of-00003.safetensors",
375
+ "model.layers.23.feed_forward.w3.weight": "model-00002-of-00003.safetensors",
376
+ "model.layers.23.feed_forward.w3.weight.absmax": "model-00002-of-00003.safetensors",
377
+ "model.layers.23.feed_forward.w3.weight.quant_map": "model-00002-of-00003.safetensors",
378
+ "model.layers.23.feed_forward.w3.weight.quant_state.bitsandbytes__nf4": "model-00002-of-00003.safetensors",
379
+ "model.layers.23.ffn_norm.weight": "model-00002-of-00003.safetensors",
380
+ "model.layers.24.attention.wo.weight": "model-00002-of-00003.safetensors",
381
+ "model.layers.24.attention.wo.weight.absmax": "model-00002-of-00003.safetensors",
382
+ "model.layers.24.attention.wo.weight.quant_map": "model-00002-of-00003.safetensors",
383
+ "model.layers.24.attention.wo.weight.quant_state.bitsandbytes__nf4": "model-00002-of-00003.safetensors",
384
+ "model.layers.24.attention.wqkv.weight": "model-00002-of-00003.safetensors",
385
+ "model.layers.24.attention.wqkv.weight.absmax": "model-00002-of-00003.safetensors",
386
+ "model.layers.24.attention.wqkv.weight.quant_map": "model-00002-of-00003.safetensors",
387
+ "model.layers.24.attention.wqkv.weight.quant_state.bitsandbytes__nf4": "model-00002-of-00003.safetensors",
388
+ "model.layers.24.attention_norm.weight": "model-00002-of-00003.safetensors",
389
+ "model.layers.24.feed_forward.w1.weight": "model-00002-of-00003.safetensors",
390
+ "model.layers.24.feed_forward.w1.weight.absmax": "model-00002-of-00003.safetensors",
391
+ "model.layers.24.feed_forward.w1.weight.quant_map": "model-00002-of-00003.safetensors",
392
+ "model.layers.24.feed_forward.w1.weight.quant_state.bitsandbytes__nf4": "model-00002-of-00003.safetensors",
393
+ "model.layers.24.feed_forward.w2.weight": "model-00002-of-00003.safetensors",
394
+ "model.layers.24.feed_forward.w2.weight.absmax": "model-00002-of-00003.safetensors",
395
+ "model.layers.24.feed_forward.w2.weight.quant_map": "model-00002-of-00003.safetensors",
396
+ "model.layers.24.feed_forward.w2.weight.quant_state.bitsandbytes__nf4": "model-00002-of-00003.safetensors",
397
+ "model.layers.24.feed_forward.w3.weight": "model-00002-of-00003.safetensors",
398
+ "model.layers.24.feed_forward.w3.weight.absmax": "model-00002-of-00003.safetensors",
399
+ "model.layers.24.feed_forward.w3.weight.quant_map": "model-00002-of-00003.safetensors",
400
+ "model.layers.24.feed_forward.w3.weight.quant_state.bitsandbytes__nf4": "model-00002-of-00003.safetensors",
401
+ "model.layers.24.ffn_norm.weight": "model-00002-of-00003.safetensors",
402
+ "model.layers.25.attention.wo.weight": "model-00002-of-00003.safetensors",
403
+ "model.layers.25.attention.wo.weight.absmax": "model-00002-of-00003.safetensors",
404
+ "model.layers.25.attention.wo.weight.quant_map": "model-00002-of-00003.safetensors",
405
+ "model.layers.25.attention.wo.weight.quant_state.bitsandbytes__nf4": "model-00002-of-00003.safetensors",
406
+ "model.layers.25.attention.wqkv.weight": "model-00002-of-00003.safetensors",
407
+ "model.layers.25.attention.wqkv.weight.absmax": "model-00002-of-00003.safetensors",
408
+ "model.layers.25.attention.wqkv.weight.quant_map": "model-00002-of-00003.safetensors",
409
+ "model.layers.25.attention.wqkv.weight.quant_state.bitsandbytes__nf4": "model-00002-of-00003.safetensors",
410
+ "model.layers.25.attention_norm.weight": "model-00002-of-00003.safetensors",
411
+ "model.layers.25.feed_forward.w1.weight": "model-00002-of-00003.safetensors",
412
+ "model.layers.25.feed_forward.w1.weight.absmax": "model-00002-of-00003.safetensors",
413
+ "model.layers.25.feed_forward.w1.weight.quant_map": "model-00002-of-00003.safetensors",
414
+ "model.layers.25.feed_forward.w1.weight.quant_state.bitsandbytes__nf4": "model-00002-of-00003.safetensors",
415
+ "model.layers.25.feed_forward.w2.weight": "model-00002-of-00003.safetensors",
416
+ "model.layers.25.feed_forward.w2.weight.absmax": "model-00002-of-00003.safetensors",
417
+ "model.layers.25.feed_forward.w2.weight.quant_map": "model-00002-of-00003.safetensors",
418
+ "model.layers.25.feed_forward.w2.weight.quant_state.bitsandbytes__nf4": "model-00002-of-00003.safetensors",
419
+ "model.layers.25.feed_forward.w3.weight": "model-00002-of-00003.safetensors",
420
+ "model.layers.25.feed_forward.w3.weight.absmax": "model-00002-of-00003.safetensors",
421
+ "model.layers.25.feed_forward.w3.weight.quant_map": "model-00002-of-00003.safetensors",
422
+ "model.layers.25.feed_forward.w3.weight.quant_state.bitsandbytes__nf4": "model-00002-of-00003.safetensors",
423
+ "model.layers.25.ffn_norm.weight": "model-00002-of-00003.safetensors",
424
+ "model.layers.26.attention.wo.weight": "model-00002-of-00003.safetensors",
425
+ "model.layers.26.attention.wo.weight.absmax": "model-00002-of-00003.safetensors",
426
+ "model.layers.26.attention.wo.weight.quant_map": "model-00002-of-00003.safetensors",
427
+ "model.layers.26.attention.wo.weight.quant_state.bitsandbytes__nf4": "model-00002-of-00003.safetensors",
428
+ "model.layers.26.attention.wqkv.weight": "model-00002-of-00003.safetensors",
429
+ "model.layers.26.attention.wqkv.weight.absmax": "model-00002-of-00003.safetensors",
430
+ "model.layers.26.attention.wqkv.weight.quant_map": "model-00002-of-00003.safetensors",
431
+ "model.layers.26.attention.wqkv.weight.quant_state.bitsandbytes__nf4": "model-00002-of-00003.safetensors",
432
+ "model.layers.26.attention_norm.weight": "model-00003-of-00003.safetensors",
433
+ "model.layers.26.feed_forward.w1.weight": "model-00003-of-00003.safetensors",
434
+ "model.layers.26.feed_forward.w1.weight.absmax": "model-00003-of-00003.safetensors",
435
+ "model.layers.26.feed_forward.w1.weight.quant_map": "model-00003-of-00003.safetensors",
436
+ "model.layers.26.feed_forward.w1.weight.quant_state.bitsandbytes__nf4": "model-00003-of-00003.safetensors",
437
+ "model.layers.26.feed_forward.w2.weight": "model-00003-of-00003.safetensors",
438
+ "model.layers.26.feed_forward.w2.weight.absmax": "model-00003-of-00003.safetensors",
439
+ "model.layers.26.feed_forward.w2.weight.quant_map": "model-00003-of-00003.safetensors",
440
+ "model.layers.26.feed_forward.w2.weight.quant_state.bitsandbytes__nf4": "model-00003-of-00003.safetensors",
441
+ "model.layers.26.feed_forward.w3.weight": "model-00003-of-00003.safetensors",
442
+ "model.layers.26.feed_forward.w3.weight.absmax": "model-00003-of-00003.safetensors",
443
+ "model.layers.26.feed_forward.w3.weight.quant_map": "model-00003-of-00003.safetensors",
444
+ "model.layers.26.feed_forward.w3.weight.quant_state.bitsandbytes__nf4": "model-00003-of-00003.safetensors",
445
+ "model.layers.26.ffn_norm.weight": "model-00003-of-00003.safetensors",
446
+ "model.layers.27.attention.wo.weight": "model-00003-of-00003.safetensors",
447
+ "model.layers.27.attention.wo.weight.absmax": "model-00003-of-00003.safetensors",
448
+ "model.layers.27.attention.wo.weight.quant_map": "model-00003-of-00003.safetensors",
449
+ "model.layers.27.attention.wo.weight.quant_state.bitsandbytes__nf4": "model-00003-of-00003.safetensors",
450
+ "model.layers.27.attention.wqkv.weight": "model-00003-of-00003.safetensors",
451
+ "model.layers.27.attention.wqkv.weight.absmax": "model-00003-of-00003.safetensors",
452
+ "model.layers.27.attention.wqkv.weight.quant_map": "model-00003-of-00003.safetensors",
453
+ "model.layers.27.attention.wqkv.weight.quant_state.bitsandbytes__nf4": "model-00003-of-00003.safetensors",
454
+ "model.layers.27.attention_norm.weight": "model-00003-of-00003.safetensors",
455
+ "model.layers.27.feed_forward.w1.weight": "model-00003-of-00003.safetensors",
456
+ "model.layers.27.feed_forward.w1.weight.absmax": "model-00003-of-00003.safetensors",
457
+ "model.layers.27.feed_forward.w1.weight.quant_map": "model-00003-of-00003.safetensors",
458
+ "model.layers.27.feed_forward.w1.weight.quant_state.bitsandbytes__nf4": "model-00003-of-00003.safetensors",
459
+ "model.layers.27.feed_forward.w2.weight": "model-00003-of-00003.safetensors",
460
+ "model.layers.27.feed_forward.w2.weight.absmax": "model-00003-of-00003.safetensors",
461
+ "model.layers.27.feed_forward.w2.weight.quant_map": "model-00003-of-00003.safetensors",
462
+ "model.layers.27.feed_forward.w2.weight.quant_state.bitsandbytes__nf4": "model-00003-of-00003.safetensors",
463
+ "model.layers.27.feed_forward.w3.weight": "model-00003-of-00003.safetensors",
464
+ "model.layers.27.feed_forward.w3.weight.absmax": "model-00003-of-00003.safetensors",
465
+ "model.layers.27.feed_forward.w3.weight.quant_map": "model-00003-of-00003.safetensors",
466
+ "model.layers.27.feed_forward.w3.weight.quant_state.bitsandbytes__nf4": "model-00003-of-00003.safetensors",
467
+ "model.layers.27.ffn_norm.weight": "model-00003-of-00003.safetensors",
468
+ "model.layers.28.attention.wo.weight": "model-00003-of-00003.safetensors",
469
+ "model.layers.28.attention.wo.weight.absmax": "model-00003-of-00003.safetensors",
470
+ "model.layers.28.attention.wo.weight.quant_map": "model-00003-of-00003.safetensors",
471
+ "model.layers.28.attention.wo.weight.quant_state.bitsandbytes__nf4": "model-00003-of-00003.safetensors",
472
+ "model.layers.28.attention.wqkv.weight": "model-00003-of-00003.safetensors",
473
+ "model.layers.28.attention.wqkv.weight.absmax": "model-00003-of-00003.safetensors",
474
+ "model.layers.28.attention.wqkv.weight.quant_map": "model-00003-of-00003.safetensors",
475
+ "model.layers.28.attention.wqkv.weight.quant_state.bitsandbytes__nf4": "model-00003-of-00003.safetensors",
476
+ "model.layers.28.attention_norm.weight": "model-00003-of-00003.safetensors",
477
+ "model.layers.28.feed_forward.w1.weight": "model-00003-of-00003.safetensors",
478
+ "model.layers.28.feed_forward.w1.weight.absmax": "model-00003-of-00003.safetensors",
479
+ "model.layers.28.feed_forward.w1.weight.quant_map": "model-00003-of-00003.safetensors",
480
+ "model.layers.28.feed_forward.w1.weight.quant_state.bitsandbytes__nf4": "model-00003-of-00003.safetensors",
481
+ "model.layers.28.feed_forward.w2.weight": "model-00003-of-00003.safetensors",
482
+ "model.layers.28.feed_forward.w2.weight.absmax": "model-00003-of-00003.safetensors",
483
+ "model.layers.28.feed_forward.w2.weight.quant_map": "model-00003-of-00003.safetensors",
484
+ "model.layers.28.feed_forward.w2.weight.quant_state.bitsandbytes__nf4": "model-00003-of-00003.safetensors",
485
+ "model.layers.28.feed_forward.w3.weight": "model-00003-of-00003.safetensors",
486
+ "model.layers.28.feed_forward.w3.weight.absmax": "model-00003-of-00003.safetensors",
487
+ "model.layers.28.feed_forward.w3.weight.quant_map": "model-00003-of-00003.safetensors",
488
+ "model.layers.28.feed_forward.w3.weight.quant_state.bitsandbytes__nf4": "model-00003-of-00003.safetensors",
489
+ "model.layers.28.ffn_norm.weight": "model-00003-of-00003.safetensors",
490
+ "model.layers.29.attention.wo.weight": "model-00003-of-00003.safetensors",
491
+ "model.layers.29.attention.wo.weight.absmax": "model-00003-of-00003.safetensors",
492
+ "model.layers.29.attention.wo.weight.quant_map": "model-00003-of-00003.safetensors",
493
+ "model.layers.29.attention.wo.weight.quant_state.bitsandbytes__nf4": "model-00003-of-00003.safetensors",
494
+ "model.layers.29.attention.wqkv.weight": "model-00003-of-00003.safetensors",
495
+ "model.layers.29.attention.wqkv.weight.absmax": "model-00003-of-00003.safetensors",
496
+ "model.layers.29.attention.wqkv.weight.quant_map": "model-00003-of-00003.safetensors",
497
+ "model.layers.29.attention.wqkv.weight.quant_state.bitsandbytes__nf4": "model-00003-of-00003.safetensors",
498
+ "model.layers.29.attention_norm.weight": "model-00003-of-00003.safetensors",
499
+ "model.layers.29.feed_forward.w1.weight": "model-00003-of-00003.safetensors",
500
+ "model.layers.29.feed_forward.w1.weight.absmax": "model-00003-of-00003.safetensors",
501
+ "model.layers.29.feed_forward.w1.weight.quant_map": "model-00003-of-00003.safetensors",
502
+ "model.layers.29.feed_forward.w1.weight.quant_state.bitsandbytes__nf4": "model-00003-of-00003.safetensors",
503
+ "model.layers.29.feed_forward.w2.weight": "model-00003-of-00003.safetensors",
504
+ "model.layers.29.feed_forward.w2.weight.absmax": "model-00003-of-00003.safetensors",
505
+ "model.layers.29.feed_forward.w2.weight.quant_map": "model-00003-of-00003.safetensors",
506
+ "model.layers.29.feed_forward.w2.weight.quant_state.bitsandbytes__nf4": "model-00003-of-00003.safetensors",
507
+ "model.layers.29.feed_forward.w3.weight": "model-00003-of-00003.safetensors",
508
+ "model.layers.29.feed_forward.w3.weight.absmax": "model-00003-of-00003.safetensors",
509
+ "model.layers.29.feed_forward.w3.weight.quant_map": "model-00003-of-00003.safetensors",
510
+ "model.layers.29.feed_forward.w3.weight.quant_state.bitsandbytes__nf4": "model-00003-of-00003.safetensors",
511
+ "model.layers.29.ffn_norm.weight": "model-00003-of-00003.safetensors",
512
+ "model.layers.3.attention.wo.weight": "model-00001-of-00003.safetensors",
513
+ "model.layers.3.attention.wo.weight.absmax": "model-00001-of-00003.safetensors",
514
+ "model.layers.3.attention.wo.weight.quant_map": "model-00001-of-00003.safetensors",
515
+ "model.layers.3.attention.wo.weight.quant_state.bitsandbytes__nf4": "model-00001-of-00003.safetensors",
516
+ "model.layers.3.attention.wqkv.weight": "model-00001-of-00003.safetensors",
517
+ "model.layers.3.attention.wqkv.weight.absmax": "model-00001-of-00003.safetensors",
518
+ "model.layers.3.attention.wqkv.weight.quant_map": "model-00001-of-00003.safetensors",
519
+ "model.layers.3.attention.wqkv.weight.quant_state.bitsandbytes__nf4": "model-00001-of-00003.safetensors",
520
+ "model.layers.3.attention_norm.weight": "model-00001-of-00003.safetensors",
521
+ "model.layers.3.feed_forward.w1.weight": "model-00001-of-00003.safetensors",
522
+ "model.layers.3.feed_forward.w1.weight.absmax": "model-00001-of-00003.safetensors",
523
+ "model.layers.3.feed_forward.w1.weight.quant_map": "model-00001-of-00003.safetensors",
524
+ "model.layers.3.feed_forward.w1.weight.quant_state.bitsandbytes__nf4": "model-00001-of-00003.safetensors",
525
+ "model.layers.3.feed_forward.w2.weight": "model-00001-of-00003.safetensors",
526
+ "model.layers.3.feed_forward.w2.weight.absmax": "model-00001-of-00003.safetensors",
527
+ "model.layers.3.feed_forward.w2.weight.quant_map": "model-00001-of-00003.safetensors",
528
+ "model.layers.3.feed_forward.w2.weight.quant_state.bitsandbytes__nf4": "model-00001-of-00003.safetensors",
529
+ "model.layers.3.feed_forward.w3.weight": "model-00001-of-00003.safetensors",
530
+ "model.layers.3.feed_forward.w3.weight.absmax": "model-00001-of-00003.safetensors",
531
+ "model.layers.3.feed_forward.w3.weight.quant_map": "model-00001-of-00003.safetensors",
532
+ "model.layers.3.feed_forward.w3.weight.quant_state.bitsandbytes__nf4": "model-00001-of-00003.safetensors",
533
+ "model.layers.3.ffn_norm.weight": "model-00001-of-00003.safetensors",
534
+ "model.layers.30.attention.wo.weight": "model-00003-of-00003.safetensors",
535
+ "model.layers.30.attention.wo.weight.absmax": "model-00003-of-00003.safetensors",
536
+ "model.layers.30.attention.wo.weight.quant_map": "model-00003-of-00003.safetensors",
537
+ "model.layers.30.attention.wo.weight.quant_state.bitsandbytes__nf4": "model-00003-of-00003.safetensors",
538
+ "model.layers.30.attention.wqkv.weight": "model-00003-of-00003.safetensors",
539
+ "model.layers.30.attention.wqkv.weight.absmax": "model-00003-of-00003.safetensors",
540
+ "model.layers.30.attention.wqkv.weight.quant_map": "model-00003-of-00003.safetensors",
541
+ "model.layers.30.attention.wqkv.weight.quant_state.bitsandbytes__nf4": "model-00003-of-00003.safetensors",
542
+ "model.layers.30.attention_norm.weight": "model-00003-of-00003.safetensors",
543
+ "model.layers.30.feed_forward.w1.weight": "model-00003-of-00003.safetensors",
544
+ "model.layers.30.feed_forward.w1.weight.absmax": "model-00003-of-00003.safetensors",
545
+ "model.layers.30.feed_forward.w1.weight.quant_map": "model-00003-of-00003.safetensors",
546
+ "model.layers.30.feed_forward.w1.weight.quant_state.bitsandbytes__nf4": "model-00003-of-00003.safetensors",
547
+ "model.layers.30.feed_forward.w2.weight": "model-00003-of-00003.safetensors",
548
+ "model.layers.30.feed_forward.w2.weight.absmax": "model-00003-of-00003.safetensors",
549
+ "model.layers.30.feed_forward.w2.weight.quant_map": "model-00003-of-00003.safetensors",
550
+ "model.layers.30.feed_forward.w2.weight.quant_state.bitsandbytes__nf4": "model-00003-of-00003.safetensors",
551
+ "model.layers.30.feed_forward.w3.weight": "model-00003-of-00003.safetensors",
552
+ "model.layers.30.feed_forward.w3.weight.absmax": "model-00003-of-00003.safetensors",
553
+ "model.layers.30.feed_forward.w3.weight.quant_map": "model-00003-of-00003.safetensors",
554
+ "model.layers.30.feed_forward.w3.weight.quant_state.bitsandbytes__nf4": "model-00003-of-00003.safetensors",
555
+ "model.layers.30.ffn_norm.weight": "model-00003-of-00003.safetensors",
556
+ "model.layers.31.attention.wo.weight": "model-00003-of-00003.safetensors",
557
+ "model.layers.31.attention.wo.weight.absmax": "model-00003-of-00003.safetensors",
558
+ "model.layers.31.attention.wo.weight.quant_map": "model-00003-of-00003.safetensors",
559
+ "model.layers.31.attention.wo.weight.quant_state.bitsandbytes__nf4": "model-00003-of-00003.safetensors",
560
+ "model.layers.31.attention.wqkv.weight": "model-00003-of-00003.safetensors",
561
+ "model.layers.31.attention.wqkv.weight.absmax": "model-00003-of-00003.safetensors",
562
+ "model.layers.31.attention.wqkv.weight.quant_map": "model-00003-of-00003.safetensors",
563
+ "model.layers.31.attention.wqkv.weight.quant_state.bitsandbytes__nf4": "model-00003-of-00003.safetensors",
564
+ "model.layers.31.attention_norm.weight": "model-00003-of-00003.safetensors",
565
+ "model.layers.31.feed_forward.w1.weight": "model-00003-of-00003.safetensors",
566
+ "model.layers.31.feed_forward.w1.weight.absmax": "model-00003-of-00003.safetensors",
567
+ "model.layers.31.feed_forward.w1.weight.quant_map": "model-00003-of-00003.safetensors",
568
+ "model.layers.31.feed_forward.w1.weight.quant_state.bitsandbytes__nf4": "model-00003-of-00003.safetensors",
569
+ "model.layers.31.feed_forward.w2.weight": "model-00003-of-00003.safetensors",
570
+ "model.layers.31.feed_forward.w2.weight.absmax": "model-00003-of-00003.safetensors",
571
+ "model.layers.31.feed_forward.w2.weight.quant_map": "model-00003-of-00003.safetensors",
572
+ "model.layers.31.feed_forward.w2.weight.quant_state.bitsandbytes__nf4": "model-00003-of-00003.safetensors",
573
+ "model.layers.31.feed_forward.w3.weight": "model-00003-of-00003.safetensors",
574
+ "model.layers.31.feed_forward.w3.weight.absmax": "model-00003-of-00003.safetensors",
575
+ "model.layers.31.feed_forward.w3.weight.quant_map": "model-00003-of-00003.safetensors",
576
+ "model.layers.31.feed_forward.w3.weight.quant_state.bitsandbytes__nf4": "model-00003-of-00003.safetensors",
577
+ "model.layers.31.ffn_norm.weight": "model-00003-of-00003.safetensors",
578
+ "model.layers.4.attention.wo.weight": "model-00001-of-00003.safetensors",
579
+ "model.layers.4.attention.wo.weight.absmax": "model-00001-of-00003.safetensors",
580
+ "model.layers.4.attention.wo.weight.quant_map": "model-00001-of-00003.safetensors",
581
+ "model.layers.4.attention.wo.weight.quant_state.bitsandbytes__nf4": "model-00001-of-00003.safetensors",
582
+ "model.layers.4.attention.wqkv.weight": "model-00001-of-00003.safetensors",
583
+ "model.layers.4.attention.wqkv.weight.absmax": "model-00001-of-00003.safetensors",
584
+ "model.layers.4.attention.wqkv.weight.quant_map": "model-00001-of-00003.safetensors",
585
+ "model.layers.4.attention.wqkv.weight.quant_state.bitsandbytes__nf4": "model-00001-of-00003.safetensors",
586
+ "model.layers.4.attention_norm.weight": "model-00001-of-00003.safetensors",
587
+ "model.layers.4.feed_forward.w1.weight": "model-00001-of-00003.safetensors",
588
+ "model.layers.4.feed_forward.w1.weight.absmax": "model-00001-of-00003.safetensors",
589
+ "model.layers.4.feed_forward.w1.weight.quant_map": "model-00001-of-00003.safetensors",
590
+ "model.layers.4.feed_forward.w1.weight.quant_state.bitsandbytes__nf4": "model-00001-of-00003.safetensors",
591
+ "model.layers.4.feed_forward.w2.weight": "model-00001-of-00003.safetensors",
592
+ "model.layers.4.feed_forward.w2.weight.absmax": "model-00001-of-00003.safetensors",
593
+ "model.layers.4.feed_forward.w2.weight.quant_map": "model-00001-of-00003.safetensors",
594
+ "model.layers.4.feed_forward.w2.weight.quant_state.bitsandbytes__nf4": "model-00001-of-00003.safetensors",
595
+ "model.layers.4.feed_forward.w3.weight": "model-00001-of-00003.safetensors",
596
+ "model.layers.4.feed_forward.w3.weight.absmax": "model-00001-of-00003.safetensors",
597
+ "model.layers.4.feed_forward.w3.weight.quant_map": "model-00001-of-00003.safetensors",
598
+ "model.layers.4.feed_forward.w3.weight.quant_state.bitsandbytes__nf4": "model-00001-of-00003.safetensors",
599
+ "model.layers.4.ffn_norm.weight": "model-00001-of-00003.safetensors",
600
+ "model.layers.5.attention.wo.weight": "model-00001-of-00003.safetensors",
601
+ "model.layers.5.attention.wo.weight.absmax": "model-00001-of-00003.safetensors",
602
+ "model.layers.5.attention.wo.weight.quant_map": "model-00001-of-00003.safetensors",
603
+ "model.layers.5.attention.wo.weight.quant_state.bitsandbytes__nf4": "model-00001-of-00003.safetensors",
604
+ "model.layers.5.attention.wqkv.weight": "model-00001-of-00003.safetensors",
605
+ "model.layers.5.attention.wqkv.weight.absmax": "model-00001-of-00003.safetensors",
606
+ "model.layers.5.attention.wqkv.weight.quant_map": "model-00001-of-00003.safetensors",
607
+ "model.layers.5.attention.wqkv.weight.quant_state.bitsandbytes__nf4": "model-00001-of-00003.safetensors",
608
+ "model.layers.5.attention_norm.weight": "model-00001-of-00003.safetensors",
609
+ "model.layers.5.feed_forward.w1.weight": "model-00001-of-00003.safetensors",
610
+ "model.layers.5.feed_forward.w1.weight.absmax": "model-00001-of-00003.safetensors",
611
+ "model.layers.5.feed_forward.w1.weight.quant_map": "model-00001-of-00003.safetensors",
612
+ "model.layers.5.feed_forward.w1.weight.quant_state.bitsandbytes__nf4": "model-00001-of-00003.safetensors",
613
+ "model.layers.5.feed_forward.w2.weight": "model-00001-of-00003.safetensors",
614
+ "model.layers.5.feed_forward.w2.weight.absmax": "model-00001-of-00003.safetensors",
615
+ "model.layers.5.feed_forward.w2.weight.quant_map": "model-00001-of-00003.safetensors",
616
+ "model.layers.5.feed_forward.w2.weight.quant_state.bitsandbytes__nf4": "model-00001-of-00003.safetensors",
617
+ "model.layers.5.feed_forward.w3.weight": "model-00001-of-00003.safetensors",
618
+ "model.layers.5.feed_forward.w3.weight.absmax": "model-00001-of-00003.safetensors",
619
+ "model.layers.5.feed_forward.w3.weight.quant_map": "model-00001-of-00003.safetensors",
620
+ "model.layers.5.feed_forward.w3.weight.quant_state.bitsandbytes__nf4": "model-00001-of-00003.safetensors",
621
+ "model.layers.5.ffn_norm.weight": "model-00001-of-00003.safetensors",
622
+ "model.layers.6.attention.wo.weight": "model-00001-of-00003.safetensors",
623
+ "model.layers.6.attention.wo.weight.absmax": "model-00001-of-00003.safetensors",
624
+ "model.layers.6.attention.wo.weight.quant_map": "model-00001-of-00003.safetensors",
625
+ "model.layers.6.attention.wo.weight.quant_state.bitsandbytes__nf4": "model-00001-of-00003.safetensors",
626
+ "model.layers.6.attention.wqkv.weight": "model-00001-of-00003.safetensors",
627
+ "model.layers.6.attention.wqkv.weight.absmax": "model-00001-of-00003.safetensors",
628
+ "model.layers.6.attention.wqkv.weight.quant_map": "model-00001-of-00003.safetensors",
629
+ "model.layers.6.attention.wqkv.weight.quant_state.bitsandbytes__nf4": "model-00001-of-00003.safetensors",
630
+ "model.layers.6.attention_norm.weight": "model-00001-of-00003.safetensors",
631
+ "model.layers.6.feed_forward.w1.weight": "model-00001-of-00003.safetensors",
632
+ "model.layers.6.feed_forward.w1.weight.absmax": "model-00001-of-00003.safetensors",
633
+ "model.layers.6.feed_forward.w1.weight.quant_map": "model-00001-of-00003.safetensors",
634
+ "model.layers.6.feed_forward.w1.weight.quant_state.bitsandbytes__nf4": "model-00001-of-00003.safetensors",
635
+ "model.layers.6.feed_forward.w2.weight": "model-00001-of-00003.safetensors",
636
+ "model.layers.6.feed_forward.w2.weight.absmax": "model-00001-of-00003.safetensors",
637
+ "model.layers.6.feed_forward.w2.weight.quant_map": "model-00001-of-00003.safetensors",
638
+ "model.layers.6.feed_forward.w2.weight.quant_state.bitsandbytes__nf4": "model-00001-of-00003.safetensors",
639
+ "model.layers.6.feed_forward.w3.weight": "model-00001-of-00003.safetensors",
640
+ "model.layers.6.feed_forward.w3.weight.absmax": "model-00001-of-00003.safetensors",
641
+ "model.layers.6.feed_forward.w3.weight.quant_map": "model-00001-of-00003.safetensors",
642
+ "model.layers.6.feed_forward.w3.weight.quant_state.bitsandbytes__nf4": "model-00001-of-00003.safetensors",
643
+ "model.layers.6.ffn_norm.weight": "model-00001-of-00003.safetensors",
644
+ "model.layers.7.attention.wo.weight": "model-00001-of-00003.safetensors",
645
+ "model.layers.7.attention.wo.weight.absmax": "model-00001-of-00003.safetensors",
646
+ "model.layers.7.attention.wo.weight.quant_map": "model-00001-of-00003.safetensors",
647
+ "model.layers.7.attention.wo.weight.quant_state.bitsandbytes__nf4": "model-00001-of-00003.safetensors",
648
+ "model.layers.7.attention.wqkv.weight": "model-00001-of-00003.safetensors",
649
+ "model.layers.7.attention.wqkv.weight.absmax": "model-00001-of-00003.safetensors",
650
+ "model.layers.7.attention.wqkv.weight.quant_map": "model-00001-of-00003.safetensors",
651
+ "model.layers.7.attention.wqkv.weight.quant_state.bitsandbytes__nf4": "model-00001-of-00003.safetensors",
652
+ "model.layers.7.attention_norm.weight": "model-00001-of-00003.safetensors",
653
+ "model.layers.7.feed_forward.w1.weight": "model-00001-of-00003.safetensors",
654
+ "model.layers.7.feed_forward.w1.weight.absmax": "model-00001-of-00003.safetensors",
655
+ "model.layers.7.feed_forward.w1.weight.quant_map": "model-00001-of-00003.safetensors",
656
+ "model.layers.7.feed_forward.w1.weight.quant_state.bitsandbytes__nf4": "model-00001-of-00003.safetensors",
657
+ "model.layers.7.feed_forward.w2.weight": "model-00001-of-00003.safetensors",
658
+ "model.layers.7.feed_forward.w2.weight.absmax": "model-00001-of-00003.safetensors",
659
+ "model.layers.7.feed_forward.w2.weight.quant_map": "model-00001-of-00003.safetensors",
660
+ "model.layers.7.feed_forward.w2.weight.quant_state.bitsandbytes__nf4": "model-00001-of-00003.safetensors",
661
+ "model.layers.7.feed_forward.w3.weight": "model-00001-of-00003.safetensors",
662
+ "model.layers.7.feed_forward.w3.weight.absmax": "model-00001-of-00003.safetensors",
663
+ "model.layers.7.feed_forward.w3.weight.quant_map": "model-00001-of-00003.safetensors",
664
+ "model.layers.7.feed_forward.w3.weight.quant_state.bitsandbytes__nf4": "model-00001-of-00003.safetensors",
665
+ "model.layers.7.ffn_norm.weight": "model-00001-of-00003.safetensors",
666
+ "model.layers.8.attention.wo.weight": "model-00001-of-00003.safetensors",
667
+ "model.layers.8.attention.wo.weight.absmax": "model-00001-of-00003.safetensors",
668
+ "model.layers.8.attention.wo.weight.quant_map": "model-00001-of-00003.safetensors",
669
+ "model.layers.8.attention.wo.weight.quant_state.bitsandbytes__nf4": "model-00001-of-00003.safetensors",
670
+ "model.layers.8.attention.wqkv.weight": "model-00001-of-00003.safetensors",
671
+ "model.layers.8.attention.wqkv.weight.absmax": "model-00001-of-00003.safetensors",
672
+ "model.layers.8.attention.wqkv.weight.quant_map": "model-00001-of-00003.safetensors",
673
+ "model.layers.8.attention.wqkv.weight.quant_state.bitsandbytes__nf4": "model-00001-of-00003.safetensors",
674
+ "model.layers.8.attention_norm.weight": "model-00001-of-00003.safetensors",
675
+ "model.layers.8.feed_forward.w1.weight": "model-00001-of-00003.safetensors",
676
+ "model.layers.8.feed_forward.w1.weight.absmax": "model-00001-of-00003.safetensors",
677
+ "model.layers.8.feed_forward.w1.weight.quant_map": "model-00001-of-00003.safetensors",
678
+ "model.layers.8.feed_forward.w1.weight.quant_state.bitsandbytes__nf4": "model-00001-of-00003.safetensors",
679
+ "model.layers.8.feed_forward.w2.weight": "model-00001-of-00003.safetensors",
680
+ "model.layers.8.feed_forward.w2.weight.absmax": "model-00001-of-00003.safetensors",
681
+ "model.layers.8.feed_forward.w2.weight.quant_map": "model-00001-of-00003.safetensors",
682
+ "model.layers.8.feed_forward.w2.weight.quant_state.bitsandbytes__nf4": "model-00001-of-00003.safetensors",
683
+ "model.layers.8.feed_forward.w3.weight": "model-00001-of-00003.safetensors",
684
+ "model.layers.8.feed_forward.w3.weight.absmax": "model-00001-of-00003.safetensors",
685
+ "model.layers.8.feed_forward.w3.weight.quant_map": "model-00001-of-00003.safetensors",
686
+ "model.layers.8.feed_forward.w3.weight.quant_state.bitsandbytes__nf4": "model-00001-of-00003.safetensors",
687
+ "model.layers.8.ffn_norm.weight": "model-00001-of-00003.safetensors",
688
+ "model.layers.9.attention.wo.weight": "model-00001-of-00003.safetensors",
689
+ "model.layers.9.attention.wo.weight.absmax": "model-00001-of-00003.safetensors",
690
+ "model.layers.9.attention.wo.weight.quant_map": "model-00001-of-00003.safetensors",
691
+ "model.layers.9.attention.wo.weight.quant_state.bitsandbytes__nf4": "model-00001-of-00003.safetensors",
692
+ "model.layers.9.attention.wqkv.weight": "model-00001-of-00003.safetensors",
693
+ "model.layers.9.attention.wqkv.weight.absmax": "model-00001-of-00003.safetensors",
694
+ "model.layers.9.attention.wqkv.weight.quant_map": "model-00001-of-00003.safetensors",
695
+ "model.layers.9.attention.wqkv.weight.quant_state.bitsandbytes__nf4": "model-00001-of-00003.safetensors",
696
+ "model.layers.9.attention_norm.weight": "model-00001-of-00003.safetensors",
697
+ "model.layers.9.feed_forward.w1.weight": "model-00001-of-00003.safetensors",
698
+ "model.layers.9.feed_forward.w1.weight.absmax": "model-00001-of-00003.safetensors",
699
+ "model.layers.9.feed_forward.w1.weight.quant_map": "model-00001-of-00003.safetensors",
700
+ "model.layers.9.feed_forward.w1.weight.quant_state.bitsandbytes__nf4": "model-00001-of-00003.safetensors",
701
+ "model.layers.9.feed_forward.w2.weight": "model-00001-of-00003.safetensors",
702
+ "model.layers.9.feed_forward.w2.weight.absmax": "model-00001-of-00003.safetensors",
703
+ "model.layers.9.feed_forward.w2.weight.quant_map": "model-00001-of-00003.safetensors",
704
+ "model.layers.9.feed_forward.w2.weight.quant_state.bitsandbytes__nf4": "model-00001-of-00003.safetensors",
705
+ "model.layers.9.feed_forward.w3.weight": "model-00001-of-00003.safetensors",
706
+ "model.layers.9.feed_forward.w3.weight.absmax": "model-00001-of-00003.safetensors",
707
+ "model.layers.9.feed_forward.w3.weight.quant_map": "model-00001-of-00003.safetensors",
708
+ "model.layers.9.feed_forward.w3.weight.quant_state.bitsandbytes__nf4": "model-00001-of-00003.safetensors",
709
+ "model.layers.9.ffn_norm.weight": "model-00001-of-00003.safetensors",
710
+ "model.norm.weight": "model-00003-of-00003.safetensors",
711
+ "model.tok_embeddings.weight": "model-00001-of-00003.safetensors",
712
+ "output.weight": "model-00003-of-00003.safetensors"
713
+ }
714
+ }
modeling_internlm2.py ADDED
@@ -0,0 +1,1246 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # coding=utf-8
2
+ # # Copyright (c) InternLM. All rights reserved.
3
+ #
4
+ # This code is based on EleutherAI's GPT-NeoX library and the GPT-NeoX
5
+ # and OPT implementations in this library. It has been modified from its
6
+ # original forms to accommodate minor architectural differences compared
7
+ # to GPT-NeoX and OPT used by the Meta AI team that trained the model.
8
+ #
9
+ # Licensed under the Apache License, Version 2.0 (the "License");
10
+ # you may not use this file except in compliance with the License.
11
+ # You may obtain a copy of the License at
12
+ #
13
+ # http://www.apache.org/licenses/LICENSE-2.0
14
+ #
15
+ # Unless required by applicable law or agreed to in writing, software
16
+ # distributed under the License is distributed on an "AS IS" BASIS,
17
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
+ # See the License for the specific language governing permissions and
19
+ # limitations under the License.
20
+ """ PyTorch InternLM2 model."""
21
+ import math
22
+ import queue
23
+ import threading
24
+ import warnings
25
+ from typing import List, Optional, Tuple, Union
26
+
27
+ import torch
28
+ import torch.utils.checkpoint
29
+ from einops import rearrange
30
+ from torch import nn
31
+ from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss
32
+ from transformers.activations import ACT2FN
33
+ from transformers.modeling_outputs import (
34
+ BaseModelOutputWithPast,
35
+ CausalLMOutputWithPast,
36
+ SequenceClassifierOutputWithPast,
37
+ )
38
+ from transformers.modeling_utils import PreTrainedModel
39
+ from transformers.utils import (
40
+ add_start_docstrings,
41
+ add_start_docstrings_to_model_forward,
42
+ logging,
43
+ replace_return_docstrings,
44
+ )
45
+
46
+ try:
47
+ from transformers.generation.streamers import BaseStreamer
48
+ except: # noqa # pylint: disable=bare-except
49
+ BaseStreamer = None
50
+
51
+ from .configuration_internlm import InternLMConfig as InternLM2Config
52
+
53
+ logger = logging.get_logger(__name__)
54
+
55
+ _CONFIG_FOR_DOC = "InternLM2Config"
56
+
57
+
58
+ # Copied from transformers.models.bart.modeling_bart._make_causal_mask
59
+ def _make_causal_mask(
60
+ input_ids_shape: torch.Size, dtype: torch.dtype, device: torch.device, past_key_values_length: int = 0
61
+ ):
62
+ """
63
+ Make causal mask used for bi-directional self-attention.
64
+ """
65
+ bsz, tgt_len = input_ids_shape
66
+ mask = torch.full((tgt_len, tgt_len), torch.tensor(torch.finfo(dtype).min, device=device), device=device)
67
+ mask_cond = torch.arange(mask.size(-1), device=device)
68
+ mask.masked_fill_(mask_cond < (mask_cond + 1).view(mask.size(-1), 1), 0)
69
+ mask = mask.to(dtype)
70
+
71
+ if past_key_values_length > 0:
72
+ mask = torch.cat([torch.zeros(tgt_len, past_key_values_length, dtype=dtype, device=device), mask], dim=-1)
73
+ return mask[None, None, :, :].expand(bsz, 1, tgt_len, tgt_len + past_key_values_length)
74
+
75
+
76
+ # Copied from transformers.models.bart.modeling_bart._expand_mask
77
+ def _expand_mask(mask: torch.Tensor, dtype: torch.dtype, tgt_len: Optional[int] = None):
78
+ """
79
+ Expands attention_mask from `[bsz, seq_len]` to `[bsz, 1, tgt_seq_len, src_seq_len]`.
80
+ """
81
+ bsz, src_len = mask.size()
82
+ tgt_len = tgt_len if tgt_len is not None else src_len
83
+
84
+ expanded_mask = mask[:, None, None, :].expand(bsz, 1, tgt_len, src_len).to(dtype)
85
+
86
+ inverted_mask = 1.0 - expanded_mask
87
+
88
+ return inverted_mask.masked_fill(inverted_mask.to(torch.bool), torch.finfo(dtype).min)
89
+
90
+
91
+ class InternLM2RMSNorm(nn.Module):
92
+ def __init__(self, hidden_size, eps=1e-6):
93
+ """
94
+ InternLM2RMSNorm is equivalent to T5LayerNorm
95
+ """
96
+ super().__init__()
97
+ self.weight = nn.Parameter(torch.ones(hidden_size))
98
+ self.variance_epsilon = eps
99
+
100
+ def forward(self, hidden_states):
101
+ input_dtype = hidden_states.dtype
102
+ hidden_states = hidden_states.to(torch.float32)
103
+ variance = hidden_states.pow(2).mean(-1, keepdim=True)
104
+ hidden_states = hidden_states * torch.rsqrt(variance + self.variance_epsilon)
105
+ return self.weight * hidden_states.to(input_dtype)
106
+
107
+
108
+ class InternLM2RotaryEmbedding(nn.Module):
109
+ def __init__(self, dim, max_position_embeddings=2048, base=10000, device=None):
110
+ super().__init__()
111
+
112
+ self.dim = dim
113
+ self.max_position_embeddings = max_position_embeddings
114
+ self.base = base
115
+ inv_freq = 1.0 / (self.base ** (torch.arange(0, self.dim, 2).float().to(device) / self.dim))
116
+ self.register_buffer("inv_freq", inv_freq, persistent=False)
117
+
118
+ # Build here to make `torch.jit.trace` work.
119
+ self._set_cos_sin_cache(
120
+ seq_len=max_position_embeddings, device=self.inv_freq.device, dtype=torch.get_default_dtype()
121
+ )
122
+
123
+ def _set_cos_sin_cache(self, seq_len, device, dtype):
124
+ self.max_seq_len_cached = seq_len
125
+ t = torch.arange(self.max_seq_len_cached, device=device, dtype=self.inv_freq.dtype)
126
+
127
+ freqs = torch.einsum("i,j->ij", t, self.inv_freq)
128
+ # Different from paper, but it uses a different permutation in order to obtain the same calculation
129
+ emb = torch.cat((freqs, freqs), dim=-1)
130
+ self.register_buffer("cos_cached", emb.cos().to(dtype), persistent=False)
131
+ self.register_buffer("sin_cached", emb.sin().to(dtype), persistent=False)
132
+
133
+ def forward(self, x, seq_len=None):
134
+ # x: [bs, num_attention_heads, seq_len, head_size]
135
+ if seq_len > self.max_seq_len_cached:
136
+ self._set_cos_sin_cache(seq_len=seq_len, device=x.device, dtype=x.dtype)
137
+
138
+ return (
139
+ self.cos_cached[:seq_len].to(dtype=x.dtype),
140
+ self.sin_cached[:seq_len].to(dtype=x.dtype),
141
+ )
142
+
143
+
144
+ class InternLM2LinearScalingRotaryEmbedding(InternLM2RotaryEmbedding):
145
+ """InternLM2RotaryEmbedding extended with linear scaling. Credits to the Reddit user /u/kaiokendev"""
146
+
147
+ def __init__(self, dim, max_position_embeddings=2048, base=10000, device=None, scaling_factor=1.0):
148
+ self.scaling_factor = scaling_factor
149
+ super().__init__(dim, max_position_embeddings, base, device)
150
+
151
+ def _set_cos_sin_cache(self, seq_len, device, dtype):
152
+ self.max_seq_len_cached = seq_len
153
+ t = torch.arange(self.max_seq_len_cached, device=device, dtype=self.inv_freq.dtype)
154
+ t = t / self.scaling_factor
155
+
156
+ freqs = torch.einsum("i,j->ij", t, self.inv_freq)
157
+ # Different from paper, but it uses a different permutation in order to obtain the same calculation
158
+ emb = torch.cat((freqs, freqs), dim=-1)
159
+ self.register_buffer("cos_cached", emb.cos().to(dtype), persistent=False)
160
+ self.register_buffer("sin_cached", emb.sin().to(dtype), persistent=False)
161
+
162
+
163
+ class InternLM2DynamicNTKScalingRotaryEmbedding(InternLM2RotaryEmbedding):
164
+ """InternLM2RotaryEmbedding extended with Dynamic NTK scaling.
165
+ Credits to the Reddit users /u/bloc97 and /u/emozilla.
166
+ """
167
+
168
+ def __init__(self, dim, max_position_embeddings=2048, base=10000, device=None, scaling_factor=1.0):
169
+ self.scaling_factor = scaling_factor
170
+ super().__init__(dim, max_position_embeddings, base, device)
171
+
172
+ def _set_cos_sin_cache(self, seq_len, device, dtype):
173
+ self.max_seq_len_cached = seq_len
174
+
175
+ if seq_len > self.max_position_embeddings:
176
+ base = self.base * (
177
+ (self.scaling_factor * seq_len / self.max_position_embeddings) - (self.scaling_factor - 1)
178
+ ) ** (self.dim / (self.dim - 2))
179
+ inv_freq = 1.0 / (base ** (torch.arange(0, self.dim, 2).float().to(device) / self.dim))
180
+ self.register_buffer("inv_freq", inv_freq, persistent=False)
181
+
182
+ t = torch.arange(self.max_seq_len_cached, device=device, dtype=self.inv_freq.dtype)
183
+
184
+ freqs = torch.einsum("i,j->ij", t, self.inv_freq)
185
+ # Different from paper, but it uses a different permutation in order to obtain the same calculation
186
+ emb = torch.cat((freqs, freqs), dim=-1)
187
+ self.register_buffer("cos_cached", emb.cos().to(dtype), persistent=False)
188
+ self.register_buffer("sin_cached", emb.sin().to(dtype), persistent=False)
189
+
190
+
191
+ def rotate_half(x):
192
+ """Rotates half the hidden dims of the input."""
193
+ x1 = x[..., : x.shape[-1] // 2]
194
+ x2 = x[..., x.shape[-1] // 2 :]
195
+ return torch.cat((-x2, x1), dim=-1)
196
+
197
+
198
+ def apply_rotary_pos_emb(q, k, cos, sin, position_ids):
199
+ # The first two dimensions of cos and sin are always 1, so we can `squeeze` them.
200
+ cos = cos.squeeze(1).squeeze(0) # [seq_len, dim]
201
+ sin = sin.squeeze(1).squeeze(0) # [seq_len, dim]
202
+ cos = cos.unsqueeze(0).unsqueeze(0).expand(len(position_ids), -1, -1, -1)
203
+ sin = sin.unsqueeze(0).unsqueeze(0).expand(len(position_ids), -1, -1, -1)
204
+ if q.size(2) == 1:
205
+ q_embed = (q * cos[:, :, -1, :]) + (rotate_half(q) * sin[:, :, -1, :])
206
+ else:
207
+ q_embed = (q * cos) + (rotate_half(q) * sin)
208
+
209
+ if k.size(2) == 1:
210
+ k_embed = (k * cos[:, :, -1, :]) + (rotate_half(k) * sin[:, :, -1, :])
211
+ else:
212
+ k_embed = (k * cos) + (rotate_half(k) * sin)
213
+
214
+ return q_embed, k_embed
215
+
216
+
217
+ class InternLM2MLP(nn.Module):
218
+ def __init__(self, config):
219
+ super().__init__()
220
+ self.config = config
221
+ self.hidden_size = config.hidden_size
222
+ self.intermediate_size = config.intermediate_size
223
+ self.w1 = nn.Linear(self.hidden_size, self.intermediate_size, bias=False)
224
+ self.w3 = nn.Linear(self.hidden_size, self.intermediate_size, bias=False)
225
+ self.w2 = nn.Linear(self.intermediate_size, self.hidden_size, bias=False)
226
+ self.act_fn = ACT2FN[config.hidden_act]
227
+
228
+ def forward(self, x):
229
+ down_proj = self.w2(self.act_fn(self.w1(x)) * self.w3(x))
230
+
231
+ return down_proj
232
+
233
+
234
+ def repeat_kv(hidden_states: torch.Tensor, n_rep: int) -> torch.Tensor:
235
+ """
236
+ This is the equivalent of torch.repeat_interleave(x, dim=1, repeats=n_rep). The hidden states go from (batch,
237
+ num_key_value_heads, seqlen, head_dim) to (batch, num_attention_heads, seqlen, head_dim)
238
+ """
239
+ batch, num_key_value_heads, slen, head_dim = hidden_states.shape
240
+ if n_rep == 1:
241
+ return hidden_states
242
+ hidden_states = hidden_states[:, :, None, :, :].expand(batch, num_key_value_heads, n_rep, slen, head_dim)
243
+ return hidden_states.reshape(batch, num_key_value_heads * n_rep, slen, head_dim)
244
+
245
+
246
+ class InternLM2Attention(nn.Module):
247
+ """Multi-headed attention from 'Attention Is All You Need' paper"""
248
+
249
+ def __init__(self, config: InternLM2Config):
250
+ super().__init__()
251
+ self.config = config
252
+ self.hidden_size = config.hidden_size
253
+ self.num_heads = config.num_attention_heads
254
+ self.head_dim = self.hidden_size // self.num_heads
255
+ self.num_key_value_heads = config.num_key_value_heads
256
+ self.num_key_value_groups = self.num_heads // self.num_key_value_heads
257
+ self.max_position_embeddings = config.max_position_embeddings
258
+ self.is_causal = True
259
+
260
+ if (self.head_dim * self.num_heads) != self.hidden_size:
261
+ raise ValueError(
262
+ f"hidden_size must be divisible by num_heads (got `hidden_size`: {self.hidden_size}"
263
+ f" and `num_heads`: {self.num_heads})."
264
+ )
265
+
266
+ self.wqkv = nn.Linear(
267
+ self.hidden_size,
268
+ (self.num_heads + 2 * self.num_key_value_heads) * self.head_dim,
269
+ bias=config.bias,
270
+ )
271
+
272
+ self.wo = nn.Linear(self.num_heads * self.head_dim, self.hidden_size, bias=config.bias)
273
+ self._init_rope()
274
+
275
+ def _init_rope(self):
276
+ if self.config.rotary["type"] == "origin":
277
+ self.rotary_emb = InternLM2RotaryEmbedding(
278
+ self.head_dim,
279
+ max_position_embeddings=self.max_position_embeddings,
280
+ base=self.config.rotary["base"],
281
+ )
282
+ elif self.config.rotary["type"] == "dynamic":
283
+ self.rotary_emb = InternLM2DynamicNTKScalingRotaryEmbedding(
284
+ self.head_dim,
285
+ max_position_embeddings=self.max_position_embeddings,
286
+ base=self.config.rotary["base"],
287
+ scaling_factor=self.config.rotary.get("scaling_factor", 1.0),
288
+ )
289
+ elif self.config.rotary["type"] == "linear":
290
+ self.rotary_emb = InternLM2LinearScalingRotaryEmbedding(
291
+ self.head_dim,
292
+ max_position_embeddings=self.max_position_embeddings,
293
+ base=self.config.rotary["base"],
294
+ scaling_factor=self.config.rotary.get("scaling_factor", 1.0),
295
+ )
296
+ else:
297
+ raise ValueError("Currently we only support rotary embedding's type being one of ('origin', 'dynamic').")
298
+ return self.rotary_emb
299
+
300
+ def _shape(self, tensor: torch.Tensor, seq_len: int, bsz: int):
301
+ return tensor.view(bsz, seq_len, self.num_heads, self.head_dim).transpose(1, 2).contiguous()
302
+
303
+ def forward(
304
+ self,
305
+ hidden_states: torch.Tensor,
306
+ attention_mask: Optional[torch.Tensor] = None,
307
+ position_ids: Optional[torch.LongTensor] = None,
308
+ past_key_value: Optional[Tuple[torch.Tensor]] = None,
309
+ output_attentions: bool = False,
310
+ use_cache: bool = False,
311
+ **kwargs,
312
+ ) -> Tuple[torch.Tensor, Optional[torch.Tensor], Optional[Tuple[torch.Tensor]]]:
313
+ if "padding_mask" in kwargs:
314
+ warnings.warn(
315
+ "Passing `padding_mask` is deprecated and will be removed in v4.37. "
316
+ "Please make sure use `attention_mask` instead.`"
317
+ )
318
+
319
+ bsz, q_len, _ = hidden_states.size()
320
+
321
+ qkv_states = self.wqkv(hidden_states)
322
+
323
+ qkv_states = rearrange(
324
+ qkv_states,
325
+ "b q (h gs d) -> b q h gs d",
326
+ gs=2 + self.num_key_value_groups,
327
+ d=self.head_dim,
328
+ )
329
+
330
+ query_states = qkv_states[..., : self.num_key_value_groups, :]
331
+ query_states = rearrange(query_states, "b q h gs d -> b q (h gs) d")
332
+ key_states = qkv_states[..., -2, :]
333
+ value_states = qkv_states[..., -1, :]
334
+
335
+ query_states = query_states.transpose(1, 2)
336
+ key_states = key_states.transpose(1, 2)
337
+ value_states = value_states.transpose(1, 2)
338
+
339
+ kv_seq_len = key_states.shape[-2]
340
+ if past_key_value is not None:
341
+ kv_seq_len += past_key_value[0].shape[-2]
342
+ cos, sin = self.rotary_emb(value_states, seq_len=kv_seq_len)
343
+ query_states, key_states = apply_rotary_pos_emb(query_states, key_states, cos, sin, position_ids)
344
+
345
+ if past_key_value is not None:
346
+ # reuse k, v, self_attention
347
+ key_states = torch.cat([past_key_value[0], key_states], dim=2)
348
+ value_states = torch.cat([past_key_value[1], value_states], dim=2)
349
+
350
+ past_key_value = (key_states, value_states) if use_cache else None
351
+
352
+ key_states = repeat_kv(key_states, self.num_key_value_groups)
353
+ value_states = repeat_kv(value_states, self.num_key_value_groups)
354
+
355
+ attn_weights = torch.matmul(query_states, key_states.transpose(2, 3)) / math.sqrt(self.head_dim)
356
+
357
+ if attn_weights.size() != (bsz, self.num_heads, q_len, kv_seq_len):
358
+ raise ValueError(
359
+ f"Attention weights should be of size {(bsz, self.num_heads, q_len, kv_seq_len)}, but is"
360
+ f" {attn_weights.size()}"
361
+ )
362
+
363
+ if attention_mask is not None:
364
+ if attention_mask.size() != (bsz, 1, q_len, kv_seq_len):
365
+ raise ValueError(
366
+ f"Attention mask should be of size {(bsz, 1, q_len, kv_seq_len)}, but is {attention_mask.size()}"
367
+ )
368
+ attn_weights = attn_weights + attention_mask
369
+
370
+ # upcast attention to fp32
371
+ attn_weights = nn.functional.softmax(attn_weights, dim=-1, dtype=torch.float32).to(query_states.dtype)
372
+ attn_output = torch.matmul(attn_weights, value_states)
373
+
374
+ if attn_output.size() != (bsz, self.num_heads, q_len, self.head_dim):
375
+ raise ValueError(
376
+ f"`attn_output` should be of size {(bsz, self.num_heads, q_len, self.head_dim)}, but is"
377
+ f" {attn_output.size()}"
378
+ )
379
+
380
+ attn_output = attn_output.transpose(1, 2).contiguous()
381
+ attn_output = attn_output.reshape(bsz, q_len, self.hidden_size)
382
+
383
+ attn_output = self.wo(attn_output)
384
+
385
+ if not output_attentions:
386
+ attn_weights = None
387
+
388
+ return attn_output, attn_weights, past_key_value
389
+
390
+
391
+ class InternLM2FlashAttention2(InternLM2Attention):
392
+ """
393
+ InternLM2 flash attention module. This module inherits from `InternLM2Attention` as the weights of the module stays
394
+ untouched. The only required change would be on the forward pass where it needs to correctly call the public API of
395
+ flash attention and deal with padding tokens in case the input contains any of them.
396
+ """
397
+
398
+ def forward(
399
+ self,
400
+ hidden_states: torch.Tensor,
401
+ attention_mask: Optional[torch.LongTensor] = None,
402
+ position_ids: Optional[torch.LongTensor] = None,
403
+ past_key_value: Optional[Tuple[torch.Tensor]] = None,
404
+ output_attentions: bool = False,
405
+ use_cache: bool = False,
406
+ **kwargs,
407
+ ) -> Tuple[torch.Tensor, Optional[torch.Tensor], Optional[Tuple[torch.Tensor]]]:
408
+ # InternLM2FlashAttention2 attention does not support output_attentions
409
+ if "padding_mask" in kwargs:
410
+ warnings.warn(
411
+ "Passing `padding_mask` is deprecated and will be removed in v4.37. "
412
+ "Please make sure use `attention_mask` instead.`"
413
+ )
414
+
415
+ # overwrite attention_mask with padding_mask
416
+ attention_mask = kwargs.pop("padding_mask")
417
+
418
+ output_attentions = False
419
+
420
+ bsz, q_len, _ = hidden_states.size()
421
+
422
+ qkv_states = self.wqkv(hidden_states)
423
+
424
+ qkv_states = rearrange(
425
+ qkv_states,
426
+ "b q (h gs d) -> b q h gs d",
427
+ gs=self.num_heads + 2 * self.num_key_value_heads,
428
+ d=self.head_dim,
429
+ q=q_len,
430
+ )
431
+
432
+ query_states = qkv_states[..., : self.num_key_value_groups, :]
433
+ query_states = rearrange(query_states, "b q h gs d -> b q (h gs) d")
434
+ key_states = qkv_states[..., -2, :]
435
+ value_states = qkv_states[..., -1, :]
436
+
437
+ kv_seq_len = key_states.shape[-2]
438
+ if past_key_value is not None:
439
+ kv_seq_len += past_key_value[0].shape[-2]
440
+
441
+ cos, sin = self.rotary_emb(value_states, seq_len=kv_seq_len)
442
+
443
+ query_states, key_states = apply_rotary_pos_emb(query_states, key_states, cos, sin, position_ids)
444
+
445
+ if past_key_value is not None:
446
+ # reuse k, v, self_attention
447
+ key_states = torch.cat([past_key_value[0], key_states], dim=2)
448
+ value_states = torch.cat([past_key_value[1], value_states], dim=2)
449
+
450
+ past_key_value = (key_states, value_states) if use_cache else None
451
+
452
+ query_states = query_states.transpose(1, 2)
453
+ key_states = key_states.transpose(1, 2)
454
+ value_states = value_states.transpose(1, 2)
455
+
456
+ dropout_rate = 0.0 if not self.training else self.attention_dropout
457
+
458
+ # In PEFT, usually we cast the layer norms in float32 for training stability reasons
459
+ # therefore the input hidden states gets silently casted in float32. Hence, we need
460
+ # cast them back in the correct dtype just to be sure everything works as expected.
461
+ # This might slowdown training & inference so it is recommended to not cast the LayerNorms
462
+ # in fp32. (InternLM2RMSNorm handles it correctly)
463
+
464
+ input_dtype = query_states.dtype
465
+ if input_dtype == torch.float32:
466
+ # Handle the case where the model is quantized
467
+ if hasattr(self.config, "_pre_quantization_dtype"):
468
+ target_dtype = self.config._pre_quantization_dtype
469
+ else:
470
+ target_dtype = self.q_proj.weight.dtype
471
+
472
+ logger.warning_once(
473
+ f"The input hidden states seems to be silently casted in float32, this might be related to"
474
+ f" the fact you have upcasted embedding or layer norm layers in float32. We will cast back "
475
+ f"the input in {target_dtype}."
476
+ )
477
+
478
+ query_states = query_states.to(target_dtype)
479
+ key_states = key_states.to(target_dtype)
480
+ value_states = value_states.to(target_dtype)
481
+
482
+ attn_output = self._flash_attention_forward(
483
+ query_states, key_states, value_states, attention_mask, q_len, dropout=dropout_rate
484
+ )
485
+
486
+ attn_output = attn_output.reshape(bsz, q_len, self.hidden_size).contiguous()
487
+ attn_output = self.wo(attn_output)
488
+
489
+ if not output_attentions:
490
+ attn_weights = None
491
+
492
+ return attn_output, attn_weights, past_key_value
493
+
494
+
495
+ class InternLM2DecoderLayer(nn.Module):
496
+ def __init__(self, config: InternLM2Config):
497
+ super().__init__()
498
+ self.hidden_size = config.hidden_size
499
+ self.attention = (
500
+ InternLM2Attention(config=config)
501
+ if not getattr(config, "_flash_attn_2_enabled", False)
502
+ else InternLM2FlashAttention2(config=config)
503
+ )
504
+ self.feed_forward = InternLM2MLP(config)
505
+ self.attention_norm = InternLM2RMSNorm(config.hidden_size, eps=config.rms_norm_eps)
506
+ self.ffn_norm = InternLM2RMSNorm(config.hidden_size, eps=config.rms_norm_eps)
507
+
508
+ def forward(
509
+ self,
510
+ hidden_states: torch.Tensor,
511
+ attention_mask: Optional[torch.Tensor] = None,
512
+ position_ids: Optional[torch.LongTensor] = None,
513
+ past_key_value: Optional[Tuple[torch.Tensor]] = None,
514
+ output_attentions: Optional[bool] = False,
515
+ use_cache: Optional[bool] = False,
516
+ **kwargs,
517
+ ) -> Tuple[torch.FloatTensor, Optional[Tuple[torch.FloatTensor, torch.FloatTensor]]]:
518
+ """
519
+ Args:
520
+ hidden_states (`torch.FloatTensor`): input to the layer of shape `(batch, seq_len, embed_dim)`
521
+ attention_mask (`torch.FloatTensor`, *optional*):
522
+ attention mask of size `(batch_size, sequence_length)` if flash attention is used or `(batch_size, 1,
523
+ query_sequence_length, key_sequence_length)` if default attention is used.
524
+ output_attentions (`bool`, *optional*):
525
+ Whether or not to return the attentions tensors of all attention layers. See `attentions` under
526
+ returned tensors for more detail.
527
+ use_cache (`bool`, *optional*):
528
+ If set to `True`, `past_key_values` key value states are returned and can be used to speed up decoding
529
+ (see `past_key_values`).
530
+ past_key_value (`Tuple(torch.FloatTensor)`, *optional*): cached past key and value projection states
531
+ """
532
+ if "padding_mask" in kwargs:
533
+ warnings.warn(
534
+ "Passing `padding_mask` is deprecated and will be removed in v4.37. "
535
+ "Please make sure use `attention_mask` instead.`"
536
+ )
537
+
538
+ residual = hidden_states
539
+
540
+ hidden_states = self.attention_norm(hidden_states)
541
+
542
+ # Self Attention
543
+ hidden_states, self_attn_weights, present_key_value = self.attention(
544
+ hidden_states=hidden_states,
545
+ attention_mask=attention_mask,
546
+ position_ids=position_ids,
547
+ past_key_value=past_key_value,
548
+ output_attentions=output_attentions,
549
+ use_cache=use_cache,
550
+ **kwargs,
551
+ )
552
+ hidden_states = residual + hidden_states
553
+
554
+ # Fully Connected
555
+ residual = hidden_states
556
+ hidden_states = self.ffn_norm(hidden_states)
557
+ hidden_states = self.feed_forward(hidden_states)
558
+ hidden_states = residual + hidden_states
559
+
560
+ outputs = (hidden_states,)
561
+
562
+ if output_attentions:
563
+ outputs += (self_attn_weights,)
564
+
565
+ if use_cache:
566
+ outputs += (present_key_value,)
567
+
568
+ return outputs
569
+
570
+
571
+ InternLM2_START_DOCSTRING = r"""
572
+ This model inherits from [`PreTrainedModel`]. Check the superclass documentation for the generic methods the
573
+ library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
574
+ etc.)
575
+ This model is also a PyTorch [torch.nn.Module](https://pytorch.org/docs/stable/nn.html#torch.nn.Module) subclass.
576
+ Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
577
+ and behavior.
578
+ Parameters:
579
+ config ([`InternLM2Config`]):
580
+ Model configuration class with all the parameters of the model. Initializing with a config file does not
581
+ load the weights associated with the model, only the configuration. Check out the
582
+ [`~PreTrainedModel.from_pretrained`] method to load the model weights.
583
+ """
584
+
585
+
586
+ @add_start_docstrings(
587
+ "The bare InternLM2 Model outputting raw hidden-states without any specific head on top.",
588
+ InternLM2_START_DOCSTRING,
589
+ )
590
+ class InternLM2PreTrainedModel(PreTrainedModel):
591
+ config_class = InternLM2Config
592
+ base_model_prefix = "model"
593
+ supports_gradient_checkpointing = True
594
+ _no_split_modules = ["InternLM2DecoderLayer"]
595
+ _skip_keys_device_placement = "past_key_values"
596
+ _supports_flash_attn_2 = True
597
+
598
+ def _init_weights(self, module):
599
+ std = self.config.initializer_range
600
+ if isinstance(module, nn.Linear):
601
+ module.weight.data.normal_(mean=0.0, std=std)
602
+ if module.bias is not None:
603
+ module.bias.data.zero_()
604
+ elif isinstance(module, nn.Embedding):
605
+ module.weight.data.normal_(mean=0.0, std=std)
606
+ if module.padding_idx is not None:
607
+ module.weight.data[module.padding_idx].zero_()
608
+
609
+
610
+ InternLM2_INPUTS_DOCSTRING = r"""
611
+ Args:
612
+ input_ids (`torch.LongTensor` of shape `(batch_size, sequence_length)`):
613
+ Indices of input sequence tokens in the vocabulary. Padding will be ignored by default should you provide
614
+ it.
615
+ Indices can be obtained using [`AutoTokenizer`]. See [`PreTrainedTokenizer.encode`] and
616
+ [`PreTrainedTokenizer.__call__`] for details.
617
+ [What are input IDs?](../glossary#input-ids)
618
+ attention_mask (`torch.Tensor` of shape `(batch_size, sequence_length)`, *optional*):
619
+ Mask to avoid performing attention on padding token indices. Mask values selected in `[0, 1]`:
620
+ - 1 for tokens that are **not masked**,
621
+ - 0 for tokens that are **masked**.
622
+ [What are attention masks?](../glossary#attention-mask)
623
+ Indices can be obtained using [`AutoTokenizer`]. See [`PreTrainedTokenizer.encode`] and
624
+ [`PreTrainedTokenizer.__call__`] for details.
625
+ If `past_key_values` is used, optionally only the last `input_ids` have to be input (see
626
+ `past_key_values`).
627
+ If you want to change padding behavior, you should read [`modeling_opt._prepare_decoder_attention_mask`]
628
+ and modify to your needs. See diagram 1 in [the paper](https://arxiv.org/abs/1910.13461) for more
629
+ information on the default strategy.
630
+ - 1 indicates the head is **not masked**,
631
+ - 0 indicates the head is **masked**.
632
+ position_ids (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *optional*):
633
+ Indices of positions of each input sequence tokens in the position embeddings. Selected in the range `[0,
634
+ config.n_positions - 1]`.
635
+ [What are position IDs?](../glossary#position-ids)
636
+ past_key_values (`tuple(tuple(torch.FloatTensor))`, *optional*, returned when `use_cache=True` is passed or
637
+ when `config.use_cache=True`):
638
+ Tuple of `tuple(torch.FloatTensor)` of length `config.n_layers`, with each tuple having 2 tensors of shape
639
+ `(batch_size, num_heads, sequence_length, embed_size_per_head)`) and 2 additional tensors of shape
640
+ `(batch_size, num_heads, decoder_sequence_length, embed_size_per_head)`.
641
+ Contains pre-computed hidden-states (key and values in the self-attention blocks and in the cross-attention
642
+ blocks) that can be used (see `past_key_values` input) to speed up sequential decoding.
643
+ If `past_key_values` are used, the user can optionally input only the last `input_ids` (those that don't
644
+ have their past key value states given to this model) of shape `(batch_size, 1)` instead of all `input_ids`
645
+ of shape `(batch_size, sequence_length)`.
646
+ inputs_embeds (`torch.FloatTensor` of shape `(batch_size, sequence_length, hidden_size)`, *optional*):
647
+ Optionally, instead of passing `input_ids` you can choose to directly pass an embedded representation. This
648
+ is useful if you want more control over how to convert `input_ids` indices into associated vectors than the
649
+ model's internal embedding lookup matrix.
650
+ use_cache (`bool`, *optional*):
651
+ If set to `True`, `past_key_values` key value states are returned and can be used to speed up decoding (see
652
+ `past_key_values`).
653
+ output_attentions (`bool`, *optional*):
654
+ Whether or not to return the attentions tensors of all attention layers. See `attentions` under returned
655
+ tensors for more detail.
656
+ output_hidden_states (`bool`, *optional*):
657
+ Whether or not to return the hidden states of all layers. See `hidden_states` under returned tensors for
658
+ more detail.
659
+ return_dict (`bool`, *optional*):
660
+ Whether or not to return a [`~utils.ModelOutput`] instead of a plain tuple.
661
+ """
662
+
663
+
664
+ @add_start_docstrings(
665
+ "The bare InternLM2 Model outputting raw hidden-states without any specific head on top.",
666
+ InternLM2_START_DOCSTRING,
667
+ )
668
+ class InternLM2Model(InternLM2PreTrainedModel):
669
+ """
670
+ Transformer decoder consisting of *config.num_hidden_layers* layers. Each layer is a [`InternLM2DecoderLayer`]
671
+ Args:
672
+ config: InternLM2Config
673
+ """
674
+
675
+ _auto_class = "AutoModel"
676
+
677
+ def __init__(self, config: InternLM2Config):
678
+ super().__init__(config)
679
+ self.padding_idx = config.pad_token_id
680
+ self.vocab_size = config.vocab_size
681
+
682
+ self.tok_embeddings = nn.Embedding(config.vocab_size, config.hidden_size, self.padding_idx)
683
+ self.layers = nn.ModuleList([InternLM2DecoderLayer(config) for _ in range(config.num_hidden_layers)])
684
+ self.norm = InternLM2RMSNorm(config.hidden_size, eps=config.rms_norm_eps)
685
+
686
+ self.gradient_checkpointing = False
687
+ # Initialize weights and apply final processing
688
+ self.post_init()
689
+
690
+ def get_input_embeddings(self):
691
+ return self.tok_embeddings
692
+
693
+ def set_input_embeddings(self, value):
694
+ self.tok_embeddings = value
695
+
696
+ # Copied from transformers.models.bart.modeling_bart.BartDecoder._prepare_decoder_attention_mask
697
+ def _prepare_decoder_attention_mask(self, attention_mask, input_shape, inputs_embeds, past_key_values_length):
698
+ # create causal mask
699
+ # [bsz, seq_len] -> [bsz, 1, tgt_seq_len, src_seq_len]
700
+ combined_attention_mask = None
701
+ if input_shape[-1] > 1:
702
+ combined_attention_mask = _make_causal_mask(
703
+ input_shape,
704
+ inputs_embeds.dtype,
705
+ device=inputs_embeds.device,
706
+ past_key_values_length=past_key_values_length,
707
+ )
708
+
709
+ if attention_mask is not None:
710
+ # [bsz, seq_len] -> [bsz, 1, tgt_seq_len, src_seq_len]
711
+ expanded_attn_mask = _expand_mask(attention_mask, inputs_embeds.dtype, tgt_len=input_shape[-1]).to(
712
+ inputs_embeds.device
713
+ )
714
+ combined_attention_mask = (
715
+ expanded_attn_mask if combined_attention_mask is None else expanded_attn_mask + combined_attention_mask
716
+ )
717
+
718
+ return combined_attention_mask
719
+
720
+ @add_start_docstrings_to_model_forward(InternLM2_INPUTS_DOCSTRING)
721
+ def forward(
722
+ self,
723
+ input_ids: torch.LongTensor = None,
724
+ attention_mask: Optional[torch.Tensor] = None,
725
+ position_ids: Optional[torch.LongTensor] = None,
726
+ past_key_values: Optional[List[torch.FloatTensor]] = None,
727
+ inputs_embeds: Optional[torch.FloatTensor] = None,
728
+ use_cache: Optional[bool] = None,
729
+ output_attentions: Optional[bool] = None,
730
+ output_hidden_states: Optional[bool] = None,
731
+ return_dict: Optional[bool] = None,
732
+ ) -> Union[Tuple, BaseModelOutputWithPast]:
733
+ output_attentions = output_attentions if output_attentions is not None else self.config.output_attentions
734
+ output_hidden_states = (
735
+ output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
736
+ )
737
+ use_cache = use_cache if use_cache is not None else self.config.use_cache
738
+
739
+ return_dict = return_dict if return_dict is not None else self.config.use_return_dict
740
+
741
+ # retrieve input_ids and inputs_embeds
742
+ if input_ids is not None and inputs_embeds is not None:
743
+ raise ValueError("You cannot specify both input_ids and inputs_embeds at the same time")
744
+ elif input_ids is not None:
745
+ batch_size, seq_length = input_ids.shape[:2]
746
+ elif inputs_embeds is not None:
747
+ batch_size, seq_length = inputs_embeds.shape[:2]
748
+ else:
749
+ raise ValueError("You have to specify either input_ids or inputs_embeds")
750
+
751
+ seq_length_with_past = seq_length
752
+ past_key_values_length = 0
753
+ if past_key_values is not None:
754
+ past_key_values_length = past_key_values[0][0].shape[2]
755
+ seq_length_with_past = seq_length_with_past + past_key_values_length
756
+
757
+ if position_ids is None:
758
+ device = input_ids.device if input_ids is not None else inputs_embeds.device
759
+ position_ids = torch.arange(
760
+ past_key_values_length, seq_length + past_key_values_length, dtype=torch.long, device=device
761
+ )
762
+ position_ids = position_ids.unsqueeze(0)
763
+
764
+ if inputs_embeds is None:
765
+ inputs_embeds = self.tok_embeddings(input_ids)
766
+ # embed positions
767
+ if attention_mask is None:
768
+ attention_mask = torch.ones(
769
+ (batch_size, seq_length_with_past), dtype=torch.bool, device=inputs_embeds.device
770
+ )
771
+ attention_mask = self._prepare_decoder_attention_mask(
772
+ attention_mask, (batch_size, seq_length), inputs_embeds, past_key_values_length
773
+ )
774
+
775
+ # embed positions
776
+ hidden_states = inputs_embeds
777
+
778
+ if self.gradient_checkpointing and self.training:
779
+ if use_cache:
780
+ logger.warning_once(
781
+ "`use_cache=True` is incompatible with gradient checkpointing. Setting `use_cache=False`..."
782
+ )
783
+ use_cache = False
784
+
785
+ # decoder layers
786
+ all_hidden_states = () if output_hidden_states else None
787
+ all_self_attns = () if output_attentions else None
788
+ next_decoder_cache = () if use_cache else None
789
+
790
+ for idx, decoder_layer in enumerate(self.layers):
791
+ if output_hidden_states:
792
+ all_hidden_states += (hidden_states,)
793
+
794
+ past_key_value = past_key_values[idx] if past_key_values is not None else None
795
+
796
+ if self.gradient_checkpointing and self.training:
797
+
798
+ def create_custom_forward(module):
799
+ def custom_forward(*inputs):
800
+ # None for past_key_value
801
+ return module(*inputs, output_attentions, None)
802
+
803
+ return custom_forward
804
+
805
+ layer_outputs = torch.utils.checkpoint.checkpoint(
806
+ create_custom_forward(decoder_layer),
807
+ hidden_states,
808
+ attention_mask,
809
+ position_ids,
810
+ None,
811
+ )
812
+ else:
813
+ layer_outputs = decoder_layer(
814
+ hidden_states,
815
+ attention_mask=attention_mask,
816
+ position_ids=position_ids,
817
+ past_key_value=past_key_value,
818
+ output_attentions=output_attentions,
819
+ use_cache=use_cache,
820
+ )
821
+
822
+ hidden_states = layer_outputs[0]
823
+
824
+ if use_cache:
825
+ next_decoder_cache += (layer_outputs[2 if output_attentions else 1],)
826
+
827
+ if output_attentions:
828
+ all_self_attns += (layer_outputs[1],)
829
+
830
+ hidden_states = self.norm(hidden_states)
831
+
832
+ # add hidden states from the last decoder layer
833
+ if output_hidden_states:
834
+ all_hidden_states += (hidden_states,)
835
+
836
+ next_cache = next_decoder_cache if use_cache else None
837
+ if not return_dict:
838
+ return tuple(v for v in [hidden_states, next_cache, all_hidden_states, all_self_attns] if v is not None)
839
+ return BaseModelOutputWithPast(
840
+ last_hidden_state=hidden_states,
841
+ past_key_values=next_cache,
842
+ hidden_states=all_hidden_states,
843
+ attentions=all_self_attns,
844
+ )
845
+
846
+
847
+ class InternLM2ForCausalLM(InternLM2PreTrainedModel):
848
+ _auto_class = "AutoModelForCausalLM"
849
+
850
+ _tied_weights_keys = ["output.weight"]
851
+
852
+ def __init__(self, config):
853
+ super().__init__(config)
854
+ self.model = InternLM2Model(config)
855
+ self.vocab_size = config.vocab_size
856
+ self.output = nn.Linear(config.hidden_size, config.vocab_size, bias=False)
857
+
858
+ # Initialize weights and apply final processing
859
+ self.post_init()
860
+
861
+ def get_input_embeddings(self):
862
+ return self.model.tok_embeddings
863
+
864
+ def set_input_embeddings(self, value):
865
+ self.model.tok_embeddings = value
866
+
867
+ def get_output_embeddings(self):
868
+ return self.output
869
+
870
+ def set_output_embeddings(self, new_embeddings):
871
+ self.output = new_embeddings
872
+
873
+ def set_decoder(self, decoder):
874
+ self.model = decoder
875
+
876
+ def get_decoder(self):
877
+ return self.model
878
+
879
+ @add_start_docstrings_to_model_forward(InternLM2_INPUTS_DOCSTRING)
880
+ @replace_return_docstrings(output_type=CausalLMOutputWithPast, config_class=_CONFIG_FOR_DOC)
881
+ def forward(
882
+ self,
883
+ input_ids: torch.LongTensor = None,
884
+ attention_mask: Optional[torch.Tensor] = None,
885
+ position_ids: Optional[torch.LongTensor] = None,
886
+ past_key_values: Optional[List[torch.FloatTensor]] = None,
887
+ inputs_embeds: Optional[torch.FloatTensor] = None,
888
+ labels: Optional[torch.LongTensor] = None,
889
+ use_cache: Optional[bool] = None,
890
+ output_attentions: Optional[bool] = None,
891
+ output_hidden_states: Optional[bool] = None,
892
+ return_dict: Optional[bool] = None,
893
+ ) -> Union[Tuple, CausalLMOutputWithPast]:
894
+ r"""
895
+ Args:
896
+ labels (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *optional*):
897
+ Labels for computing the masked language modeling loss. Indices should either be in `[0, ...,
898
+ config.vocab_size]` or -100 (see `input_ids` docstring). Tokens with indices set to `-100` are ignored
899
+ (masked), the loss is only computed for the tokens with labels in `[0, ..., config.vocab_size]`.
900
+ Returns:
901
+ Example:
902
+ ```python
903
+ >>> from transformers import AutoTokenizer, InternLM2ForCausalLM
904
+ >>> model = InternLM2ForCausalLM.from_pretrained(PATH_TO_CONVERTED_WEIGHTS)
905
+ >>> tokenizer = AutoTokenizer.from_pretrained(PATH_TO_CONVERTED_TOKENIZER)
906
+ >>> prompt = "Hey, are you conscious? Can you talk to me?"
907
+ >>> inputs = tokenizer(prompt, return_tensors="pt")
908
+ >>> # Generate
909
+ >>> generate_ids = model.generate(inputs.input_ids, max_length=30)
910
+ >>> tokenizer.batch_decode(generate_ids, skip_special_tokens=True, clean_up_tokenization_spaces=False)[0]
911
+ "Hey, are you conscious? Can you talk to me?\nI'm not conscious, but I can talk to you."
912
+ ```"""
913
+
914
+ output_attentions = output_attentions if output_attentions is not None else self.config.output_attentions
915
+ output_hidden_states = (
916
+ output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
917
+ )
918
+ return_dict = return_dict if return_dict is not None else self.config.use_return_dict
919
+
920
+ # decoder outputs consists of (dec_features, layer_state, dec_hidden, dec_attn)
921
+ outputs = self.model(
922
+ input_ids=input_ids,
923
+ attention_mask=attention_mask,
924
+ position_ids=position_ids,
925
+ past_key_values=past_key_values,
926
+ inputs_embeds=inputs_embeds,
927
+ use_cache=use_cache,
928
+ output_attentions=output_attentions,
929
+ output_hidden_states=output_hidden_states,
930
+ return_dict=return_dict,
931
+ )
932
+
933
+ hidden_states = outputs[0]
934
+ logits = self.output(hidden_states)
935
+ logits = logits.float()
936
+
937
+ loss = None
938
+ if labels is not None:
939
+ # Shift so that tokens < n predict n
940
+ shift_logits = logits[..., :-1, :].contiguous()
941
+ shift_labels = labels[..., 1:].contiguous()
942
+ # Flatten the tokens
943
+ loss_fct = CrossEntropyLoss()
944
+ shift_logits = shift_logits.view(-1, self.config.vocab_size)
945
+ shift_labels = shift_labels.view(-1)
946
+ # Enable model parallelism
947
+ shift_labels = shift_labels.to(shift_logits.device)
948
+ loss = loss_fct(shift_logits, shift_labels)
949
+
950
+ if not return_dict:
951
+ output = (logits,) + outputs[1:]
952
+ return (loss,) + output if loss is not None else output
953
+
954
+ return CausalLMOutputWithPast(
955
+ loss=loss,
956
+ logits=logits,
957
+ past_key_values=outputs.past_key_values,
958
+ hidden_states=outputs.hidden_states,
959
+ attentions=outputs.attentions,
960
+ )
961
+
962
+ def prepare_inputs_for_generation(
963
+ self, input_ids, past_key_values=None, attention_mask=None, inputs_embeds=None, **kwargs
964
+ ):
965
+ if past_key_values is not None:
966
+ past_length = past_key_values[0][0].shape[2]
967
+
968
+ # Some generation methods already pass only the last input ID
969
+ if input_ids.shape[1] > past_length:
970
+ remove_prefix_length = past_length
971
+ else:
972
+ # Default to old behavior: keep only final ID
973
+ remove_prefix_length = input_ids.shape[1] - 1
974
+
975
+ input_ids = input_ids[:, remove_prefix_length:]
976
+
977
+ position_ids = kwargs.get("position_ids", None)
978
+ if attention_mask is not None and position_ids is None:
979
+ # create position_ids on the fly for batch generation
980
+ position_ids = attention_mask.long().cumsum(-1) - 1
981
+ position_ids.masked_fill_(attention_mask == 0, 1)
982
+ if past_key_values:
983
+ position_ids = position_ids[:, -input_ids.shape[1] :]
984
+
985
+ # if `inputs_embeds` are passed, we only want to use them in the 1st generation step
986
+ if inputs_embeds is not None and past_key_values is None:
987
+ model_inputs = {"inputs_embeds": inputs_embeds}
988
+ else:
989
+ model_inputs = {"input_ids": input_ids}
990
+
991
+ model_inputs.update(
992
+ {
993
+ "position_ids": position_ids,
994
+ "past_key_values": past_key_values,
995
+ "use_cache": kwargs.get("use_cache"),
996
+ "attention_mask": attention_mask,
997
+ }
998
+ )
999
+ return model_inputs
1000
+
1001
+ @staticmethod
1002
+ def _reorder_cache(past_key_values, beam_idx):
1003
+ reordered_past = ()
1004
+ for layer_past in past_key_values:
1005
+ reordered_past += (
1006
+ tuple(past_state.index_select(0, beam_idx.to(past_state.device)) for past_state in layer_past),
1007
+ )
1008
+ return reordered_past
1009
+
1010
+ def build_inputs(self, tokenizer, query: str, history: List[Tuple[str, str]] = []):
1011
+ prompt = ""
1012
+ for record in history:
1013
+ prompt += f"""<|User|>:{record[0]}<eoh>\n<|Bot|>:{record[1]}<eoa>\n"""
1014
+ prompt += f"""<|User|>:{query}<eoh>\n<|Bot|>:"""
1015
+ return tokenizer([prompt], return_tensors="pt")
1016
+
1017
+ @torch.no_grad()
1018
+ def chat(
1019
+ self,
1020
+ tokenizer,
1021
+ query: str,
1022
+ history: List[Tuple[str, str]] = [],
1023
+ streamer: Optional[BaseStreamer] = None,
1024
+ max_new_tokens: int = 1024,
1025
+ do_sample: bool = True,
1026
+ temperature: float = 0.8,
1027
+ top_p: float = 0.8,
1028
+ **kwargs,
1029
+ ):
1030
+ inputs = self.build_inputs(tokenizer, query, history)
1031
+ inputs = {k: v.to(self.device) for k, v in inputs.items() if torch.is_tensor(v)}
1032
+ outputs = self.generate(
1033
+ **inputs,
1034
+ streamer=streamer,
1035
+ max_new_tokens=max_new_tokens,
1036
+ do_sample=do_sample,
1037
+ temperature=temperature,
1038
+ top_p=top_p,
1039
+ **kwargs,
1040
+ )
1041
+ outputs = outputs[0].cpu().tolist()[len(inputs["input_ids"][0]) :]
1042
+ response = tokenizer.decode(outputs, skip_special_tokens=True)
1043
+ response = response.split("<eoa>")[0]
1044
+ history = history + [(query, response)]
1045
+ return response, history
1046
+
1047
+ @torch.no_grad()
1048
+ def stream_chat(
1049
+ self,
1050
+ tokenizer,
1051
+ query: str,
1052
+ history: List[Tuple[str, str]] = [],
1053
+ max_new_tokens: int = 1024,
1054
+ do_sample: bool = True,
1055
+ temperature: float = 0.8,
1056
+ top_p: float = 0.8,
1057
+ **kwargs,
1058
+ ):
1059
+ """
1060
+ Return a generator in format: (response, history)
1061
+ Eg.
1062
+ ('你好,有什么可以帮助您的吗', [('你好', '你好,有什么可以帮助您的吗')])
1063
+ ('你好,有什么可以帮助您的吗?', [('你好', '你好,有什么可以帮助您的吗?')])
1064
+ """
1065
+ if BaseStreamer is None:
1066
+ raise ModuleNotFoundError(
1067
+ "The version of `transformers` is too low. Please make sure "
1068
+ "that you have installed `transformers>=4.28.0`."
1069
+ )
1070
+
1071
+ response_queue = queue.Queue(maxsize=20)
1072
+
1073
+ class ChatStreamer(BaseStreamer):
1074
+ def __init__(self, tokenizer) -> None:
1075
+ super().__init__()
1076
+ self.tokenizer = tokenizer
1077
+ self.queue = response_queue
1078
+ self.query = query
1079
+ self.history = history
1080
+ self.response = ""
1081
+ self.received_inputs = False
1082
+ self.queue.put((self.response, history + [(self.query, self.response)]))
1083
+
1084
+ def put(self, value):
1085
+ if len(value.shape) > 1 and value.shape[0] > 1:
1086
+ raise ValueError("ChatStreamer only supports batch size 1")
1087
+ elif len(value.shape) > 1:
1088
+ value = value[0]
1089
+
1090
+ if not self.received_inputs:
1091
+ # The first received value is input_ids, ignore here
1092
+ self.received_inputs = True
1093
+ return
1094
+
1095
+ token = self.tokenizer.decode([value[-1]], skip_special_tokens=True)
1096
+ if token.strip() != "<eoa>":
1097
+ self.response = self.response + token
1098
+ history = self.history + [(self.query, self.response)]
1099
+ self.queue.put((self.response, history))
1100
+
1101
+ def end(self):
1102
+ self.queue.put(None)
1103
+
1104
+ def stream_producer():
1105
+ return self.chat(
1106
+ tokenizer=tokenizer,
1107
+ query=query,
1108
+ streamer=ChatStreamer(tokenizer=tokenizer),
1109
+ history=history,
1110
+ max_new_tokens=max_new_tokens,
1111
+ do_sample=do_sample,
1112
+ temperature=temperature,
1113
+ top_p=top_p,
1114
+ **kwargs,
1115
+ )
1116
+
1117
+ def consumer():
1118
+ producer = threading.Thread(target=stream_producer)
1119
+ producer.start()
1120
+ while True:
1121
+ res = response_queue.get()
1122
+ if res is None:
1123
+ return
1124
+ yield res
1125
+
1126
+ return consumer()
1127
+
1128
+
1129
+ @add_start_docstrings(
1130
+ """
1131
+ The InternLM2 Model transformer with a sequence classification head on top (linear layer).
1132
+ [`InternLM2ForSequenceClassification`] uses the last token in order to do the classification,
1133
+ as other causal models (e.g. GPT-2) do.
1134
+ Since it does classification on the last token, it requires to know the position of the last token. If a
1135
+ `pad_token_id` is defined in the configuration, it finds the last token that is not a padding token in each row. If
1136
+ no `pad_token_id` is defined, it simply takes the last value in each row of the batch. Since it cannot guess the
1137
+ padding tokens when `inputs_embeds` are passed instead of `input_ids`, it does the same (take the last value in
1138
+ each row of the batch).
1139
+ """,
1140
+ InternLM2_START_DOCSTRING,
1141
+ )
1142
+ class InternLM2ForSequenceClassification(InternLM2PreTrainedModel):
1143
+ def __init__(self, config):
1144
+ super().__init__(config)
1145
+ self.num_labels = config.num_labels
1146
+ self.model = InternLM2Model(config)
1147
+ self.score = nn.Linear(config.hidden_size, self.num_labels, bias=False)
1148
+
1149
+ # Initialize weights and apply final processing
1150
+ self.post_init()
1151
+
1152
+ def get_input_embeddings(self):
1153
+ return self.model.tok_embeddings
1154
+
1155
+ def set_input_embeddings(self, value):
1156
+ self.model.tok_embeddings = value
1157
+
1158
+ @add_start_docstrings_to_model_forward(InternLM2_INPUTS_DOCSTRING)
1159
+ def forward(
1160
+ self,
1161
+ input_ids: torch.LongTensor = None,
1162
+ attention_mask: Optional[torch.Tensor] = None,
1163
+ position_ids: Optional[torch.LongTensor] = None,
1164
+ past_key_values: Optional[List[torch.FloatTensor]] = None,
1165
+ inputs_embeds: Optional[torch.FloatTensor] = None,
1166
+ labels: Optional[torch.LongTensor] = None,
1167
+ use_cache: Optional[bool] = None,
1168
+ output_attentions: Optional[bool] = None,
1169
+ output_hidden_states: Optional[bool] = None,
1170
+ return_dict: Optional[bool] = None,
1171
+ ) -> Union[Tuple, SequenceClassifierOutputWithPast]:
1172
+ r"""
1173
+ labels (`torch.LongTensor` of shape `(batch_size,)`, *optional*):
1174
+ Labels for computing the sequence classification/regression loss. Indices should be in `[0, ...,
1175
+ config.num_labels - 1]`. If `config.num_labels == 1` a regression loss is computed (Mean-Square loss), If
1176
+ `config.num_labels > 1` a classification loss is computed (Cross-Entropy).
1177
+ """
1178
+ return_dict = return_dict if return_dict is not None else self.config.use_return_dict
1179
+
1180
+ transformer_outputs = self.model(
1181
+ input_ids,
1182
+ attention_mask=attention_mask,
1183
+ position_ids=position_ids,
1184
+ past_key_values=past_key_values,
1185
+ inputs_embeds=inputs_embeds,
1186
+ use_cache=use_cache,
1187
+ output_attentions=output_attentions,
1188
+ output_hidden_states=output_hidden_states,
1189
+ return_dict=return_dict,
1190
+ )
1191
+ hidden_states = transformer_outputs[0]
1192
+ logits = self.score(hidden_states)
1193
+
1194
+ if input_ids is not None:
1195
+ batch_size = input_ids.shape[0]
1196
+ else:
1197
+ batch_size = inputs_embeds.shape[0]
1198
+
1199
+ if self.config.pad_token_id is None and batch_size != 1:
1200
+ raise ValueError("Cannot handle batch sizes > 1 if no padding token is defined.")
1201
+ if self.config.pad_token_id is None:
1202
+ sequence_lengths = -1
1203
+ else:
1204
+ if input_ids is not None:
1205
+ sequence_lengths = (torch.eq(input_ids, self.config.pad_token_id).int().argmax(-1) - 1).to(
1206
+ logits.device
1207
+ )
1208
+ else:
1209
+ sequence_lengths = -1
1210
+
1211
+ pooled_logits = logits[torch.arange(batch_size, device=logits.device), sequence_lengths]
1212
+
1213
+ loss = None
1214
+ if labels is not None:
1215
+ labels = labels.to(logits.device)
1216
+ if self.config.problem_type is None:
1217
+ if self.num_labels == 1:
1218
+ self.config.problem_type = "regression"
1219
+ elif self.num_labels > 1 and (labels.dtype == torch.long or labels.dtype == torch.int):
1220
+ self.config.problem_type = "single_label_classification"
1221
+ else:
1222
+ self.config.problem_type = "multi_label_classification"
1223
+
1224
+ if self.config.problem_type == "regression":
1225
+ loss_fct = MSELoss()
1226
+ if self.num_labels == 1:
1227
+ loss = loss_fct(pooled_logits.squeeze(), labels.squeeze())
1228
+ else:
1229
+ loss = loss_fct(pooled_logits, labels)
1230
+ elif self.config.problem_type == "single_label_classification":
1231
+ loss_fct = CrossEntropyLoss()
1232
+ loss = loss_fct(pooled_logits.view(-1, self.num_labels), labels.view(-1))
1233
+ elif self.config.problem_type == "multi_label_classification":
1234
+ loss_fct = BCEWithLogitsLoss()
1235
+ loss = loss_fct(pooled_logits, labels)
1236
+ if not return_dict:
1237
+ output = (pooled_logits,) + transformer_outputs[1:]
1238
+ return ((loss,) + output) if loss is not None else output
1239
+
1240
+ return SequenceClassifierOutputWithPast(
1241
+ loss=loss,
1242
+ logits=pooled_logits,
1243
+ past_key_values=transformer_outputs.past_key_values,
1244
+ hidden_states=transformer_outputs.hidden_states,
1245
+ attentions=transformer_outputs.attentions,
1246
+ )