Commit
•
edce41b
1
Parent(s):
078a937
Upload folder using huggingface_hub
Browse files- README.md +60 -0
- added_tokens.json +5 -0
- config.json +38 -0
- configuration_llama.py +184 -0
- generation_config.json +10 -0
- huggingface-metadata.txt +20 -0
- modeling_llama_yarn.py +1406 -0
- output-00001-of-00003.safetensors +3 -0
- output-00002-of-00003.safetensors +3 -0
- output-00003-of-00003.safetensors +3 -0
- pytorch_model.bin.index.json +730 -0
- special_tokens_map.json +5 -0
- tokenizer.json +0 -0
- tokenizer.model +3 -0
- tokenizer_config.json +40 -0
README.md
ADDED
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
metrics:
|
3 |
+
- perplexity
|
4 |
+
library_name: transformers
|
5 |
+
license: apache-2.0
|
6 |
+
language:
|
7 |
+
- en
|
8 |
+
datasets:
|
9 |
+
- emozilla/yarn-train-tokenized-8k-llama
|
10 |
+
---
|
11 |
+
|
12 |
+
# Model Card: Yarn-Llama-2-70b-32k
|
13 |
+
|
14 |
+
[Preprint (arXiv)](https://arxiv.org/abs/2309.00071)
|
15 |
+
[GitHub](https://github.com/jquesnelle/yarn)
|
16 |
+
![yarn](https://raw.githubusercontent.com/jquesnelle/yarn/70b/data/proofpile-long-small-32k-70b.csv.png)
|
17 |
+
|
18 |
+
The authors would like to thank [LAION AI](https://laion.ai/) for their support of compute for this model.
|
19 |
+
It was trained on the [JUWELS](https://www.fz-juelich.de/en/ias/jsc/systems/supercomputers/juwels) supercomputer.
|
20 |
+
|
21 |
+
## Model Description
|
22 |
+
|
23 |
+
Nous-Yarn-Llama-2-70b-32k is a state-of-the-art language model for long context, further pretrained on long context data for 400 steps using the YaRN extension method.
|
24 |
+
It is an extension of [Llama-2-70b-hf](meta-llama/Llama-2-70b-hf) and supports a 32k token context window.
|
25 |
+
|
26 |
+
To use, pass `trust_remote_code=True` when loading the model, for example
|
27 |
+
|
28 |
+
```python
|
29 |
+
model = AutoModelForCausalLM.from_pretrained("NousResearch/Yarn-Llama-2-70b-32k",
|
30 |
+
use_flash_attention_2=True,
|
31 |
+
torch_dtype=torch.bfloat16,
|
32 |
+
device_map="auto",
|
33 |
+
trust_remote_code=True)
|
34 |
+
```
|
35 |
+
|
36 |
+
In addition you will need to use the latest version of `transformers` (until 4.35 comes out)
|
37 |
+
```sh
|
38 |
+
pip install git+https://github.com/huggingface/transformers
|
39 |
+
```
|
40 |
+
|
41 |
+
## Benchmarks
|
42 |
+
|
43 |
+
Long context benchmarks:
|
44 |
+
| Model | Context Window | 1k PPL | 2k PPL | 4k PPL | 8k PPL | 16k PPL | 32k PPL |
|
45 |
+
|-------|---------------:|-------:|--------:|------:|-------:|--------:|--------:|
|
46 |
+
| [Llama-2-70b-hf](meta-llama/Llama-2-70b-hf) | 4k | 3.71 | 3.27 | 2.96 | - | - | - |
|
47 |
+
| [Yarn-Llama-2-70b-32k](https://huggingface.co/NousResearch/Yarn-Llama-2-70b-32k) | 32k | 3.61 | 3.22 | 2.91 | 2.82 | 2.45 | 2.23 |
|
48 |
+
|
49 |
+
Short context benchmarks showing that quality degradation is minimal:
|
50 |
+
| Model | Context Window | ARC-c | MMLU | Truthful QA |
|
51 |
+
|-------|---------------:|------:|-----:|------------:|
|
52 |
+
| [Llama-2-70b-hf](meta-llama/Llama-2-70b-hf) | 4k | 67.32 | 69.83 | 44.92 |
|
53 |
+
| [Yarn-Llama-2-70b-32k](https://huggingface.co/NousResearch/Yarn-Llama-2-70b-32k) | 32k | 67.41 | 68.84 | 46.14 |
|
54 |
+
|
55 |
+
## Collaborators
|
56 |
+
|
57 |
+
- [bloc97](https://github.com/bloc97): Methods, paper and evals
|
58 |
+
- [@theemozilla](https://twitter.com/theemozilla): Methods, paper, model training, and evals
|
59 |
+
- [@EnricoShippole](https://twitter.com/EnricoShippole): Model training
|
60 |
+
- [honglu2875](https://github.com/honglu2875): Paper and evals
|
added_tokens.json
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"</s>": 2,
|
3 |
+
"<s>": 1,
|
4 |
+
"<unk>": 0
|
5 |
+
}
|
config.json
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_name_or_path": "meta-llama/Llama-2-70b-hf",
|
3 |
+
"architectures": [
|
4 |
+
"LlamaForCausalLM"
|
5 |
+
],
|
6 |
+
"auto_map": {
|
7 |
+
"AutoConfig": "configuration_llama.LlamaConfig",
|
8 |
+
"AutoModelForCausalLM": "modeling_llama_yarn.LlamaForCausalLM"
|
9 |
+
},
|
10 |
+
"attention_bias": false,
|
11 |
+
"bos_token_id": 1,
|
12 |
+
"eos_token_id": 2,
|
13 |
+
"hidden_act": "silu",
|
14 |
+
"hidden_size": 8192,
|
15 |
+
"initializer_range": 0.02,
|
16 |
+
"intermediate_size": 28672,
|
17 |
+
"max_position_embeddings": 8192,
|
18 |
+
"max_sequence_length": 32768,
|
19 |
+
"model_type": "llama",
|
20 |
+
"num_attention_heads": 64,
|
21 |
+
"num_hidden_layers": 80,
|
22 |
+
"num_key_value_heads": 8,
|
23 |
+
"pad_token_id": 0,
|
24 |
+
"pretraining_tp": 1,
|
25 |
+
"rms_norm_eps": 1e-05,
|
26 |
+
"rope_scaling": {
|
27 |
+
"factor": 8.0,
|
28 |
+
"finetuned": true,
|
29 |
+
"original_max_position_embeddings": 4096,
|
30 |
+
"type": "yarn"
|
31 |
+
},
|
32 |
+
"rope_theta": 10000.0,
|
33 |
+
"tie_word_embeddings": false,
|
34 |
+
"torch_dtype": "bfloat16",
|
35 |
+
"transformers_version": "4.35.0.dev0",
|
36 |
+
"use_cache": true,
|
37 |
+
"vocab_size": 32000
|
38 |
+
}
|
configuration_llama.py
ADDED
@@ -0,0 +1,184 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# coding=utf-8
|
2 |
+
# Copyright 2022 EleutherAI and the HuggingFace Inc. team. 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 |
+
""" LLaMA model configuration"""
|
21 |
+
|
22 |
+
from transformers.configuration_utils import PretrainedConfig
|
23 |
+
from transformers.utils import logging
|
24 |
+
|
25 |
+
|
26 |
+
logger = logging.get_logger(__name__)
|
27 |
+
|
28 |
+
LLAMA_PRETRAINED_CONFIG_ARCHIVE_MAP = {}
|
29 |
+
|
30 |
+
|
31 |
+
class LlamaConfig(PretrainedConfig):
|
32 |
+
r"""
|
33 |
+
This is the configuration class to store the configuration of a [`LlamaModel`]. It is used to instantiate an LLaMA
|
34 |
+
model according to the specified arguments, defining the model architecture. Instantiating a configuration with the
|
35 |
+
defaults will yield a similar configuration to that of the LLaMA-7B.
|
36 |
+
|
37 |
+
Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the
|
38 |
+
documentation from [`PretrainedConfig`] for more information.
|
39 |
+
|
40 |
+
|
41 |
+
Args:
|
42 |
+
vocab_size (`int`, *optional*, defaults to 32000):
|
43 |
+
Vocabulary size of the LLaMA model. Defines the number of different tokens that can be represented by the
|
44 |
+
`inputs_ids` passed when calling [`LlamaModel`]
|
45 |
+
hidden_size (`int`, *optional*, defaults to 4096):
|
46 |
+
Dimension of the hidden representations.
|
47 |
+
intermediate_size (`int`, *optional*, defaults to 11008):
|
48 |
+
Dimension of the MLP representations.
|
49 |
+
num_hidden_layers (`int`, *optional*, defaults to 32):
|
50 |
+
Number of hidden layers in the Transformer encoder.
|
51 |
+
num_attention_heads (`int`, *optional*, defaults to 32):
|
52 |
+
Number of attention heads for each attention layer in the Transformer encoder.
|
53 |
+
num_key_value_heads (`int`, *optional*):
|
54 |
+
This is the number of key_value heads that should be used to implement Grouped Query Attention. If
|
55 |
+
`num_key_value_heads=num_attention_heads`, the model will use Multi Head Attention (MHA), if
|
56 |
+
`num_key_value_heads=1 the model will use Multi Query Attention (MQA) otherwise GQA is used. When
|
57 |
+
converting a multi-head checkpoint to a GQA checkpoint, each group key and value head should be constructed
|
58 |
+
by meanpooling all the original heads within that group. For more details checkout [this
|
59 |
+
paper](https://arxiv.org/pdf/2305.13245.pdf). If it is not specified, will default to
|
60 |
+
`num_attention_heads`.
|
61 |
+
pretraining_tp (`int`, *optional*, defaults to `1`):
|
62 |
+
Experimental feature. Tensor parallelism rank used during pretraining. Please refer to [this
|
63 |
+
document](https://huggingface.co/docs/transformers/parallelism) to understand more about it. This value is
|
64 |
+
necessary to ensure exact reproducibility of the pretraining results. Please refer to [this
|
65 |
+
issue](https://github.com/pytorch/pytorch/issues/76232).
|
66 |
+
hidden_act (`str` or `function`, *optional*, defaults to `"silu"`):
|
67 |
+
The non-linear activation function (function or string) in the decoder.
|
68 |
+
max_position_embeddings (`int`, *optional*, defaults to 2048):
|
69 |
+
The maximum sequence length that this model might ever be used with. Typically set this to something large
|
70 |
+
just in case (e.g., 512 or 1024 or 2048).
|
71 |
+
initializer_range (`float`, *optional*, defaults to 0.02):
|
72 |
+
The standard deviation of the truncated_normal_initializer for initializing all weight matrices.
|
73 |
+
rms_norm_eps (`float`, *optional*, defaults to 1e-12):
|
74 |
+
The epsilon used by the rms normalization layers.
|
75 |
+
use_cache (`bool`, *optional*, defaults to `True`):
|
76 |
+
Whether or not the model should return the last key/values attentions (not used by all models). Only
|
77 |
+
relevant if `config.is_decoder=True`.
|
78 |
+
tie_word_embeddings(`bool`, *optional*, defaults to `False`):
|
79 |
+
Whether to tie weight embeddings
|
80 |
+
rope_scaling (`Dict`, *optional*):
|
81 |
+
Dictionary containing the scaling configuration for the RoPE embeddings. Currently supports three scaling
|
82 |
+
strategies: linear and dynamic. Their scaling factor must be an float greater than 1. The expected format
|
83 |
+
is `{"type": strategy name, "factor": scaling factor}`. When using this flag, don't update
|
84 |
+
`max_position_embeddings` to the expected new maximum. See the following thread for more information on how
|
85 |
+
these scaling strategies behave:
|
86 |
+
https://www.reddit.com/r/LocalLLaMA/comments/14mrgpr/dynamically_scaled_rope_further_increases/. This is an
|
87 |
+
experimental feature, subject to breaking API changes in future versions.
|
88 |
+
attention_bias (`bool`, defaults to `False`, *optional*, defaults to `False`):
|
89 |
+
Whether to use a bias in the query, key, value and output projection layers during self-attention.
|
90 |
+
|
91 |
+
Example:
|
92 |
+
|
93 |
+
```python
|
94 |
+
>>> from transformers import LlamaModel, LlamaConfig
|
95 |
+
|
96 |
+
>>> # Initializing a LLaMA llama-7b style configuration
|
97 |
+
>>> configuration = LlamaConfig()
|
98 |
+
|
99 |
+
>>> # Initializing a model from the llama-7b style configuration
|
100 |
+
>>> model = LlamaModel(configuration)
|
101 |
+
|
102 |
+
>>> # Accessing the model configuration
|
103 |
+
>>> configuration = model.config
|
104 |
+
```"""
|
105 |
+
model_type = "llama"
|
106 |
+
keys_to_ignore_at_inference = ["past_key_values"]
|
107 |
+
|
108 |
+
def __init__(
|
109 |
+
self,
|
110 |
+
vocab_size=32000,
|
111 |
+
hidden_size=4096,
|
112 |
+
intermediate_size=11008,
|
113 |
+
num_hidden_layers=32,
|
114 |
+
num_attention_heads=32,
|
115 |
+
num_key_value_heads=None,
|
116 |
+
hidden_act="silu",
|
117 |
+
max_position_embeddings=2048,
|
118 |
+
initializer_range=0.02,
|
119 |
+
rms_norm_eps=1e-6,
|
120 |
+
use_cache=True,
|
121 |
+
pad_token_id=0,
|
122 |
+
bos_token_id=1,
|
123 |
+
eos_token_id=2,
|
124 |
+
pretraining_tp=1,
|
125 |
+
tie_word_embeddings=False,
|
126 |
+
rope_theta=10000,
|
127 |
+
rope_scaling=None,
|
128 |
+
attention_bias=False,
|
129 |
+
**kwargs,
|
130 |
+
):
|
131 |
+
self.vocab_size = vocab_size
|
132 |
+
self.max_position_embeddings = max_position_embeddings
|
133 |
+
self.hidden_size = hidden_size
|
134 |
+
self.intermediate_size = intermediate_size
|
135 |
+
self.num_hidden_layers = num_hidden_layers
|
136 |
+
self.num_attention_heads = num_attention_heads
|
137 |
+
|
138 |
+
# for backward compatibility
|
139 |
+
if num_key_value_heads is None:
|
140 |
+
num_key_value_heads = num_attention_heads
|
141 |
+
|
142 |
+
self.num_key_value_heads = num_key_value_heads
|
143 |
+
self.hidden_act = hidden_act
|
144 |
+
self.initializer_range = initializer_range
|
145 |
+
self.rms_norm_eps = rms_norm_eps
|
146 |
+
self.pretraining_tp = pretraining_tp
|
147 |
+
self.use_cache = use_cache
|
148 |
+
self.rope_theta = rope_theta
|
149 |
+
self.rope_scaling = rope_scaling
|
150 |
+
self._rope_scaling_validation()
|
151 |
+
self.attention_bias = attention_bias
|
152 |
+
|
153 |
+
super().__init__(
|
154 |
+
pad_token_id=pad_token_id,
|
155 |
+
bos_token_id=bos_token_id,
|
156 |
+
eos_token_id=eos_token_id,
|
157 |
+
tie_word_embeddings=tie_word_embeddings,
|
158 |
+
**kwargs,
|
159 |
+
)
|
160 |
+
|
161 |
+
def _rope_scaling_validation(self):
|
162 |
+
"""
|
163 |
+
Validate the `rope_scaling` configuration.
|
164 |
+
"""
|
165 |
+
if self.rope_scaling is None:
|
166 |
+
return
|
167 |
+
|
168 |
+
if not isinstance(self.rope_scaling, dict):
|
169 |
+
raise ValueError(
|
170 |
+
"`rope_scaling` must be a dictionary, "
|
171 |
+
f"got {self.rope_scaling}"
|
172 |
+
)
|
173 |
+
rope_scaling_type = self.rope_scaling.get("type", None)
|
174 |
+
rope_scaling_factor = self.rope_scaling.get("factor", None)
|
175 |
+
if rope_scaling_type is None or rope_scaling_type not in ["linear", "dynamic", "yarn", "dynamic-yarn"]:
|
176 |
+
raise ValueError(
|
177 |
+
f"`rope_scaling`'s name field must be one of ['linear', 'dynamic', 'yarn', 'dynamic-yarn'], got {rope_scaling_type}"
|
178 |
+
)
|
179 |
+
if rope_scaling_factor is None or not isinstance(rope_scaling_factor, float) or rope_scaling_factor <= 1.0:
|
180 |
+
raise ValueError(f"`rope_scaling`'s factor field must be an float > 1, got {rope_scaling_factor}")
|
181 |
+
if rope_scaling_type == "yarn" or rope_scaling_type == "dynamic-yarn":
|
182 |
+
original_max_position_embeddings = self.rope_scaling.get("original_max_position_embeddings", None)
|
183 |
+
if original_max_position_embeddings is None or not isinstance(original_max_position_embeddings, int):
|
184 |
+
raise ValueError(f"`rope_scaling.original_max_position_embeddings` must be set to an int when using yarn, and dynamic-yarn")
|
generation_config.json
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"bos_token_id": 1,
|
3 |
+
"do_sample": true,
|
4 |
+
"eos_token_id": 2,
|
5 |
+
"max_length": 4096,
|
6 |
+
"pad_token_id": 0,
|
7 |
+
"temperature": 0.6,
|
8 |
+
"top_p": 0.9,
|
9 |
+
"transformers_version": "4.35.0.dev0"
|
10 |
+
}
|
huggingface-metadata.txt
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
url: https://huggingface.co/NousResearch/Yarn-Llama-2-70b-32k
|
2 |
+
branch: main
|
3 |
+
download date: 2023-11-21 10:50:00
|
4 |
+
sha256sum:
|
5 |
+
4a6437407226b8f285195908f8242b5927bfcfaf17400ef3f7f1e8e0c12c3855 pytorch_model-00001-of-00015.bin
|
6 |
+
5952bde86d32fba40b60befebb942b60a6c28a534c518c65751da29911928322 pytorch_model-00002-of-00015.bin
|
7 |
+
9ede3a84d9f6afee4a63ece121b298620c20226005970da6039d53a8877514ae pytorch_model-00003-of-00015.bin
|
8 |
+
b2acd22648ab2505a876205939482d96c3350b8aac2d1f82baf7f4cd17737e33 pytorch_model-00004-of-00015.bin
|
9 |
+
1ab84094aa966bed158cd4087736f7b3725ee2a66c24047cd436b5238a771ae3 pytorch_model-00005-of-00015.bin
|
10 |
+
bed79fe2103fc9613100edc0a9f8163a558ee61890016d40e99e073b2a0a2003 pytorch_model-00006-of-00015.bin
|
11 |
+
179ca184e0dd635dafddb2820d2c8527d71b60e45b7dd0e61471d35f098d06bc pytorch_model-00007-of-00015.bin
|
12 |
+
278b7757b820f982ca2a977f0fc16542bc8fbc282cd82e45f4f74ba2e5669885 pytorch_model-00008-of-00015.bin
|
13 |
+
6152fa960e583452d8ff3e95bb8ac55dfb3ea990eafb1ad279c32d79ac3e002f pytorch_model-00009-of-00015.bin
|
14 |
+
47deb887e6f1e8546c51825fd91d516bcba97d8e5bd351a7aade0c41906ed4fb pytorch_model-00010-of-00015.bin
|
15 |
+
c75a1b0aba6e4e85c6c6e01af51531e41e7dad187972f4d575faf424446b376a pytorch_model-00011-of-00015.bin
|
16 |
+
735bd94bdeaa4469e1d8048730721a9256b4c8a806e7b33336175bf4991a5fe5 pytorch_model-00012-of-00015.bin
|
17 |
+
5bfb0de70b2d7b151fb4edfadd6cccc7a06da8d7c8054fb8c522733fea4e3997 pytorch_model-00013-of-00015.bin
|
18 |
+
64c9dfd546320478aea35b205e74eb9162cee5280dd88cab4a032f52ae76769f pytorch_model-00014-of-00015.bin
|
19 |
+
ff98dd0b9c6efb896d1526b99d98b86ce311e7515b49f5a1c85ec771e110d84d pytorch_model-00015-of-00015.bin
|
20 |
+
9e556afd44213b6bd1be2b850ebbbd98f5481437a8021afaf58ee7fb1818d347 tokenizer.model
|
modeling_llama_yarn.py
ADDED
@@ -0,0 +1,1406 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# coding=utf-8
|
2 |
+
# Copyright 2022 EleutherAI and the HuggingFace Inc. team. 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 LLaMA model."""
|
21 |
+
import math
|
22 |
+
from typing import List, Optional, Tuple, Union
|
23 |
+
|
24 |
+
import torch
|
25 |
+
import torch.nn.functional as F
|
26 |
+
import torch.utils.checkpoint
|
27 |
+
from torch import nn
|
28 |
+
from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss
|
29 |
+
|
30 |
+
from transformers.activations import ACT2FN
|
31 |
+
from transformers.modeling_outputs import BaseModelOutputWithPast, CausalLMOutputWithPast, SequenceClassifierOutputWithPast
|
32 |
+
from transformers.modeling_utils import PreTrainedModel
|
33 |
+
from transformers.pytorch_utils import ALL_LAYERNORM_LAYERS
|
34 |
+
from transformers.utils import (
|
35 |
+
add_start_docstrings,
|
36 |
+
add_start_docstrings_to_model_forward,
|
37 |
+
is_flash_attn_2_available,
|
38 |
+
logging,
|
39 |
+
replace_return_docstrings,
|
40 |
+
)
|
41 |
+
from .configuration_llama import LlamaConfig
|
42 |
+
|
43 |
+
|
44 |
+
if is_flash_attn_2_available():
|
45 |
+
from flash_attn import flash_attn_func, flash_attn_varlen_func
|
46 |
+
from flash_attn.bert_padding import index_first_axis, pad_input, unpad_input # noqa
|
47 |
+
|
48 |
+
|
49 |
+
logger = logging.get_logger(__name__)
|
50 |
+
|
51 |
+
_CONFIG_FOR_DOC = "LlamaConfig"
|
52 |
+
|
53 |
+
|
54 |
+
def _get_unpad_data(padding_mask):
|
55 |
+
seqlens_in_batch = padding_mask.sum(dim=-1, dtype=torch.int32)
|
56 |
+
indices = torch.nonzero(padding_mask.flatten(), as_tuple=False).flatten()
|
57 |
+
max_seqlen_in_batch = seqlens_in_batch.max().item()
|
58 |
+
cu_seqlens = F.pad(torch.cumsum(seqlens_in_batch, dim=0, dtype=torch.torch.int32), (1, 0))
|
59 |
+
return (
|
60 |
+
indices,
|
61 |
+
cu_seqlens,
|
62 |
+
max_seqlen_in_batch,
|
63 |
+
)
|
64 |
+
|
65 |
+
|
66 |
+
# Copied from transformers.models.bart.modeling_bart._make_causal_mask
|
67 |
+
def _make_causal_mask(
|
68 |
+
input_ids_shape: torch.Size, dtype: torch.dtype, device: torch.device, past_key_values_length: int = 0
|
69 |
+
):
|
70 |
+
"""
|
71 |
+
Make causal mask used for bi-directional self-attention.
|
72 |
+
"""
|
73 |
+
bsz, tgt_len = input_ids_shape
|
74 |
+
mask = torch.full((tgt_len, tgt_len), torch.finfo(dtype).min, device=device)
|
75 |
+
mask_cond = torch.arange(mask.size(-1), device=device)
|
76 |
+
mask.masked_fill_(mask_cond < (mask_cond + 1).view(mask.size(-1), 1), 0)
|
77 |
+
mask = mask.to(dtype)
|
78 |
+
|
79 |
+
if past_key_values_length > 0:
|
80 |
+
mask = torch.cat([torch.zeros(tgt_len, past_key_values_length, dtype=dtype, device=device), mask], dim=-1)
|
81 |
+
return mask[None, None, :, :].expand(bsz, 1, tgt_len, tgt_len + past_key_values_length)
|
82 |
+
|
83 |
+
|
84 |
+
# Copied from transformers.models.bart.modeling_bart._expand_mask
|
85 |
+
def _expand_mask(mask: torch.Tensor, dtype: torch.dtype, tgt_len: Optional[int] = None):
|
86 |
+
"""
|
87 |
+
Expands attention_mask from `[bsz, seq_len]` to `[bsz, 1, tgt_seq_len, src_seq_len]`.
|
88 |
+
"""
|
89 |
+
bsz, src_len = mask.size()
|
90 |
+
tgt_len = tgt_len if tgt_len is not None else src_len
|
91 |
+
|
92 |
+
expanded_mask = mask[:, None, None, :].expand(bsz, 1, tgt_len, src_len).to(dtype)
|
93 |
+
|
94 |
+
inverted_mask = 1.0 - expanded_mask
|
95 |
+
|
96 |
+
return inverted_mask.masked_fill(inverted_mask.to(torch.bool), torch.finfo(dtype).min)
|
97 |
+
|
98 |
+
# Inverse dim formula to find dim based on number of rotations
|
99 |
+
def _yarn_find_correction_dim(num_rotations, dim, base=10000, max_position_embeddings=2048):
|
100 |
+
return (dim * math.log(max_position_embeddings/(num_rotations * 2 * math.pi)))/(2 * math.log(base))
|
101 |
+
|
102 |
+
# Find dim range bounds based on rotations
|
103 |
+
def _yarn_find_correction_range(low_rot, high_rot, dim, base=10000, max_position_embeddings=2048):
|
104 |
+
low = math.floor(_yarn_find_correction_dim(
|
105 |
+
low_rot, dim, base, max_position_embeddings))
|
106 |
+
high = math.ceil(_yarn_find_correction_dim(
|
107 |
+
high_rot, dim, base, max_position_embeddings))
|
108 |
+
return max(low, 0), min(high, dim-1) # Clamp values just in case
|
109 |
+
|
110 |
+
def _yarn_linear_ramp_mask(min, max, dim):
|
111 |
+
if min == max:
|
112 |
+
max += 0.001 # Prevent singularity
|
113 |
+
|
114 |
+
linear_func = (torch.arange(dim, dtype=torch.float32) - min) / (max - min)
|
115 |
+
ramp_func = torch.clamp(linear_func, 0, 1)
|
116 |
+
return ramp_func
|
117 |
+
|
118 |
+
def _yarn_get_mscale(scale=1):
|
119 |
+
if scale <= 1:
|
120 |
+
return 1.0
|
121 |
+
return 0.1 * math.log(scale) + 1.0
|
122 |
+
|
123 |
+
class LlamaRMSNorm(nn.Module):
|
124 |
+
def __init__(self, hidden_size, eps=1e-6):
|
125 |
+
"""
|
126 |
+
LlamaRMSNorm is equivalent to T5LayerNorm
|
127 |
+
"""
|
128 |
+
super().__init__()
|
129 |
+
self.weight = nn.Parameter(torch.ones(hidden_size))
|
130 |
+
self.variance_epsilon = eps
|
131 |
+
|
132 |
+
def forward(self, hidden_states):
|
133 |
+
input_dtype = hidden_states.dtype
|
134 |
+
hidden_states = hidden_states.to(torch.float32)
|
135 |
+
variance = hidden_states.pow(2).mean(-1, keepdim=True)
|
136 |
+
hidden_states = hidden_states * torch.rsqrt(variance + self.variance_epsilon)
|
137 |
+
return self.weight * hidden_states.to(input_dtype)
|
138 |
+
|
139 |
+
|
140 |
+
ALL_LAYERNORM_LAYERS.append(LlamaRMSNorm)
|
141 |
+
|
142 |
+
|
143 |
+
class LlamaRotaryEmbedding(nn.Module):
|
144 |
+
def __init__(self, dim, max_position_embeddings=2048, base=10000, device=None):
|
145 |
+
super().__init__()
|
146 |
+
|
147 |
+
self.dim = dim
|
148 |
+
self.max_position_embeddings = max_position_embeddings
|
149 |
+
self.base = base
|
150 |
+
inv_freq = 1.0 / (self.base ** (torch.arange(0, self.dim, 2).float().to(device) / self.dim))
|
151 |
+
self.register_buffer("inv_freq", inv_freq, persistent=False)
|
152 |
+
|
153 |
+
# Build here to make `torch.jit.trace` work.
|
154 |
+
self._set_cos_sin_cache(
|
155 |
+
seq_len=max_position_embeddings, device=self.inv_freq.device, dtype=torch.get_default_dtype()
|
156 |
+
)
|
157 |
+
|
158 |
+
def _set_cos_sin_cache(self, seq_len, device, dtype):
|
159 |
+
self.max_seq_len_cached = seq_len
|
160 |
+
t = torch.arange(self.max_seq_len_cached, device=device, dtype=self.inv_freq.dtype)
|
161 |
+
|
162 |
+
freqs = torch.einsum("i,j->ij", t, self.inv_freq)
|
163 |
+
# Different from paper, but it uses a different permutation in order to obtain the same calculation
|
164 |
+
emb = torch.cat((freqs, freqs), dim=-1)
|
165 |
+
self.register_buffer("cos_cached", emb.cos().to(dtype), persistent=False)
|
166 |
+
self.register_buffer("sin_cached", emb.sin().to(dtype), persistent=False)
|
167 |
+
|
168 |
+
def forward(self, x, seq_len=None):
|
169 |
+
# x: [bs, num_attention_heads, seq_len, head_size]
|
170 |
+
if seq_len > self.max_seq_len_cached:
|
171 |
+
self._set_cos_sin_cache(seq_len=seq_len, device=x.device, dtype=x.dtype)
|
172 |
+
|
173 |
+
return (
|
174 |
+
self.cos_cached[:seq_len].to(dtype=x.dtype),
|
175 |
+
self.sin_cached[:seq_len].to(dtype=x.dtype),
|
176 |
+
)
|
177 |
+
|
178 |
+
|
179 |
+
class LlamaLinearScalingRotaryEmbedding(LlamaRotaryEmbedding):
|
180 |
+
"""LlamaRotaryEmbedding extended with linear scaling. Credits to the Reddit user /u/kaiokendev"""
|
181 |
+
|
182 |
+
def __init__(self, dim, max_position_embeddings=2048, base=10000, device=None, scaling_factor=1.0):
|
183 |
+
self.scaling_factor = scaling_factor
|
184 |
+
super().__init__(dim, max_position_embeddings, base, device)
|
185 |
+
|
186 |
+
def _set_cos_sin_cache(self, seq_len, device, dtype):
|
187 |
+
self.max_seq_len_cached = seq_len
|
188 |
+
t = torch.arange(self.max_seq_len_cached, device=device, dtype=self.inv_freq.dtype)
|
189 |
+
t = t / self.scaling_factor
|
190 |
+
|
191 |
+
freqs = torch.einsum("i,j->ij", t, self.inv_freq)
|
192 |
+
# Different from paper, but it uses a different permutation in order to obtain the same calculation
|
193 |
+
emb = torch.cat((freqs, freqs), dim=-1)
|
194 |
+
self.register_buffer("cos_cached", emb.cos().to(dtype), persistent=False)
|
195 |
+
self.register_buffer("sin_cached", emb.sin().to(dtype), persistent=False)
|
196 |
+
|
197 |
+
|
198 |
+
class LlamaDynamicNTKScalingRotaryEmbedding(LlamaRotaryEmbedding):
|
199 |
+
"""LlamaRotaryEmbedding extended with Dynamic NTK scaling. Credits to the Reddit users /u/bloc97 and /u/emozilla"""
|
200 |
+
|
201 |
+
def __init__(self, dim, max_position_embeddings=2048, base=10000, device=None, scaling_factor=1.0):
|
202 |
+
self.scaling_factor = scaling_factor
|
203 |
+
super().__init__(dim, max_position_embeddings, base, device)
|
204 |
+
|
205 |
+
def _set_cos_sin_cache(self, seq_len, device, dtype):
|
206 |
+
self.max_seq_len_cached = seq_len
|
207 |
+
|
208 |
+
if seq_len > self.max_position_embeddings:
|
209 |
+
base = self.base * (
|
210 |
+
(self.scaling_factor * seq_len / self.max_position_embeddings) - (self.scaling_factor - 1)
|
211 |
+
) ** (self.dim / (self.dim - 2))
|
212 |
+
inv_freq = 1.0 / (base ** (torch.arange(0, self.dim, 2).float().to(device) / self.dim))
|
213 |
+
self.register_buffer("inv_freq", inv_freq, persistent=False)
|
214 |
+
|
215 |
+
t = torch.arange(self.max_seq_len_cached, device=device, dtype=self.inv_freq.dtype)
|
216 |
+
|
217 |
+
freqs = torch.einsum("i,j->ij", t, self.inv_freq)
|
218 |
+
# Different from paper, but it uses a different permutation in order to obtain the same calculation
|
219 |
+
emb = torch.cat((freqs, freqs), dim=-1)
|
220 |
+
self.register_buffer("cos_cached", emb.cos().to(dtype), persistent=False)
|
221 |
+
self.register_buffer("sin_cached", emb.sin().to(dtype), persistent=False)
|
222 |
+
|
223 |
+
|
224 |
+
class LlamaYaRNScaledRotaryEmbedding(torch.nn.Module):
|
225 |
+
def __init__(self, dim, max_position_embeddings=2048, base=10000, scale=1, original_max_position_embeddings=2048, extrapolation_factor=1, attn_factor=1, beta_fast=32, beta_slow=1, finetuned=False, device=None):
|
226 |
+
super().__init__()
|
227 |
+
|
228 |
+
self.dim = dim
|
229 |
+
self.max_position_embeddings = max_position_embeddings
|
230 |
+
self.base = base
|
231 |
+
self.scale = scale
|
232 |
+
self.original_max_position_embeddings = original_max_position_embeddings
|
233 |
+
self.extrapolation_factor = extrapolation_factor
|
234 |
+
self.attn_factor = attn_factor
|
235 |
+
self.beta_fast = beta_fast
|
236 |
+
self.beta_slow = beta_slow
|
237 |
+
|
238 |
+
self.yarn(device)
|
239 |
+
|
240 |
+
# Build here to make `torch.jit.trace` work.
|
241 |
+
self.max_seq_len_cached = max_position_embeddings
|
242 |
+
t = torch.arange(self.max_seq_len_cached, device=self.inv_freq.device, dtype=self.inv_freq.dtype)
|
243 |
+
freqs = torch.einsum("i,j->ij", t, self.inv_freq)
|
244 |
+
# Different from paper, but it uses a different permutation in order to obtain the same calculation
|
245 |
+
emb = torch.cat((freqs, freqs), dim=-1)
|
246 |
+
dtype = torch.get_default_dtype()
|
247 |
+
|
248 |
+
self.register_buffer("cos_cached", (emb.cos() * self.mscale).to(dtype), persistent=False)
|
249 |
+
self.register_buffer("sin_cached", (emb.sin() * self.mscale).to(dtype), persistent=False)
|
250 |
+
|
251 |
+
def forward(self, x, seq_len=None):
|
252 |
+
# x: [bs, num_attention_heads, seq_len, head_size]
|
253 |
+
# This `if` block is unlikely to be run after we build sin/cos in `__init__`. Keep the logic here just in case.
|
254 |
+
if seq_len > self.max_seq_len_cached:
|
255 |
+
self.max_seq_len_cached = seq_len
|
256 |
+
|
257 |
+
t = torch.arange(self.max_seq_len_cached, device=x.device, dtype=self.inv_freq.dtype)
|
258 |
+
freqs = torch.einsum("i,j->ij", t, self.inv_freq)
|
259 |
+
# Different from paper, but it uses a different permutation in order to obtain the same calculation
|
260 |
+
emb = torch.cat((freqs, freqs), dim=-1).to(x.device)
|
261 |
+
|
262 |
+
self.register_buffer("cos_cached", (emb.cos() * self.mscale).to(x.dtype), persistent=False)
|
263 |
+
self.register_buffer("sin_cached", (emb.sin() * self.mscale).to(x.dtype), persistent=False)
|
264 |
+
return (
|
265 |
+
self.cos_cached[:seq_len].to(dtype=x.dtype),
|
266 |
+
self.sin_cached[:seq_len].to(dtype=x.dtype),
|
267 |
+
)
|
268 |
+
|
269 |
+
def yarn(self, device):
|
270 |
+
pos_freqs = self.base ** (torch.arange(0, self.dim, 2).float().to(device) / self.dim)
|
271 |
+
inv_freq_extrapolation = 1.0 / pos_freqs
|
272 |
+
inv_freq_interpolation = 1.0 / (self.scale * pos_freqs)
|
273 |
+
|
274 |
+
low, high = _yarn_find_correction_range(self.beta_fast, self.beta_slow, self.dim, self.base, self.original_max_position_embeddings)
|
275 |
+
inv_freq_mask = (1 - _yarn_linear_ramp_mask(low, high, self.dim // 2).float().to(device)) * self.extrapolation_factor # Get n-d rotational scaling corrected for extrapolation
|
276 |
+
inv_freq = inv_freq_interpolation * (1 - inv_freq_mask) + inv_freq_extrapolation * inv_freq_mask
|
277 |
+
|
278 |
+
self.register_buffer("inv_freq", inv_freq, persistent=False)
|
279 |
+
self.mscale = float(_yarn_get_mscale(self.scale) * self.attn_factor) # Get n-d magnitude scaling corrected for interpolation
|
280 |
+
|
281 |
+
|
282 |
+
class LlamaDynamicYaRNScaledRotaryEmbedding(torch.nn.Module):
|
283 |
+
def __init__(self, dim, max_position_embeddings=2048, base=10000, original_max_position_embeddings=2048, extrapolation_factor=1, attn_factor=1, beta_fast=32, beta_slow=1, finetuned=False, device=None):
|
284 |
+
super().__init__()
|
285 |
+
|
286 |
+
self.dim = dim
|
287 |
+
self.max_position_embeddings = max_position_embeddings
|
288 |
+
self.base = base
|
289 |
+
self.original_max_position_embeddings = original_max_position_embeddings
|
290 |
+
self.extrapolation_factor = extrapolation_factor
|
291 |
+
self.attn_factor = attn_factor
|
292 |
+
self.beta_fast = beta_fast
|
293 |
+
self.beta_slow = beta_slow
|
294 |
+
|
295 |
+
if finetuned:
|
296 |
+
self.yarn(self.max_position_embeddings / self.original_max_position_embeddings, device)
|
297 |
+
else:
|
298 |
+
inv_freq = 1.0 / \
|
299 |
+
(base ** (torch.arange(0, dim, 2).float().to(device) / dim))
|
300 |
+
self.register_buffer("inv_freq", inv_freq, persistent=False)
|
301 |
+
self.mscale = 1
|
302 |
+
|
303 |
+
# Build here to make `torch.jit.trace` work.
|
304 |
+
self.max_seq_len_cached = max_position_embeddings
|
305 |
+
t = torch.arange(self.max_seq_len_cached, device=self.inv_freq.device, dtype=torch.float32)
|
306 |
+
freqs = torch.einsum("i,j->ij", t, self.inv_freq)
|
307 |
+
# Different from paper, but it uses a different permutation in order to obtain the same calculation
|
308 |
+
emb = torch.cat((freqs, freqs), dim=-1)
|
309 |
+
dtype = torch.get_default_dtype()
|
310 |
+
|
311 |
+
self.register_buffer("cos_cached", (emb.cos() * self.mscale).to(dtype), persistent=False)
|
312 |
+
self.register_buffer("sin_cached", (emb.sin() * self.mscale).to(dtype), persistent=False)
|
313 |
+
|
314 |
+
def forward(self, x, seq_len=None):
|
315 |
+
# x: [bs, num_attention_heads, seq_len, head_size]
|
316 |
+
# This `if` block is unlikely to be run after we build sin/cos in `__init__`. Keep the logic here just in case.
|
317 |
+
if seq_len > self.max_seq_len_cached:
|
318 |
+
self.max_seq_len_cached = seq_len
|
319 |
+
|
320 |
+
self.yarn(seq_len / self.max_position_embeddings, x.device)
|
321 |
+
|
322 |
+
t = torch.arange(self.max_seq_len_cached, device=x.device, dtype=self.inv_freq.dtype)
|
323 |
+
freqs = torch.einsum("i,j->ij", t, self.inv_freq)
|
324 |
+
# Different from paper, but it uses a different permutation in order to obtain the same calculation
|
325 |
+
emb = torch.cat((freqs, freqs), dim=-1).to(x.device)
|
326 |
+
|
327 |
+
self.register_buffer("cos_cached", (emb.cos() * self.mscale).to(x.dtype), persistent=False)
|
328 |
+
self.register_buffer("sin_cached", (emb.sin() * self.mscale).to(x.dtype), persistent=False)
|
329 |
+
return (
|
330 |
+
self.cos_cached[:seq_len].to(dtype=x.dtype),
|
331 |
+
self.sin_cached[:seq_len].to(dtype=x.dtype),
|
332 |
+
)
|
333 |
+
|
334 |
+
def yarn(self, scale, device):
|
335 |
+
pos_freqs = self.base ** (torch.arange(0, self.dim, 2).float().to(device) / self.dim)
|
336 |
+
inv_freq_extrapolation = 1.0 / pos_freqs
|
337 |
+
inv_freq_interpolation = 1.0 / (scale * pos_freqs)
|
338 |
+
|
339 |
+
low, high = _yarn_find_correction_range(self.beta_fast, self.beta_slow, self.dim, self.base, self.original_max_position_embeddings)
|
340 |
+
inv_freq_mask = (1 - _yarn_linear_ramp_mask(low, high, self.dim // 2).float().to(device)) * self.extrapolation_factor # Get n-d rotational scaling corrected for extrapolation
|
341 |
+
inv_freq = inv_freq_interpolation * (1 - inv_freq_mask) + inv_freq_extrapolation * inv_freq_mask
|
342 |
+
|
343 |
+
self.register_buffer("inv_freq", inv_freq, persistent=False)
|
344 |
+
self.mscale = float(_yarn_get_mscale(scale) * self.attn_factor) # Get n-d magnitude scaling corrected for interpolation
|
345 |
+
|
346 |
+
|
347 |
+
def rotate_half(x):
|
348 |
+
"""Rotates half the hidden dims of the input."""
|
349 |
+
x1 = x[..., : x.shape[-1] // 2]
|
350 |
+
x2 = x[..., x.shape[-1] // 2 :]
|
351 |
+
return torch.cat((-x2, x1), dim=-1)
|
352 |
+
|
353 |
+
|
354 |
+
# Copied from transformers.models.gpt_neox.modeling_gpt_neox.apply_rotary_pos_emb
|
355 |
+
def apply_rotary_pos_emb(q, k, cos, sin, position_ids):
|
356 |
+
cos = cos[position_ids].unsqueeze(1) # [seq_len, dim] -> [batch_size, 1, seq_len, head_dim]
|
357 |
+
sin = sin[position_ids].unsqueeze(1)
|
358 |
+
q_embed = (q * cos) + (rotate_half(q) * sin)
|
359 |
+
k_embed = (k * cos) + (rotate_half(k) * sin)
|
360 |
+
return q_embed, k_embed
|
361 |
+
|
362 |
+
|
363 |
+
class LlamaMLP(nn.Module):
|
364 |
+
def __init__(self, config):
|
365 |
+
super().__init__()
|
366 |
+
self.config = config
|
367 |
+
self.hidden_size = config.hidden_size
|
368 |
+
self.intermediate_size = config.intermediate_size
|
369 |
+
self.gate_proj = nn.Linear(self.hidden_size, self.intermediate_size, bias=False)
|
370 |
+
self.up_proj = nn.Linear(self.hidden_size, self.intermediate_size, bias=False)
|
371 |
+
self.down_proj = nn.Linear(self.intermediate_size, self.hidden_size, bias=False)
|
372 |
+
self.act_fn = ACT2FN[config.hidden_act]
|
373 |
+
|
374 |
+
def forward(self, x):
|
375 |
+
if self.config.pretraining_tp > 1:
|
376 |
+
slice = self.intermediate_size // self.config.pretraining_tp
|
377 |
+
gate_proj_slices = self.gate_proj.weight.split(slice, dim=0)
|
378 |
+
up_proj_slices = self.up_proj.weight.split(slice, dim=0)
|
379 |
+
down_proj_slices = self.down_proj.weight.split(slice, dim=1)
|
380 |
+
|
381 |
+
gate_proj = torch.cat(
|
382 |
+
[F.linear(x, gate_proj_slices[i]) for i in range(self.config.pretraining_tp)], dim=-1
|
383 |
+
)
|
384 |
+
up_proj = torch.cat([F.linear(x, up_proj_slices[i]) for i in range(self.config.pretraining_tp)], dim=-1)
|
385 |
+
|
386 |
+
intermediate_states = (self.act_fn(gate_proj) * up_proj).split(slice, dim=2)
|
387 |
+
down_proj = [
|
388 |
+
F.linear(intermediate_states[i], down_proj_slices[i]) for i in range(self.config.pretraining_tp)
|
389 |
+
]
|
390 |
+
down_proj = sum(down_proj)
|
391 |
+
else:
|
392 |
+
down_proj = self.down_proj(self.act_fn(self.gate_proj(x)) * self.up_proj(x))
|
393 |
+
|
394 |
+
return down_proj
|
395 |
+
|
396 |
+
|
397 |
+
def repeat_kv(hidden_states: torch.Tensor, n_rep: int) -> torch.Tensor:
|
398 |
+
"""
|
399 |
+
This is the equivalent of torch.repeat_interleave(x, dim=1, repeats=n_rep). The hidden states go from (batch,
|
400 |
+
num_key_value_heads, seqlen, head_dim) to (batch, num_attention_heads, seqlen, head_dim)
|
401 |
+
"""
|
402 |
+
batch, num_key_value_heads, slen, head_dim = hidden_states.shape
|
403 |
+
if n_rep == 1:
|
404 |
+
return hidden_states
|
405 |
+
hidden_states = hidden_states[:, :, None, :, :].expand(batch, num_key_value_heads, n_rep, slen, head_dim)
|
406 |
+
return hidden_states.reshape(batch, num_key_value_heads * n_rep, slen, head_dim)
|
407 |
+
|
408 |
+
|
409 |
+
class LlamaAttention(nn.Module):
|
410 |
+
"""Multi-headed attention from 'Attention Is All You Need' paper"""
|
411 |
+
|
412 |
+
def __init__(self, config: LlamaConfig):
|
413 |
+
super().__init__()
|
414 |
+
self.config = config
|
415 |
+
self.hidden_size = config.hidden_size
|
416 |
+
self.num_heads = config.num_attention_heads
|
417 |
+
self.head_dim = self.hidden_size // self.num_heads
|
418 |
+
self.num_key_value_heads = config.num_key_value_heads
|
419 |
+
self.num_key_value_groups = self.num_heads // self.num_key_value_heads
|
420 |
+
self.max_position_embeddings = config.max_position_embeddings
|
421 |
+
self.rope_theta = config.rope_theta
|
422 |
+
|
423 |
+
if (self.head_dim * self.num_heads) != self.hidden_size:
|
424 |
+
raise ValueError(
|
425 |
+
f"hidden_size must be divisible by num_heads (got `hidden_size`: {self.hidden_size}"
|
426 |
+
f" and `num_heads`: {self.num_heads})."
|
427 |
+
)
|
428 |
+
self.q_proj = nn.Linear(self.hidden_size, self.num_heads * self.head_dim, bias=config.attention_bias)
|
429 |
+
self.k_proj = nn.Linear(self.hidden_size, self.num_key_value_heads * self.head_dim, bias=config.attention_bias)
|
430 |
+
self.v_proj = nn.Linear(self.hidden_size, self.num_key_value_heads * self.head_dim, bias=config.attention_bias)
|
431 |
+
self.o_proj = nn.Linear(self.num_heads * self.head_dim, self.hidden_size, bias=config.attention_bias)
|
432 |
+
self._init_rope()
|
433 |
+
|
434 |
+
def _init_rope(self):
|
435 |
+
if self.config.rope_scaling is None:
|
436 |
+
self.rotary_emb = LlamaRotaryEmbedding(
|
437 |
+
self.head_dim,
|
438 |
+
max_position_embeddings=self.max_position_embeddings,
|
439 |
+
base=self.rope_theta,
|
440 |
+
)
|
441 |
+
else:
|
442 |
+
scaling_type = self.config.rope_scaling["type"]
|
443 |
+
scaling_factor = self.config.rope_scaling["factor"]
|
444 |
+
if scaling_type == "linear":
|
445 |
+
self.rotary_emb = LlamaLinearScalingRotaryEmbedding(
|
446 |
+
self.head_dim,
|
447 |
+
max_position_embeddings=self.max_position_embeddings,
|
448 |
+
scaling_factor=scaling_factor,
|
449 |
+
base=self.rope_theta,
|
450 |
+
)
|
451 |
+
elif scaling_type == "dynamic":
|
452 |
+
self.rotary_emb = LlamaDynamicNTKScalingRotaryEmbedding(
|
453 |
+
self.head_dim,
|
454 |
+
max_position_embeddings=self.max_position_embeddings,
|
455 |
+
scaling_factor=scaling_factor,
|
456 |
+
base=self.rope_theta,
|
457 |
+
)
|
458 |
+
elif scaling_type == "yarn":
|
459 |
+
original_max_position_embeddings = self.config.rope_scaling["original_max_position_embeddings"]
|
460 |
+
self.rotary_emb = LlamaYaRNScaledRotaryEmbedding(
|
461 |
+
self.head_dim,
|
462 |
+
max_position_embeddings=self.max_position_embeddings,
|
463 |
+
scale=scaling_factor,
|
464 |
+
original_max_position_embeddings=original_max_position_embeddings
|
465 |
+
)
|
466 |
+
elif scaling_type == "dynamic-yarn":
|
467 |
+
original_max_position_embeddings = self.config.rope_scaling["original_max_position_embeddings"]
|
468 |
+
self.rotary_emb = LlamaDynamicYaRNScaledRotaryEmbedding(
|
469 |
+
self.head_dim,
|
470 |
+
max_position_embeddings=self.max_position_embeddings,
|
471 |
+
original_max_position_embeddings=original_max_position_embeddings
|
472 |
+
)
|
473 |
+
else:
|
474 |
+
raise ValueError(f"Unknown RoPE scaling type {scaling_type}")
|
475 |
+
|
476 |
+
def _shape(self, tensor: torch.Tensor, seq_len: int, bsz: int):
|
477 |
+
return tensor.view(bsz, seq_len, self.num_heads, self.head_dim).transpose(1, 2).contiguous()
|
478 |
+
|
479 |
+
def forward(
|
480 |
+
self,
|
481 |
+
hidden_states: torch.Tensor,
|
482 |
+
attention_mask: Optional[torch.Tensor] = None,
|
483 |
+
position_ids: Optional[torch.LongTensor] = None,
|
484 |
+
past_key_value: Optional[Tuple[torch.Tensor]] = None,
|
485 |
+
output_attentions: bool = False,
|
486 |
+
use_cache: bool = False,
|
487 |
+
padding_mask: Optional[torch.LongTensor] = None,
|
488 |
+
) -> Tuple[torch.Tensor, Optional[torch.Tensor], Optional[Tuple[torch.Tensor]]]:
|
489 |
+
bsz, q_len, _ = hidden_states.size()
|
490 |
+
|
491 |
+
if self.config.pretraining_tp > 1:
|
492 |
+
key_value_slicing = (self.num_key_value_heads * self.head_dim) // self.config.pretraining_tp
|
493 |
+
query_slices = self.q_proj.weight.split(
|
494 |
+
(self.num_heads * self.head_dim) // self.config.pretraining_tp, dim=0
|
495 |
+
)
|
496 |
+
key_slices = self.k_proj.weight.split(key_value_slicing, dim=0)
|
497 |
+
value_slices = self.v_proj.weight.split(key_value_slicing, dim=0)
|
498 |
+
|
499 |
+
query_states = [F.linear(hidden_states, query_slices[i]) for i in range(self.config.pretraining_tp)]
|
500 |
+
query_states = torch.cat(query_states, dim=-1)
|
501 |
+
|
502 |
+
key_states = [F.linear(hidden_states, key_slices[i]) for i in range(self.config.pretraining_tp)]
|
503 |
+
key_states = torch.cat(key_states, dim=-1)
|
504 |
+
|
505 |
+
value_states = [F.linear(hidden_states, value_slices[i]) for i in range(self.config.pretraining_tp)]
|
506 |
+
value_states = torch.cat(value_states, dim=-1)
|
507 |
+
|
508 |
+
else:
|
509 |
+
query_states = self.q_proj(hidden_states)
|
510 |
+
key_states = self.k_proj(hidden_states)
|
511 |
+
value_states = self.v_proj(hidden_states)
|
512 |
+
|
513 |
+
query_states = query_states.view(bsz, q_len, self.num_heads, self.head_dim).transpose(1, 2)
|
514 |
+
key_states = key_states.view(bsz, q_len, self.num_key_value_heads, self.head_dim).transpose(1, 2)
|
515 |
+
value_states = value_states.view(bsz, q_len, self.num_key_value_heads, self.head_dim).transpose(1, 2)
|
516 |
+
|
517 |
+
kv_seq_len = key_states.shape[-2]
|
518 |
+
if past_key_value is not None:
|
519 |
+
kv_seq_len += past_key_value[0].shape[-2]
|
520 |
+
cos, sin = self.rotary_emb(value_states, seq_len=kv_seq_len)
|
521 |
+
query_states, key_states = apply_rotary_pos_emb(query_states, key_states, cos, sin, position_ids)
|
522 |
+
|
523 |
+
if past_key_value is not None:
|
524 |
+
# reuse k, v, self_attention
|
525 |
+
key_states = torch.cat([past_key_value[0], key_states], dim=2)
|
526 |
+
value_states = torch.cat([past_key_value[1], value_states], dim=2)
|
527 |
+
|
528 |
+
past_key_value = (key_states, value_states) if use_cache else None
|
529 |
+
|
530 |
+
key_states = repeat_kv(key_states, self.num_key_value_groups)
|
531 |
+
value_states = repeat_kv(value_states, self.num_key_value_groups)
|
532 |
+
|
533 |
+
attn_weights = torch.matmul(query_states, key_states.transpose(2, 3)) / math.sqrt(self.head_dim)
|
534 |
+
|
535 |
+
if attn_weights.size() != (bsz, self.num_heads, q_len, kv_seq_len):
|
536 |
+
raise ValueError(
|
537 |
+
f"Attention weights should be of size {(bsz, self.num_heads, q_len, kv_seq_len)}, but is"
|
538 |
+
f" {attn_weights.size()}"
|
539 |
+
)
|
540 |
+
|
541 |
+
if attention_mask is not None:
|
542 |
+
if attention_mask.size() != (bsz, 1, q_len, kv_seq_len):
|
543 |
+
raise ValueError(
|
544 |
+
f"Attention mask should be of size {(bsz, 1, q_len, kv_seq_len)}, but is {attention_mask.size()}"
|
545 |
+
)
|
546 |
+
attn_weights = attn_weights + attention_mask
|
547 |
+
|
548 |
+
# upcast attention to fp32
|
549 |
+
attn_weights = nn.functional.softmax(attn_weights, dim=-1, dtype=torch.float32).to(query_states.dtype)
|
550 |
+
attn_output = torch.matmul(attn_weights, value_states)
|
551 |
+
|
552 |
+
if attn_output.size() != (bsz, self.num_heads, q_len, self.head_dim):
|
553 |
+
raise ValueError(
|
554 |
+
f"`attn_output` should be of size {(bsz, self.num_heads, q_len, self.head_dim)}, but is"
|
555 |
+
f" {attn_output.size()}"
|
556 |
+
)
|
557 |
+
|
558 |
+
attn_output = attn_output.transpose(1, 2).contiguous()
|
559 |
+
|
560 |
+
attn_output = attn_output.reshape(bsz, q_len, self.hidden_size)
|
561 |
+
|
562 |
+
if self.config.pretraining_tp > 1:
|
563 |
+
attn_output = attn_output.split(self.hidden_size // self.config.pretraining_tp, dim=2)
|
564 |
+
o_proj_slices = self.o_proj.weight.split(self.hidden_size // self.config.pretraining_tp, dim=1)
|
565 |
+
attn_output = sum([F.linear(attn_output[i], o_proj_slices[i]) for i in range(self.config.pretraining_tp)])
|
566 |
+
else:
|
567 |
+
attn_output = self.o_proj(attn_output)
|
568 |
+
|
569 |
+
if not output_attentions:
|
570 |
+
attn_weights = None
|
571 |
+
|
572 |
+
return attn_output, attn_weights, past_key_value
|
573 |
+
|
574 |
+
|
575 |
+
class LlamaFlashAttention2(LlamaAttention):
|
576 |
+
"""
|
577 |
+
Llama flash attention module. This module inherits from `LlamaAttention` as the weights of the module stays
|
578 |
+
untouched. The only required change would be on the forward pass where it needs to correctly call the public API of
|
579 |
+
flash attention and deal with padding tokens in case the input contains any of them.
|
580 |
+
"""
|
581 |
+
|
582 |
+
def forward(
|
583 |
+
self,
|
584 |
+
hidden_states: torch.Tensor,
|
585 |
+
attention_mask: Optional[torch.Tensor] = None,
|
586 |
+
position_ids: Optional[torch.LongTensor] = None,
|
587 |
+
past_key_value: Optional[Tuple[torch.Tensor]] = None,
|
588 |
+
output_attentions: bool = False,
|
589 |
+
use_cache: bool = False,
|
590 |
+
padding_mask: Optional[torch.LongTensor] = None,
|
591 |
+
) -> Tuple[torch.Tensor, Optional[torch.Tensor], Optional[Tuple[torch.Tensor]]]:
|
592 |
+
# LlamaFlashAttention2 attention does not support output_attentions
|
593 |
+
output_attentions = False
|
594 |
+
|
595 |
+
bsz, q_len, _ = hidden_states.size()
|
596 |
+
|
597 |
+
query_states = self.q_proj(hidden_states)
|
598 |
+
key_states = self.k_proj(hidden_states)
|
599 |
+
value_states = self.v_proj(hidden_states)
|
600 |
+
|
601 |
+
# Flash attention requires the input to have the shape
|
602 |
+
# batch_size x seq_length x head_dime x hidden_dim
|
603 |
+
# therefore we just need to keep the original shape
|
604 |
+
query_states = query_states.view(bsz, q_len, self.num_heads, self.head_dim).transpose(1, 2)
|
605 |
+
key_states = key_states.view(bsz, q_len, self.num_key_value_heads, self.head_dim).transpose(1, 2)
|
606 |
+
value_states = value_states.view(bsz, q_len, self.num_key_value_heads, self.head_dim).transpose(1, 2)
|
607 |
+
|
608 |
+
kv_seq_len = key_states.shape[-2]
|
609 |
+
if past_key_value is not None:
|
610 |
+
kv_seq_len += past_key_value[0].shape[-2]
|
611 |
+
|
612 |
+
cos, sin = self.rotary_emb(value_states, seq_len=kv_seq_len)
|
613 |
+
|
614 |
+
query_states, key_states = apply_rotary_pos_emb(query_states, key_states, cos, sin, position_ids)
|
615 |
+
|
616 |
+
if past_key_value is not None:
|
617 |
+
# reuse k, v, self_attention
|
618 |
+
key_states = torch.cat([past_key_value[0], key_states], dim=2)
|
619 |
+
value_states = torch.cat([past_key_value[1], value_states], dim=2)
|
620 |
+
|
621 |
+
past_key_value = (key_states, value_states) if use_cache else None
|
622 |
+
|
623 |
+
query_states = query_states.transpose(1, 2)
|
624 |
+
key_states = key_states.transpose(1, 2)
|
625 |
+
value_states = value_states.transpose(1, 2)
|
626 |
+
|
627 |
+
# TODO: llama does not have dropout in the config??
|
628 |
+
# It is recommended to use dropout with FA according to the docs
|
629 |
+
# when training.
|
630 |
+
dropout_rate = 0.0 # if not self.training else self.attn_dropout
|
631 |
+
|
632 |
+
# In PEFT, usually we cast the layer norms in float32 for training stability reasons
|
633 |
+
# therefore the input hidden states gets silently casted in float32. Hence, we need
|
634 |
+
# cast them back in float16 just to be sure everything works as expected.
|
635 |
+
# This might slowdown training & inference so it is recommended to not cast the LayerNorms
|
636 |
+
# in fp32. (LlamaRMSNorm handles it correctly)
|
637 |
+
input_dtype = query_states.dtype
|
638 |
+
if input_dtype == torch.float32:
|
639 |
+
logger.warning_once(
|
640 |
+
"The input hidden states seems to be silently casted in float32, this might be related to"
|
641 |
+
" the fact you have upcasted embedding or layer norm layers in float32. We will cast back the input in"
|
642 |
+
" float16."
|
643 |
+
)
|
644 |
+
|
645 |
+
query_states = query_states.to(torch.float16)
|
646 |
+
key_states = key_states.to(torch.float16)
|
647 |
+
value_states = value_states.to(torch.float16)
|
648 |
+
|
649 |
+
attn_output = self._flash_attention_forward(
|
650 |
+
query_states, key_states, value_states, padding_mask, q_len, dropout=dropout_rate
|
651 |
+
)
|
652 |
+
|
653 |
+
attn_output = attn_output.reshape(bsz, q_len, self.hidden_size).contiguous()
|
654 |
+
attn_output = self.o_proj(attn_output)
|
655 |
+
|
656 |
+
if not output_attentions:
|
657 |
+
attn_weights = None
|
658 |
+
|
659 |
+
return attn_output, attn_weights, past_key_value
|
660 |
+
|
661 |
+
def _flash_attention_forward(
|
662 |
+
self, query_states, key_states, value_states, padding_mask, query_length, dropout=0.0, softmax_scale=None
|
663 |
+
):
|
664 |
+
"""
|
665 |
+
Calls the forward method of Flash Attention - if the input hidden states contain at least one padding token
|
666 |
+
first unpad the input, then computes the attention scores and pad the final attention scores.
|
667 |
+
|
668 |
+
Args:
|
669 |
+
query_states (`torch.Tensor`):
|
670 |
+
Input query states to be passed to Flash Attention API
|
671 |
+
key_states (`torch.Tensor`):
|
672 |
+
Input key states to be passed to Flash Attention API
|
673 |
+
value_states (`torch.Tensor`):
|
674 |
+
Input value states to be passed to Flash Attention API
|
675 |
+
padding_mask (`torch.Tensor`):
|
676 |
+
The padding mask - corresponds to a tensor of size `(batch_size, seq_len)` where 0 stands for the
|
677 |
+
position of padding tokens and 1 for the position of non-padding tokens.
|
678 |
+
dropout (`int`, *optional*):
|
679 |
+
Attention dropout
|
680 |
+
softmax_scale (`float`, *optional*):
|
681 |
+
The scaling of QK^T before applying softmax. Default to 1 / sqrt(head_dim)
|
682 |
+
"""
|
683 |
+
# Contains at least one padding token in the sequence
|
684 |
+
if padding_mask is not None:
|
685 |
+
batch_size = query_states.shape[0]
|
686 |
+
query_states, key_states, value_states, indices_q, cu_seq_lens, max_seq_lens = self._upad_input(
|
687 |
+
query_states, key_states, value_states, padding_mask, query_length
|
688 |
+
)
|
689 |
+
|
690 |
+
cu_seqlens_q, cu_seqlens_k = cu_seq_lens
|
691 |
+
max_seqlen_in_batch_q, max_seqlen_in_batch_k = max_seq_lens
|
692 |
+
|
693 |
+
attn_output_unpad = flash_attn_varlen_func(
|
694 |
+
query_states,
|
695 |
+
key_states,
|
696 |
+
value_states,
|
697 |
+
cu_seqlens_q=cu_seqlens_q,
|
698 |
+
cu_seqlens_k=cu_seqlens_k,
|
699 |
+
max_seqlen_q=max_seqlen_in_batch_q,
|
700 |
+
max_seqlen_k=max_seqlen_in_batch_k,
|
701 |
+
dropout_p=dropout,
|
702 |
+
softmax_scale=softmax_scale,
|
703 |
+
causal=True,
|
704 |
+
)
|
705 |
+
|
706 |
+
attn_output = pad_input(attn_output_unpad, indices_q, batch_size, query_length)
|
707 |
+
else:
|
708 |
+
attn_output = flash_attn_func(
|
709 |
+
query_states, key_states, value_states, dropout, softmax_scale=softmax_scale, causal=True
|
710 |
+
)
|
711 |
+
|
712 |
+
return attn_output
|
713 |
+
|
714 |
+
def _upad_input(self, query_layer, key_layer, value_layer, padding_mask, query_length):
|
715 |
+
indices_k, cu_seqlens_k, max_seqlen_in_batch_k = _get_unpad_data(padding_mask)
|
716 |
+
batch_size, kv_seq_len, num_key_value_heads, head_dim = key_layer.shape
|
717 |
+
|
718 |
+
key_layer = index_first_axis(
|
719 |
+
key_layer.reshape(batch_size * kv_seq_len, num_key_value_heads, head_dim), indices_k
|
720 |
+
)
|
721 |
+
value_layer = index_first_axis(
|
722 |
+
value_layer.reshape(batch_size * kv_seq_len, num_key_value_heads, head_dim), indices_k
|
723 |
+
)
|
724 |
+
if query_length == kv_seq_len:
|
725 |
+
query_layer = index_first_axis(
|
726 |
+
query_layer.reshape(batch_size * kv_seq_len, self.num_heads, head_dim), indices_k
|
727 |
+
)
|
728 |
+
cu_seqlens_q = cu_seqlens_k
|
729 |
+
max_seqlen_in_batch_q = max_seqlen_in_batch_k
|
730 |
+
indices_q = indices_k
|
731 |
+
elif query_length == 1:
|
732 |
+
max_seqlen_in_batch_q = 1
|
733 |
+
cu_seqlens_q = torch.arange(
|
734 |
+
batch_size + 1, dtype=torch.int32, device=query_layer.device
|
735 |
+
) # There is a memcpy here, that is very bad.
|
736 |
+
indices_q = cu_seqlens_q[:-1]
|
737 |
+
query_layer = query_layer.squeeze(1)
|
738 |
+
else:
|
739 |
+
# The -q_len: slice assumes left padding.
|
740 |
+
padding_mask = padding_mask[:, -query_length:]
|
741 |
+
query_layer, indices_q, cu_seqlens_q, max_seqlen_in_batch_q = unpad_input(query_layer, padding_mask)
|
742 |
+
|
743 |
+
return (
|
744 |
+
query_layer,
|
745 |
+
key_layer,
|
746 |
+
value_layer,
|
747 |
+
indices_q,
|
748 |
+
(cu_seqlens_q, cu_seqlens_k),
|
749 |
+
(max_seqlen_in_batch_q, max_seqlen_in_batch_k),
|
750 |
+
)
|
751 |
+
|
752 |
+
|
753 |
+
class LlamaDecoderLayer(nn.Module):
|
754 |
+
def __init__(self, config: LlamaConfig):
|
755 |
+
super().__init__()
|
756 |
+
self.hidden_size = config.hidden_size
|
757 |
+
self.self_attn = (
|
758 |
+
LlamaAttention(config=config)
|
759 |
+
if not getattr(config, "_flash_attn_2_enabled", False)
|
760 |
+
else LlamaFlashAttention2(config=config)
|
761 |
+
)
|
762 |
+
self.mlp = LlamaMLP(config)
|
763 |
+
self.input_layernorm = LlamaRMSNorm(config.hidden_size, eps=config.rms_norm_eps)
|
764 |
+
self.post_attention_layernorm = LlamaRMSNorm(config.hidden_size, eps=config.rms_norm_eps)
|
765 |
+
|
766 |
+
def forward(
|
767 |
+
self,
|
768 |
+
hidden_states: torch.Tensor,
|
769 |
+
attention_mask: Optional[torch.Tensor] = None,
|
770 |
+
position_ids: Optional[torch.LongTensor] = None,
|
771 |
+
past_key_value: Optional[Tuple[torch.Tensor]] = None,
|
772 |
+
output_attentions: Optional[bool] = False,
|
773 |
+
use_cache: Optional[bool] = False,
|
774 |
+
padding_mask: Optional[torch.LongTensor] = None,
|
775 |
+
) -> Tuple[torch.FloatTensor, Optional[Tuple[torch.FloatTensor, torch.FloatTensor]]]:
|
776 |
+
"""
|
777 |
+
Args:
|
778 |
+
hidden_states (`torch.FloatTensor`): input to the layer of shape `(batch, seq_len, embed_dim)`
|
779 |
+
attention_mask (`torch.FloatTensor`, *optional*): attention mask of size
|
780 |
+
`(batch, 1, tgt_len, src_len)` where padding elements are indicated by very large negative values.
|
781 |
+
output_attentions (`bool`, *optional*):
|
782 |
+
Whether or not to return the attentions tensors of all attention layers. See `attentions` under
|
783 |
+
returned tensors for more detail.
|
784 |
+
use_cache (`bool`, *optional*):
|
785 |
+
If set to `True`, `past_key_values` key value states are returned and can be used to speed up decoding
|
786 |
+
(see `past_key_values`).
|
787 |
+
past_key_value (`Tuple(torch.FloatTensor)`, *optional*): cached past key and value projection states
|
788 |
+
"""
|
789 |
+
|
790 |
+
residual = hidden_states
|
791 |
+
|
792 |
+
hidden_states = self.input_layernorm(hidden_states)
|
793 |
+
|
794 |
+
# Self Attention
|
795 |
+
hidden_states, self_attn_weights, present_key_value = self.self_attn(
|
796 |
+
hidden_states=hidden_states,
|
797 |
+
attention_mask=attention_mask,
|
798 |
+
position_ids=position_ids,
|
799 |
+
past_key_value=past_key_value,
|
800 |
+
output_attentions=output_attentions,
|
801 |
+
use_cache=use_cache,
|
802 |
+
padding_mask=padding_mask,
|
803 |
+
)
|
804 |
+
hidden_states = residual + hidden_states
|
805 |
+
|
806 |
+
# Fully Connected
|
807 |
+
residual = hidden_states
|
808 |
+
hidden_states = self.post_attention_layernorm(hidden_states)
|
809 |
+
hidden_states = self.mlp(hidden_states)
|
810 |
+
hidden_states = residual + hidden_states
|
811 |
+
|
812 |
+
outputs = (hidden_states,)
|
813 |
+
|
814 |
+
if output_attentions:
|
815 |
+
outputs += (self_attn_weights,)
|
816 |
+
|
817 |
+
if use_cache:
|
818 |
+
outputs += (present_key_value,)
|
819 |
+
|
820 |
+
return outputs
|
821 |
+
|
822 |
+
|
823 |
+
LLAMA_START_DOCSTRING = r"""
|
824 |
+
This model inherits from [`PreTrainedModel`]. Check the superclass documentation for the generic methods the
|
825 |
+
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
|
826 |
+
etc.)
|
827 |
+
|
828 |
+
This model is also a PyTorch [torch.nn.Module](https://pytorch.org/docs/stable/nn.html#torch.nn.Module) subclass.
|
829 |
+
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
|
830 |
+
and behavior.
|
831 |
+
|
832 |
+
Parameters:
|
833 |
+
config ([`LlamaConfig`]):
|
834 |
+
Model configuration class with all the parameters of the model. Initializing with a config file does not
|
835 |
+
load the weights associated with the model, only the configuration. Check out the
|
836 |
+
[`~PreTrainedModel.from_pretrained`] method to load the model weights.
|
837 |
+
"""
|
838 |
+
|
839 |
+
|
840 |
+
@add_start_docstrings(
|
841 |
+
"The bare LLaMA Model outputting raw hidden-states without any specific head on top.",
|
842 |
+
LLAMA_START_DOCSTRING,
|
843 |
+
)
|
844 |
+
class LlamaPreTrainedModel(PreTrainedModel):
|
845 |
+
config_class = LlamaConfig
|
846 |
+
base_model_prefix = "model"
|
847 |
+
supports_gradient_checkpointing = True
|
848 |
+
_no_split_modules = ["LlamaDecoderLayer"]
|
849 |
+
_skip_keys_device_placement = "past_key_values"
|
850 |
+
_supports_flash_attn_2 = True
|
851 |
+
|
852 |
+
def _init_weights(self, module):
|
853 |
+
std = self.config.initializer_range
|
854 |
+
if isinstance(module, nn.Linear):
|
855 |
+
module.weight.data.normal_(mean=0.0, std=std)
|
856 |
+
if module.bias is not None:
|
857 |
+
module.bias.data.zero_()
|
858 |
+
elif isinstance(module, nn.Embedding):
|
859 |
+
module.weight.data.normal_(mean=0.0, std=std)
|
860 |
+
if module.padding_idx is not None:
|
861 |
+
module.weight.data[module.padding_idx].zero_()
|
862 |
+
|
863 |
+
|
864 |
+
LLAMA_INPUTS_DOCSTRING = r"""
|
865 |
+
Args:
|
866 |
+
input_ids (`torch.LongTensor` of shape `(batch_size, sequence_length)`):
|
867 |
+
Indices of input sequence tokens in the vocabulary. Padding will be ignored by default should you provide
|
868 |
+
it.
|
869 |
+
|
870 |
+
Indices can be obtained using [`AutoTokenizer`]. See [`PreTrainedTokenizer.encode`] and
|
871 |
+
[`PreTrainedTokenizer.__call__`] for details.
|
872 |
+
|
873 |
+
[What are input IDs?](../glossary#input-ids)
|
874 |
+
attention_mask (`torch.Tensor` of shape `(batch_size, sequence_length)`, *optional*):
|
875 |
+
Mask to avoid performing attention on padding token indices. Mask values selected in `[0, 1]`:
|
876 |
+
|
877 |
+
- 1 for tokens that are **not masked**,
|
878 |
+
- 0 for tokens that are **masked**.
|
879 |
+
|
880 |
+
[What are attention masks?](../glossary#attention-mask)
|
881 |
+
|
882 |
+
Indices can be obtained using [`AutoTokenizer`]. See [`PreTrainedTokenizer.encode`] and
|
883 |
+
[`PreTrainedTokenizer.__call__`] for details.
|
884 |
+
|
885 |
+
If `past_key_values` is used, optionally only the last `input_ids` have to be input (see
|
886 |
+
`past_key_values`).
|
887 |
+
|
888 |
+
If you want to change padding behavior, you should read [`modeling_opt._prepare_decoder_attention_mask`]
|
889 |
+
and modify to your needs. See diagram 1 in [the paper](https://arxiv.org/abs/1910.13461) for more
|
890 |
+
information on the default strategy.
|
891 |
+
|
892 |
+
- 1 indicates the head is **not masked**,
|
893 |
+
- 0 indicates the head is **masked**.
|
894 |
+
position_ids (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *optional*):
|
895 |
+
Indices of positions of each input sequence tokens in the position embeddings. Selected in the range `[0,
|
896 |
+
config.n_positions - 1]`.
|
897 |
+
|
898 |
+
[What are position IDs?](../glossary#position-ids)
|
899 |
+
past_key_values (`tuple(tuple(torch.FloatTensor))`, *optional*, returned when `use_cache=True` is passed or when `config.use_cache=True`):
|
900 |
+
Tuple of `tuple(torch.FloatTensor)` of length `config.n_layers`, with each tuple having 2 tensors of shape
|
901 |
+
`(batch_size, num_heads, sequence_length, embed_size_per_head)`) and 2 additional tensors of shape
|
902 |
+
`(batch_size, num_heads, encoder_sequence_length, embed_size_per_head)`.
|
903 |
+
|
904 |
+
Contains pre-computed hidden-states (key and values in the self-attention blocks and in the cross-attention
|
905 |
+
blocks) that can be used (see `past_key_values` input) to speed up sequential decoding.
|
906 |
+
|
907 |
+
If `past_key_values` are used, the user can optionally input only the last `input_ids` (those that don't
|
908 |
+
have their past key value states given to this model) of shape `(batch_size, 1)` instead of all `input_ids`
|
909 |
+
of shape `(batch_size, sequence_length)`.
|
910 |
+
inputs_embeds (`torch.FloatTensor` of shape `(batch_size, sequence_length, hidden_size)`, *optional*):
|
911 |
+
Optionally, instead of passing `input_ids` you can choose to directly pass an embedded representation. This
|
912 |
+
is useful if you want more control over how to convert `input_ids` indices into associated vectors than the
|
913 |
+
model's internal embedding lookup matrix.
|
914 |
+
use_cache (`bool`, *optional*):
|
915 |
+
If set to `True`, `past_key_values` key value states are returned and can be used to speed up decoding (see
|
916 |
+
`past_key_values`).
|
917 |
+
output_attentions (`bool`, *optional*):
|
918 |
+
Whether or not to return the attentions tensors of all attention layers. See `attentions` under returned
|
919 |
+
tensors for more detail.
|
920 |
+
output_hidden_states (`bool`, *optional*):
|
921 |
+
Whether or not to return the hidden states of all layers. See `hidden_states` under returned tensors for
|
922 |
+
more detail.
|
923 |
+
return_dict (`bool`, *optional*):
|
924 |
+
Whether or not to return a [`~utils.ModelOutput`] instead of a plain tuple.
|
925 |
+
"""
|
926 |
+
|
927 |
+
|
928 |
+
@add_start_docstrings(
|
929 |
+
"The bare LLaMA Model outputting raw hidden-states without any specific head on top.",
|
930 |
+
LLAMA_START_DOCSTRING,
|
931 |
+
)
|
932 |
+
class LlamaModel(LlamaPreTrainedModel):
|
933 |
+
"""
|
934 |
+
Transformer decoder consisting of *config.num_hidden_layers* layers. Each layer is a [`LlamaDecoderLayer`]
|
935 |
+
|
936 |
+
Args:
|
937 |
+
config: LlamaConfig
|
938 |
+
"""
|
939 |
+
|
940 |
+
def __init__(self, config: LlamaConfig):
|
941 |
+
super().__init__(config)
|
942 |
+
self.padding_idx = config.pad_token_id
|
943 |
+
self.vocab_size = config.vocab_size
|
944 |
+
|
945 |
+
self.embed_tokens = nn.Embedding(config.vocab_size, config.hidden_size, self.padding_idx)
|
946 |
+
self.layers = nn.ModuleList([LlamaDecoderLayer(config) for _ in range(config.num_hidden_layers)])
|
947 |
+
self.norm = LlamaRMSNorm(config.hidden_size, eps=config.rms_norm_eps)
|
948 |
+
|
949 |
+
self.gradient_checkpointing = False
|
950 |
+
# Initialize weights and apply final processing
|
951 |
+
self.post_init()
|
952 |
+
|
953 |
+
def get_input_embeddings(self):
|
954 |
+
return self.embed_tokens
|
955 |
+
|
956 |
+
def set_input_embeddings(self, value):
|
957 |
+
self.embed_tokens = value
|
958 |
+
|
959 |
+
# Copied from transformers.models.bart.modeling_bart.BartDecoder._prepare_decoder_attention_mask
|
960 |
+
def _prepare_decoder_attention_mask(self, attention_mask, input_shape, inputs_embeds, past_key_values_length):
|
961 |
+
# create causal mask
|
962 |
+
# [bsz, seq_len] -> [bsz, 1, tgt_seq_len, src_seq_len]
|
963 |
+
combined_attention_mask = None
|
964 |
+
if input_shape[-1] > 1:
|
965 |
+
combined_attention_mask = _make_causal_mask(
|
966 |
+
input_shape,
|
967 |
+
inputs_embeds.dtype,
|
968 |
+
device=inputs_embeds.device,
|
969 |
+
past_key_values_length=past_key_values_length,
|
970 |
+
)
|
971 |
+
|
972 |
+
if attention_mask is not None:
|
973 |
+
# [bsz, seq_len] -> [bsz, 1, tgt_seq_len, src_seq_len]
|
974 |
+
expanded_attn_mask = _expand_mask(attention_mask, inputs_embeds.dtype, tgt_len=input_shape[-1]).to(
|
975 |
+
inputs_embeds.device
|
976 |
+
)
|
977 |
+
combined_attention_mask = (
|
978 |
+
expanded_attn_mask if combined_attention_mask is None else expanded_attn_mask + combined_attention_mask
|
979 |
+
)
|
980 |
+
|
981 |
+
return combined_attention_mask
|
982 |
+
|
983 |
+
@add_start_docstrings_to_model_forward(LLAMA_INPUTS_DOCSTRING)
|
984 |
+
def forward(
|
985 |
+
self,
|
986 |
+
input_ids: torch.LongTensor = None,
|
987 |
+
attention_mask: Optional[torch.Tensor] = None,
|
988 |
+
position_ids: Optional[torch.LongTensor] = None,
|
989 |
+
past_key_values: Optional[List[torch.FloatTensor]] = None,
|
990 |
+
inputs_embeds: Optional[torch.FloatTensor] = None,
|
991 |
+
use_cache: Optional[bool] = None,
|
992 |
+
output_attentions: Optional[bool] = None,
|
993 |
+
output_hidden_states: Optional[bool] = None,
|
994 |
+
return_dict: Optional[bool] = None,
|
995 |
+
) -> Union[Tuple, BaseModelOutputWithPast]:
|
996 |
+
output_attentions = output_attentions if output_attentions is not None else self.config.output_attentions
|
997 |
+
output_hidden_states = (
|
998 |
+
output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
|
999 |
+
)
|
1000 |
+
use_cache = use_cache if use_cache is not None else self.config.use_cache
|
1001 |
+
|
1002 |
+
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
1003 |
+
|
1004 |
+
# retrieve input_ids and inputs_embeds
|
1005 |
+
if input_ids is not None and inputs_embeds is not None:
|
1006 |
+
raise ValueError("You cannot specify both input_ids and inputs_embeds at the same time")
|
1007 |
+
elif input_ids is not None:
|
1008 |
+
batch_size, seq_length = input_ids.shape
|
1009 |
+
elif inputs_embeds is not None:
|
1010 |
+
batch_size, seq_length, _ = inputs_embeds.shape
|
1011 |
+
else:
|
1012 |
+
raise ValueError("You have to specify either input_ids or inputs_embeds")
|
1013 |
+
|
1014 |
+
seq_length_with_past = seq_length
|
1015 |
+
past_key_values_length = 0
|
1016 |
+
|
1017 |
+
if past_key_values is not None:
|
1018 |
+
past_key_values_length = past_key_values[0][0].shape[2]
|
1019 |
+
seq_length_with_past = seq_length_with_past + past_key_values_length
|
1020 |
+
|
1021 |
+
if position_ids is None:
|
1022 |
+
device = input_ids.device if input_ids is not None else inputs_embeds.device
|
1023 |
+
position_ids = torch.arange(
|
1024 |
+
past_key_values_length, seq_length + past_key_values_length, dtype=torch.long, device=device
|
1025 |
+
)
|
1026 |
+
position_ids = position_ids.unsqueeze(0)
|
1027 |
+
|
1028 |
+
if inputs_embeds is None:
|
1029 |
+
inputs_embeds = self.embed_tokens(input_ids)
|
1030 |
+
# embed positions
|
1031 |
+
if attention_mask is None:
|
1032 |
+
attention_mask = torch.ones(
|
1033 |
+
(batch_size, seq_length_with_past), dtype=torch.bool, device=inputs_embeds.device
|
1034 |
+
)
|
1035 |
+
padding_mask = None
|
1036 |
+
else:
|
1037 |
+
if 0 in attention_mask:
|
1038 |
+
padding_mask = attention_mask
|
1039 |
+
else:
|
1040 |
+
padding_mask = None
|
1041 |
+
|
1042 |
+
attention_mask = self._prepare_decoder_attention_mask(
|
1043 |
+
attention_mask, (batch_size, seq_length), inputs_embeds, past_key_values_length
|
1044 |
+
)
|
1045 |
+
|
1046 |
+
hidden_states = inputs_embeds
|
1047 |
+
|
1048 |
+
if self.gradient_checkpointing and self.training:
|
1049 |
+
if use_cache:
|
1050 |
+
logger.warning_once(
|
1051 |
+
"`use_cache=True` is incompatible with gradient checkpointing. Setting `use_cache=False`..."
|
1052 |
+
)
|
1053 |
+
use_cache = False
|
1054 |
+
|
1055 |
+
# decoder layers
|
1056 |
+
all_hidden_states = () if output_hidden_states else None
|
1057 |
+
all_self_attns = () if output_attentions else None
|
1058 |
+
next_decoder_cache = () if use_cache else None
|
1059 |
+
|
1060 |
+
for idx, decoder_layer in enumerate(self.layers):
|
1061 |
+
if output_hidden_states:
|
1062 |
+
all_hidden_states += (hidden_states,)
|
1063 |
+
|
1064 |
+
past_key_value = past_key_values[idx] if past_key_values is not None else None
|
1065 |
+
|
1066 |
+
if self.gradient_checkpointing and self.training:
|
1067 |
+
|
1068 |
+
def create_custom_forward(module):
|
1069 |
+
def custom_forward(*inputs):
|
1070 |
+
# None for past_key_value
|
1071 |
+
return module(*inputs, past_key_value, output_attentions, padding_mask=padding_mask)
|
1072 |
+
|
1073 |
+
return custom_forward
|
1074 |
+
|
1075 |
+
layer_outputs = torch.utils.checkpoint.checkpoint(
|
1076 |
+
create_custom_forward(decoder_layer), hidden_states, attention_mask, position_ids
|
1077 |
+
)
|
1078 |
+
else:
|
1079 |
+
layer_outputs = decoder_layer(
|
1080 |
+
hidden_states,
|
1081 |
+
attention_mask=attention_mask,
|
1082 |
+
position_ids=position_ids,
|
1083 |
+
past_key_value=past_key_value,
|
1084 |
+
output_attentions=output_attentions,
|
1085 |
+
use_cache=use_cache,
|
1086 |
+
padding_mask=padding_mask,
|
1087 |
+
)
|
1088 |
+
|
1089 |
+
hidden_states = layer_outputs[0]
|
1090 |
+
|
1091 |
+
if use_cache:
|
1092 |
+
next_decoder_cache += (layer_outputs[2 if output_attentions else 1],)
|
1093 |
+
|
1094 |
+
if output_attentions:
|
1095 |
+
all_self_attns += (layer_outputs[1],)
|
1096 |
+
|
1097 |
+
hidden_states = self.norm(hidden_states)
|
1098 |
+
|
1099 |
+
# add hidden states from the last decoder layer
|
1100 |
+
if output_hidden_states:
|
1101 |
+
all_hidden_states += (hidden_states,)
|
1102 |
+
|
1103 |
+
next_cache = next_decoder_cache if use_cache else None
|
1104 |
+
if not return_dict:
|
1105 |
+
return tuple(v for v in [hidden_states, next_cache, all_hidden_states, all_self_attns] if v is not None)
|
1106 |
+
return BaseModelOutputWithPast(
|
1107 |
+
last_hidden_state=hidden_states,
|
1108 |
+
past_key_values=next_cache,
|
1109 |
+
hidden_states=all_hidden_states,
|
1110 |
+
attentions=all_self_attns,
|
1111 |
+
)
|
1112 |
+
|
1113 |
+
|
1114 |
+
class LlamaForCausalLM(LlamaPreTrainedModel):
|
1115 |
+
_tied_weights_keys = ["lm_head.weight"]
|
1116 |
+
|
1117 |
+
def __init__(self, config):
|
1118 |
+
super().__init__(config)
|
1119 |
+
self.model = LlamaModel(config)
|
1120 |
+
self.vocab_size = config.vocab_size
|
1121 |
+
self.lm_head = nn.Linear(config.hidden_size, config.vocab_size, bias=False)
|
1122 |
+
|
1123 |
+
# Initialize weights and apply final processing
|
1124 |
+
self.post_init()
|
1125 |
+
|
1126 |
+
def get_input_embeddings(self):
|
1127 |
+
return self.model.embed_tokens
|
1128 |
+
|
1129 |
+
def set_input_embeddings(self, value):
|
1130 |
+
self.model.embed_tokens = value
|
1131 |
+
|
1132 |
+
def get_output_embeddings(self):
|
1133 |
+
return self.lm_head
|
1134 |
+
|
1135 |
+
def set_output_embeddings(self, new_embeddings):
|
1136 |
+
self.lm_head = new_embeddings
|
1137 |
+
|
1138 |
+
def set_decoder(self, decoder):
|
1139 |
+
self.model = decoder
|
1140 |
+
|
1141 |
+
def get_decoder(self):
|
1142 |
+
return self.model
|
1143 |
+
|
1144 |
+
@add_start_docstrings_to_model_forward(LLAMA_INPUTS_DOCSTRING)
|
1145 |
+
@replace_return_docstrings(output_type=CausalLMOutputWithPast, config_class=_CONFIG_FOR_DOC)
|
1146 |
+
def forward(
|
1147 |
+
self,
|
1148 |
+
input_ids: torch.LongTensor = None,
|
1149 |
+
attention_mask: Optional[torch.Tensor] = None,
|
1150 |
+
position_ids: Optional[torch.LongTensor] = None,
|
1151 |
+
past_key_values: Optional[List[torch.FloatTensor]] = None,
|
1152 |
+
inputs_embeds: Optional[torch.FloatTensor] = None,
|
1153 |
+
labels: Optional[torch.LongTensor] = None,
|
1154 |
+
use_cache: Optional[bool] = None,
|
1155 |
+
output_attentions: Optional[bool] = None,
|
1156 |
+
output_hidden_states: Optional[bool] = None,
|
1157 |
+
return_dict: Optional[bool] = None,
|
1158 |
+
) -> Union[Tuple, CausalLMOutputWithPast]:
|
1159 |
+
r"""
|
1160 |
+
Args:
|
1161 |
+
labels (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *optional*):
|
1162 |
+
Labels for computing the masked language modeling loss. Indices should either be in `[0, ...,
|
1163 |
+
config.vocab_size]` or -100 (see `input_ids` docstring). Tokens with indices set to `-100` are ignored
|
1164 |
+
(masked), the loss is only computed for the tokens with labels in `[0, ..., config.vocab_size]`.
|
1165 |
+
|
1166 |
+
Returns:
|
1167 |
+
|
1168 |
+
Example:
|
1169 |
+
|
1170 |
+
```python
|
1171 |
+
>>> from transformers import AutoTokenizer, LlamaForCausalLM
|
1172 |
+
|
1173 |
+
>>> model = LlamaForCausalLM.from_pretrained(PATH_TO_CONVERTED_WEIGHTS)
|
1174 |
+
>>> tokenizer = AutoTokenizer.from_pretrained(PATH_TO_CONVERTED_TOKENIZER)
|
1175 |
+
|
1176 |
+
>>> prompt = "Hey, are you conscious? Can you talk to me?"
|
1177 |
+
>>> inputs = tokenizer(prompt, return_tensors="pt")
|
1178 |
+
|
1179 |
+
>>> # Generate
|
1180 |
+
>>> generate_ids = model.generate(inputs.input_ids, max_length=30)
|
1181 |
+
>>> tokenizer.batch_decode(generate_ids, skip_special_tokens=True, clean_up_tokenization_spaces=False)[0]
|
1182 |
+
"Hey, are you conscious? Can you talk to me?\nI'm not conscious, but I can talk to you."
|
1183 |
+
```"""
|
1184 |
+
|
1185 |
+
output_attentions = output_attentions if output_attentions is not None else self.config.output_attentions
|
1186 |
+
output_hidden_states = (
|
1187 |
+
output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
|
1188 |
+
)
|
1189 |
+
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
1190 |
+
|
1191 |
+
# decoder outputs consists of (dec_features, layer_state, dec_hidden, dec_attn)
|
1192 |
+
outputs = self.model(
|
1193 |
+
input_ids=input_ids,
|
1194 |
+
attention_mask=attention_mask,
|
1195 |
+
position_ids=position_ids,
|
1196 |
+
past_key_values=past_key_values,
|
1197 |
+
inputs_embeds=inputs_embeds,
|
1198 |
+
use_cache=use_cache,
|
1199 |
+
output_attentions=output_attentions,
|
1200 |
+
output_hidden_states=output_hidden_states,
|
1201 |
+
return_dict=return_dict,
|
1202 |
+
)
|
1203 |
+
|
1204 |
+
hidden_states = outputs[0]
|
1205 |
+
if self.config.pretraining_tp > 1:
|
1206 |
+
lm_head_slices = self.lm_head.weight.split(self.vocab_size // self.config.pretraining_tp, dim=0)
|
1207 |
+
logits = [F.linear(hidden_states, lm_head_slices[i]) for i in range(self.config.pretraining_tp)]
|
1208 |
+
logits = torch.cat(logits, dim=-1)
|
1209 |
+
else:
|
1210 |
+
logits = self.lm_head(hidden_states)
|
1211 |
+
logits = logits.float()
|
1212 |
+
|
1213 |
+
loss = None
|
1214 |
+
if labels is not None:
|
1215 |
+
# Shift so that tokens < n predict n
|
1216 |
+
shift_logits = logits[..., :-1, :].contiguous()
|
1217 |
+
shift_labels = labels[..., 1:].contiguous()
|
1218 |
+
# Flatten the tokens
|
1219 |
+
loss_fct = CrossEntropyLoss()
|
1220 |
+
shift_logits = shift_logits.view(-1, self.config.vocab_size)
|
1221 |
+
shift_labels = shift_labels.view(-1)
|
1222 |
+
# Enable model parallelism
|
1223 |
+
shift_labels = shift_labels.to(shift_logits.device)
|
1224 |
+
loss = loss_fct(shift_logits, shift_labels)
|
1225 |
+
|
1226 |
+
if not return_dict:
|
1227 |
+
output = (logits,) + outputs[1:]
|
1228 |
+
return (loss,) + output if loss is not None else output
|
1229 |
+
|
1230 |
+
return CausalLMOutputWithPast(
|
1231 |
+
loss=loss,
|
1232 |
+
logits=logits,
|
1233 |
+
past_key_values=outputs.past_key_values,
|
1234 |
+
hidden_states=outputs.hidden_states,
|
1235 |
+
attentions=outputs.attentions,
|
1236 |
+
)
|
1237 |
+
|
1238 |
+
def prepare_inputs_for_generation(
|
1239 |
+
self, input_ids, past_key_values=None, attention_mask=None, inputs_embeds=None, **kwargs
|
1240 |
+
):
|
1241 |
+
if past_key_values is not None:
|
1242 |
+
past_length = past_key_values[0][0].shape[2]
|
1243 |
+
|
1244 |
+
# Some generation methods already pass only the last input ID
|
1245 |
+
if input_ids.shape[1] > past_length:
|
1246 |
+
remove_prefix_length = past_length
|
1247 |
+
else:
|
1248 |
+
# Default to old behavior: keep only final ID
|
1249 |
+
remove_prefix_length = input_ids.shape[1] - 1
|
1250 |
+
|
1251 |
+
input_ids = input_ids[:, remove_prefix_length:]
|
1252 |
+
|
1253 |
+
position_ids = kwargs.get("position_ids", None)
|
1254 |
+
if attention_mask is not None and position_ids is None:
|
1255 |
+
# create position_ids on the fly for batch generation
|
1256 |
+
position_ids = attention_mask.long().cumsum(-1) - 1
|
1257 |
+
position_ids.masked_fill_(attention_mask == 0, 1)
|
1258 |
+
if past_key_values:
|
1259 |
+
position_ids = position_ids[:, -input_ids.shape[1] :]
|
1260 |
+
|
1261 |
+
# if `inputs_embeds` are passed, we only want to use them in the 1st generation step
|
1262 |
+
if inputs_embeds is not None and past_key_values is None:
|
1263 |
+
model_inputs = {"inputs_embeds": inputs_embeds}
|
1264 |
+
else:
|
1265 |
+
model_inputs = {"input_ids": input_ids}
|
1266 |
+
|
1267 |
+
model_inputs.update(
|
1268 |
+
{
|
1269 |
+
"position_ids": position_ids,
|
1270 |
+
"past_key_values": past_key_values,
|
1271 |
+
"use_cache": kwargs.get("use_cache"),
|
1272 |
+
"attention_mask": attention_mask,
|
1273 |
+
}
|
1274 |
+
)
|
1275 |
+
return model_inputs
|
1276 |
+
|
1277 |
+
@staticmethod
|
1278 |
+
def _reorder_cache(past_key_values, beam_idx):
|
1279 |
+
reordered_past = ()
|
1280 |
+
for layer_past in past_key_values:
|
1281 |
+
reordered_past += (
|
1282 |
+
tuple(past_state.index_select(0, beam_idx.to(past_state.device)) for past_state in layer_past),
|
1283 |
+
)
|
1284 |
+
return reordered_past
|
1285 |
+
|
1286 |
+
|
1287 |
+
@add_start_docstrings(
|
1288 |
+
"""
|
1289 |
+
The LLaMa Model transformer with a sequence classification head on top (linear layer).
|
1290 |
+
|
1291 |
+
[`LlamaForSequenceClassification`] uses the last token in order to do the classification, as other causal models
|
1292 |
+
(e.g. GPT-2) do.
|
1293 |
+
|
1294 |
+
Since it does classification on the last token, it requires to know the position of the last token. If a
|
1295 |
+
`pad_token_id` is defined in the configuration, it finds the last token that is not a padding token in each row. If
|
1296 |
+
no `pad_token_id` is defined, it simply takes the last value in each row of the batch. Since it cannot guess the
|
1297 |
+
padding tokens when `inputs_embeds` are passed instead of `input_ids`, it does the same (take the last value in
|
1298 |
+
each row of the batch).
|
1299 |
+
""",
|
1300 |
+
LLAMA_START_DOCSTRING,
|
1301 |
+
)
|
1302 |
+
class LlamaForSequenceClassification(LlamaPreTrainedModel):
|
1303 |
+
def __init__(self, config):
|
1304 |
+
super().__init__(config)
|
1305 |
+
self.num_labels = config.num_labels
|
1306 |
+
self.model = LlamaModel(config)
|
1307 |
+
self.score = nn.Linear(config.hidden_size, self.num_labels, bias=False)
|
1308 |
+
|
1309 |
+
# Initialize weights and apply final processing
|
1310 |
+
self.post_init()
|
1311 |
+
|
1312 |
+
def get_input_embeddings(self):
|
1313 |
+
return self.model.embed_tokens
|
1314 |
+
|
1315 |
+
def set_input_embeddings(self, value):
|
1316 |
+
self.model.embed_tokens = value
|
1317 |
+
|
1318 |
+
@add_start_docstrings_to_model_forward(LLAMA_INPUTS_DOCSTRING)
|
1319 |
+
def forward(
|
1320 |
+
self,
|
1321 |
+
input_ids: torch.LongTensor = None,
|
1322 |
+
attention_mask: Optional[torch.Tensor] = None,
|
1323 |
+
position_ids: Optional[torch.LongTensor] = None,
|
1324 |
+
past_key_values: Optional[List[torch.FloatTensor]] = None,
|
1325 |
+
inputs_embeds: Optional[torch.FloatTensor] = None,
|
1326 |
+
labels: Optional[torch.LongTensor] = None,
|
1327 |
+
use_cache: Optional[bool] = None,
|
1328 |
+
output_attentions: Optional[bool] = None,
|
1329 |
+
output_hidden_states: Optional[bool] = None,
|
1330 |
+
return_dict: Optional[bool] = None,
|
1331 |
+
) -> Union[Tuple, SequenceClassifierOutputWithPast]:
|
1332 |
+
r"""
|
1333 |
+
labels (`torch.LongTensor` of shape `(batch_size,)`, *optional*):
|
1334 |
+
Labels for computing the sequence classification/regression loss. Indices should be in `[0, ...,
|
1335 |
+
config.num_labels - 1]`. If `config.num_labels == 1` a regression loss is computed (Mean-Square loss), If
|
1336 |
+
`config.num_labels > 1` a classification loss is computed (Cross-Entropy).
|
1337 |
+
"""
|
1338 |
+
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
1339 |
+
|
1340 |
+
transformer_outputs = self.model(
|
1341 |
+
input_ids,
|
1342 |
+
attention_mask=attention_mask,
|
1343 |
+
position_ids=position_ids,
|
1344 |
+
past_key_values=past_key_values,
|
1345 |
+
inputs_embeds=inputs_embeds,
|
1346 |
+
use_cache=use_cache,
|
1347 |
+
output_attentions=output_attentions,
|
1348 |
+
output_hidden_states=output_hidden_states,
|
1349 |
+
return_dict=return_dict,
|
1350 |
+
)
|
1351 |
+
hidden_states = transformer_outputs[0]
|
1352 |
+
logits = self.score(hidden_states)
|
1353 |
+
|
1354 |
+
if input_ids is not None:
|
1355 |
+
batch_size = input_ids.shape[0]
|
1356 |
+
else:
|
1357 |
+
batch_size = inputs_embeds.shape[0]
|
1358 |
+
|
1359 |
+
if self.config.pad_token_id is None and batch_size != 1:
|
1360 |
+
raise ValueError("Cannot handle batch sizes > 1 if no padding token is defined.")
|
1361 |
+
if self.config.pad_token_id is None:
|
1362 |
+
sequence_lengths = -1
|
1363 |
+
else:
|
1364 |
+
if input_ids is not None:
|
1365 |
+
sequence_lengths = (torch.eq(input_ids, self.config.pad_token_id).long().argmax(-1) - 1).to(
|
1366 |
+
logits.device
|
1367 |
+
)
|
1368 |
+
else:
|
1369 |
+
sequence_lengths = -1
|
1370 |
+
|
1371 |
+
pooled_logits = logits[torch.arange(batch_size, device=logits.device), sequence_lengths]
|
1372 |
+
|
1373 |
+
loss = None
|
1374 |
+
if labels is not None:
|
1375 |
+
labels = labels.to(logits.device)
|
1376 |
+
if self.config.problem_type is None:
|
1377 |
+
if self.num_labels == 1:
|
1378 |
+
self.config.problem_type = "regression"
|
1379 |
+
elif self.num_labels > 1 and (labels.dtype == torch.long or labels.dtype == torch.int):
|
1380 |
+
self.config.problem_type = "single_label_classification"
|
1381 |
+
else:
|
1382 |
+
self.config.problem_type = "multi_label_classification"
|
1383 |
+
|
1384 |
+
if self.config.problem_type == "regression":
|
1385 |
+
loss_fct = MSELoss()
|
1386 |
+
if self.num_labels == 1:
|
1387 |
+
loss = loss_fct(pooled_logits.squeeze(), labels.squeeze())
|
1388 |
+
else:
|
1389 |
+
loss = loss_fct(pooled_logits, labels)
|
1390 |
+
elif self.config.problem_type == "single_label_classification":
|
1391 |
+
loss_fct = CrossEntropyLoss()
|
1392 |
+
loss = loss_fct(pooled_logits.view(-1, self.num_labels), labels.view(-1))
|
1393 |
+
elif self.config.problem_type == "multi_label_classification":
|
1394 |
+
loss_fct = BCEWithLogitsLoss()
|
1395 |
+
loss = loss_fct(pooled_logits, labels)
|
1396 |
+
if not return_dict:
|
1397 |
+
output = (pooled_logits,) + transformer_outputs[1:]
|
1398 |
+
return ((loss,) + output) if loss is not None else output
|
1399 |
+
|
1400 |
+
return SequenceClassifierOutputWithPast(
|
1401 |
+
loss=loss,
|
1402 |
+
logits=pooled_logits,
|
1403 |
+
past_key_values=transformer_outputs.past_key_values,
|
1404 |
+
hidden_states=transformer_outputs.hidden_states,
|
1405 |
+
attentions=transformer_outputs.attentions,
|
1406 |
+
)
|
output-00001-of-00003.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:818f61340294b8c42747af215301118f3e7762d08daf7a53729184f8b5d5f5aa
|
3 |
+
size 8541775416
|
output-00002-of-00003.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:d2b48972e0a8e706d540baac4d89fe49cb77b5ae459537e0ed99844a89f69e18
|
3 |
+
size 8561338472
|
output-00003-of-00003.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:04e21c5f811dbe0f4b19474d1564d3164de9ed15a01de4b3969e6bb667233e93
|
3 |
+
size 4195481720
|
pytorch_model.bin.index.json
ADDED
@@ -0,0 +1,730 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"metadata": {
|
3 |
+
"total_size": 137953296384
|
4 |
+
},
|
5 |
+
"weight_map": {
|
6 |
+
"lm_head.weight": "pytorch_model-00015-of-00015.bin",
|
7 |
+
"model.embed_tokens.weight": "pytorch_model-00001-of-00015.bin",
|
8 |
+
"model.layers.0.input_layernorm.weight": "pytorch_model-00001-of-00015.bin",
|
9 |
+
"model.layers.0.mlp.down_proj.weight": "pytorch_model-00001-of-00015.bin",
|
10 |
+
"model.layers.0.mlp.gate_proj.weight": "pytorch_model-00001-of-00015.bin",
|
11 |
+
"model.layers.0.mlp.up_proj.weight": "pytorch_model-00001-of-00015.bin",
|
12 |
+
"model.layers.0.post_attention_layernorm.weight": "pytorch_model-00001-of-00015.bin",
|
13 |
+
"model.layers.0.self_attn.k_proj.weight": "pytorch_model-00001-of-00015.bin",
|
14 |
+
"model.layers.0.self_attn.o_proj.weight": "pytorch_model-00001-of-00015.bin",
|
15 |
+
"model.layers.0.self_attn.q_proj.weight": "pytorch_model-00001-of-00015.bin",
|
16 |
+
"model.layers.0.self_attn.v_proj.weight": "pytorch_model-00001-of-00015.bin",
|
17 |
+
"model.layers.1.input_layernorm.weight": "pytorch_model-00001-of-00015.bin",
|
18 |
+
"model.layers.1.mlp.down_proj.weight": "pytorch_model-00001-of-00015.bin",
|
19 |
+
"model.layers.1.mlp.gate_proj.weight": "pytorch_model-00001-of-00015.bin",
|
20 |
+
"model.layers.1.mlp.up_proj.weight": "pytorch_model-00001-of-00015.bin",
|
21 |
+
"model.layers.1.post_attention_layernorm.weight": "pytorch_model-00001-of-00015.bin",
|
22 |
+
"model.layers.1.self_attn.k_proj.weight": "pytorch_model-00001-of-00015.bin",
|
23 |
+
"model.layers.1.self_attn.o_proj.weight": "pytorch_model-00001-of-00015.bin",
|
24 |
+
"model.layers.1.self_attn.q_proj.weight": "pytorch_model-00001-of-00015.bin",
|
25 |
+
"model.layers.1.self_attn.v_proj.weight": "pytorch_model-00001-of-00015.bin",
|
26 |
+
"model.layers.10.input_layernorm.weight": "pytorch_model-00002-of-00015.bin",
|
27 |
+
"model.layers.10.mlp.down_proj.weight": "pytorch_model-00002-of-00015.bin",
|
28 |
+
"model.layers.10.mlp.gate_proj.weight": "pytorch_model-00002-of-00015.bin",
|
29 |
+
"model.layers.10.mlp.up_proj.weight": "pytorch_model-00002-of-00015.bin",
|
30 |
+
"model.layers.10.post_attention_layernorm.weight": "pytorch_model-00002-of-00015.bin",
|
31 |
+
"model.layers.10.self_attn.k_proj.weight": "pytorch_model-00002-of-00015.bin",
|
32 |
+
"model.layers.10.self_attn.o_proj.weight": "pytorch_model-00002-of-00015.bin",
|
33 |
+
"model.layers.10.self_attn.q_proj.weight": "pytorch_model-00002-of-00015.bin",
|
34 |
+
"model.layers.10.self_attn.v_proj.weight": "pytorch_model-00002-of-00015.bin",
|
35 |
+
"model.layers.11.input_layernorm.weight": "pytorch_model-00003-of-00015.bin",
|
36 |
+
"model.layers.11.mlp.down_proj.weight": "pytorch_model-00003-of-00015.bin",
|
37 |
+
"model.layers.11.mlp.gate_proj.weight": "pytorch_model-00003-of-00015.bin",
|
38 |
+
"model.layers.11.mlp.up_proj.weight": "pytorch_model-00003-of-00015.bin",
|
39 |
+
"model.layers.11.post_attention_layernorm.weight": "pytorch_model-00003-of-00015.bin",
|
40 |
+
"model.layers.11.self_attn.k_proj.weight": "pytorch_model-00002-of-00015.bin",
|
41 |
+
"model.layers.11.self_attn.o_proj.weight": "pytorch_model-00002-of-00015.bin",
|
42 |
+
"model.layers.11.self_attn.q_proj.weight": "pytorch_model-00002-of-00015.bin",
|
43 |
+
"model.layers.11.self_attn.v_proj.weight": "pytorch_model-00002-of-00015.bin",
|
44 |
+
"model.layers.12.input_layernorm.weight": "pytorch_model-00003-of-00015.bin",
|
45 |
+
"model.layers.12.mlp.down_proj.weight": "pytorch_model-00003-of-00015.bin",
|
46 |
+
"model.layers.12.mlp.gate_proj.weight": "pytorch_model-00003-of-00015.bin",
|
47 |
+
"model.layers.12.mlp.up_proj.weight": "pytorch_model-00003-of-00015.bin",
|
48 |
+
"model.layers.12.post_attention_layernorm.weight": "pytorch_model-00003-of-00015.bin",
|
49 |
+
"model.layers.12.self_attn.k_proj.weight": "pytorch_model-00003-of-00015.bin",
|
50 |
+
"model.layers.12.self_attn.o_proj.weight": "pytorch_model-00003-of-00015.bin",
|
51 |
+
"model.layers.12.self_attn.q_proj.weight": "pytorch_model-00003-of-00015.bin",
|
52 |
+
"model.layers.12.self_attn.v_proj.weight": "pytorch_model-00003-of-00015.bin",
|
53 |
+
"model.layers.13.input_layernorm.weight": "pytorch_model-00003-of-00015.bin",
|
54 |
+
"model.layers.13.mlp.down_proj.weight": "pytorch_model-00003-of-00015.bin",
|
55 |
+
"model.layers.13.mlp.gate_proj.weight": "pytorch_model-00003-of-00015.bin",
|
56 |
+
"model.layers.13.mlp.up_proj.weight": "pytorch_model-00003-of-00015.bin",
|
57 |
+
"model.layers.13.post_attention_layernorm.weight": "pytorch_model-00003-of-00015.bin",
|
58 |
+
"model.layers.13.self_attn.k_proj.weight": "pytorch_model-00003-of-00015.bin",
|
59 |
+
"model.layers.13.self_attn.o_proj.weight": "pytorch_model-00003-of-00015.bin",
|
60 |
+
"model.layers.13.self_attn.q_proj.weight": "pytorch_model-00003-of-00015.bin",
|
61 |
+
"model.layers.13.self_attn.v_proj.weight": "pytorch_model-00003-of-00015.bin",
|
62 |
+
"model.layers.14.input_layernorm.weight": "pytorch_model-00003-of-00015.bin",
|
63 |
+
"model.layers.14.mlp.down_proj.weight": "pytorch_model-00003-of-00015.bin",
|
64 |
+
"model.layers.14.mlp.gate_proj.weight": "pytorch_model-00003-of-00015.bin",
|
65 |
+
"model.layers.14.mlp.up_proj.weight": "pytorch_model-00003-of-00015.bin",
|
66 |
+
"model.layers.14.post_attention_layernorm.weight": "pytorch_model-00003-of-00015.bin",
|
67 |
+
"model.layers.14.self_attn.k_proj.weight": "pytorch_model-00003-of-00015.bin",
|
68 |
+
"model.layers.14.self_attn.o_proj.weight": "pytorch_model-00003-of-00015.bin",
|
69 |
+
"model.layers.14.self_attn.q_proj.weight": "pytorch_model-00003-of-00015.bin",
|
70 |
+
"model.layers.14.self_attn.v_proj.weight": "pytorch_model-00003-of-00015.bin",
|
71 |
+
"model.layers.15.input_layernorm.weight": "pytorch_model-00003-of-00015.bin",
|
72 |
+
"model.layers.15.mlp.down_proj.weight": "pytorch_model-00003-of-00015.bin",
|
73 |
+
"model.layers.15.mlp.gate_proj.weight": "pytorch_model-00003-of-00015.bin",
|
74 |
+
"model.layers.15.mlp.up_proj.weight": "pytorch_model-00003-of-00015.bin",
|
75 |
+
"model.layers.15.post_attention_layernorm.weight": "pytorch_model-00003-of-00015.bin",
|
76 |
+
"model.layers.15.self_attn.k_proj.weight": "pytorch_model-00003-of-00015.bin",
|
77 |
+
"model.layers.15.self_attn.o_proj.weight": "pytorch_model-00003-of-00015.bin",
|
78 |
+
"model.layers.15.self_attn.q_proj.weight": "pytorch_model-00003-of-00015.bin",
|
79 |
+
"model.layers.15.self_attn.v_proj.weight": "pytorch_model-00003-of-00015.bin",
|
80 |
+
"model.layers.16.input_layernorm.weight": "pytorch_model-00003-of-00015.bin",
|
81 |
+
"model.layers.16.mlp.down_proj.weight": "pytorch_model-00003-of-00015.bin",
|
82 |
+
"model.layers.16.mlp.gate_proj.weight": "pytorch_model-00003-of-00015.bin",
|
83 |
+
"model.layers.16.mlp.up_proj.weight": "pytorch_model-00003-of-00015.bin",
|
84 |
+
"model.layers.16.post_attention_layernorm.weight": "pytorch_model-00003-of-00015.bin",
|
85 |
+
"model.layers.16.self_attn.k_proj.weight": "pytorch_model-00003-of-00015.bin",
|
86 |
+
"model.layers.16.self_attn.o_proj.weight": "pytorch_model-00003-of-00015.bin",
|
87 |
+
"model.layers.16.self_attn.q_proj.weight": "pytorch_model-00003-of-00015.bin",
|
88 |
+
"model.layers.16.self_attn.v_proj.weight": "pytorch_model-00003-of-00015.bin",
|
89 |
+
"model.layers.17.input_layernorm.weight": "pytorch_model-00004-of-00015.bin",
|
90 |
+
"model.layers.17.mlp.down_proj.weight": "pytorch_model-00004-of-00015.bin",
|
91 |
+
"model.layers.17.mlp.gate_proj.weight": "pytorch_model-00004-of-00015.bin",
|
92 |
+
"model.layers.17.mlp.up_proj.weight": "pytorch_model-00004-of-00015.bin",
|
93 |
+
"model.layers.17.post_attention_layernorm.weight": "pytorch_model-00004-of-00015.bin",
|
94 |
+
"model.layers.17.self_attn.k_proj.weight": "pytorch_model-00004-of-00015.bin",
|
95 |
+
"model.layers.17.self_attn.o_proj.weight": "pytorch_model-00004-of-00015.bin",
|
96 |
+
"model.layers.17.self_attn.q_proj.weight": "pytorch_model-00004-of-00015.bin",
|
97 |
+
"model.layers.17.self_attn.v_proj.weight": "pytorch_model-00004-of-00015.bin",
|
98 |
+
"model.layers.18.input_layernorm.weight": "pytorch_model-00004-of-00015.bin",
|
99 |
+
"model.layers.18.mlp.down_proj.weight": "pytorch_model-00004-of-00015.bin",
|
100 |
+
"model.layers.18.mlp.gate_proj.weight": "pytorch_model-00004-of-00015.bin",
|
101 |
+
"model.layers.18.mlp.up_proj.weight": "pytorch_model-00004-of-00015.bin",
|
102 |
+
"model.layers.18.post_attention_layernorm.weight": "pytorch_model-00004-of-00015.bin",
|
103 |
+
"model.layers.18.self_attn.k_proj.weight": "pytorch_model-00004-of-00015.bin",
|
104 |
+
"model.layers.18.self_attn.o_proj.weight": "pytorch_model-00004-of-00015.bin",
|
105 |
+
"model.layers.18.self_attn.q_proj.weight": "pytorch_model-00004-of-00015.bin",
|
106 |
+
"model.layers.18.self_attn.v_proj.weight": "pytorch_model-00004-of-00015.bin",
|
107 |
+
"model.layers.19.input_layernorm.weight": "pytorch_model-00004-of-00015.bin",
|
108 |
+
"model.layers.19.mlp.down_proj.weight": "pytorch_model-00004-of-00015.bin",
|
109 |
+
"model.layers.19.mlp.gate_proj.weight": "pytorch_model-00004-of-00015.bin",
|
110 |
+
"model.layers.19.mlp.up_proj.weight": "pytorch_model-00004-of-00015.bin",
|
111 |
+
"model.layers.19.post_attention_layernorm.weight": "pytorch_model-00004-of-00015.bin",
|
112 |
+
"model.layers.19.self_attn.k_proj.weight": "pytorch_model-00004-of-00015.bin",
|
113 |
+
"model.layers.19.self_attn.o_proj.weight": "pytorch_model-00004-of-00015.bin",
|
114 |
+
"model.layers.19.self_attn.q_proj.weight": "pytorch_model-00004-of-00015.bin",
|
115 |
+
"model.layers.19.self_attn.v_proj.weight": "pytorch_model-00004-of-00015.bin",
|
116 |
+
"model.layers.2.input_layernorm.weight": "pytorch_model-00001-of-00015.bin",
|
117 |
+
"model.layers.2.mlp.down_proj.weight": "pytorch_model-00001-of-00015.bin",
|
118 |
+
"model.layers.2.mlp.gate_proj.weight": "pytorch_model-00001-of-00015.bin",
|
119 |
+
"model.layers.2.mlp.up_proj.weight": "pytorch_model-00001-of-00015.bin",
|
120 |
+
"model.layers.2.post_attention_layernorm.weight": "pytorch_model-00001-of-00015.bin",
|
121 |
+
"model.layers.2.self_attn.k_proj.weight": "pytorch_model-00001-of-00015.bin",
|
122 |
+
"model.layers.2.self_attn.o_proj.weight": "pytorch_model-00001-of-00015.bin",
|
123 |
+
"model.layers.2.self_attn.q_proj.weight": "pytorch_model-00001-of-00015.bin",
|
124 |
+
"model.layers.2.self_attn.v_proj.weight": "pytorch_model-00001-of-00015.bin",
|
125 |
+
"model.layers.20.input_layernorm.weight": "pytorch_model-00004-of-00015.bin",
|
126 |
+
"model.layers.20.mlp.down_proj.weight": "pytorch_model-00004-of-00015.bin",
|
127 |
+
"model.layers.20.mlp.gate_proj.weight": "pytorch_model-00004-of-00015.bin",
|
128 |
+
"model.layers.20.mlp.up_proj.weight": "pytorch_model-00004-of-00015.bin",
|
129 |
+
"model.layers.20.post_attention_layernorm.weight": "pytorch_model-00004-of-00015.bin",
|
130 |
+
"model.layers.20.self_attn.k_proj.weight": "pytorch_model-00004-of-00015.bin",
|
131 |
+
"model.layers.20.self_attn.o_proj.weight": "pytorch_model-00004-of-00015.bin",
|
132 |
+
"model.layers.20.self_attn.q_proj.weight": "pytorch_model-00004-of-00015.bin",
|
133 |
+
"model.layers.20.self_attn.v_proj.weight": "pytorch_model-00004-of-00015.bin",
|
134 |
+
"model.layers.21.input_layernorm.weight": "pytorch_model-00004-of-00015.bin",
|
135 |
+
"model.layers.21.mlp.down_proj.weight": "pytorch_model-00004-of-00015.bin",
|
136 |
+
"model.layers.21.mlp.gate_proj.weight": "pytorch_model-00004-of-00015.bin",
|
137 |
+
"model.layers.21.mlp.up_proj.weight": "pytorch_model-00004-of-00015.bin",
|
138 |
+
"model.layers.21.post_attention_layernorm.weight": "pytorch_model-00004-of-00015.bin",
|
139 |
+
"model.layers.21.self_attn.k_proj.weight": "pytorch_model-00004-of-00015.bin",
|
140 |
+
"model.layers.21.self_attn.o_proj.weight": "pytorch_model-00004-of-00015.bin",
|
141 |
+
"model.layers.21.self_attn.q_proj.weight": "pytorch_model-00004-of-00015.bin",
|
142 |
+
"model.layers.21.self_attn.v_proj.weight": "pytorch_model-00004-of-00015.bin",
|
143 |
+
"model.layers.22.input_layernorm.weight": "pytorch_model-00005-of-00015.bin",
|
144 |
+
"model.layers.22.mlp.down_proj.weight": "pytorch_model-00005-of-00015.bin",
|
145 |
+
"model.layers.22.mlp.gate_proj.weight": "pytorch_model-00004-of-00015.bin",
|
146 |
+
"model.layers.22.mlp.up_proj.weight": "pytorch_model-00004-of-00015.bin",
|
147 |
+
"model.layers.22.post_attention_layernorm.weight": "pytorch_model-00005-of-00015.bin",
|
148 |
+
"model.layers.22.self_attn.k_proj.weight": "pytorch_model-00004-of-00015.bin",
|
149 |
+
"model.layers.22.self_attn.o_proj.weight": "pytorch_model-00004-of-00015.bin",
|
150 |
+
"model.layers.22.self_attn.q_proj.weight": "pytorch_model-00004-of-00015.bin",
|
151 |
+
"model.layers.22.self_attn.v_proj.weight": "pytorch_model-00004-of-00015.bin",
|
152 |
+
"model.layers.23.input_layernorm.weight": "pytorch_model-00005-of-00015.bin",
|
153 |
+
"model.layers.23.mlp.down_proj.weight": "pytorch_model-00005-of-00015.bin",
|
154 |
+
"model.layers.23.mlp.gate_proj.weight": "pytorch_model-00005-of-00015.bin",
|
155 |
+
"model.layers.23.mlp.up_proj.weight": "pytorch_model-00005-of-00015.bin",
|
156 |
+
"model.layers.23.post_attention_layernorm.weight": "pytorch_model-00005-of-00015.bin",
|
157 |
+
"model.layers.23.self_attn.k_proj.weight": "pytorch_model-00005-of-00015.bin",
|
158 |
+
"model.layers.23.self_attn.o_proj.weight": "pytorch_model-00005-of-00015.bin",
|
159 |
+
"model.layers.23.self_attn.q_proj.weight": "pytorch_model-00005-of-00015.bin",
|
160 |
+
"model.layers.23.self_attn.v_proj.weight": "pytorch_model-00005-of-00015.bin",
|
161 |
+
"model.layers.24.input_layernorm.weight": "pytorch_model-00005-of-00015.bin",
|
162 |
+
"model.layers.24.mlp.down_proj.weight": "pytorch_model-00005-of-00015.bin",
|
163 |
+
"model.layers.24.mlp.gate_proj.weight": "pytorch_model-00005-of-00015.bin",
|
164 |
+
"model.layers.24.mlp.up_proj.weight": "pytorch_model-00005-of-00015.bin",
|
165 |
+
"model.layers.24.post_attention_layernorm.weight": "pytorch_model-00005-of-00015.bin",
|
166 |
+
"model.layers.24.self_attn.k_proj.weight": "pytorch_model-00005-of-00015.bin",
|
167 |
+
"model.layers.24.self_attn.o_proj.weight": "pytorch_model-00005-of-00015.bin",
|
168 |
+
"model.layers.24.self_attn.q_proj.weight": "pytorch_model-00005-of-00015.bin",
|
169 |
+
"model.layers.24.self_attn.v_proj.weight": "pytorch_model-00005-of-00015.bin",
|
170 |
+
"model.layers.25.input_layernorm.weight": "pytorch_model-00005-of-00015.bin",
|
171 |
+
"model.layers.25.mlp.down_proj.weight": "pytorch_model-00005-of-00015.bin",
|
172 |
+
"model.layers.25.mlp.gate_proj.weight": "pytorch_model-00005-of-00015.bin",
|
173 |
+
"model.layers.25.mlp.up_proj.weight": "pytorch_model-00005-of-00015.bin",
|
174 |
+
"model.layers.25.post_attention_layernorm.weight": "pytorch_model-00005-of-00015.bin",
|
175 |
+
"model.layers.25.self_attn.k_proj.weight": "pytorch_model-00005-of-00015.bin",
|
176 |
+
"model.layers.25.self_attn.o_proj.weight": "pytorch_model-00005-of-00015.bin",
|
177 |
+
"model.layers.25.self_attn.q_proj.weight": "pytorch_model-00005-of-00015.bin",
|
178 |
+
"model.layers.25.self_attn.v_proj.weight": "pytorch_model-00005-of-00015.bin",
|
179 |
+
"model.layers.26.input_layernorm.weight": "pytorch_model-00005-of-00015.bin",
|
180 |
+
"model.layers.26.mlp.down_proj.weight": "pytorch_model-00005-of-00015.bin",
|
181 |
+
"model.layers.26.mlp.gate_proj.weight": "pytorch_model-00005-of-00015.bin",
|
182 |
+
"model.layers.26.mlp.up_proj.weight": "pytorch_model-00005-of-00015.bin",
|
183 |
+
"model.layers.26.post_attention_layernorm.weight": "pytorch_model-00005-of-00015.bin",
|
184 |
+
"model.layers.26.self_attn.k_proj.weight": "pytorch_model-00005-of-00015.bin",
|
185 |
+
"model.layers.26.self_attn.o_proj.weight": "pytorch_model-00005-of-00015.bin",
|
186 |
+
"model.layers.26.self_attn.q_proj.weight": "pytorch_model-00005-of-00015.bin",
|
187 |
+
"model.layers.26.self_attn.v_proj.weight": "pytorch_model-00005-of-00015.bin",
|
188 |
+
"model.layers.27.input_layernorm.weight": "pytorch_model-00005-of-00015.bin",
|
189 |
+
"model.layers.27.mlp.down_proj.weight": "pytorch_model-00005-of-00015.bin",
|
190 |
+
"model.layers.27.mlp.gate_proj.weight": "pytorch_model-00005-of-00015.bin",
|
191 |
+
"model.layers.27.mlp.up_proj.weight": "pytorch_model-00005-of-00015.bin",
|
192 |
+
"model.layers.27.post_attention_layernorm.weight": "pytorch_model-00005-of-00015.bin",
|
193 |
+
"model.layers.27.self_attn.k_proj.weight": "pytorch_model-00005-of-00015.bin",
|
194 |
+
"model.layers.27.self_attn.o_proj.weight": "pytorch_model-00005-of-00015.bin",
|
195 |
+
"model.layers.27.self_attn.q_proj.weight": "pytorch_model-00005-of-00015.bin",
|
196 |
+
"model.layers.27.self_attn.v_proj.weight": "pytorch_model-00005-of-00015.bin",
|
197 |
+
"model.layers.28.input_layernorm.weight": "pytorch_model-00006-of-00015.bin",
|
198 |
+
"model.layers.28.mlp.down_proj.weight": "pytorch_model-00006-of-00015.bin",
|
199 |
+
"model.layers.28.mlp.gate_proj.weight": "pytorch_model-00005-of-00015.bin",
|
200 |
+
"model.layers.28.mlp.up_proj.weight": "pytorch_model-00006-of-00015.bin",
|
201 |
+
"model.layers.28.post_attention_layernorm.weight": "pytorch_model-00006-of-00015.bin",
|
202 |
+
"model.layers.28.self_attn.k_proj.weight": "pytorch_model-00005-of-00015.bin",
|
203 |
+
"model.layers.28.self_attn.o_proj.weight": "pytorch_model-00005-of-00015.bin",
|
204 |
+
"model.layers.28.self_attn.q_proj.weight": "pytorch_model-00005-of-00015.bin",
|
205 |
+
"model.layers.28.self_attn.v_proj.weight": "pytorch_model-00005-of-00015.bin",
|
206 |
+
"model.layers.29.input_layernorm.weight": "pytorch_model-00006-of-00015.bin",
|
207 |
+
"model.layers.29.mlp.down_proj.weight": "pytorch_model-00006-of-00015.bin",
|
208 |
+
"model.layers.29.mlp.gate_proj.weight": "pytorch_model-00006-of-00015.bin",
|
209 |
+
"model.layers.29.mlp.up_proj.weight": "pytorch_model-00006-of-00015.bin",
|
210 |
+
"model.layers.29.post_attention_layernorm.weight": "pytorch_model-00006-of-00015.bin",
|
211 |
+
"model.layers.29.self_attn.k_proj.weight": "pytorch_model-00006-of-00015.bin",
|
212 |
+
"model.layers.29.self_attn.o_proj.weight": "pytorch_model-00006-of-00015.bin",
|
213 |
+
"model.layers.29.self_attn.q_proj.weight": "pytorch_model-00006-of-00015.bin",
|
214 |
+
"model.layers.29.self_attn.v_proj.weight": "pytorch_model-00006-of-00015.bin",
|
215 |
+
"model.layers.3.input_layernorm.weight": "pytorch_model-00001-of-00015.bin",
|
216 |
+
"model.layers.3.mlp.down_proj.weight": "pytorch_model-00001-of-00015.bin",
|
217 |
+
"model.layers.3.mlp.gate_proj.weight": "pytorch_model-00001-of-00015.bin",
|
218 |
+
"model.layers.3.mlp.up_proj.weight": "pytorch_model-00001-of-00015.bin",
|
219 |
+
"model.layers.3.post_attention_layernorm.weight": "pytorch_model-00001-of-00015.bin",
|
220 |
+
"model.layers.3.self_attn.k_proj.weight": "pytorch_model-00001-of-00015.bin",
|
221 |
+
"model.layers.3.self_attn.o_proj.weight": "pytorch_model-00001-of-00015.bin",
|
222 |
+
"model.layers.3.self_attn.q_proj.weight": "pytorch_model-00001-of-00015.bin",
|
223 |
+
"model.layers.3.self_attn.v_proj.weight": "pytorch_model-00001-of-00015.bin",
|
224 |
+
"model.layers.30.input_layernorm.weight": "pytorch_model-00006-of-00015.bin",
|
225 |
+
"model.layers.30.mlp.down_proj.weight": "pytorch_model-00006-of-00015.bin",
|
226 |
+
"model.layers.30.mlp.gate_proj.weight": "pytorch_model-00006-of-00015.bin",
|
227 |
+
"model.layers.30.mlp.up_proj.weight": "pytorch_model-00006-of-00015.bin",
|
228 |
+
"model.layers.30.post_attention_layernorm.weight": "pytorch_model-00006-of-00015.bin",
|
229 |
+
"model.layers.30.self_attn.k_proj.weight": "pytorch_model-00006-of-00015.bin",
|
230 |
+
"model.layers.30.self_attn.o_proj.weight": "pytorch_model-00006-of-00015.bin",
|
231 |
+
"model.layers.30.self_attn.q_proj.weight": "pytorch_model-00006-of-00015.bin",
|
232 |
+
"model.layers.30.self_attn.v_proj.weight": "pytorch_model-00006-of-00015.bin",
|
233 |
+
"model.layers.31.input_layernorm.weight": "pytorch_model-00006-of-00015.bin",
|
234 |
+
"model.layers.31.mlp.down_proj.weight": "pytorch_model-00006-of-00015.bin",
|
235 |
+
"model.layers.31.mlp.gate_proj.weight": "pytorch_model-00006-of-00015.bin",
|
236 |
+
"model.layers.31.mlp.up_proj.weight": "pytorch_model-00006-of-00015.bin",
|
237 |
+
"model.layers.31.post_attention_layernorm.weight": "pytorch_model-00006-of-00015.bin",
|
238 |
+
"model.layers.31.self_attn.k_proj.weight": "pytorch_model-00006-of-00015.bin",
|
239 |
+
"model.layers.31.self_attn.o_proj.weight": "pytorch_model-00006-of-00015.bin",
|
240 |
+
"model.layers.31.self_attn.q_proj.weight": "pytorch_model-00006-of-00015.bin",
|
241 |
+
"model.layers.31.self_attn.v_proj.weight": "pytorch_model-00006-of-00015.bin",
|
242 |
+
"model.layers.32.input_layernorm.weight": "pytorch_model-00006-of-00015.bin",
|
243 |
+
"model.layers.32.mlp.down_proj.weight": "pytorch_model-00006-of-00015.bin",
|
244 |
+
"model.layers.32.mlp.gate_proj.weight": "pytorch_model-00006-of-00015.bin",
|
245 |
+
"model.layers.32.mlp.up_proj.weight": "pytorch_model-00006-of-00015.bin",
|
246 |
+
"model.layers.32.post_attention_layernorm.weight": "pytorch_model-00006-of-00015.bin",
|
247 |
+
"model.layers.32.self_attn.k_proj.weight": "pytorch_model-00006-of-00015.bin",
|
248 |
+
"model.layers.32.self_attn.o_proj.weight": "pytorch_model-00006-of-00015.bin",
|
249 |
+
"model.layers.32.self_attn.q_proj.weight": "pytorch_model-00006-of-00015.bin",
|
250 |
+
"model.layers.32.self_attn.v_proj.weight": "pytorch_model-00006-of-00015.bin",
|
251 |
+
"model.layers.33.input_layernorm.weight": "pytorch_model-00006-of-00015.bin",
|
252 |
+
"model.layers.33.mlp.down_proj.weight": "pytorch_model-00006-of-00015.bin",
|
253 |
+
"model.layers.33.mlp.gate_proj.weight": "pytorch_model-00006-of-00015.bin",
|
254 |
+
"model.layers.33.mlp.up_proj.weight": "pytorch_model-00006-of-00015.bin",
|
255 |
+
"model.layers.33.post_attention_layernorm.weight": "pytorch_model-00006-of-00015.bin",
|
256 |
+
"model.layers.33.self_attn.k_proj.weight": "pytorch_model-00006-of-00015.bin",
|
257 |
+
"model.layers.33.self_attn.o_proj.weight": "pytorch_model-00006-of-00015.bin",
|
258 |
+
"model.layers.33.self_attn.q_proj.weight": "pytorch_model-00006-of-00015.bin",
|
259 |
+
"model.layers.33.self_attn.v_proj.weight": "pytorch_model-00006-of-00015.bin",
|
260 |
+
"model.layers.34.input_layernorm.weight": "pytorch_model-00007-of-00015.bin",
|
261 |
+
"model.layers.34.mlp.down_proj.weight": "pytorch_model-00007-of-00015.bin",
|
262 |
+
"model.layers.34.mlp.gate_proj.weight": "pytorch_model-00007-of-00015.bin",
|
263 |
+
"model.layers.34.mlp.up_proj.weight": "pytorch_model-00007-of-00015.bin",
|
264 |
+
"model.layers.34.post_attention_layernorm.weight": "pytorch_model-00007-of-00015.bin",
|
265 |
+
"model.layers.34.self_attn.k_proj.weight": "pytorch_model-00006-of-00015.bin",
|
266 |
+
"model.layers.34.self_attn.o_proj.weight": "pytorch_model-00006-of-00015.bin",
|
267 |
+
"model.layers.34.self_attn.q_proj.weight": "pytorch_model-00006-of-00015.bin",
|
268 |
+
"model.layers.34.self_attn.v_proj.weight": "pytorch_model-00006-of-00015.bin",
|
269 |
+
"model.layers.35.input_layernorm.weight": "pytorch_model-00007-of-00015.bin",
|
270 |
+
"model.layers.35.mlp.down_proj.weight": "pytorch_model-00007-of-00015.bin",
|
271 |
+
"model.layers.35.mlp.gate_proj.weight": "pytorch_model-00007-of-00015.bin",
|
272 |
+
"model.layers.35.mlp.up_proj.weight": "pytorch_model-00007-of-00015.bin",
|
273 |
+
"model.layers.35.post_attention_layernorm.weight": "pytorch_model-00007-of-00015.bin",
|
274 |
+
"model.layers.35.self_attn.k_proj.weight": "pytorch_model-00007-of-00015.bin",
|
275 |
+
"model.layers.35.self_attn.o_proj.weight": "pytorch_model-00007-of-00015.bin",
|
276 |
+
"model.layers.35.self_attn.q_proj.weight": "pytorch_model-00007-of-00015.bin",
|
277 |
+
"model.layers.35.self_attn.v_proj.weight": "pytorch_model-00007-of-00015.bin",
|
278 |
+
"model.layers.36.input_layernorm.weight": "pytorch_model-00007-of-00015.bin",
|
279 |
+
"model.layers.36.mlp.down_proj.weight": "pytorch_model-00007-of-00015.bin",
|
280 |
+
"model.layers.36.mlp.gate_proj.weight": "pytorch_model-00007-of-00015.bin",
|
281 |
+
"model.layers.36.mlp.up_proj.weight": "pytorch_model-00007-of-00015.bin",
|
282 |
+
"model.layers.36.post_attention_layernorm.weight": "pytorch_model-00007-of-00015.bin",
|
283 |
+
"model.layers.36.self_attn.k_proj.weight": "pytorch_model-00007-of-00015.bin",
|
284 |
+
"model.layers.36.self_attn.o_proj.weight": "pytorch_model-00007-of-00015.bin",
|
285 |
+
"model.layers.36.self_attn.q_proj.weight": "pytorch_model-00007-of-00015.bin",
|
286 |
+
"model.layers.36.self_attn.v_proj.weight": "pytorch_model-00007-of-00015.bin",
|
287 |
+
"model.layers.37.input_layernorm.weight": "pytorch_model-00007-of-00015.bin",
|
288 |
+
"model.layers.37.mlp.down_proj.weight": "pytorch_model-00007-of-00015.bin",
|
289 |
+
"model.layers.37.mlp.gate_proj.weight": "pytorch_model-00007-of-00015.bin",
|
290 |
+
"model.layers.37.mlp.up_proj.weight": "pytorch_model-00007-of-00015.bin",
|
291 |
+
"model.layers.37.post_attention_layernorm.weight": "pytorch_model-00007-of-00015.bin",
|
292 |
+
"model.layers.37.self_attn.k_proj.weight": "pytorch_model-00007-of-00015.bin",
|
293 |
+
"model.layers.37.self_attn.o_proj.weight": "pytorch_model-00007-of-00015.bin",
|
294 |
+
"model.layers.37.self_attn.q_proj.weight": "pytorch_model-00007-of-00015.bin",
|
295 |
+
"model.layers.37.self_attn.v_proj.weight": "pytorch_model-00007-of-00015.bin",
|
296 |
+
"model.layers.38.input_layernorm.weight": "pytorch_model-00007-of-00015.bin",
|
297 |
+
"model.layers.38.mlp.down_proj.weight": "pytorch_model-00007-of-00015.bin",
|
298 |
+
"model.layers.38.mlp.gate_proj.weight": "pytorch_model-00007-of-00015.bin",
|
299 |
+
"model.layers.38.mlp.up_proj.weight": "pytorch_model-00007-of-00015.bin",
|
300 |
+
"model.layers.38.post_attention_layernorm.weight": "pytorch_model-00007-of-00015.bin",
|
301 |
+
"model.layers.38.self_attn.k_proj.weight": "pytorch_model-00007-of-00015.bin",
|
302 |
+
"model.layers.38.self_attn.o_proj.weight": "pytorch_model-00007-of-00015.bin",
|
303 |
+
"model.layers.38.self_attn.q_proj.weight": "pytorch_model-00007-of-00015.bin",
|
304 |
+
"model.layers.38.self_attn.v_proj.weight": "pytorch_model-00007-of-00015.bin",
|
305 |
+
"model.layers.39.input_layernorm.weight": "pytorch_model-00007-of-00015.bin",
|
306 |
+
"model.layers.39.mlp.down_proj.weight": "pytorch_model-00007-of-00015.bin",
|
307 |
+
"model.layers.39.mlp.gate_proj.weight": "pytorch_model-00007-of-00015.bin",
|
308 |
+
"model.layers.39.mlp.up_proj.weight": "pytorch_model-00007-of-00015.bin",
|
309 |
+
"model.layers.39.post_attention_layernorm.weight": "pytorch_model-00007-of-00015.bin",
|
310 |
+
"model.layers.39.self_attn.k_proj.weight": "pytorch_model-00007-of-00015.bin",
|
311 |
+
"model.layers.39.self_attn.o_proj.weight": "pytorch_model-00007-of-00015.bin",
|
312 |
+
"model.layers.39.self_attn.q_proj.weight": "pytorch_model-00007-of-00015.bin",
|
313 |
+
"model.layers.39.self_attn.v_proj.weight": "pytorch_model-00007-of-00015.bin",
|
314 |
+
"model.layers.4.input_layernorm.weight": "pytorch_model-00001-of-00015.bin",
|
315 |
+
"model.layers.4.mlp.down_proj.weight": "pytorch_model-00001-of-00015.bin",
|
316 |
+
"model.layers.4.mlp.gate_proj.weight": "pytorch_model-00001-of-00015.bin",
|
317 |
+
"model.layers.4.mlp.up_proj.weight": "pytorch_model-00001-of-00015.bin",
|
318 |
+
"model.layers.4.post_attention_layernorm.weight": "pytorch_model-00001-of-00015.bin",
|
319 |
+
"model.layers.4.self_attn.k_proj.weight": "pytorch_model-00001-of-00015.bin",
|
320 |
+
"model.layers.4.self_attn.o_proj.weight": "pytorch_model-00001-of-00015.bin",
|
321 |
+
"model.layers.4.self_attn.q_proj.weight": "pytorch_model-00001-of-00015.bin",
|
322 |
+
"model.layers.4.self_attn.v_proj.weight": "pytorch_model-00001-of-00015.bin",
|
323 |
+
"model.layers.40.input_layernorm.weight": "pytorch_model-00008-of-00015.bin",
|
324 |
+
"model.layers.40.mlp.down_proj.weight": "pytorch_model-00008-of-00015.bin",
|
325 |
+
"model.layers.40.mlp.gate_proj.weight": "pytorch_model-00008-of-00015.bin",
|
326 |
+
"model.layers.40.mlp.up_proj.weight": "pytorch_model-00008-of-00015.bin",
|
327 |
+
"model.layers.40.post_attention_layernorm.weight": "pytorch_model-00008-of-00015.bin",
|
328 |
+
"model.layers.40.self_attn.k_proj.weight": "pytorch_model-00008-of-00015.bin",
|
329 |
+
"model.layers.40.self_attn.o_proj.weight": "pytorch_model-00008-of-00015.bin",
|
330 |
+
"model.layers.40.self_attn.q_proj.weight": "pytorch_model-00008-of-00015.bin",
|
331 |
+
"model.layers.40.self_attn.v_proj.weight": "pytorch_model-00008-of-00015.bin",
|
332 |
+
"model.layers.41.input_layernorm.weight": "pytorch_model-00008-of-00015.bin",
|
333 |
+
"model.layers.41.mlp.down_proj.weight": "pytorch_model-00008-of-00015.bin",
|
334 |
+
"model.layers.41.mlp.gate_proj.weight": "pytorch_model-00008-of-00015.bin",
|
335 |
+
"model.layers.41.mlp.up_proj.weight": "pytorch_model-00008-of-00015.bin",
|
336 |
+
"model.layers.41.post_attention_layernorm.weight": "pytorch_model-00008-of-00015.bin",
|
337 |
+
"model.layers.41.self_attn.k_proj.weight": "pytorch_model-00008-of-00015.bin",
|
338 |
+
"model.layers.41.self_attn.o_proj.weight": "pytorch_model-00008-of-00015.bin",
|
339 |
+
"model.layers.41.self_attn.q_proj.weight": "pytorch_model-00008-of-00015.bin",
|
340 |
+
"model.layers.41.self_attn.v_proj.weight": "pytorch_model-00008-of-00015.bin",
|
341 |
+
"model.layers.42.input_layernorm.weight": "pytorch_model-00008-of-00015.bin",
|
342 |
+
"model.layers.42.mlp.down_proj.weight": "pytorch_model-00008-of-00015.bin",
|
343 |
+
"model.layers.42.mlp.gate_proj.weight": "pytorch_model-00008-of-00015.bin",
|
344 |
+
"model.layers.42.mlp.up_proj.weight": "pytorch_model-00008-of-00015.bin",
|
345 |
+
"model.layers.42.post_attention_layernorm.weight": "pytorch_model-00008-of-00015.bin",
|
346 |
+
"model.layers.42.self_attn.k_proj.weight": "pytorch_model-00008-of-00015.bin",
|
347 |
+
"model.layers.42.self_attn.o_proj.weight": "pytorch_model-00008-of-00015.bin",
|
348 |
+
"model.layers.42.self_attn.q_proj.weight": "pytorch_model-00008-of-00015.bin",
|
349 |
+
"model.layers.42.self_attn.v_proj.weight": "pytorch_model-00008-of-00015.bin",
|
350 |
+
"model.layers.43.input_layernorm.weight": "pytorch_model-00008-of-00015.bin",
|
351 |
+
"model.layers.43.mlp.down_proj.weight": "pytorch_model-00008-of-00015.bin",
|
352 |
+
"model.layers.43.mlp.gate_proj.weight": "pytorch_model-00008-of-00015.bin",
|
353 |
+
"model.layers.43.mlp.up_proj.weight": "pytorch_model-00008-of-00015.bin",
|
354 |
+
"model.layers.43.post_attention_layernorm.weight": "pytorch_model-00008-of-00015.bin",
|
355 |
+
"model.layers.43.self_attn.k_proj.weight": "pytorch_model-00008-of-00015.bin",
|
356 |
+
"model.layers.43.self_attn.o_proj.weight": "pytorch_model-00008-of-00015.bin",
|
357 |
+
"model.layers.43.self_attn.q_proj.weight": "pytorch_model-00008-of-00015.bin",
|
358 |
+
"model.layers.43.self_attn.v_proj.weight": "pytorch_model-00008-of-00015.bin",
|
359 |
+
"model.layers.44.input_layernorm.weight": "pytorch_model-00008-of-00015.bin",
|
360 |
+
"model.layers.44.mlp.down_proj.weight": "pytorch_model-00008-of-00015.bin",
|
361 |
+
"model.layers.44.mlp.gate_proj.weight": "pytorch_model-00008-of-00015.bin",
|
362 |
+
"model.layers.44.mlp.up_proj.weight": "pytorch_model-00008-of-00015.bin",
|
363 |
+
"model.layers.44.post_attention_layernorm.weight": "pytorch_model-00008-of-00015.bin",
|
364 |
+
"model.layers.44.self_attn.k_proj.weight": "pytorch_model-00008-of-00015.bin",
|
365 |
+
"model.layers.44.self_attn.o_proj.weight": "pytorch_model-00008-of-00015.bin",
|
366 |
+
"model.layers.44.self_attn.q_proj.weight": "pytorch_model-00008-of-00015.bin",
|
367 |
+
"model.layers.44.self_attn.v_proj.weight": "pytorch_model-00008-of-00015.bin",
|
368 |
+
"model.layers.45.input_layernorm.weight": "pytorch_model-00009-of-00015.bin",
|
369 |
+
"model.layers.45.mlp.down_proj.weight": "pytorch_model-00009-of-00015.bin",
|
370 |
+
"model.layers.45.mlp.gate_proj.weight": "pytorch_model-00008-of-00015.bin",
|
371 |
+
"model.layers.45.mlp.up_proj.weight": "pytorch_model-00008-of-00015.bin",
|
372 |
+
"model.layers.45.post_attention_layernorm.weight": "pytorch_model-00009-of-00015.bin",
|
373 |
+
"model.layers.45.self_attn.k_proj.weight": "pytorch_model-00008-of-00015.bin",
|
374 |
+
"model.layers.45.self_attn.o_proj.weight": "pytorch_model-00008-of-00015.bin",
|
375 |
+
"model.layers.45.self_attn.q_proj.weight": "pytorch_model-00008-of-00015.bin",
|
376 |
+
"model.layers.45.self_attn.v_proj.weight": "pytorch_model-00008-of-00015.bin",
|
377 |
+
"model.layers.46.input_layernorm.weight": "pytorch_model-00009-of-00015.bin",
|
378 |
+
"model.layers.46.mlp.down_proj.weight": "pytorch_model-00009-of-00015.bin",
|
379 |
+
"model.layers.46.mlp.gate_proj.weight": "pytorch_model-00009-of-00015.bin",
|
380 |
+
"model.layers.46.mlp.up_proj.weight": "pytorch_model-00009-of-00015.bin",
|
381 |
+
"model.layers.46.post_attention_layernorm.weight": "pytorch_model-00009-of-00015.bin",
|
382 |
+
"model.layers.46.self_attn.k_proj.weight": "pytorch_model-00009-of-00015.bin",
|
383 |
+
"model.layers.46.self_attn.o_proj.weight": "pytorch_model-00009-of-00015.bin",
|
384 |
+
"model.layers.46.self_attn.q_proj.weight": "pytorch_model-00009-of-00015.bin",
|
385 |
+
"model.layers.46.self_attn.v_proj.weight": "pytorch_model-00009-of-00015.bin",
|
386 |
+
"model.layers.47.input_layernorm.weight": "pytorch_model-00009-of-00015.bin",
|
387 |
+
"model.layers.47.mlp.down_proj.weight": "pytorch_model-00009-of-00015.bin",
|
388 |
+
"model.layers.47.mlp.gate_proj.weight": "pytorch_model-00009-of-00015.bin",
|
389 |
+
"model.layers.47.mlp.up_proj.weight": "pytorch_model-00009-of-00015.bin",
|
390 |
+
"model.layers.47.post_attention_layernorm.weight": "pytorch_model-00009-of-00015.bin",
|
391 |
+
"model.layers.47.self_attn.k_proj.weight": "pytorch_model-00009-of-00015.bin",
|
392 |
+
"model.layers.47.self_attn.o_proj.weight": "pytorch_model-00009-of-00015.bin",
|
393 |
+
"model.layers.47.self_attn.q_proj.weight": "pytorch_model-00009-of-00015.bin",
|
394 |
+
"model.layers.47.self_attn.v_proj.weight": "pytorch_model-00009-of-00015.bin",
|
395 |
+
"model.layers.48.input_layernorm.weight": "pytorch_model-00009-of-00015.bin",
|
396 |
+
"model.layers.48.mlp.down_proj.weight": "pytorch_model-00009-of-00015.bin",
|
397 |
+
"model.layers.48.mlp.gate_proj.weight": "pytorch_model-00009-of-00015.bin",
|
398 |
+
"model.layers.48.mlp.up_proj.weight": "pytorch_model-00009-of-00015.bin",
|
399 |
+
"model.layers.48.post_attention_layernorm.weight": "pytorch_model-00009-of-00015.bin",
|
400 |
+
"model.layers.48.self_attn.k_proj.weight": "pytorch_model-00009-of-00015.bin",
|
401 |
+
"model.layers.48.self_attn.o_proj.weight": "pytorch_model-00009-of-00015.bin",
|
402 |
+
"model.layers.48.self_attn.q_proj.weight": "pytorch_model-00009-of-00015.bin",
|
403 |
+
"model.layers.48.self_attn.v_proj.weight": "pytorch_model-00009-of-00015.bin",
|
404 |
+
"model.layers.49.input_layernorm.weight": "pytorch_model-00009-of-00015.bin",
|
405 |
+
"model.layers.49.mlp.down_proj.weight": "pytorch_model-00009-of-00015.bin",
|
406 |
+
"model.layers.49.mlp.gate_proj.weight": "pytorch_model-00009-of-00015.bin",
|
407 |
+
"model.layers.49.mlp.up_proj.weight": "pytorch_model-00009-of-00015.bin",
|
408 |
+
"model.layers.49.post_attention_layernorm.weight": "pytorch_model-00009-of-00015.bin",
|
409 |
+
"model.layers.49.self_attn.k_proj.weight": "pytorch_model-00009-of-00015.bin",
|
410 |
+
"model.layers.49.self_attn.o_proj.weight": "pytorch_model-00009-of-00015.bin",
|
411 |
+
"model.layers.49.self_attn.q_proj.weight": "pytorch_model-00009-of-00015.bin",
|
412 |
+
"model.layers.49.self_attn.v_proj.weight": "pytorch_model-00009-of-00015.bin",
|
413 |
+
"model.layers.5.input_layernorm.weight": "pytorch_model-00002-of-00015.bin",
|
414 |
+
"model.layers.5.mlp.down_proj.weight": "pytorch_model-00002-of-00015.bin",
|
415 |
+
"model.layers.5.mlp.gate_proj.weight": "pytorch_model-00001-of-00015.bin",
|
416 |
+
"model.layers.5.mlp.up_proj.weight": "pytorch_model-00002-of-00015.bin",
|
417 |
+
"model.layers.5.post_attention_layernorm.weight": "pytorch_model-00002-of-00015.bin",
|
418 |
+
"model.layers.5.self_attn.k_proj.weight": "pytorch_model-00001-of-00015.bin",
|
419 |
+
"model.layers.5.self_attn.o_proj.weight": "pytorch_model-00001-of-00015.bin",
|
420 |
+
"model.layers.5.self_attn.q_proj.weight": "pytorch_model-00001-of-00015.bin",
|
421 |
+
"model.layers.5.self_attn.v_proj.weight": "pytorch_model-00001-of-00015.bin",
|
422 |
+
"model.layers.50.input_layernorm.weight": "pytorch_model-00009-of-00015.bin",
|
423 |
+
"model.layers.50.mlp.down_proj.weight": "pytorch_model-00009-of-00015.bin",
|
424 |
+
"model.layers.50.mlp.gate_proj.weight": "pytorch_model-00009-of-00015.bin",
|
425 |
+
"model.layers.50.mlp.up_proj.weight": "pytorch_model-00009-of-00015.bin",
|
426 |
+
"model.layers.50.post_attention_layernorm.weight": "pytorch_model-00009-of-00015.bin",
|
427 |
+
"model.layers.50.self_attn.k_proj.weight": "pytorch_model-00009-of-00015.bin",
|
428 |
+
"model.layers.50.self_attn.o_proj.weight": "pytorch_model-00009-of-00015.bin",
|
429 |
+
"model.layers.50.self_attn.q_proj.weight": "pytorch_model-00009-of-00015.bin",
|
430 |
+
"model.layers.50.self_attn.v_proj.weight": "pytorch_model-00009-of-00015.bin",
|
431 |
+
"model.layers.51.input_layernorm.weight": "pytorch_model-00010-of-00015.bin",
|
432 |
+
"model.layers.51.mlp.down_proj.weight": "pytorch_model-00010-of-00015.bin",
|
433 |
+
"model.layers.51.mlp.gate_proj.weight": "pytorch_model-00009-of-00015.bin",
|
434 |
+
"model.layers.51.mlp.up_proj.weight": "pytorch_model-00010-of-00015.bin",
|
435 |
+
"model.layers.51.post_attention_layernorm.weight": "pytorch_model-00010-of-00015.bin",
|
436 |
+
"model.layers.51.self_attn.k_proj.weight": "pytorch_model-00009-of-00015.bin",
|
437 |
+
"model.layers.51.self_attn.o_proj.weight": "pytorch_model-00009-of-00015.bin",
|
438 |
+
"model.layers.51.self_attn.q_proj.weight": "pytorch_model-00009-of-00015.bin",
|
439 |
+
"model.layers.51.self_attn.v_proj.weight": "pytorch_model-00009-of-00015.bin",
|
440 |
+
"model.layers.52.input_layernorm.weight": "pytorch_model-00010-of-00015.bin",
|
441 |
+
"model.layers.52.mlp.down_proj.weight": "pytorch_model-00010-of-00015.bin",
|
442 |
+
"model.layers.52.mlp.gate_proj.weight": "pytorch_model-00010-of-00015.bin",
|
443 |
+
"model.layers.52.mlp.up_proj.weight": "pytorch_model-00010-of-00015.bin",
|
444 |
+
"model.layers.52.post_attention_layernorm.weight": "pytorch_model-00010-of-00015.bin",
|
445 |
+
"model.layers.52.self_attn.k_proj.weight": "pytorch_model-00010-of-00015.bin",
|
446 |
+
"model.layers.52.self_attn.o_proj.weight": "pytorch_model-00010-of-00015.bin",
|
447 |
+
"model.layers.52.self_attn.q_proj.weight": "pytorch_model-00010-of-00015.bin",
|
448 |
+
"model.layers.52.self_attn.v_proj.weight": "pytorch_model-00010-of-00015.bin",
|
449 |
+
"model.layers.53.input_layernorm.weight": "pytorch_model-00010-of-00015.bin",
|
450 |
+
"model.layers.53.mlp.down_proj.weight": "pytorch_model-00010-of-00015.bin",
|
451 |
+
"model.layers.53.mlp.gate_proj.weight": "pytorch_model-00010-of-00015.bin",
|
452 |
+
"model.layers.53.mlp.up_proj.weight": "pytorch_model-00010-of-00015.bin",
|
453 |
+
"model.layers.53.post_attention_layernorm.weight": "pytorch_model-00010-of-00015.bin",
|
454 |
+
"model.layers.53.self_attn.k_proj.weight": "pytorch_model-00010-of-00015.bin",
|
455 |
+
"model.layers.53.self_attn.o_proj.weight": "pytorch_model-00010-of-00015.bin",
|
456 |
+
"model.layers.53.self_attn.q_proj.weight": "pytorch_model-00010-of-00015.bin",
|
457 |
+
"model.layers.53.self_attn.v_proj.weight": "pytorch_model-00010-of-00015.bin",
|
458 |
+
"model.layers.54.input_layernorm.weight": "pytorch_model-00010-of-00015.bin",
|
459 |
+
"model.layers.54.mlp.down_proj.weight": "pytorch_model-00010-of-00015.bin",
|
460 |
+
"model.layers.54.mlp.gate_proj.weight": "pytorch_model-00010-of-00015.bin",
|
461 |
+
"model.layers.54.mlp.up_proj.weight": "pytorch_model-00010-of-00015.bin",
|
462 |
+
"model.layers.54.post_attention_layernorm.weight": "pytorch_model-00010-of-00015.bin",
|
463 |
+
"model.layers.54.self_attn.k_proj.weight": "pytorch_model-00010-of-00015.bin",
|
464 |
+
"model.layers.54.self_attn.o_proj.weight": "pytorch_model-00010-of-00015.bin",
|
465 |
+
"model.layers.54.self_attn.q_proj.weight": "pytorch_model-00010-of-00015.bin",
|
466 |
+
"model.layers.54.self_attn.v_proj.weight": "pytorch_model-00010-of-00015.bin",
|
467 |
+
"model.layers.55.input_layernorm.weight": "pytorch_model-00010-of-00015.bin",
|
468 |
+
"model.layers.55.mlp.down_proj.weight": "pytorch_model-00010-of-00015.bin",
|
469 |
+
"model.layers.55.mlp.gate_proj.weight": "pytorch_model-00010-of-00015.bin",
|
470 |
+
"model.layers.55.mlp.up_proj.weight": "pytorch_model-00010-of-00015.bin",
|
471 |
+
"model.layers.55.post_attention_layernorm.weight": "pytorch_model-00010-of-00015.bin",
|
472 |
+
"model.layers.55.self_attn.k_proj.weight": "pytorch_model-00010-of-00015.bin",
|
473 |
+
"model.layers.55.self_attn.o_proj.weight": "pytorch_model-00010-of-00015.bin",
|
474 |
+
"model.layers.55.self_attn.q_proj.weight": "pytorch_model-00010-of-00015.bin",
|
475 |
+
"model.layers.55.self_attn.v_proj.weight": "pytorch_model-00010-of-00015.bin",
|
476 |
+
"model.layers.56.input_layernorm.weight": "pytorch_model-00010-of-00015.bin",
|
477 |
+
"model.layers.56.mlp.down_proj.weight": "pytorch_model-00010-of-00015.bin",
|
478 |
+
"model.layers.56.mlp.gate_proj.weight": "pytorch_model-00010-of-00015.bin",
|
479 |
+
"model.layers.56.mlp.up_proj.weight": "pytorch_model-00010-of-00015.bin",
|
480 |
+
"model.layers.56.post_attention_layernorm.weight": "pytorch_model-00010-of-00015.bin",
|
481 |
+
"model.layers.56.self_attn.k_proj.weight": "pytorch_model-00010-of-00015.bin",
|
482 |
+
"model.layers.56.self_attn.o_proj.weight": "pytorch_model-00010-of-00015.bin",
|
483 |
+
"model.layers.56.self_attn.q_proj.weight": "pytorch_model-00010-of-00015.bin",
|
484 |
+
"model.layers.56.self_attn.v_proj.weight": "pytorch_model-00010-of-00015.bin",
|
485 |
+
"model.layers.57.input_layernorm.weight": "pytorch_model-00011-of-00015.bin",
|
486 |
+
"model.layers.57.mlp.down_proj.weight": "pytorch_model-00011-of-00015.bin",
|
487 |
+
"model.layers.57.mlp.gate_proj.weight": "pytorch_model-00011-of-00015.bin",
|
488 |
+
"model.layers.57.mlp.up_proj.weight": "pytorch_model-00011-of-00015.bin",
|
489 |
+
"model.layers.57.post_attention_layernorm.weight": "pytorch_model-00011-of-00015.bin",
|
490 |
+
"model.layers.57.self_attn.k_proj.weight": "pytorch_model-00010-of-00015.bin",
|
491 |
+
"model.layers.57.self_attn.o_proj.weight": "pytorch_model-00010-of-00015.bin",
|
492 |
+
"model.layers.57.self_attn.q_proj.weight": "pytorch_model-00010-of-00015.bin",
|
493 |
+
"model.layers.57.self_attn.v_proj.weight": "pytorch_model-00010-of-00015.bin",
|
494 |
+
"model.layers.58.input_layernorm.weight": "pytorch_model-00011-of-00015.bin",
|
495 |
+
"model.layers.58.mlp.down_proj.weight": "pytorch_model-00011-of-00015.bin",
|
496 |
+
"model.layers.58.mlp.gate_proj.weight": "pytorch_model-00011-of-00015.bin",
|
497 |
+
"model.layers.58.mlp.up_proj.weight": "pytorch_model-00011-of-00015.bin",
|
498 |
+
"model.layers.58.post_attention_layernorm.weight": "pytorch_model-00011-of-00015.bin",
|
499 |
+
"model.layers.58.self_attn.k_proj.weight": "pytorch_model-00011-of-00015.bin",
|
500 |
+
"model.layers.58.self_attn.o_proj.weight": "pytorch_model-00011-of-00015.bin",
|
501 |
+
"model.layers.58.self_attn.q_proj.weight": "pytorch_model-00011-of-00015.bin",
|
502 |
+
"model.layers.58.self_attn.v_proj.weight": "pytorch_model-00011-of-00015.bin",
|
503 |
+
"model.layers.59.input_layernorm.weight": "pytorch_model-00011-of-00015.bin",
|
504 |
+
"model.layers.59.mlp.down_proj.weight": "pytorch_model-00011-of-00015.bin",
|
505 |
+
"model.layers.59.mlp.gate_proj.weight": "pytorch_model-00011-of-00015.bin",
|
506 |
+
"model.layers.59.mlp.up_proj.weight": "pytorch_model-00011-of-00015.bin",
|
507 |
+
"model.layers.59.post_attention_layernorm.weight": "pytorch_model-00011-of-00015.bin",
|
508 |
+
"model.layers.59.self_attn.k_proj.weight": "pytorch_model-00011-of-00015.bin",
|
509 |
+
"model.layers.59.self_attn.o_proj.weight": "pytorch_model-00011-of-00015.bin",
|
510 |
+
"model.layers.59.self_attn.q_proj.weight": "pytorch_model-00011-of-00015.bin",
|
511 |
+
"model.layers.59.self_attn.v_proj.weight": "pytorch_model-00011-of-00015.bin",
|
512 |
+
"model.layers.6.input_layernorm.weight": "pytorch_model-00002-of-00015.bin",
|
513 |
+
"model.layers.6.mlp.down_proj.weight": "pytorch_model-00002-of-00015.bin",
|
514 |
+
"model.layers.6.mlp.gate_proj.weight": "pytorch_model-00002-of-00015.bin",
|
515 |
+
"model.layers.6.mlp.up_proj.weight": "pytorch_model-00002-of-00015.bin",
|
516 |
+
"model.layers.6.post_attention_layernorm.weight": "pytorch_model-00002-of-00015.bin",
|
517 |
+
"model.layers.6.self_attn.k_proj.weight": "pytorch_model-00002-of-00015.bin",
|
518 |
+
"model.layers.6.self_attn.o_proj.weight": "pytorch_model-00002-of-00015.bin",
|
519 |
+
"model.layers.6.self_attn.q_proj.weight": "pytorch_model-00002-of-00015.bin",
|
520 |
+
"model.layers.6.self_attn.v_proj.weight": "pytorch_model-00002-of-00015.bin",
|
521 |
+
"model.layers.60.input_layernorm.weight": "pytorch_model-00011-of-00015.bin",
|
522 |
+
"model.layers.60.mlp.down_proj.weight": "pytorch_model-00011-of-00015.bin",
|
523 |
+
"model.layers.60.mlp.gate_proj.weight": "pytorch_model-00011-of-00015.bin",
|
524 |
+
"model.layers.60.mlp.up_proj.weight": "pytorch_model-00011-of-00015.bin",
|
525 |
+
"model.layers.60.post_attention_layernorm.weight": "pytorch_model-00011-of-00015.bin",
|
526 |
+
"model.layers.60.self_attn.k_proj.weight": "pytorch_model-00011-of-00015.bin",
|
527 |
+
"model.layers.60.self_attn.o_proj.weight": "pytorch_model-00011-of-00015.bin",
|
528 |
+
"model.layers.60.self_attn.q_proj.weight": "pytorch_model-00011-of-00015.bin",
|
529 |
+
"model.layers.60.self_attn.v_proj.weight": "pytorch_model-00011-of-00015.bin",
|
530 |
+
"model.layers.61.input_layernorm.weight": "pytorch_model-00011-of-00015.bin",
|
531 |
+
"model.layers.61.mlp.down_proj.weight": "pytorch_model-00011-of-00015.bin",
|
532 |
+
"model.layers.61.mlp.gate_proj.weight": "pytorch_model-00011-of-00015.bin",
|
533 |
+
"model.layers.61.mlp.up_proj.weight": "pytorch_model-00011-of-00015.bin",
|
534 |
+
"model.layers.61.post_attention_layernorm.weight": "pytorch_model-00011-of-00015.bin",
|
535 |
+
"model.layers.61.self_attn.k_proj.weight": "pytorch_model-00011-of-00015.bin",
|
536 |
+
"model.layers.61.self_attn.o_proj.weight": "pytorch_model-00011-of-00015.bin",
|
537 |
+
"model.layers.61.self_attn.q_proj.weight": "pytorch_model-00011-of-00015.bin",
|
538 |
+
"model.layers.61.self_attn.v_proj.weight": "pytorch_model-00011-of-00015.bin",
|
539 |
+
"model.layers.62.input_layernorm.weight": "pytorch_model-00011-of-00015.bin",
|
540 |
+
"model.layers.62.mlp.down_proj.weight": "pytorch_model-00011-of-00015.bin",
|
541 |
+
"model.layers.62.mlp.gate_proj.weight": "pytorch_model-00011-of-00015.bin",
|
542 |
+
"model.layers.62.mlp.up_proj.weight": "pytorch_model-00011-of-00015.bin",
|
543 |
+
"model.layers.62.post_attention_layernorm.weight": "pytorch_model-00011-of-00015.bin",
|
544 |
+
"model.layers.62.self_attn.k_proj.weight": "pytorch_model-00011-of-00015.bin",
|
545 |
+
"model.layers.62.self_attn.o_proj.weight": "pytorch_model-00011-of-00015.bin",
|
546 |
+
"model.layers.62.self_attn.q_proj.weight": "pytorch_model-00011-of-00015.bin",
|
547 |
+
"model.layers.62.self_attn.v_proj.weight": "pytorch_model-00011-of-00015.bin",
|
548 |
+
"model.layers.63.input_layernorm.weight": "pytorch_model-00012-of-00015.bin",
|
549 |
+
"model.layers.63.mlp.down_proj.weight": "pytorch_model-00012-of-00015.bin",
|
550 |
+
"model.layers.63.mlp.gate_proj.weight": "pytorch_model-00012-of-00015.bin",
|
551 |
+
"model.layers.63.mlp.up_proj.weight": "pytorch_model-00012-of-00015.bin",
|
552 |
+
"model.layers.63.post_attention_layernorm.weight": "pytorch_model-00012-of-00015.bin",
|
553 |
+
"model.layers.63.self_attn.k_proj.weight": "pytorch_model-00012-of-00015.bin",
|
554 |
+
"model.layers.63.self_attn.o_proj.weight": "pytorch_model-00012-of-00015.bin",
|
555 |
+
"model.layers.63.self_attn.q_proj.weight": "pytorch_model-00012-of-00015.bin",
|
556 |
+
"model.layers.63.self_attn.v_proj.weight": "pytorch_model-00012-of-00015.bin",
|
557 |
+
"model.layers.64.input_layernorm.weight": "pytorch_model-00012-of-00015.bin",
|
558 |
+
"model.layers.64.mlp.down_proj.weight": "pytorch_model-00012-of-00015.bin",
|
559 |
+
"model.layers.64.mlp.gate_proj.weight": "pytorch_model-00012-of-00015.bin",
|
560 |
+
"model.layers.64.mlp.up_proj.weight": "pytorch_model-00012-of-00015.bin",
|
561 |
+
"model.layers.64.post_attention_layernorm.weight": "pytorch_model-00012-of-00015.bin",
|
562 |
+
"model.layers.64.self_attn.k_proj.weight": "pytorch_model-00012-of-00015.bin",
|
563 |
+
"model.layers.64.self_attn.o_proj.weight": "pytorch_model-00012-of-00015.bin",
|
564 |
+
"model.layers.64.self_attn.q_proj.weight": "pytorch_model-00012-of-00015.bin",
|
565 |
+
"model.layers.64.self_attn.v_proj.weight": "pytorch_model-00012-of-00015.bin",
|
566 |
+
"model.layers.65.input_layernorm.weight": "pytorch_model-00012-of-00015.bin",
|
567 |
+
"model.layers.65.mlp.down_proj.weight": "pytorch_model-00012-of-00015.bin",
|
568 |
+
"model.layers.65.mlp.gate_proj.weight": "pytorch_model-00012-of-00015.bin",
|
569 |
+
"model.layers.65.mlp.up_proj.weight": "pytorch_model-00012-of-00015.bin",
|
570 |
+
"model.layers.65.post_attention_layernorm.weight": "pytorch_model-00012-of-00015.bin",
|
571 |
+
"model.layers.65.self_attn.k_proj.weight": "pytorch_model-00012-of-00015.bin",
|
572 |
+
"model.layers.65.self_attn.o_proj.weight": "pytorch_model-00012-of-00015.bin",
|
573 |
+
"model.layers.65.self_attn.q_proj.weight": "pytorch_model-00012-of-00015.bin",
|
574 |
+
"model.layers.65.self_attn.v_proj.weight": "pytorch_model-00012-of-00015.bin",
|
575 |
+
"model.layers.66.input_layernorm.weight": "pytorch_model-00012-of-00015.bin",
|
576 |
+
"model.layers.66.mlp.down_proj.weight": "pytorch_model-00012-of-00015.bin",
|
577 |
+
"model.layers.66.mlp.gate_proj.weight": "pytorch_model-00012-of-00015.bin",
|
578 |
+
"model.layers.66.mlp.up_proj.weight": "pytorch_model-00012-of-00015.bin",
|
579 |
+
"model.layers.66.post_attention_layernorm.weight": "pytorch_model-00012-of-00015.bin",
|
580 |
+
"model.layers.66.self_attn.k_proj.weight": "pytorch_model-00012-of-00015.bin",
|
581 |
+
"model.layers.66.self_attn.o_proj.weight": "pytorch_model-00012-of-00015.bin",
|
582 |
+
"model.layers.66.self_attn.q_proj.weight": "pytorch_model-00012-of-00015.bin",
|
583 |
+
"model.layers.66.self_attn.v_proj.weight": "pytorch_model-00012-of-00015.bin",
|
584 |
+
"model.layers.67.input_layernorm.weight": "pytorch_model-00012-of-00015.bin",
|
585 |
+
"model.layers.67.mlp.down_proj.weight": "pytorch_model-00012-of-00015.bin",
|
586 |
+
"model.layers.67.mlp.gate_proj.weight": "pytorch_model-00012-of-00015.bin",
|
587 |
+
"model.layers.67.mlp.up_proj.weight": "pytorch_model-00012-of-00015.bin",
|
588 |
+
"model.layers.67.post_attention_layernorm.weight": "pytorch_model-00012-of-00015.bin",
|
589 |
+
"model.layers.67.self_attn.k_proj.weight": "pytorch_model-00012-of-00015.bin",
|
590 |
+
"model.layers.67.self_attn.o_proj.weight": "pytorch_model-00012-of-00015.bin",
|
591 |
+
"model.layers.67.self_attn.q_proj.weight": "pytorch_model-00012-of-00015.bin",
|
592 |
+
"model.layers.67.self_attn.v_proj.weight": "pytorch_model-00012-of-00015.bin",
|
593 |
+
"model.layers.68.input_layernorm.weight": "pytorch_model-00013-of-00015.bin",
|
594 |
+
"model.layers.68.mlp.down_proj.weight": "pytorch_model-00013-of-00015.bin",
|
595 |
+
"model.layers.68.mlp.gate_proj.weight": "pytorch_model-00012-of-00015.bin",
|
596 |
+
"model.layers.68.mlp.up_proj.weight": "pytorch_model-00012-of-00015.bin",
|
597 |
+
"model.layers.68.post_attention_layernorm.weight": "pytorch_model-00013-of-00015.bin",
|
598 |
+
"model.layers.68.self_attn.k_proj.weight": "pytorch_model-00012-of-00015.bin",
|
599 |
+
"model.layers.68.self_attn.o_proj.weight": "pytorch_model-00012-of-00015.bin",
|
600 |
+
"model.layers.68.self_attn.q_proj.weight": "pytorch_model-00012-of-00015.bin",
|
601 |
+
"model.layers.68.self_attn.v_proj.weight": "pytorch_model-00012-of-00015.bin",
|
602 |
+
"model.layers.69.input_layernorm.weight": "pytorch_model-00013-of-00015.bin",
|
603 |
+
"model.layers.69.mlp.down_proj.weight": "pytorch_model-00013-of-00015.bin",
|
604 |
+
"model.layers.69.mlp.gate_proj.weight": "pytorch_model-00013-of-00015.bin",
|
605 |
+
"model.layers.69.mlp.up_proj.weight": "pytorch_model-00013-of-00015.bin",
|
606 |
+
"model.layers.69.post_attention_layernorm.weight": "pytorch_model-00013-of-00015.bin",
|
607 |
+
"model.layers.69.self_attn.k_proj.weight": "pytorch_model-00013-of-00015.bin",
|
608 |
+
"model.layers.69.self_attn.o_proj.weight": "pytorch_model-00013-of-00015.bin",
|
609 |
+
"model.layers.69.self_attn.q_proj.weight": "pytorch_model-00013-of-00015.bin",
|
610 |
+
"model.layers.69.self_attn.v_proj.weight": "pytorch_model-00013-of-00015.bin",
|
611 |
+
"model.layers.7.input_layernorm.weight": "pytorch_model-00002-of-00015.bin",
|
612 |
+
"model.layers.7.mlp.down_proj.weight": "pytorch_model-00002-of-00015.bin",
|
613 |
+
"model.layers.7.mlp.gate_proj.weight": "pytorch_model-00002-of-00015.bin",
|
614 |
+
"model.layers.7.mlp.up_proj.weight": "pytorch_model-00002-of-00015.bin",
|
615 |
+
"model.layers.7.post_attention_layernorm.weight": "pytorch_model-00002-of-00015.bin",
|
616 |
+
"model.layers.7.self_attn.k_proj.weight": "pytorch_model-00002-of-00015.bin",
|
617 |
+
"model.layers.7.self_attn.o_proj.weight": "pytorch_model-00002-of-00015.bin",
|
618 |
+
"model.layers.7.self_attn.q_proj.weight": "pytorch_model-00002-of-00015.bin",
|
619 |
+
"model.layers.7.self_attn.v_proj.weight": "pytorch_model-00002-of-00015.bin",
|
620 |
+
"model.layers.70.input_layernorm.weight": "pytorch_model-00013-of-00015.bin",
|
621 |
+
"model.layers.70.mlp.down_proj.weight": "pytorch_model-00013-of-00015.bin",
|
622 |
+
"model.layers.70.mlp.gate_proj.weight": "pytorch_model-00013-of-00015.bin",
|
623 |
+
"model.layers.70.mlp.up_proj.weight": "pytorch_model-00013-of-00015.bin",
|
624 |
+
"model.layers.70.post_attention_layernorm.weight": "pytorch_model-00013-of-00015.bin",
|
625 |
+
"model.layers.70.self_attn.k_proj.weight": "pytorch_model-00013-of-00015.bin",
|
626 |
+
"model.layers.70.self_attn.o_proj.weight": "pytorch_model-00013-of-00015.bin",
|
627 |
+
"model.layers.70.self_attn.q_proj.weight": "pytorch_model-00013-of-00015.bin",
|
628 |
+
"model.layers.70.self_attn.v_proj.weight": "pytorch_model-00013-of-00015.bin",
|
629 |
+
"model.layers.71.input_layernorm.weight": "pytorch_model-00013-of-00015.bin",
|
630 |
+
"model.layers.71.mlp.down_proj.weight": "pytorch_model-00013-of-00015.bin",
|
631 |
+
"model.layers.71.mlp.gate_proj.weight": "pytorch_model-00013-of-00015.bin",
|
632 |
+
"model.layers.71.mlp.up_proj.weight": "pytorch_model-00013-of-00015.bin",
|
633 |
+
"model.layers.71.post_attention_layernorm.weight": "pytorch_model-00013-of-00015.bin",
|
634 |
+
"model.layers.71.self_attn.k_proj.weight": "pytorch_model-00013-of-00015.bin",
|
635 |
+
"model.layers.71.self_attn.o_proj.weight": "pytorch_model-00013-of-00015.bin",
|
636 |
+
"model.layers.71.self_attn.q_proj.weight": "pytorch_model-00013-of-00015.bin",
|
637 |
+
"model.layers.71.self_attn.v_proj.weight": "pytorch_model-00013-of-00015.bin",
|
638 |
+
"model.layers.72.input_layernorm.weight": "pytorch_model-00013-of-00015.bin",
|
639 |
+
"model.layers.72.mlp.down_proj.weight": "pytorch_model-00013-of-00015.bin",
|
640 |
+
"model.layers.72.mlp.gate_proj.weight": "pytorch_model-00013-of-00015.bin",
|
641 |
+
"model.layers.72.mlp.up_proj.weight": "pytorch_model-00013-of-00015.bin",
|
642 |
+
"model.layers.72.post_attention_layernorm.weight": "pytorch_model-00013-of-00015.bin",
|
643 |
+
"model.layers.72.self_attn.k_proj.weight": "pytorch_model-00013-of-00015.bin",
|
644 |
+
"model.layers.72.self_attn.o_proj.weight": "pytorch_model-00013-of-00015.bin",
|
645 |
+
"model.layers.72.self_attn.q_proj.weight": "pytorch_model-00013-of-00015.bin",
|
646 |
+
"model.layers.72.self_attn.v_proj.weight": "pytorch_model-00013-of-00015.bin",
|
647 |
+
"model.layers.73.input_layernorm.weight": "pytorch_model-00013-of-00015.bin",
|
648 |
+
"model.layers.73.mlp.down_proj.weight": "pytorch_model-00013-of-00015.bin",
|
649 |
+
"model.layers.73.mlp.gate_proj.weight": "pytorch_model-00013-of-00015.bin",
|
650 |
+
"model.layers.73.mlp.up_proj.weight": "pytorch_model-00013-of-00015.bin",
|
651 |
+
"model.layers.73.post_attention_layernorm.weight": "pytorch_model-00013-of-00015.bin",
|
652 |
+
"model.layers.73.self_attn.k_proj.weight": "pytorch_model-00013-of-00015.bin",
|
653 |
+
"model.layers.73.self_attn.o_proj.weight": "pytorch_model-00013-of-00015.bin",
|
654 |
+
"model.layers.73.self_attn.q_proj.weight": "pytorch_model-00013-of-00015.bin",
|
655 |
+
"model.layers.73.self_attn.v_proj.weight": "pytorch_model-00013-of-00015.bin",
|
656 |
+
"model.layers.74.input_layernorm.weight": "pytorch_model-00014-of-00015.bin",
|
657 |
+
"model.layers.74.mlp.down_proj.weight": "pytorch_model-00014-of-00015.bin",
|
658 |
+
"model.layers.74.mlp.gate_proj.weight": "pytorch_model-00013-of-00015.bin",
|
659 |
+
"model.layers.74.mlp.up_proj.weight": "pytorch_model-00014-of-00015.bin",
|
660 |
+
"model.layers.74.post_attention_layernorm.weight": "pytorch_model-00014-of-00015.bin",
|
661 |
+
"model.layers.74.self_attn.k_proj.weight": "pytorch_model-00013-of-00015.bin",
|
662 |
+
"model.layers.74.self_attn.o_proj.weight": "pytorch_model-00013-of-00015.bin",
|
663 |
+
"model.layers.74.self_attn.q_proj.weight": "pytorch_model-00013-of-00015.bin",
|
664 |
+
"model.layers.74.self_attn.v_proj.weight": "pytorch_model-00013-of-00015.bin",
|
665 |
+
"model.layers.75.input_layernorm.weight": "pytorch_model-00014-of-00015.bin",
|
666 |
+
"model.layers.75.mlp.down_proj.weight": "pytorch_model-00014-of-00015.bin",
|
667 |
+
"model.layers.75.mlp.gate_proj.weight": "pytorch_model-00014-of-00015.bin",
|
668 |
+
"model.layers.75.mlp.up_proj.weight": "pytorch_model-00014-of-00015.bin",
|
669 |
+
"model.layers.75.post_attention_layernorm.weight": "pytorch_model-00014-of-00015.bin",
|
670 |
+
"model.layers.75.self_attn.k_proj.weight": "pytorch_model-00014-of-00015.bin",
|
671 |
+
"model.layers.75.self_attn.o_proj.weight": "pytorch_model-00014-of-00015.bin",
|
672 |
+
"model.layers.75.self_attn.q_proj.weight": "pytorch_model-00014-of-00015.bin",
|
673 |
+
"model.layers.75.self_attn.v_proj.weight": "pytorch_model-00014-of-00015.bin",
|
674 |
+
"model.layers.76.input_layernorm.weight": "pytorch_model-00014-of-00015.bin",
|
675 |
+
"model.layers.76.mlp.down_proj.weight": "pytorch_model-00014-of-00015.bin",
|
676 |
+
"model.layers.76.mlp.gate_proj.weight": "pytorch_model-00014-of-00015.bin",
|
677 |
+
"model.layers.76.mlp.up_proj.weight": "pytorch_model-00014-of-00015.bin",
|
678 |
+
"model.layers.76.post_attention_layernorm.weight": "pytorch_model-00014-of-00015.bin",
|
679 |
+
"model.layers.76.self_attn.k_proj.weight": "pytorch_model-00014-of-00015.bin",
|
680 |
+
"model.layers.76.self_attn.o_proj.weight": "pytorch_model-00014-of-00015.bin",
|
681 |
+
"model.layers.76.self_attn.q_proj.weight": "pytorch_model-00014-of-00015.bin",
|
682 |
+
"model.layers.76.self_attn.v_proj.weight": "pytorch_model-00014-of-00015.bin",
|
683 |
+
"model.layers.77.input_layernorm.weight": "pytorch_model-00014-of-00015.bin",
|
684 |
+
"model.layers.77.mlp.down_proj.weight": "pytorch_model-00014-of-00015.bin",
|
685 |
+
"model.layers.77.mlp.gate_proj.weight": "pytorch_model-00014-of-00015.bin",
|
686 |
+
"model.layers.77.mlp.up_proj.weight": "pytorch_model-00014-of-00015.bin",
|
687 |
+
"model.layers.77.post_attention_layernorm.weight": "pytorch_model-00014-of-00015.bin",
|
688 |
+
"model.layers.77.self_attn.k_proj.weight": "pytorch_model-00014-of-00015.bin",
|
689 |
+
"model.layers.77.self_attn.o_proj.weight": "pytorch_model-00014-of-00015.bin",
|
690 |
+
"model.layers.77.self_attn.q_proj.weight": "pytorch_model-00014-of-00015.bin",
|
691 |
+
"model.layers.77.self_attn.v_proj.weight": "pytorch_model-00014-of-00015.bin",
|
692 |
+
"model.layers.78.input_layernorm.weight": "pytorch_model-00014-of-00015.bin",
|
693 |
+
"model.layers.78.mlp.down_proj.weight": "pytorch_model-00014-of-00015.bin",
|
694 |
+
"model.layers.78.mlp.gate_proj.weight": "pytorch_model-00014-of-00015.bin",
|
695 |
+
"model.layers.78.mlp.up_proj.weight": "pytorch_model-00014-of-00015.bin",
|
696 |
+
"model.layers.78.post_attention_layernorm.weight": "pytorch_model-00014-of-00015.bin",
|
697 |
+
"model.layers.78.self_attn.k_proj.weight": "pytorch_model-00014-of-00015.bin",
|
698 |
+
"model.layers.78.self_attn.o_proj.weight": "pytorch_model-00014-of-00015.bin",
|
699 |
+
"model.layers.78.self_attn.q_proj.weight": "pytorch_model-00014-of-00015.bin",
|
700 |
+
"model.layers.78.self_attn.v_proj.weight": "pytorch_model-00014-of-00015.bin",
|
701 |
+
"model.layers.79.input_layernorm.weight": "pytorch_model-00014-of-00015.bin",
|
702 |
+
"model.layers.79.mlp.down_proj.weight": "pytorch_model-00014-of-00015.bin",
|
703 |
+
"model.layers.79.mlp.gate_proj.weight": "pytorch_model-00014-of-00015.bin",
|
704 |
+
"model.layers.79.mlp.up_proj.weight": "pytorch_model-00014-of-00015.bin",
|
705 |
+
"model.layers.79.post_attention_layernorm.weight": "pytorch_model-00014-of-00015.bin",
|
706 |
+
"model.layers.79.self_attn.k_proj.weight": "pytorch_model-00014-of-00015.bin",
|
707 |
+
"model.layers.79.self_attn.o_proj.weight": "pytorch_model-00014-of-00015.bin",
|
708 |
+
"model.layers.79.self_attn.q_proj.weight": "pytorch_model-00014-of-00015.bin",
|
709 |
+
"model.layers.79.self_attn.v_proj.weight": "pytorch_model-00014-of-00015.bin",
|
710 |
+
"model.layers.8.input_layernorm.weight": "pytorch_model-00002-of-00015.bin",
|
711 |
+
"model.layers.8.mlp.down_proj.weight": "pytorch_model-00002-of-00015.bin",
|
712 |
+
"model.layers.8.mlp.gate_proj.weight": "pytorch_model-00002-of-00015.bin",
|
713 |
+
"model.layers.8.mlp.up_proj.weight": "pytorch_model-00002-of-00015.bin",
|
714 |
+
"model.layers.8.post_attention_layernorm.weight": "pytorch_model-00002-of-00015.bin",
|
715 |
+
"model.layers.8.self_attn.k_proj.weight": "pytorch_model-00002-of-00015.bin",
|
716 |
+
"model.layers.8.self_attn.o_proj.weight": "pytorch_model-00002-of-00015.bin",
|
717 |
+
"model.layers.8.self_attn.q_proj.weight": "pytorch_model-00002-of-00015.bin",
|
718 |
+
"model.layers.8.self_attn.v_proj.weight": "pytorch_model-00002-of-00015.bin",
|
719 |
+
"model.layers.9.input_layernorm.weight": "pytorch_model-00002-of-00015.bin",
|
720 |
+
"model.layers.9.mlp.down_proj.weight": "pytorch_model-00002-of-00015.bin",
|
721 |
+
"model.layers.9.mlp.gate_proj.weight": "pytorch_model-00002-of-00015.bin",
|
722 |
+
"model.layers.9.mlp.up_proj.weight": "pytorch_model-00002-of-00015.bin",
|
723 |
+
"model.layers.9.post_attention_layernorm.weight": "pytorch_model-00002-of-00015.bin",
|
724 |
+
"model.layers.9.self_attn.k_proj.weight": "pytorch_model-00002-of-00015.bin",
|
725 |
+
"model.layers.9.self_attn.o_proj.weight": "pytorch_model-00002-of-00015.bin",
|
726 |
+
"model.layers.9.self_attn.q_proj.weight": "pytorch_model-00002-of-00015.bin",
|
727 |
+
"model.layers.9.self_attn.v_proj.weight": "pytorch_model-00002-of-00015.bin",
|
728 |
+
"model.norm.weight": "pytorch_model-00014-of-00015.bin"
|
729 |
+
}
|
730 |
+
}
|
special_tokens_map.json
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"bos_token": "<s>",
|
3 |
+
"eos_token": "</s>",
|
4 |
+
"unk_token": "<unk>"
|
5 |
+
}
|
tokenizer.json
ADDED
The diff for this file is too large to render.
See raw diff
|
|
tokenizer.model
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:9e556afd44213b6bd1be2b850ebbbd98f5481437a8021afaf58ee7fb1818d347
|
3 |
+
size 499723
|
tokenizer_config.json
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"added_tokens_decoder": {
|
3 |
+
"0": {
|
4 |
+
"content": "<unk>",
|
5 |
+
"lstrip": false,
|
6 |
+
"normalized": false,
|
7 |
+
"rstrip": false,
|
8 |
+
"single_word": false,
|
9 |
+
"special": true
|
10 |
+
},
|
11 |
+
"1": {
|
12 |
+
"content": "<s>",
|
13 |
+
"lstrip": false,
|
14 |
+
"normalized": false,
|
15 |
+
"rstrip": false,
|
16 |
+
"single_word": false,
|
17 |
+
"special": true
|
18 |
+
},
|
19 |
+
"2": {
|
20 |
+
"content": "</s>",
|
21 |
+
"lstrip": false,
|
22 |
+
"normalized": false,
|
23 |
+
"rstrip": false,
|
24 |
+
"single_word": false,
|
25 |
+
"special": true
|
26 |
+
}
|
27 |
+
},
|
28 |
+
"additional_special_tokens": [],
|
29 |
+
"bos_token": "<s>",
|
30 |
+
"clean_up_tokenization_spaces": false,
|
31 |
+
"eos_token": "</s>",
|
32 |
+
"legacy": false,
|
33 |
+
"model_max_length": 1000000000000000019884624838656,
|
34 |
+
"pad_token": null,
|
35 |
+
"padding_side": "right",
|
36 |
+
"sp_model_kwargs": {},
|
37 |
+
"tokenizer_class": "LlamaTokenizer",
|
38 |
+
"unk_token": "<unk>",
|
39 |
+
"use_default_system_prompt": false
|
40 |
+
}
|