Update README.md
Browse files
README.md
CHANGED
@@ -1,185 +1,190 @@
|
|
1 |
-
---
|
2 |
-
language: th
|
3 |
-
license: apache-2.0
|
4 |
-
tags:
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
model_type: unigram
|
10 |
-
library_name: tokenizers
|
11 |
-
pretty_name: Advanced Thai Tokenizer V3
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
-
|
23 |
-
|
24 |
-
|
25 |
-
- **
|
26 |
-
- **
|
27 |
-
|
28 |
-
|
29 |
-
-
|
30 |
-
-
|
31 |
-
-
|
32 |
-
|
33 |
-
|
34 |
-
- ✅
|
35 |
-
- ✅
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
- `
|
62 |
-
- `
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
###
|
84 |
-
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
###
|
89 |
-
-
|
90 |
-
-
|
91 |
-
-
|
92 |
-
|
93 |
-
###
|
94 |
-
-
|
95 |
-
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
-
|
100 |
-
- Not
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
-
|
107 |
-
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
### Training
|
137 |
-
- **
|
138 |
-
- **
|
139 |
-
- **
|
140 |
-
|
141 |
-
|
142 |
-
- **
|
143 |
-
|
144 |
-
|
145 |
-
- **
|
146 |
-
- **
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
- **
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
-
|
158 |
-
-
|
159 |
-
|
160 |
-
##
|
161 |
-
|
162 |
-
-
|
163 |
-
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
|
|
|
|
|
|
|
|
|
|
185 |
For questions or feedback, open an issue on the HuggingFace repo or contact ZombitX64 via HuggingFace.
|
|
|
1 |
+
---
|
2 |
+
language: th
|
3 |
+
license: apache-2.0
|
4 |
+
tags:
|
5 |
+
- thai
|
6 |
+
- tokenizer
|
7 |
+
- nlp
|
8 |
+
- subword
|
9 |
+
model_type: unigram
|
10 |
+
library_name: tokenizers
|
11 |
+
pretty_name: Advanced Thai Tokenizer V3
|
12 |
+
datasets:
|
13 |
+
- ZombitX64/Thai-corpus-word
|
14 |
+
metrics:
|
15 |
+
- accuracy
|
16 |
+
- character
|
17 |
+
---
|
18 |
+
|
19 |
+
# Advanced Thai Tokenizer V3
|
20 |
+
|
21 |
+
## Overview
|
22 |
+
Advanced Thai language tokenizer (Unigram, HuggingFace-compatible) trained on a large, cleaned, real-world Thai corpus. Handles Thai, mixed Thai-English, numbers, and modern vocabulary. Designed for LLM/NLP use, with robust roundtrip accuracy and no byte-level artifacts.
|
23 |
+
|
24 |
+
## Performance
|
25 |
+
- **Overall Accuracy:** 24/24 (100.0%)
|
26 |
+
- **Vocabulary Size:** 35,590 tokens
|
27 |
+
- **Average Compression:** 3.45 chars/token
|
28 |
+
- **UNK Ratio:** 0%
|
29 |
+
- **Thai Character Coverage:** 100%
|
30 |
+
- **Tested on:** Real-world, mixed, and edge-case sentences
|
31 |
+
- **Training Corpus:** `combined_thai_corpus.txt` (cleaned, deduplicated, multi-domain)
|
32 |
+
|
33 |
+
## Key Features
|
34 |
+
- ✅ No Thai character corruption (no byte-level fallback, no normalization loss)
|
35 |
+
- ✅ Handles mixed Thai-English, numbers, and symbols
|
36 |
+
- ✅ Modern vocabulary (internet, technology, social, business)
|
37 |
+
- ✅ Efficient compression (subword, not word-level)
|
38 |
+
- ✅ Clean decoding without artifacts
|
39 |
+
- ✅ HuggingFace-compatible (tokenizer.json, vocab.json, config)
|
40 |
+
- ✅ Production-ready: tested, documented, and robust
|
41 |
+
|
42 |
+
## Quick Start
|
43 |
+
```python
|
44 |
+
from transformers import AutoTokenizer
|
45 |
+
|
46 |
+
# Load tokenizer from HuggingFace Hub
|
47 |
+
try:
|
48 |
+
tokenizer = AutoTokenizer.from_pretrained("ZombitX64/Thaitokenizer")
|
49 |
+
text = "นั่งตาก ลม"
|
50 |
+
tokens = tokenizer.tokenize(text)
|
51 |
+
print(f"Tokens: {tokens}")
|
52 |
+
encoding = tokenizer(text, return_tensors=None, add_special_tokens=False)
|
53 |
+
decoded = tokenizer.decode(encoding['input_ids'], skip_special_tokens=True)
|
54 |
+
print(f"Original: {text}")
|
55 |
+
print(f"Decoded: {decoded}")
|
56 |
+
except Exception as e:
|
57 |
+
print(f"Error loading tokenizer: {e}")
|
58 |
+
```
|
59 |
+
|
60 |
+
## Files
|
61 |
+
- `tokenizer.json` — Main tokenizer file (HuggingFace format)
|
62 |
+
- `vocab.json` — Vocabulary mapping
|
63 |
+
- `tokenizer_config.json` — Transformers config
|
64 |
+
- `metadata.json` — Performance and configuration details
|
65 |
+
- `usage_examples.json` — Code examples
|
66 |
+
- `README.md` — This file
|
67 |
+
- `combined_thai_corpus.txt` — Training corpus (not included in repo, see dataset card)
|
68 |
+
|
69 |
+
Created: July 2025
|
70 |
+
|
71 |
+
---
|
72 |
+
|
73 |
+
# Model Card for Advanced Thai Tokenizer V3
|
74 |
+
|
75 |
+
## Model Details
|
76 |
+
|
77 |
+
**Developed by:** ZombitX64 (https://huggingface.co/ZombitX64)
|
78 |
+
**Model type:** Unigram (subword) tokenizer
|
79 |
+
**Language(s):** th (Thai), mixed Thai-English
|
80 |
+
**License:** Apache-2.0
|
81 |
+
**Finetuned from model:** N/A (trained from scratch)
|
82 |
+
|
83 |
+
### Model Sources
|
84 |
+
- **Repository:** https://huggingface.co/ZombitX64/Thaitokenizer
|
85 |
+
|
86 |
+
## Uses
|
87 |
+
|
88 |
+
### Direct Use
|
89 |
+
- Tokenization for Thai LLMs, NLP, and downstream tasks
|
90 |
+
- Preprocessing for text classification, NER, QA, summarization, etc.
|
91 |
+
- Robust for mixed Thai-English, numbers, and social content
|
92 |
+
|
93 |
+
### Downstream Use
|
94 |
+
- Plug into HuggingFace Transformers pipelines
|
95 |
+
- Use as tokenizer for Thai LLM pretraining/fine-tuning
|
96 |
+
- Integrate with spaCy, PyThaiNLP, or custom pipelines
|
97 |
+
|
98 |
+
### Out-of-Scope Use
|
99 |
+
- Not a language model (no text generation by itself)
|
100 |
+
- Not suitable for non-Thai-centric tasks
|
101 |
+
|
102 |
+
## Bias, Risks, and Limitations
|
103 |
+
|
104 |
+
- Trained on public Thai web/corpus data; may reflect real-world bias
|
105 |
+
- Not guaranteed to cover rare dialects, slang, or OCR errors
|
106 |
+
- No explicit filtering for toxic/biased content in corpus
|
107 |
+
- Tokenizer does not understand context/meaning (no disambiguation)
|
108 |
+
|
109 |
+
### Recommendations
|
110 |
+
|
111 |
+
- For best results, use with LLMs or models trained on similar corpus
|
112 |
+
- For sensitive/critical applications, review corpus and test thoroughly
|
113 |
+
- For word-level tasks, use with context-aware models (NER, POS)
|
114 |
+
|
115 |
+
## How to Get Started with the Model
|
116 |
+
|
117 |
+
```python
|
118 |
+
from transformers import AutoTokenizer
|
119 |
+
|
120 |
+
# Load tokenizer from HuggingFace Hub
|
121 |
+
try:
|
122 |
+
tokenizer = AutoTokenizer.from_pretrained("ZombitX64/Thaitokenizer")
|
123 |
+
text = "นั่งตาก ลม"
|
124 |
+
tokens = tokenizer.tokenize(text)
|
125 |
+
print(f"Tokens: {tokens}")
|
126 |
+
encoding = tokenizer(text, return_tensors=None, add_special_tokens=False)
|
127 |
+
decoded = tokenizer.decode(encoding['input_ids'], skip_special_tokens=True)
|
128 |
+
print(f"Original: {text}")
|
129 |
+
print(f"Decoded: {decoded}")
|
130 |
+
except Exception as e:
|
131 |
+
print(f"Error loading tokenizer: {e}")
|
132 |
+
```
|
133 |
+
|
134 |
+
## Training Details
|
135 |
+
|
136 |
+
### Training Data
|
137 |
+
- **Source:** `combined_thai_corpus.txt` (cleaned, deduplicated, multi-domain Thai text)
|
138 |
+
- **Size:** 71.7M
|
139 |
+
- **Preprocessing:** Remove duplicates, normalize encoding, minimal cleaning, no normalization, no byte fallback
|
140 |
+
|
141 |
+
### Training Procedure
|
142 |
+
- **Tokenizer:** HuggingFace Tokenizers (Unigram)
|
143 |
+
- **Vocab size:** 35,590
|
144 |
+
- **Special tokens:** <unk>
|
145 |
+
- **Pre-tokenizer:** Punctuation only
|
146 |
+
- **No normalization, no post-processor, no decoder**
|
147 |
+
- **Training regime:** CPU, Python 3.11, single run, see script for details
|
148 |
+
|
149 |
+
### Speeds, Sizes, Times
|
150 |
+
- **Training time:** -
|
151 |
+
- **Checkpoint size:** tokenizer.json ~[size] KB
|
152 |
+
|
153 |
+
## Evaluation
|
154 |
+
|
155 |
+
### Testing Data, Factors & Metrics
|
156 |
+
- **Testing data:** Real-world Thai sentences, mixed content, edge cases
|
157 |
+
- **Metrics:** Roundtrip accuracy, UNK ratio, Thai character coverage, compression ratio
|
158 |
+
- **Results:** 100% roundtrip, 0% UNK, 100% Thai char coverage, 3.45 chars/token
|
159 |
+
|
160 |
+
## Environmental Impact
|
161 |
+
|
162 |
+
- Training on CPU, low energy usage
|
163 |
+
- No large-scale GPU/TPU compute required
|
164 |
+
|
165 |
+
## Technical Specifications
|
166 |
+
|
167 |
+
- **Model architecture:** Unigram (subword) tokenizer
|
168 |
+
- **Software:** tokenizers==0.15+, Python 3.11
|
169 |
+
- **Hardware:** Standard CPU (no GPU required)
|
170 |
+
|
171 |
+
## Citation
|
172 |
+
|
173 |
+
If you use this tokenizer, please cite:
|
174 |
+
|
175 |
+
```
|
176 |
+
@misc{zombitx64_thaitokenizer_v3_2025,
|
177 |
+
author = {ZombitX64},
|
178 |
+
title = {Advanced Thai Tokenizer V3},
|
179 |
+
year = {2025},
|
180 |
+
howpublished = {\\url{https://huggingface.co/ZombitX64/Thaitokenizer}}
|
181 |
+
}
|
182 |
+
```
|
183 |
+
|
184 |
+
## Model Card Authors
|
185 |
+
|
186 |
+
- ZombitX64 (https://huggingface.co/ZombitX64)
|
187 |
+
|
188 |
+
## Model Card Contact
|
189 |
+
|
190 |
For questions or feedback, open an issue on the HuggingFace repo or contact ZombitX64 via HuggingFace.
|