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- README.md +43 -14
- tokenizer.json +2 -2
- tokenizer_config.json +1 -3
README.md
CHANGED
|
@@ -6,28 +6,57 @@ tags:
|
|
| 6 |
- pinyin
|
| 7 |
- ime
|
| 8 |
- tokenizer
|
| 9 |
-
base_model:
|
| 10 |
---
|
| 11 |
|
| 12 |
# Chiboard 1.1 tokenizer (prompt contract v3)
|
| 13 |
|
| 14 |
-
|
| 15 |
-
prompt contract `qwen35-chiboard-field-tokens-v3`. Every existing token, merge, normalizer and
|
| 16 |
-
pre-tokenizer rule is unchanged.
|
| 17 |
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
|
| 23 |
-
|
|
|
|
|
|
|
|
|
|
| 24 |
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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:
|
| 3 |
-
size
|
|
|
|
| 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": "
|
| 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|>",
|