Upload folder using huggingface_hub
Browse files- ByteWave_Yi-23B-Llama/README.md +31 -0
- ByteWave_Yi-23B-Llama/config.json +28 -0
- ByteWave_Yi-23B-Llama/huggingface-metadata.txt +10 -0
- ByteWave_Yi-23B-Llama/model-00001-of-00005.safetensors +3 -0
- ByteWave_Yi-23B-Llama/model-00002-of-00005.safetensors +3 -0
- ByteWave_Yi-23B-Llama/model-00003-of-00005.safetensors +3 -0
- ByteWave_Yi-23B-Llama/model-00004-of-00005.safetensors +3 -0
- ByteWave_Yi-23B-Llama/model-00005-of-00005.safetensors +3 -0
- ByteWave_Yi-23B-Llama/model.safetensors.index.json +1 -0
- ByteWave_Yi-23B-Llama/tokenization_yi.py +246 -0
- ByteWave_Yi-23B-Llama/tokenizer.model +3 -0
- ByteWave_Yi-23B-Llama/tokenizer_config.json +9 -0
ByteWave_Yi-23B-Llama/README.md
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: other
|
3 |
+
license_name: yi-licence
|
4 |
+
license_link: LICENSE
|
5 |
+
language:
|
6 |
+
- en
|
7 |
+
pipeline_tag: text-generation
|
8 |
+
---
|
9 |
+
# Yi-23B-Llama Model by ByteWave
|
10 |
+
|
11 |
+
<div align="center">
|
12 |
+
|
13 |
+
<img src="./Yi.svg" width="200px">
|
14 |
+
|
15 |
+
</div>
|
16 |
+
|
17 |
+
Distil version of [chargoddard/Yi-34B-Llama](https://huggingface.co/chargoddard/Yi-34B-Llama)
|
18 |
+
|
19 |
+
# [Open LLM Leaderboard Evaluation Results](https://huggingface.co/spaces/HuggingFaceH4/open_llm_leaderboard)
|
20 |
+
Detailed results can be found [Coming soon]()
|
21 |
+
|
22 |
+
| Metric | Value |
|
23 |
+
|-----------------------|---------------------------|
|
24 |
+
| Avg. | Coming soon |
|
25 |
+
| ARC (25-shot) | Coming soon |
|
26 |
+
| HellaSwag (10-shot) | Coming soon |
|
27 |
+
| MMLU (5-shot) | Coming soon |
|
28 |
+
| TruthfulQA (0-shot) | Coming soon |
|
29 |
+
| Winogrande (5-shot) | Coming soon |
|
30 |
+
| GSM8K (5-shot) | Coming soon |
|
31 |
+
| DROP (3-shot) | Coming soon |
|
ByteWave_Yi-23B-Llama/config.json
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_name_or_path": "distil-yi-llama",
|
3 |
+
"architectures": [
|
4 |
+
"LlamaForCausalLM"
|
5 |
+
],
|
6 |
+
"attention_bias": false,
|
7 |
+
"bos_token_id": 1,
|
8 |
+
"eos_token_id": 2,
|
9 |
+
"hidden_act": "silu",
|
10 |
+
"hidden_size": 7168,
|
11 |
+
"initializer_range": 0.02,
|
12 |
+
"intermediate_size": 20480,
|
13 |
+
"max_position_embeddings": 4096,
|
14 |
+
"model_type": "llama",
|
15 |
+
"num_attention_heads": 56,
|
16 |
+
"num_hidden_layers": 40,
|
17 |
+
"num_key_value_heads": 8,
|
18 |
+
"pad_token_id": 0,
|
19 |
+
"pretraining_tp": 1,
|
20 |
+
"rms_norm_eps": 1e-05,
|
21 |
+
"rope_scaling": null,
|
22 |
+
"rope_theta": 5000000.0,
|
23 |
+
"tie_word_embeddings": false,
|
24 |
+
"torch_dtype": "bfloat16",
|
25 |
+
"transformers_version": "4.35.2",
|
26 |
+
"use_cache": true,
|
27 |
+
"vocab_size": 64000
|
28 |
+
}
|
ByteWave_Yi-23B-Llama/huggingface-metadata.txt
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
url: https://huggingface.co/ByteWave/Yi-23B-Llama
|
2 |
+
branch: main
|
3 |
+
download date: 2023-11-19 22:02:17
|
4 |
+
sha256sum:
|
5 |
+
5042a5315764fd9d91a06bb083e6d9d7d7cc20b62df6f3fcb7cc8b35949b76cd model-00001-of-00005.safetensors
|
6 |
+
4448601dcfeaeb4639267285440bc118aa5f1923b946e4e26ae7dc33b8aa1a5e model-00002-of-00005.safetensors
|
7 |
+
7e4b364ee9122bcdd7ec61712c8136d7f9dfe4ef702cb2c939a9b0c5c4a10959 model-00003-of-00005.safetensors
|
8 |
+
d5e0dc4745cdb70c16c086d169f4c6cbdcda92fccf89f00c3e50c460af69291c model-00004-of-00005.safetensors
|
9 |
+
cc2d73746a5b5cadcf14e3c526f38b3db03b6433a212798788ffc3d96a5dc619 model-00005-of-00005.safetensors
|
10 |
+
386c49cf943d71aa110361135338c50e38beeff0a66593480421f37b319e1a39 tokenizer.model
|
ByteWave_Yi-23B-Llama/model-00001-of-00005.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:5042a5315764fd9d91a06bb083e6d9d7d7cc20b62df6f3fcb7cc8b35949b76cd
|
3 |
+
size 9975356056
|
ByteWave_Yi-23B-Llama/model-00002-of-00005.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:4448601dcfeaeb4639267285440bc118aa5f1923b946e4e26ae7dc33b8aa1a5e
|
3 |
+
size 9909310280
|
ByteWave_Yi-23B-Llama/model-00003-of-00005.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:7e4b364ee9122bcdd7ec61712c8136d7f9dfe4ef702cb2c939a9b0c5c4a10959
|
3 |
+
size 9747800928
|
ByteWave_Yi-23B-Llama/model-00004-of-00005.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:d5e0dc4745cdb70c16c086d169f4c6cbdcda92fccf89f00c3e50c460af69291c
|
3 |
+
size 9747829832
|
ByteWave_Yi-23B-Llama/model-00005-of-00005.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:cc2d73746a5b5cadcf14e3c526f38b3db03b6433a212798788ffc3d96a5dc619
|
3 |
+
size 7083308688
|
ByteWave_Yi-23B-Llama/model.safetensors.index.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"metadata": {"mergekit_version": "0.0.2.2"}, "weight_map": {"model.embed_tokens.weight": "model-00001-of-00005.safetensors", "model.layers.0.input_layernorm.weight": "model-00001-of-00005.safetensors", "model.layers.0.mlp.down_proj.weight": "model-00001-of-00005.safetensors", "model.layers.0.mlp.gate_proj.weight": "model-00001-of-00005.safetensors", "model.layers.0.mlp.up_proj.weight": "model-00001-of-00005.safetensors", "model.layers.0.post_attention_layernorm.weight": "model-00001-of-00005.safetensors", "model.layers.0.self_attn.k_proj.weight": "model-00001-of-00005.safetensors", "model.layers.0.self_attn.o_proj.weight": "model-00001-of-00005.safetensors", "model.layers.0.self_attn.q_proj.weight": "model-00001-of-00005.safetensors", "model.layers.0.self_attn.v_proj.weight": "model-00001-of-00005.safetensors", "model.layers.1.input_layernorm.weight": "model-00001-of-00005.safetensors", "model.layers.1.mlp.down_proj.weight": "model-00001-of-00005.safetensors", "model.layers.1.mlp.gate_proj.weight": "model-00001-of-00005.safetensors", "model.layers.1.mlp.up_proj.weight": "model-00001-of-00005.safetensors", "model.layers.1.post_attention_layernorm.weight": "model-00001-of-00005.safetensors", "model.layers.1.self_attn.k_proj.weight": "model-00001-of-00005.safetensors", "model.layers.1.self_attn.o_proj.weight": "model-00001-of-00005.safetensors", "model.layers.1.self_attn.q_proj.weight": "model-00001-of-00005.safetensors", "model.layers.1.self_attn.v_proj.weight": "model-00001-of-00005.safetensors", "model.layers.2.input_layernorm.weight": "model-00001-of-00005.safetensors", "model.layers.2.mlp.down_proj.weight": "model-00001-of-00005.safetensors", "model.layers.2.mlp.gate_proj.weight": "model-00001-of-00005.safetensors", "model.layers.2.mlp.up_proj.weight": "model-00001-of-00005.safetensors", "model.layers.2.post_attention_layernorm.weight": "model-00001-of-00005.safetensors", "model.layers.2.self_attn.k_proj.weight": "model-00001-of-00005.safetensors", "model.layers.2.self_attn.o_proj.weight": "model-00001-of-00005.safetensors", "model.layers.2.self_attn.q_proj.weight": "model-00001-of-00005.safetensors", "model.layers.2.self_attn.v_proj.weight": "model-00001-of-00005.safetensors", "model.layers.3.input_layernorm.weight": "model-00001-of-00005.safetensors", "model.layers.3.mlp.down_proj.weight": "model-00001-of-00005.safetensors", "model.layers.3.mlp.gate_proj.weight": "model-00001-of-00005.safetensors", "model.layers.3.mlp.up_proj.weight": "model-00001-of-00005.safetensors", "model.layers.3.post_attention_layernorm.weight": "model-00001-of-00005.safetensors", "model.layers.3.self_attn.k_proj.weight": "model-00001-of-00005.safetensors", "model.layers.3.self_attn.o_proj.weight": "model-00001-of-00005.safetensors", "model.layers.3.self_attn.q_proj.weight": "model-00001-of-00005.safetensors", "model.layers.3.self_attn.v_proj.weight": "model-00001-of-00005.safetensors", "model.layers.4.input_layernorm.weight": "model-00001-of-00005.safetensors", "model.layers.4.mlp.down_proj.weight": "model-00001-of-00005.safetensors", "model.layers.4.mlp.gate_proj.weight": "model-00001-of-00005.safetensors", "model.layers.4.mlp.up_proj.weight": "model-00001-of-00005.safetensors", "model.layers.4.post_attention_layernorm.weight": "model-00001-of-00005.safetensors", "model.layers.4.self_attn.k_proj.weight": "model-00001-of-00005.safetensors", "model.layers.4.self_attn.o_proj.weight": "model-00001-of-00005.safetensors", "model.layers.4.self_attn.q_proj.weight": "model-00001-of-00005.safetensors", "model.layers.4.self_attn.v_proj.weight": "model-00001-of-00005.safetensors", "model.layers.5.input_layernorm.weight": "model-00001-of-00005.safetensors", "model.layers.5.mlp.down_proj.weight": "model-00001-of-00005.safetensors", "model.layers.5.mlp.gate_proj.weight": "model-00001-of-00005.safetensors", "model.layers.5.mlp.up_proj.weight": "model-00001-of-00005.safetensors", "model.layers.5.post_attention_layernorm.weight": "model-00001-of-00005.safetensors", "model.layers.5.self_attn.k_proj.weight": "model-00001-of-00005.safetensors", "model.layers.5.self_attn.o_proj.weight": "model-00001-of-00005.safetensors", "model.layers.5.self_attn.q_proj.weight": "model-00001-of-00005.safetensors", "model.layers.5.self_attn.v_proj.weight": "model-00001-of-00005.safetensors", "model.layers.6.input_layernorm.weight": "model-00001-of-00005.safetensors", "model.layers.6.mlp.down_proj.weight": "model-00001-of-00005.safetensors", "model.layers.6.mlp.gate_proj.weight": "model-00001-of-00005.safetensors", "model.layers.6.mlp.up_proj.weight": "model-00001-of-00005.safetensors", "model.layers.6.post_attention_layernorm.weight": "model-00001-of-00005.safetensors", "model.layers.6.self_attn.k_proj.weight": "model-00001-of-00005.safetensors", "model.layers.6.self_attn.o_proj.weight": "model-00001-of-00005.safetensors", "model.layers.6.self_attn.q_proj.weight": "model-00001-of-00005.safetensors", "model.layers.6.self_attn.v_proj.weight": "model-00001-of-00005.safetensors", "model.layers.7.input_layernorm.weight": "model-00001-of-00005.safetensors", "model.layers.7.mlp.down_proj.weight": "model-00001-of-00005.safetensors", "model.layers.7.mlp.gate_proj.weight": "model-00001-of-00005.safetensors", "model.layers.7.mlp.up_proj.weight": "model-00001-of-00005.safetensors", "model.layers.7.post_attention_layernorm.weight": "model-00001-of-00005.safetensors", "model.layers.7.self_attn.k_proj.weight": "model-00001-of-00005.safetensors", "model.layers.7.self_attn.o_proj.weight": "model-00001-of-00005.safetensors", "model.layers.7.self_attn.q_proj.weight": "model-00001-of-00005.safetensors", "model.layers.7.self_attn.v_proj.weight": "model-00001-of-00005.safetensors", "model.layers.8.self_attn.k_proj.weight": "model-00001-of-00005.safetensors", "model.layers.8.self_attn.q_proj.weight": "model-00001-of-00005.safetensors", "model.layers.8.self_attn.v_proj.weight": "model-00001-of-00005.safetensors", "model.layers.10.input_layernorm.weight": "model-00001-of-00005.safetensors", "model.layers.10.mlp.down_proj.weight": "model-00002-of-00005.safetensors", "model.layers.10.mlp.gate_proj.weight": "model-00002-of-00005.safetensors", "model.layers.10.mlp.up_proj.weight": "model-00002-of-00005.safetensors", "model.layers.10.post_attention_layernorm.weight": "model-00002-of-00005.safetensors", "model.layers.10.self_attn.k_proj.weight": "model-00002-of-00005.safetensors", "model.layers.10.self_attn.o_proj.weight": "model-00002-of-00005.safetensors", "model.layers.10.self_attn.q_proj.weight": "model-00002-of-00005.safetensors", "model.layers.10.self_attn.v_proj.weight": "model-00002-of-00005.safetensors", "model.layers.11.input_layernorm.weight": "model-00002-of-00005.safetensors", "model.layers.11.mlp.down_proj.weight": "model-00002-of-00005.safetensors", "model.layers.11.mlp.gate_proj.weight": "model-00002-of-00005.safetensors", "model.layers.11.mlp.up_proj.weight": "model-00002-of-00005.safetensors", "model.layers.11.post_attention_layernorm.weight": "model-00002-of-00005.safetensors", "model.layers.11.self_attn.k_proj.weight": "model-00002-of-00005.safetensors", "model.layers.11.self_attn.o_proj.weight": "model-00002-of-00005.safetensors", "model.layers.11.self_attn.q_proj.weight": "model-00002-of-00005.safetensors", "model.layers.11.self_attn.v_proj.weight": "model-00002-of-00005.safetensors", "model.layers.12.input_layernorm.weight": "model-00002-of-00005.safetensors", "model.layers.12.mlp.down_proj.weight": "model-00002-of-00005.safetensors", "model.layers.12.mlp.gate_proj.weight": "model-00002-of-00005.safetensors", "model.layers.12.mlp.up_proj.weight": "model-00002-of-00005.safetensors", "model.layers.12.post_attention_layernorm.weight": "model-00002-of-00005.safetensors", "model.layers.12.self_attn.k_proj.weight": "model-00002-of-00005.safetensors", "model.layers.12.self_attn.o_proj.weight": "model-00002-of-00005.safetensors", "model.layers.12.self_attn.q_proj.weight": "model-00002-of-00005.safetensors", "model.layers.12.self_attn.v_proj.weight": "model-00002-of-00005.safetensors", "model.layers.13.input_layernorm.weight": "model-00002-of-00005.safetensors", "model.layers.13.mlp.down_proj.weight": "model-00002-of-00005.safetensors", "model.layers.13.mlp.gate_proj.weight": "model-00002-of-00005.safetensors", "model.layers.13.mlp.up_proj.weight": "model-00002-of-00005.safetensors", "model.layers.13.post_attention_layernorm.weight": "model-00002-of-00005.safetensors", "model.layers.13.self_attn.k_proj.weight": "model-00002-of-00005.safetensors", "model.layers.13.self_attn.o_proj.weight": "model-00002-of-00005.safetensors", "model.layers.13.self_attn.q_proj.weight": "model-00002-of-00005.safetensors", "model.layers.13.self_attn.v_proj.weight": "model-00002-of-00005.safetensors", "model.layers.14.input_layernorm.weight": "model-00002-of-00005.safetensors", "model.layers.14.mlp.down_proj.weight": "model-00002-of-00005.safetensors", "model.layers.14.mlp.gate_proj.weight": "model-00002-of-00005.safetensors", "model.layers.14.mlp.up_proj.weight": "model-00002-of-00005.safetensors", "model.layers.14.post_attention_layernorm.weight": "model-00002-of-00005.safetensors", "model.layers.14.self_attn.k_proj.weight": "model-00002-of-00005.safetensors", "model.layers.14.self_attn.o_proj.weight": "model-00002-of-00005.safetensors", "model.layers.14.self_attn.q_proj.weight": "model-00002-of-00005.safetensors", "model.layers.14.self_attn.v_proj.weight": "model-00002-of-00005.safetensors", "model.layers.15.input_layernorm.weight": "model-00002-of-00005.safetensors", "model.layers.15.mlp.down_proj.weight": "model-00002-of-00005.safetensors", "model.layers.15.mlp.gate_proj.weight": "model-00002-of-00005.safetensors", "model.layers.15.mlp.up_proj.weight": "model-00002-of-00005.safetensors", "model.layers.15.post_attention_layernorm.weight": "model-00002-of-00005.safetensors", "model.layers.15.self_attn.k_proj.weight": "model-00002-of-00005.safetensors", "model.layers.15.self_attn.o_proj.weight": "model-00002-of-00005.safetensors", "model.layers.15.self_attn.q_proj.weight": "model-00002-of-00005.safetensors", "model.layers.15.self_attn.v_proj.weight": "model-00002-of-00005.safetensors", "model.layers.16.input_layernorm.weight": "model-00002-of-00005.safetensors", "model.layers.16.mlp.down_proj.weight": "model-00002-of-00005.safetensors", "model.layers.16.mlp.gate_proj.weight": "model-00002-of-00005.safetensors", "model.layers.16.mlp.up_proj.weight": "model-00002-of-00005.safetensors", "model.layers.16.post_attention_layernorm.weight": "model-00002-of-00005.safetensors", "model.layers.16.self_attn.k_proj.weight": "model-00002-of-00005.safetensors", "model.layers.16.self_attn.o_proj.weight": "model-00002-of-00005.safetensors", "model.layers.16.self_attn.q_proj.weight": "model-00002-of-00005.safetensors", "model.layers.16.self_attn.v_proj.weight": "model-00002-of-00005.safetensors", "model.layers.8.input_layernorm.weight": "model-00002-of-00005.safetensors", "model.layers.8.mlp.down_proj.weight": "model-00002-of-00005.safetensors", "model.layers.8.mlp.gate_proj.weight": "model-00002-of-00005.safetensors", "model.layers.8.mlp.up_proj.weight": "model-00002-of-00005.safetensors", "model.layers.8.post_attention_layernorm.weight": "model-00002-of-00005.safetensors", "model.layers.8.self_attn.o_proj.weight": "model-00002-of-00005.safetensors", "model.layers.9.input_layernorm.weight": "model-00002-of-00005.safetensors", "model.layers.9.mlp.down_proj.weight": "model-00002-of-00005.safetensors", "model.layers.9.mlp.gate_proj.weight": "model-00002-of-00005.safetensors", "model.layers.9.mlp.up_proj.weight": "model-00002-of-00005.safetensors", "model.layers.9.post_attention_layernorm.weight": "model-00002-of-00005.safetensors", "model.layers.9.self_attn.k_proj.weight": "model-00002-of-00005.safetensors", "model.layers.9.self_attn.o_proj.weight": "model-00002-of-00005.safetensors", "model.layers.9.self_attn.q_proj.weight": "model-00002-of-00005.safetensors", "model.layers.9.self_attn.v_proj.weight": "model-00002-of-00005.safetensors", "model.layers.17.input_layernorm.weight": "model-00002-of-00005.safetensors", "model.layers.17.mlp.down_proj.weight": "model-00003-of-00005.safetensors", "model.layers.17.mlp.gate_proj.weight": "model-00003-of-00005.safetensors", "model.layers.17.mlp.up_proj.weight": "model-00003-of-00005.safetensors", "model.layers.17.post_attention_layernorm.weight": "model-00003-of-00005.safetensors", "model.layers.17.self_attn.k_proj.weight": "model-00003-of-00005.safetensors", "model.layers.17.self_attn.o_proj.weight": "model-00003-of-00005.safetensors", "model.layers.17.self_attn.q_proj.weight": "model-00003-of-00005.safetensors", "model.layers.17.self_attn.v_proj.weight": "model-00003-of-00005.safetensors", "model.layers.18.input_layernorm.weight": "model-00003-of-00005.safetensors", "model.layers.18.mlp.down_proj.weight": "model-00003-of-00005.safetensors", "model.layers.18.mlp.gate_proj.weight": "model-00003-of-00005.safetensors", "model.layers.18.mlp.up_proj.weight": "model-00003-of-00005.safetensors", "model.layers.18.post_attention_layernorm.weight": "model-00003-of-00005.safetensors", "model.layers.18.self_attn.k_proj.weight": "model-00003-of-00005.safetensors", "model.layers.18.self_attn.o_proj.weight": "model-00003-of-00005.safetensors", "model.layers.18.self_attn.q_proj.weight": "model-00003-of-00005.safetensors", "model.layers.18.self_attn.v_proj.weight": "model-00003-of-00005.safetensors", "model.layers.19.input_layernorm.weight": "model-00003-of-00005.safetensors", "model.layers.19.mlp.down_proj.weight": "model-00003-of-00005.safetensors", "model.layers.19.mlp.gate_proj.weight": "model-00003-of-00005.safetensors", "model.layers.19.mlp.up_proj.weight": "model-00003-of-00005.safetensors", "model.layers.19.post_attention_layernorm.weight": "model-00003-of-00005.safetensors", "model.layers.19.self_attn.k_proj.weight": "model-00003-of-00005.safetensors", "model.layers.19.self_attn.o_proj.weight": "model-00003-of-00005.safetensors", "model.layers.19.self_attn.q_proj.weight": "model-00003-of-00005.safetensors", "model.layers.19.self_attn.v_proj.weight": "model-00003-of-00005.safetensors", "model.layers.20.input_layernorm.weight": "model-00003-of-00005.safetensors", "model.layers.20.mlp.down_proj.weight": "model-00003-of-00005.safetensors", "model.layers.20.mlp.gate_proj.weight": "model-00003-of-00005.safetensors", "model.layers.20.mlp.up_proj.weight": "model-00003-of-00005.safetensors", "model.layers.20.post_attention_layernorm.weight": "model-00003-of-00005.safetensors", "model.layers.20.self_attn.k_proj.weight": "model-00003-of-00005.safetensors", "model.layers.20.self_attn.o_proj.weight": "model-00003-of-00005.safetensors", "model.layers.20.self_attn.q_proj.weight": "model-00003-of-00005.safetensors", "model.layers.20.self_attn.v_proj.weight": "model-00003-of-00005.safetensors", "model.layers.21.input_layernorm.weight": "model-00003-of-00005.safetensors", "model.layers.21.mlp.down_proj.weight": "model-00003-of-00005.safetensors", "model.layers.21.mlp.gate_proj.weight": "model-00003-of-00005.safetensors", "model.layers.21.mlp.up_proj.weight": "model-00003-of-00005.safetensors", "model.layers.21.post_attention_layernorm.weight": "model-00003-of-00005.safetensors", "model.layers.21.self_attn.k_proj.weight": "model-00003-of-00005.safetensors", "model.layers.21.self_attn.o_proj.weight": "model-00003-of-00005.safetensors", "model.layers.21.self_attn.q_proj.weight": "model-00003-of-00005.safetensors", "model.layers.21.self_attn.v_proj.weight": "model-00003-of-00005.safetensors", "model.layers.22.input_layernorm.weight": "model-00003-of-00005.safetensors", "model.layers.22.mlp.down_proj.weight": "model-00003-of-00005.safetensors", "model.layers.22.mlp.gate_proj.weight": "model-00003-of-00005.safetensors", "model.layers.22.mlp.up_proj.weight": "model-00003-of-00005.safetensors", "model.layers.22.post_attention_layernorm.weight": "model-00003-of-00005.safetensors", "model.layers.22.self_attn.k_proj.weight": "model-00003-of-00005.safetensors", "model.layers.22.self_attn.o_proj.weight": "model-00003-of-00005.safetensors", "model.layers.22.self_attn.q_proj.weight": "model-00003-of-00005.safetensors", "model.layers.22.self_attn.v_proj.weight": "model-00003-of-00005.safetensors", "model.layers.23.input_layernorm.weight": "model-00003-of-00005.safetensors", "model.layers.23.mlp.down_proj.weight": "model-00003-of-00005.safetensors", "model.layers.23.mlp.gate_proj.weight": "model-00003-of-00005.safetensors", "model.layers.23.mlp.up_proj.weight": "model-00003-of-00005.safetensors", "model.layers.23.post_attention_layernorm.weight": "model-00003-of-00005.safetensors", "model.layers.23.self_attn.k_proj.weight": "model-00003-of-00005.safetensors", "model.layers.23.self_attn.o_proj.weight": "model-00003-of-00005.safetensors", "model.layers.23.self_attn.q_proj.weight": "model-00003-of-00005.safetensors", "model.layers.23.self_attn.v_proj.weight": "model-00003-of-00005.safetensors", "model.layers.24.input_layernorm.weight": "model-00003-of-00005.safetensors", "model.layers.24.mlp.down_proj.weight": "model-00003-of-00005.safetensors", "model.layers.24.mlp.gate_proj.weight": "model-00003-of-00005.safetensors", "model.layers.24.mlp.up_proj.weight": "model-00003-of-00005.safetensors", "model.layers.24.post_attention_layernorm.weight": "model-00003-of-00005.safetensors", "model.layers.24.self_attn.k_proj.weight": "model-00003-of-00005.safetensors", "model.layers.24.self_attn.o_proj.weight": "model-00003-of-00005.safetensors", "model.layers.24.self_attn.q_proj.weight": "model-00003-of-00005.safetensors", "model.layers.24.self_attn.v_proj.weight": "model-00003-of-00005.safetensors", "model.layers.25.mlp.down_proj.weight": "model-00003-of-00005.safetensors", "model.layers.25.mlp.gate_proj.weight": "model-00003-of-00005.safetensors", "model.layers.25.self_attn.k_proj.weight": "model-00003-of-00005.safetensors", "model.layers.25.self_attn.o_proj.weight": "model-00003-of-00005.safetensors", "model.layers.25.self_attn.q_proj.weight": "model-00003-of-00005.safetensors", "model.layers.25.self_attn.v_proj.weight": "model-00003-of-00005.safetensors", "model.layers.25.input_layernorm.weight": "model-00003-of-00005.safetensors", "model.layers.25.mlp.up_proj.weight": "model-00004-of-00005.safetensors", "model.layers.25.post_attention_layernorm.weight": "model-00004-of-00005.safetensors", "model.layers.26.input_layernorm.weight": "model-00004-of-00005.safetensors", "model.layers.26.mlp.down_proj.weight": "model-00004-of-00005.safetensors", "model.layers.26.mlp.gate_proj.weight": "model-00004-of-00005.safetensors", "model.layers.26.mlp.up_proj.weight": "model-00004-of-00005.safetensors", "model.layers.26.post_attention_layernorm.weight": "model-00004-of-00005.safetensors", "model.layers.26.self_attn.k_proj.weight": "model-00004-of-00005.safetensors", "model.layers.26.self_attn.o_proj.weight": "model-00004-of-00005.safetensors", "model.layers.26.self_attn.q_proj.weight": "model-00004-of-00005.safetensors", "model.layers.26.self_attn.v_proj.weight": "model-00004-of-00005.safetensors", "model.layers.27.input_layernorm.weight": "model-00004-of-00005.safetensors", "model.layers.27.mlp.down_proj.weight": "model-00004-of-00005.safetensors", "model.layers.27.mlp.gate_proj.weight": "model-00004-of-00005.safetensors", "model.layers.27.mlp.up_proj.weight": "model-00004-of-00005.safetensors", "model.layers.27.post_attention_layernorm.weight": "model-00004-of-00005.safetensors", "model.layers.27.self_attn.k_proj.weight": "model-00004-of-00005.safetensors", "model.layers.27.self_attn.o_proj.weight": "model-00004-of-00005.safetensors", "model.layers.27.self_attn.q_proj.weight": "model-00004-of-00005.safetensors", "model.layers.27.self_attn.v_proj.weight": "model-00004-of-00005.safetensors", "model.layers.28.input_layernorm.weight": "model-00004-of-00005.safetensors", "model.layers.28.mlp.down_proj.weight": "model-00004-of-00005.safetensors", "model.layers.28.mlp.gate_proj.weight": "model-00004-of-00005.safetensors", "model.layers.28.mlp.up_proj.weight": "model-00004-of-00005.safetensors", "model.layers.28.post_attention_layernorm.weight": "model-00004-of-00005.safetensors", "model.layers.28.self_attn.k_proj.weight": "model-00004-of-00005.safetensors", "model.layers.28.self_attn.o_proj.weight": "model-00004-of-00005.safetensors", "model.layers.28.self_attn.q_proj.weight": "model-00004-of-00005.safetensors", "model.layers.28.self_attn.v_proj.weight": "model-00004-of-00005.safetensors", "model.layers.29.input_layernorm.weight": "model-00004-of-00005.safetensors", "model.layers.29.mlp.down_proj.weight": "model-00004-of-00005.safetensors", "model.layers.29.mlp.gate_proj.weight": "model-00004-of-00005.safetensors", "model.layers.29.mlp.up_proj.weight": "model-00004-of-00005.safetensors", "model.layers.29.post_attention_layernorm.weight": "model-00004-of-00005.safetensors", "model.layers.29.self_attn.k_proj.weight": "model-00004-of-00005.safetensors", "model.layers.29.self_attn.o_proj.weight": "model-00004-of-00005.safetensors", "model.layers.29.self_attn.q_proj.weight": "model-00004-of-00005.safetensors", "model.layers.29.self_attn.v_proj.weight": "model-00004-of-00005.safetensors", "model.layers.30.input_layernorm.weight": "model-00004-of-00005.safetensors", "model.layers.30.mlp.down_proj.weight": "model-00004-of-00005.safetensors", "model.layers.30.mlp.gate_proj.weight": "model-00004-of-00005.safetensors", "model.layers.30.mlp.up_proj.weight": "model-00004-of-00005.safetensors", "model.layers.30.post_attention_layernorm.weight": "model-00004-of-00005.safetensors", "model.layers.30.self_attn.k_proj.weight": "model-00004-of-00005.safetensors", "model.layers.30.self_attn.o_proj.weight": "model-00004-of-00005.safetensors", "model.layers.30.self_attn.q_proj.weight": "model-00004-of-00005.safetensors", "model.layers.30.self_attn.v_proj.weight": "model-00004-of-00005.safetensors", "model.layers.31.input_layernorm.weight": "model-00004-of-00005.safetensors", "model.layers.31.mlp.down_proj.weight": "model-00004-of-00005.safetensors", "model.layers.31.mlp.gate_proj.weight": "model-00004-of-00005.safetensors", "model.layers.31.mlp.up_proj.weight": "model-00004-of-00005.safetensors", "model.layers.31.post_attention_layernorm.weight": "model-00004-of-00005.safetensors", "model.layers.31.self_attn.k_proj.weight": "model-00004-of-00005.safetensors", "model.layers.31.self_attn.o_proj.weight": "model-00004-of-00005.safetensors", "model.layers.31.self_attn.q_proj.weight": "model-00004-of-00005.safetensors", "model.layers.31.self_attn.v_proj.weight": "model-00004-of-00005.safetensors", "model.layers.32.input_layernorm.weight": "model-00004-of-00005.safetensors", "model.layers.32.mlp.down_proj.weight": "model-00004-of-00005.safetensors", "model.layers.32.mlp.gate_proj.weight": "model-00004-of-00005.safetensors", "model.layers.32.mlp.up_proj.weight": "model-00004-of-00005.safetensors", "model.layers.32.post_attention_layernorm.weight": "model-00004-of-00005.safetensors", "model.layers.32.self_attn.k_proj.weight": "model-00004-of-00005.safetensors", "model.layers.32.self_attn.o_proj.weight": "model-00004-of-00005.safetensors", "model.layers.32.self_attn.q_proj.weight": "model-00004-of-00005.safetensors", "model.layers.32.self_attn.v_proj.weight": "model-00004-of-00005.safetensors", "model.layers.33.input_layernorm.weight": "model-00004-of-00005.safetensors", "model.layers.33.mlp.down_proj.weight": "model-00004-of-00005.safetensors", "model.layers.33.mlp.gate_proj.weight": "model-00004-of-00005.safetensors", "model.layers.33.mlp.up_proj.weight": "model-00004-of-00005.safetensors", "model.layers.33.post_attention_layernorm.weight": "model-00004-of-00005.safetensors", "model.layers.33.self_attn.k_proj.weight": "model-00004-of-00005.safetensors", "model.layers.33.self_attn.o_proj.weight": "model-00004-of-00005.safetensors", "model.layers.33.self_attn.q_proj.weight": "model-00004-of-00005.safetensors", "model.layers.33.self_attn.v_proj.weight": "model-00004-of-00005.safetensors", "model.layers.34.mlp.gate_proj.weight": "model-00004-of-00005.safetensors", "model.layers.34.self_attn.k_proj.weight": "model-00004-of-00005.safetensors", "model.layers.34.self_attn.o_proj.weight": "model-00004-of-00005.safetensors", "model.layers.34.self_attn.q_proj.weight": "model-00004-of-00005.safetensors", "model.layers.34.self_attn.v_proj.weight": "model-00004-of-00005.safetensors", "model.layers.34.input_layernorm.weight": "model-00004-of-00005.safetensors", "model.layers.34.mlp.down_proj.weight": "model-00005-of-00005.safetensors", "model.layers.34.mlp.up_proj.weight": "model-00005-of-00005.safetensors", "model.layers.34.post_attention_layernorm.weight": "model-00005-of-00005.safetensors", "model.layers.35.input_layernorm.weight": "model-00005-of-00005.safetensors", "model.layers.35.mlp.down_proj.weight": "model-00005-of-00005.safetensors", "model.layers.35.mlp.gate_proj.weight": "model-00005-of-00005.safetensors", "model.layers.35.mlp.up_proj.weight": "model-00005-of-00005.safetensors", "model.layers.35.post_attention_layernorm.weight": "model-00005-of-00005.safetensors", "model.layers.35.self_attn.k_proj.weight": "model-00005-of-00005.safetensors", "model.layers.35.self_attn.o_proj.weight": "model-00005-of-00005.safetensors", "model.layers.35.self_attn.q_proj.weight": "model-00005-of-00005.safetensors", "model.layers.35.self_attn.v_proj.weight": "model-00005-of-00005.safetensors", "model.layers.36.input_layernorm.weight": "model-00005-of-00005.safetensors", "model.layers.36.mlp.down_proj.weight": "model-00005-of-00005.safetensors", "model.layers.36.mlp.gate_proj.weight": "model-00005-of-00005.safetensors", "model.layers.36.mlp.up_proj.weight": "model-00005-of-00005.safetensors", "model.layers.36.post_attention_layernorm.weight": "model-00005-of-00005.safetensors", "model.layers.36.self_attn.k_proj.weight": "model-00005-of-00005.safetensors", "model.layers.36.self_attn.o_proj.weight": "model-00005-of-00005.safetensors", "model.layers.36.self_attn.q_proj.weight": "model-00005-of-00005.safetensors", "model.layers.36.self_attn.v_proj.weight": "model-00005-of-00005.safetensors", "model.layers.37.input_layernorm.weight": "model-00005-of-00005.safetensors", "model.layers.37.mlp.down_proj.weight": "model-00005-of-00005.safetensors", "model.layers.37.mlp.gate_proj.weight": "model-00005-of-00005.safetensors", "model.layers.37.mlp.up_proj.weight": "model-00005-of-00005.safetensors", "model.layers.37.post_attention_layernorm.weight": "model-00005-of-00005.safetensors", "model.layers.37.self_attn.k_proj.weight": "model-00005-of-00005.safetensors", "model.layers.37.self_attn.o_proj.weight": "model-00005-of-00005.safetensors", "model.layers.37.self_attn.q_proj.weight": "model-00005-of-00005.safetensors", "model.layers.37.self_attn.v_proj.weight": "model-00005-of-00005.safetensors", "model.layers.38.input_layernorm.weight": "model-00005-of-00005.safetensors", "model.layers.38.mlp.down_proj.weight": "model-00005-of-00005.safetensors", "model.layers.38.mlp.gate_proj.weight": "model-00005-of-00005.safetensors", "model.layers.38.mlp.up_proj.weight": "model-00005-of-00005.safetensors", "model.layers.38.post_attention_layernorm.weight": "model-00005-of-00005.safetensors", "model.layers.38.self_attn.k_proj.weight": "model-00005-of-00005.safetensors", "model.layers.38.self_attn.o_proj.weight": "model-00005-of-00005.safetensors", "model.layers.38.self_attn.q_proj.weight": "model-00005-of-00005.safetensors", "model.layers.38.self_attn.v_proj.weight": "model-00005-of-00005.safetensors", "model.layers.39.input_layernorm.weight": "model-00005-of-00005.safetensors", "model.layers.39.mlp.down_proj.weight": "model-00005-of-00005.safetensors", "model.layers.39.mlp.gate_proj.weight": "model-00005-of-00005.safetensors", "model.layers.39.mlp.up_proj.weight": "model-00005-of-00005.safetensors", "model.layers.39.post_attention_layernorm.weight": "model-00005-of-00005.safetensors", "model.layers.39.self_attn.k_proj.weight": "model-00005-of-00005.safetensors", "model.layers.39.self_attn.o_proj.weight": "model-00005-of-00005.safetensors", "model.layers.39.self_attn.q_proj.weight": "model-00005-of-00005.safetensors", "model.layers.39.self_attn.v_proj.weight": "model-00005-of-00005.safetensors", "lm_head.weight": "model-00005-of-00005.safetensors", "model.norm.weight": "model-00005-of-00005.safetensors"}}
|
ByteWave_Yi-23B-Llama/tokenization_yi.py
ADDED
@@ -0,0 +1,246 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
from shutil import copyfile
|
3 |
+
from typing import Any, Dict, List, Optional, Tuple
|
4 |
+
|
5 |
+
import sentencepiece as spm
|
6 |
+
from transformers.tokenization_utils import AddedToken, PreTrainedTokenizer
|
7 |
+
from transformers.utils import logging
|
8 |
+
|
9 |
+
logger = logging.get_logger(__name__)
|
10 |
+
|
11 |
+
VOCAB_FILES_NAMES = {"vocab_file": "tokenizer.model"}
|
12 |
+
|
13 |
+
PRETRAINED_VOCAB_FILES_MAP = {
|
14 |
+
"vocab_file": {},
|
15 |
+
"tokenizer_file": {},
|
16 |
+
}
|
17 |
+
PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES = {}
|
18 |
+
|
19 |
+
|
20 |
+
class YiTokenizer(PreTrainedTokenizer):
|
21 |
+
"""
|
22 |
+
Construct a Yi tokenizer. Based on byte-level Byte-Pair-Encoding.
|
23 |
+
Args:
|
24 |
+
vocab_file (`str`):
|
25 |
+
Path to the vocabulary file.
|
26 |
+
"""
|
27 |
+
|
28 |
+
vocab_files_names = VOCAB_FILES_NAMES
|
29 |
+
pretrained_vocab_files_map = PRETRAINED_VOCAB_FILES_MAP
|
30 |
+
max_model_input_sizes = PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
|
31 |
+
model_input_names = ["input_ids", "attention_mask"]
|
32 |
+
|
33 |
+
def __init__(
|
34 |
+
self,
|
35 |
+
vocab_file,
|
36 |
+
unk_token="<unk>",
|
37 |
+
bos_token="<|startoftext|>",
|
38 |
+
eos_token="<|endoftext|>",
|
39 |
+
pad_token="<unk>",
|
40 |
+
sp_model_kwargs: Optional[Dict[str, Any]] = None,
|
41 |
+
add_bos_token=True,
|
42 |
+
add_eos_token=False,
|
43 |
+
clean_up_tokenization_spaces=False,
|
44 |
+
**kwargs,
|
45 |
+
):
|
46 |
+
self.sp_model_kwargs = {} if sp_model_kwargs is None else sp_model_kwargs
|
47 |
+
bos_token = (
|
48 |
+
AddedToken(bos_token, lstrip=False, rstrip=False)
|
49 |
+
if isinstance(bos_token, str)
|
50 |
+
else bos_token
|
51 |
+
)
|
52 |
+
eos_token = (
|
53 |
+
AddedToken(eos_token, lstrip=False, rstrip=False)
|
54 |
+
if isinstance(eos_token, str)
|
55 |
+
else eos_token
|
56 |
+
)
|
57 |
+
unk_token = (
|
58 |
+
AddedToken(unk_token, lstrip=False, rstrip=False)
|
59 |
+
if isinstance(unk_token, str)
|
60 |
+
else unk_token
|
61 |
+
)
|
62 |
+
pad_token = (
|
63 |
+
AddedToken(pad_token, lstrip=False, rstrip=False)
|
64 |
+
if isinstance(pad_token, str)
|
65 |
+
else pad_token
|
66 |
+
)
|
67 |
+
self.vocab_file = vocab_file
|
68 |
+
self.add_bos_token = add_bos_token
|
69 |
+
self.add_eos_token = add_eos_token
|
70 |
+
self.sp_model = spm.SentencePieceProcessor(**self.sp_model_kwargs)
|
71 |
+
self.sp_model.Load(vocab_file)
|
72 |
+
super().__init__(
|
73 |
+
bos_token=bos_token,
|
74 |
+
eos_token=eos_token,
|
75 |
+
unk_token=unk_token,
|
76 |
+
pad_token=pad_token,
|
77 |
+
add_bos_token=add_bos_token,
|
78 |
+
add_eos_token=add_eos_token,
|
79 |
+
sp_model_kwargs=self.sp_model_kwargs,
|
80 |
+
clean_up_tokenization_spaces=clean_up_tokenization_spaces,
|
81 |
+
**kwargs,
|
82 |
+
)
|
83 |
+
|
84 |
+
def __getstate__(self):
|
85 |
+
state = self.__dict__.copy()
|
86 |
+
state["sp_model"] = None
|
87 |
+
return state
|
88 |
+
|
89 |
+
def __setstate__(self, d):
|
90 |
+
self.__dict__ = d
|
91 |
+
self.sp_model = spm.SentencePieceProcessor(**self.sp_model_kwargs)
|
92 |
+
self.sp_model.Load(self.vocab_file)
|
93 |
+
|
94 |
+
@property
|
95 |
+
def vocab_size(self):
|
96 |
+
"""Returns vocab size"""
|
97 |
+
return self.sp_model.get_piece_size()
|
98 |
+
|
99 |
+
def get_vocab(self):
|
100 |
+
"""Returns vocab as a dict"""
|
101 |
+
vocab = {self.convert_ids_to_tokens(i): i for i in range(self.vocab_size)}
|
102 |
+
vocab.update(self.added_tokens_encoder)
|
103 |
+
return vocab
|
104 |
+
|
105 |
+
def _tokenize(self, text):
|
106 |
+
"""Returns a tokenized string."""
|
107 |
+
return self.sp_model.encode(text, out_type=str)
|
108 |
+
|
109 |
+
def _convert_token_to_id(self, token):
|
110 |
+
"""Converts a token (str) in an id using the vocab."""
|
111 |
+
return self.sp_model.piece_to_id(token)
|
112 |
+
|
113 |
+
def _convert_id_to_token(self, index):
|
114 |
+
"""Converts an index (integer) in a token (str) using the vocab."""
|
115 |
+
token = self.sp_model.IdToPiece(index)
|
116 |
+
return token
|
117 |
+
|
118 |
+
def convert_tokens_to_string(self, tokens):
|
119 |
+
"""Converts a sequence of tokens (string) in a single string."""
|
120 |
+
current_sub_tokens = []
|
121 |
+
out_string = ""
|
122 |
+
prev_is_special = False
|
123 |
+
for i, token in enumerate(tokens):
|
124 |
+
# make sure that special tokens are not decoded using sentencepiece model
|
125 |
+
if token in self.all_special_tokens:
|
126 |
+
if not prev_is_special and i != 0:
|
127 |
+
out_string += " "
|
128 |
+
out_string += self.sp_model.decode(current_sub_tokens) + token
|
129 |
+
prev_is_special = True
|
130 |
+
current_sub_tokens = []
|
131 |
+
else:
|
132 |
+
current_sub_tokens.append(token)
|
133 |
+
prev_is_special = False
|
134 |
+
out_string += self.sp_model.decode(current_sub_tokens)
|
135 |
+
return out_string
|
136 |
+
|
137 |
+
def save_vocabulary(
|
138 |
+
self, save_directory, filename_prefix: Optional[str] = None
|
139 |
+
) -> Tuple[str]:
|
140 |
+
"""
|
141 |
+
Save the vocabulary and special tokens file to a directory.
|
142 |
+
Args:
|
143 |
+
save_directory (`str`):
|
144 |
+
The directory in which to save the vocabulary.
|
145 |
+
Returns:
|
146 |
+
`Tuple(str)`: Paths to the files saved.
|
147 |
+
"""
|
148 |
+
if not os.path.isdir(save_directory):
|
149 |
+
logger.error(f"Vocabulary path ({save_directory}) should be a directory")
|
150 |
+
return
|
151 |
+
out_vocab_file = os.path.join(
|
152 |
+
save_directory,
|
153 |
+
(filename_prefix + "-" if filename_prefix else "")
|
154 |
+
+ VOCAB_FILES_NAMES["vocab_file"],
|
155 |
+
)
|
156 |
+
|
157 |
+
if os.path.abspath(self.vocab_file) != os.path.abspath(
|
158 |
+
out_vocab_file
|
159 |
+
) and os.path.isfile(self.vocab_file):
|
160 |
+
copyfile(self.vocab_file, out_vocab_file)
|
161 |
+
elif not os.path.isfile(self.vocab_file):
|
162 |
+
with open(out_vocab_file, "wb") as fi:
|
163 |
+
content_spiece_model = self.sp_model.serialized_model_proto()
|
164 |
+
fi.write(content_spiece_model)
|
165 |
+
|
166 |
+
return (out_vocab_file,)
|
167 |
+
|
168 |
+
def build_inputs_with_special_tokens(self, token_ids_0, token_ids_1=None):
|
169 |
+
bos_token_id = [self.bos_token_id] if self.add_bos_token else []
|
170 |
+
eos_token_id = [self.eos_token_id] if self.add_eos_token else []
|
171 |
+
|
172 |
+
output = bos_token_id + token_ids_0 + eos_token_id
|
173 |
+
|
174 |
+
if token_ids_1 is not None:
|
175 |
+
output = output + bos_token_id + token_ids_1 + eos_token_id
|
176 |
+
|
177 |
+
return output
|
178 |
+
|
179 |
+
def get_special_tokens_mask(
|
180 |
+
self,
|
181 |
+
token_ids_0: List[int],
|
182 |
+
token_ids_1: Optional[List[int]] = None,
|
183 |
+
already_has_special_tokens: bool = False,
|
184 |
+
) -> List[int]:
|
185 |
+
"""
|
186 |
+
Retrieve sequence ids from a token list that has no special tokens added. This method is called when adding
|
187 |
+
special tokens using the tokenizer `prepare_for_model` method.
|
188 |
+
Args:
|
189 |
+
token_ids_0 (`List[int]`):
|
190 |
+
List of IDs.
|
191 |
+
token_ids_1 (`List[int]`, *optional*):
|
192 |
+
Optional second list of IDs for sequence pairs.
|
193 |
+
already_has_special_tokens (`bool`, *optional*, defaults to `False`):
|
194 |
+
Whether or not the token list is already formatted with special tokens for the model.
|
195 |
+
Returns:
|
196 |
+
`List[int]`: A list of integers in the range [0, 1]: 1 for a special token, 0 for a sequence token.
|
197 |
+
"""
|
198 |
+
if already_has_special_tokens:
|
199 |
+
return super().get_special_tokens_mask(
|
200 |
+
token_ids_0=token_ids_0,
|
201 |
+
token_ids_1=token_ids_1,
|
202 |
+
already_has_special_tokens=True,
|
203 |
+
)
|
204 |
+
|
205 |
+
bos_token_id = [1] if self.add_bos_token else []
|
206 |
+
eos_token_id = [1] if self.add_eos_token else []
|
207 |
+
|
208 |
+
if token_ids_1 is None:
|
209 |
+
return bos_token_id + ([0] * len(token_ids_0)) + eos_token_id
|
210 |
+
return (
|
211 |
+
bos_token_id
|
212 |
+
+ ([0] * len(token_ids_0))
|
213 |
+
+ eos_token_id
|
214 |
+
+ bos_token_id
|
215 |
+
+ ([0] * len(token_ids_1))
|
216 |
+
+ eos_token_id
|
217 |
+
)
|
218 |
+
|
219 |
+
def create_token_type_ids_from_sequences(
|
220 |
+
self, token_ids_0: List[int], token_ids_1: Optional[List[int]] = None
|
221 |
+
) -> List[int]:
|
222 |
+
"""
|
223 |
+
Creates a mask from the two sequences passed to be used in a sequence-pair classification task. An ALBERT
|
224 |
+
sequence pair mask has the following format:
|
225 |
+
```
|
226 |
+
0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1
|
227 |
+
| first sequence | second sequence |
|
228 |
+
```
|
229 |
+
if token_ids_1 is None, only returns the first portion of the mask (0s).
|
230 |
+
Args:
|
231 |
+
token_ids_0 (`List[int]`):
|
232 |
+
List of ids.
|
233 |
+
token_ids_1 (`List[int]`, *optional*):
|
234 |
+
Optional second list of IDs for sequence pairs.
|
235 |
+
Returns:
|
236 |
+
`List[int]`: List of [token type IDs](../glossary#token-type-ids) according to the given sequence(s).
|
237 |
+
"""
|
238 |
+
bos_token_id = [self.bos_token_id] if self.add_bos_token else []
|
239 |
+
eos_token_id = [self.eos_token_id] if self.add_eos_token else []
|
240 |
+
|
241 |
+
output = [0] * len(bos_token_id + token_ids_0 + eos_token_id)
|
242 |
+
|
243 |
+
if token_ids_1 is not None:
|
244 |
+
output += [1] * len(bos_token_id + token_ids_1 + eos_token_id)
|
245 |
+
|
246 |
+
return output
|
ByteWave_Yi-23B-Llama/tokenizer.model
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:386c49cf943d71aa110361135338c50e38beeff0a66593480421f37b319e1a39
|
3 |
+
size 1033105
|
ByteWave_Yi-23B-Llama/tokenizer_config.json
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"auto_map": {
|
3 |
+
"AutoTokenizer": ["tokenization_yi.YiTokenizer", null]
|
4 |
+
},
|
5 |
+
"add_bos_token": false,
|
6 |
+
"add_eos_token": false,
|
7 |
+
"model_max_length": 4096,
|
8 |
+
"tokenizer_class": "YiTokenizer"
|
9 |
+
}
|