Upload folder using huggingface_hub
Browse files- config.json +19 -0
- model.safetensors +3 -0
- preprocessor_config.json +23 -0
- processor_config.json +9 -0
- pytorch_model.bin.index.json +280 -0
- special_tokens_map.json +16 -0
- test_conv.py +365 -0
- tokenizer.json +0 -0
- tokenizer_config.json +11 -0
config.json
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"architectures": [
|
| 3 |
+
"LlamaForCausalLM"
|
| 4 |
+
],
|
| 5 |
+
"max_position_embeddings": 16384,
|
| 6 |
+
"model_type": "llama",
|
| 7 |
+
"num_hidden_layers": 30,
|
| 8 |
+
"hidden_size": 4096,
|
| 9 |
+
"intermediate_size": 11008,
|
| 10 |
+
"head_dim": 128,
|
| 11 |
+
"num_attention_heads": 32,
|
| 12 |
+
"num_key_value_heads": 32,
|
| 13 |
+
"rms_norm_eps": 1e-06,
|
| 14 |
+
"rope_theta": 10000.0,
|
| 15 |
+
"tie_word_embeddings": false,
|
| 16 |
+
"torch_dtype": "bfloat16",
|
| 17 |
+
"vocab_size": 102400,
|
| 18 |
+
"transformers_version": "4.33.1"
|
| 19 |
+
}
|
model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e7849160fbd3cbf16c2553345ee599bc7054cfb5bd899c4fa7c201e66adaa19a
|
| 3 |
+
size 13820763056
|
preprocessor_config.json
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"background_color": [
|
| 3 |
+
127,
|
| 4 |
+
127,
|
| 5 |
+
127
|
| 6 |
+
],
|
| 7 |
+
"do_normalize": true,
|
| 8 |
+
"image_mean": [
|
| 9 |
+
0.5,
|
| 10 |
+
0.5,
|
| 11 |
+
0.5
|
| 12 |
+
],
|
| 13 |
+
"image_processor_type": "VLMImageProcessor",
|
| 14 |
+
"image_size": 384,
|
| 15 |
+
"image_std": [
|
| 16 |
+
0.5,
|
| 17 |
+
0.5,
|
| 18 |
+
0.5
|
| 19 |
+
],
|
| 20 |
+
"min_size": 14,
|
| 21 |
+
"processor_class": "VLChatProcessor",
|
| 22 |
+
"rescale_factor": 0.00392156862745098
|
| 23 |
+
}
|
processor_config.json
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"add_special_token": false,
|
| 3 |
+
"ignore_id": -100,
|
| 4 |
+
"image_tag": "<image_placeholder>",
|
| 5 |
+
"mask_prompt": true,
|
| 6 |
+
"num_image_tokens": 576,
|
| 7 |
+
"processor_class": "VLChatProcessor",
|
| 8 |
+
"sft_format": "deepseek"
|
| 9 |
+
}
|
pytorch_model.bin.index.json
ADDED
|
@@ -0,0 +1,280 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"metadata": {
|
| 3 |
+
"total_size": 14840868118
|
| 4 |
+
},
|
| 5 |
+
"weight_map": {
|
| 6 |
+
"lm_head.weight": "pytorch_model.bin",
|
| 7 |
+
"model.embed_tokens.weight": "pytorch_model.bin",
|
| 8 |
+
"model.layers.0.input_layernorm.weight": "pytorch_model.bin",
|
| 9 |
+
"model.layers.0.mlp.down_proj.weight": "pytorch_model.bin",
|
| 10 |
+
"model.layers.0.mlp.gate_proj.weight": "pytorch_model.bin",
|
| 11 |
+
"model.layers.0.mlp.up_proj.weight": "pytorch_model.bin",
|
| 12 |
+
"model.layers.0.post_attention_layernorm.weight": "pytorch_model.bin",
|
| 13 |
+
"model.layers.0.self_attn.k_proj.weight": "pytorch_model.bin",
|
| 14 |
+
"model.layers.0.self_attn.o_proj.weight": "pytorch_model.bin",
|
| 15 |
+
"model.layers.0.self_attn.q_proj.weight": "pytorch_model.bin",
|
| 16 |
+
"model.layers.0.self_attn.v_proj.weight": "pytorch_model.bin",
|
| 17 |
+
"model.layers.1.input_layernorm.weight": "pytorch_model.bin",
|
| 18 |
+
"model.layers.1.mlp.down_proj.weight": "pytorch_model.bin",
|
| 19 |
+
"model.layers.1.mlp.gate_proj.weight": "pytorch_model.bin",
|
| 20 |
+
"model.layers.1.mlp.up_proj.weight": "pytorch_model.bin",
|
| 21 |
+
"model.layers.1.post_attention_layernorm.weight": "pytorch_model.bin",
|
| 22 |
+
"model.layers.1.self_attn.k_proj.weight": "pytorch_model.bin",
|
| 23 |
+
"model.layers.1.self_attn.o_proj.weight": "pytorch_model.bin",
|
| 24 |
+
"model.layers.1.self_attn.q_proj.weight": "pytorch_model.bin",
|
| 25 |
+
"model.layers.1.self_attn.v_proj.weight": "pytorch_model.bin",
|
| 26 |
+
"model.layers.10.input_layernorm.weight": "pytorch_model.bin",
|
| 27 |
+
"model.layers.10.mlp.down_proj.weight": "pytorch_model.bin",
|
| 28 |
+
"model.layers.10.mlp.gate_proj.weight": "pytorch_model.bin",
|
| 29 |
+
"model.layers.10.mlp.up_proj.weight": "pytorch_model.bin",
|
| 30 |
+
"model.layers.10.post_attention_layernorm.weight": "pytorch_model.bin",
|
| 31 |
+
"model.layers.10.self_attn.k_proj.weight": "pytorch_model.bin",
|
| 32 |
+
"model.layers.10.self_attn.o_proj.weight": "pytorch_model.bin",
|
| 33 |
+
"model.layers.10.self_attn.q_proj.weight": "pytorch_model.bin",
|
| 34 |
+
"model.layers.10.self_attn.v_proj.weight": "pytorch_model.bin",
|
| 35 |
+
"model.layers.11.input_layernorm.weight": "pytorch_model.bin",
|
| 36 |
+
"model.layers.11.mlp.down_proj.weight": "pytorch_model.bin",
|
| 37 |
+
"model.layers.11.mlp.gate_proj.weight": "pytorch_model.bin",
|
| 38 |
+
"model.layers.11.mlp.up_proj.weight": "pytorch_model.bin",
|
| 39 |
+
"model.layers.11.post_attention_layernorm.weight": "pytorch_model.bin",
|
| 40 |
+
"model.layers.11.self_attn.k_proj.weight": "pytorch_model.bin",
|
| 41 |
+
"model.layers.11.self_attn.o_proj.weight": "pytorch_model.bin",
|
| 42 |
+
"model.layers.11.self_attn.q_proj.weight": "pytorch_model.bin",
|
| 43 |
+
"model.layers.11.self_attn.v_proj.weight": "pytorch_model.bin",
|
| 44 |
+
"model.layers.12.input_layernorm.weight": "pytorch_model.bin",
|
| 45 |
+
"model.layers.12.mlp.down_proj.weight": "pytorch_model.bin",
|
| 46 |
+
"model.layers.12.mlp.gate_proj.weight": "pytorch_model.bin",
|
| 47 |
+
"model.layers.12.mlp.up_proj.weight": "pytorch_model.bin",
|
| 48 |
+
"model.layers.12.post_attention_layernorm.weight": "pytorch_model.bin",
|
| 49 |
+
"model.layers.12.self_attn.k_proj.weight": "pytorch_model.bin",
|
| 50 |
+
"model.layers.12.self_attn.o_proj.weight": "pytorch_model.bin",
|
| 51 |
+
"model.layers.12.self_attn.q_proj.weight": "pytorch_model.bin",
|
| 52 |
+
"model.layers.12.self_attn.v_proj.weight": "pytorch_model.bin",
|
| 53 |
+
"model.layers.13.input_layernorm.weight": "pytorch_model.bin",
|
| 54 |
+
"model.layers.13.mlp.down_proj.weight": "pytorch_model.bin",
|
| 55 |
+
"model.layers.13.mlp.gate_proj.weight": "pytorch_model.bin",
|
| 56 |
+
"model.layers.13.mlp.up_proj.weight": "pytorch_model.bin",
|
| 57 |
+
"model.layers.13.post_attention_layernorm.weight": "pytorch_model.bin",
|
| 58 |
+
"model.layers.13.self_attn.k_proj.weight": "pytorch_model.bin",
|
| 59 |
+
"model.layers.13.self_attn.o_proj.weight": "pytorch_model.bin",
|
| 60 |
+
"model.layers.13.self_attn.q_proj.weight": "pytorch_model.bin",
|
| 61 |
+
"model.layers.13.self_attn.v_proj.weight": "pytorch_model.bin",
|
| 62 |
+
"model.layers.14.input_layernorm.weight": "pytorch_model.bin",
|
| 63 |
+
"model.layers.14.mlp.down_proj.weight": "pytorch_model.bin",
|
| 64 |
+
"model.layers.14.mlp.gate_proj.weight": "pytorch_model.bin",
|
| 65 |
+
"model.layers.14.mlp.up_proj.weight": "pytorch_model.bin",
|
| 66 |
+
"model.layers.14.post_attention_layernorm.weight": "pytorch_model.bin",
|
| 67 |
+
"model.layers.14.self_attn.k_proj.weight": "pytorch_model.bin",
|
| 68 |
+
"model.layers.14.self_attn.o_proj.weight": "pytorch_model.bin",
|
| 69 |
+
"model.layers.14.self_attn.q_proj.weight": "pytorch_model.bin",
|
| 70 |
+
"model.layers.14.self_attn.v_proj.weight": "pytorch_model.bin",
|
| 71 |
+
"model.layers.15.input_layernorm.weight": "pytorch_model.bin",
|
| 72 |
+
"model.layers.15.mlp.down_proj.weight": "pytorch_model.bin",
|
| 73 |
+
"model.layers.15.mlp.gate_proj.weight": "pytorch_model.bin",
|
| 74 |
+
"model.layers.15.mlp.up_proj.weight": "pytorch_model.bin",
|
| 75 |
+
"model.layers.15.post_attention_layernorm.weight": "pytorch_model.bin",
|
| 76 |
+
"model.layers.15.self_attn.k_proj.weight": "pytorch_model.bin",
|
| 77 |
+
"model.layers.15.self_attn.o_proj.weight": "pytorch_model.bin",
|
| 78 |
+
"model.layers.15.self_attn.q_proj.weight": "pytorch_model.bin",
|
| 79 |
+
"model.layers.15.self_attn.v_proj.weight": "pytorch_model.bin",
|
| 80 |
+
"model.layers.16.input_layernorm.weight": "pytorch_model.bin",
|
| 81 |
+
"model.layers.16.mlp.down_proj.weight": "pytorch_model.bin",
|
| 82 |
+
"model.layers.16.mlp.gate_proj.weight": "pytorch_model.bin",
|
| 83 |
+
"model.layers.16.mlp.up_proj.weight": "pytorch_model.bin",
|
| 84 |
+
"model.layers.16.post_attention_layernorm.weight": "pytorch_model.bin",
|
| 85 |
+
"model.layers.16.self_attn.k_proj.weight": "pytorch_model.bin",
|
| 86 |
+
"model.layers.16.self_attn.o_proj.weight": "pytorch_model.bin",
|
| 87 |
+
"model.layers.16.self_attn.q_proj.weight": "pytorch_model.bin",
|
| 88 |
+
"model.layers.16.self_attn.v_proj.weight": "pytorch_model.bin",
|
| 89 |
+
"model.layers.17.input_layernorm.weight": "pytorch_model.bin",
|
| 90 |
+
"model.layers.17.mlp.down_proj.weight": "pytorch_model.bin",
|
| 91 |
+
"model.layers.17.mlp.gate_proj.weight": "pytorch_model.bin",
|
| 92 |
+
"model.layers.17.mlp.up_proj.weight": "pytorch_model.bin",
|
| 93 |
+
"model.layers.17.post_attention_layernorm.weight": "pytorch_model.bin",
|
| 94 |
+
"model.layers.17.self_attn.k_proj.weight": "pytorch_model.bin",
|
| 95 |
+
"model.layers.17.self_attn.o_proj.weight": "pytorch_model.bin",
|
| 96 |
+
"model.layers.17.self_attn.q_proj.weight": "pytorch_model.bin",
|
| 97 |
+
"model.layers.17.self_attn.v_proj.weight": "pytorch_model.bin",
|
| 98 |
+
"model.layers.18.input_layernorm.weight": "pytorch_model.bin",
|
| 99 |
+
"model.layers.18.mlp.down_proj.weight": "pytorch_model.bin",
|
| 100 |
+
"model.layers.18.mlp.gate_proj.weight": "pytorch_model.bin",
|
| 101 |
+
"model.layers.18.mlp.up_proj.weight": "pytorch_model.bin",
|
| 102 |
+
"model.layers.18.post_attention_layernorm.weight": "pytorch_model.bin",
|
| 103 |
+
"model.layers.18.self_attn.k_proj.weight": "pytorch_model.bin",
|
| 104 |
+
"model.layers.18.self_attn.o_proj.weight": "pytorch_model.bin",
|
| 105 |
+
"model.layers.18.self_attn.q_proj.weight": "pytorch_model.bin",
|
| 106 |
+
"model.layers.18.self_attn.v_proj.weight": "pytorch_model.bin",
|
| 107 |
+
"model.layers.19.input_layernorm.weight": "pytorch_model.bin",
|
| 108 |
+
"model.layers.19.mlp.down_proj.weight": "pytorch_model.bin",
|
| 109 |
+
"model.layers.19.mlp.gate_proj.weight": "pytorch_model.bin",
|
| 110 |
+
"model.layers.19.mlp.up_proj.weight": "pytorch_model.bin",
|
| 111 |
+
"model.layers.19.post_attention_layernorm.weight": "pytorch_model.bin",
|
| 112 |
+
"model.layers.19.self_attn.k_proj.weight": "pytorch_model.bin",
|
| 113 |
+
"model.layers.19.self_attn.o_proj.weight": "pytorch_model.bin",
|
| 114 |
+
"model.layers.19.self_attn.q_proj.weight": "pytorch_model.bin",
|
| 115 |
+
"model.layers.19.self_attn.v_proj.weight": "pytorch_model.bin",
|
| 116 |
+
"model.layers.2.input_layernorm.weight": "pytorch_model.bin",
|
| 117 |
+
"model.layers.2.mlp.down_proj.weight": "pytorch_model.bin",
|
| 118 |
+
"model.layers.2.mlp.gate_proj.weight": "pytorch_model.bin",
|
| 119 |
+
"model.layers.2.mlp.up_proj.weight": "pytorch_model.bin",
|
| 120 |
+
"model.layers.2.post_attention_layernorm.weight": "pytorch_model.bin",
|
| 121 |
+
"model.layers.2.self_attn.k_proj.weight": "pytorch_model.bin",
|
| 122 |
+
"model.layers.2.self_attn.o_proj.weight": "pytorch_model.bin",
|
| 123 |
+
"model.layers.2.self_attn.q_proj.weight": "pytorch_model.bin",
|
| 124 |
+
"model.layers.2.self_attn.v_proj.weight": "pytorch_model.bin",
|
| 125 |
+
"model.layers.20.input_layernorm.weight": "pytorch_model.bin",
|
| 126 |
+
"model.layers.20.mlp.down_proj.weight": "pytorch_model.bin",
|
| 127 |
+
"model.layers.20.mlp.gate_proj.weight": "pytorch_model.bin",
|
| 128 |
+
"model.layers.20.mlp.up_proj.weight": "pytorch_model.bin",
|
| 129 |
+
"model.layers.20.post_attention_layernorm.weight": "pytorch_model.bin",
|
| 130 |
+
"model.layers.20.self_attn.k_proj.weight": "pytorch_model.bin",
|
| 131 |
+
"model.layers.20.self_attn.o_proj.weight": "pytorch_model.bin",
|
| 132 |
+
"model.layers.20.self_attn.q_proj.weight": "pytorch_model.bin",
|
| 133 |
+
"model.layers.20.self_attn.v_proj.weight": "pytorch_model.bin",
|
| 134 |
+
"model.layers.21.input_layernorm.weight": "pytorch_model.bin",
|
| 135 |
+
"model.layers.21.mlp.down_proj.weight": "pytorch_model.bin",
|
| 136 |
+
"model.layers.21.mlp.gate_proj.weight": "pytorch_model.bin",
|
| 137 |
+
"model.layers.21.mlp.up_proj.weight": "pytorch_model.bin",
|
| 138 |
+
"model.layers.21.post_attention_layernorm.weight": "pytorch_model.bin",
|
| 139 |
+
"model.layers.21.self_attn.k_proj.weight": "pytorch_model.bin",
|
| 140 |
+
"model.layers.21.self_attn.o_proj.weight": "pytorch_model.bin",
|
| 141 |
+
"model.layers.21.self_attn.q_proj.weight": "pytorch_model.bin",
|
| 142 |
+
"model.layers.21.self_attn.v_proj.weight": "pytorch_model.bin",
|
| 143 |
+
"model.layers.22.input_layernorm.weight": "pytorch_model.bin",
|
| 144 |
+
"model.layers.22.mlp.down_proj.weight": "pytorch_model.bin",
|
| 145 |
+
"model.layers.22.mlp.gate_proj.weight": "pytorch_model.bin",
|
| 146 |
+
"model.layers.22.mlp.up_proj.weight": "pytorch_model.bin",
|
| 147 |
+
"model.layers.22.post_attention_layernorm.weight": "pytorch_model.bin",
|
| 148 |
+
"model.layers.22.self_attn.k_proj.weight": "pytorch_model.bin",
|
| 149 |
+
"model.layers.22.self_attn.o_proj.weight": "pytorch_model.bin",
|
| 150 |
+
"model.layers.22.self_attn.q_proj.weight": "pytorch_model.bin",
|
| 151 |
+
"model.layers.22.self_attn.v_proj.weight": "pytorch_model.bin",
|
| 152 |
+
"model.layers.23.input_layernorm.weight": "pytorch_model.bin",
|
| 153 |
+
"model.layers.23.mlp.down_proj.weight": "pytorch_model.bin",
|
| 154 |
+
"model.layers.23.mlp.gate_proj.weight": "pytorch_model.bin",
|
| 155 |
+
"model.layers.23.mlp.up_proj.weight": "pytorch_model.bin",
|
| 156 |
+
"model.layers.23.post_attention_layernorm.weight": "pytorch_model.bin",
|
| 157 |
+
"model.layers.23.self_attn.k_proj.weight": "pytorch_model.bin",
|
| 158 |
+
"model.layers.23.self_attn.o_proj.weight": "pytorch_model.bin",
|
| 159 |
+
"model.layers.23.self_attn.q_proj.weight": "pytorch_model.bin",
|
| 160 |
+
"model.layers.23.self_attn.v_proj.weight": "pytorch_model.bin",
|
| 161 |
+
"model.layers.24.input_layernorm.weight": "pytorch_model.bin",
|
| 162 |
+
"model.layers.24.mlp.down_proj.weight": "pytorch_model.bin",
|
| 163 |
+
"model.layers.24.mlp.gate_proj.weight": "pytorch_model.bin",
|
| 164 |
+
"model.layers.24.mlp.up_proj.weight": "pytorch_model.bin",
|
| 165 |
+
"model.layers.24.post_attention_layernorm.weight": "pytorch_model.bin",
|
| 166 |
+
"model.layers.24.self_attn.k_proj.weight": "pytorch_model.bin",
|
| 167 |
+
"model.layers.24.self_attn.o_proj.weight": "pytorch_model.bin",
|
| 168 |
+
"model.layers.24.self_attn.q_proj.weight": "pytorch_model.bin",
|
| 169 |
+
"model.layers.24.self_attn.v_proj.weight": "pytorch_model.bin",
|
| 170 |
+
"model.layers.25.input_layernorm.weight": "pytorch_model.bin",
|
| 171 |
+
"model.layers.25.mlp.down_proj.weight": "pytorch_model.bin",
|
| 172 |
+
"model.layers.25.mlp.gate_proj.weight": "pytorch_model.bin",
|
| 173 |
+
"model.layers.25.mlp.up_proj.weight": "pytorch_model.bin",
|
| 174 |
+
"model.layers.25.post_attention_layernorm.weight": "pytorch_model.bin",
|
| 175 |
+
"model.layers.25.self_attn.k_proj.weight": "pytorch_model.bin",
|
| 176 |
+
"model.layers.25.self_attn.o_proj.weight": "pytorch_model.bin",
|
| 177 |
+
"model.layers.25.self_attn.q_proj.weight": "pytorch_model.bin",
|
| 178 |
+
"model.layers.25.self_attn.v_proj.weight": "pytorch_model.bin",
|
| 179 |
+
"model.layers.26.input_layernorm.weight": "pytorch_model.bin",
|
| 180 |
+
"model.layers.26.mlp.down_proj.weight": "pytorch_model.bin",
|
| 181 |
+
"model.layers.26.mlp.gate_proj.weight": "pytorch_model.bin",
|
| 182 |
+
"model.layers.26.mlp.up_proj.weight": "pytorch_model.bin",
|
| 183 |
+
"model.layers.26.post_attention_layernorm.weight": "pytorch_model.bin",
|
| 184 |
+
"model.layers.26.self_attn.k_proj.weight": "pytorch_model.bin",
|
| 185 |
+
"model.layers.26.self_attn.o_proj.weight": "pytorch_model.bin",
|
| 186 |
+
"model.layers.26.self_attn.q_proj.weight": "pytorch_model.bin",
|
| 187 |
+
"model.layers.26.self_attn.v_proj.weight": "pytorch_model.bin",
|
| 188 |
+
"model.layers.27.input_layernorm.weight": "pytorch_model.bin",
|
| 189 |
+
"model.layers.27.mlp.down_proj.weight": "pytorch_model.bin",
|
| 190 |
+
"model.layers.27.mlp.gate_proj.weight": "pytorch_model.bin",
|
| 191 |
+
"model.layers.27.mlp.up_proj.weight": "pytorch_model.bin",
|
| 192 |
+
"model.layers.27.post_attention_layernorm.weight": "pytorch_model.bin",
|
| 193 |
+
"model.layers.27.self_attn.k_proj.weight": "pytorch_model.bin",
|
| 194 |
+
"model.layers.27.self_attn.o_proj.weight": "pytorch_model.bin",
|
| 195 |
+
"model.layers.27.self_attn.q_proj.weight": "pytorch_model.bin",
|
| 196 |
+
"model.layers.27.self_attn.v_proj.weight": "pytorch_model.bin",
|
| 197 |
+
"model.layers.28.input_layernorm.weight": "pytorch_model.bin",
|
| 198 |
+
"model.layers.28.mlp.down_proj.weight": "pytorch_model.bin",
|
| 199 |
+
"model.layers.28.mlp.gate_proj.weight": "pytorch_model.bin",
|
| 200 |
+
"model.layers.28.mlp.up_proj.weight": "pytorch_model.bin",
|
| 201 |
+
"model.layers.28.post_attention_layernorm.weight": "pytorch_model.bin",
|
| 202 |
+
"model.layers.28.self_attn.k_proj.weight": "pytorch_model.bin",
|
| 203 |
+
"model.layers.28.self_attn.o_proj.weight": "pytorch_model.bin",
|
| 204 |
+
"model.layers.28.self_attn.q_proj.weight": "pytorch_model.bin",
|
| 205 |
+
"model.layers.28.self_attn.v_proj.weight": "pytorch_model.bin",
|
| 206 |
+
"model.layers.29.input_layernorm.weight": "pytorch_model.bin",
|
| 207 |
+
"model.layers.29.mlp.down_proj.weight": "pytorch_model.bin",
|
| 208 |
+
"model.layers.29.mlp.gate_proj.weight": "pytorch_model.bin",
|
| 209 |
+
"model.layers.29.mlp.up_proj.weight": "pytorch_model.bin",
|
| 210 |
+
"model.layers.29.post_attention_layernorm.weight": "pytorch_model.bin",
|
| 211 |
+
"model.layers.29.self_attn.k_proj.weight": "pytorch_model.bin",
|
| 212 |
+
"model.layers.29.self_attn.o_proj.weight": "pytorch_model.bin",
|
| 213 |
+
"model.layers.29.self_attn.q_proj.weight": "pytorch_model.bin",
|
| 214 |
+
"model.layers.29.self_attn.v_proj.weight": "pytorch_model.bin",
|
| 215 |
+
"model.layers.3.input_layernorm.weight": "pytorch_model.bin",
|
| 216 |
+
"model.layers.3.mlp.down_proj.weight": "pytorch_model.bin",
|
| 217 |
+
"model.layers.3.mlp.gate_proj.weight": "pytorch_model.bin",
|
| 218 |
+
"model.layers.3.mlp.up_proj.weight": "pytorch_model.bin",
|
| 219 |
+
"model.layers.3.post_attention_layernorm.weight": "pytorch_model.bin",
|
| 220 |
+
"model.layers.3.self_attn.k_proj.weight": "pytorch_model.bin",
|
| 221 |
+
"model.layers.3.self_attn.o_proj.weight": "pytorch_model.bin",
|
| 222 |
+
"model.layers.3.self_attn.q_proj.weight": "pytorch_model.bin",
|
| 223 |
+
"model.layers.3.self_attn.v_proj.weight": "pytorch_model.bin",
|
| 224 |
+
"model.layers.4.input_layernorm.weight": "pytorch_model.bin",
|
| 225 |
+
"model.layers.4.mlp.down_proj.weight": "pytorch_model.bin",
|
| 226 |
+
"model.layers.4.mlp.gate_proj.weight": "pytorch_model.bin",
|
| 227 |
+
"model.layers.4.mlp.up_proj.weight": "pytorch_model.bin",
|
| 228 |
+
"model.layers.4.post_attention_layernorm.weight": "pytorch_model.bin",
|
| 229 |
+
"model.layers.4.self_attn.k_proj.weight": "pytorch_model.bin",
|
| 230 |
+
"model.layers.4.self_attn.o_proj.weight": "pytorch_model.bin",
|
| 231 |
+
"model.layers.4.self_attn.q_proj.weight": "pytorch_model.bin",
|
| 232 |
+
"model.layers.4.self_attn.v_proj.weight": "pytorch_model.bin",
|
| 233 |
+
"model.layers.5.input_layernorm.weight": "pytorch_model.bin",
|
| 234 |
+
"model.layers.5.mlp.down_proj.weight": "pytorch_model.bin",
|
| 235 |
+
"model.layers.5.mlp.gate_proj.weight": "pytorch_model.bin",
|
| 236 |
+
"model.layers.5.mlp.up_proj.weight": "pytorch_model.bin",
|
| 237 |
+
"model.layers.5.post_attention_layernorm.weight": "pytorch_model.bin",
|
| 238 |
+
"model.layers.5.self_attn.k_proj.weight": "pytorch_model.bin",
|
| 239 |
+
"model.layers.5.self_attn.o_proj.weight": "pytorch_model.bin",
|
| 240 |
+
"model.layers.5.self_attn.q_proj.weight": "pytorch_model.bin",
|
| 241 |
+
"model.layers.5.self_attn.v_proj.weight": "pytorch_model.bin",
|
| 242 |
+
"model.layers.6.input_layernorm.weight": "pytorch_model.bin",
|
| 243 |
+
"model.layers.6.mlp.down_proj.weight": "pytorch_model.bin",
|
| 244 |
+
"model.layers.6.mlp.gate_proj.weight": "pytorch_model.bin",
|
| 245 |
+
"model.layers.6.mlp.up_proj.weight": "pytorch_model.bin",
|
| 246 |
+
"model.layers.6.post_attention_layernorm.weight": "pytorch_model.bin",
|
| 247 |
+
"model.layers.6.self_attn.k_proj.weight": "pytorch_model.bin",
|
| 248 |
+
"model.layers.6.self_attn.o_proj.weight": "pytorch_model.bin",
|
| 249 |
+
"model.layers.6.self_attn.q_proj.weight": "pytorch_model.bin",
|
| 250 |
+
"model.layers.6.self_attn.v_proj.weight": "pytorch_model.bin",
|
| 251 |
+
"model.layers.7.input_layernorm.weight": "pytorch_model.bin",
|
| 252 |
+
"model.layers.7.mlp.down_proj.weight": "pytorch_model.bin",
|
| 253 |
+
"model.layers.7.mlp.gate_proj.weight": "pytorch_model.bin",
|
| 254 |
+
"model.layers.7.mlp.up_proj.weight": "pytorch_model.bin",
|
| 255 |
+
"model.layers.7.post_attention_layernorm.weight": "pytorch_model.bin",
|
| 256 |
+
"model.layers.7.self_attn.k_proj.weight": "pytorch_model.bin",
|
| 257 |
+
"model.layers.7.self_attn.o_proj.weight": "pytorch_model.bin",
|
| 258 |
+
"model.layers.7.self_attn.q_proj.weight": "pytorch_model.bin",
|
| 259 |
+
"model.layers.7.self_attn.v_proj.weight": "pytorch_model.bin",
|
| 260 |
+
"model.layers.8.input_layernorm.weight": "pytorch_model.bin",
|
| 261 |
+
"model.layers.8.mlp.down_proj.weight": "pytorch_model.bin",
|
| 262 |
+
"model.layers.8.mlp.gate_proj.weight": "pytorch_model.bin",
|
| 263 |
+
"model.layers.8.mlp.up_proj.weight": "pytorch_model.bin",
|
| 264 |
+
"model.layers.8.post_attention_layernorm.weight": "pytorch_model.bin",
|
| 265 |
+
"model.layers.8.self_attn.k_proj.weight": "pytorch_model.bin",
|
| 266 |
+
"model.layers.8.self_attn.o_proj.weight": "pytorch_model.bin",
|
| 267 |
+
"model.layers.8.self_attn.q_proj.weight": "pytorch_model.bin",
|
| 268 |
+
"model.layers.8.self_attn.v_proj.weight": "pytorch_model.bin",
|
| 269 |
+
"model.layers.9.input_layernorm.weight": "pytorch_model.bin",
|
| 270 |
+
"model.layers.9.mlp.down_proj.weight": "pytorch_model.bin",
|
| 271 |
+
"model.layers.9.mlp.gate_proj.weight": "pytorch_model.bin",
|
| 272 |
+
"model.layers.9.mlp.up_proj.weight": "pytorch_model.bin",
|
| 273 |
+
"model.layers.9.post_attention_layernorm.weight": "pytorch_model.bin",
|
| 274 |
+
"model.layers.9.self_attn.k_proj.weight": "pytorch_model.bin",
|
| 275 |
+
"model.layers.9.self_attn.o_proj.weight": "pytorch_model.bin",
|
| 276 |
+
"model.layers.9.self_attn.q_proj.weight": "pytorch_model.bin",
|
| 277 |
+
"model.layers.9.self_attn.v_proj.weight": "pytorch_model.bin",
|
| 278 |
+
"model.norm.weight": "pytorch_model.bin"
|
| 279 |
+
}
|
| 280 |
+
}
|
special_tokens_map.json
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"additional_special_tokens": [
|
| 3 |
+
"<image_placeholder>",
|
| 4 |
+
"<patch_placeholder>",
|
| 5 |
+
"<|ref|>",
|
| 6 |
+
"<|/ref|>",
|
| 7 |
+
"<|det|>",
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright (c) 2023-2024 DeepSeek.
|
| 2 |
+
#
|
| 3 |
+
# Permission is hereby granted, free of charge, to any person obtaining a copy of
|
| 4 |
+
# this software and associated documentation files (the "Software"), to deal in
|
| 5 |
+
# the Software without restriction, including without limitation the rights to
|
| 6 |
+
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
| 7 |
+
# the Software, and to permit persons to whom the Software is furnished to do so,
|
| 8 |
+
# subject to the following conditions:
|
| 9 |
+
#
|
| 10 |
+
# The above copyright notice and this permission notice shall be included in all
|
| 11 |
+
# copies or substantial portions of the Software.
|
| 12 |
+
#
|
| 13 |
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 14 |
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
| 15 |
+
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
| 16 |
+
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
| 17 |
+
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
| 18 |
+
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
| 19 |
+
|
| 20 |
+
"""
|
| 21 |
+
From https://github.com/lm-sys/FastChat/blob/main/fastchat/conversation.py
|
| 22 |
+
"""
|
| 23 |
+
|
| 24 |
+
import dataclasses
|
| 25 |
+
from enum import IntEnum, auto
|
| 26 |
+
from typing import Dict, List
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
class SeparatorStyle(IntEnum):
|
| 30 |
+
"""Separator styles."""
|
| 31 |
+
|
| 32 |
+
ADD_COLON_SINGLE = auto()
|
| 33 |
+
ADD_COLON_TWO = auto()
|
| 34 |
+
ADD_COLON_SPACE_SINGLE = auto()
|
| 35 |
+
NO_COLON_SINGLE = auto()
|
| 36 |
+
NO_COLON_TWO = auto()
|
| 37 |
+
ADD_NEW_LINE_SINGLE = auto()
|
| 38 |
+
LLAMA2 = auto()
|
| 39 |
+
CHATGLM = auto()
|
| 40 |
+
CHATML = auto()
|
| 41 |
+
CHATINTERN = auto()
|
| 42 |
+
DOLLY = auto()
|
| 43 |
+
RWKV = auto()
|
| 44 |
+
PHOENIX = auto()
|
| 45 |
+
ROBIN = auto()
|
| 46 |
+
DeepSeek = auto()
|
| 47 |
+
PLAIN = auto()
|
| 48 |
+
ALIGNMENT = auto()
|
| 49 |
+
|
| 50 |
+
|
| 51 |
+
@dataclasses.dataclass
|
| 52 |
+
class Conversation:
|
| 53 |
+
"""A class that manages prompt templates and keeps all conversation history."""
|
| 54 |
+
|
| 55 |
+
# The name of this template
|
| 56 |
+
name: str
|
| 57 |
+
# The template of the system prompt
|
| 58 |
+
system_template: str = "{system_message}"
|
| 59 |
+
# The system message
|
| 60 |
+
system_message: str = ""
|
| 61 |
+
# The names of two roles
|
| 62 |
+
roles: List[str] = (("USER", "ASSISTANT"),)
|
| 63 |
+
# All messages. Each item is (role, message).
|
| 64 |
+
messages: List[List[str]] = ()
|
| 65 |
+
# The number of few shot examples
|
| 66 |
+
offset: int = 0
|
| 67 |
+
# The separator style and configurations
|
| 68 |
+
sep_style: SeparatorStyle = SeparatorStyle.ADD_COLON_SINGLE
|
| 69 |
+
sep: str = "\n"
|
| 70 |
+
sep2: str = None
|
| 71 |
+
# Stop criteria (the default one is EOS token)
|
| 72 |
+
stop_str: str = None
|
| 73 |
+
# Stops generation if meeting any token in this list
|
| 74 |
+
stop_token_ids: List[int] = None
|
| 75 |
+
|
| 76 |
+
def get_prompt(self) -> str:
|
| 77 |
+
"""Get the prompt for generation."""
|
| 78 |
+
system_prompt = self.system_template.format(system_message=self.system_message)
|
| 79 |
+
|
| 80 |
+
if self.sep_style == SeparatorStyle.DeepSeek:
|
| 81 |
+
seps = [self.sep, self.sep2]
|
| 82 |
+
if system_prompt == "" or system_prompt is None:
|
| 83 |
+
ret = ""
|
| 84 |
+
else:
|
| 85 |
+
ret = system_prompt + seps[0]
|
| 86 |
+
for i, (role, message) in enumerate(self.messages):
|
| 87 |
+
if message:
|
| 88 |
+
ret += role + ": " + message + seps[i % 2]
|
| 89 |
+
else:
|
| 90 |
+
ret += role + ":"
|
| 91 |
+
return ret
|
| 92 |
+
elif self.sep_style == SeparatorStyle.LLAMA2:
|
| 93 |
+
seps = [self.sep, self.sep2]
|
| 94 |
+
if self.system_message:
|
| 95 |
+
ret = system_prompt
|
| 96 |
+
else:
|
| 97 |
+
ret = "[INST] "
|
| 98 |
+
for i, (role, message) in enumerate(self.messages):
|
| 99 |
+
tag = self.roles[i % 2]
|
| 100 |
+
if message:
|
| 101 |
+
if type(message) is tuple: # multimodal message
|
| 102 |
+
message, _ = message
|
| 103 |
+
if i == 0:
|
| 104 |
+
ret += message + " "
|
| 105 |
+
else:
|
| 106 |
+
ret += tag + " " + message + seps[i % 2]
|
| 107 |
+
else:
|
| 108 |
+
ret += tag
|
| 109 |
+
return ret
|
| 110 |
+
elif self.sep_style == SeparatorStyle.PLAIN:
|
| 111 |
+
seps = [self.sep, self.sep2]
|
| 112 |
+
ret = ""
|
| 113 |
+
for i, (role, message) in enumerate(self.messages):
|
| 114 |
+
if message:
|
| 115 |
+
if type(message) is tuple:
|
| 116 |
+
message, _, _ = message
|
| 117 |
+
if i % 2 == 0:
|
| 118 |
+
ret += message + seps[i % 2]
|
| 119 |
+
else:
|
| 120 |
+
ret += message + seps[i % 2]
|
| 121 |
+
else:
|
| 122 |
+
ret += ""
|
| 123 |
+
return ret
|
| 124 |
+
elif self.sep_style == SeparatorStyle.ALIGNMENT:
|
| 125 |
+
seps = [self.sep, self.sep2]
|
| 126 |
+
ret = ""
|
| 127 |
+
for i, (role, message) in enumerate(self.messages):
|
| 128 |
+
if message:
|
| 129 |
+
if type(message) is tuple:
|
| 130 |
+
message, _, _ = message
|
| 131 |
+
if i % 2 == 0:
|
| 132 |
+
ret += "<image>\n" + seps[i % 2]
|
| 133 |
+
else:
|
| 134 |
+
ret += message + seps[i % 2]
|
| 135 |
+
else:
|
| 136 |
+
ret += ""
|
| 137 |
+
return ret
|
| 138 |
+
else:
|
| 139 |
+
raise ValueError(f"Invalid style: {self.sep_style}")
|
| 140 |
+
|
| 141 |
+
def get_prompt_for_current_round(self, content=None):
|
| 142 |
+
"""Get current round formatted question prompt during sft training"""
|
| 143 |
+
if self.sep_style == SeparatorStyle.PLAIN:
|
| 144 |
+
formatted_question = "<image>\n"
|
| 145 |
+
elif self.sep_style == SeparatorStyle.DeepSeek:
|
| 146 |
+
formatted_question = (
|
| 147 |
+
f"{self.roles[0]}: " + content.strip() + self.sep + f"{self.roles[1]}:"
|
| 148 |
+
)
|
| 149 |
+
else:
|
| 150 |
+
raise ValueError(f"Unsupported sep_style: {self.sep_style}")
|
| 151 |
+
return formatted_question
|
| 152 |
+
|
| 153 |
+
def set_system_message(self, system_message: str):
|
| 154 |
+
"""Set the system message."""
|
| 155 |
+
self.system_message = system_message
|
| 156 |
+
|
| 157 |
+
def append_message(self, role: str, message: str):
|
| 158 |
+
"""Append a new message."""
|
| 159 |
+
self.messages.append([role, message])
|
| 160 |
+
|
| 161 |
+
def reset_message(self):
|
| 162 |
+
"""Reset a new message."""
|
| 163 |
+
self.messages = []
|
| 164 |
+
|
| 165 |
+
def update_last_message(self, message: str):
|
| 166 |
+
"""Update the last output.
|
| 167 |
+
|
| 168 |
+
The last message is typically set to be None when constructing the prompt,
|
| 169 |
+
so we need to update it in-place after getting the response from a model.
|
| 170 |
+
"""
|
| 171 |
+
self.messages[-1][1] = message
|
| 172 |
+
|
| 173 |
+
def to_gradio_chatbot(self):
|
| 174 |
+
"""Convert the conversation to gradio chatbot format."""
|
| 175 |
+
ret = []
|
| 176 |
+
for i, (role, msg) in enumerate(self.messages[self.offset :]):
|
| 177 |
+
if i % 2 == 0:
|
| 178 |
+
ret.append([msg, None])
|
| 179 |
+
else:
|
| 180 |
+
ret[-1][-1] = msg
|
| 181 |
+
return ret
|
| 182 |
+
|
| 183 |
+
def to_openai_api_messages(self):
|
| 184 |
+
"""Convert the conversation to OpenAI chat completion format."""
|
| 185 |
+
system_prompt = self.system_template.format(system_message=self.system_message)
|
| 186 |
+
ret = [{"role": "system", "content": system_prompt}]
|
| 187 |
+
|
| 188 |
+
for i, (_, msg) in enumerate(self.messages[self.offset :]):
|
| 189 |
+
if i % 2 == 0:
|
| 190 |
+
ret.append({"role": "user", "content": msg})
|
| 191 |
+
else:
|
| 192 |
+
if msg is not None:
|
| 193 |
+
ret.append({"role": "assistant", "content": msg})
|
| 194 |
+
return ret
|
| 195 |
+
|
| 196 |
+
def copy(self):
|
| 197 |
+
return Conversation(
|
| 198 |
+
name=self.name,
|
| 199 |
+
system_template=self.system_template,
|
| 200 |
+
system_message=self.system_message,
|
| 201 |
+
roles=self.roles,
|
| 202 |
+
messages=[[x, y] for x, y in self.messages],
|
| 203 |
+
offset=self.offset,
|
| 204 |
+
sep_style=self.sep_style,
|
| 205 |
+
sep=self.sep,
|
| 206 |
+
sep2=self.sep2,
|
| 207 |
+
stop_str=self.stop_str,
|
| 208 |
+
stop_token_ids=self.stop_token_ids,
|
| 209 |
+
)
|
| 210 |
+
|
| 211 |
+
def dict(self):
|
| 212 |
+
return {
|
| 213 |
+
"template_name": self.name,
|
| 214 |
+
"system_message": self.system_message,
|
| 215 |
+
"roles": self.roles,
|
| 216 |
+
"messages": self.messages,
|
| 217 |
+
"offset": self.offset,
|
| 218 |
+
}
|
| 219 |
+
|
| 220 |
+
|
| 221 |
+
# A global registry for all conversation templates
|
| 222 |
+
conv_templates: Dict[str, Conversation] = {}
|
| 223 |
+
|
| 224 |
+
|
| 225 |
+
def register_conv_template(template: Conversation, override: bool = False):
|
| 226 |
+
"""Register a new conversation template."""
|
| 227 |
+
if not override:
|
| 228 |
+
assert (
|
| 229 |
+
template.name not in conv_templates
|
| 230 |
+
), f"{template.name} has been registered."
|
| 231 |
+
|
| 232 |
+
conv_templates[template.name] = template
|
| 233 |
+
|
| 234 |
+
|
| 235 |
+
def get_conv_template(name: str) -> Conversation:
|
| 236 |
+
"""Get a conversation template."""
|
| 237 |
+
return conv_templates[name].copy()
|
| 238 |
+
|
| 239 |
+
|
| 240 |
+
# llava_llama2 template
|
| 241 |
+
register_conv_template(
|
| 242 |
+
Conversation(
|
| 243 |
+
name="llava_llama2",
|
| 244 |
+
system_message="You are a helpful language and vision assistant. "
|
| 245 |
+
"You are able to understand the visual content that the user provides, "
|
| 246 |
+
"and assist the user with a variety of tasks using natural language.",
|
| 247 |
+
system_template="[INST] <<SYS>>\n{system_message}\n<</SYS>>\n\n",
|
| 248 |
+
roles=("[INST]", "[/INST]"),
|
| 249 |
+
messages=(),
|
| 250 |
+
offset=0,
|
| 251 |
+
sep_style=SeparatorStyle.LLAMA2,
|
| 252 |
+
sep=" ",
|
| 253 |
+
sep2=" </s><s>",
|
| 254 |
+
stop_token_ids=[2],
|
| 255 |
+
)
|
| 256 |
+
)
|
| 257 |
+
|
| 258 |
+
# llama2 template
|
| 259 |
+
# reference: https://github.com/facebookresearch/llama/blob/cfc3fc8c1968d390eb830e65c63865e980873a06/llama/generation.py#L212
|
| 260 |
+
register_conv_template(
|
| 261 |
+
Conversation(
|
| 262 |
+
name="llama-2",
|
| 263 |
+
system_template="[INST] <<SYS>>\n{system_message}\n<</SYS>>\n\n",
|
| 264 |
+
roles=("[INST]", "[/INST]"),
|
| 265 |
+
messages=(),
|
| 266 |
+
offset=0,
|
| 267 |
+
sep_style=SeparatorStyle.LLAMA2,
|
| 268 |
+
sep=" ",
|
| 269 |
+
sep2=" </s><s>",
|
| 270 |
+
stop_token_ids=[2],
|
| 271 |
+
)
|
| 272 |
+
)
|
| 273 |
+
|
| 274 |
+
|
| 275 |
+
# deepseek template
|
| 276 |
+
register_conv_template(
|
| 277 |
+
Conversation(
|
| 278 |
+
name="deepseek_old",
|
| 279 |
+
system_template="{system_message}",
|
| 280 |
+
# system_message="You are a helpful assistant. Please answer truthfully and write out your "
|
| 281 |
+
# "thinking step by step to be sure you get the right answer.",
|
| 282 |
+
system_message="",
|
| 283 |
+
roles=("User", "Assistant"),
|
| 284 |
+
messages=(),
|
| 285 |
+
offset=0,
|
| 286 |
+
sep_style=SeparatorStyle.DeepSeek,
|
| 287 |
+
sep="\n\n",
|
| 288 |
+
sep2="<|end▁of▁sentence|>",
|
| 289 |
+
stop_token_ids=[100001],
|
| 290 |
+
stop_str=["User:", "<|end▁of▁sentence|>"],
|
| 291 |
+
)
|
| 292 |
+
)
|
| 293 |
+
register_conv_template(
|
| 294 |
+
Conversation(
|
| 295 |
+
name="deepseek",
|
| 296 |
+
system_template="{system_message}",
|
| 297 |
+
# system_message="You are a helpful assistant. Please answer truthfully and write out your "
|
| 298 |
+
# "thinking step by step to be sure you get the right answer.",
|
| 299 |
+
system_message="",
|
| 300 |
+
roles=("<|User|>", "<|Assistant|>"),
|
| 301 |
+
messages=(),
|
| 302 |
+
offset=0,
|
| 303 |
+
sep_style=SeparatorStyle.DeepSeek,
|
| 304 |
+
sep="\n\n",
|
| 305 |
+
sep2="<|end▁of▁sentence|>",
|
| 306 |
+
stop_token_ids=[100001],
|
| 307 |
+
stop_str=["<|User|>", "<|end▁of▁sentence|>"]
|
| 308 |
+
)
|
| 309 |
+
)
|
| 310 |
+
|
| 311 |
+
register_conv_template(
|
| 312 |
+
Conversation(
|
| 313 |
+
name="plain",
|
| 314 |
+
system_template="",
|
| 315 |
+
system_message="",
|
| 316 |
+
roles=("", ""),
|
| 317 |
+
messages=(),
|
| 318 |
+
offset=0,
|
| 319 |
+
sep_style=SeparatorStyle.PLAIN,
|
| 320 |
+
sep="",
|
| 321 |
+
sep2="",
|
| 322 |
+
stop_token_ids=[2],
|
| 323 |
+
stop_str=["</s>"],
|
| 324 |
+
)
|
| 325 |
+
)
|
| 326 |
+
|
| 327 |
+
|
| 328 |
+
register_conv_template(
|
| 329 |
+
Conversation(
|
| 330 |
+
name="alignment",
|
| 331 |
+
system_template="",
|
| 332 |
+
system_message="",
|
| 333 |
+
roles=("", ""),
|
| 334 |
+
messages=(),
|
| 335 |
+
offset=0,
|
| 336 |
+
sep_style=SeparatorStyle.ALIGNMENT,
|
| 337 |
+
sep="",
|
| 338 |
+
sep2="",
|
| 339 |
+
stop_token_ids=[2],
|
| 340 |
+
stop_str=["</s>"],
|
| 341 |
+
)
|
| 342 |
+
)
|
| 343 |
+
|
| 344 |
+
|
| 345 |
+
if __name__ == "__main__":
|
| 346 |
+
# print("Llama-2 template:")
|
| 347 |
+
# conv = get_conv_template("llama-2")
|
| 348 |
+
# conv.set_system_message("You are a helpful, respectful and honest assistant.")
|
| 349 |
+
# conv.append_message(conv.roles[0], "Hello!")
|
| 350 |
+
# conv.append_message(conv.roles[1], "Hi!")
|
| 351 |
+
# conv.append_message(conv.roles[0], "How are you?")
|
| 352 |
+
# conv.append_message(conv.roles[1], None)
|
| 353 |
+
# print(conv.get_prompt())
|
| 354 |
+
|
| 355 |
+
# print("\n")
|
| 356 |
+
|
| 357 |
+
print("deepseek template:")
|
| 358 |
+
conv = get_conv_template("deepseek")
|
| 359 |
+
conv.append_message(conv.roles[0], "Hello!")
|
| 360 |
+
conv.append_message(conv.roles[1], "Hi! This is Tony.")
|
| 361 |
+
conv.append_message(conv.roles[0], "Who are you?")
|
| 362 |
+
conv.append_message(conv.roles[1], "I am a helpful assistant.")
|
| 363 |
+
conv.append_message(conv.roles[0], "How are you?")
|
| 364 |
+
conv.append_message(conv.roles[1], None)
|
| 365 |
+
print(conv.get_prompt())
|
tokenizer.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
tokenizer_config.json
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"bos_token": "<|begin▁of▁sentence|>",
|
| 3 |
+
"clean_up_tokenization_spaces": false,
|
| 4 |
+
"eos_token": "<|end▁of▁sentence|>",
|
| 5 |
+
"model_max_length": 16384,
|
| 6 |
+
"pad_token": null,
|
| 7 |
+
"tokenizer_class": "LlamaTokenizer",
|
| 8 |
+
"chat_template": "{% if not add_generation_prompt is defined %}{% set add_generation_prompt = false %}{% endif %}{% set ns = namespace(is_first=false, is_tool=false, is_output_first=true, system_prompt='') %}{%- for message in messages %}{%- if message['role'] == 'system' %}{% set ns.system_prompt = message['content'] %}{%- endif %}{%- endfor %}{{ns.system_prompt}}{%- for message in messages %}{%- if message['role'] == 'user' %}{{'<|User|>: ' + message['content'] + '\\n\\n'}}{%- endif %}{%- if message['role'] == 'assistant' and message['content'] is not none %}{% set content = message['content'] %}{% if '</think>' in content %}{% set content = content.split('</think>')[-1] %}{% endif %}{{'<|Assistant|>: ' + content + '<|end▁of▁sentence|>'}}{%- endif %}{%- endfor -%}{% if add_generation_prompt %}{{'<|Assistant|>: '}}{% endif %}",
|
| 9 |
+
"unk_token": null,
|
| 10 |
+
"use_default_system_prompt": true
|
| 11 |
+
}
|