48k IT/EN/code BPE (40/40/20), frontier-aligned special tokens
Browse files- README.md +60 -0
- summary.json +34 -0
- tokenizer/token_bytes.pt +3 -0
- tokenizer/tokenizer.pkl +3 -0
README.md
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: mit
|
| 3 |
+
language:
|
| 4 |
+
- it
|
| 5 |
+
- en
|
| 6 |
+
library_name: tiktoken
|
| 7 |
+
tags:
|
| 8 |
+
- tokenizer
|
| 9 |
+
- bpe
|
| 10 |
+
- italian
|
| 11 |
+
- english
|
| 12 |
+
- code
|
| 13 |
+
- fineweb-2
|
| 14 |
+
- fineweb-edu
|
| 15 |
+
---
|
| 16 |
+
|
| 17 |
+
# ita-en-code-bpe-48k
|
| 18 |
+
|
| 19 |
+
A byte-level **BPE tokenizer**, vocab **49152 (48k)**, trained with
|
| 20 |
+
[`rustbpe`](https://github.com/karpathy/rustbpe) on a **40% Italian / 40% English
|
| 21 |
+
/ 20% code** mix (~4B chars), so it is efficient across all three:
|
| 22 |
+
|
| 23 |
+
- **Italian** β [FineWeb-2](https://huggingface.co/datasets/HuggingFaceFW/fineweb-2) `ita_Latn` (filtered)
|
| 24 |
+
- **English** β [FineWeb-Edu](https://huggingface.co/datasets/HuggingFaceFW/fineweb-edu) `sample/100BT` (`int_score β₯ 3`)
|
| 25 |
+
- **code** β [github-code-clean](https://huggingface.co/datasets/codeparrot/github-code-clean)
|
| 26 |
+
|
| 27 |
+
Inference uses [`tiktoken`](https://github.com/openai/tiktoken) β `tokenizer.pkl`
|
| 28 |
+
is a pickled `tiktoken.Encoding`. GPT-4 split pattern (cl100k). Italian stays
|
| 29 |
+
efficient (IT/EN share Latin script β shared merges) while English and code are
|
| 30 |
+
first-class.
|
| 31 |
+
|
| 32 |
+
## Special tokens (aligned with DeepSeek-V4 / GLM-5.2)
|
| 33 |
+
|
| 34 |
+
33 special tokens, ids **49119β49151**. Pretraining packs each doc `<|bos|> β¦ <|eos|>`.
|
| 35 |
+
|
| 36 |
+
| group | tokens |
|
| 37 |
+
|---|---|
|
| 38 |
+
| core | `<\|bos\|>` (49119), `<\|eos\|>` (49120), `<\|pad\|>` (49121) |
|
| 39 |
+
| chat | `<\|system\|>`, `<\|user\|>`, `<\|assistant\|>`, `<\|observation\|>` |
|
| 40 |
+
| turn | `<\|eot\|>` |
|
| 41 |
+
| reasoning | `<think>`, `</think>` |
|
| 42 |
+
| tools | `<tool_call>`, `</tool_call>`, `<tool_response>`, `</tool_response>` |
|
| 43 |
+
| code FIM | `<\|fim_begin\|>`, `<\|fim_hole\|>`, `<\|fim_end\|>` |
|
| 44 |
+
| reserved | `<\|reserved_0\|>` β¦ `<\|reserved_15\|>` |
|
| 45 |
+
|
| 46 |
+
## Files
|
| 47 |
+
- `tokenizer.pkl` β pickled `tiktoken.Encoding`.
|
| 48 |
+
- `token_bytes.pt` β per-id UTF-8 byte length (0 for specials), for bits-per-byte eval.
|
| 49 |
+
- `summary.json` β training config + stats.
|
| 50 |
+
|
| 51 |
+
## Usage
|
| 52 |
+
```python
|
| 53 |
+
import pickle
|
| 54 |
+
from huggingface_hub import hf_hub_download
|
| 55 |
+
enc = pickle.load(open(hf_hub_download("procmarco/ita-en-code-bpe-48k", "tokenizer.pkl"), "rb"))
|
| 56 |
+
ids = enc.encode_ordinary("def somma(a, b):\n return a + b # Ciao")
|
| 57 |
+
print(len(ids), enc.decode(ids))
|
| 58 |
+
```
|
| 59 |
+
`pip install tiktoken` runs it; training used `rustbpe`. Companion token dataset:
|
| 60 |
+
[procmarco/ita-en-code-tokens-48k](https://huggingface.co/datasets/procmarco/ita-en-code-tokens-48k).
|
summary.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"vocab_size": 49152,
|
| 3 |
+
"num_special_tokens": 33,
|
| 4 |
+
"ratios": {
|
| 5 |
+
"ita": 0.4,
|
| 6 |
+
"en": 0.4,
|
| 7 |
+
"code": 0.2
|
| 8 |
+
},
|
| 9 |
+
"char_budget": 4000000000,
|
| 10 |
+
"special_token_ids": {
|
| 11 |
+
"bos": 49119,
|
| 12 |
+
"eos": 49120,
|
| 13 |
+
"pad": 49121
|
| 14 |
+
},
|
| 15 |
+
"pad_distinct_from_eos": true,
|
| 16 |
+
"train_time_sec": 126.83898162841797,
|
| 17 |
+
"sanity": [
|
| 18 |
+
{
|
| 19 |
+
"text": "Ciao mondo, l'Italia \u00e8 bellissima.",
|
| 20 |
+
"num_tokens": 8,
|
| 21 |
+
"roundtrip_ok": true
|
| 22 |
+
},
|
| 23 |
+
{
|
| 24 |
+
"text": "The quick brown fox jumps over the lazy dog.",
|
| 25 |
+
"num_tokens": 11,
|
| 26 |
+
"roundtrip_ok": true
|
| 27 |
+
},
|
| 28 |
+
{
|
| 29 |
+
"text": "def add(a, b):\n return a + b # sum",
|
| 30 |
+
"num_tokens": 14,
|
| 31 |
+
"roundtrip_ok": true
|
| 32 |
+
}
|
| 33 |
+
]
|
| 34 |
+
}
|
tokenizer/token_bytes.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:fecb6042d2eefc25c6dadcd30e4287f2d4c0466a9c45759a5487231a86634bd6
|
| 3 |
+
size 198213
|
tokenizer/tokenizer.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e48d6a95c6e4e2b98eba5121dc0a8da77d3515613bcc0847fb742b86f995fdb9
|
| 3 |
+
size 612162
|