codefuse-admin
commited on
Commit
•
8b76ef3
1
Parent(s):
5b9fbfd
Upload 9 files
Browse files- MODEL_LICENSE.md +22 -0
- README.md +93 -3
- config.json +149 -0
- configuration_codefuse_cge_small.py +142 -0
- model.safetensors.index.json +215 -0
- modeling_codefuse_cge_small.py +243 -0
- tokenizer.json +0 -0
- tokenizer.model +3 -0
- tokenizer_config.json +130 -0
MODEL_LICENSE.md
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Microsoft.
|
2 |
+
Copyright (c) Microsoft Corporation.
|
3 |
+
|
4 |
+
MIT License
|
5 |
+
|
6 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
7 |
+
of this software and associated documentation files (the "Software"), to deal
|
8 |
+
in the Software without restriction, including without limitation the rights
|
9 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10 |
+
copies of the Software, and to permit persons to whom the Software is
|
11 |
+
furnished to do so, subject to the following conditions:
|
12 |
+
|
13 |
+
The above copyright notice and this permission notice shall be included in all
|
14 |
+
copies or substantial portions of the Software.
|
15 |
+
|
16 |
+
THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
22 |
+
SOFTWARE.
|
README.md
CHANGED
@@ -1,3 +1,93 @@
|
|
1 |
-
---
|
2 |
-
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
frameworks:
|
3 |
+
- Pytorch
|
4 |
+
license: other
|
5 |
+
tasks:
|
6 |
+
- text-embedding
|
7 |
+
---
|
8 |
+
|
9 |
+
## CodeFuse-CGE-Small
|
10 |
+
<p align="center">
|
11 |
+
<img src="https://modelscope.cn/api/v1/models/codefuse-ai/CodeFuse-QWen-14B/repo?Revision=master&FilePath=LOGO.jpg&View=true" width="800"/>
|
12 |
+
<p>
|
13 |
+
|
14 |
+
## Model Description
|
15 |
+
CodeFuse-CGE-Small is the Small version of the CodeFuse-CGE family which is fine-tuned based on Phi-3.5-mini-instruct. CodeFuse-CGE-Small is distinguish on text2code task for it's powerful ability of capturing the semantic relationship between code and text.
|
16 |
+
|
17 |
+
This model has the following notable features:
|
18 |
+
● Instruction-tuning is enabled for both query and code snippet sides.
|
19 |
+
● The model obtains sentence-level and code-level representations through a layer of cross-attention computation module.
|
20 |
+
● The model has a smaller dimensional size without significant degradation in performance.
|
21 |
+
|
22 |
+
Model Configuration
|
23 |
+
Model Size: 3.8B
|
24 |
+
Embedding Dimension: 1024
|
25 |
+
Hidden Layers: 32
|
26 |
+
Max Input Tokens: 1024
|
27 |
+
|
28 |
+
|
29 |
+
Requirements
|
30 |
+
```
|
31 |
+
flash_attn==2.4.2
|
32 |
+
torch==2.1.0
|
33 |
+
accelerate==0.28.0
|
34 |
+
transformers==4.43.0
|
35 |
+
```
|
36 |
+
|
37 |
+
|
38 |
+
## How to Use
|
39 |
+
### transformers
|
40 |
+
```
|
41 |
+
from transformers import AutoTokenizer, AutoModel
|
42 |
+
|
43 |
+
model_name_or_path = "CodeFuse-CGE-Small"
|
44 |
+
model = AutoModel.from_pretrained(model_name_or_path, trust_remote_code=True)
|
45 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name_or_path, trust_remote_code=True, truncation_side='right', padding_side='right')
|
46 |
+
model = model.to(torch.bfloat16)
|
47 |
+
|
48 |
+
if torch.cuda.is_available():
|
49 |
+
device = 'cuda'
|
50 |
+
else:
|
51 |
+
device = 'cpu'
|
52 |
+
model.to(device)
|
53 |
+
|
54 |
+
prefix_dict = {'python':{'query':'Retrieve the Python code that solves the following query:', 'passage':'Python code:'},
|
55 |
+
'java':{'query':'Retrieve the Java code that solves the following query:', 'passage':'Java code:'},
|
56 |
+
'go':{'query':'Retrieve the Go code that solves the following query:', 'passage':'Go code:'},
|
57 |
+
'c++':{'query':'Retrieve the C++ code that solves the following query:', 'passage':'C++ code:'},
|
58 |
+
'javascript':{'query':'Retrieve the Javascript code that solves the following query:', 'passage':'Javascript code:'},
|
59 |
+
'php':{'query':'Retrieve the PHP code that solves the following query:', 'passage':'PHP code:'},
|
60 |
+
'ruby':{'query':'Retrieve the Ruby code that solves the following query:', 'passage':'Ruby code:'},
|
61 |
+
'default':{'query':'Retrieve the code that solves the following query:', 'passage':'Code:'}
|
62 |
+
}
|
63 |
+
|
64 |
+
text = ["Writes a Boolean to the stream.",
|
65 |
+
"def writeBoolean(self, n): t = TYPE_BOOL_TRUE if n is False: t = TYPE_BOOL_FALSE self.stream.write(t)"]
|
66 |
+
text[0] += prefix_dict['python']['query']
|
67 |
+
text[0] += prefix_dict['python']['passage']
|
68 |
+
embed = model.encode(tokenizer, text)
|
69 |
+
score = embed[0] @ embed[1].T
|
70 |
+
print("score", score)
|
71 |
+
|
72 |
+
```
|
73 |
+
|
74 |
+
## Benchmark the Performance
|
75 |
+
We use MRR metric to evaluate the ability on text2code retrieval tasks: AdvTest, CosQA, CSN
|
76 |
+
|
77 |
+
|
78 |
+
![result](./result.png)
|
79 |
+
|
80 |
+
## Acknowledgement
|
81 |
+
Thanks to the authors of open-sourced datasets, including CSN, Adv, CoSQA.
|
82 |
+
|
83 |
+
## License
|
84 |
+
Since CodeFuse-CGE-Small is fine-tuned based on Phi3 model, our usage license follows the same terms as that of Phi3 model.
|
85 |
+
|
86 |
+
## 加入我们
|
87 |
+
我们是平台技术事业群AI Native团队,负责蚂蚁蚂蚁集团平台工程的智能化,团队成立3年多以来,支持了蚂蚁集团云计算基础设施智能化运维的升级改造。团队的Mission是,通过世界级的技术创新和影响,构建有广泛用户的算法服务和平台,支撑内外部产品和业务落地。团队秉承创新基因,在支撑业务落地的同时,推动技术影响。3年以来在ICLR、NeurIPS、KDD、ACL等顶会发表论文20余篇,创新业务结果获得两次蚂蚁技术最高奖T-Star,1次蚂蚁集团最高奖SuperMA。开源项目CodeFuse获得4K点赞(2024年2月),Huggingface和modelscope上模型累积下载量超过150万次。
|
88 |
+
|
89 |
+
我们正在寻找行业中的佼佼者加入我们的团队!如果您希望在一个充满活力、创新和卓越文化的环境中发展您的职业生涯,欢迎您查看我们的社招&校招机会,加入我们,一起创造下一个行业里程碑。
|
90 |
+
|
91 |
+
校招:https://hrrecommend.antgroup.com/guide.html?code=8uoP5mlus5DqQYbE_EnqcE2FD5JZH21MwvMUIb9mb6X3osXPuBraG54SyM8GLn_7
|
92 |
+
|
93 |
+
社招:https://talent.antgroup.com/off-campus-position?positionId=1933830
|
config.json
ADDED
@@ -0,0 +1,149 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_name_or_path": "CodeFuse_CGE_Small",
|
3 |
+
"architectures": [
|
4 |
+
"CodeFuse_CGE_Small"
|
5 |
+
],
|
6 |
+
"attention_bias": false,
|
7 |
+
"attention_dropout": 0.0,
|
8 |
+
"auto_map": {
|
9 |
+
"AutoConfig": "configuration_codefuse_cge_small.CodeFuseCGESmallConfig",
|
10 |
+
"AutoModel": "modeling_codefuse_cge_small.CodeFuse_CGE_Small"
|
11 |
+
},
|
12 |
+
"bos_token_id": 1,
|
13 |
+
"compress_dim": 1024,
|
14 |
+
"embd_pdrop": 0.0,
|
15 |
+
"embedding_dim": 4096,
|
16 |
+
"embedding_method": "pma",
|
17 |
+
"eos_token_id": 32000,
|
18 |
+
"hidden_act": "silu",
|
19 |
+
"hidden_size": 3072,
|
20 |
+
"inf_seq_length": 1024,
|
21 |
+
"initializer_range": 0.02,
|
22 |
+
"intermediate_size": 8192,
|
23 |
+
"keep_max_layer": 24,
|
24 |
+
"max_position_embeddings": 131072,
|
25 |
+
"max_window_layers": 28,
|
26 |
+
"num_attention_heads": 32,
|
27 |
+
"num_hidden_layers": 32,
|
28 |
+
"num_key_value_heads": 32,
|
29 |
+
"original_max_position_embeddings": 4096,
|
30 |
+
"pad_token_id": 32000,
|
31 |
+
"padding_side": "right",
|
32 |
+
"pma_ln": true,
|
33 |
+
"pma_norm": false,
|
34 |
+
"pma_norm_mode": "post_normal",
|
35 |
+
"pma_num_heads": 32,
|
36 |
+
"resid_pdrop": 0.0,
|
37 |
+
"rms_norm_eps": 1e-05,
|
38 |
+
"rope_scaling": {
|
39 |
+
"long_factor": [
|
40 |
+
1.0800000429153442,
|
41 |
+
1.1100000143051147,
|
42 |
+
1.1399999856948853,
|
43 |
+
1.340000033378601,
|
44 |
+
1.5899999141693115,
|
45 |
+
1.600000023841858,
|
46 |
+
1.6200000047683716,
|
47 |
+
2.620000123977661,
|
48 |
+
3.2300000190734863,
|
49 |
+
3.2300000190734863,
|
50 |
+
4.789999961853027,
|
51 |
+
7.400000095367432,
|
52 |
+
7.700000286102295,
|
53 |
+
9.09000015258789,
|
54 |
+
12.199999809265137,
|
55 |
+
17.670000076293945,
|
56 |
+
24.46000099182129,
|
57 |
+
28.57000160217285,
|
58 |
+
30.420001983642578,
|
59 |
+
30.840002059936523,
|
60 |
+
32.590003967285156,
|
61 |
+
32.93000411987305,
|
62 |
+
42.320003509521484,
|
63 |
+
44.96000289916992,
|
64 |
+
50.340003967285156,
|
65 |
+
50.45000457763672,
|
66 |
+
57.55000305175781,
|
67 |
+
57.93000411987305,
|
68 |
+
58.21000289916992,
|
69 |
+
60.1400032043457,
|
70 |
+
62.61000442504883,
|
71 |
+
62.62000274658203,
|
72 |
+
62.71000289916992,
|
73 |
+
63.1400032043457,
|
74 |
+
63.1400032043457,
|
75 |
+
63.77000427246094,
|
76 |
+
63.93000411987305,
|
77 |
+
63.96000289916992,
|
78 |
+
63.970001220703125,
|
79 |
+
64.02999877929688,
|
80 |
+
64.06999969482422,
|
81 |
+
64.08000183105469,
|
82 |
+
64.12000274658203,
|
83 |
+
64.41000366210938,
|
84 |
+
64.4800033569336,
|
85 |
+
64.51000213623047,
|
86 |
+
64.52999877929688,
|
87 |
+
64.83999633789062
|
88 |
+
],
|
89 |
+
"short_factor": [
|
90 |
+
1.0,
|
91 |
+
1.0199999809265137,
|
92 |
+
1.0299999713897705,
|
93 |
+
1.0299999713897705,
|
94 |
+
1.0499999523162842,
|
95 |
+
1.0499999523162842,
|
96 |
+
1.0499999523162842,
|
97 |
+
1.0499999523162842,
|
98 |
+
1.0499999523162842,
|
99 |
+
1.0699999332427979,
|
100 |
+
1.0999999046325684,
|
101 |
+
1.1099998950958252,
|
102 |
+
1.1599998474121094,
|
103 |
+
1.1599998474121094,
|
104 |
+
1.1699998378753662,
|
105 |
+
1.2899998426437378,
|
106 |
+
1.339999794960022,
|
107 |
+
1.679999828338623,
|
108 |
+
1.7899998426437378,
|
109 |
+
1.8199998140335083,
|
110 |
+
1.8499997854232788,
|
111 |
+
1.8799997568130493,
|
112 |
+
1.9099997282028198,
|
113 |
+
1.9399996995925903,
|
114 |
+
1.9899996519088745,
|
115 |
+
2.0199997425079346,
|
116 |
+
2.0199997425079346,
|
117 |
+
2.0199997425079346,
|
118 |
+
2.0199997425079346,
|
119 |
+
2.0199997425079346,
|
120 |
+
2.0199997425079346,
|
121 |
+
2.0299997329711914,
|
122 |
+
2.0299997329711914,
|
123 |
+
2.0299997329711914,
|
124 |
+
2.0299997329711914,
|
125 |
+
2.0299997329711914,
|
126 |
+
2.0299997329711914,
|
127 |
+
2.0299997329711914,
|
128 |
+
2.0299997329711914,
|
129 |
+
2.0299997329711914,
|
130 |
+
2.0799996852874756,
|
131 |
+
2.0899996757507324,
|
132 |
+
2.189999580383301,
|
133 |
+
2.2199995517730713,
|
134 |
+
2.5899994373321533,
|
135 |
+
2.729999542236328,
|
136 |
+
2.749999523162842,
|
137 |
+
2.8399994373321533
|
138 |
+
],
|
139 |
+
"type": "longrope"
|
140 |
+
},
|
141 |
+
"rope_theta": 10000.0,
|
142 |
+
"sliding_window": null,
|
143 |
+
"tie_word_embeddings": false,
|
144 |
+
"torch_dtype": "bfloat16",
|
145 |
+
"transformers_version": "4.39.2",
|
146 |
+
"use_cache": true,
|
147 |
+
"use_sliding_window": false,
|
148 |
+
"vocab_size": 32064
|
149 |
+
}
|
configuration_codefuse_cge_small.py
ADDED
@@ -0,0 +1,142 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers.configuration_utils import PretrainedConfig
|
2 |
+
from transformers.utils import logging
|
3 |
+
|
4 |
+
|
5 |
+
logger = logging.get_logger(__name__)
|
6 |
+
|
7 |
+
|
8 |
+
|
9 |
+
class CodeFuseCGESmallConfig(PretrainedConfig):
|
10 |
+
model_type = "phi3"
|
11 |
+
keys_to_ignore_at_inference = ["past_key_values"]
|
12 |
+
|
13 |
+
def __init__(
|
14 |
+
self,
|
15 |
+
vocab_size=32064,
|
16 |
+
hidden_size=3072,
|
17 |
+
intermediate_size=8192,
|
18 |
+
num_hidden_layers=32,
|
19 |
+
num_attention_heads=32,
|
20 |
+
num_key_value_heads=None,
|
21 |
+
resid_pdrop=0.0,
|
22 |
+
embd_pdrop=0.0,
|
23 |
+
attention_dropout=0.0,
|
24 |
+
hidden_act="silu",
|
25 |
+
max_position_embeddings=4096,
|
26 |
+
original_max_position_embeddings=4096,
|
27 |
+
initializer_range=0.02,
|
28 |
+
rms_norm_eps=1e-5,
|
29 |
+
use_cache=True,
|
30 |
+
tie_word_embeddings=False,
|
31 |
+
rope_theta=10000.0,
|
32 |
+
rope_scaling=None,
|
33 |
+
bos_token_id=1,
|
34 |
+
eos_token_id=32000,
|
35 |
+
pad_token_id=32000,
|
36 |
+
sliding_window=None,
|
37 |
+
embedding_method="pma",
|
38 |
+
inf_seq_length=1024,
|
39 |
+
padding_side="right",
|
40 |
+
compress_dim=1024,
|
41 |
+
keep_max_layer=32,
|
42 |
+
pma_num_heads=32,
|
43 |
+
pma_ln=True,
|
44 |
+
pma_norm=False,
|
45 |
+
pma_norm_mode="post_normal",
|
46 |
+
**kwargs,
|
47 |
+
):
|
48 |
+
self.vocab_size = vocab_size
|
49 |
+
self.hidden_size = hidden_size
|
50 |
+
self.intermediate_size = intermediate_size
|
51 |
+
self.num_hidden_layers = num_hidden_layers
|
52 |
+
self.num_attention_heads = num_attention_heads
|
53 |
+
|
54 |
+
if num_key_value_heads is None:
|
55 |
+
num_key_value_heads = num_attention_heads
|
56 |
+
|
57 |
+
self.num_key_value_heads = num_key_value_heads
|
58 |
+
self.resid_pdrop = resid_pdrop
|
59 |
+
self.embd_pdrop = embd_pdrop
|
60 |
+
self.attention_dropout = attention_dropout
|
61 |
+
self.hidden_act = hidden_act
|
62 |
+
self.max_position_embeddings = max_position_embeddings
|
63 |
+
self.original_max_position_embeddings = original_max_position_embeddings
|
64 |
+
self.initializer_range = initializer_range
|
65 |
+
self.rms_norm_eps = rms_norm_eps
|
66 |
+
self.use_cache = use_cache
|
67 |
+
self.rope_theta = rope_theta
|
68 |
+
self.rope_scaling = rope_scaling
|
69 |
+
self._rope_scaling_adjustment()
|
70 |
+
self._rope_scaling_validation()
|
71 |
+
self.sliding_window = sliding_window
|
72 |
+
|
73 |
+
self.embedding_method = embedding_method
|
74 |
+
self.inf_seq_length = inf_seq_length
|
75 |
+
self.padding_side = padding_side
|
76 |
+
self.compress_dim = compress_dim
|
77 |
+
self.keep_max_layer = keep_max_layer
|
78 |
+
self.pma_num_heads = pma_num_heads
|
79 |
+
self.pma_ln = pma_ln
|
80 |
+
self.pma_norm = pma_norm
|
81 |
+
self.pma_norm_mode = pma_norm_mode
|
82 |
+
|
83 |
+
super().__init__(
|
84 |
+
bos_token_id=bos_token_id,
|
85 |
+
eos_token_id=eos_token_id,
|
86 |
+
pad_token_id=pad_token_id,
|
87 |
+
tie_word_embeddings=tie_word_embeddings,
|
88 |
+
**kwargs,
|
89 |
+
)
|
90 |
+
|
91 |
+
def _rope_scaling_adjustment(self):
|
92 |
+
"""
|
93 |
+
Adjust the `type` of the `rope_scaling` configuration for backward compatibility.
|
94 |
+
"""
|
95 |
+
if self.rope_scaling is None:
|
96 |
+
return
|
97 |
+
|
98 |
+
rope_scaling_type = self.rope_scaling.get("type", None)
|
99 |
+
|
100 |
+
# For backward compatibility if previous version used "su" or "yarn"
|
101 |
+
if rope_scaling_type is not None and rope_scaling_type in ["su", "yarn"]:
|
102 |
+
self.rope_scaling["type"] = "longrope"
|
103 |
+
|
104 |
+
def _rope_scaling_validation(self):
|
105 |
+
"""
|
106 |
+
Validate the `rope_scaling` configuration.
|
107 |
+
"""
|
108 |
+
if self.rope_scaling is None:
|
109 |
+
return
|
110 |
+
|
111 |
+
if not isinstance(self.rope_scaling, dict) or len(self.rope_scaling) != 3:
|
112 |
+
raise ValueError(
|
113 |
+
"`rope_scaling` must be a dictionary with three fields, `type`, `short_factor` and `long_factor`, "
|
114 |
+
f"got {self.rope_scaling}"
|
115 |
+
)
|
116 |
+
rope_scaling_type = self.rope_scaling.get("type", None)
|
117 |
+
rope_scaling_short_factor = self.rope_scaling.get("short_factor", None)
|
118 |
+
rope_scaling_long_factor = self.rope_scaling.get("long_factor", None)
|
119 |
+
if rope_scaling_type is None or rope_scaling_type not in ["longrope"]:
|
120 |
+
raise ValueError(f"`rope_scaling`'s type field must be one of ['longrope'], got {rope_scaling_type}")
|
121 |
+
if not (
|
122 |
+
isinstance(rope_scaling_short_factor, list)
|
123 |
+
and all(isinstance(x, (int, float)) for x in rope_scaling_short_factor)
|
124 |
+
):
|
125 |
+
raise ValueError(
|
126 |
+
f"`rope_scaling`'s short_factor field must be a list of numbers, got {rope_scaling_short_factor}"
|
127 |
+
)
|
128 |
+
if not len(rope_scaling_short_factor) == self.hidden_size // self.num_attention_heads // 2:
|
129 |
+
raise ValueError(
|
130 |
+
f"`rope_scaling`'s short_factor field must have length {self.hidden_size // self.num_attention_heads // 2}, got {len(rope_scaling_short_factor)}"
|
131 |
+
)
|
132 |
+
if not (
|
133 |
+
isinstance(rope_scaling_long_factor, list)
|
134 |
+
and all(isinstance(x, (int, float)) for x in rope_scaling_long_factor)
|
135 |
+
):
|
136 |
+
raise ValueError(
|
137 |
+
f"`rope_scaling`'s long_factor field must be a list of numbers, got {rope_scaling_long_factor}"
|
138 |
+
)
|
139 |
+
if not len(rope_scaling_long_factor) == self.hidden_size // self.num_attention_heads // 2:
|
140 |
+
raise ValueError(
|
141 |
+
f"`rope_scaling`'s long_factor field must have length {self.hidden_size // self.num_attention_heads // 2}, got {len(rope_scaling_long_factor)}"
|
142 |
+
)
|
model.safetensors.index.json
ADDED
@@ -0,0 +1,215 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"metadata": {
|
3 |
+
"total_size": 7658954752
|
4 |
+
},
|
5 |
+
"weight_map": {
|
6 |
+
"mha_pma.S": "model-00002-of-00002.safetensors",
|
7 |
+
"mha_pma.mab.fc_k.bias": "model-00002-of-00002.safetensors",
|
8 |
+
"mha_pma.mab.fc_k.weight": "model-00002-of-00002.safetensors",
|
9 |
+
"mha_pma.mab.fc_o.bias": "model-00002-of-00002.safetensors",
|
10 |
+
"mha_pma.mab.fc_o.weight": "model-00002-of-00002.safetensors",
|
11 |
+
"mha_pma.mab.fc_q.bias": "model-00002-of-00002.safetensors",
|
12 |
+
"mha_pma.mab.fc_q.weight": "model-00002-of-00002.safetensors",
|
13 |
+
"mha_pma.mab.fc_v.bias": "model-00002-of-00002.safetensors",
|
14 |
+
"mha_pma.mab.fc_v.weight": "model-00002-of-00002.safetensors",
|
15 |
+
"mha_pma.mab.ln0.bias": "model-00002-of-00002.safetensors",
|
16 |
+
"mha_pma.mab.ln0.weight": "model-00002-of-00002.safetensors",
|
17 |
+
"mha_pma.mab.ln1.bias": "model-00002-of-00002.safetensors",
|
18 |
+
"mha_pma.mab.ln1.weight": "model-00002-of-00002.safetensors",
|
19 |
+
"plm_model.lm_head.weight": "model-00002-of-00002.safetensors",
|
20 |
+
"plm_model.model.embed_tokens.weight": "model-00001-of-00002.safetensors",
|
21 |
+
"plm_model.model.layers.0.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
22 |
+
"plm_model.model.layers.0.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
23 |
+
"plm_model.model.layers.0.mlp.gate_up_proj.weight": "model-00001-of-00002.safetensors",
|
24 |
+
"plm_model.model.layers.0.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
25 |
+
"plm_model.model.layers.0.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
26 |
+
"plm_model.model.layers.0.self_attn.qkv_proj.weight": "model-00001-of-00002.safetensors",
|
27 |
+
"plm_model.model.layers.1.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
28 |
+
"plm_model.model.layers.1.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
29 |
+
"plm_model.model.layers.1.mlp.gate_up_proj.weight": "model-00001-of-00002.safetensors",
|
30 |
+
"plm_model.model.layers.1.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
31 |
+
"plm_model.model.layers.1.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
32 |
+
"plm_model.model.layers.1.self_attn.qkv_proj.weight": "model-00001-of-00002.safetensors",
|
33 |
+
"plm_model.model.layers.10.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
34 |
+
"plm_model.model.layers.10.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
35 |
+
"plm_model.model.layers.10.mlp.gate_up_proj.weight": "model-00001-of-00002.safetensors",
|
36 |
+
"plm_model.model.layers.10.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
37 |
+
"plm_model.model.layers.10.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
38 |
+
"plm_model.model.layers.10.self_attn.qkv_proj.weight": "model-00001-of-00002.safetensors",
|
39 |
+
"plm_model.model.layers.11.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
40 |
+
"plm_model.model.layers.11.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
41 |
+
"plm_model.model.layers.11.mlp.gate_up_proj.weight": "model-00001-of-00002.safetensors",
|
42 |
+
"plm_model.model.layers.11.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
43 |
+
"plm_model.model.layers.11.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
44 |
+
"plm_model.model.layers.11.self_attn.qkv_proj.weight": "model-00001-of-00002.safetensors",
|
45 |
+
"plm_model.model.layers.12.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
46 |
+
"plm_model.model.layers.12.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
47 |
+
"plm_model.model.layers.12.mlp.gate_up_proj.weight": "model-00001-of-00002.safetensors",
|
48 |
+
"plm_model.model.layers.12.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
49 |
+
"plm_model.model.layers.12.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
50 |
+
"plm_model.model.layers.12.self_attn.qkv_proj.weight": "model-00001-of-00002.safetensors",
|
51 |
+
"plm_model.model.layers.13.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
52 |
+
"plm_model.model.layers.13.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
53 |
+
"plm_model.model.layers.13.mlp.gate_up_proj.weight": "model-00001-of-00002.safetensors",
|
54 |
+
"plm_model.model.layers.13.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
55 |
+
"plm_model.model.layers.13.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
56 |
+
"plm_model.model.layers.13.self_attn.qkv_proj.weight": "model-00001-of-00002.safetensors",
|
57 |
+
"plm_model.model.layers.14.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
58 |
+
"plm_model.model.layers.14.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
59 |
+
"plm_model.model.layers.14.mlp.gate_up_proj.weight": "model-00001-of-00002.safetensors",
|
60 |
+
"plm_model.model.layers.14.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
61 |
+
"plm_model.model.layers.14.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
62 |
+
"plm_model.model.layers.14.self_attn.qkv_proj.weight": "model-00001-of-00002.safetensors",
|
63 |
+
"plm_model.model.layers.15.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
64 |
+
"plm_model.model.layers.15.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
65 |
+
"plm_model.model.layers.15.mlp.gate_up_proj.weight": "model-00001-of-00002.safetensors",
|
66 |
+
"plm_model.model.layers.15.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
67 |
+
"plm_model.model.layers.15.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
68 |
+
"plm_model.model.layers.15.self_attn.qkv_proj.weight": "model-00001-of-00002.safetensors",
|
69 |
+
"plm_model.model.layers.16.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
70 |
+
"plm_model.model.layers.16.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
71 |
+
"plm_model.model.layers.16.mlp.gate_up_proj.weight": "model-00001-of-00002.safetensors",
|
72 |
+
"plm_model.model.layers.16.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
73 |
+
"plm_model.model.layers.16.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
74 |
+
"plm_model.model.layers.16.self_attn.qkv_proj.weight": "model-00001-of-00002.safetensors",
|
75 |
+
"plm_model.model.layers.17.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
76 |
+
"plm_model.model.layers.17.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
77 |
+
"plm_model.model.layers.17.mlp.gate_up_proj.weight": "model-00001-of-00002.safetensors",
|
78 |
+
"plm_model.model.layers.17.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
79 |
+
"plm_model.model.layers.17.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
80 |
+
"plm_model.model.layers.17.self_attn.qkv_proj.weight": "model-00001-of-00002.safetensors",
|
81 |
+
"plm_model.model.layers.18.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
82 |
+
"plm_model.model.layers.18.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
83 |
+
"plm_model.model.layers.18.mlp.gate_up_proj.weight": "model-00001-of-00002.safetensors",
|
84 |
+
"plm_model.model.layers.18.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
85 |
+
"plm_model.model.layers.18.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
86 |
+
"plm_model.model.layers.18.self_attn.qkv_proj.weight": "model-00001-of-00002.safetensors",
|
87 |
+
"plm_model.model.layers.19.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
88 |
+
"plm_model.model.layers.19.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
89 |
+
"plm_model.model.layers.19.mlp.gate_up_proj.weight": "model-00001-of-00002.safetensors",
|
90 |
+
"plm_model.model.layers.19.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
91 |
+
"plm_model.model.layers.19.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
92 |
+
"plm_model.model.layers.19.self_attn.qkv_proj.weight": "model-00001-of-00002.safetensors",
|
93 |
+
"plm_model.model.layers.2.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
94 |
+
"plm_model.model.layers.2.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
95 |
+
"plm_model.model.layers.2.mlp.gate_up_proj.weight": "model-00001-of-00002.safetensors",
|
96 |
+
"plm_model.model.layers.2.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
97 |
+
"plm_model.model.layers.2.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
98 |
+
"plm_model.model.layers.2.self_attn.qkv_proj.weight": "model-00001-of-00002.safetensors",
|
99 |
+
"plm_model.model.layers.20.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
100 |
+
"plm_model.model.layers.20.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
101 |
+
"plm_model.model.layers.20.mlp.gate_up_proj.weight": "model-00001-of-00002.safetensors",
|
102 |
+
"plm_model.model.layers.20.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
103 |
+
"plm_model.model.layers.20.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
104 |
+
"plm_model.model.layers.20.self_attn.qkv_proj.weight": "model-00001-of-00002.safetensors",
|
105 |
+
"plm_model.model.layers.21.input_layernorm.weight": "model-00002-of-00002.safetensors",
|
106 |
+
"plm_model.model.layers.21.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
|
107 |
+
"plm_model.model.layers.21.mlp.gate_up_proj.weight": "model-00002-of-00002.safetensors",
|
108 |
+
"plm_model.model.layers.21.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
|
109 |
+
"plm_model.model.layers.21.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
110 |
+
"plm_model.model.layers.21.self_attn.qkv_proj.weight": "model-00002-of-00002.safetensors",
|
111 |
+
"plm_model.model.layers.22.input_layernorm.weight": "model-00002-of-00002.safetensors",
|
112 |
+
"plm_model.model.layers.22.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
|
113 |
+
"plm_model.model.layers.22.mlp.gate_up_proj.weight": "model-00002-of-00002.safetensors",
|
114 |
+
"plm_model.model.layers.22.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
|
115 |
+
"plm_model.model.layers.22.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
|
116 |
+
"plm_model.model.layers.22.self_attn.qkv_proj.weight": "model-00002-of-00002.safetensors",
|
117 |
+
"plm_model.model.layers.23.input_layernorm.weight": "model-00002-of-00002.safetensors",
|
118 |
+
"plm_model.model.layers.23.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
|
119 |
+
"plm_model.model.layers.23.mlp.gate_up_proj.weight": "model-00002-of-00002.safetensors",
|
120 |
+
"plm_model.model.layers.23.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
|
121 |
+
"plm_model.model.layers.23.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
|
122 |
+
"plm_model.model.layers.23.self_attn.qkv_proj.weight": "model-00002-of-00002.safetensors",
|
123 |
+
"plm_model.model.layers.24.input_layernorm.weight": "model-00002-of-00002.safetensors",
|
124 |
+
"plm_model.model.layers.24.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
|
125 |
+
"plm_model.model.layers.24.mlp.gate_up_proj.weight": "model-00002-of-00002.safetensors",
|
126 |
+
"plm_model.model.layers.24.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
|
127 |
+
"plm_model.model.layers.24.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
|
128 |
+
"plm_model.model.layers.24.self_attn.qkv_proj.weight": "model-00002-of-00002.safetensors",
|
129 |
+
"plm_model.model.layers.25.input_layernorm.weight": "model-00002-of-00002.safetensors",
|
130 |
+
"plm_model.model.layers.25.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
|
131 |
+
"plm_model.model.layers.25.mlp.gate_up_proj.weight": "model-00002-of-00002.safetensors",
|
132 |
+
"plm_model.model.layers.25.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
|
133 |
+
"plm_model.model.layers.25.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
|
134 |
+
"plm_model.model.layers.25.self_attn.qkv_proj.weight": "model-00002-of-00002.safetensors",
|
135 |
+
"plm_model.model.layers.26.input_layernorm.weight": "model-00002-of-00002.safetensors",
|
136 |
+
"plm_model.model.layers.26.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
|
137 |
+
"plm_model.model.layers.26.mlp.gate_up_proj.weight": "model-00002-of-00002.safetensors",
|
138 |
+
"plm_model.model.layers.26.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
|
139 |
+
"plm_model.model.layers.26.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
|
140 |
+
"plm_model.model.layers.26.self_attn.qkv_proj.weight": "model-00002-of-00002.safetensors",
|
141 |
+
"plm_model.model.layers.27.input_layernorm.weight": "model-00002-of-00002.safetensors",
|
142 |
+
"plm_model.model.layers.27.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
|
143 |
+
"plm_model.model.layers.27.mlp.gate_up_proj.weight": "model-00002-of-00002.safetensors",
|
144 |
+
"plm_model.model.layers.27.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
|
145 |
+
"plm_model.model.layers.27.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
|
146 |
+
"plm_model.model.layers.27.self_attn.qkv_proj.weight": "model-00002-of-00002.safetensors",
|
147 |
+
"plm_model.model.layers.28.input_layernorm.weight": "model-00002-of-00002.safetensors",
|
148 |
+
"plm_model.model.layers.28.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
|
149 |
+
"plm_model.model.layers.28.mlp.gate_up_proj.weight": "model-00002-of-00002.safetensors",
|
150 |
+
"plm_model.model.layers.28.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
|
151 |
+
"plm_model.model.layers.28.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
|
152 |
+
"plm_model.model.layers.28.self_attn.qkv_proj.weight": "model-00002-of-00002.safetensors",
|
153 |
+
"plm_model.model.layers.29.input_layernorm.weight": "model-00002-of-00002.safetensors",
|
154 |
+
"plm_model.model.layers.29.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
|
155 |
+
"plm_model.model.layers.29.mlp.gate_up_proj.weight": "model-00002-of-00002.safetensors",
|
156 |
+
"plm_model.model.layers.29.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
|
157 |
+
"plm_model.model.layers.29.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
|
158 |
+
"plm_model.model.layers.29.self_attn.qkv_proj.weight": "model-00002-of-00002.safetensors",
|
159 |
+
"plm_model.model.layers.3.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
160 |
+
"plm_model.model.layers.3.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
161 |
+
"plm_model.model.layers.3.mlp.gate_up_proj.weight": "model-00001-of-00002.safetensors",
|
162 |
+
"plm_model.model.layers.3.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
163 |
+
"plm_model.model.layers.3.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
164 |
+
"plm_model.model.layers.3.self_attn.qkv_proj.weight": "model-00001-of-00002.safetensors",
|
165 |
+
"plm_model.model.layers.30.input_layernorm.weight": "model-00002-of-00002.safetensors",
|
166 |
+
"plm_model.model.layers.30.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
|
167 |
+
"plm_model.model.layers.30.mlp.gate_up_proj.weight": "model-00002-of-00002.safetensors",
|
168 |
+
"plm_model.model.layers.30.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
|
169 |
+
"plm_model.model.layers.30.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
|
170 |
+
"plm_model.model.layers.30.self_attn.qkv_proj.weight": "model-00002-of-00002.safetensors",
|
171 |
+
"plm_model.model.layers.31.input_layernorm.weight": "model-00002-of-00002.safetensors",
|
172 |
+
"plm_model.model.layers.31.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
|
173 |
+
"plm_model.model.layers.31.mlp.gate_up_proj.weight": "model-00002-of-00002.safetensors",
|
174 |
+
"plm_model.model.layers.31.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
|
175 |
+
"plm_model.model.layers.31.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
|
176 |
+
"plm_model.model.layers.31.self_attn.qkv_proj.weight": "model-00002-of-00002.safetensors",
|
177 |
+
"plm_model.model.layers.4.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
178 |
+
"plm_model.model.layers.4.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
179 |
+
"plm_model.model.layers.4.mlp.gate_up_proj.weight": "model-00001-of-00002.safetensors",
|
180 |
+
"plm_model.model.layers.4.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
181 |
+
"plm_model.model.layers.4.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
182 |
+
"plm_model.model.layers.4.self_attn.qkv_proj.weight": "model-00001-of-00002.safetensors",
|
183 |
+
"plm_model.model.layers.5.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
184 |
+
"plm_model.model.layers.5.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
185 |
+
"plm_model.model.layers.5.mlp.gate_up_proj.weight": "model-00001-of-00002.safetensors",
|
186 |
+
"plm_model.model.layers.5.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
187 |
+
"plm_model.model.layers.5.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
188 |
+
"plm_model.model.layers.5.self_attn.qkv_proj.weight": "model-00001-of-00002.safetensors",
|
189 |
+
"plm_model.model.layers.6.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
190 |
+
"plm_model.model.layers.6.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
191 |
+
"plm_model.model.layers.6.mlp.gate_up_proj.weight": "model-00001-of-00002.safetensors",
|
192 |
+
"plm_model.model.layers.6.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
193 |
+
"plm_model.model.layers.6.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
194 |
+
"plm_model.model.layers.6.self_attn.qkv_proj.weight": "model-00001-of-00002.safetensors",
|
195 |
+
"plm_model.model.layers.7.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
196 |
+
"plm_model.model.layers.7.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
197 |
+
"plm_model.model.layers.7.mlp.gate_up_proj.weight": "model-00001-of-00002.safetensors",
|
198 |
+
"plm_model.model.layers.7.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
199 |
+
"plm_model.model.layers.7.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
200 |
+
"plm_model.model.layers.7.self_attn.qkv_proj.weight": "model-00001-of-00002.safetensors",
|
201 |
+
"plm_model.model.layers.8.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
202 |
+
"plm_model.model.layers.8.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
203 |
+
"plm_model.model.layers.8.mlp.gate_up_proj.weight": "model-00001-of-00002.safetensors",
|
204 |
+
"plm_model.model.layers.8.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
205 |
+
"plm_model.model.layers.8.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
206 |
+
"plm_model.model.layers.8.self_attn.qkv_proj.weight": "model-00001-of-00002.safetensors",
|
207 |
+
"plm_model.model.layers.9.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
208 |
+
"plm_model.model.layers.9.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
209 |
+
"plm_model.model.layers.9.mlp.gate_up_proj.weight": "model-00001-of-00002.safetensors",
|
210 |
+
"plm_model.model.layers.9.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
211 |
+
"plm_model.model.layers.9.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
212 |
+
"plm_model.model.layers.9.self_attn.qkv_proj.weight": "model-00001-of-00002.safetensors",
|
213 |
+
"plm_model.model.norm.weight": "model-00002-of-00002.safetensors"
|
214 |
+
}
|
215 |
+
}
|
modeling_codefuse_cge_small.py
ADDED
@@ -0,0 +1,243 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import inspect
|
2 |
+
import math
|
3 |
+
import os
|
4 |
+
import warnings
|
5 |
+
from typing import List, Optional, Tuple, Union
|
6 |
+
|
7 |
+
import torch
|
8 |
+
import torch.nn.functional as F
|
9 |
+
import torch.utils.checkpoint
|
10 |
+
from torch import nn
|
11 |
+
from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss
|
12 |
+
from transformers import PretrainedConfig
|
13 |
+
|
14 |
+
from transformers.activations import ACT2FN
|
15 |
+
from transformers.cache_utils import Cache, DynamicCache
|
16 |
+
from transformers.modeling_attn_mask_utils import _prepare_4d_causal_attention_mask, _prepare_4d_causal_attention_mask_for_sdpa, _prepare_4d_attention_mask, _prepare_4d_attention_mask_for_sdpa
|
17 |
+
from transformers.modeling_outputs import BaseModelOutputWithPast, CausalLMOutputWithPast, SequenceClassifierOutputWithPast
|
18 |
+
from transformers.modeling_utils import PreTrainedModel
|
19 |
+
from transformers.utils import (
|
20 |
+
add_start_docstrings,
|
21 |
+
add_start_docstrings_to_model_forward,
|
22 |
+
is_flash_attn_2_available,
|
23 |
+
is_flash_attn_greater_or_equal_2_10,
|
24 |
+
logging,
|
25 |
+
replace_return_docstrings,
|
26 |
+
)
|
27 |
+
import numpy as np
|
28 |
+
from transformers import Phi3ForCausalLM
|
29 |
+
import inspect
|
30 |
+
import math
|
31 |
+
import os
|
32 |
+
import warnings
|
33 |
+
from typing import List, Optional, Tuple, Union
|
34 |
+
from tqdm import tqdm, trange
|
35 |
+
import torch
|
36 |
+
import torch.nn.functional as F
|
37 |
+
import torch.utils.checkpoint
|
38 |
+
from torch import nn
|
39 |
+
from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss
|
40 |
+
|
41 |
+
from transformers.activations import ACT2FN
|
42 |
+
from transformers.cache_utils import Cache, DynamicCache
|
43 |
+
from transformers.modeling_attn_mask_utils import _prepare_4d_causal_attention_mask, _prepare_4d_causal_attention_mask_for_sdpa, _prepare_4d_attention_mask, _prepare_4d_attention_mask_for_sdpa
|
44 |
+
from transformers.modeling_outputs import BaseModelOutputWithPast, CausalLMOutputWithPast, SequenceClassifierOutputWithPast
|
45 |
+
from transformers.modeling_utils import PreTrainedModel
|
46 |
+
from transformers.utils import (
|
47 |
+
add_start_docstrings,
|
48 |
+
add_start_docstrings_to_model_forward,
|
49 |
+
is_flash_attn_2_available,
|
50 |
+
is_flash_attn_greater_or_equal_2_10,
|
51 |
+
logging,
|
52 |
+
replace_return_docstrings,
|
53 |
+
)
|
54 |
+
import numpy as np
|
55 |
+
import torch
|
56 |
+
import os
|
57 |
+
import argparse
|
58 |
+
import json
|
59 |
+
from tqdm import tqdm
|
60 |
+
from typing import cast, List, Union, Tuple
|
61 |
+
from transformers import AutoTokenizer, AutoModel # pylint: disable=C0413
|
62 |
+
from peft import LoraConfig, get_peft_model, TaskType
|
63 |
+
import time
|
64 |
+
import torch.nn.functional as F
|
65 |
+
import sys
|
66 |
+
import time
|
67 |
+
import torch
|
68 |
+
import torch.nn as nn
|
69 |
+
import torch.nn.functional as F
|
70 |
+
import numpy as np
|
71 |
+
from tqdm import tqdm, trange
|
72 |
+
from collections import defaultdict
|
73 |
+
from transformers import AutoTokenizer, AutoModel, AutoModelForCausalLM, AutoConfig
|
74 |
+
import torch.distributed as dist
|
75 |
+
from deepspeed.utils.zero_to_fp32 import get_fp32_state_dict_from_zero_checkpoint
|
76 |
+
import sys
|
77 |
+
import torch
|
78 |
+
import torch.nn as nn
|
79 |
+
import torch.nn.functional as F
|
80 |
+
import math
|
81 |
+
import re
|
82 |
+
|
83 |
+
|
84 |
+
class MAB_POST(nn.Module):
|
85 |
+
def __init__(self, dim_Q, dim_K, dim_V, num_heads, ln=False):
|
86 |
+
super(MAB_POST, self).__init__()
|
87 |
+
self.dim_V = dim_V
|
88 |
+
self.num_heads = num_heads
|
89 |
+
self.fc_q = nn.Linear(dim_Q, dim_V)
|
90 |
+
self.fc_k = nn.Linear(dim_K, dim_V)
|
91 |
+
self.fc_v = nn.Linear(dim_K, dim_V)
|
92 |
+
if ln:
|
93 |
+
self.ln0 = nn.LayerNorm(dim_V)
|
94 |
+
self.ln1 = nn.LayerNorm(dim_V)
|
95 |
+
self.fc_o = nn.Linear(dim_V, dim_V)
|
96 |
+
nn.init.xavier_uniform_(self.fc_q.weight)
|
97 |
+
nn.init.xavier_uniform_(self.fc_k.weight)
|
98 |
+
nn.init.xavier_uniform_(self.fc_v.weight)
|
99 |
+
nn.init.xavier_uniform_(self.fc_o.weight)
|
100 |
+
|
101 |
+
def forward(self, Q, K, pad_mask=None):
|
102 |
+
|
103 |
+
Q_ = self.fc_q(Q)
|
104 |
+
K_, V_ = self.fc_k(K), self.fc_v(K)
|
105 |
+
|
106 |
+
dim_split = self.dim_V // self.num_heads
|
107 |
+
Q_ = torch.cat(Q_.split(dim_split, 2), 0)
|
108 |
+
K_ = torch.cat(K_.split(dim_split, 2), 0)
|
109 |
+
V_ = torch.cat(V_.split(dim_split, 2), 0)
|
110 |
+
|
111 |
+
pad_mask = pad_mask.unsqueeze(1).repeat(self.num_heads, Q.size(1), 1)
|
112 |
+
score = Q_.bmm(K_.transpose(1,2))/math.sqrt(self.dim_V)
|
113 |
+
score = score.masked_fill(pad_mask == 0, -1e12)
|
114 |
+
A = torch.softmax(score, 2)
|
115 |
+
A = A * pad_mask
|
116 |
+
O = torch.cat(A.bmm(V_).split(Q.size(0), 0), 2)
|
117 |
+
O = Q + O
|
118 |
+
O = O if getattr(self, 'ln0', None) is None else self.ln0(O)
|
119 |
+
O = O + F.relu(self.fc_o(O))
|
120 |
+
O = O if getattr(self, 'ln1', None) is None else self.ln1(O)
|
121 |
+
return O
|
122 |
+
|
123 |
+
|
124 |
+
class PMA(nn.Module):
|
125 |
+
def __init__(self, dim, compress_dim, num_heads, num_seeds, ln=False, pma_mode=None):
|
126 |
+
super(PMA, self).__init__()
|
127 |
+
self.S = nn.Parameter(torch.Tensor(1, num_seeds, compress_dim))
|
128 |
+
nn.init.xavier_uniform_(self.S)
|
129 |
+
if pma_mode == 'post_normal':
|
130 |
+
self.mab = MAB_POST(compress_dim, dim, compress_dim, num_heads, ln=ln)
|
131 |
+
elif pma_mode == 'pre_normal':
|
132 |
+
self.mab = MAB_PRE_NORMAL(compress_dim, dim, compress_dim, num_heads, ln=ln)
|
133 |
+
elif pma_mode == 'pre_gptj':
|
134 |
+
self.mab = MAB_PRE_GPTJ(compress_dim, dim, compress_dim, num_heads, ln=ln)
|
135 |
+
else:
|
136 |
+
raise ValueError(f"Error, the pma_mode {pma_mode} is not implemented !")
|
137 |
+
|
138 |
+
def forward(self, X, pad_mask):
|
139 |
+
if self.S.dtype != torch.bfloat16:
|
140 |
+
X = X.float()
|
141 |
+
return self.mab(self.S.repeat(X.size(0), 1, 1), X, pad_mask)
|
142 |
+
|
143 |
+
|
144 |
+
class CodeFuse_CGE_Small(PreTrainedModel):
|
145 |
+
|
146 |
+
def __init__(self, config):
|
147 |
+
super().__init__(config)
|
148 |
+
self.plm_model = Phi3ForCausalLM(config)
|
149 |
+
self.embedding_method = config.embedding_method
|
150 |
+
self.inf_seq_length = config.inf_seq_length
|
151 |
+
self.padding_side = config.padding_side
|
152 |
+
|
153 |
+
self.keep_max_layer = config.keep_max_layer
|
154 |
+
self.emb_dim = self.plm_model.model.embed_tokens.weight.size(1)
|
155 |
+
self.num_heads = config.pma_num_heads
|
156 |
+
self.ln = config.pma_ln
|
157 |
+
self.norm = config.pma_norm
|
158 |
+
self.compress_dim = config.compress_dim
|
159 |
+
self.pma_mode = config.pma_norm_mode
|
160 |
+
self.mha_pma = PMA(self.emb_dim, self.compress_dim, self.num_heads, 1, ln=self.ln, pma_mode=self.pma_mode)
|
161 |
+
|
162 |
+
def last_embedding(self, A, index):
|
163 |
+
bs, seq, emb = A.size()
|
164 |
+
res = A[torch.arange(bs), index, :]
|
165 |
+
return res
|
166 |
+
|
167 |
+
def mean_embedding(self, A, mask):
|
168 |
+
bs, seq, emb = A.size()
|
169 |
+
res = (A * (mask.unsqueeze(-1))).sum(1) / (mask.sum(1).unsqueeze(-1))
|
170 |
+
return res
|
171 |
+
|
172 |
+
def weighted_embedding(self, A, mask):
|
173 |
+
weights = (torch.arange(start=1, end=A.size(1) + 1).unsqueeze(0).unsqueeze(-1).expand(A.size()).float()).to(A.device)
|
174 |
+
input_mask_expanded = (mask.squeeze(1).unsqueeze(-1).expand(A.size()).float()).to(A.device)
|
175 |
+
sum_embedding = torch.sum(A * input_mask_expanded * weights, dim=1)
|
176 |
+
sum_mask = torch.sum(input_mask_expanded * weights, dim=1)
|
177 |
+
weighted_embedding = sum_embedding / sum_mask
|
178 |
+
return weighted_embedding
|
179 |
+
|
180 |
+
def pma_embedding(self, A, mask):
|
181 |
+
res = self.mha_pma(A, mask).squeeze(1)
|
182 |
+
return res
|
183 |
+
|
184 |
+
def get_sentence_embedding(self, embedding_method, **inputs):
|
185 |
+
outputs = self.plm_model(inputs['input_ids'], inputs['attention_mask'], output_hidden_states=True)
|
186 |
+
if embedding_method == 'last':
|
187 |
+
embedding = outputs.hidden_states[self.keep_max_layer]
|
188 |
+
index = inputs['attention_mask'].sum(-1).long() - 1
|
189 |
+
res_embedding = self.last_embedding(embedding, index)
|
190 |
+
elif embedding_method == 'mean':
|
191 |
+
embedding = outputs.hidden_states[self.keep_max_layer]
|
192 |
+
res_embedding = self.mean_embedding(embedding, inputs['attention_mask'])
|
193 |
+
elif embedding_method == 'weighted':
|
194 |
+
embedding = outputs.hidden_states[self.keep_max_layer]
|
195 |
+
res_embedding = self.weighted_embedding(embedding, inputs['attention_mask'])
|
196 |
+
elif embedding_method == 'pma':
|
197 |
+
embedding = outputs.hidden_states[self.keep_max_layer]
|
198 |
+
attention_mask = inputs['attention_mask']
|
199 |
+
res_embedding = self.pma_embedding(embedding, attention_mask)
|
200 |
+
else:
|
201 |
+
logger.debug('Error, no {} way to obtain embbedings'.format(embedding_method))
|
202 |
+
|
203 |
+
if not self.norm:
|
204 |
+
res_embedding = torch.nn.functional.normalize(res_embedding, p=2.0, dim=-1, eps=1e-12, out=None)
|
205 |
+
return res_embedding
|
206 |
+
|
207 |
+
|
208 |
+
def encode(self, tokenizer, sentences, batch_size=32, convert_to_numpy=True,
|
209 |
+
convert_to_tensor=False, show_progress_bar=True, max_seq_length=None, **kwargs):
|
210 |
+
|
211 |
+
if max_seq_length is None:
|
212 |
+
max_seq_length = self.inf_seq_length
|
213 |
+
|
214 |
+
input_is_string = False
|
215 |
+
if isinstance(sentences, str) or not hasattr(sentences, "__len__"):
|
216 |
+
sentences = [sentences]
|
217 |
+
input_is_string = True
|
218 |
+
|
219 |
+
all_embeddings = []
|
220 |
+
length_sorted_idx = np.argsort([-len(s) for s in sentences])
|
221 |
+
sentences_sorted = [sentences[idx] for idx in length_sorted_idx]
|
222 |
+
with torch.no_grad():
|
223 |
+
for start_index in trange(0, len(sentences), batch_size, desc="Batches", disable=not show_progress_bar):
|
224 |
+
sentences_batch = sentences_sorted[start_index: start_index + batch_size]
|
225 |
+
with torch.no_grad():
|
226 |
+
inputs = tokenizer(sentences_batch, padding=True, truncation=True, max_length=max_seq_length, add_special_tokens=False, return_tensors='pt').to(self.plm_model.device)
|
227 |
+
embeddings = self.get_sentence_embedding(self.embedding_method, **inputs)
|
228 |
+
embeddings = embeddings.detach()
|
229 |
+
if convert_to_numpy:
|
230 |
+
if embeddings.dtype == torch.bfloat16:
|
231 |
+
embeddings = embeddings.cpu().to(torch.float32)
|
232 |
+
else:
|
233 |
+
embeddings = embeddings.cpu()
|
234 |
+
all_embeddings.extend(embeddings)
|
235 |
+
all_embeddings = [all_embeddings[idx] for idx in np.argsort(length_sorted_idx)]
|
236 |
+
if convert_to_tensor:
|
237 |
+
all_embeddings = torch.stack(all_embeddings)
|
238 |
+
elif convert_to_numpy:
|
239 |
+
all_embeddings = np.asarray([emb.numpy() for emb in all_embeddings])
|
240 |
+
|
241 |
+
if input_is_string:
|
242 |
+
all_embeddings = all_embeddings[0]
|
243 |
+
return all_embeddings
|
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,130 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"add_bos_token": false,
|
3 |
+
"add_eos_token": false,
|
4 |
+
"added_tokens_decoder": {
|
5 |
+
"0": {
|
6 |
+
"content": "<unk>",
|
7 |
+
"lstrip": false,
|
8 |
+
"normalized": false,
|
9 |
+
"rstrip": false,
|
10 |
+
"single_word": false,
|
11 |
+
"special": true
|
12 |
+
},
|
13 |
+
"1": {
|
14 |
+
"content": "<s>",
|
15 |
+
"lstrip": false,
|
16 |
+
"normalized": false,
|
17 |
+
"rstrip": false,
|
18 |
+
"single_word": false,
|
19 |
+
"special": true
|
20 |
+
},
|
21 |
+
"2": {
|
22 |
+
"content": "</s>",
|
23 |
+
"lstrip": false,
|
24 |
+
"normalized": false,
|
25 |
+
"rstrip": true,
|
26 |
+
"single_word": false,
|
27 |
+
"special": false
|
28 |
+
},
|
29 |
+
"32000": {
|
30 |
+
"content": "<|endoftext|>",
|
31 |
+
"lstrip": false,
|
32 |
+
"normalized": false,
|
33 |
+
"rstrip": false,
|
34 |
+
"single_word": false,
|
35 |
+
"special": true
|
36 |
+
},
|
37 |
+
"32001": {
|
38 |
+
"content": "<|assistant|>",
|
39 |
+
"lstrip": false,
|
40 |
+
"normalized": false,
|
41 |
+
"rstrip": true,
|
42 |
+
"single_word": false,
|
43 |
+
"special": true
|
44 |
+
},
|
45 |
+
"32002": {
|
46 |
+
"content": "<|placeholder1|>",
|
47 |
+
"lstrip": false,
|
48 |
+
"normalized": false,
|
49 |
+
"rstrip": true,
|
50 |
+
"single_word": false,
|
51 |
+
"special": true
|
52 |
+
},
|
53 |
+
"32003": {
|
54 |
+
"content": "<|placeholder2|>",
|
55 |
+
"lstrip": false,
|
56 |
+
"normalized": false,
|
57 |
+
"rstrip": true,
|
58 |
+
"single_word": false,
|
59 |
+
"special": true
|
60 |
+
},
|
61 |
+
"32004": {
|
62 |
+
"content": "<|placeholder3|>",
|
63 |
+
"lstrip": false,
|
64 |
+
"normalized": false,
|
65 |
+
"rstrip": true,
|
66 |
+
"single_word": false,
|
67 |
+
"special": true
|
68 |
+
},
|
69 |
+
"32005": {
|
70 |
+
"content": "<|placeholder4|>",
|
71 |
+
"lstrip": false,
|
72 |
+
"normalized": false,
|
73 |
+
"rstrip": true,
|
74 |
+
"single_word": false,
|
75 |
+
"special": true
|
76 |
+
},
|
77 |
+
"32006": {
|
78 |
+
"content": "<|system|>",
|
79 |
+
"lstrip": false,
|
80 |
+
"normalized": false,
|
81 |
+
"rstrip": true,
|
82 |
+
"single_word": false,
|
83 |
+
"special": true
|
84 |
+
},
|
85 |
+
"32007": {
|
86 |
+
"content": "<|end|>",
|
87 |
+
"lstrip": false,
|
88 |
+
"normalized": false,
|
89 |
+
"rstrip": true,
|
90 |
+
"single_word": false,
|
91 |
+
"special": true
|
92 |
+
},
|
93 |
+
"32008": {
|
94 |
+
"content": "<|placeholder5|>",
|
95 |
+
"lstrip": false,
|
96 |
+
"normalized": false,
|
97 |
+
"rstrip": true,
|
98 |
+
"single_word": false,
|
99 |
+
"special": true
|
100 |
+
},
|
101 |
+
"32009": {
|
102 |
+
"content": "<|placeholder6|>",
|
103 |
+
"lstrip": false,
|
104 |
+
"normalized": false,
|
105 |
+
"rstrip": true,
|
106 |
+
"single_word": false,
|
107 |
+
"special": true
|
108 |
+
},
|
109 |
+
"32010": {
|
110 |
+
"content": "<|user|>",
|
111 |
+
"lstrip": false,
|
112 |
+
"normalized": false,
|
113 |
+
"rstrip": true,
|
114 |
+
"single_word": false,
|
115 |
+
"special": true
|
116 |
+
}
|
117 |
+
},
|
118 |
+
"bos_token": "<s>",
|
119 |
+
"chat_template": "{% for message in messages %}{% if message['role'] == 'system' and message['content'] %}{{'<|system|>\n' + message['content'] + '<|end|>\n'}}{% elif message['role'] == 'user' %}{{'<|user|>\n' + message['content'] + '<|end|>\n'}}{% elif message['role'] == 'assistant' %}{{'<|assistant|>\n' + message['content'] + '<|end|>\n'}}{% endif %}{% endfor %}{% if add_generation_prompt %}{{ '<|assistant|>\n' }}{% else %}{{ eos_token }}{% endif %}",
|
120 |
+
"clean_up_tokenization_spaces": false,
|
121 |
+
"eos_token": "<|endoftext|>",
|
122 |
+
"legacy": false,
|
123 |
+
"model_max_length": 131072,
|
124 |
+
"pad_token": "<|endoftext|>",
|
125 |
+
"padding_side": "left",
|
126 |
+
"sp_model_kwargs": {},
|
127 |
+
"tokenizer_class": "LlamaTokenizer",
|
128 |
+
"unk_token": "<unk>",
|
129 |
+
"use_default_system_prompt": false
|
130 |
+
}
|