codefuse-admin commited on
Commit
d1b2ad8
1 Parent(s): c690c68

Upload 10 files

Browse files
MODEL_LICENSE.md ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Tongyi Qianwen LICENSE AGREEMENT
2
+
3
+ Tongyi Qianwen Release Date: August 3, 2023
4
+
5
+ By clicking to agree or by using or distributing any portion or element of the Tongyi Qianwen Materials, you will be deemed to have recognized and accepted the content of this Agreement, which is effective immediately.
6
+
7
+ 1. Definitions
8
+ a. This Tongyi Qianwen LICENSE AGREEMENT (this "Agreement") shall mean the terms and conditions for use, reproduction, distribution and modification of the Materials as defined by this Agreement.
9
+ b. "We"(or "Us") shall mean Alibaba Cloud.
10
+ c. "You" (or "Your") shall mean a natural person or legal entity exercising the rights granted by this Agreement and/or using the Materials for any purpose and in any field of use.
11
+ d. "Third Parties" shall mean individuals or legal entities that are not under common control with Us or You.
12
+ e. "Tongyi Qianwen" shall mean the large language models (including Qwen model and Qwen-Chat model), and software and algorithms, consisting of trained model weights, parameters (including optimizer states), machine-learning model code, inference-enabling code, training-enabling code, fine-tuning enabling code and other elements of the foregoing distributed by Us.
13
+ f. "Materials" shall mean, collectively, Alibaba Cloud's proprietary Tongyi Qianwen and Documentation (and any portion thereof) made available under this Agreement.
14
+ g. "Source" form shall mean the preferred form for making modifications, including but not limited to model source code, documentation source, and configuration files.
15
+ h. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation,
16
+ and conversions to other media types.
17
+
18
+ 2. Grant of Rights
19
+ You are granted a non-exclusive, worldwide, non-transferable and royalty-free limited license under Alibaba Cloud's intellectual property or other rights owned by Us embodied in the Materials to use, reproduce, distribute, copy, create derivative works of, and make modifications to the Materials.
20
+
21
+ 3. Redistribution
22
+ You may reproduce and distribute copies of the Materials or derivative works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
23
+ a. You shall give any other recipients of the Materials or derivative works a copy of this Agreement;
24
+ b. You shall cause any modified files to carry prominent notices stating that You changed the files;
25
+ c. You shall retain in all copies of the Materials that You distribute the following attribution notices within a "Notice" text file distributed as a part of such copies: "Tongyi Qianwen is licensed under the Tongyi Qianwen LICENSE AGREEMENT, Copyright (c) Alibaba Cloud. All Rights Reserved."; and
26
+ d. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such derivative works as a whole, provided Your use, reproduction, and distribution of the work otherwise complies with the terms and conditions of this Agreement.
27
+
28
+ 4. Restrictions
29
+ If you are commercially using the Materials, and your product or service has more than 100 million monthly active users, You shall request a license from Us. You cannot exercise your rights under this Agreement without our express authorization.
30
+
31
+ 5. Rules of use
32
+ a. The Materials may be subject to export controls or restrictions in China, the United States or other countries or regions. You shall comply with applicable laws and regulations in your use of the Materials.
33
+ b. You can not use the Materials or any output therefrom to improve any other large language model (excluding Tongyi Qianwen or derivative works thereof).
34
+
35
+ 6. Intellectual Property
36
+ a. We retain ownership of all intellectual property rights in and to the Materials and derivatives made by or for Us. Conditioned upon compliance with the terms and conditions of this Agreement, with respect to any derivative works and modifications of the Materials that are made by you, you are and will be the owner of such derivative works and modifications.
37
+ b. No trademark license is granted to use the trade names, trademarks, service marks, or product names of Us, except as required to fulfill notice requirements under this Agreement or as required for reasonable and customary use in describing and redistributing the Materials.
38
+ c. If you commence a lawsuit or other proceedings (including a cross-claim or counterclaim in a lawsuit) against Us or any entity alleging that the Materials or any output therefrom, or any part of the foregoing, infringe any intellectual property or other right owned or licensable by you, then all licences granted to you under this Agreement shall terminate as of the date such lawsuit or other proceeding is commenced or brought.
39
+
40
+ 7. Disclaimer of Warranty and Limitation of Liability
41
+
42
+ a. We are not obligated to support, update, provide training for, or develop any further version of the Tongyi Qianwen Materials or to grant any license thereto.
43
+ b. THE MATERIALS ARE PROVIDED "AS IS" WITHOUT ANY EXPRESS OR IMPLIED WARRANTY OF ANY KIND INCLUDING WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT, OR FITNESS FOR A PARTICULAR PURPOSE. WE MAKE NO WARRANTY AND ASSUME NO RESPONSIBILITY FOR THE SAFETY OR STABILITY OF THE MATERIALS AND ANY OUTPUT THEREFROM.
44
+ c. IN NO EVENT SHALL WE BE LIABLE TO YOU FOR ANY DAMAGES, INCLUDING, BUT NOT LIMITED TO ANY DIRECT, OR INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING FROM YOUR USE OR INABILITY TO USE THE MATERIALS OR ANY OUTPUT OF IT, NO MATTER HOW IT’S CAUSED.
45
+ d. You will defend, indemnify and hold harmless Us from and against any claim by any third party arising out of or related to your use or distribution of the Materials.
46
+
47
+ 8. Survival and Termination.
48
+ a. The term of this Agreement shall commence upon your acceptance of this Agreement or access to the Materials and will continue in full force and effect until terminated in accordance with the terms and conditions herein.
49
+ b. We may terminate this Agreement if you breach any of the terms or conditions of this Agreement. Upon termination of this Agreement, you must delete and cease use of the Materials. Sections 7 and 9 shall survive the termination of this Agreement.
50
+
51
+ 9. Governing Law and Jurisdiction.
52
+ a. This Agreement and any dispute arising out of or relating to it will be governed by the laws of China, without regard to conflict of law principles, and the UN Convention on Contracts for the International Sale of Goods does not apply to this Agreement.
53
+ b. The People's Courts in Hangzhou City shall have exclusive jurisdiction over any dispute arising out of this Agreement.
README.md CHANGED
@@ -1,5 +1,81 @@
1
- ---
2
- license: other
3
- license_name: tongyi-qwen
4
- license_link: LICENSE
5
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ## CodeFuse-CGE-Large
2
+ CodeFuse-CGE-Large is the Large version of the CodeFuse-CGE family which is fine-tuned based on CodeQwen1.5-7B. CodeFuse-CGE-Large is distinguish on text2code task for it's powerful ability of capturing the semantic relationship between code and text.
3
+
4
+ This model has the following notable features:
5
+ ● Instruction-tuning is enabled for both query and code snippet sides.
6
+ ● The model obtains sentence-level and code-level representations through a layer of cross-attention computation module.
7
+ ● The model has a smaller dimensional size without significant degradation in performance.
8
+
9
+ Model Configuration
10
+ Model Size: 7B
11
+ Embedding Dimension: 1024
12
+ Hidden Layers: 32
13
+ Max Input Tokens: 1024
14
+
15
+
16
+ Requirements
17
+ ```
18
+ flash_attn==2.4.2
19
+ torch==2.1.0
20
+ accelerate==0.28.0
21
+ transformers==4.39.2
22
+ vllm=0.5.3
23
+ ```
24
+
25
+
26
+ ## How to Use
27
+ ### transformers
28
+ ```
29
+ from transformers import AutoTokenizer, AutoModel
30
+
31
+ model_name_or_path = "CodeFuse-CGE-Large"
32
+ model = AutoModel.from_pretrained(model_name_or_path, trust_remote_code=True)
33
+ tokenizer = AutoTokenizer.from_pretrained(model_name_or_path, trust_remote_code=True, truncation_side='right', padding_side='right')
34
+ model = model.to(torch.bfloat16)
35
+
36
+ if torch.cuda.is_available():
37
+ device = 'cuda'
38
+ else:
39
+ device = 'cpu'
40
+ model.to(device)
41
+
42
+ prefix_dict = {'python':{'query':'Retrieve the Python code that solves the following query:', 'passage':'Python code:'},
43
+ 'java':{'query':'Retrieve the Java code that solves the following query:', 'passage':'Java code:'},
44
+ 'go':{'query':'Retrieve the Go code that solves the following query:', 'passage':'Go code:'},
45
+ 'c++':{'query':'Retrieve the C++ code that solves the following query:', 'passage':'C++ code:'},
46
+ 'javascript':{'query':'Retrieve the Javascript code that solves the following query:', 'passage':'Javascript code:'},
47
+ 'php':{'query':'Retrieve the PHP code that solves the following query:', 'passage':'PHP code:'},
48
+ 'ruby':{'query':'Retrieve the Ruby code that solves the following query:', 'passage':'Ruby code:'},
49
+ 'default':{'query':'Retrieve the code that solves the following query:', 'passage':'Code:'}
50
+ }
51
+
52
+ text = ["Writes a Boolean to the stream.",
53
+ "def writeBoolean(self, n): t = TYPE_BOOL_TRUE if n is False: t = TYPE_BOOL_FALSE self.stream.write(t)"]
54
+ text[0] += prefix_dict['python']['query']
55
+ text[0] += prefix_dict['python']['passage']
56
+ embed = model.encode(tokenizer, text)
57
+ score = embed[0] @ embed[1].T
58
+ print("score", score)
59
+
60
+ ```
61
+
62
+ ## Benchmark the Performance
63
+ We use MRR metric to evaluate the ability on text2code retrieval tasks: AdvTest, CosQA, CSN
64
+
65
+
66
+ ![result](./result.png)
67
+
68
+ ## Acknowledgement
69
+ Thanks to the authors of open-sourced datasets, including CSN, Adv, CoSQA.
70
+
71
+ ## License
72
+ Since CodeFuse-CGE-Large is fine-tuned based on CodeQwen1.5-7B model, our usage license follows the same terms as that of CodeQwen1.5-7B model.
73
+
74
+ ## 加入我们
75
+ 我们是平台技术事业群AI Native团队,负责蚂蚁蚂蚁集团平台工程的智能化,团队成立3年多以来,支持了蚂蚁集团云计算基础设施智能化运维的升级改造。团队的Mission是,通过世界级的技术创新和影响,构建有广泛用户的算法服务和平台,支撑内外部产品和业务落地。团队秉承创新基因,在支撑业务落地的同时,推动技术影响。3年以来在ICLR、NeurIPS、KDD、ACL等顶会发表论文20余篇,创新业务结果获得两次蚂蚁技术最高奖T-Star,1次蚂蚁集团最高奖SuperMA。开源项目CodeFuse获得4K点赞(2024年2月),Huggingface和modelscope上模型累积下载量超过150万次。
76
+
77
+ 我们正在寻找行业中的佼佼者加入我们的团队!如果您希望在一个充满活力、创新和卓越文化的环境中发展您的职业生涯,欢迎您查看我们的社招&校招机会,加入我们,一起创造下一个行业里程碑。
78
+
79
+ 校招:https://hrrecommend.antgroup.com/guide.html?code=8uoP5mlus5DqQYbE_EnqcE2FD5JZH21MwvMUIb9mb6X3osXPuBraG54SyM8GLn_7
80
+
81
+ 社招:https://talent.antgroup.com/off-campus-position?positionId=1933830
config.json ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "CodeFuse_CGE_Large"
4
+ ],
5
+ "auto_map": {
6
+ "AutoConfig": "configuration_codefuse_cge_large.CodeFuseCGELargeConfig",
7
+ "AutoModel": "modeling_codefuse_cge_large.CodeFuse_CGE_Large"
8
+ },
9
+ "attention_dropout": 0.0,
10
+ "bos_token_id": 2,
11
+ "embedding_dim": 4096,
12
+ "embedding_method": "pma",
13
+ "encoder_mode": "post_normal",
14
+ "eos_token_id": 2,
15
+ "hidden_act": "silu",
16
+ "hidden_size": 4096,
17
+ "inf_seq_length": 1024,
18
+ "initializer_range": 0.02,
19
+ "intermediate_size": 13440,
20
+ "keep_max_layer": 32,
21
+ "max_position_embeddings": 65536,
22
+ "max_window_layers": 28,
23
+ "model_type": "qwen2",
24
+ "num_attention_heads": 32,
25
+ "num_encoder_layers": 0,
26
+ "num_hidden_layers": 32,
27
+ "num_key_value_heads": 4,
28
+ "padding_side": "right",
29
+ "pma_ln": true,
30
+ "pma_norm": false,
31
+ "pma_norm_mode": "post_normal",
32
+ "pma_num_heads": 32,
33
+ "compress_dim": 1024,
34
+ "rms_norm_eps": 1e-05,
35
+ "rope_theta": 1000000,
36
+ "rotary_emb_base": 1000000,
37
+ "seq_length": 65536,
38
+ "sliding_window": null,
39
+ "tie_word_embeddings": false,
40
+ "torch_dtype": "bfloat16",
41
+ "transformers_version": "4.39.2",
42
+ "use_cache": true,
43
+ "use_sliding_window": false,
44
+ "vocab_size": 92416
45
+ }
configuration.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"task":"sentence-embedding"}
configuration_codefuse_cge_large.py ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import PretrainedConfig
2
+ from transformers.utils import logging
3
+
4
+
5
+ logger = logging.get_logger(__name__)
6
+
7
+
8
+ class CodeFuseCGELargeConfig(PretrainedConfig):
9
+ model_type = "qwen2"
10
+ keys_to_ignore_at_inference = ["past_key_values"]
11
+
12
+ def __init__(
13
+ self,
14
+ vocab_size=151936,
15
+ hidden_size=4096,
16
+ intermediate_size=22016,
17
+ num_hidden_layers=32,
18
+ num_attention_heads=32,
19
+ num_key_value_heads=32,
20
+ hidden_act="silu",
21
+ max_position_embeddings=32768,
22
+ initializer_range=0.02,
23
+ rms_norm_eps=1e-6,
24
+ use_cache=True,
25
+ tie_word_embeddings=False,
26
+ rope_theta=10000.0,
27
+ use_sliding_window=False,
28
+ sliding_window=4096,
29
+ max_window_layers=28,
30
+ attention_dropout=0.0,
31
+ embedding_method="pma",
32
+ inf_seq_length=1024,
33
+ padding_side="right",
34
+ compress_dim=1024,
35
+ keep_max_layer=32,
36
+ pma_num_heads=32,
37
+ pma_ln=True,
38
+ pma_norm=False,
39
+ pma_norm_mode="post_normal",
40
+ **kwargs,
41
+ ):
42
+ self.vocab_size = vocab_size
43
+ self.max_position_embeddings = max_position_embeddings
44
+ self.hidden_size = hidden_size
45
+ self.intermediate_size = intermediate_size
46
+ self.num_hidden_layers = num_hidden_layers
47
+ self.num_attention_heads = num_attention_heads
48
+ self.use_sliding_window = use_sliding_window
49
+ self.sliding_window = sliding_window if use_sliding_window else None
50
+ self.max_window_layers = max_window_layers
51
+
52
+ if num_key_value_heads is None:
53
+ num_key_value_heads = num_attention_heads
54
+
55
+ self.num_key_value_heads = num_key_value_heads
56
+ self.hidden_act = hidden_act
57
+ self.initializer_range = initializer_range
58
+ self.rms_norm_eps = rms_norm_eps
59
+ self.use_cache = use_cache
60
+ self.rope_theta = rope_theta
61
+ self.attention_dropout = attention_dropout
62
+
63
+ self.embedding_method = embedding_method
64
+ self.inf_seq_length = inf_seq_length
65
+ self.padding_side = padding_side
66
+ self.compress_dim = compress_dim
67
+ self.keep_max_layer = keep_max_layer
68
+ self.pma_num_heads = pma_num_heads
69
+ self.pma_ln = pma_ln
70
+ self.pma_norm = pma_norm
71
+ self.pma_norm_mode = pma_norm_mode
72
+
73
+ super().__init__(
74
+ tie_word_embeddings=tie_word_embeddings,
75
+ **kwargs,
76
+ )
model.safetensors.index.json ADDED
@@ -0,0 +1,407 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "metadata": {
3
+ "total_size": 29043118080
4
+ },
5
+ "weight_map": {
6
+ "mha_pma.S": "model-00006-of-00006.safetensors",
7
+ "mha_pma.mab.fc_k.bias": "model-00006-of-00006.safetensors",
8
+ "mha_pma.mab.fc_k.weight": "model-00006-of-00006.safetensors",
9
+ "mha_pma.mab.fc_o.bias": "model-00006-of-00006.safetensors",
10
+ "mha_pma.mab.fc_o.weight": "model-00006-of-00006.safetensors",
11
+ "mha_pma.mab.fc_q.bias": "model-00006-of-00006.safetensors",
12
+ "mha_pma.mab.fc_q.weight": "model-00006-of-00006.safetensors",
13
+ "mha_pma.mab.fc_v.bias": "model-00006-of-00006.safetensors",
14
+ "mha_pma.mab.fc_v.weight": "model-00006-of-00006.safetensors",
15
+ "mha_pma.mab.ln0.bias": "model-00006-of-00006.safetensors",
16
+ "mha_pma.mab.ln0.weight": "model-00006-of-00006.safetensors",
17
+ "mha_pma.mab.ln1.bias": "model-00006-of-00006.safetensors",
18
+ "mha_pma.mab.ln1.weight": "model-00006-of-00006.safetensors",
19
+ "plm_model.lm_head.weight": "model-00006-of-00006.safetensors",
20
+ "plm_model.model.embed_tokens.weight": "model-00001-of-00006.safetensors",
21
+ "plm_model.model.layers.0.input_layernorm.weight": "model-00001-of-00006.safetensors",
22
+ "plm_model.model.layers.0.mlp.down_proj.weight": "model-00001-of-00006.safetensors",
23
+ "plm_model.model.layers.0.mlp.gate_proj.weight": "model-00001-of-00006.safetensors",
24
+ "plm_model.model.layers.0.mlp.up_proj.weight": "model-00001-of-00006.safetensors",
25
+ "plm_model.model.layers.0.post_attention_layernorm.weight": "model-00001-of-00006.safetensors",
26
+ "plm_model.model.layers.0.self_attn.k_proj.bias": "model-00001-of-00006.safetensors",
27
+ "plm_model.model.layers.0.self_attn.k_proj.weight": "model-00001-of-00006.safetensors",
28
+ "plm_model.model.layers.0.self_attn.o_proj.weight": "model-00001-of-00006.safetensors",
29
+ "plm_model.model.layers.0.self_attn.q_proj.bias": "model-00001-of-00006.safetensors",
30
+ "plm_model.model.layers.0.self_attn.q_proj.weight": "model-00001-of-00006.safetensors",
31
+ "plm_model.model.layers.0.self_attn.v_proj.bias": "model-00001-of-00006.safetensors",
32
+ "plm_model.model.layers.0.self_attn.v_proj.weight": "model-00001-of-00006.safetensors",
33
+ "plm_model.model.layers.1.input_layernorm.weight": "model-00001-of-00006.safetensors",
34
+ "plm_model.model.layers.1.mlp.down_proj.weight": "model-00001-of-00006.safetensors",
35
+ "plm_model.model.layers.1.mlp.gate_proj.weight": "model-00001-of-00006.safetensors",
36
+ "plm_model.model.layers.1.mlp.up_proj.weight": "model-00001-of-00006.safetensors",
37
+ "plm_model.model.layers.1.post_attention_layernorm.weight": "model-00001-of-00006.safetensors",
38
+ "plm_model.model.layers.1.self_attn.k_proj.bias": "model-00001-of-00006.safetensors",
39
+ "plm_model.model.layers.1.self_attn.k_proj.weight": "model-00001-of-00006.safetensors",
40
+ "plm_model.model.layers.1.self_attn.o_proj.weight": "model-00001-of-00006.safetensors",
41
+ "plm_model.model.layers.1.self_attn.q_proj.bias": "model-00001-of-00006.safetensors",
42
+ "plm_model.model.layers.1.self_attn.q_proj.weight": "model-00001-of-00006.safetensors",
43
+ "plm_model.model.layers.1.self_attn.v_proj.bias": "model-00001-of-00006.safetensors",
44
+ "plm_model.model.layers.1.self_attn.v_proj.weight": "model-00001-of-00006.safetensors",
45
+ "plm_model.model.layers.10.input_layernorm.weight": "model-00003-of-00006.safetensors",
46
+ "plm_model.model.layers.10.mlp.down_proj.weight": "model-00003-of-00006.safetensors",
47
+ "plm_model.model.layers.10.mlp.gate_proj.weight": "model-00003-of-00006.safetensors",
48
+ "plm_model.model.layers.10.mlp.up_proj.weight": "model-00003-of-00006.safetensors",
49
+ "plm_model.model.layers.10.post_attention_layernorm.weight": "model-00003-of-00006.safetensors",
50
+ "plm_model.model.layers.10.self_attn.k_proj.bias": "model-00002-of-00006.safetensors",
51
+ "plm_model.model.layers.10.self_attn.k_proj.weight": "model-00002-of-00006.safetensors",
52
+ "plm_model.model.layers.10.self_attn.o_proj.weight": "model-00002-of-00006.safetensors",
53
+ "plm_model.model.layers.10.self_attn.q_proj.bias": "model-00002-of-00006.safetensors",
54
+ "plm_model.model.layers.10.self_attn.q_proj.weight": "model-00002-of-00006.safetensors",
55
+ "plm_model.model.layers.10.self_attn.v_proj.bias": "model-00002-of-00006.safetensors",
56
+ "plm_model.model.layers.10.self_attn.v_proj.weight": "model-00002-of-00006.safetensors",
57
+ "plm_model.model.layers.11.input_layernorm.weight": "model-00003-of-00006.safetensors",
58
+ "plm_model.model.layers.11.mlp.down_proj.weight": "model-00003-of-00006.safetensors",
59
+ "plm_model.model.layers.11.mlp.gate_proj.weight": "model-00003-of-00006.safetensors",
60
+ "plm_model.model.layers.11.mlp.up_proj.weight": "model-00003-of-00006.safetensors",
61
+ "plm_model.model.layers.11.post_attention_layernorm.weight": "model-00003-of-00006.safetensors",
62
+ "plm_model.model.layers.11.self_attn.k_proj.bias": "model-00003-of-00006.safetensors",
63
+ "plm_model.model.layers.11.self_attn.k_proj.weight": "model-00003-of-00006.safetensors",
64
+ "plm_model.model.layers.11.self_attn.o_proj.weight": "model-00003-of-00006.safetensors",
65
+ "plm_model.model.layers.11.self_attn.q_proj.bias": "model-00003-of-00006.safetensors",
66
+ "plm_model.model.layers.11.self_attn.q_proj.weight": "model-00003-of-00006.safetensors",
67
+ "plm_model.model.layers.11.self_attn.v_proj.bias": "model-00003-of-00006.safetensors",
68
+ "plm_model.model.layers.11.self_attn.v_proj.weight": "model-00003-of-00006.safetensors",
69
+ "plm_model.model.layers.12.input_layernorm.weight": "model-00003-of-00006.safetensors",
70
+ "plm_model.model.layers.12.mlp.down_proj.weight": "model-00003-of-00006.safetensors",
71
+ "plm_model.model.layers.12.mlp.gate_proj.weight": "model-00003-of-00006.safetensors",
72
+ "plm_model.model.layers.12.mlp.up_proj.weight": "model-00003-of-00006.safetensors",
73
+ "plm_model.model.layers.12.post_attention_layernorm.weight": "model-00003-of-00006.safetensors",
74
+ "plm_model.model.layers.12.self_attn.k_proj.bias": "model-00003-of-00006.safetensors",
75
+ "plm_model.model.layers.12.self_attn.k_proj.weight": "model-00003-of-00006.safetensors",
76
+ "plm_model.model.layers.12.self_attn.o_proj.weight": "model-00003-of-00006.safetensors",
77
+ "plm_model.model.layers.12.self_attn.q_proj.bias": "model-00003-of-00006.safetensors",
78
+ "plm_model.model.layers.12.self_attn.q_proj.weight": "model-00003-of-00006.safetensors",
79
+ "plm_model.model.layers.12.self_attn.v_proj.bias": "model-00003-of-00006.safetensors",
80
+ "plm_model.model.layers.12.self_attn.v_proj.weight": "model-00003-of-00006.safetensors",
81
+ "plm_model.model.layers.13.input_layernorm.weight": "model-00003-of-00006.safetensors",
82
+ "plm_model.model.layers.13.mlp.down_proj.weight": "model-00003-of-00006.safetensors",
83
+ "plm_model.model.layers.13.mlp.gate_proj.weight": "model-00003-of-00006.safetensors",
84
+ "plm_model.model.layers.13.mlp.up_proj.weight": "model-00003-of-00006.safetensors",
85
+ "plm_model.model.layers.13.post_attention_layernorm.weight": "model-00003-of-00006.safetensors",
86
+ "plm_model.model.layers.13.self_attn.k_proj.bias": "model-00003-of-00006.safetensors",
87
+ "plm_model.model.layers.13.self_attn.k_proj.weight": "model-00003-of-00006.safetensors",
88
+ "plm_model.model.layers.13.self_attn.o_proj.weight": "model-00003-of-00006.safetensors",
89
+ "plm_model.model.layers.13.self_attn.q_proj.bias": "model-00003-of-00006.safetensors",
90
+ "plm_model.model.layers.13.self_attn.q_proj.weight": "model-00003-of-00006.safetensors",
91
+ "plm_model.model.layers.13.self_attn.v_proj.bias": "model-00003-of-00006.safetensors",
92
+ "plm_model.model.layers.13.self_attn.v_proj.weight": "model-00003-of-00006.safetensors",
93
+ "plm_model.model.layers.14.input_layernorm.weight": "model-00003-of-00006.safetensors",
94
+ "plm_model.model.layers.14.mlp.down_proj.weight": "model-00003-of-00006.safetensors",
95
+ "plm_model.model.layers.14.mlp.gate_proj.weight": "model-00003-of-00006.safetensors",
96
+ "plm_model.model.layers.14.mlp.up_proj.weight": "model-00003-of-00006.safetensors",
97
+ "plm_model.model.layers.14.post_attention_layernorm.weight": "model-00003-of-00006.safetensors",
98
+ "plm_model.model.layers.14.self_attn.k_proj.bias": "model-00003-of-00006.safetensors",
99
+ "plm_model.model.layers.14.self_attn.k_proj.weight": "model-00003-of-00006.safetensors",
100
+ "plm_model.model.layers.14.self_attn.o_proj.weight": "model-00003-of-00006.safetensors",
101
+ "plm_model.model.layers.14.self_attn.q_proj.bias": "model-00003-of-00006.safetensors",
102
+ "plm_model.model.layers.14.self_attn.q_proj.weight": "model-00003-of-00006.safetensors",
103
+ "plm_model.model.layers.14.self_attn.v_proj.bias": "model-00003-of-00006.safetensors",
104
+ "plm_model.model.layers.14.self_attn.v_proj.weight": "model-00003-of-00006.safetensors",
105
+ "plm_model.model.layers.15.input_layernorm.weight": "model-00003-of-00006.safetensors",
106
+ "plm_model.model.layers.15.mlp.down_proj.weight": "model-00003-of-00006.safetensors",
107
+ "plm_model.model.layers.15.mlp.gate_proj.weight": "model-00003-of-00006.safetensors",
108
+ "plm_model.model.layers.15.mlp.up_proj.weight": "model-00003-of-00006.safetensors",
109
+ "plm_model.model.layers.15.post_attention_layernorm.weight": "model-00003-of-00006.safetensors",
110
+ "plm_model.model.layers.15.self_attn.k_proj.bias": "model-00003-of-00006.safetensors",
111
+ "plm_model.model.layers.15.self_attn.k_proj.weight": "model-00003-of-00006.safetensors",
112
+ "plm_model.model.layers.15.self_attn.o_proj.weight": "model-00003-of-00006.safetensors",
113
+ "plm_model.model.layers.15.self_attn.q_proj.bias": "model-00003-of-00006.safetensors",
114
+ "plm_model.model.layers.15.self_attn.q_proj.weight": "model-00003-of-00006.safetensors",
115
+ "plm_model.model.layers.15.self_attn.v_proj.bias": "model-00003-of-00006.safetensors",
116
+ "plm_model.model.layers.15.self_attn.v_proj.weight": "model-00003-of-00006.safetensors",
117
+ "plm_model.model.layers.16.input_layernorm.weight": "model-00004-of-00006.safetensors",
118
+ "plm_model.model.layers.16.mlp.down_proj.weight": "model-00004-of-00006.safetensors",
119
+ "plm_model.model.layers.16.mlp.gate_proj.weight": "model-00004-of-00006.safetensors",
120
+ "plm_model.model.layers.16.mlp.up_proj.weight": "model-00004-of-00006.safetensors",
121
+ "plm_model.model.layers.16.post_attention_layernorm.weight": "model-00004-of-00006.safetensors",
122
+ "plm_model.model.layers.16.self_attn.k_proj.bias": "model-00003-of-00006.safetensors",
123
+ "plm_model.model.layers.16.self_attn.k_proj.weight": "model-00003-of-00006.safetensors",
124
+ "plm_model.model.layers.16.self_attn.o_proj.weight": "model-00003-of-00006.safetensors",
125
+ "plm_model.model.layers.16.self_attn.q_proj.bias": "model-00003-of-00006.safetensors",
126
+ "plm_model.model.layers.16.self_attn.q_proj.weight": "model-00003-of-00006.safetensors",
127
+ "plm_model.model.layers.16.self_attn.v_proj.bias": "model-00003-of-00006.safetensors",
128
+ "plm_model.model.layers.16.self_attn.v_proj.weight": "model-00003-of-00006.safetensors",
129
+ "plm_model.model.layers.17.input_layernorm.weight": "model-00004-of-00006.safetensors",
130
+ "plm_model.model.layers.17.mlp.down_proj.weight": "model-00004-of-00006.safetensors",
131
+ "plm_model.model.layers.17.mlp.gate_proj.weight": "model-00004-of-00006.safetensors",
132
+ "plm_model.model.layers.17.mlp.up_proj.weight": "model-00004-of-00006.safetensors",
133
+ "plm_model.model.layers.17.post_attention_layernorm.weight": "model-00004-of-00006.safetensors",
134
+ "plm_model.model.layers.17.self_attn.k_proj.bias": "model-00004-of-00006.safetensors",
135
+ "plm_model.model.layers.17.self_attn.k_proj.weight": "model-00004-of-00006.safetensors",
136
+ "plm_model.model.layers.17.self_attn.o_proj.weight": "model-00004-of-00006.safetensors",
137
+ "plm_model.model.layers.17.self_attn.q_proj.bias": "model-00004-of-00006.safetensors",
138
+ "plm_model.model.layers.17.self_attn.q_proj.weight": "model-00004-of-00006.safetensors",
139
+ "plm_model.model.layers.17.self_attn.v_proj.bias": "model-00004-of-00006.safetensors",
140
+ "plm_model.model.layers.17.self_attn.v_proj.weight": "model-00004-of-00006.safetensors",
141
+ "plm_model.model.layers.18.input_layernorm.weight": "model-00004-of-00006.safetensors",
142
+ "plm_model.model.layers.18.mlp.down_proj.weight": "model-00004-of-00006.safetensors",
143
+ "plm_model.model.layers.18.mlp.gate_proj.weight": "model-00004-of-00006.safetensors",
144
+ "plm_model.model.layers.18.mlp.up_proj.weight": "model-00004-of-00006.safetensors",
145
+ "plm_model.model.layers.18.post_attention_layernorm.weight": "model-00004-of-00006.safetensors",
146
+ "plm_model.model.layers.18.self_attn.k_proj.bias": "model-00004-of-00006.safetensors",
147
+ "plm_model.model.layers.18.self_attn.k_proj.weight": "model-00004-of-00006.safetensors",
148
+ "plm_model.model.layers.18.self_attn.o_proj.weight": "model-00004-of-00006.safetensors",
149
+ "plm_model.model.layers.18.self_attn.q_proj.bias": "model-00004-of-00006.safetensors",
150
+ "plm_model.model.layers.18.self_attn.q_proj.weight": "model-00004-of-00006.safetensors",
151
+ "plm_model.model.layers.18.self_attn.v_proj.bias": "model-00004-of-00006.safetensors",
152
+ "plm_model.model.layers.18.self_attn.v_proj.weight": "model-00004-of-00006.safetensors",
153
+ "plm_model.model.layers.19.input_layernorm.weight": "model-00004-of-00006.safetensors",
154
+ "plm_model.model.layers.19.mlp.down_proj.weight": "model-00004-of-00006.safetensors",
155
+ "plm_model.model.layers.19.mlp.gate_proj.weight": "model-00004-of-00006.safetensors",
156
+ "plm_model.model.layers.19.mlp.up_proj.weight": "model-00004-of-00006.safetensors",
157
+ "plm_model.model.layers.19.post_attention_layernorm.weight": "model-00004-of-00006.safetensors",
158
+ "plm_model.model.layers.19.self_attn.k_proj.bias": "model-00004-of-00006.safetensors",
159
+ "plm_model.model.layers.19.self_attn.k_proj.weight": "model-00004-of-00006.safetensors",
160
+ "plm_model.model.layers.19.self_attn.o_proj.weight": "model-00004-of-00006.safetensors",
161
+ "plm_model.model.layers.19.self_attn.q_proj.bias": "model-00004-of-00006.safetensors",
162
+ "plm_model.model.layers.19.self_attn.q_proj.weight": "model-00004-of-00006.safetensors",
163
+ "plm_model.model.layers.19.self_attn.v_proj.bias": "model-00004-of-00006.safetensors",
164
+ "plm_model.model.layers.19.self_attn.v_proj.weight": "model-00004-of-00006.safetensors",
165
+ "plm_model.model.layers.2.input_layernorm.weight": "model-00001-of-00006.safetensors",
166
+ "plm_model.model.layers.2.mlp.down_proj.weight": "model-00001-of-00006.safetensors",
167
+ "plm_model.model.layers.2.mlp.gate_proj.weight": "model-00001-of-00006.safetensors",
168
+ "plm_model.model.layers.2.mlp.up_proj.weight": "model-00001-of-00006.safetensors",
169
+ "plm_model.model.layers.2.post_attention_layernorm.weight": "model-00001-of-00006.safetensors",
170
+ "plm_model.model.layers.2.self_attn.k_proj.bias": "model-00001-of-00006.safetensors",
171
+ "plm_model.model.layers.2.self_attn.k_proj.weight": "model-00001-of-00006.safetensors",
172
+ "plm_model.model.layers.2.self_attn.o_proj.weight": "model-00001-of-00006.safetensors",
173
+ "plm_model.model.layers.2.self_attn.q_proj.bias": "model-00001-of-00006.safetensors",
174
+ "plm_model.model.layers.2.self_attn.q_proj.weight": "model-00001-of-00006.safetensors",
175
+ "plm_model.model.layers.2.self_attn.v_proj.bias": "model-00001-of-00006.safetensors",
176
+ "plm_model.model.layers.2.self_attn.v_proj.weight": "model-00001-of-00006.safetensors",
177
+ "plm_model.model.layers.20.input_layernorm.weight": "model-00004-of-00006.safetensors",
178
+ "plm_model.model.layers.20.mlp.down_proj.weight": "model-00004-of-00006.safetensors",
179
+ "plm_model.model.layers.20.mlp.gate_proj.weight": "model-00004-of-00006.safetensors",
180
+ "plm_model.model.layers.20.mlp.up_proj.weight": "model-00004-of-00006.safetensors",
181
+ "plm_model.model.layers.20.post_attention_layernorm.weight": "model-00004-of-00006.safetensors",
182
+ "plm_model.model.layers.20.self_attn.k_proj.bias": "model-00004-of-00006.safetensors",
183
+ "plm_model.model.layers.20.self_attn.k_proj.weight": "model-00004-of-00006.safetensors",
184
+ "plm_model.model.layers.20.self_attn.o_proj.weight": "model-00004-of-00006.safetensors",
185
+ "plm_model.model.layers.20.self_attn.q_proj.bias": "model-00004-of-00006.safetensors",
186
+ "plm_model.model.layers.20.self_attn.q_proj.weight": "model-00004-of-00006.safetensors",
187
+ "plm_model.model.layers.20.self_attn.v_proj.bias": "model-00004-of-00006.safetensors",
188
+ "plm_model.model.layers.20.self_attn.v_proj.weight": "model-00004-of-00006.safetensors",
189
+ "plm_model.model.layers.21.input_layernorm.weight": "model-00004-of-00006.safetensors",
190
+ "plm_model.model.layers.21.mlp.down_proj.weight": "model-00004-of-00006.safetensors",
191
+ "plm_model.model.layers.21.mlp.gate_proj.weight": "model-00004-of-00006.safetensors",
192
+ "plm_model.model.layers.21.mlp.up_proj.weight": "model-00004-of-00006.safetensors",
193
+ "plm_model.model.layers.21.post_attention_layernorm.weight": "model-00004-of-00006.safetensors",
194
+ "plm_model.model.layers.21.self_attn.k_proj.bias": "model-00004-of-00006.safetensors",
195
+ "plm_model.model.layers.21.self_attn.k_proj.weight": "model-00004-of-00006.safetensors",
196
+ "plm_model.model.layers.21.self_attn.o_proj.weight": "model-00004-of-00006.safetensors",
197
+ "plm_model.model.layers.21.self_attn.q_proj.bias": "model-00004-of-00006.safetensors",
198
+ "plm_model.model.layers.21.self_attn.q_proj.weight": "model-00004-of-00006.safetensors",
199
+ "plm_model.model.layers.21.self_attn.v_proj.bias": "model-00004-of-00006.safetensors",
200
+ "plm_model.model.layers.21.self_attn.v_proj.weight": "model-00004-of-00006.safetensors",
201
+ "plm_model.model.layers.22.input_layernorm.weight": "model-00005-of-00006.safetensors",
202
+ "plm_model.model.layers.22.mlp.down_proj.weight": "model-00005-of-00006.safetensors",
203
+ "plm_model.model.layers.22.mlp.gate_proj.weight": "model-00005-of-00006.safetensors",
204
+ "plm_model.model.layers.22.mlp.up_proj.weight": "model-00005-of-00006.safetensors",
205
+ "plm_model.model.layers.22.post_attention_layernorm.weight": "model-00005-of-00006.safetensors",
206
+ "plm_model.model.layers.22.self_attn.k_proj.bias": "model-00004-of-00006.safetensors",
207
+ "plm_model.model.layers.22.self_attn.k_proj.weight": "model-00004-of-00006.safetensors",
208
+ "plm_model.model.layers.22.self_attn.o_proj.weight": "model-00004-of-00006.safetensors",
209
+ "plm_model.model.layers.22.self_attn.q_proj.bias": "model-00004-of-00006.safetensors",
210
+ "plm_model.model.layers.22.self_attn.q_proj.weight": "model-00004-of-00006.safetensors",
211
+ "plm_model.model.layers.22.self_attn.v_proj.bias": "model-00004-of-00006.safetensors",
212
+ "plm_model.model.layers.22.self_attn.v_proj.weight": "model-00004-of-00006.safetensors",
213
+ "plm_model.model.layers.23.input_layernorm.weight": "model-00005-of-00006.safetensors",
214
+ "plm_model.model.layers.23.mlp.down_proj.weight": "model-00005-of-00006.safetensors",
215
+ "plm_model.model.layers.23.mlp.gate_proj.weight": "model-00005-of-00006.safetensors",
216
+ "plm_model.model.layers.23.mlp.up_proj.weight": "model-00005-of-00006.safetensors",
217
+ "plm_model.model.layers.23.post_attention_layernorm.weight": "model-00005-of-00006.safetensors",
218
+ "plm_model.model.layers.23.self_attn.k_proj.bias": "model-00005-of-00006.safetensors",
219
+ "plm_model.model.layers.23.self_attn.k_proj.weight": "model-00005-of-00006.safetensors",
220
+ "plm_model.model.layers.23.self_attn.o_proj.weight": "model-00005-of-00006.safetensors",
221
+ "plm_model.model.layers.23.self_attn.q_proj.bias": "model-00005-of-00006.safetensors",
222
+ "plm_model.model.layers.23.self_attn.q_proj.weight": "model-00005-of-00006.safetensors",
223
+ "plm_model.model.layers.23.self_attn.v_proj.bias": "model-00005-of-00006.safetensors",
224
+ "plm_model.model.layers.23.self_attn.v_proj.weight": "model-00005-of-00006.safetensors",
225
+ "plm_model.model.layers.24.input_layernorm.weight": "model-00005-of-00006.safetensors",
226
+ "plm_model.model.layers.24.mlp.down_proj.weight": "model-00005-of-00006.safetensors",
227
+ "plm_model.model.layers.24.mlp.gate_proj.weight": "model-00005-of-00006.safetensors",
228
+ "plm_model.model.layers.24.mlp.up_proj.weight": "model-00005-of-00006.safetensors",
229
+ "plm_model.model.layers.24.post_attention_layernorm.weight": "model-00005-of-00006.safetensors",
230
+ "plm_model.model.layers.24.self_attn.k_proj.bias": "model-00005-of-00006.safetensors",
231
+ "plm_model.model.layers.24.self_attn.k_proj.weight": "model-00005-of-00006.safetensors",
232
+ "plm_model.model.layers.24.self_attn.o_proj.weight": "model-00005-of-00006.safetensors",
233
+ "plm_model.model.layers.24.self_attn.q_proj.bias": "model-00005-of-00006.safetensors",
234
+ "plm_model.model.layers.24.self_attn.q_proj.weight": "model-00005-of-00006.safetensors",
235
+ "plm_model.model.layers.24.self_attn.v_proj.bias": "model-00005-of-00006.safetensors",
236
+ "plm_model.model.layers.24.self_attn.v_proj.weight": "model-00005-of-00006.safetensors",
237
+ "plm_model.model.layers.25.input_layernorm.weight": "model-00005-of-00006.safetensors",
238
+ "plm_model.model.layers.25.mlp.down_proj.weight": "model-00005-of-00006.safetensors",
239
+ "plm_model.model.layers.25.mlp.gate_proj.weight": "model-00005-of-00006.safetensors",
240
+ "plm_model.model.layers.25.mlp.up_proj.weight": "model-00005-of-00006.safetensors",
241
+ "plm_model.model.layers.25.post_attention_layernorm.weight": "model-00005-of-00006.safetensors",
242
+ "plm_model.model.layers.25.self_attn.k_proj.bias": "model-00005-of-00006.safetensors",
243
+ "plm_model.model.layers.25.self_attn.k_proj.weight": "model-00005-of-00006.safetensors",
244
+ "plm_model.model.layers.25.self_attn.o_proj.weight": "model-00005-of-00006.safetensors",
245
+ "plm_model.model.layers.25.self_attn.q_proj.bias": "model-00005-of-00006.safetensors",
246
+ "plm_model.model.layers.25.self_attn.q_proj.weight": "model-00005-of-00006.safetensors",
247
+ "plm_model.model.layers.25.self_attn.v_proj.bias": "model-00005-of-00006.safetensors",
248
+ "plm_model.model.layers.25.self_attn.v_proj.weight": "model-00005-of-00006.safetensors",
249
+ "plm_model.model.layers.26.input_layernorm.weight": "model-00005-of-00006.safetensors",
250
+ "plm_model.model.layers.26.mlp.down_proj.weight": "model-00005-of-00006.safetensors",
251
+ "plm_model.model.layers.26.mlp.gate_proj.weight": "model-00005-of-00006.safetensors",
252
+ "plm_model.model.layers.26.mlp.up_proj.weight": "model-00005-of-00006.safetensors",
253
+ "plm_model.model.layers.26.post_attention_layernorm.weight": "model-00005-of-00006.safetensors",
254
+ "plm_model.model.layers.26.self_attn.k_proj.bias": "model-00005-of-00006.safetensors",
255
+ "plm_model.model.layers.26.self_attn.k_proj.weight": "model-00005-of-00006.safetensors",
256
+ "plm_model.model.layers.26.self_attn.o_proj.weight": "model-00005-of-00006.safetensors",
257
+ "plm_model.model.layers.26.self_attn.q_proj.bias": "model-00005-of-00006.safetensors",
258
+ "plm_model.model.layers.26.self_attn.q_proj.weight": "model-00005-of-00006.safetensors",
259
+ "plm_model.model.layers.26.self_attn.v_proj.bias": "model-00005-of-00006.safetensors",
260
+ "plm_model.model.layers.26.self_attn.v_proj.weight": "model-00005-of-00006.safetensors",
261
+ "plm_model.model.layers.27.input_layernorm.weight": "model-00005-of-00006.safetensors",
262
+ "plm_model.model.layers.27.mlp.down_proj.weight": "model-00005-of-00006.safetensors",
263
+ "plm_model.model.layers.27.mlp.gate_proj.weight": "model-00005-of-00006.safetensors",
264
+ "plm_model.model.layers.27.mlp.up_proj.weight": "model-00005-of-00006.safetensors",
265
+ "plm_model.model.layers.27.post_attention_layernorm.weight": "model-00005-of-00006.safetensors",
266
+ "plm_model.model.layers.27.self_attn.k_proj.bias": "model-00005-of-00006.safetensors",
267
+ "plm_model.model.layers.27.self_attn.k_proj.weight": "model-00005-of-00006.safetensors",
268
+ "plm_model.model.layers.27.self_attn.o_proj.weight": "model-00005-of-00006.safetensors",
269
+ "plm_model.model.layers.27.self_attn.q_proj.bias": "model-00005-of-00006.safetensors",
270
+ "plm_model.model.layers.27.self_attn.q_proj.weight": "model-00005-of-00006.safetensors",
271
+ "plm_model.model.layers.27.self_attn.v_proj.bias": "model-00005-of-00006.safetensors",
272
+ "plm_model.model.layers.27.self_attn.v_proj.weight": "model-00005-of-00006.safetensors",
273
+ "plm_model.model.layers.28.input_layernorm.weight": "model-00006-of-00006.safetensors",
274
+ "plm_model.model.layers.28.mlp.down_proj.weight": "model-00006-of-00006.safetensors",
275
+ "plm_model.model.layers.28.mlp.gate_proj.weight": "model-00006-of-00006.safetensors",
276
+ "plm_model.model.layers.28.mlp.up_proj.weight": "model-00006-of-00006.safetensors",
277
+ "plm_model.model.layers.28.post_attention_layernorm.weight": "model-00006-of-00006.safetensors",
278
+ "plm_model.model.layers.28.self_attn.k_proj.bias": "model-00005-of-00006.safetensors",
279
+ "plm_model.model.layers.28.self_attn.k_proj.weight": "model-00005-of-00006.safetensors",
280
+ "plm_model.model.layers.28.self_attn.o_proj.weight": "model-00005-of-00006.safetensors",
281
+ "plm_model.model.layers.28.self_attn.q_proj.bias": "model-00005-of-00006.safetensors",
282
+ "plm_model.model.layers.28.self_attn.q_proj.weight": "model-00005-of-00006.safetensors",
283
+ "plm_model.model.layers.28.self_attn.v_proj.bias": "model-00005-of-00006.safetensors",
284
+ "plm_model.model.layers.28.self_attn.v_proj.weight": "model-00005-of-00006.safetensors",
285
+ "plm_model.model.layers.29.input_layernorm.weight": "model-00006-of-00006.safetensors",
286
+ "plm_model.model.layers.29.mlp.down_proj.weight": "model-00006-of-00006.safetensors",
287
+ "plm_model.model.layers.29.mlp.gate_proj.weight": "model-00006-of-00006.safetensors",
288
+ "plm_model.model.layers.29.mlp.up_proj.weight": "model-00006-of-00006.safetensors",
289
+ "plm_model.model.layers.29.post_attention_layernorm.weight": "model-00006-of-00006.safetensors",
290
+ "plm_model.model.layers.29.self_attn.k_proj.bias": "model-00006-of-00006.safetensors",
291
+ "plm_model.model.layers.29.self_attn.k_proj.weight": "model-00006-of-00006.safetensors",
292
+ "plm_model.model.layers.29.self_attn.o_proj.weight": "model-00006-of-00006.safetensors",
293
+ "plm_model.model.layers.29.self_attn.q_proj.bias": "model-00006-of-00006.safetensors",
294
+ "plm_model.model.layers.29.self_attn.q_proj.weight": "model-00006-of-00006.safetensors",
295
+ "plm_model.model.layers.29.self_attn.v_proj.bias": "model-00006-of-00006.safetensors",
296
+ "plm_model.model.layers.29.self_attn.v_proj.weight": "model-00006-of-00006.safetensors",
297
+ "plm_model.model.layers.3.input_layernorm.weight": "model-00001-of-00006.safetensors",
298
+ "plm_model.model.layers.3.mlp.down_proj.weight": "model-00001-of-00006.safetensors",
299
+ "plm_model.model.layers.3.mlp.gate_proj.weight": "model-00001-of-00006.safetensors",
300
+ "plm_model.model.layers.3.mlp.up_proj.weight": "model-00001-of-00006.safetensors",
301
+ "plm_model.model.layers.3.post_attention_layernorm.weight": "model-00001-of-00006.safetensors",
302
+ "plm_model.model.layers.3.self_attn.k_proj.bias": "model-00001-of-00006.safetensors",
303
+ "plm_model.model.layers.3.self_attn.k_proj.weight": "model-00001-of-00006.safetensors",
304
+ "plm_model.model.layers.3.self_attn.o_proj.weight": "model-00001-of-00006.safetensors",
305
+ "plm_model.model.layers.3.self_attn.q_proj.bias": "model-00001-of-00006.safetensors",
306
+ "plm_model.model.layers.3.self_attn.q_proj.weight": "model-00001-of-00006.safetensors",
307
+ "plm_model.model.layers.3.self_attn.v_proj.bias": "model-00001-of-00006.safetensors",
308
+ "plm_model.model.layers.3.self_attn.v_proj.weight": "model-00001-of-00006.safetensors",
309
+ "plm_model.model.layers.30.input_layernorm.weight": "model-00006-of-00006.safetensors",
310
+ "plm_model.model.layers.30.mlp.down_proj.weight": "model-00006-of-00006.safetensors",
311
+ "plm_model.model.layers.30.mlp.gate_proj.weight": "model-00006-of-00006.safetensors",
312
+ "plm_model.model.layers.30.mlp.up_proj.weight": "model-00006-of-00006.safetensors",
313
+ "plm_model.model.layers.30.post_attention_layernorm.weight": "model-00006-of-00006.safetensors",
314
+ "plm_model.model.layers.30.self_attn.k_proj.bias": "model-00006-of-00006.safetensors",
315
+ "plm_model.model.layers.30.self_attn.k_proj.weight": "model-00006-of-00006.safetensors",
316
+ "plm_model.model.layers.30.self_attn.o_proj.weight": "model-00006-of-00006.safetensors",
317
+ "plm_model.model.layers.30.self_attn.q_proj.bias": "model-00006-of-00006.safetensors",
318
+ "plm_model.model.layers.30.self_attn.q_proj.weight": "model-00006-of-00006.safetensors",
319
+ "plm_model.model.layers.30.self_attn.v_proj.bias": "model-00006-of-00006.safetensors",
320
+ "plm_model.model.layers.30.self_attn.v_proj.weight": "model-00006-of-00006.safetensors",
321
+ "plm_model.model.layers.31.input_layernorm.weight": "model-00006-of-00006.safetensors",
322
+ "plm_model.model.layers.31.mlp.down_proj.weight": "model-00006-of-00006.safetensors",
323
+ "plm_model.model.layers.31.mlp.gate_proj.weight": "model-00006-of-00006.safetensors",
324
+ "plm_model.model.layers.31.mlp.up_proj.weight": "model-00006-of-00006.safetensors",
325
+ "plm_model.model.layers.31.post_attention_layernorm.weight": "model-00006-of-00006.safetensors",
326
+ "plm_model.model.layers.31.self_attn.k_proj.bias": "model-00006-of-00006.safetensors",
327
+ "plm_model.model.layers.31.self_attn.k_proj.weight": "model-00006-of-00006.safetensors",
328
+ "plm_model.model.layers.31.self_attn.o_proj.weight": "model-00006-of-00006.safetensors",
329
+ "plm_model.model.layers.31.self_attn.q_proj.bias": "model-00006-of-00006.safetensors",
330
+ "plm_model.model.layers.31.self_attn.q_proj.weight": "model-00006-of-00006.safetensors",
331
+ "plm_model.model.layers.31.self_attn.v_proj.bias": "model-00006-of-00006.safetensors",
332
+ "plm_model.model.layers.31.self_attn.v_proj.weight": "model-00006-of-00006.safetensors",
333
+ "plm_model.model.layers.4.input_layernorm.weight": "model-00002-of-00006.safetensors",
334
+ "plm_model.model.layers.4.mlp.down_proj.weight": "model-00002-of-00006.safetensors",
335
+ "plm_model.model.layers.4.mlp.gate_proj.weight": "model-00002-of-00006.safetensors",
336
+ "plm_model.model.layers.4.mlp.up_proj.weight": "model-00002-of-00006.safetensors",
337
+ "plm_model.model.layers.4.post_attention_layernorm.weight": "model-00002-of-00006.safetensors",
338
+ "plm_model.model.layers.4.self_attn.k_proj.bias": "model-00001-of-00006.safetensors",
339
+ "plm_model.model.layers.4.self_attn.k_proj.weight": "model-00001-of-00006.safetensors",
340
+ "plm_model.model.layers.4.self_attn.o_proj.weight": "model-00001-of-00006.safetensors",
341
+ "plm_model.model.layers.4.self_attn.q_proj.bias": "model-00001-of-00006.safetensors",
342
+ "plm_model.model.layers.4.self_attn.q_proj.weight": "model-00001-of-00006.safetensors",
343
+ "plm_model.model.layers.4.self_attn.v_proj.bias": "model-00001-of-00006.safetensors",
344
+ "plm_model.model.layers.4.self_attn.v_proj.weight": "model-00001-of-00006.safetensors",
345
+ "plm_model.model.layers.5.input_layernorm.weight": "model-00002-of-00006.safetensors",
346
+ "plm_model.model.layers.5.mlp.down_proj.weight": "model-00002-of-00006.safetensors",
347
+ "plm_model.model.layers.5.mlp.gate_proj.weight": "model-00002-of-00006.safetensors",
348
+ "plm_model.model.layers.5.mlp.up_proj.weight": "model-00002-of-00006.safetensors",
349
+ "plm_model.model.layers.5.post_attention_layernorm.weight": "model-00002-of-00006.safetensors",
350
+ "plm_model.model.layers.5.self_attn.k_proj.bias": "model-00002-of-00006.safetensors",
351
+ "plm_model.model.layers.5.self_attn.k_proj.weight": "model-00002-of-00006.safetensors",
352
+ "plm_model.model.layers.5.self_attn.o_proj.weight": "model-00002-of-00006.safetensors",
353
+ "plm_model.model.layers.5.self_attn.q_proj.bias": "model-00002-of-00006.safetensors",
354
+ "plm_model.model.layers.5.self_attn.q_proj.weight": "model-00002-of-00006.safetensors",
355
+ "plm_model.model.layers.5.self_attn.v_proj.bias": "model-00002-of-00006.safetensors",
356
+ "plm_model.model.layers.5.self_attn.v_proj.weight": "model-00002-of-00006.safetensors",
357
+ "plm_model.model.layers.6.input_layernorm.weight": "model-00002-of-00006.safetensors",
358
+ "plm_model.model.layers.6.mlp.down_proj.weight": "model-00002-of-00006.safetensors",
359
+ "plm_model.model.layers.6.mlp.gate_proj.weight": "model-00002-of-00006.safetensors",
360
+ "plm_model.model.layers.6.mlp.up_proj.weight": "model-00002-of-00006.safetensors",
361
+ "plm_model.model.layers.6.post_attention_layernorm.weight": "model-00002-of-00006.safetensors",
362
+ "plm_model.model.layers.6.self_attn.k_proj.bias": "model-00002-of-00006.safetensors",
363
+ "plm_model.model.layers.6.self_attn.k_proj.weight": "model-00002-of-00006.safetensors",
364
+ "plm_model.model.layers.6.self_attn.o_proj.weight": "model-00002-of-00006.safetensors",
365
+ "plm_model.model.layers.6.self_attn.q_proj.bias": "model-00002-of-00006.safetensors",
366
+ "plm_model.model.layers.6.self_attn.q_proj.weight": "model-00002-of-00006.safetensors",
367
+ "plm_model.model.layers.6.self_attn.v_proj.bias": "model-00002-of-00006.safetensors",
368
+ "plm_model.model.layers.6.self_attn.v_proj.weight": "model-00002-of-00006.safetensors",
369
+ "plm_model.model.layers.7.input_layernorm.weight": "model-00002-of-00006.safetensors",
370
+ "plm_model.model.layers.7.mlp.down_proj.weight": "model-00002-of-00006.safetensors",
371
+ "plm_model.model.layers.7.mlp.gate_proj.weight": "model-00002-of-00006.safetensors",
372
+ "plm_model.model.layers.7.mlp.up_proj.weight": "model-00002-of-00006.safetensors",
373
+ "plm_model.model.layers.7.post_attention_layernorm.weight": "model-00002-of-00006.safetensors",
374
+ "plm_model.model.layers.7.self_attn.k_proj.bias": "model-00002-of-00006.safetensors",
375
+ "plm_model.model.layers.7.self_attn.k_proj.weight": "model-00002-of-00006.safetensors",
376
+ "plm_model.model.layers.7.self_attn.o_proj.weight": "model-00002-of-00006.safetensors",
377
+ "plm_model.model.layers.7.self_attn.q_proj.bias": "model-00002-of-00006.safetensors",
378
+ "plm_model.model.layers.7.self_attn.q_proj.weight": "model-00002-of-00006.safetensors",
379
+ "plm_model.model.layers.7.self_attn.v_proj.bias": "model-00002-of-00006.safetensors",
380
+ "plm_model.model.layers.7.self_attn.v_proj.weight": "model-00002-of-00006.safetensors",
381
+ "plm_model.model.layers.8.input_layernorm.weight": "model-00002-of-00006.safetensors",
382
+ "plm_model.model.layers.8.mlp.down_proj.weight": "model-00002-of-00006.safetensors",
383
+ "plm_model.model.layers.8.mlp.gate_proj.weight": "model-00002-of-00006.safetensors",
384
+ "plm_model.model.layers.8.mlp.up_proj.weight": "model-00002-of-00006.safetensors",
385
+ "plm_model.model.layers.8.post_attention_layernorm.weight": "model-00002-of-00006.safetensors",
386
+ "plm_model.model.layers.8.self_attn.k_proj.bias": "model-00002-of-00006.safetensors",
387
+ "plm_model.model.layers.8.self_attn.k_proj.weight": "model-00002-of-00006.safetensors",
388
+ "plm_model.model.layers.8.self_attn.o_proj.weight": "model-00002-of-00006.safetensors",
389
+ "plm_model.model.layers.8.self_attn.q_proj.bias": "model-00002-of-00006.safetensors",
390
+ "plm_model.model.layers.8.self_attn.q_proj.weight": "model-00002-of-00006.safetensors",
391
+ "plm_model.model.layers.8.self_attn.v_proj.bias": "model-00002-of-00006.safetensors",
392
+ "plm_model.model.layers.8.self_attn.v_proj.weight": "model-00002-of-00006.safetensors",
393
+ "plm_model.model.layers.9.input_layernorm.weight": "model-00002-of-00006.safetensors",
394
+ "plm_model.model.layers.9.mlp.down_proj.weight": "model-00002-of-00006.safetensors",
395
+ "plm_model.model.layers.9.mlp.gate_proj.weight": "model-00002-of-00006.safetensors",
396
+ "plm_model.model.layers.9.mlp.up_proj.weight": "model-00002-of-00006.safetensors",
397
+ "plm_model.model.layers.9.post_attention_layernorm.weight": "model-00002-of-00006.safetensors",
398
+ "plm_model.model.layers.9.self_attn.k_proj.bias": "model-00002-of-00006.safetensors",
399
+ "plm_model.model.layers.9.self_attn.k_proj.weight": "model-00002-of-00006.safetensors",
400
+ "plm_model.model.layers.9.self_attn.o_proj.weight": "model-00002-of-00006.safetensors",
401
+ "plm_model.model.layers.9.self_attn.q_proj.bias": "model-00002-of-00006.safetensors",
402
+ "plm_model.model.layers.9.self_attn.q_proj.weight": "model-00002-of-00006.safetensors",
403
+ "plm_model.model.layers.9.self_attn.v_proj.bias": "model-00002-of-00006.safetensors",
404
+ "plm_model.model.layers.9.self_attn.v_proj.weight": "model-00002-of-00006.safetensors",
405
+ "plm_model.model.norm.weight": "model-00006-of-00006.safetensors"
406
+ }
407
+ }
modeling_codefuse_cge_large.py ADDED
@@ -0,0 +1,245 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import Qwen2Config
2
+ import inspect
3
+ import math
4
+ import os
5
+ import warnings
6
+ from typing import List, Optional, Tuple, Union
7
+
8
+ import torch
9
+ import torch.nn.functional as F
10
+ import torch.utils.checkpoint
11
+ from torch import nn
12
+ from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss
13
+ from transformers import PretrainedConfig
14
+
15
+ from transformers.activations import ACT2FN
16
+ from transformers.cache_utils import Cache, DynamicCache
17
+ 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
18
+ from transformers.modeling_outputs import BaseModelOutputWithPast, CausalLMOutputWithPast, SequenceClassifierOutputWithPast
19
+ from transformers.modeling_utils import PreTrainedModel
20
+ from transformers.utils import (
21
+ add_start_docstrings,
22
+ add_start_docstrings_to_model_forward,
23
+ is_flash_attn_2_available,
24
+ is_flash_attn_greater_or_equal_2_10,
25
+ logging,
26
+ replace_return_docstrings,
27
+ )
28
+ import numpy as np
29
+ from transformers import Qwen2Config
30
+ from transformers import Qwen2ForCausalLM
31
+ import inspect
32
+ import math
33
+ import os
34
+ import warnings
35
+ from typing import List, Optional, Tuple, Union
36
+ from tqdm import tqdm, trange
37
+ import torch
38
+ import torch.nn.functional as F
39
+ import torch.utils.checkpoint
40
+ from torch import nn
41
+ from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss
42
+
43
+ from transformers.activations import ACT2FN
44
+ from transformers.cache_utils import Cache, DynamicCache
45
+ 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
46
+ from transformers.modeling_outputs import BaseModelOutputWithPast, CausalLMOutputWithPast, SequenceClassifierOutputWithPast
47
+ from transformers.modeling_utils import PreTrainedModel
48
+ from transformers.utils import (
49
+ add_start_docstrings,
50
+ add_start_docstrings_to_model_forward,
51
+ is_flash_attn_2_available,
52
+ is_flash_attn_greater_or_equal_2_10,
53
+ logging,
54
+ replace_return_docstrings,
55
+ )
56
+ import numpy as np
57
+ import torch
58
+ import os
59
+ import argparse
60
+ import json
61
+ from tqdm import tqdm
62
+ from typing import cast, List, Union, Tuple
63
+ from transformers import AutoTokenizer, AutoModel # pylint: disable=C0413
64
+ from peft import LoraConfig, get_peft_model, TaskType
65
+ import time
66
+ import torch.nn.functional as F
67
+ import sys
68
+ import time
69
+ import torch
70
+ import torch.nn as nn
71
+ import torch.nn.functional as F
72
+ import numpy as np
73
+ from tqdm import tqdm, trange
74
+ from collections import defaultdict
75
+ from transformers import AutoTokenizer, AutoModel, AutoModelForCausalLM, AutoConfig
76
+ import torch.distributed as dist
77
+ from deepspeed.utils.zero_to_fp32 import get_fp32_state_dict_from_zero_checkpoint
78
+ import sys
79
+ import torch
80
+ import torch.nn as nn
81
+ import torch.nn.functional as F
82
+ import math
83
+ import re
84
+
85
+
86
+ class MAB_POST(nn.Module):
87
+ def __init__(self, dim_Q, dim_K, dim_V, num_heads, ln=False):
88
+ super(MAB_POST, self).__init__()
89
+ self.dim_V = dim_V
90
+ self.num_heads = num_heads
91
+ self.fc_q = nn.Linear(dim_Q, dim_V)
92
+ self.fc_k = nn.Linear(dim_K, dim_V)
93
+ self.fc_v = nn.Linear(dim_K, dim_V)
94
+ if ln:
95
+ self.ln0 = nn.LayerNorm(dim_V)
96
+ self.ln1 = nn.LayerNorm(dim_V)
97
+ self.fc_o = nn.Linear(dim_V, dim_V)
98
+ nn.init.xavier_uniform_(self.fc_q.weight)
99
+ nn.init.xavier_uniform_(self.fc_k.weight)
100
+ nn.init.xavier_uniform_(self.fc_v.weight)
101
+ nn.init.xavier_uniform_(self.fc_o.weight)
102
+
103
+ def forward(self, Q, K, pad_mask=None):
104
+
105
+ Q_ = self.fc_q(Q)
106
+ K_, V_ = self.fc_k(K), self.fc_v(K)
107
+
108
+ dim_split = self.dim_V // self.num_heads
109
+ Q_ = torch.cat(Q_.split(dim_split, 2), 0)
110
+ K_ = torch.cat(K_.split(dim_split, 2), 0)
111
+ V_ = torch.cat(V_.split(dim_split, 2), 0)
112
+
113
+ pad_mask = pad_mask.unsqueeze(1).repeat(self.num_heads, Q.size(1), 1)
114
+ score = Q_.bmm(K_.transpose(1,2))/math.sqrt(self.dim_V)
115
+ score = score.masked_fill(pad_mask == 0, -1e12)
116
+ A = torch.softmax(score, 2)
117
+ A = A * pad_mask
118
+ O = torch.cat(A.bmm(V_).split(Q.size(0), 0), 2)
119
+ O = Q + O
120
+ O = O if getattr(self, 'ln0', None) is None else self.ln0(O)
121
+ O = O + F.relu(self.fc_o(O))
122
+ O = O if getattr(self, 'ln1', None) is None else self.ln1(O)
123
+ return O
124
+
125
+
126
+ class PMA(nn.Module):
127
+ def __init__(self, dim, compress_dim, num_heads, num_seeds, ln=False, pma_mode=None):
128
+ super(PMA, self).__init__()
129
+ self.S = nn.Parameter(torch.Tensor(1, num_seeds, compress_dim))
130
+ nn.init.xavier_uniform_(self.S)
131
+ if pma_mode == 'post_normal':
132
+ self.mab = MAB_POST(compress_dim, dim, compress_dim, num_heads, ln=ln)
133
+ elif pma_mode == 'pre_normal':
134
+ self.mab = MAB_PRE_NORMAL(compress_dim, dim, compress_dim, num_heads, ln=ln)
135
+ elif pma_mode == 'pre_gptj':
136
+ self.mab = MAB_PRE_GPTJ(compress_dim, dim, compress_dim, num_heads, ln=ln)
137
+ else:
138
+ raise ValueError(f"Error, the pma_mode {pma_mode} is not implemented !")
139
+
140
+ def forward(self, X, pad_mask):
141
+ if self.S.dtype != torch.bfloat16:
142
+ X = X.float()
143
+ return self.mab(self.S.repeat(X.size(0), 1, 1), X, pad_mask)
144
+
145
+
146
+ class CodeFuse_CGE_Large(PreTrainedModel):
147
+
148
+ def __init__(self, config):
149
+ super().__init__(config)
150
+ self.plm_model = Qwen2ForCausalLM(config)
151
+ self.embedding_method = config.embedding_method
152
+ self.inf_seq_length = config.inf_seq_length
153
+ self.padding_side = config.padding_side
154
+
155
+ self.keep_max_layer = config.keep_max_layer
156
+ self.emb_dim = self.plm_model.model.embed_tokens.weight.size(1)
157
+ self.num_heads = config.pma_num_heads
158
+ self.ln = config.pma_ln
159
+ self.norm = config.pma_norm
160
+ self.compress_dim = config.compress_dim
161
+ self.pma_mode = config.pma_norm_mode
162
+ self.mha_pma = PMA(self.emb_dim, self.compress_dim, self.num_heads, 1, ln=self.ln, pma_mode=self.pma_mode)
163
+
164
+ def last_embedding(self, A, index):
165
+ bs, seq, emb = A.size()
166
+ res = A[torch.arange(bs), index, :]
167
+ return res
168
+
169
+ def mean_embedding(self, A, mask):
170
+ bs, seq, emb = A.size()
171
+ res = (A * (mask.unsqueeze(-1))).sum(1) / (mask.sum(1).unsqueeze(-1))
172
+ return res
173
+
174
+ def weighted_embedding(self, A, mask):
175
+ weights = (torch.arange(start=1, end=A.size(1) + 1).unsqueeze(0).unsqueeze(-1).expand(A.size()).float()).to(A.device)
176
+ input_mask_expanded = (mask.squeeze(1).unsqueeze(-1).expand(A.size()).float()).to(A.device)
177
+ sum_embedding = torch.sum(A * input_mask_expanded * weights, dim=1)
178
+ sum_mask = torch.sum(input_mask_expanded * weights, dim=1)
179
+ weighted_embedding = sum_embedding / sum_mask
180
+ return weighted_embedding
181
+
182
+ def pma_embedding(self, A, mask):
183
+ res = self.mha_pma(A, mask).squeeze(1)
184
+ return res
185
+
186
+ def get_sentence_embedding(self, embedding_method, **inputs):
187
+ outputs = self.plm_model(inputs['input_ids'], inputs['attention_mask'], output_hidden_states=True)
188
+ if embedding_method == 'last':
189
+ embedding = outputs.hidden_states[self.keep_max_layer]
190
+ index = inputs['attention_mask'].sum(-1).long() - 1
191
+ res_embedding = self.last_embedding(embedding, index)
192
+ elif embedding_method == 'mean':
193
+ embedding = outputs.hidden_states[self.keep_max_layer]
194
+ res_embedding = self.mean_embedding(embedding, inputs['attention_mask'])
195
+ elif embedding_method == 'weighted':
196
+ embedding = outputs.hidden_states[self.keep_max_layer]
197
+ res_embedding = self.weighted_embedding(embedding, inputs['attention_mask'])
198
+ elif embedding_method == 'pma':
199
+ embedding = outputs.hidden_states[self.keep_max_layer]
200
+ attention_mask = inputs['attention_mask']
201
+ res_embedding = self.pma_embedding(embedding, attention_mask)
202
+ else:
203
+ logger.debug('Error, no {} way to obtain embbedings'.format(embedding_method))
204
+
205
+ if not self.norm:
206
+ res_embedding = torch.nn.functional.normalize(res_embedding, p=2.0, dim=-1, eps=1e-12, out=None)
207
+ return res_embedding
208
+
209
+
210
+ def encode(self, tokenizer, sentences, batch_size=32, convert_to_numpy=True,
211
+ convert_to_tensor=False, show_progress_bar=True, max_seq_length=None, **kwargs):
212
+
213
+ if max_seq_length is None:
214
+ max_seq_length = self.inf_seq_length
215
+
216
+ input_is_string = False
217
+ if isinstance(sentences, str) or not hasattr(sentences, "__len__"):
218
+ sentences = [sentences]
219
+ input_is_string = True
220
+
221
+ all_embeddings = []
222
+ length_sorted_idx = np.argsort([-len(s) for s in sentences])
223
+ sentences_sorted = [sentences[idx] for idx in length_sorted_idx]
224
+ with torch.no_grad():
225
+ for start_index in trange(0, len(sentences), batch_size, desc="Batches", disable=not show_progress_bar):
226
+ sentences_batch = sentences_sorted[start_index: start_index + batch_size]
227
+ with torch.no_grad():
228
+ 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)
229
+ embeddings = self.get_sentence_embedding(self.embedding_method, **inputs)
230
+ embeddings = embeddings.detach()
231
+ if convert_to_numpy:
232
+ if embeddings.dtype == torch.bfloat16:
233
+ embeddings = embeddings.cpu().to(torch.float32)
234
+ else:
235
+ embeddings = embeddings.cpu()
236
+ all_embeddings.extend(embeddings)
237
+ all_embeddings = [all_embeddings[idx] for idx in np.argsort(length_sorted_idx)]
238
+ if convert_to_tensor:
239
+ all_embeddings = torch.stack(all_embeddings)
240
+ elif convert_to_numpy:
241
+ all_embeddings = np.asarray([emb.numpy() for emb in all_embeddings])
242
+
243
+ if input_is_string:
244
+ all_embeddings = all_embeddings[0]
245
+ 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:656b66a920a54bc45e8e06dc587691ab3c0b2930b9ae56d5fa31e72db2f3bff3
3
+ size 1423961
tokenizer_config.json ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_bos_token": false,
3
+ "add_eos_token": false,
4
+ "add_prefix_space": false,
5
+ "additional_special_tokens": ["<|im_start|>", "<|im_end|>", "<fim_prefix>", "<fim_middle>", "<fim_suffix>", "<fim_pad>"],
6
+ "bos_token": "<|endoftext|>",
7
+ "clean_up_tokenization_spaces": false,
8
+ "eos_token": "<|im_end|>",
9
+ "legacy": false,
10
+ "model_max_length": 1000000000000000019884624838656,
11
+ "pad_token": "<fim_pad>",
12
+ "sp_model_kwargs": {},
13
+ "spaces_between_special_tokens": false,
14
+ "tokenizer_class": "PreTrainedTokenizerFast",
15
+ "unk_token": "<unk>",
16
+ "use_default_system_prompt": false,
17
+ "add_prefix_space": true,
18
+ "chat_template": "{% for message in messages %}{% if loop.first and messages[0]['role'] != 'system' %}{{ '<|im_start|>system\nYou are a helpful assistant<|im_end|>\n' }}{% endif %}{{'<|im_start|>' + message['role'] + '\n' + message['content'] + '<|im_end|>' + '\n'}}{% endfor %}{% if add_generation_prompt %}{{ '<|im_start|>assistant\n' }}{% endif %}"
19
+ }