johnbean393 commited on
Commit
dc692bd
·
verified ·
1 Parent(s): 177cdc8

Use the Qwen3.5 base pre-tokenizer and decoder (regex [\p{L}\p{M}]+); tokenizer_class TokenizersBackend so transformers loads tokenizer.json verbatim; supersedes 177cdc85 (T1's Qwen2 pre-tokenizer)

Browse files
Files changed (3) hide show
  1. README.md +43 -14
  2. tokenizer.json +2 -2
  3. tokenizer_config.json +1 -3
README.md CHANGED
@@ -6,28 +6,57 @@ tags:
6
  - pinyin
7
  - ime
8
  - tokenizer
9
- base_model: johnbean393/chiboard-1-qwen3.5-0.8b-t1
10
  ---
11
 
12
  # Chiboard 1.1 tokenizer (prompt contract v3)
13
 
14
- The Chiboard 1 (T1) tokenizer plus exactly two special tokens for the two screen slots of
15
- prompt contract `qwen35-chiboard-field-tokens-v3`. Every existing token, merge, normalizer and
16
- pre-tokenizer rule is unchanged.
17
 
18
- | Token | ID |
19
- |---|---|
20
- | `<|chiboard_screen_ref|>` | 248081 |
21
- | `<|chiboard_screen|>` | 248082 |
22
 
23
- Tokenizer length 248083; the model's embedding matrix keeps 248320 rows.
 
 
 
24
 
25
- - Derived from `johnbean393/chiboard-1-qwen3.5-0.8b-t1` @ `36a048c87989697f0b0110ee59d36c6b41339453`
26
- (T1 `tokenizer.json` sha256 `ddc3e761a8d49ae66a0f608ff69fc21e68d754c8ec8a980142eb11d230fc1230`).
27
- - `tokenizer.json` sha256 `2e62a5711d7d301ee5e6c0ac8d7816bc7298b79b18b608e6197f101a6a64a1eb`.
28
- - `tokenizer_config.json` differs from T1 only by the two entries appended to `extra_special_tokens`.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
  - `chat_template.jinja` is byte-identical to T1's. Contract v3 uses no chat template.
30
- - The tokenizer files derive from `Qwen/Qwen3.5-0.8B-Base`'s tokenizer.
31
 
32
  ## Serialization
33
 
 
6
  - pinyin
7
  - ime
8
  - tokenizer
9
+ base_model: Qwen/Qwen3.5-0.8B-Base
10
  ---
11
 
12
  # Chiboard 1.1 tokenizer (prompt contract v3)
13
 
14
+ This is the tokenizer for prompt contract `qwen35-chiboard-field-tokens-v3`.
 
 
15
 
16
+ - **Pre-tokenization and decoding are the Qwen3.5 base tokenizer's.**
17
+ - The normalizer, pre-tokenizer (regex `[\p{L}\p{M}]+`), post-processor, decoder and BPE vocabulary/merges are copied verbatim from `Qwen/Qwen3.5-0.8B-Base@dc7cdfe2ee4154fa7e30f5b51ca41bfa40174e68`. That `tokenizer.json` has sha256 `fe000e3ed39ed12b8d2481d527d44f93c65d37e87645d2dcc80d1bf9d50d2927`.
18
+ - The merges keep the same string storage format.
19
+ - **Added tokens** are Chiboard 1 (T1)'s 37 added tokens (ids 248044–248080, including the four Chiboard field tokens) plus two new screen-slot tokens:
20
 
21
+ | Token | ID |
22
+ |---|---|
23
+ | `<|chiboard_screen_ref|>` | 248081 |
24
+ | `<|chiboard_screen|>` | 248082 |
25
 
26
+ The ids shared with the base tokenizer are identical. Tokenizer length is 248083; the model keeps 248320 embedding rows. No existing token id changed.
27
+
28
+ ## Why not T1's pre-tokenizer
29
+
30
+ T1's `tokenizer.json` matches what transformers 5's `Qwen2Tokenizer` class rebuilds: the Qwen2 regex (`\p{L}+`, which leaves combining marks out of words) and its default ByteLevel decoder. T1 was therefore trained with Qwen2 pre-tokenization. Its GGUF, however, runs llama.cpp's `qwen35` pre-tokenizer.
31
+
32
+ Chiboard 1.1 trains and runs with the same Qwen3.5 pre-tokenization. On a 200K-document train sample, the two pre-tokenizers give different token ids for 0.0075% of documents. All of them contain combining marks (emoji U+FE0F, Indic/Thai signs, decomposed diacritics).
33
+
34
+ The first v3 build (`@177cdc85`, `tokenizer.json` sha256 `2e62a571…`) inherited T1's pre-tokenizer and is superseded.
35
+
36
+ ## Loading
37
+
38
+ `tokenizer_config.json` sets `tokenizer_class: TokenizersBackend`. With it, transformers 5.x loads `tokenizer.json` verbatim, so `AutoTokenizer.from_pretrained` produces exactly the same encodings as `tokenizers.Tokenizer.from_file("tokenizer.json")`.
39
+
40
+ Do not load this tokenizer as `Qwen2Tokenizer` or `Qwen3_5Tokenizer`: those classes rebuild the pre-tokenizer and decoder from class constants.
41
+
42
+ Guard (trainer, evaluator, pipeline):
43
+
44
+ ```python
45
+ import json
46
+ from tokenizers import Tokenizer
47
+ from transformers import AutoTokenizer
48
+ tok = AutoTokenizer.from_pretrained(path)
49
+ want = json.loads(Tokenizer.from_file(f"{path}/tokenizer.json").to_str())
50
+ got = json.loads(tok.backend_tokenizer.to_str())
51
+ assert all(got[k] == want[k] for k in ("normalizer", "pre_tokenizer", "post_processor", "decoder"))
52
+ ```
53
+
54
+ With this config, llama.cpp `convert_hf_to_gguf.py` computes chkhsh `d30d75d9059f1aa2c19359de71047b3ae408c70875e8a3ccf8c5fba56c9d8af4`, which maps to `qwen35`.
55
+
56
+ Other files:
57
+
58
+ - `tokenizer_config.json` is T1's, with three changes: `tokenizer_class` is `TokenizersBackend`, the two new tokens are appended to `extra_special_tokens`, and two save-time keys are removed.
59
  - `chat_template.jinja` is byte-identical to T1's. Contract v3 uses no chat template.
 
60
 
61
  ## Serialization
62
 
tokenizer.json CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:2e62a5711d7d301ee5e6c0ac8d7816bc7298b79b18b608e6197f101a6a64a1eb
3
- size 19990507
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5b9d57867977c857094bcd169e11505a4997c55d32ac0aec87dbdb58cf151b21
3
+ size 12810474
tokenizer_config.json CHANGED
@@ -17,8 +17,6 @@
17
  "<|chiboard_screen|>"
18
  ],
19
  "image_token": "<|image_pad|>",
20
- "is_local": false,
21
- "local_files_only": true,
22
  "model_max_length": 262144,
23
  "model_specific_special_tokens": {
24
  "audio_bos_token": "<|audio_start|>",
@@ -32,7 +30,7 @@
32
  "pad_token": "<|endoftext|>",
33
  "pretokenize_regex": "(?i:'s|'t|'re|'ve|'m|'ll|'d)|[^\\r\\n\\p{L}\\p{N}]?[\\p{L}\\p{M}]+|\\p{N}| ?[^\\s\\p{L}\\p{M}\\p{N}]+[\\r\\n]*|\\s*[\\r\\n]+|\\s+(?!\\S)|\\s+",
34
  "split_special_tokens": false,
35
- "tokenizer_class": "Qwen2Tokenizer",
36
  "unk_token": null,
37
  "video_token": "<|video_pad|>",
38
  "vision_bos_token": "<|vision_start|>",
 
17
  "<|chiboard_screen|>"
18
  ],
19
  "image_token": "<|image_pad|>",
 
 
20
  "model_max_length": 262144,
21
  "model_specific_special_tokens": {
22
  "audio_bos_token": "<|audio_start|>",
 
30
  "pad_token": "<|endoftext|>",
31
  "pretokenize_regex": "(?i:'s|'t|'re|'ve|'m|'ll|'d)|[^\\r\\n\\p{L}\\p{N}]?[\\p{L}\\p{M}]+|\\p{N}| ?[^\\s\\p{L}\\p{M}\\p{N}]+[\\r\\n]*|\\s*[\\r\\n]+|\\s+(?!\\S)|\\s+",
32
  "split_special_tokens": false,
33
+ "tokenizer_class": "TokenizersBackend",
34
  "unk_token": null,
35
  "video_token": "<|video_pad|>",
36
  "vision_bos_token": "<|vision_start|>",