qqc1989 commited on
Commit
87c28b5
·
verified ·
1 Parent(s): 3bc5f77

Upload 40 files

Browse files
Files changed (41) hide show
  1. .gitattributes +3 -0
  2. config.json +0 -0
  3. main_ax650 +3 -0
  4. main_axcl_aarch64 +3 -0
  5. main_axcl_x86 +3 -0
  6. minicpm4-0.5b-int8-ctx-ax650/MiniCPMForCausalLM_p128_l0_together.axmodel +3 -0
  7. minicpm4-0.5b-int8-ctx-ax650/MiniCPMForCausalLM_p128_l10_together.axmodel +3 -0
  8. minicpm4-0.5b-int8-ctx-ax650/MiniCPMForCausalLM_p128_l11_together.axmodel +3 -0
  9. minicpm4-0.5b-int8-ctx-ax650/MiniCPMForCausalLM_p128_l12_together.axmodel +3 -0
  10. minicpm4-0.5b-int8-ctx-ax650/MiniCPMForCausalLM_p128_l13_together.axmodel +3 -0
  11. minicpm4-0.5b-int8-ctx-ax650/MiniCPMForCausalLM_p128_l14_together.axmodel +3 -0
  12. minicpm4-0.5b-int8-ctx-ax650/MiniCPMForCausalLM_p128_l15_together.axmodel +3 -0
  13. minicpm4-0.5b-int8-ctx-ax650/MiniCPMForCausalLM_p128_l16_together.axmodel +3 -0
  14. minicpm4-0.5b-int8-ctx-ax650/MiniCPMForCausalLM_p128_l17_together.axmodel +3 -0
  15. minicpm4-0.5b-int8-ctx-ax650/MiniCPMForCausalLM_p128_l18_together.axmodel +3 -0
  16. minicpm4-0.5b-int8-ctx-ax650/MiniCPMForCausalLM_p128_l19_together.axmodel +3 -0
  17. minicpm4-0.5b-int8-ctx-ax650/MiniCPMForCausalLM_p128_l1_together.axmodel +3 -0
  18. minicpm4-0.5b-int8-ctx-ax650/MiniCPMForCausalLM_p128_l20_together.axmodel +3 -0
  19. minicpm4-0.5b-int8-ctx-ax650/MiniCPMForCausalLM_p128_l21_together.axmodel +3 -0
  20. minicpm4-0.5b-int8-ctx-ax650/MiniCPMForCausalLM_p128_l22_together.axmodel +3 -0
  21. minicpm4-0.5b-int8-ctx-ax650/MiniCPMForCausalLM_p128_l23_together.axmodel +3 -0
  22. minicpm4-0.5b-int8-ctx-ax650/MiniCPMForCausalLM_p128_l2_together.axmodel +3 -0
  23. minicpm4-0.5b-int8-ctx-ax650/MiniCPMForCausalLM_p128_l3_together.axmodel +3 -0
  24. minicpm4-0.5b-int8-ctx-ax650/MiniCPMForCausalLM_p128_l4_together.axmodel +3 -0
  25. minicpm4-0.5b-int8-ctx-ax650/MiniCPMForCausalLM_p128_l5_together.axmodel +3 -0
  26. minicpm4-0.5b-int8-ctx-ax650/MiniCPMForCausalLM_p128_l6_together.axmodel +3 -0
  27. minicpm4-0.5b-int8-ctx-ax650/MiniCPMForCausalLM_p128_l7_together.axmodel +3 -0
  28. minicpm4-0.5b-int8-ctx-ax650/MiniCPMForCausalLM_p128_l8_together.axmodel +3 -0
  29. minicpm4-0.5b-int8-ctx-ax650/MiniCPMForCausalLM_p128_l9_together.axmodel +3 -0
  30. minicpm4-0.5b-int8-ctx-ax650/MiniCPMForCausalLM_post.axmodel +3 -0
  31. minicpm4-0.5b-int8-ctx-ax650/model.embed_tokens.weight.bfloat16.bin +3 -0
  32. minicpm4_tokenizer/added_tokens.json +10 -0
  33. minicpm4_tokenizer/config.json +37 -0
  34. minicpm4_tokenizer/generation_config.json +12 -0
  35. minicpm4_tokenizer/special_tokens_map.json +33 -0
  36. minicpm4_tokenizer/tokenizer.json +0 -0
  37. minicpm4_tokenizer/tokenizer.model +3 -0
  38. minicpm4_tokenizer/tokenizer_config.json +117 -0
  39. minicpm4_tokenizer_uid.py +199 -0
  40. post_config.json +14 -0
  41. run_minicpm4_0.5b_int8_ctx_ax650.sh +14 -0
.gitattributes CHANGED
@@ -34,3 +34,6 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
  *.axmodel filter=lfs diff=lfs merge=lfs -text
 
 
 
 
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
  *.axmodel filter=lfs diff=lfs merge=lfs -text
37
+ main_ax650 filter=lfs diff=lfs merge=lfs -text
38
+ main_axcl_aarch64 filter=lfs diff=lfs merge=lfs -text
39
+ main_axcl_x86 filter=lfs diff=lfs merge=lfs -text
config.json ADDED
File without changes
main_ax650 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:870254b83b53d8f1909a03d2e73b0049fd5541e848579fc530888d07c28a48a2
3
+ size 989368
main_axcl_aarch64 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:03012513d42b834360fac6e61aa8b7387deb4f5ecd9f9c86d0b208e608b8c991
3
+ size 1724632
main_axcl_x86 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5f872d9f2238ec7db7ce3a075d52a673bac7b5a7e18455a81852b80223037ae3
3
+ size 1839824
minicpm4-0.5b-int8-ctx-ax650/MiniCPMForCausalLM_p128_l0_together.axmodel ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a464bc5480ab466fb81df78b7f38fc1d2afd3c07e6b8ed9e43e8a4661d265b1d
3
+ size 17484788
minicpm4-0.5b-int8-ctx-ax650/MiniCPMForCausalLM_p128_l10_together.axmodel ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fa4feb9e333fccafbed59942743b0815089ecfef2efa83b8e6f2b1d53ecf855e
3
+ size 17473812
minicpm4-0.5b-int8-ctx-ax650/MiniCPMForCausalLM_p128_l11_together.axmodel ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4b6592b72f251590db011e9923d6f51e64dce5eb25a937111d957371ee40587c
3
+ size 17473812
minicpm4-0.5b-int8-ctx-ax650/MiniCPMForCausalLM_p128_l12_together.axmodel ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:eff9f8748fa09a9228e718160008d33f8e2c4ed335bc978c41471f09796843c5
3
+ size 17473812
minicpm4-0.5b-int8-ctx-ax650/MiniCPMForCausalLM_p128_l13_together.axmodel ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:dee4386ae92bdfeaa83590b2a5720598c944b75ea0eca296a5c1cd77f9328b76
3
+ size 17473812
minicpm4-0.5b-int8-ctx-ax650/MiniCPMForCausalLM_p128_l14_together.axmodel ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f4ac5661daec71577bb0bd864d59f8bc63e076d6a3ee647b3cb7b3d2b87ed11d
3
+ size 17473812
minicpm4-0.5b-int8-ctx-ax650/MiniCPMForCausalLM_p128_l15_together.axmodel ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fda43fc22089a66f2e7b91ce1dad1a587ab8c33057755aa7f34f977839b116b1
3
+ size 17473812
minicpm4-0.5b-int8-ctx-ax650/MiniCPMForCausalLM_p128_l16_together.axmodel ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f55ee28760e580a88a5e62dfabdf1aaf8faf4205f7fb8434747cff1c0d6f3013
3
+ size 17473812
minicpm4-0.5b-int8-ctx-ax650/MiniCPMForCausalLM_p128_l17_together.axmodel ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d2267345dc7101f1bb28ed4bc95d92b86de77b59a862e0bad0011ef27f4e23c0
3
+ size 17473812
minicpm4-0.5b-int8-ctx-ax650/MiniCPMForCausalLM_p128_l18_together.axmodel ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5d6844de1eda71f56656588e76ab985520462b7b124172bdaaea426bf5f8ffbb
3
+ size 17473812
minicpm4-0.5b-int8-ctx-ax650/MiniCPMForCausalLM_p128_l19_together.axmodel ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2f29a2a84421b83d722b3c0926ce4627f7328b80dfe4720f3baf487651cad02f
3
+ size 17473812
minicpm4-0.5b-int8-ctx-ax650/MiniCPMForCausalLM_p128_l1_together.axmodel ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:189188e9b5a332e464b78a59faebde1707cff564836980e46812c03af8f17f80
3
+ size 17473812
minicpm4-0.5b-int8-ctx-ax650/MiniCPMForCausalLM_p128_l20_together.axmodel ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:bd589426ec6c7831e7a710038762118b7933951faa8c6edcf9a7a8f755d29b9c
3
+ size 17473812
minicpm4-0.5b-int8-ctx-ax650/MiniCPMForCausalLM_p128_l21_together.axmodel ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ee832073759c4630cd3bfee9fb25dcb936c9be0ade8f8269630b2f89f863ad7e
3
+ size 17473812
minicpm4-0.5b-int8-ctx-ax650/MiniCPMForCausalLM_p128_l22_together.axmodel ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9003410840fbf31810f13c54b0fb925decf202959b16da4e894eec8c57507fc5
3
+ size 17473812
minicpm4-0.5b-int8-ctx-ax650/MiniCPMForCausalLM_p128_l23_together.axmodel ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:80a35d4f1a12d88b63c34202f321743f689290ac27885356c26bffdc960a7338
3
+ size 17473812
minicpm4-0.5b-int8-ctx-ax650/MiniCPMForCausalLM_p128_l2_together.axmodel ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ecf6012ab296f5e4ea8a2d67a867d2c2a00cdcedeaf81df7e78651d3135325da
3
+ size 17473812
minicpm4-0.5b-int8-ctx-ax650/MiniCPMForCausalLM_p128_l3_together.axmodel ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:bac813c3ba1f660c2deb9f18a350fb7e8bf41219cb29091c67ee8805f51cb921
3
+ size 17473812
minicpm4-0.5b-int8-ctx-ax650/MiniCPMForCausalLM_p128_l4_together.axmodel ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:08141250430f708078aeb76263eb253288e001483008b8e85cef2a5172eb2606
3
+ size 17473812
minicpm4-0.5b-int8-ctx-ax650/MiniCPMForCausalLM_p128_l5_together.axmodel ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:40eeab8f4971717ce7570a549701d93bae6c8c70458dcba3e54eb59cc4676984
3
+ size 17473812
minicpm4-0.5b-int8-ctx-ax650/MiniCPMForCausalLM_p128_l6_together.axmodel ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2f3c4a4e7040be172f266f521b990732dc3c45fd93750b7fd4be464e0b02153c
3
+ size 17473812
minicpm4-0.5b-int8-ctx-ax650/MiniCPMForCausalLM_p128_l7_together.axmodel ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c31a22f0a4639df13cb7368f2f654a19d62b1693da75d24b352d4b81f247b2eb
3
+ size 17473812
minicpm4-0.5b-int8-ctx-ax650/MiniCPMForCausalLM_p128_l8_together.axmodel ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b75ad009315ff06f5dd99eb3e24fc4ac4b6ce3686cb15614ccace73140c30c1b
3
+ size 17473812
minicpm4-0.5b-int8-ctx-ax650/MiniCPMForCausalLM_p128_l9_together.axmodel ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:05a679d5a05cdaa0744711d4094a27327221ca99d2494dca697469a85a79b86a
3
+ size 17473812
minicpm4-0.5b-int8-ctx-ax650/MiniCPMForCausalLM_post.axmodel ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1a98a8caef2c9769674a7390b1506695c38c25b970c551dc64369373274f8d89
3
+ size 82179198
minicpm4-0.5b-int8-ctx-ax650/model.embed_tokens.weight.bfloat16.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:89e99a3acaab0bc7fe030abef0fa2c41e6373afbf40a79c84be6cb620ea5495d
3
+ size 150421504
minicpm4_tokenizer/added_tokens.json ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "<|execute_end|>": 73444,
3
+ "<|execute_start|>": 73443,
4
+ "<|fim_middle|>": 73446,
5
+ "<|fim_prefix|>": 73445,
6
+ "<|fim_suffix|>": 73447,
7
+ "<|im_end|>": 73440,
8
+ "<|im_start|>": 73441,
9
+ "<|tool_call|>": 73442
10
+ }
minicpm4_tokenizer/config.json ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "openbmb/MiniCPM4-0.5B",
3
+ "architectures": [
4
+ "MiniCPMForCausalLM"
5
+ ],
6
+ "auto_map": {
7
+ "AutoConfig": "configuration_minicpm.MiniCPMConfig",
8
+ "AutoModel": "modeling_minicpm.MiniCPMModel",
9
+ "AutoModelForCausalLM": "modeling_minicpm.MiniCPMForCausalLM",
10
+ "AutoModelForSeq2SeqLM": "modeling_minicpm.MiniCPMForCausalLM",
11
+ "AutoModelForSequenceClassification": "modeling_minicpm.MiniCPMForSequenceClassification"
12
+ },
13
+ "bos_token_id": 1,
14
+ "eos_token_id": [2, 73440],
15
+ "hidden_act": "silu",
16
+ "hidden_size": 1024,
17
+ "initializer_range": 0.1,
18
+ "intermediate_size": 4096,
19
+ "max_position_embeddings": 32768,
20
+ "num_attention_heads": 16,
21
+ "num_hidden_layers": 24,
22
+ "num_key_value_heads": 2,
23
+ "rms_norm_eps": 1e-05,
24
+ "rope_scaling": {
25
+ "rope_type": "longrope",
26
+ "long_factor": [1.0004360675811768, 1.0668443441390991, 1.1631425619125366, 1.3025742769241333, 1.5040205717086792, 1.7941505908966064, 2.2101221084594727, 2.802666664123535, 3.6389970779418945, 4.804192543029785, 6.39855432510376, 8.527148246765137, 11.277542114257812, 14.684998512268066, 18.69317054748535, 23.13019371032715, 27.72362518310547, 32.1606559753418, 36.168827056884766, 39.57627868652344, 42.32667541503906, 44.45526885986328, 46.04962921142578, 47.21482849121094, 48.05115509033203, 48.64370346069336, 49.05967712402344, 49.34980392456055, 49.551246643066406, 49.69068145751953, 49.78697967529297, 49.85338592529297],
27
+ "short_factor": [1.0004360675811768, 1.0668443441390991, 1.1631425619125366, 1.3025742769241333, 1.5040205717086792, 1.7941505908966064, 2.2101221084594727, 2.802666664123535, 3.6389970779418945, 4.804192543029785, 6.39855432510376, 8.527148246765137, 11.277542114257812, 14.684998512268066, 18.69317054748535, 23.13019371032715, 27.72362518310547, 32.1606559753418, 36.168827056884766, 39.57627868652344, 42.32667541503906, 44.45526885986328, 46.04962921142578, 47.21482849121094, 48.05115509033203, 48.64370346069336, 49.05967712402344, 49.34980392456055, 49.551246643066406, 49.69068145751953, 49.78697967529297, 49.85338592529297],
28
+ "original_max_position_embeddings": 32768
29
+ },
30
+ "torch_dtype": "bfloat16",
31
+ "transformers_version": "4.46.3",
32
+ "use_cache": true,
33
+ "vocab_size": 73448,
34
+ "scale_emb": 12,
35
+ "dim_model_base": 256,
36
+ "scale_depth": 1.4
37
+ }
minicpm4_tokenizer/generation_config.json ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token_id": 1,
3
+ "do_sample": true,
4
+ "eos_token_id": [
5
+ 2,
6
+ 73440
7
+ ],
8
+ "pad_token_id": 2,
9
+ "temperature": 0.8,
10
+ "top_p": 0.8,
11
+ "transformers_version": "4.46.1"
12
+ }
minicpm4_tokenizer/special_tokens_map.json ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "additional_special_tokens": [
3
+ "<|im_end|>",
4
+ "<|im_start|>",
5
+ "<|tool_call|>",
6
+ "<|execute_start|>",
7
+ "<|execute_end|>",
8
+ "<|fim_prefix|>",
9
+ "<|fim_middle|>",
10
+ "<|fim_suffix|>"
11
+ ],
12
+ "bos_token": {
13
+ "content": "<s>",
14
+ "lstrip": false,
15
+ "normalized": false,
16
+ "rstrip": false,
17
+ "single_word": false
18
+ },
19
+ "eos_token": {
20
+ "content": "<|im_end|>",
21
+ "lstrip": false,
22
+ "normalized": false,
23
+ "rstrip": false,
24
+ "single_word": false
25
+ },
26
+ "unk_token": {
27
+ "content": "<unk>",
28
+ "lstrip": false,
29
+ "normalized": false,
30
+ "rstrip": false,
31
+ "single_word": false
32
+ }
33
+ }
minicpm4_tokenizer/tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
minicpm4_tokenizer/tokenizer.model ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:bb74d51116831c3bf65db812c553f94ab0c88dcf97a5bbb37e3504f6d359c530
3
+ size 1181204
minicpm4_tokenizer/tokenizer_config.json ADDED
@@ -0,0 +1,117 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_bos_token": true,
3
+ "add_eos_token": false,
4
+ "add_prefix_space": null,
5
+ "added_tokens_decoder": {
6
+ "0": {
7
+ "content": "<unk>",
8
+ "lstrip": false,
9
+ "normalized": false,
10
+ "rstrip": false,
11
+ "single_word": false,
12
+ "special": true
13
+ },
14
+ "1": {
15
+ "content": "<s>",
16
+ "lstrip": false,
17
+ "normalized": false,
18
+ "rstrip": false,
19
+ "single_word": false,
20
+ "special": true
21
+ },
22
+ "2": {
23
+ "content": "</s>",
24
+ "lstrip": false,
25
+ "normalized": false,
26
+ "rstrip": false,
27
+ "single_word": false,
28
+ "special": true
29
+ },
30
+ "73440": {
31
+ "content": "<|im_end|>",
32
+ "lstrip": false,
33
+ "normalized": false,
34
+ "rstrip": false,
35
+ "single_word": false,
36
+ "special": true
37
+ },
38
+ "73441": {
39
+ "content": "<|im_start|>",
40
+ "lstrip": false,
41
+ "normalized": false,
42
+ "rstrip": false,
43
+ "single_word": false,
44
+ "special": true
45
+ },
46
+ "73442": {
47
+ "content": "<|tool_call|>",
48
+ "lstrip": false,
49
+ "normalized": false,
50
+ "rstrip": false,
51
+ "single_word": false,
52
+ "special": true
53
+ },
54
+ "73443": {
55
+ "content": "<|execute_start|>",
56
+ "lstrip": false,
57
+ "normalized": false,
58
+ "rstrip": false,
59
+ "single_word": false,
60
+ "special": true
61
+ },
62
+ "73444": {
63
+ "content": "<|execute_end|>",
64
+ "lstrip": false,
65
+ "normalized": false,
66
+ "rstrip": false,
67
+ "single_word": false,
68
+ "special": true
69
+ },
70
+ "73445": {
71
+ "content": "<|fim_prefix|>",
72
+ "lstrip": false,
73
+ "normalized": false,
74
+ "rstrip": false,
75
+ "single_word": false,
76
+ "special": true
77
+ },
78
+ "73446": {
79
+ "content": "<|fim_middle|>",
80
+ "lstrip": false,
81
+ "normalized": false,
82
+ "rstrip": false,
83
+ "single_word": false,
84
+ "special": true
85
+ },
86
+ "73447": {
87
+ "content": "<|fim_suffix|>",
88
+ "lstrip": false,
89
+ "normalized": false,
90
+ "rstrip": false,
91
+ "single_word": false,
92
+ "special": true
93
+ }
94
+ },
95
+ "additional_special_tokens": [
96
+ "<|im_end|>",
97
+ "<|im_start|>",
98
+ "<|tool_call|>",
99
+ "<|execute_start|>",
100
+ "<|execute_end|>",
101
+ "<|fim_prefix|>",
102
+ "<|fim_middle|>",
103
+ "<|fim_suffix|>"
104
+ ],
105
+ "bos_token": "<s>",
106
+ "chat_template": "{% for message in messages %}{{'<|im_start|>' + message['role'] + '\n' + message['content'] + '<|im_end|>' + '\n'}}{% endfor %}{% if add_generation_prompt %}{{ '<|im_start|>assistant\n' }}{% endif %}",
107
+ "clean_up_tokenization_spaces": false,
108
+ "eos_token": "<|im_end|>",
109
+ "legacy": true,
110
+ "model_max_length": 1000000000000000019884624838656,
111
+ "pad_token": null,
112
+ "sp_model_kwargs": {},
113
+ "spaces_between_special_tokens": false,
114
+ "tokenizer_class": "LlamaTokenizer",
115
+ "unk_token": "<unk>",
116
+ "use_default_system_prompt": false
117
+ }
minicpm4_tokenizer_uid.py ADDED
@@ -0,0 +1,199 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import AutoTokenizer, PreTrainedTokenizerFast
2
+ from http.server import HTTPServer, BaseHTTPRequestHandler
3
+ import json
4
+ import argparse
5
+ import uuid
6
+
7
+ # 全局字典:存储 uid 到 Tokenizer_Http 实例的映射
8
+ tokenizers = {}
9
+
10
+ class Tokenizer_Http():
11
+ def __init__(self):
12
+ model_id = "minicpm4_tokenizer"
13
+ self.tokenizer = AutoTokenizer.from_pretrained(model_id)
14
+ self.messages = [
15
+ {"role": "system", "content": "You are MiniCPM4, created by ModelBest. You are a helpful assistant."},
16
+ ]
17
+ self.token_ids = []
18
+
19
+ self.token_ids_cache = []
20
+
21
+ def encode(self, prompt, last_reply=None):
22
+ if last_reply is not None:
23
+ self.messages.append({"role": "assistant", "content": last_reply})
24
+ text = self.tokenizer.apply_chat_template(
25
+ self.messages,
26
+ tokenize=False,
27
+ add_generation_prompt=True
28
+ )
29
+ # print("生成的文本:\n============\n", text, "============\n")
30
+ self.token_ids = self.tokenizer.encode(text)[:-3]
31
+ self.messages.append({"role": "user", "content": prompt})
32
+
33
+ text = self.tokenizer.apply_chat_template(
34
+ self.messages,
35
+ tokenize=False,
36
+ add_generation_prompt=True
37
+ )
38
+ print("生成的文本:\n============\n", text, "============\n")
39
+ token_ids = self.tokenizer.encode(text)
40
+ # 找出新增部分
41
+ diff = token_ids[len(self.token_ids):]
42
+ self.token_ids = token_ids
43
+ print(self.decode(diff))
44
+ return token_ids, diff
45
+
46
+ def decode(self, token_ids):
47
+ self.token_ids_cache += token_ids
48
+ text = self.tokenizer.decode(self.token_ids_cache)
49
+ if "\ufffd" in text:
50
+ print("text 中包含非法字符")
51
+ return ""
52
+ else:
53
+ self.token_ids_cache.clear()
54
+ return text
55
+
56
+
57
+ @property
58
+ def bos_id(self):
59
+ return self.tokenizer.bos_token_id
60
+
61
+ @property
62
+ def eos_id(self):
63
+ return self.tokenizer.eos_token_id
64
+
65
+ @property
66
+ def bos_token(self):
67
+ return self.tokenizer.bos_token
68
+
69
+ @property
70
+ def eos_token(self):
71
+ return self.tokenizer.eos_token
72
+
73
+ def reset(self, system_prompt="You are MiniCPM4, created by ModelBest. You are a helpful assistant."):
74
+ self.messages = [
75
+ {"role": "system", "content": system_prompt},
76
+ ]
77
+ text = self.tokenizer.apply_chat_template(
78
+ self.messages,
79
+ tokenize=False,
80
+ add_generation_prompt=True
81
+ )
82
+ token_ids = self.tokenizer.encode(text)[:-3]
83
+ self.token_ids = token_ids
84
+ print(self.decode(token_ids))
85
+ return token_ids
86
+
87
+
88
+ class Request(BaseHTTPRequestHandler):
89
+ timeout = 5
90
+ server_version = 'Apache'
91
+
92
+ def do_GET(self):
93
+ print("GET 请求路径:", self.path)
94
+ self.send_response(200)
95
+ self.send_header("Content-Type", "application/json")
96
+ self.end_headers()
97
+
98
+ # 新增接口:获取 uid
99
+ if '/get_uid' in self.path:
100
+ new_uid = str(uuid.uuid4())
101
+ print("新 uid:", new_uid)
102
+ # 为该 uid 创建一个新的 Tokenizer_Http 实例
103
+ tokenizers[new_uid] = Tokenizer_Http()
104
+ msg = json.dumps({'uid': new_uid})
105
+ elif '/bos_id' in self.path:
106
+ # 获取 uid 参数(例如 ?uid=xxx)
107
+ uid = self.get_query_param("uid")
108
+ instance: Tokenizer_Http = tokenizers.get(uid)
109
+ if instance is None:
110
+ msg = json.dumps({'error': 'Invalid uid'})
111
+ else:
112
+ bos_id = instance.bos_id
113
+ msg = json.dumps({'bos_id': bos_id if bos_id is not None else -1})
114
+ elif '/eos_id' in self.path:
115
+ uid = self.get_query_param("uid")
116
+ instance: Tokenizer_Http = tokenizers.get(uid)
117
+ if instance is None:
118
+ msg = json.dumps({'error': 'Invalid uid'})
119
+ else:
120
+ eos_id = instance.eos_id
121
+ msg = json.dumps({'eos_id': eos_id if eos_id is not None else -1})
122
+ else:
123
+ msg = json.dumps({'error': 'Invalid GET endpoint'})
124
+
125
+ print("响应消息:", msg)
126
+ self.wfile.write(msg.encode())
127
+
128
+ def do_POST(self):
129
+ content_length = int(self.headers.get('content-length', 0))
130
+ data = self.rfile.read(content_length).decode()
131
+ print("POST 请求路径:", self.path)
132
+ print("接收到的数据:", data)
133
+ req = json.loads(data)
134
+
135
+ self.send_response(200)
136
+ self.send_header("Content-Type", "application/json")
137
+ self.end_headers()
138
+
139
+ if '/encode' in self.path:
140
+ # 请求数据中必须包含 uid, text, 和可选的 last_reply
141
+ uid = req.get('uid')
142
+ prompt = req.get('text')
143
+ last_reply = req.get('last_reply')
144
+ instance: Tokenizer_Http = tokenizers.get(uid)
145
+ if instance is None:
146
+ msg = json.dumps({'error': 'Invalid uid'})
147
+ else:
148
+ token_ids, diff = instance.encode(prompt, last_reply)
149
+ msg = json.dumps({'token_ids': token_ids, 'diff': diff})
150
+ elif '/decode' in self.path:
151
+ uid = req.get('uid')
152
+ token_ids = req.get('token_ids')
153
+ instance: Tokenizer_Http = tokenizers.get(uid)
154
+ if instance is None:
155
+ msg = json.dumps({'error': 'Invalid uid'})
156
+ else:
157
+ text = instance.decode(token_ids)
158
+ msg = json.dumps({'text': text})
159
+ elif '/reset' in self.path:
160
+ uid = req.get("uid")
161
+ system_prompt = req.get("system_prompt")
162
+ instance: Tokenizer_Http = tokenizers.get(uid)
163
+ if instance is None:
164
+ msg = json.dumps({'error': 'Invalid uid'})
165
+ else:
166
+ if system_prompt is not None:
167
+ print("system_prompt:", system_prompt)
168
+ token_ids = instance.reset(system_prompt)
169
+ msg = json.dumps({'token_ids': token_ids})
170
+ else:
171
+ token_ids = instance.reset()
172
+ msg = json.dumps({'token_ids': token_ids})
173
+ else:
174
+ msg = json.dumps({'error': 'Invalid POST endpoint'})
175
+
176
+ print("响应消息:", msg)
177
+ self.wfile.write(msg.encode())
178
+
179
+ def get_query_param(self, key):
180
+ """
181
+ 辅助函数:从 GET 请求的 URL 中获取查询参数的值
182
+ 例如:/bos_id?uid=xxx
183
+ """
184
+ from urllib.parse import urlparse, parse_qs
185
+ query = urlparse(self.path).query
186
+ params = parse_qs(query)
187
+ values = params.get(key)
188
+ return values[0] if values else None
189
+
190
+ if __name__ == "__main__":
191
+ parser = argparse.ArgumentParser()
192
+ parser.add_argument('--host', type=str, default='0.0.0.0')
193
+ parser.add_argument('--port', type=int, default=12345)
194
+ args = parser.parse_args()
195
+
196
+ host = (args.host, args.port)
197
+ print('Server running at http://%s:%s' % host)
198
+ server = HTTPServer(host, Request)
199
+ server.serve_forever()
post_config.json ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "enable_temperature" : false,
3
+ "temperature" : 0.9,
4
+
5
+ "enable_repetition_penalty" : false,
6
+ "repetition_penalty" : 1.2,
7
+ "penalty_window" : 20,
8
+
9
+ "enable_top_p_sampling" : false,
10
+ "top_p" : 0.8,
11
+
12
+ "enable_top_k_sampling" : true,
13
+ "top_k" : 1
14
+ }
run_minicpm4_0.5b_int8_ctx_ax650.sh ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ./main_ax650 \
2
+ --system_prompt "You are MiniCPM4, created by ModelBest. You are a helpful assistant." \
3
+ --template_filename_axmodel "minicpm4-0.5b-int8-ctx-ax650/MiniCPMForCausalLM_p128_l%d_together.axmodel" \
4
+ --axmodel_num 24 \
5
+ --tokenizer_type 2 \
6
+ --url_tokenizer_model "http://127.0.0.1:12345" \
7
+ --filename_post_axmodel "minicpm4-0.5b-int8-ctx-ax650/MiniCPMForCausalLM_post.axmodel" \
8
+ --filename_tokens_embed "minicpm4-0.5b-int8-ctx-ax650/model.embed_tokens.weight.bfloat16.bin" \
9
+ --tokens_embed_num 73448 \
10
+ --tokens_embed_size 1024 \
11
+ --use_mmap_load_embed 0 \
12
+ --live_print 1
13
+
14
+ # --kvcache_path /home/axera/ax-llm/build/kvcache_yuanqi \