qqc1989 commited on
Commit
2cfeff1
·
verified ·
1 Parent(s): 9368e04

Upload 45 files

Browse files
Files changed (46) hide show
  1. .gitattributes +3 -0
  2. config.json +0 -0
  3. main_axcl_aarch64 +3 -0
  4. main_axcl_x86 +3 -0
  5. main_prefill +3 -0
  6. post_config.json +14 -0
  7. run_smollm2_360m_ax650.sh +14 -0
  8. run_smollm2_360m_axcl_aarch64.sh +14 -0
  9. run_smollm2_360m_axcl_x86.sh +14 -0
  10. smollm2-360m-ax650/llama_p128_l0_together.axmodel +3 -0
  11. smollm2-360m-ax650/llama_p128_l10_together.axmodel +3 -0
  12. smollm2-360m-ax650/llama_p128_l11_together.axmodel +3 -0
  13. smollm2-360m-ax650/llama_p128_l12_together.axmodel +3 -0
  14. smollm2-360m-ax650/llama_p128_l13_together.axmodel +3 -0
  15. smollm2-360m-ax650/llama_p128_l14_together.axmodel +3 -0
  16. smollm2-360m-ax650/llama_p128_l15_together.axmodel +3 -0
  17. smollm2-360m-ax650/llama_p128_l16_together.axmodel +3 -0
  18. smollm2-360m-ax650/llama_p128_l17_together.axmodel +3 -0
  19. smollm2-360m-ax650/llama_p128_l18_together.axmodel +3 -0
  20. smollm2-360m-ax650/llama_p128_l19_together.axmodel +3 -0
  21. smollm2-360m-ax650/llama_p128_l1_together.axmodel +3 -0
  22. smollm2-360m-ax650/llama_p128_l20_together.axmodel +3 -0
  23. smollm2-360m-ax650/llama_p128_l21_together.axmodel +3 -0
  24. smollm2-360m-ax650/llama_p128_l22_together.axmodel +3 -0
  25. smollm2-360m-ax650/llama_p128_l23_together.axmodel +3 -0
  26. smollm2-360m-ax650/llama_p128_l24_together.axmodel +3 -0
  27. smollm2-360m-ax650/llama_p128_l25_together.axmodel +3 -0
  28. smollm2-360m-ax650/llama_p128_l26_together.axmodel +3 -0
  29. smollm2-360m-ax650/llama_p128_l27_together.axmodel +3 -0
  30. smollm2-360m-ax650/llama_p128_l28_together.axmodel +3 -0
  31. smollm2-360m-ax650/llama_p128_l29_together.axmodel +3 -0
  32. smollm2-360m-ax650/llama_p128_l2_together.axmodel +3 -0
  33. smollm2-360m-ax650/llama_p128_l30_together.axmodel +3 -0
  34. smollm2-360m-ax650/llama_p128_l31_together.axmodel +3 -0
  35. smollm2-360m-ax650/llama_p128_l3_together.axmodel +3 -0
  36. smollm2-360m-ax650/llama_p128_l4_together.axmodel +3 -0
  37. smollm2-360m-ax650/llama_p128_l5_together.axmodel +3 -0
  38. smollm2-360m-ax650/llama_p128_l6_together.axmodel +3 -0
  39. smollm2-360m-ax650/llama_p128_l7_together.axmodel +3 -0
  40. smollm2-360m-ax650/llama_p128_l8_together.axmodel +3 -0
  41. smollm2-360m-ax650/llama_p128_l9_together.axmodel +3 -0
  42. smollm2-360m-ax650/llama_post.axmodel +3 -0
  43. smollm2-360m-ax650/model.embed_tokens.weight.bfloat16.bin +3 -0
  44. smollm2_tokenizer.py +133 -0
  45. smollm2_tokenizer/tokenizer.json +0 -0
  46. smollm2_tokenizer/tokenizer_config.json +154 -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_axcl_aarch64 filter=lfs diff=lfs merge=lfs -text
38
+ main_axcl_x86 filter=lfs diff=lfs merge=lfs -text
39
+ main_prefill filter=lfs diff=lfs merge=lfs -text
config.json ADDED
File without changes
main_axcl_aarch64 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:bb111fc00c54abb6142a8f44df087bf104c8150a1cefa6be55c6b174b932c4ec
3
+ size 999008
main_axcl_x86 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6cba0be8df523e351789fcfa745772423096f52a3b0a760f8d8c9f5b8bb2ec82
3
+ size 1022384
main_prefill ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:90026f1e071aef781ccc9bc313db3805749b3e234bf03d578c9f97ae2e60abd2
3
+ size 953544
post_config.json ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "enable_temperature" : true,
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" : 10
14
+ }
run_smollm2_360m_ax650.sh ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ./main_prefill \
2
+ --template_filename_axmodel "smollm2-360m-ax650/llama_p128_l%d_together.axmodel" \
3
+ --axmodel_num 32 \
4
+ --tokenizer_type 2 \
5
+ --filename_tokenizer_model "http://127.0.0.1:12345" \
6
+ --bos 0 --eos 0 \
7
+ --filename_post_axmodel "smollm2-360m-ax650/llama_post.axmodel" \
8
+ --filename_tokens_embed "smollm2-360m-ax650/model.embed_tokens.weight.bfloat16.bin" \
9
+ --tokens_embed_num 49152 \
10
+ --tokens_embed_size 960 \
11
+ --use_mmap_load_embed 1 \
12
+ --live_print 1 \
13
+ --continue 1 \
14
+ --prompt "$1"
run_smollm2_360m_axcl_aarch64.sh ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ./main_axcl_aarch64 \
2
+ --template_filename_axmodel "smollm2-360m-ax650/llama_p128_l%d_together.axmodel" \
3
+ --axmodel_num 32 \
4
+ --tokenizer_type 2 \
5
+ --filename_tokenizer_model "http://127.0.0.1:12345" \
6
+ --bos 0 --eos 0 \
7
+ --filename_post_axmodel "smollm2-360m-ax650/llama_post.axmodel" \
8
+ --filename_tokens_embed "smollm2-360m-ax650/model.embed_tokens.weight.bfloat16.bin" \
9
+ --tokens_embed_num 49152 \
10
+ --tokens_embed_size 960 \
11
+ --use_mmap_load_embed 0 \
12
+ --live_print 1 \
13
+ --continue 1 \
14
+ --prompt "$1"
run_smollm2_360m_axcl_x86.sh ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ./main_axcl_x86 \
2
+ --template_filename_axmodel "smollm2-360m-ax650/llama_p128_l%d_together.axmodel" \
3
+ --axmodel_num 32 \
4
+ --tokenizer_type 2 \
5
+ --filename_tokenizer_model "http://127.0.0.1:12345" \
6
+ --bos 0 --eos 0 \
7
+ --filename_post_axmodel "smollm2-360m-ax650/llama_post.axmodel" \
8
+ --filename_tokens_embed "smollm2-360m-ax650/model.embed_tokens.weight.bfloat16.bin" \
9
+ --tokens_embed_num 49152 \
10
+ --tokens_embed_size 960 \
11
+ --use_mmap_load_embed 0 \
12
+ --live_print 1 \
13
+ --continue 1 \
14
+ --prompt "$1"
smollm2-360m-ax650/llama_p128_l0_together.axmodel ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:489febc320a376e049b6fa6f059dcf423174513da6544b89b36e89cbf8900fd7
3
+ size 11218690
smollm2-360m-ax650/llama_p128_l10_together.axmodel ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:676db9c8def427b8d24e89154d7c54623ad96d550a74b93392af5b2351609dc2
3
+ size 11218690
smollm2-360m-ax650/llama_p128_l11_together.axmodel ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a572f7f626eb436047c9fdcc14e12f448faebaa7ac7ec54710e25f8283a2ae91
3
+ size 11218690
smollm2-360m-ax650/llama_p128_l12_together.axmodel ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:19aac1ab81b32be3d2b6c32bb30b59157d48e85ece6c2aac36099ea371082b35
3
+ size 11218690
smollm2-360m-ax650/llama_p128_l13_together.axmodel ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8d1ae96d861cafeed478b4953b0a17f018bf2d3d7b65704509ec4462f0d931ba
3
+ size 11218690
smollm2-360m-ax650/llama_p128_l14_together.axmodel ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:aaeefd23274a3aab6018781683b03c097fd07d565c779b9c01cf65e30d42801f
3
+ size 11218690
smollm2-360m-ax650/llama_p128_l15_together.axmodel ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:84bd88ec4ce38d35ca28996c1b178953b3ea2d97eb4a1a6941ed2a4a61b678fc
3
+ size 11218690
smollm2-360m-ax650/llama_p128_l16_together.axmodel ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cf68c070d51d404f1c1c861e8e5d9e7e7c3421ee59a7790f30050a056933c62e
3
+ size 11218690
smollm2-360m-ax650/llama_p128_l17_together.axmodel ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:90dabb01513932459c2c344f8aee8f8c53d6869b6a5ab91251ef18fd139a619c
3
+ size 11218690
smollm2-360m-ax650/llama_p128_l18_together.axmodel ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f5ed70f209cfb6859971bfc6acc289e6768fd160799a54a4a30e0bcf7860bb05
3
+ size 11218690
smollm2-360m-ax650/llama_p128_l19_together.axmodel ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:13d65f6805ed97aea4c813b7bcf90821ec0ad6ce7e0a1be0d385554cb8211c34
3
+ size 11218690
smollm2-360m-ax650/llama_p128_l1_together.axmodel ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:995f165341d9808fa11f754236041555edf933571aec9d9938bf480ac8f05328
3
+ size 11218690
smollm2-360m-ax650/llama_p128_l20_together.axmodel ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7da1158e22b5ca6a3332949d1c456a62574cd0ce274b0c247b685856f3329f31
3
+ size 11218690
smollm2-360m-ax650/llama_p128_l21_together.axmodel ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3f2ae999d342e4a76292a0117f9604187c8985cd07cb2ef11e4f57c7381bcc0a
3
+ size 11218690
smollm2-360m-ax650/llama_p128_l22_together.axmodel ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d1b428789458de91e3fb4cd95d6e58c400e06795dbcc3cffea1e78c0d58d902a
3
+ size 11218690
smollm2-360m-ax650/llama_p128_l23_together.axmodel ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ad53076c95797aebf892595a2b7d88fb3e712e27efdfd92a54561c750a88124d
3
+ size 11218690
smollm2-360m-ax650/llama_p128_l24_together.axmodel ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0bcf51f105a596b88a8d06f8095cad551b337a4384afb645fb554d0e346a7382
3
+ size 11218690
smollm2-360m-ax650/llama_p128_l25_together.axmodel ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:002e44afa0542f838bf9fde6d217ac92c6855c5bfc9c8802e8e80c5fb0509687
3
+ size 11218690
smollm2-360m-ax650/llama_p128_l26_together.axmodel ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7aa19ca187a16f2f08afc80ff9f755e78cf18868f45b699c065c2bb1fb194290
3
+ size 11218690
smollm2-360m-ax650/llama_p128_l27_together.axmodel ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:da4bf6b5fdc6abd69f7cc6bd259df7685972de282f07e66def6236a209623820
3
+ size 11218690
smollm2-360m-ax650/llama_p128_l28_together.axmodel ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:416d24cf85eb4eab1cb5bc19cea300318b4a0d34b63ccf591f5264ef827e9bfa
3
+ size 11218690
smollm2-360m-ax650/llama_p128_l29_together.axmodel ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:579e1b979e97247aed78dabe564d50b5bdbc81c0edada4046c81c43cd76b645e
3
+ size 11218690
smollm2-360m-ax650/llama_p128_l2_together.axmodel ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fabbd458282bb1dc52006a1c96c68fcdcb7c8b686a557a1da08dc15fc29e4b80
3
+ size 11218690
smollm2-360m-ax650/llama_p128_l30_together.axmodel ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f7bd3399a0a851f05116de727c0a28838dace9f8096876fe782cf8383fe314a5
3
+ size 11218690
smollm2-360m-ax650/llama_p128_l31_together.axmodel ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f5078029f054ba1c4a2ecf0dd0919865084017b39d8c790049227bdffb1d048c
3
+ size 11218690
smollm2-360m-ax650/llama_p128_l3_together.axmodel ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0983d31036313e367a7cf91bb771bee3cb1854e07baf4068bff123ffd296c98e
3
+ size 11218690
smollm2-360m-ax650/llama_p128_l4_together.axmodel ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:14b9402ae0d8f05d08b525fc571f641f219138e92f2ce9b82ac89cb6ffc15910
3
+ size 11218690
smollm2-360m-ax650/llama_p128_l5_together.axmodel ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4d2143709587c18dce172eb8297fa7ff57bdf397a1a0c4f3e9fd56d63720dc2a
3
+ size 11218690
smollm2-360m-ax650/llama_p128_l6_together.axmodel ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ff12125e92ed34c5bfe5efd7232229d69b23956248236e34d3357c711a78736a
3
+ size 11218690
smollm2-360m-ax650/llama_p128_l7_together.axmodel ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5eb6216f8f4531364348e7e85403e305103eef19ac7ba18b33b7fff0afdc2d9e
3
+ size 11218690
smollm2-360m-ax650/llama_p128_l8_together.axmodel ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:af8cebf4cf6698ebfdb07663a18cc9bc046ae52944f51902315a3a7df72c318c
3
+ size 11218690
smollm2-360m-ax650/llama_p128_l9_together.axmodel ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:33b7bbe08d59ee7d2c187edf8c85cee8aee464fe11fb1c5608a44369fb83907c
3
+ size 11218690
smollm2-360m-ax650/llama_post.axmodel ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f891122c5016004037af8b7dd70edd218729548301e432425d0e9c2305610adb
3
+ size 51443158
smollm2-360m-ax650/model.embed_tokens.weight.bfloat16.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:bc8a09d622a836b0b05ee1d8144054f8ac8b2d7e239e6957aae3b52134c12cb3
3
+ size 94371840
smollm2_tokenizer.py ADDED
@@ -0,0 +1,133 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import AutoTokenizer, PreTrainedTokenizerFast
2
+ from http.server import HTTPServer, BaseHTTPRequestHandler
3
+ import json
4
+ import argparse
5
+
6
+
7
+ class Tokenizer_Http():
8
+
9
+ def __init__(self):
10
+ model_id = "smollm2_tokenizer"
11
+ self.tokenizer = AutoTokenizer.from_pretrained(model_id)
12
+
13
+ def encode(self, prompt):
14
+ messages = [
15
+ #{"role": "system", "content": "You are Qwen, created by Alibaba Cloud. You are a helpful assistant."},
16
+ {"role": "user", "content": prompt}
17
+ ]
18
+ text = self.tokenizer.apply_chat_template(
19
+ messages,
20
+ tokenize=False,
21
+ add_generation_prompt=True
22
+ )
23
+ print(text)
24
+ token_ids = self.tokenizer.encode(text)
25
+ return token_ids
26
+
27
+ def decode(self, token_ids):
28
+ return self.tokenizer.decode(token_ids)
29
+
30
+ @property
31
+ def bos_id(self):
32
+ return self.tokenizer.bos_token_id
33
+
34
+ @property
35
+ def eos_id(self):
36
+ return self.tokenizer.eos_token_id
37
+
38
+ @property
39
+ def bos_token(self):
40
+ return self.tokenizer.bos_token
41
+
42
+ @property
43
+ def eos_token(self):
44
+ return self.tokenizer.eos_token
45
+
46
+
47
+ tokenizer = Tokenizer_Http()
48
+
49
+ print(tokenizer.bos_id, tokenizer.bos_token, tokenizer.eos_id, tokenizer.eos_token)
50
+ print(tokenizer.encode("hello world"))
51
+
52
+
53
+ class Request(BaseHTTPRequestHandler):
54
+ #通过类继承,新定义类
55
+ timeout = 5
56
+ server_version = 'Apache'
57
+
58
+ def do_GET(self):
59
+ print(self.path)
60
+ #在新类中定义get的内容(当客户端向该服务端使用get请求时,本服务端将如下运行)
61
+ self.send_response(200)
62
+ self.send_header("type", "get") #设置响应头,可省略或设置多个
63
+ self.end_headers()
64
+
65
+ if self.path == '/bos_id':
66
+ bos_id = tokenizer.bos_id
67
+ # print(bos_id)
68
+ # to json
69
+ if bos_id is None:
70
+ msg = json.dumps({'bos_id': -1})
71
+ else:
72
+ msg = json.dumps({'bos_id': bos_id})
73
+ elif self.path == '/eos_id':
74
+ eos_id = tokenizer.eos_id
75
+ if eos_id is None:
76
+ msg = json.dumps({'eos_id': -1})
77
+ else:
78
+ msg = json.dumps({'eos_id': eos_id})
79
+ else:
80
+ msg = 'error'
81
+
82
+ print(msg)
83
+ msg = str(msg).encode() #转为str再转为byte格式
84
+
85
+ self.wfile.write(msg) #将byte格式的信息返回给客户端
86
+
87
+ def do_POST(self):
88
+ #在新类中定义post的内容(当客户端向该服务端使用post请求时,本服务端将如下运行)
89
+ data = self.rfile.read(int(
90
+ self.headers['content-length'])) #获取从客户端传入的参数(byte格式)
91
+ data = data.decode() #将byte格式转为str格式
92
+
93
+ self.send_response(200)
94
+ self.send_header("type", "post") #设置响应头,可省略或设置多个
95
+ self.end_headers()
96
+
97
+ if self.path == '/encode':
98
+ req = json.loads(data)
99
+ prompt = req['text']
100
+
101
+ token_ids = tokenizer.encode(prompt)
102
+ if token_ids is None:
103
+ msg = json.dumps({'token_ids': -1})
104
+ else:
105
+ msg = json.dumps({'token_ids': token_ids})
106
+
107
+ elif self.path == '/decode':
108
+ req = json.loads(data)
109
+ token_ids = req['token_ids']
110
+ text = tokenizer.decode(token_ids)
111
+ if text is None:
112
+ msg = json.dumps({'text': ""})
113
+ else:
114
+ msg = json.dumps({'text': text})
115
+ else:
116
+ msg = 'error'
117
+ print(msg)
118
+ msg = str(msg).encode() #转为str再转为byte格式
119
+
120
+ self.wfile.write(msg) #将byte格式的信息返回给客户端
121
+
122
+
123
+ if __name__ == "__main__":
124
+
125
+ args = argparse.ArgumentParser()
126
+ args.add_argument('--host', type=str, default='localhost')
127
+ args.add_argument('--port', type=int, default=8080)
128
+ args = args.parse_args()
129
+
130
+ host = (args.host, args.port) #设定地址与端口号,'localhost'等价于'127.0.0.1'
131
+ print('http://%s:%s' % host)
132
+ server = HTTPServer(host, Request) #根据地址端口号和新定义的类,创建服务器实例
133
+ server.serve_forever() #开启服务
smollm2_tokenizer/tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
smollm2_tokenizer/tokenizer_config.json ADDED
@@ -0,0 +1,154 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_prefix_space": false,
3
+ "added_tokens_decoder": {
4
+ "0": {
5
+ "content": "<|endoftext|>",
6
+ "lstrip": false,
7
+ "normalized": false,
8
+ "rstrip": false,
9
+ "single_word": false,
10
+ "special": true
11
+ },
12
+ "1": {
13
+ "content": "<|im_start|>",
14
+ "lstrip": false,
15
+ "normalized": false,
16
+ "rstrip": false,
17
+ "single_word": false,
18
+ "special": true
19
+ },
20
+ "2": {
21
+ "content": "<|im_end|>",
22
+ "lstrip": false,
23
+ "normalized": false,
24
+ "rstrip": false,
25
+ "single_word": false,
26
+ "special": true
27
+ },
28
+ "3": {
29
+ "content": "<repo_name>",
30
+ "lstrip": false,
31
+ "normalized": false,
32
+ "rstrip": false,
33
+ "single_word": false,
34
+ "special": true
35
+ },
36
+ "4": {
37
+ "content": "<reponame>",
38
+ "lstrip": false,
39
+ "normalized": false,
40
+ "rstrip": false,
41
+ "single_word": false,
42
+ "special": true
43
+ },
44
+ "5": {
45
+ "content": "<file_sep>",
46
+ "lstrip": false,
47
+ "normalized": false,
48
+ "rstrip": false,
49
+ "single_word": false,
50
+ "special": true
51
+ },
52
+ "6": {
53
+ "content": "<filename>",
54
+ "lstrip": false,
55
+ "normalized": false,
56
+ "rstrip": false,
57
+ "single_word": false,
58
+ "special": true
59
+ },
60
+ "7": {
61
+ "content": "<gh_stars>",
62
+ "lstrip": false,
63
+ "normalized": false,
64
+ "rstrip": false,
65
+ "single_word": false,
66
+ "special": true
67
+ },
68
+ "8": {
69
+ "content": "<issue_start>",
70
+ "lstrip": false,
71
+ "normalized": false,
72
+ "rstrip": false,
73
+ "single_word": false,
74
+ "special": true
75
+ },
76
+ "9": {
77
+ "content": "<issue_comment>",
78
+ "lstrip": false,
79
+ "normalized": false,
80
+ "rstrip": false,
81
+ "single_word": false,
82
+ "special": true
83
+ },
84
+ "10": {
85
+ "content": "<issue_closed>",
86
+ "lstrip": false,
87
+ "normalized": false,
88
+ "rstrip": false,
89
+ "single_word": false,
90
+ "special": true
91
+ },
92
+ "11": {
93
+ "content": "<jupyter_start>",
94
+ "lstrip": false,
95
+ "normalized": false,
96
+ "rstrip": false,
97
+ "single_word": false,
98
+ "special": true
99
+ },
100
+ "12": {
101
+ "content": "<jupyter_text>",
102
+ "lstrip": false,
103
+ "normalized": false,
104
+ "rstrip": false,
105
+ "single_word": false,
106
+ "special": true
107
+ },
108
+ "13": {
109
+ "content": "<jupyter_code>",
110
+ "lstrip": false,
111
+ "normalized": false,
112
+ "rstrip": false,
113
+ "single_word": false,
114
+ "special": true
115
+ },
116
+ "14": {
117
+ "content": "<jupyter_output>",
118
+ "lstrip": false,
119
+ "normalized": false,
120
+ "rstrip": false,
121
+ "single_word": false,
122
+ "special": true
123
+ },
124
+ "15": {
125
+ "content": "<jupyter_script>",
126
+ "lstrip": false,
127
+ "normalized": false,
128
+ "rstrip": false,
129
+ "single_word": false,
130
+ "special": true
131
+ },
132
+ "16": {
133
+ "content": "<empty_output>",
134
+ "lstrip": false,
135
+ "normalized": false,
136
+ "rstrip": false,
137
+ "single_word": false,
138
+ "special": true
139
+ }
140
+ },
141
+ "additional_special_tokens": [
142
+ "<|im_start|>",
143
+ "<|im_end|>"
144
+ ],
145
+ "bos_token": "<|im_start|>",
146
+ "chat_template": "{% for message in messages %}{% if loop.first and messages[0]['role'] != 'system' %}{{ '<|im_start|>system\nYou are a helpful AI assistant named SmolLM, trained by Hugging Face<|im_end|>\n' }}{% endif %}{{'<|im_start|>' + message['role'] + '\n' + message['content'] + '<|im_end|>' + '\n'}}{% endfor %}{% if add_generation_prompt %}{{ '<|im_start|>assistant\n' }}{% endif %}",
147
+ "clean_up_tokenization_spaces": false,
148
+ "eos_token": "<|im_end|>",
149
+ "model_max_length": 8192,
150
+ "pad_token": "<|im_end|>",
151
+ "tokenizer_class": "GPT2Tokenizer",
152
+ "unk_token": "<|endoftext|>",
153
+ "vocab_size": 49152
154
+ }