Apppublic
yhavinga/dutch-tokenizer-arena
8likes
App README
压缩率 Compress Rate
在 cc-100 数据集,每个语言取1万条数据,测试不同tokenizer的压缩率。
压缩率示例:
llama3扩充了词典,具有更高的压缩比。同样1T字节的简体中文语料,llama分词后是 0.56万亿个token,llama3只需要0.31万亿个token。
| tokenizer | vocab_size | t_bytes/t_tokens | t_tokens/t_bytes | n_chars/n_tokens |
|---|---|---|---|---|
| llama | 32000 | 1.8 | 0.56 | 0.7 |
| llama3 | 128000 | 3.2 | 0.31 | 1.24 |
可通过以下脚本进行复现
sh
python utils/compress_rate_util.py <details> <summary>英文压缩率</summary> 在英文数据集 cc100-en 计算压缩率
| tokenizer | vocab_size | g_bytes/b_tokens | b_tokens/g_bytes | t_bytes/t_tokens | t_tokens/t_bytes | n_chars/n_tokens |
|---|---|---|---|---|---|---|
| amber | 32000 | 3.56 | 0.28 | 3.47 | 0.29 | 3.81 |
| aya_101 | 250100 | 3.3 | 0.3 | 3.22 | 0.31 | 3.53 |
| baichuan | 64000 | 3.74 | 0.27 | 3.65 | 0.27 | 4 |
| baichuan2 | 125696 | 3.89 | 0.26 | 3.8 | 0.26 | 4.17 |
| bertbasecased | 28996 | 3.64 | 0.27 | 3.55 | 0.28 | 3.89 |
| bertbasechinese | 21128 | 2.78 | 0.36 | 2.71 | 0.37 | 2.97 |
| bertbaseuncased | 30522 | 3.73 | 0.27 | 3.65 | 0.27 | 4 |
| bloom | 250680 | 4.07 | 0.25 | 3.97 | 0.25 | 4.36 |
| byt5_small | 256 | 0.92 | 1.08 | 0.9 | 1.11 | 0.99 |
| characterglm6b | 64794 | 3.62 | 0.28 | 3.54 | 0.28 | 3.88 |
| chatglm2_6b | 64794 | 3.62 | 0.28 | 3.54 | 0.28 | 3.88 |
| chatglm3_6b | 64798 | 3.62 | 0.28 | 3.54 | 0.28 | 3.88 |
| chatglm_6b | 150344 | 3.68 | 0.27 | 3.59 | 0.28 | 3.94 |
| chatyuanlargev2 | 32128 | 1.95 | 0.51 | 1.91 | 0.52 | 2.09 |
| chinese_llama | 49953 | 3.59 | 0.28 | 3.51 | 0.28 | 3.85 |
| chinese_llama2 | 55296 | 3.56 | 0.28 | 3.47 | 0.29 | 3.81 |
| codedavinci002 | 50281 | 4.05 | 0.25 | 3.96 | 0.25 | 4.34 |
| crystal_coder | 32000 | 3.68 | 0.27 | 3.59 | 0.28 | 3.94 |
| dbrx_instruct | 100277 | 4.11 | 0.24 | 4.01 | 0.25 | 4.4 |
| deepseekcoder33b_instruct | 32000 | 3.64 | 0.27 | 3.56 | 0.28 | 3.9 |
| deepseekllm7b_base | 100000 | 3.85 | 0.26 | 3.76 | 0.27 | 4.12 |
| falcon_180b | 65024 | 3.99 | 0.25 | 3.9 | 0.26 | 4.27 |
| falcon_7b | 65024 | 3.99 | 0.25 | 3.9 | 0.26 | 4.27 |
| fastchatt53b | 32000 | 2.16 | 0.46 | 2.11 | 0.47 | 2.31 |
| flant5base | 32100 | 3.61 | 0.28 | 3.53 | 0.28 | 3.87 |
| gemma_7b | 256000 | 3.91 | 0.26 | 3.82 | 0.26 | 4.18 |
| gpt2 | 50257 | 4.05 | 0.25 | 3.96 | 0.25 | 4.34 |
| gpt2_chinese | 21128 | 2.67 | 0.37 | 2.61 | 0.38 | 2.86 |
| gpt35turbo | 100277 | 4.11 | 0.24 | 4.01 | 0.25 | 4.4 |
| gpt_4 | 100277 | 4.11 | 0.24 | 4.01 | 0.25 | 4.4 |
| gptnexo20b | 50254 | 4.04 | 0.25 | 3.94 | 0.25 | 4.32 |
| grok_1 | 131072 | 4.06 | 0.25 | 3.96 | 0.25 | 4.35 |
| internlm2chat7b | 92544 | 3.86 | 0.26 | 3.77 | 0.27 | 4.13 |
| internlm2math7b | 92544 | 3.86 | 0.26 | 3.77 | 0.27 | 4.13 |
| internlmchat7b | 103168 | 3.86 | 0.26 | 3.77 | 0.27 | 4.13 |
| internlmxcomposer7b | 103168 | 3.86 | 0.26 | 3.77 | 0.27 | 4.13 |
| jambav01 | 65536 | 3.82 | 0.26 | 3.73 | 0.27 | 4.09 |
| kplug | 10261 | 2.66 | 0.38 | 2.6 | 0.38 | 2.85 |
| llama | 32000 | 3.56 | 0.28 | 3.47 | 0.29 | 3.81 |
| llama2 | 32000 | 3.56 | 0.28 | 3.47 | 0.29 | 3.81 |
| llama3 | 128000 | 4.11 | 0.24 | 4.01 | 0.25 | 4.4 |
| mistral_7b | 32000 | 3.67 | 0.27 | 3.58 | 0.28 | 3.92 |
| mixtral87b | 32000 | 3.67 | 0.27 | 3.58 | 0.28 | 3.92 |
| mobilebert_uncased | 30522 | 3.73 | 0.27 | 3.65 | 0.27 | 4 |
| moss | 106029 | 4.08 | 0.25 | 3.98 | 0.25 | 4.36 |
| mt5_large | 250100 | 3.3 | 0.3 | 3.22 | 0.31 | 3.53 |
| olmo_7b | 50280 | 4.04 | 0.25 | 3.94 | 0.25 | 4.32 |
| orion14bchat | 84608 | 3.94 | 0.25 | 3.85 | 0.26 | 4.22 |
| phi_1 | 50257 | 4.05 | 0.25 | 3.96 | 0.25 | 4.34 |
| phi_2 | 50257 | 4.05 | 0.25 | 3.96 | 0.25 | 4.34 |
| pkot5large | 50258 | 1.59 | 0.63 | 1.55 | 0.64 | 1.7 |
| prompt_clue | 32128 | 1.95 | 0.51 | 1.91 | 0.52 | 2.09 |
| qwen1514b_chat | 151643 | 4.06 | 0.25 | 3.97 | 0.25 | 4.35 |
| qwen18b_chat | 151851 | 4.06 | 0.25 | 3.97 | 0.25 | 4.35 |
| qwen72bchat | 151851 | 4.06 | 0.25 | 3.97 | 0.25 | 4.35 |
| qwen7bchat | 151851 | 4.06 | 0.25 | 3.97 | 0.25 | 4.35 |
| robertachineseclue | 8021 | 1.8 | 0.56 | 1.75 | 0.57 | 1.92 |
| skywork13bbase | 65519 | 3.56 | 0.28 | 3.47 | 0.29 | 3.81 |
| skywork13bmath | 65519 | 3.56 | 0.28 | 3.47 | 0.29 | 3.81 |
| solar107b | 32000 | 3.67 | 0.27 | 3.58 | 0.28 | 3.92 |
| starchat_alpha | 49152 | 3.63 | 0.28 | 3.54 | 0.28 | 3.88 |
| switchc2048 | 32100 | 3.61 | 0.28 | 3.53 | 0.28 | 3.87 |
| t5_base | 32100 | 3.61 | 0.28 | 3.53 | 0.28 | 3.87 |
| t5_large | 32100 | 3.61 | 0.28 | 3.53 | 0.28 | 3.87 |
| t5_small | 32100 | 3.61 | 0.28 | 3.53 | 0.28 | 3.87 |
| textdavinci003 | 50281 | 4.05 | 0.25 | 3.96 | 0.25 | 4.34 |
| tigerbot13bchat_v2 | 60512 | 3.67 | 0.27 | 3.58 | 0.28 | 3.93 |
| tigerbot70bchatv44k | 65107 | 3.65 | 0.27 | 3.57 | 0.28 | 3.91 |
| wizardcoder15bv1 | 49152 | 3.63 | 0.28 | 3.54 | 0.28 | 3.88 |
| wizardcoderpython7b_v1 | 32000 | 3.56 | 0.28 | 3.47 | 0.29 | 3.81 |
| wizardlm7bv1 | 32000 | 3.56 | 0.28 | 3.47 | 0.29 | 3.81 |
| wizardmath70bv1 | 32000 | 3.56 | 0.28 | 3.47 | 0.29 | 3.81 |
| xlm_roberta | 250002 | 3.49 | 0.29 | 3.41 | 0.29 | 3.74 |
| yi_34b | 64000 | 3.87 | 0.26 | 3.78 | 0.26 | 4.15 |
| yi_6b | 64000 | 3.87 | 0.26 | 3.78 | 0.26 | 4.15 |
| yi_vl34b | 64000 | 3.88 | 0.26 | 3.79 | 0.26 | 4.16 |
| zephyr7bbeta | 32000 | 3.67 | 0.27 | 3.58 | 0.28 | 3.92 |
</details>
<details> <summary>简体中文压缩率</summary> 在简体中文数据集 cc100-zh-Hans 计算压缩率
| tokenizer | vocab_size | g_bytes/b_tokens | b_tokens/g_bytes | t_bytes/t_tokens | t_tokens/t_bytes | n_chars/n_tokens |
|---|---|---|---|---|---|---|
| amber | 32000 | 1.84 | 0.54 | 1.8 | 0.56 | 0.7 |
| aya_101 | 250100 | 3.89 | 0.26 | 3.79 | 0.26 | 1.47 |
| baichuan | 64000 | 3.92 | 0.26 | 3.82 | 0.26 | 1.48 |
| baichuan2 | 125696 | 4.53 | 0.22 | 4.42 | 0.23 | 1.71 |
| bertbasecased | 28996 | 2.73 | 0.37 | 2.66 | 0.38 | 1.03 |
| bertbasechinese | 21128 | 2.74 | 0.37 | 2.67 | 0.37 | 1.03 |
| bertbaseuncased | 30522 | 2.73 | 0.37 | 2.67 | 0.38 | 1.03 |
| bloom | 250680 | 4.28 | 0.23 | 4.18 | 0.24 | 1.62 |
| byt5_small | 256 | 0.93 | 1.08 | 0.91 | 1.1 | 0.35 |
| characterglm6b | 64794 | 4.2 | 0.24 | 4.1 | 0.24 | 1.59 |
| chatglm2_6b | 64794 | 4.2 | 0.24 | 4.1 | 0.24 | 1.59 |
| chatglm3_6b | 64798 | 4.2 | 0.24 | 4.1 | 0.24 | 1.59 |
| chatglm_6b | 150344 | 4.65 | 0.22 | 4.54 | 0.22 | 1.76 |
| chatyuanlargev2 | 32128 | 4.34 | 0.23 | 4.24 | 0.24 | 1.64 |
| chinese_llama | 49953 | 3.93 | 0.25 | 3.84 | 0.26 | 1.49 |
| chinese_llama2 | 55296 | 3.92 | 0.26 | 3.83 | 0.26 | 1.48 |
| codedavinci002 | 50281 | 1.31 | 0.77 | 1.28 | 0.78 | 0.49 |
| crystal_coder | 32000 | 1.86 | 0.54 | 1.81 | 0.55 | 0.7 |
| dbrx_instruct | 100277 | 2.26 | 0.44 | 2.21 | 0.45 | 0.85 |
| deepseekcoder33b_instruct | 32000 | 3.4 | 0.29 | 3.32 | 0.3 | 1.29 |
| deepseekllm7b_base | 100000 | 4.05 | 0.25 | 3.96 | 0.25 | 1.53 |
| falcon_180b | 65024 | 2.18 | 0.46 | 2.13 | 0.47 | 0.82 |
| falcon_7b | 65024 | 2.18 | 0.46 | 2.13 | 0.47 | 0.82 |
| fastchatt53b | 32000 | 13.7 | 0.07 | 13.38 | 0.07 | 5.18 |
| flant5base | 32100 | 14.13 | 0.07 | 13.8 | 0.07 | 5.34 |
| gemma_7b | 256000 | 3.82 | 0.26 | 3.73 | 0.27 | 1.44 |
| gpt2 | 50257 | 1.31 | 0.77 | 1.28 | 0.78 | 0.49 |
| gpt2_chinese | 21128 | 2.73 | 0.37 | 2.66 | 0.38 | 1.03 |
| gpt35turbo | 100277 | 2.26 | 0.44 | 2.21 | 0.45 | 0.85 |
| gpt_4 | 100277 | 2.26 | 0.44 | 2.21 | 0.45 | 0.85 |
| gptnexo20b | 50254 | 2.01 | 0.5 | 1.96 | 0.51 | 0.76 |
| grok_1 | 131072 | 1.73 | 0.58 | 1.69 | 0.59 | 0.66 |
| internlm2chat7b | 92544 | 4.23 | 0.24 | 4.13 | 0.24 | 1.6 |
| internlm2math7b | 92544 | 4.23 | 0.24 | 4.13 | 0.24 | 1.6 |
| internlmchat7b | 103168 | 4.23 | 0.24 | 4.14 | 0.24 | 1.6 |
| internlmxcomposer7b | 103168 | 4.23 | 0.24 | 4.14 | 0.24 | 1.6 |
| jambav01 | 65536 | 2.3 | 0.44 | 2.24 | 0.45 | 0.87 |
| kplug | 10261 | 2.72 | 0.37 | 2.65 | 0.38 | 1.03 |
| llama | 32000 | 1.84 | 0.54 | 1.8 | 0.56 | 0.7 |
| llama2 | 32000 | 1.84 | 0.54 | 1.8 | 0.56 | 0.7 |
| llama3 | 128000 | 3.28 | 0.3 | 3.2 | 0.31 | 1.24 |
| mistral_7b | 32000 | 2.36 | 0.42 | 2.3 | 0.43 | 0.89 |
| mixtral87b | 32000 | 2.36 | 0.42 | 2.3 | 0.43 | 0.89 |
| mobilebert_uncased | 30522 | 2.73 | 0.37 | 2.67 | 0.38 | 1.03 |
| moss | 106029 | 4.4 | 0.23 | 4.3 | 0.23 | 1.66 |
| mt5_large | 250100 | 3.89 | 0.26 | 3.79 | 0.26 | 1.47 |
| olmo_7b | 50280 | 2.01 | 0.5 | 1.96 | 0.51 | 0.76 |
| orion14bchat | 84608 | 4.63 | 0.22 | 4.52 | 0.22 | 1.75 |
| phi_1 | 50257 | 1.31 | 0.77 | 1.28 | 0.78 | 0.49 |
| phi_2 | 50257 | 1.31 | 0.77 | 1.28 | 0.78 | 0.49 |
| pkot5large | 50258 | 0.97 | 1.03 | 0.95 | 1.06 | 0.37 |
| prompt_clue | 32128 | 4.34 | 0.23 | 4.24 | 0.24 | 1.64 |
| qwen1514b_chat | 151643 | 4.16 | 0.24 | 4.06 | 0.25 | 1.57 |
| qwen18b_chat | 151851 | 4.16 | 0.24 | 4.06 | 0.25 | 1.57 |
| qwen72bchat | 151851 | 4.16 | 0.24 | 4.06 | 0.25 | 1.57 |
| qwen7bchat | 151851 | 4.16 | 0.24 | 4.06 | 0.25 | 1.57 |
| robertachineseclue | 8021 | 2.7 | 0.37 | 2.64 | 0.38 | 1.02 |
| skywork13bbase | 65519 | 3.69 | 0.27 | 3.61 | 0.28 | 1.4 |
| skywork13bmath | 65519 | 3.69 | 0.27 | 3.61 | 0.28 | 1.4 |
| solar107b | 32000 | 2.36 | 0.42 | 2.3 | 0.43 | 0.89 |
| starchat_alpha | 49152 | 2.78 | 0.36 | 2.72 | 0.37 | 1.05 |
| switchc2048 | 32100 | 14.13 | 0.07 | 13.8 | 0.07 | 5.34 |
| t5_base | 32100 | 14.13 | 0.07 | 13.8 | 0.07 | 5.34 |
| t5_large | 32100 | 14.13 | 0.07 | 13.8 | 0.07 | 5.34 |
| t5_small | 32100 | 14.13 | 0.07 | 13.8 | 0.07 | 5.34 |
| textdavinci003 | 50281 | 1.31 | 0.77 | 1.28 | 0.78 | 0.49 |
| tigerbot13bchat_v2 | 60512 | 4.25 | 0.24 | 4.15 | 0.24 | 1.61 |
| tigerbot70bchatv44k | 65107 | 4.25 | 0.24 | 4.15 | 0.24 | 1.61 |
| wizardcoder15bv1 | 49152 | 2.78 | 0.36 | 2.72 | 0.37 | 1.05 |
| wizardcoderpython7b_v1 | 32000 | 1.84 | 0.54 | 1.8 | 0.56 | 0.7 |
| wizardlm7bv1 | 32000 | 1.84 | 0.54 | 1.8 | 0.56 | 0.7 |
| wizardmath70bv1 | 32000 | 1.84 | 0.54 | 1.8 | 0.56 | 0.7 |
| xlm_roberta | 250002 | 3.96 | 0.25 | 3.86 | 0.26 | 1.5 |
| yi_34b | 64000 | 4.17 | 0.24 | 4.07 | 0.25 | 1.58 |
| yi_6b | 64000 | 4.17 | 0.24 | 4.07 | 0.25 | 1.58 |
| yi_vl34b | 64000 | 4.11 | 0.24 | 4.02 | 0.25 | 1.56 |
| zephyr7bbeta | 32000 | 2.36 | 0.42 | 2.3 | 0.43 | 0.89 |
</details>
Reference
- —Getting the most out of your tokenizer for pre-training and domain adaptation
- —Efficient and Effective Text Encoding for Chinese LLaMA and Alpaca
- —https://huggingface.co/spaces/Xenova/the-tokenizer-playground
