bisonnetworking Claude Sonnet 4.5 commited on
Commit
eaba2fa
·
1 Parent(s): 6b84460

Fix tokenizer configuration for proper MLX compatibility

Browse files

- Add all special tokens to additional_special_tokens and added_tokens_decoder
- Add special tokens: <|system|>, <|user|>, <|assistant|>, <|end|>
- Embed chat_template directly in tokenizer_config.json
- Fix tokenizer_class from LlamaTokenizer to PreTrainedTokenizerFast
- Add proper token ID mappings for Phi-3 format
- Ensure compatibility with and without system prompts

This update ensures proper tokenization for MLX inference with the
Phi-3 chat format, supporting flexible usage with or without system
prompts in multi-turn conversations.

Tested with mlx-lm and verified correct token encoding.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

Files changed (1) hide show
  1. tokenizer_config.json +61 -5
tokenizer_config.json CHANGED
@@ -1,16 +1,72 @@
1
  {
2
  "add_prefix_space": null,
3
- "additional_special_tokens": null,
4
- "backend": "tokenizers",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
  "bos_token": "<s>",
 
6
  "clean_up_tokenization_spaces": false,
7
  "eos_token": "<|endoftext|>",
8
- "is_local": true,
9
  "model_max_length": 131072,
10
  "pad_token": "<|endoftext|>",
11
  "padding_side": "left",
12
- "sp_model_kwargs": {},
13
- "tokenizer_class": "LlamaTokenizer",
14
  "unk_token": "<unk>",
15
  "use_default_system_prompt": false
16
  }
 
1
  {
2
  "add_prefix_space": null,
3
+ "added_tokens_decoder": {
4
+ "0": {
5
+ "content": "<unk>",
6
+ "lstrip": false,
7
+ "normalized": false,
8
+ "rstrip": false,
9
+ "single_word": false,
10
+ "special": true
11
+ },
12
+ "1": {
13
+ "content": "<s>",
14
+ "lstrip": false,
15
+ "normalized": false,
16
+ "rstrip": false,
17
+ "single_word": false,
18
+ "special": true
19
+ },
20
+ "32000": {
21
+ "content": "<|endoftext|>",
22
+ "lstrip": false,
23
+ "normalized": false,
24
+ "rstrip": false,
25
+ "single_word": false,
26
+ "special": true
27
+ },
28
+ "32001": {
29
+ "content": "<|assistant|>",
30
+ "lstrip": false,
31
+ "normalized": false,
32
+ "rstrip": false,
33
+ "single_word": false,
34
+ "special": true
35
+ },
36
+ "32006": {
37
+ "content": "<|system|>",
38
+ "lstrip": false,
39
+ "normalized": false,
40
+ "rstrip": false,
41
+ "single_word": false,
42
+ "special": true
43
+ },
44
+ "32007": {
45
+ "content": "<|end|>",
46
+ "lstrip": false,
47
+ "normalized": false,
48
+ "rstrip": false,
49
+ "single_word": false,
50
+ "special": true
51
+ },
52
+ "32010": {
53
+ "content": "<|user|>",
54
+ "lstrip": false,
55
+ "normalized": false,
56
+ "rstrip": false,
57
+ "single_word": false,
58
+ "special": true
59
+ }
60
+ },
61
+ "additional_special_tokens": ["<|system|>", "<|user|>", "<|assistant|>", "<|end|>"],
62
  "bos_token": "<s>",
63
+ "chat_template": "{% for message in messages %}{% if message['role'] == 'system' and message['content'] %}{{'<|system|>\n' + message['content'] + '<|end|>\n'}}{% elif message['role'] == 'user' %}{{'<|user|>\n' + message['content'] + '<|end|>\n'}}{% elif message['role'] == 'assistant' %}{{'<|assistant|>\n' + message['content'] + '<|end|>\n'}}{% endif %}{% endfor %}{% if add_generation_prompt %}{{ '<|assistant|>\n' }}{% else %}{{ eos_token }}{% endif %}",
64
  "clean_up_tokenization_spaces": false,
65
  "eos_token": "<|endoftext|>",
 
66
  "model_max_length": 131072,
67
  "pad_token": "<|endoftext|>",
68
  "padding_side": "left",
69
+ "tokenizer_class": "PreTrainedTokenizerFast",
 
70
  "unk_token": "<unk>",
71
  "use_default_system_prompt": false
72
  }