Nexuss0781 commited on
Commit
d681ea8
·
verified ·
1 Parent(s): dfca702

feat: Initial release of EthioBBPE - Ethiopian Language Tokenizer

Browse files
LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+
3
+ Copyright (c) 2026 ታዲዮስ || Tadiyos Aschalew
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
README.md CHANGED
@@ -1,3 +1,119 @@
1
- ---
2
- license: mit
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 🇪🇹 EthioBBPE: Byte-Level BPE Tokenizer for Ethiopian Languages
2
+
3
+ A robust, production-ready Byte-Level BPE (BBPE) tokenizer training framework specifically optimized for Ethiopian languages (Amharic, Oromo, Tigrinya, Somali, etc.) using Hugging Face's `tokenizers` library.
4
+
5
+ ## ✨ Features
6
+
7
+ - **Optimized for Ethiopic Script**: Handles complex Ge'ez script characters and Latin-based orthographies seamlessly.
8
+ - **Byte-Level Encoding**: Robust against unknown characters and emojis, ensuring no `<UNK>` tokens.
9
+ - **End-to-End Pipeline**: From raw text corpus to a ready-to-use `tokenizer.json`.
10
+ - **Hugging Face Compatible**: Directly usable with `transformers` models.
11
+ - **Flexible Configuration**: Customize vocabulary size, minimum frequency, and special tokens.
12
+ - **Multi-Format Support**: Train on `.txt`, `.json`, or `.jsonl` datasets.
13
+
14
+ ## 📦 Installation
15
+
16
+ ```bash
17
+ pip install -r requirements.txt
18
+ ```
19
+
20
+ ## 🚀 Quick Start
21
+
22
+ ### 1. Prepare Your Data
23
+ Place your training corpus (raw text files) in the `data/` directory.
24
+ ```text
25
+ data/
26
+ ├── amharic_corpus.txt
27
+ ├── oromo_corpus.txt
28
+ └── mixed_ethio_text.txt
29
+ ```
30
+
31
+ ### 2. Train the Tokenizer
32
+
33
+ **Using CLI:**
34
+ ```bash
35
+ python scripts/train_tokenizer.py \
36
+ --data_dir ./data \
37
+ --model_name EthioBBPE \
38
+ --vocab_size 32000 \
39
+ --min_frequency 2 \
40
+ --special_tokens "[PAD]","[UNK]","[CLS]","[SEP]","[MASK]"
41
+ ```
42
+
43
+ **Using Python API:**
44
+ ```python
45
+ from scripts.bbpe_trainer import BBPETrainer, BBPEConfig
46
+
47
+ # Configure for Ethiopian Languages
48
+ config = BBPEConfig(
49
+ vocab_size=32000,
50
+ min_frequency=2,
51
+ show_progress=True,
52
+ special_tokens=["[PAD]", "[UNK]", "[CLS]", "[SEP]", "[MASK]"]
53
+ )
54
+
55
+ trainer = BBPETrainer(config=config, model_name="EthioBBPE")
56
+ trainer.train_from_directory("./data")
57
+ trainer.save("./models/EthioBBPE")
58
+
59
+ # Test it
60
+ text = "ሰላም ልጄ እንዴት ነሽ? (Hello daughter, how are you?)"
61
+ tokens = trainer.tokenize(text)
62
+ print(f"Tokens: {tokens}")
63
+ ```
64
+
65
+ ### 3. Load and Use
66
+
67
+ ```python
68
+ from tokenizers import Tokenizer
69
+
70
+ # Load the trained tokenizer
71
+ tokenizer = Tokenizer.from_file("models/EthioBBPE/tokenizer.json")
72
+
73
+ # Encode
74
+ encoded = tokenizer.encode("የኢትዮጵያ ህዝብ")
75
+ print(encoded.ids)
76
+ print(encoded.tokens)
77
+
78
+ # Decode
79
+ decoded = tokenizer.decode(encoded.ids)
80
+ print(decoded)
81
+ ```
82
+
83
+ ## 🏗️ Architecture
84
+
85
+ The `EthioBBPE` architecture follows these steps:
86
+ 1. **Pre-tokenization**: Splits text into words while preserving byte-level integrity.
87
+ 2. **Byte Conversion**: Converts all characters (including Ge'ez script) into their byte representations.
88
+ 3. **BPE Training**: Learns merge operations based on frequency in the corpus.
89
+ 4. **Vocabulary Creation**: Generates a fixed-size vocabulary of byte-level tokens.
90
+
91
+ ## 📂 Project Structure
92
+
93
+ ```text
94
+ Ethio_BBPE/
95
+ ├── data/ # Raw training data
96
+ ├── models/ # Output directory for trained models
97
+ ├── scripts/
98
+ │ ├── bbpe_trainer.py # Core logic (BBPEConfig, BBPETrainer)
99
+ │ ├── train_tokenizer.py # CLI entry point
100
+ │ └── example_usage.py # Usage examples
101
+ ├── requirements.txt # Dependencies
102
+ └── README.md # This file
103
+ ```
104
+
105
+ ## 🤗 Hugging Face Hub
106
+
107
+ This model is designed to be pushed to the Hugging Face Hub:
108
+
109
+ ```python
110
+ trainer.push_to_hub("Nexuss0781/Ethio-BBPE", token="YOUR_HF_TOKEN")
111
+ ```
112
+
113
+ ## 📄 License
114
+
115
+ MIT License
116
+
117
+ ## 🙏 Acknowledgments
118
+
119
+ Built for the Ethiopian NLP community to foster better language understanding and generation capabilities.
data/sample_corpus.txt ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ This is a sample training corpus for the BBPE tokenizer.
2
+
3
+ The quick brown fox jumps over the lazy dog. This sentence contains every letter of the alphabet.
4
+
5
+ Natural Language Processing (NLP) is a field of artificial intelligence that focuses on the interaction between computers and humans through language. The ultimate objective of NLP is to read, decipher, understand, and make sense of human languages in a manner that is valuable.
6
+
7
+ Machine learning is a subset of artificial intelligence that provides systems the ability to learn and improve from experience without being explicitly programmed. Machine learning focuses on the development of computer programs that can access data and use it to learn for themselves.
8
+
9
+ Deep learning is part of a broader family of machine learning methods based on artificial neural networks with representation learning. Learning can be supervised, semi-supervised or unsupervised.
10
+
11
+ Tokenization is the process of splitting text into smaller units called tokens. These tokens can be words, characters, or subwords. Byte-level BPE (Byte Pair Encoding) is a popular tokenization algorithm used in modern language models.
12
+
13
+ The transformer architecture has revolutionized natural language processing. It uses self-attention mechanisms to process input sequences in parallel, making it much faster than recurrent neural networks.
14
+
15
+ BERT, GPT, and T5 are some of the most famous transformer-based models. They have achieved state-of-the-art results on various NLP tasks including question answering, text classification, and machine translation.
16
+
17
+ Training a tokenizer requires a representative corpus of text. The quality and diversity of your training data directly impacts the performance of your tokenizer.
18
+
19
+ Special tokens like [PAD], [UNK], [CLS], and [SEP] are often added to vocabularies for specific tasks. These tokens help models handle padding, unknown words, and sequence boundaries.
20
+
21
+ The vocabulary size is an important hyperparameter. Too small and you'll have many unknown tokens. Too large and your model becomes inefficient. Typical sizes range from 20,000 to 100,000 tokens.
22
+
23
+ Byte-level encoding ensures that any Unicode text can be tokenized without errors. This is particularly important for multilingual applications.
24
+
25
+ Minimum frequency threshold helps filter out rare tokens that might be noise. A typical value is 2 or 3, meaning a token must appear at least that many times to be included in the vocabulary.
26
+
27
+ Prefix space is often added before tokenization to distinguish between words at the beginning of sentences and words in other positions.
28
+
29
+ This sample text provides enough content to demonstrate the BBPE tokenizer training process. In practice, you would use much larger corpora containing millions or billions of tokens.
30
+
31
+ Remember to always validate your tokenizer on held-out data to ensure it generalizes well to unseen text.
32
+
33
+ Happy tokenizing!
models/demo_tokenizer/config.json ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "vocab_size": 30000,
3
+ "min_frequency": 2,
4
+ "special_tokens": [
5
+ "<pad>",
6
+ "<unk>",
7
+ "<s>",
8
+ "</s>",
9
+ "<mask>"
10
+ ],
11
+ "lowercase": false,
12
+ "add_prefix_space": false,
13
+ "trim_offsets": true,
14
+ "show_progress": true,
15
+ "initial_alphabet": [],
16
+ "data_dir": "data",
17
+ "model_save_dir": "models",
18
+ "model_name": "demo_tokenizer"
19
+ }
models/demo_tokenizer/merges.txt ADDED
@@ -0,0 +1,329 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #version: 0.2
2
+ Ġ t
3
+ i n
4
+ e n
5
+ Ġ a
6
+ e r
7
+ e s
8
+ Ġ o
9
+ Ġt o
10
+ a n
11
+ in g
12
+ a r
13
+ a t
14
+ h e
15
+ i s
16
+ o r
17
+ Ġ m
18
+ Ġ s
19
+ a l
20
+ k en
21
+ o n
22
+ Ġto ken
23
+ l e
24
+ Ġo f
25
+ Ġ b
26
+ Ġ p
27
+ i t
28
+ o u
29
+ Ġ c
30
+ Ġ f
31
+ Ġa n
32
+ i c
33
+ i z
34
+ i on
35
+ r o
36
+ e d
37
+ e l
38
+ r e
39
+ Ġ in
40
+ Ġt he
41
+ Ġ is
42
+ Ġan d
43
+ Ġ T
44
+ Ġ u
45
+ Ġb e
46
+ Ġ d
47
+ Ġt h
48
+ a c
49
+ m p
50
+ o d
51
+ Ġ w
52
+ Ġ le
53
+ en c
54
+ en t
55
+ Ġtoken iz
56
+ a s
57
+ e x
58
+ t er
59
+ Ġ l
60
+ ar n
61
+ Ġtoken s
62
+ Ġp ro
63
+ q u
64
+ u l
65
+ Ġ h
66
+ Ġ v
67
+ at ion
68
+ Ġth at
69
+ Ġle arn
70
+ a in
71
+ c es
72
+ e c
73
+ f ic
74
+ g e
75
+ i l
76
+ r es
77
+ u a
78
+ y ou
79
+ Ġ n
80
+ Ġ re
81
+ Ġ you
82
+ Ġt r
83
+ Ġt ex
84
+ Ġu n
85
+ ces s
86
+ Ġtex t
87
+ 0 0
88
+ a m
89
+ d s
90
+ e m
91
+ e t
92
+ g ua
93
+ i fic
94
+ o c
95
+ p er
96
+ s t
97
+ u r
98
+ v e
99
+ Ġo n
100
+ an gua
101
+ or ds
102
+ Ġm od
103
+ enc e
104
+ Ġtokeniz er
105
+ ul ar
106
+ Ġlearn ing
107
+ ain ing
108
+ a b
109
+ c h
110
+ f or
111
+ h in
112
+ h is
113
+ i al
114
+ i mp
115
+ k s
116
+ s e
117
+ s u
118
+ u s
119
+ Ġ B
120
+ Ġ [
121
+ Ġ imp
122
+ Ġa r
123
+ Ġo r
124
+ an s
125
+ at e
126
+ it h
127
+ Ġc an
128
+ Ġf or
129
+ ac hin
130
+ Ġw ords
131
+ Ġl angua
132
+ Ġpro cess
133
+ Ġyou r
134
+ ur al
135
+ Ġmod el
136
+ achin e
137
+ L P
138
+ N LP
139
+ P E
140
+ T he
141
+ ] ,
142
+ a d
143
+ d ed
144
+ e v
145
+ g h
146
+ i d
147
+ i m
148
+ l d
149
+ l p
150
+ l u
151
+ l y
152
+ p l
153
+ t e
154
+ t ion
155
+ t ific
156
+ u m
157
+ v is
158
+ w n
159
+ y te
160
+ Ġ en
161
+ Ġ he
162
+ Ġ it
163
+ Ġ qu
164
+ ar t
165
+ at a
166
+ or p
167
+ Ġm u
168
+ Ġm an
169
+ Ġs u
170
+ on t
171
+ it y
172
+ ou t
173
+ Ġc orp
174
+ Ġc ont
175
+ ion s
176
+ el l
177
+ Ġin t
178
+ ĠT he
179
+ Ġd ata
180
+ Ġw ith
181
+ Ġv al
182
+ Ġv oc
183
+ Ġtr aining
184
+ Ġtr ans
185
+ per vis
186
+ ab ular
187
+ for m
188
+ Ġar tific
189
+ Ġlangua ge
190
+ Ġmodel s
191
+ Ġvoc abular
192
+ pervis ed
193
+ Ġartific ial
194
+ B PE
195
+ B yte
196
+ M achine
197
+ T his
198
+ a k
199
+ a mp
200
+ a ve
201
+ c lu
202
+ d ing
203
+ d ded
204
+ e en
205
+ e qu
206
+ e ural
207
+ g r
208
+ g ence
209
+ h er
210
+ h es
211
+ i es
212
+ i ve
213
+ i gence
214
+ k n
215
+ l ions
216
+ m s
217
+ m al
218
+ o m
219
+ o o
220
+ o p
221
+ o mp
222
+ o wn
223
+ p p
224
+ p ic
225
+ p ec
226
+ p res
227
+ t s
228
+ t w
229
+ t en
230
+ t an
231
+ t ing
232
+ u t
233
+ u ter
234
+ v er
235
+ v el
236
+ v id
237
+ w or
238
+ y pic
239
+ Ġ (
240
+ Ġ 2
241
+ Ġ I
242
+ Ġ L
243
+ Ġ P
244
+ Ġ r
245
+ Ġ ex
246
+ Ġ NLP
247
+ Ġt as
248
+ Ġa l
249
+ Ġa t
250
+ Ġa re
251
+ Ġa dded
252
+ an d
253
+ at ural
254
+ or tan
255
+ Ġm achine
256
+ Ġm ak
257
+ Ġs iz
258
+ Ġs ent
259
+ Ġs amp
260
+ Ġs equ
261
+ Ġs mal
262
+ al le
263
+ le vel
264
+ Ġof ten
265
+ Ġb ro
266
+ Ġp art
267
+ ou s
268
+ ou gh
269
+ Ġc omp
270
+ Ġf ro
271
+ Ġf am
272
+ Ġf oc
273
+ Ġin clu
274
+ ĠT his
275
+ ĠT hes
276
+ ĠT oo
277
+ Ġu s
278
+ Ġu se
279
+ Ġbe tw
280
+ Ġd i
281
+ od ing
282
+ enc es
283
+ Ġtokeniz ation
284
+ as ed
285
+ Ġl ar
286
+ Ġpro gr
287
+ Ġpro vid
288
+ Ġh um
289
+ Ġh ave
290
+ ec t
291
+ il lions
292
+ Ġn et
293
+ Ġn eural
294
+ Ġre pres
295
+ Ġun kn
296
+ 00 0
297
+ su pervised
298
+ us es
299
+ ĠB BPE
300
+ Ġimp ortan
301
+ pl ic
302
+ Ġen su
303
+ Ġhe lp
304
+ Ġmu ch
305
+ Ġman y
306
+ Ġsu b
307
+ Ġcorp us
308
+ ell igence
309
+ Ġint elligence
310
+ Ġwith out
311
+ Ġtrans form
312
+ Ġvocabular y
313
+ wor ks
314
+ ypic al
315
+ Ġtas ks
316
+ Ġsamp le
317
+ Ġsmal l
318
+ Ġcomp uter
319
+ Ġfro m
320
+ Ġfoc uses
321
+ ĠThes e
322
+ Ġbetw een
323
+ Ġprogr am
324
+ Ġprovid es
325
+ Ġnet works
326
+ Ġrepres ent
327
+ Ġunkn own
328
+ Ġimportan t
329
+ Ġtransform er
models/demo_tokenizer/tokenizer.json ADDED
@@ -0,0 +1,1986 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "version": "1.0",
3
+ "truncation": null,
4
+ "padding": null,
5
+ "added_tokens": [
6
+ {
7
+ "id": 0,
8
+ "content": "<pad>",
9
+ "single_word": false,
10
+ "lstrip": false,
11
+ "rstrip": false,
12
+ "normalized": false,
13
+ "special": true
14
+ },
15
+ {
16
+ "id": 1,
17
+ "content": "<unk>",
18
+ "single_word": false,
19
+ "lstrip": false,
20
+ "rstrip": false,
21
+ "normalized": false,
22
+ "special": true
23
+ },
24
+ {
25
+ "id": 2,
26
+ "content": "<s>",
27
+ "single_word": false,
28
+ "lstrip": false,
29
+ "rstrip": false,
30
+ "normalized": false,
31
+ "special": true
32
+ },
33
+ {
34
+ "id": 3,
35
+ "content": "</s>",
36
+ "single_word": false,
37
+ "lstrip": false,
38
+ "rstrip": false,
39
+ "normalized": false,
40
+ "special": true
41
+ },
42
+ {
43
+ "id": 4,
44
+ "content": "<mask>",
45
+ "single_word": false,
46
+ "lstrip": false,
47
+ "rstrip": false,
48
+ "normalized": false,
49
+ "special": true
50
+ }
51
+ ],
52
+ "normalizer": null,
53
+ "pre_tokenizer": {
54
+ "type": "ByteLevel",
55
+ "add_prefix_space": false,
56
+ "trim_offsets": true,
57
+ "use_regex": true
58
+ },
59
+ "post_processor": {
60
+ "type": "ByteLevel",
61
+ "add_prefix_space": true,
62
+ "trim_offsets": true,
63
+ "use_regex": true
64
+ },
65
+ "decoder": {
66
+ "type": "ByteLevel",
67
+ "add_prefix_space": true,
68
+ "trim_offsets": true,
69
+ "use_regex": true
70
+ },
71
+ "model": {
72
+ "type": "BPE",
73
+ "dropout": null,
74
+ "unk_token": null,
75
+ "continuing_subword_prefix": null,
76
+ "end_of_word_suffix": null,
77
+ "fuse_unk": false,
78
+ "byte_fallback": false,
79
+ "ignore_merges": false,
80
+ "vocab": {
81
+ "<pad>": 0,
82
+ "<unk>": 1,
83
+ "<s>": 2,
84
+ "</s>": 3,
85
+ "<mask>": 4,
86
+ "!": 5,
87
+ "\"": 6,
88
+ "#": 7,
89
+ "$": 8,
90
+ "%": 9,
91
+ "&": 10,
92
+ "'": 11,
93
+ "(": 12,
94
+ ")": 13,
95
+ "*": 14,
96
+ "+": 15,
97
+ ",": 16,
98
+ "-": 17,
99
+ ".": 18,
100
+ "/": 19,
101
+ "0": 20,
102
+ "1": 21,
103
+ "2": 22,
104
+ "3": 23,
105
+ "4": 24,
106
+ "5": 25,
107
+ "6": 26,
108
+ "7": 27,
109
+ "8": 28,
110
+ "9": 29,
111
+ ":": 30,
112
+ ";": 31,
113
+ "<": 32,
114
+ "=": 33,
115
+ ">": 34,
116
+ "?": 35,
117
+ "@": 36,
118
+ "A": 37,
119
+ "B": 38,
120
+ "C": 39,
121
+ "D": 40,
122
+ "E": 41,
123
+ "F": 42,
124
+ "G": 43,
125
+ "H": 44,
126
+ "I": 45,
127
+ "J": 46,
128
+ "K": 47,
129
+ "L": 48,
130
+ "M": 49,
131
+ "N": 50,
132
+ "O": 51,
133
+ "P": 52,
134
+ "Q": 53,
135
+ "R": 54,
136
+ "S": 55,
137
+ "T": 56,
138
+ "U": 57,
139
+ "V": 58,
140
+ "W": 59,
141
+ "X": 60,
142
+ "Y": 61,
143
+ "Z": 62,
144
+ "[": 63,
145
+ "\\": 64,
146
+ "]": 65,
147
+ "^": 66,
148
+ "_": 67,
149
+ "`": 68,
150
+ "a": 69,
151
+ "b": 70,
152
+ "c": 71,
153
+ "d": 72,
154
+ "e": 73,
155
+ "f": 74,
156
+ "g": 75,
157
+ "h": 76,
158
+ "i": 77,
159
+ "j": 78,
160
+ "k": 79,
161
+ "l": 80,
162
+ "m": 81,
163
+ "n": 82,
164
+ "o": 83,
165
+ "p": 84,
166
+ "q": 85,
167
+ "r": 86,
168
+ "s": 87,
169
+ "t": 88,
170
+ "u": 89,
171
+ "v": 90,
172
+ "w": 91,
173
+ "x": 92,
174
+ "y": 93,
175
+ "z": 94,
176
+ "{": 95,
177
+ "|": 96,
178
+ "}": 97,
179
+ "~": 98,
180
+ "¡": 99,
181
+ "¢": 100,
182
+ "£": 101,
183
+ "¤": 102,
184
+ "¥": 103,
185
+ "¦": 104,
186
+ "§": 105,
187
+ "¨": 106,
188
+ "©": 107,
189
+ "ª": 108,
190
+ "«": 109,
191
+ "¬": 110,
192
+ "®": 111,
193
+ "¯": 112,
194
+ "°": 113,
195
+ "±": 114,
196
+ "²": 115,
197
+ "³": 116,
198
+ "´": 117,
199
+ "µ": 118,
200
+ "¶": 119,
201
+ "·": 120,
202
+ "¸": 121,
203
+ "¹": 122,
204
+ "º": 123,
205
+ "»": 124,
206
+ "¼": 125,
207
+ "½": 126,
208
+ "¾": 127,
209
+ "¿": 128,
210
+ "À": 129,
211
+ "Á": 130,
212
+ "Â": 131,
213
+ "Ã": 132,
214
+ "Ä": 133,
215
+ "Å": 134,
216
+ "Æ": 135,
217
+ "Ç": 136,
218
+ "È": 137,
219
+ "É": 138,
220
+ "Ê": 139,
221
+ "Ë": 140,
222
+ "Ì": 141,
223
+ "Í": 142,
224
+ "Î": 143,
225
+ "Ï": 144,
226
+ "Ð": 145,
227
+ "Ñ": 146,
228
+ "Ò": 147,
229
+ "Ó": 148,
230
+ "Ô": 149,
231
+ "Õ": 150,
232
+ "Ö": 151,
233
+ "×": 152,
234
+ "Ø": 153,
235
+ "Ù": 154,
236
+ "Ú": 155,
237
+ "Û": 156,
238
+ "Ü": 157,
239
+ "Ý": 158,
240
+ "Þ": 159,
241
+ "ß": 160,
242
+ "à": 161,
243
+ "á": 162,
244
+ "â": 163,
245
+ "ã": 164,
246
+ "ä": 165,
247
+ "å": 166,
248
+ "æ": 167,
249
+ "ç": 168,
250
+ "è": 169,
251
+ "é": 170,
252
+ "ê": 171,
253
+ "ë": 172,
254
+ "ì": 173,
255
+ "í": 174,
256
+ "î": 175,
257
+ "ï": 176,
258
+ "ð": 177,
259
+ "ñ": 178,
260
+ "ò": 179,
261
+ "ó": 180,
262
+ "ô": 181,
263
+ "õ": 182,
264
+ "ö": 183,
265
+ "÷": 184,
266
+ "ø": 185,
267
+ "ù": 186,
268
+ "ú": 187,
269
+ "û": 188,
270
+ "ü": 189,
271
+ "ý": 190,
272
+ "þ": 191,
273
+ "ÿ": 192,
274
+ "Ā": 193,
275
+ "ā": 194,
276
+ "Ă": 195,
277
+ "ă": 196,
278
+ "Ą": 197,
279
+ "ą": 198,
280
+ "Ć": 199,
281
+ "ć": 200,
282
+ "Ĉ": 201,
283
+ "ĉ": 202,
284
+ "Ċ": 203,
285
+ "ċ": 204,
286
+ "Č": 205,
287
+ "č": 206,
288
+ "Ď": 207,
289
+ "ď": 208,
290
+ "Đ": 209,
291
+ "đ": 210,
292
+ "Ē": 211,
293
+ "ē": 212,
294
+ "Ĕ": 213,
295
+ "ĕ": 214,
296
+ "Ė": 215,
297
+ "ė": 216,
298
+ "Ę": 217,
299
+ "ę": 218,
300
+ "Ě": 219,
301
+ "ě": 220,
302
+ "Ĝ": 221,
303
+ "ĝ": 222,
304
+ "Ğ": 223,
305
+ "ğ": 224,
306
+ "Ġ": 225,
307
+ "ġ": 226,
308
+ "Ģ": 227,
309
+ "ģ": 228,
310
+ "Ĥ": 229,
311
+ "ĥ": 230,
312
+ "Ħ": 231,
313
+ "ħ": 232,
314
+ "Ĩ": 233,
315
+ "ĩ": 234,
316
+ "Ī": 235,
317
+ "ī": 236,
318
+ "Ĭ": 237,
319
+ "ĭ": 238,
320
+ "Į": 239,
321
+ "į": 240,
322
+ "İ": 241,
323
+ "ı": 242,
324
+ "IJ": 243,
325
+ "ij": 244,
326
+ "Ĵ": 245,
327
+ "ĵ": 246,
328
+ "Ķ": 247,
329
+ "ķ": 248,
330
+ "ĸ": 249,
331
+ "Ĺ": 250,
332
+ "ĺ": 251,
333
+ "Ļ": 252,
334
+ "ļ": 253,
335
+ "Ľ": 254,
336
+ "ľ": 255,
337
+ "Ŀ": 256,
338
+ "ŀ": 257,
339
+ "Ł": 258,
340
+ "ł": 259,
341
+ "Ń": 260,
342
+ "Ġt": 261,
343
+ "in": 262,
344
+ "en": 263,
345
+ "Ġa": 264,
346
+ "er": 265,
347
+ "es": 266,
348
+ "Ġo": 267,
349
+ "Ġto": 268,
350
+ "an": 269,
351
+ "ing": 270,
352
+ "ar": 271,
353
+ "at": 272,
354
+ "he": 273,
355
+ "is": 274,
356
+ "or": 275,
357
+ "Ġm": 276,
358
+ "Ġs": 277,
359
+ "al": 278,
360
+ "ken": 279,
361
+ "on": 280,
362
+ "Ġtoken": 281,
363
+ "le": 282,
364
+ "Ġof": 283,
365
+ "Ġb": 284,
366
+ "Ġp": 285,
367
+ "it": 286,
368
+ "ou": 287,
369
+ "Ġc": 288,
370
+ "Ġf": 289,
371
+ "Ġan": 290,
372
+ "ic": 291,
373
+ "iz": 292,
374
+ "ion": 293,
375
+ "ro": 294,
376
+ "ed": 295,
377
+ "el": 296,
378
+ "re": 297,
379
+ "Ġin": 298,
380
+ "Ġthe": 299,
381
+ "Ġis": 300,
382
+ "Ġand": 301,
383
+ "ĠT": 302,
384
+ "Ġu": 303,
385
+ "Ġbe": 304,
386
+ "Ġd": 305,
387
+ "Ġth": 306,
388
+ "ac": 307,
389
+ "mp": 308,
390
+ "od": 309,
391
+ "Ġw": 310,
392
+ "Ġle": 311,
393
+ "enc": 312,
394
+ "ent": 313,
395
+ "Ġtokeniz": 314,
396
+ "as": 315,
397
+ "ex": 316,
398
+ "ter": 317,
399
+ "Ġl": 318,
400
+ "arn": 319,
401
+ "Ġtokens": 320,
402
+ "Ġpro": 321,
403
+ "qu": 322,
404
+ "ul": 323,
405
+ "Ġh": 324,
406
+ "Ġv": 325,
407
+ "ation": 326,
408
+ "Ġthat": 327,
409
+ "Ġlearn": 328,
410
+ "ain": 329,
411
+ "ces": 330,
412
+ "ec": 331,
413
+ "fic": 332,
414
+ "ge": 333,
415
+ "il": 334,
416
+ "res": 335,
417
+ "ua": 336,
418
+ "you": 337,
419
+ "Ġn": 338,
420
+ "Ġre": 339,
421
+ "Ġyou": 340,
422
+ "Ġtr": 341,
423
+ "Ġtex": 342,
424
+ "Ġun": 343,
425
+ "cess": 344,
426
+ "Ġtext": 345,
427
+ "00": 346,
428
+ "am": 347,
429
+ "ds": 348,
430
+ "em": 349,
431
+ "et": 350,
432
+ "gua": 351,
433
+ "ific": 352,
434
+ "oc": 353,
435
+ "per": 354,
436
+ "st": 355,
437
+ "ur": 356,
438
+ "ve": 357,
439
+ "Ġon": 358,
440
+ "angua": 359,
441
+ "ords": 360,
442
+ "Ġmod": 361,
443
+ "ence": 362,
444
+ "Ġtokenizer": 363,
445
+ "ular": 364,
446
+ "Ġlearning": 365,
447
+ "aining": 366,
448
+ "ab": 367,
449
+ "ch": 368,
450
+ "for": 369,
451
+ "hin": 370,
452
+ "his": 371,
453
+ "ial": 372,
454
+ "imp": 373,
455
+ "ks": 374,
456
+ "se": 375,
457
+ "su": 376,
458
+ "us": 377,
459
+ "ĠB": 378,
460
+ "Ġ[": 379,
461
+ "Ġimp": 380,
462
+ "Ġar": 381,
463
+ "Ġor": 382,
464
+ "ans": 383,
465
+ "ate": 384,
466
+ "ith": 385,
467
+ "Ġcan": 386,
468
+ "Ġfor": 387,
469
+ "achin": 388,
470
+ "Ġwords": 389,
471
+ "Ġlangua": 390,
472
+ "Ġprocess": 391,
473
+ "Ġyour": 392,
474
+ "ural": 393,
475
+ "Ġmodel": 394,
476
+ "achine": 395,
477
+ "LP": 396,
478
+ "NLP": 397,
479
+ "PE": 398,
480
+ "The": 399,
481
+ "],": 400,
482
+ "ad": 401,
483
+ "ded": 402,
484
+ "ev": 403,
485
+ "gh": 404,
486
+ "id": 405,
487
+ "im": 406,
488
+ "ld": 407,
489
+ "lp": 408,
490
+ "lu": 409,
491
+ "ly": 410,
492
+ "pl": 411,
493
+ "te": 412,
494
+ "tion": 413,
495
+ "tific": 414,
496
+ "um": 415,
497
+ "vis": 416,
498
+ "wn": 417,
499
+ "yte": 418,
500
+ "Ġen": 419,
501
+ "Ġhe": 420,
502
+ "Ġit": 421,
503
+ "Ġqu": 422,
504
+ "art": 423,
505
+ "ata": 424,
506
+ "orp": 425,
507
+ "Ġmu": 426,
508
+ "Ġman": 427,
509
+ "Ġsu": 428,
510
+ "ont": 429,
511
+ "ity": 430,
512
+ "out": 431,
513
+ "Ġcorp": 432,
514
+ "Ġcont": 433,
515
+ "ions": 434,
516
+ "ell": 435,
517
+ "Ġint": 436,
518
+ "ĠThe": 437,
519
+ "Ġdata": 438,
520
+ "Ġwith": 439,
521
+ "Ġval": 440,
522
+ "Ġvoc": 441,
523
+ "Ġtraining": 442,
524
+ "Ġtrans": 443,
525
+ "pervis": 444,
526
+ "abular": 445,
527
+ "form": 446,
528
+ "Ġartific": 447,
529
+ "Ġlanguage": 448,
530
+ "Ġmodels": 449,
531
+ "Ġvocabular": 450,
532
+ "pervised": 451,
533
+ "Ġartificial": 452,
534
+ "BPE": 453,
535
+ "Byte": 454,
536
+ "Machine": 455,
537
+ "This": 456,
538
+ "ak": 457,
539
+ "amp": 458,
540
+ "ave": 459,
541
+ "clu": 460,
542
+ "ding": 461,
543
+ "dded": 462,
544
+ "een": 463,
545
+ "equ": 464,
546
+ "eural": 465,
547
+ "gr": 466,
548
+ "gence": 467,
549
+ "her": 468,
550
+ "hes": 469,
551
+ "ies": 470,
552
+ "ive": 471,
553
+ "igence": 472,
554
+ "kn": 473,
555
+ "lions": 474,
556
+ "ms": 475,
557
+ "mal": 476,
558
+ "om": 477,
559
+ "oo": 478,
560
+ "op": 479,
561
+ "omp": 480,
562
+ "own": 481,
563
+ "pp": 482,
564
+ "pic": 483,
565
+ "pec": 484,
566
+ "pres": 485,
567
+ "ts": 486,
568
+ "tw": 487,
569
+ "ten": 488,
570
+ "tan": 489,
571
+ "ting": 490,
572
+ "ut": 491,
573
+ "uter": 492,
574
+ "ver": 493,
575
+ "vel": 494,
576
+ "vid": 495,
577
+ "wor": 496,
578
+ "ypic": 497,
579
+ "Ġ(": 498,
580
+ "Ġ2": 499,
581
+ "ĠI": 500,
582
+ "ĠL": 501,
583
+ "ĠP": 502,
584
+ "Ġr": 503,
585
+ "Ġex": 504,
586
+ "ĠNLP": 505,
587
+ "Ġtas": 506,
588
+ "Ġal": 507,
589
+ "Ġat": 508,
590
+ "Ġare": 509,
591
+ "Ġadded": 510,
592
+ "and": 511,
593
+ "atural": 512,
594
+ "ortan": 513,
595
+ "Ġmachine": 514,
596
+ "Ġmak": 515,
597
+ "Ġsiz": 516,
598
+ "Ġsent": 517,
599
+ "Ġsamp": 518,
600
+ "Ġsequ": 519,
601
+ "Ġsmal": 520,
602
+ "alle": 521,
603
+ "level": 522,
604
+ "Ġoften": 523,
605
+ "Ġbro": 524,
606
+ "Ġpart": 525,
607
+ "ous": 526,
608
+ "ough": 527,
609
+ "Ġcomp": 528,
610
+ "Ġfro": 529,
611
+ "Ġfam": 530,
612
+ "Ġfoc": 531,
613
+ "Ġinclu": 532,
614
+ "ĠThis": 533,
615
+ "ĠThes": 534,
616
+ "ĠToo": 535,
617
+ "Ġus": 536,
618
+ "Ġuse": 537,
619
+ "Ġbetw": 538,
620
+ "Ġdi": 539,
621
+ "oding": 540,
622
+ "ences": 541,
623
+ "Ġtokenization": 542,
624
+ "ased": 543,
625
+ "Ġlar": 544,
626
+ "Ġprogr": 545,
627
+ "Ġprovid": 546,
628
+ "Ġhum": 547,
629
+ "Ġhave": 548,
630
+ "ect": 549,
631
+ "illions": 550,
632
+ "Ġnet": 551,
633
+ "Ġneural": 552,
634
+ "Ġrepres": 553,
635
+ "Ġunkn": 554,
636
+ "000": 555,
637
+ "supervised": 556,
638
+ "uses": 557,
639
+ "ĠBBPE": 558,
640
+ "Ġimportan": 559,
641
+ "plic": 560,
642
+ "Ġensu": 561,
643
+ "Ġhelp": 562,
644
+ "Ġmuch": 563,
645
+ "Ġmany": 564,
646
+ "Ġsub": 565,
647
+ "Ġcorpus": 566,
648
+ "elligence": 567,
649
+ "Ġintelligence": 568,
650
+ "Ġwithout": 569,
651
+ "Ġtransform": 570,
652
+ "Ġvocabulary": 571,
653
+ "works": 572,
654
+ "ypical": 573,
655
+ "Ġtasks": 574,
656
+ "Ġsample": 575,
657
+ "Ġsmall": 576,
658
+ "Ġcomputer": 577,
659
+ "Ġfrom": 578,
660
+ "Ġfocuses": 579,
661
+ "ĠThese": 580,
662
+ "Ġbetween": 581,
663
+ "Ġprogram": 582,
664
+ "Ġprovides": 583,
665
+ "Ġnetworks": 584,
666
+ "Ġrepresent": 585,
667
+ "Ġunknown": 586,
668
+ "Ġimportant": 587,
669
+ "Ġtransformer": 588
670
+ },
671
+ "merges": [
672
+ [
673
+ "Ġ",
674
+ "t"
675
+ ],
676
+ [
677
+ "i",
678
+ "n"
679
+ ],
680
+ [
681
+ "e",
682
+ "n"
683
+ ],
684
+ [
685
+ "Ġ",
686
+ "a"
687
+ ],
688
+ [
689
+ "e",
690
+ "r"
691
+ ],
692
+ [
693
+ "e",
694
+ "s"
695
+ ],
696
+ [
697
+ "Ġ",
698
+ "o"
699
+ ],
700
+ [
701
+ "Ġt",
702
+ "o"
703
+ ],
704
+ [
705
+ "a",
706
+ "n"
707
+ ],
708
+ [
709
+ "in",
710
+ "g"
711
+ ],
712
+ [
713
+ "a",
714
+ "r"
715
+ ],
716
+ [
717
+ "a",
718
+ "t"
719
+ ],
720
+ [
721
+ "h",
722
+ "e"
723
+ ],
724
+ [
725
+ "i",
726
+ "s"
727
+ ],
728
+ [
729
+ "o",
730
+ "r"
731
+ ],
732
+ [
733
+ "Ġ",
734
+ "m"
735
+ ],
736
+ [
737
+ "Ġ",
738
+ "s"
739
+ ],
740
+ [
741
+ "a",
742
+ "l"
743
+ ],
744
+ [
745
+ "k",
746
+ "en"
747
+ ],
748
+ [
749
+ "o",
750
+ "n"
751
+ ],
752
+ [
753
+ "Ġto",
754
+ "ken"
755
+ ],
756
+ [
757
+ "l",
758
+ "e"
759
+ ],
760
+ [
761
+ "Ġo",
762
+ "f"
763
+ ],
764
+ [
765
+ "Ġ",
766
+ "b"
767
+ ],
768
+ [
769
+ "Ġ",
770
+ "p"
771
+ ],
772
+ [
773
+ "i",
774
+ "t"
775
+ ],
776
+ [
777
+ "o",
778
+ "u"
779
+ ],
780
+ [
781
+ "Ġ",
782
+ "c"
783
+ ],
784
+ [
785
+ "Ġ",
786
+ "f"
787
+ ],
788
+ [
789
+ "Ġa",
790
+ "n"
791
+ ],
792
+ [
793
+ "i",
794
+ "c"
795
+ ],
796
+ [
797
+ "i",
798
+ "z"
799
+ ],
800
+ [
801
+ "i",
802
+ "on"
803
+ ],
804
+ [
805
+ "r",
806
+ "o"
807
+ ],
808
+ [
809
+ "e",
810
+ "d"
811
+ ],
812
+ [
813
+ "e",
814
+ "l"
815
+ ],
816
+ [
817
+ "r",
818
+ "e"
819
+ ],
820
+ [
821
+ "Ġ",
822
+ "in"
823
+ ],
824
+ [
825
+ "Ġt",
826
+ "he"
827
+ ],
828
+ [
829
+ "Ġ",
830
+ "is"
831
+ ],
832
+ [
833
+ "Ġan",
834
+ "d"
835
+ ],
836
+ [
837
+ "Ġ",
838
+ "T"
839
+ ],
840
+ [
841
+ "Ġ",
842
+ "u"
843
+ ],
844
+ [
845
+ "Ġb",
846
+ "e"
847
+ ],
848
+ [
849
+ "Ġ",
850
+ "d"
851
+ ],
852
+ [
853
+ "Ġt",
854
+ "h"
855
+ ],
856
+ [
857
+ "a",
858
+ "c"
859
+ ],
860
+ [
861
+ "m",
862
+ "p"
863
+ ],
864
+ [
865
+ "o",
866
+ "d"
867
+ ],
868
+ [
869
+ "Ġ",
870
+ "w"
871
+ ],
872
+ [
873
+ "Ġ",
874
+ "le"
875
+ ],
876
+ [
877
+ "en",
878
+ "c"
879
+ ],
880
+ [
881
+ "en",
882
+ "t"
883
+ ],
884
+ [
885
+ "Ġtoken",
886
+ "iz"
887
+ ],
888
+ [
889
+ "a",
890
+ "s"
891
+ ],
892
+ [
893
+ "e",
894
+ "x"
895
+ ],
896
+ [
897
+ "t",
898
+ "er"
899
+ ],
900
+ [
901
+ "Ġ",
902
+ "l"
903
+ ],
904
+ [
905
+ "ar",
906
+ "n"
907
+ ],
908
+ [
909
+ "Ġtoken",
910
+ "s"
911
+ ],
912
+ [
913
+ "Ġp",
914
+ "ro"
915
+ ],
916
+ [
917
+ "q",
918
+ "u"
919
+ ],
920
+ [
921
+ "u",
922
+ "l"
923
+ ],
924
+ [
925
+ "Ġ",
926
+ "h"
927
+ ],
928
+ [
929
+ "Ġ",
930
+ "v"
931
+ ],
932
+ [
933
+ "at",
934
+ "ion"
935
+ ],
936
+ [
937
+ "Ġth",
938
+ "at"
939
+ ],
940
+ [
941
+ "Ġle",
942
+ "arn"
943
+ ],
944
+ [
945
+ "a",
946
+ "in"
947
+ ],
948
+ [
949
+ "c",
950
+ "es"
951
+ ],
952
+ [
953
+ "e",
954
+ "c"
955
+ ],
956
+ [
957
+ "f",
958
+ "ic"
959
+ ],
960
+ [
961
+ "g",
962
+ "e"
963
+ ],
964
+ [
965
+ "i",
966
+ "l"
967
+ ],
968
+ [
969
+ "r",
970
+ "es"
971
+ ],
972
+ [
973
+ "u",
974
+ "a"
975
+ ],
976
+ [
977
+ "y",
978
+ "ou"
979
+ ],
980
+ [
981
+ "Ġ",
982
+ "n"
983
+ ],
984
+ [
985
+ "Ġ",
986
+ "re"
987
+ ],
988
+ [
989
+ "Ġ",
990
+ "you"
991
+ ],
992
+ [
993
+ "Ġt",
994
+ "r"
995
+ ],
996
+ [
997
+ "Ġt",
998
+ "ex"
999
+ ],
1000
+ [
1001
+ "Ġu",
1002
+ "n"
1003
+ ],
1004
+ [
1005
+ "ces",
1006
+ "s"
1007
+ ],
1008
+ [
1009
+ "Ġtex",
1010
+ "t"
1011
+ ],
1012
+ [
1013
+ "0",
1014
+ "0"
1015
+ ],
1016
+ [
1017
+ "a",
1018
+ "m"
1019
+ ],
1020
+ [
1021
+ "d",
1022
+ "s"
1023
+ ],
1024
+ [
1025
+ "e",
1026
+ "m"
1027
+ ],
1028
+ [
1029
+ "e",
1030
+ "t"
1031
+ ],
1032
+ [
1033
+ "g",
1034
+ "ua"
1035
+ ],
1036
+ [
1037
+ "i",
1038
+ "fic"
1039
+ ],
1040
+ [
1041
+ "o",
1042
+ "c"
1043
+ ],
1044
+ [
1045
+ "p",
1046
+ "er"
1047
+ ],
1048
+ [
1049
+ "s",
1050
+ "t"
1051
+ ],
1052
+ [
1053
+ "u",
1054
+ "r"
1055
+ ],
1056
+ [
1057
+ "v",
1058
+ "e"
1059
+ ],
1060
+ [
1061
+ "Ġo",
1062
+ "n"
1063
+ ],
1064
+ [
1065
+ "an",
1066
+ "gua"
1067
+ ],
1068
+ [
1069
+ "or",
1070
+ "ds"
1071
+ ],
1072
+ [
1073
+ "Ġm",
1074
+ "od"
1075
+ ],
1076
+ [
1077
+ "enc",
1078
+ "e"
1079
+ ],
1080
+ [
1081
+ "Ġtokeniz",
1082
+ "er"
1083
+ ],
1084
+ [
1085
+ "ul",
1086
+ "ar"
1087
+ ],
1088
+ [
1089
+ "Ġlearn",
1090
+ "ing"
1091
+ ],
1092
+ [
1093
+ "ain",
1094
+ "ing"
1095
+ ],
1096
+ [
1097
+ "a",
1098
+ "b"
1099
+ ],
1100
+ [
1101
+ "c",
1102
+ "h"
1103
+ ],
1104
+ [
1105
+ "f",
1106
+ "or"
1107
+ ],
1108
+ [
1109
+ "h",
1110
+ "in"
1111
+ ],
1112
+ [
1113
+ "h",
1114
+ "is"
1115
+ ],
1116
+ [
1117
+ "i",
1118
+ "al"
1119
+ ],
1120
+ [
1121
+ "i",
1122
+ "mp"
1123
+ ],
1124
+ [
1125
+ "k",
1126
+ "s"
1127
+ ],
1128
+ [
1129
+ "s",
1130
+ "e"
1131
+ ],
1132
+ [
1133
+ "s",
1134
+ "u"
1135
+ ],
1136
+ [
1137
+ "u",
1138
+ "s"
1139
+ ],
1140
+ [
1141
+ "Ġ",
1142
+ "B"
1143
+ ],
1144
+ [
1145
+ "Ġ",
1146
+ "["
1147
+ ],
1148
+ [
1149
+ "Ġ",
1150
+ "imp"
1151
+ ],
1152
+ [
1153
+ "Ġa",
1154
+ "r"
1155
+ ],
1156
+ [
1157
+ "Ġo",
1158
+ "r"
1159
+ ],
1160
+ [
1161
+ "an",
1162
+ "s"
1163
+ ],
1164
+ [
1165
+ "at",
1166
+ "e"
1167
+ ],
1168
+ [
1169
+ "it",
1170
+ "h"
1171
+ ],
1172
+ [
1173
+ "Ġc",
1174
+ "an"
1175
+ ],
1176
+ [
1177
+ "Ġf",
1178
+ "or"
1179
+ ],
1180
+ [
1181
+ "ac",
1182
+ "hin"
1183
+ ],
1184
+ [
1185
+ "Ġw",
1186
+ "ords"
1187
+ ],
1188
+ [
1189
+ "Ġl",
1190
+ "angua"
1191
+ ],
1192
+ [
1193
+ "Ġpro",
1194
+ "cess"
1195
+ ],
1196
+ [
1197
+ "Ġyou",
1198
+ "r"
1199
+ ],
1200
+ [
1201
+ "ur",
1202
+ "al"
1203
+ ],
1204
+ [
1205
+ "Ġmod",
1206
+ "el"
1207
+ ],
1208
+ [
1209
+ "achin",
1210
+ "e"
1211
+ ],
1212
+ [
1213
+ "L",
1214
+ "P"
1215
+ ],
1216
+ [
1217
+ "N",
1218
+ "LP"
1219
+ ],
1220
+ [
1221
+ "P",
1222
+ "E"
1223
+ ],
1224
+ [
1225
+ "T",
1226
+ "he"
1227
+ ],
1228
+ [
1229
+ "]",
1230
+ ","
1231
+ ],
1232
+ [
1233
+ "a",
1234
+ "d"
1235
+ ],
1236
+ [
1237
+ "d",
1238
+ "ed"
1239
+ ],
1240
+ [
1241
+ "e",
1242
+ "v"
1243
+ ],
1244
+ [
1245
+ "g",
1246
+ "h"
1247
+ ],
1248
+ [
1249
+ "i",
1250
+ "d"
1251
+ ],
1252
+ [
1253
+ "i",
1254
+ "m"
1255
+ ],
1256
+ [
1257
+ "l",
1258
+ "d"
1259
+ ],
1260
+ [
1261
+ "l",
1262
+ "p"
1263
+ ],
1264
+ [
1265
+ "l",
1266
+ "u"
1267
+ ],
1268
+ [
1269
+ "l",
1270
+ "y"
1271
+ ],
1272
+ [
1273
+ "p",
1274
+ "l"
1275
+ ],
1276
+ [
1277
+ "t",
1278
+ "e"
1279
+ ],
1280
+ [
1281
+ "t",
1282
+ "ion"
1283
+ ],
1284
+ [
1285
+ "t",
1286
+ "ific"
1287
+ ],
1288
+ [
1289
+ "u",
1290
+ "m"
1291
+ ],
1292
+ [
1293
+ "v",
1294
+ "is"
1295
+ ],
1296
+ [
1297
+ "w",
1298
+ "n"
1299
+ ],
1300
+ [
1301
+ "y",
1302
+ "te"
1303
+ ],
1304
+ [
1305
+ "Ġ",
1306
+ "en"
1307
+ ],
1308
+ [
1309
+ "Ġ",
1310
+ "he"
1311
+ ],
1312
+ [
1313
+ "Ġ",
1314
+ "it"
1315
+ ],
1316
+ [
1317
+ "Ġ",
1318
+ "qu"
1319
+ ],
1320
+ [
1321
+ "ar",
1322
+ "t"
1323
+ ],
1324
+ [
1325
+ "at",
1326
+ "a"
1327
+ ],
1328
+ [
1329
+ "or",
1330
+ "p"
1331
+ ],
1332
+ [
1333
+ "Ġm",
1334
+ "u"
1335
+ ],
1336
+ [
1337
+ "Ġm",
1338
+ "an"
1339
+ ],
1340
+ [
1341
+ "Ġs",
1342
+ "u"
1343
+ ],
1344
+ [
1345
+ "on",
1346
+ "t"
1347
+ ],
1348
+ [
1349
+ "it",
1350
+ "y"
1351
+ ],
1352
+ [
1353
+ "ou",
1354
+ "t"
1355
+ ],
1356
+ [
1357
+ "Ġc",
1358
+ "orp"
1359
+ ],
1360
+ [
1361
+ "Ġc",
1362
+ "ont"
1363
+ ],
1364
+ [
1365
+ "ion",
1366
+ "s"
1367
+ ],
1368
+ [
1369
+ "el",
1370
+ "l"
1371
+ ],
1372
+ [
1373
+ "Ġin",
1374
+ "t"
1375
+ ],
1376
+ [
1377
+ "ĠT",
1378
+ "he"
1379
+ ],
1380
+ [
1381
+ "Ġd",
1382
+ "ata"
1383
+ ],
1384
+ [
1385
+ "Ġw",
1386
+ "ith"
1387
+ ],
1388
+ [
1389
+ "Ġv",
1390
+ "al"
1391
+ ],
1392
+ [
1393
+ "Ġv",
1394
+ "oc"
1395
+ ],
1396
+ [
1397
+ "Ġtr",
1398
+ "aining"
1399
+ ],
1400
+ [
1401
+ "Ġtr",
1402
+ "ans"
1403
+ ],
1404
+ [
1405
+ "per",
1406
+ "vis"
1407
+ ],
1408
+ [
1409
+ "ab",
1410
+ "ular"
1411
+ ],
1412
+ [
1413
+ "for",
1414
+ "m"
1415
+ ],
1416
+ [
1417
+ "Ġar",
1418
+ "tific"
1419
+ ],
1420
+ [
1421
+ "Ġlangua",
1422
+ "ge"
1423
+ ],
1424
+ [
1425
+ "Ġmodel",
1426
+ "s"
1427
+ ],
1428
+ [
1429
+ "Ġvoc",
1430
+ "abular"
1431
+ ],
1432
+ [
1433
+ "pervis",
1434
+ "ed"
1435
+ ],
1436
+ [
1437
+ "Ġartific",
1438
+ "ial"
1439
+ ],
1440
+ [
1441
+ "B",
1442
+ "PE"
1443
+ ],
1444
+ [
1445
+ "B",
1446
+ "yte"
1447
+ ],
1448
+ [
1449
+ "M",
1450
+ "achine"
1451
+ ],
1452
+ [
1453
+ "T",
1454
+ "his"
1455
+ ],
1456
+ [
1457
+ "a",
1458
+ "k"
1459
+ ],
1460
+ [
1461
+ "a",
1462
+ "mp"
1463
+ ],
1464
+ [
1465
+ "a",
1466
+ "ve"
1467
+ ],
1468
+ [
1469
+ "c",
1470
+ "lu"
1471
+ ],
1472
+ [
1473
+ "d",
1474
+ "ing"
1475
+ ],
1476
+ [
1477
+ "d",
1478
+ "ded"
1479
+ ],
1480
+ [
1481
+ "e",
1482
+ "en"
1483
+ ],
1484
+ [
1485
+ "e",
1486
+ "qu"
1487
+ ],
1488
+ [
1489
+ "e",
1490
+ "ural"
1491
+ ],
1492
+ [
1493
+ "g",
1494
+ "r"
1495
+ ],
1496
+ [
1497
+ "g",
1498
+ "ence"
1499
+ ],
1500
+ [
1501
+ "h",
1502
+ "er"
1503
+ ],
1504
+ [
1505
+ "h",
1506
+ "es"
1507
+ ],
1508
+ [
1509
+ "i",
1510
+ "es"
1511
+ ],
1512
+ [
1513
+ "i",
1514
+ "ve"
1515
+ ],
1516
+ [
1517
+ "i",
1518
+ "gence"
1519
+ ],
1520
+ [
1521
+ "k",
1522
+ "n"
1523
+ ],
1524
+ [
1525
+ "l",
1526
+ "ions"
1527
+ ],
1528
+ [
1529
+ "m",
1530
+ "s"
1531
+ ],
1532
+ [
1533
+ "m",
1534
+ "al"
1535
+ ],
1536
+ [
1537
+ "o",
1538
+ "m"
1539
+ ],
1540
+ [
1541
+ "o",
1542
+ "o"
1543
+ ],
1544
+ [
1545
+ "o",
1546
+ "p"
1547
+ ],
1548
+ [
1549
+ "o",
1550
+ "mp"
1551
+ ],
1552
+ [
1553
+ "o",
1554
+ "wn"
1555
+ ],
1556
+ [
1557
+ "p",
1558
+ "p"
1559
+ ],
1560
+ [
1561
+ "p",
1562
+ "ic"
1563
+ ],
1564
+ [
1565
+ "p",
1566
+ "ec"
1567
+ ],
1568
+ [
1569
+ "p",
1570
+ "res"
1571
+ ],
1572
+ [
1573
+ "t",
1574
+ "s"
1575
+ ],
1576
+ [
1577
+ "t",
1578
+ "w"
1579
+ ],
1580
+ [
1581
+ "t",
1582
+ "en"
1583
+ ],
1584
+ [
1585
+ "t",
1586
+ "an"
1587
+ ],
1588
+ [
1589
+ "t",
1590
+ "ing"
1591
+ ],
1592
+ [
1593
+ "u",
1594
+ "t"
1595
+ ],
1596
+ [
1597
+ "u",
1598
+ "ter"
1599
+ ],
1600
+ [
1601
+ "v",
1602
+ "er"
1603
+ ],
1604
+ [
1605
+ "v",
1606
+ "el"
1607
+ ],
1608
+ [
1609
+ "v",
1610
+ "id"
1611
+ ],
1612
+ [
1613
+ "w",
1614
+ "or"
1615
+ ],
1616
+ [
1617
+ "y",
1618
+ "pic"
1619
+ ],
1620
+ [
1621
+ "Ġ",
1622
+ "("
1623
+ ],
1624
+ [
1625
+ "Ġ",
1626
+ "2"
1627
+ ],
1628
+ [
1629
+ "Ġ",
1630
+ "I"
1631
+ ],
1632
+ [
1633
+ "Ġ",
1634
+ "L"
1635
+ ],
1636
+ [
1637
+ "Ġ",
1638
+ "P"
1639
+ ],
1640
+ [
1641
+ "Ġ",
1642
+ "r"
1643
+ ],
1644
+ [
1645
+ "Ġ",
1646
+ "ex"
1647
+ ],
1648
+ [
1649
+ "Ġ",
1650
+ "NLP"
1651
+ ],
1652
+ [
1653
+ "Ġt",
1654
+ "as"
1655
+ ],
1656
+ [
1657
+ "Ġa",
1658
+ "l"
1659
+ ],
1660
+ [
1661
+ "Ġa",
1662
+ "t"
1663
+ ],
1664
+ [
1665
+ "Ġa",
1666
+ "re"
1667
+ ],
1668
+ [
1669
+ "Ġa",
1670
+ "dded"
1671
+ ],
1672
+ [
1673
+ "an",
1674
+ "d"
1675
+ ],
1676
+ [
1677
+ "at",
1678
+ "ural"
1679
+ ],
1680
+ [
1681
+ "or",
1682
+ "tan"
1683
+ ],
1684
+ [
1685
+ "Ġm",
1686
+ "achine"
1687
+ ],
1688
+ [
1689
+ "Ġm",
1690
+ "ak"
1691
+ ],
1692
+ [
1693
+ "Ġs",
1694
+ "iz"
1695
+ ],
1696
+ [
1697
+ "Ġs",
1698
+ "ent"
1699
+ ],
1700
+ [
1701
+ "Ġs",
1702
+ "amp"
1703
+ ],
1704
+ [
1705
+ "Ġs",
1706
+ "equ"
1707
+ ],
1708
+ [
1709
+ "Ġs",
1710
+ "mal"
1711
+ ],
1712
+ [
1713
+ "al",
1714
+ "le"
1715
+ ],
1716
+ [
1717
+ "le",
1718
+ "vel"
1719
+ ],
1720
+ [
1721
+ "Ġof",
1722
+ "ten"
1723
+ ],
1724
+ [
1725
+ "Ġb",
1726
+ "ro"
1727
+ ],
1728
+ [
1729
+ "Ġp",
1730
+ "art"
1731
+ ],
1732
+ [
1733
+ "ou",
1734
+ "s"
1735
+ ],
1736
+ [
1737
+ "ou",
1738
+ "gh"
1739
+ ],
1740
+ [
1741
+ "Ġc",
1742
+ "omp"
1743
+ ],
1744
+ [
1745
+ "Ġf",
1746
+ "ro"
1747
+ ],
1748
+ [
1749
+ "Ġf",
1750
+ "am"
1751
+ ],
1752
+ [
1753
+ "Ġf",
1754
+ "oc"
1755
+ ],
1756
+ [
1757
+ "Ġin",
1758
+ "clu"
1759
+ ],
1760
+ [
1761
+ "ĠT",
1762
+ "his"
1763
+ ],
1764
+ [
1765
+ "ĠT",
1766
+ "hes"
1767
+ ],
1768
+ [
1769
+ "ĠT",
1770
+ "oo"
1771
+ ],
1772
+ [
1773
+ "Ġu",
1774
+ "s"
1775
+ ],
1776
+ [
1777
+ "Ġu",
1778
+ "se"
1779
+ ],
1780
+ [
1781
+ "Ġbe",
1782
+ "tw"
1783
+ ],
1784
+ [
1785
+ "Ġd",
1786
+ "i"
1787
+ ],
1788
+ [
1789
+ "od",
1790
+ "ing"
1791
+ ],
1792
+ [
1793
+ "enc",
1794
+ "es"
1795
+ ],
1796
+ [
1797
+ "Ġtokeniz",
1798
+ "ation"
1799
+ ],
1800
+ [
1801
+ "as",
1802
+ "ed"
1803
+ ],
1804
+ [
1805
+ "Ġl",
1806
+ "ar"
1807
+ ],
1808
+ [
1809
+ "Ġpro",
1810
+ "gr"
1811
+ ],
1812
+ [
1813
+ "Ġpro",
1814
+ "vid"
1815
+ ],
1816
+ [
1817
+ "Ġh",
1818
+ "um"
1819
+ ],
1820
+ [
1821
+ "Ġh",
1822
+ "ave"
1823
+ ],
1824
+ [
1825
+ "ec",
1826
+ "t"
1827
+ ],
1828
+ [
1829
+ "il",
1830
+ "lions"
1831
+ ],
1832
+ [
1833
+ "Ġn",
1834
+ "et"
1835
+ ],
1836
+ [
1837
+ "Ġn",
1838
+ "eural"
1839
+ ],
1840
+ [
1841
+ "Ġre",
1842
+ "pres"
1843
+ ],
1844
+ [
1845
+ "Ġun",
1846
+ "kn"
1847
+ ],
1848
+ [
1849
+ "00",
1850
+ "0"
1851
+ ],
1852
+ [
1853
+ "su",
1854
+ "pervised"
1855
+ ],
1856
+ [
1857
+ "us",
1858
+ "es"
1859
+ ],
1860
+ [
1861
+ "ĠB",
1862
+ "BPE"
1863
+ ],
1864
+ [
1865
+ "Ġimp",
1866
+ "ortan"
1867
+ ],
1868
+ [
1869
+ "pl",
1870
+ "ic"
1871
+ ],
1872
+ [
1873
+ "Ġen",
1874
+ "su"
1875
+ ],
1876
+ [
1877
+ "Ġhe",
1878
+ "lp"
1879
+ ],
1880
+ [
1881
+ "Ġmu",
1882
+ "ch"
1883
+ ],
1884
+ [
1885
+ "Ġman",
1886
+ "y"
1887
+ ],
1888
+ [
1889
+ "Ġsu",
1890
+ "b"
1891
+ ],
1892
+ [
1893
+ "Ġcorp",
1894
+ "us"
1895
+ ],
1896
+ [
1897
+ "ell",
1898
+ "igence"
1899
+ ],
1900
+ [
1901
+ "Ġint",
1902
+ "elligence"
1903
+ ],
1904
+ [
1905
+ "Ġwith",
1906
+ "out"
1907
+ ],
1908
+ [
1909
+ "Ġtrans",
1910
+ "form"
1911
+ ],
1912
+ [
1913
+ "Ġvocabular",
1914
+ "y"
1915
+ ],
1916
+ [
1917
+ "wor",
1918
+ "ks"
1919
+ ],
1920
+ [
1921
+ "ypic",
1922
+ "al"
1923
+ ],
1924
+ [
1925
+ "Ġtas",
1926
+ "ks"
1927
+ ],
1928
+ [
1929
+ "Ġsamp",
1930
+ "le"
1931
+ ],
1932
+ [
1933
+ "Ġsmal",
1934
+ "l"
1935
+ ],
1936
+ [
1937
+ "Ġcomp",
1938
+ "uter"
1939
+ ],
1940
+ [
1941
+ "Ġfro",
1942
+ "m"
1943
+ ],
1944
+ [
1945
+ "Ġfoc",
1946
+ "uses"
1947
+ ],
1948
+ [
1949
+ "ĠThes",
1950
+ "e"
1951
+ ],
1952
+ [
1953
+ "Ġbetw",
1954
+ "een"
1955
+ ],
1956
+ [
1957
+ "Ġprogr",
1958
+ "am"
1959
+ ],
1960
+ [
1961
+ "Ġprovid",
1962
+ "es"
1963
+ ],
1964
+ [
1965
+ "Ġnet",
1966
+ "works"
1967
+ ],
1968
+ [
1969
+ "Ġrepres",
1970
+ "ent"
1971
+ ],
1972
+ [
1973
+ "Ġunkn",
1974
+ "own"
1975
+ ],
1976
+ [
1977
+ "Ġimportan",
1978
+ "t"
1979
+ ],
1980
+ [
1981
+ "Ġtransform",
1982
+ "er"
1983
+ ]
1984
+ ]
1985
+ }
1986
+ }
models/demo_tokenizer/vocab.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"<pad>":0,"<unk>":1,"<s>":2,"</s>":3,"<mask>":4,"!":5,"\"":6,"#":7,"$":8,"%":9,"&":10,"'":11,"(":12,")":13,"*":14,"+":15,",":16,"-":17,".":18,"/":19,"0":20,"1":21,"2":22,"3":23,"4":24,"5":25,"6":26,"7":27,"8":28,"9":29,":":30,";":31,"<":32,"=":33,">":34,"?":35,"@":36,"A":37,"B":38,"C":39,"D":40,"E":41,"F":42,"G":43,"H":44,"I":45,"J":46,"K":47,"L":48,"M":49,"N":50,"O":51,"P":52,"Q":53,"R":54,"S":55,"T":56,"U":57,"V":58,"W":59,"X":60,"Y":61,"Z":62,"[":63,"\\":64,"]":65,"^":66,"_":67,"`":68,"a":69,"b":70,"c":71,"d":72,"e":73,"f":74,"g":75,"h":76,"i":77,"j":78,"k":79,"l":80,"m":81,"n":82,"o":83,"p":84,"q":85,"r":86,"s":87,"t":88,"u":89,"v":90,"w":91,"x":92,"y":93,"z":94,"{":95,"|":96,"}":97,"~":98,"¡":99,"¢":100,"£":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,"È":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,"ù":186,"ú":187,"û":188,"ü":189,"ý":190,"þ":191,"ÿ":192,"Ā":193,"ā":194,"Ă":195,"ă":196,"Ą":197,"ą":198,"Ć":199,"ć":200,"Ĉ":201,"ĉ":202,"Ċ":203,"ċ":204,"Č":205,"č":206,"Ď":207,"ď":208,"Đ":209,"đ":210,"Ē":211,"ē":212,"Ĕ":213,"ĕ":214,"Ė":215,"ė":216,"Ę":217,"ę":218,"Ě":219,"ě":220,"Ĝ":221,"ĝ":222,"Ğ":223,"ğ":224,"Ġ":225,"ġ":226,"Ģ":227,"ģ":228,"Ĥ":229,"ĥ":230,"Ħ":231,"ħ":232,"Ĩ":233,"ĩ":234,"Ī":235,"ī":236,"Ĭ":237,"ĭ":238,"Į":239,"į":240,"İ":241,"ı":242,"IJ":243,"ij":244,"Ĵ":245,"ĵ":246,"Ķ":247,"ķ":248,"ĸ":249,"Ĺ":250,"ĺ":251,"Ļ":252,"ļ":253,"Ľ":254,"ľ":255,"Ŀ":256,"ŀ":257,"Ł":258,"ł":259,"Ń":260,"Ġt":261,"in":262,"en":263,"Ġa":264,"er":265,"es":266,"Ġo":267,"Ġto":268,"an":269,"ing":270,"ar":271,"at":272,"he":273,"is":274,"or":275,"Ġm":276,"Ġs":277,"al":278,"ken":279,"on":280,"Ġtoken":281,"le":282,"Ġof":283,"Ġb":284,"Ġp":285,"it":286,"ou":287,"Ġc":288,"Ġf":289,"Ġan":290,"ic":291,"iz":292,"ion":293,"ro":294,"ed":295,"el":296,"re":297,"Ġin":298,"Ġthe":299,"Ġis":300,"Ġand":301,"ĠT":302,"Ġu":303,"Ġbe":304,"Ġd":305,"Ġth":306,"ac":307,"mp":308,"od":309,"Ġw":310,"Ġle":311,"enc":312,"ent":313,"Ġtokeniz":314,"as":315,"ex":316,"ter":317,"Ġl":318,"arn":319,"Ġtokens":320,"Ġpro":321,"qu":322,"ul":323,"Ġh":324,"Ġv":325,"ation":326,"Ġthat":327,"Ġlearn":328,"ain":329,"ces":330,"ec":331,"fic":332,"ge":333,"il":334,"res":335,"ua":336,"you":337,"Ġn":338,"Ġre":339,"Ġyou":340,"Ġtr":341,"Ġtex":342,"Ġun":343,"cess":344,"Ġtext":345,"00":346,"am":347,"ds":348,"em":349,"et":350,"gua":351,"ific":352,"oc":353,"per":354,"st":355,"ur":356,"ve":357,"Ġon":358,"angua":359,"ords":360,"Ġmod":361,"ence":362,"Ġtokenizer":363,"ular":364,"Ġlearning":365,"aining":366,"ab":367,"ch":368,"for":369,"hin":370,"his":371,"ial":372,"imp":373,"ks":374,"se":375,"su":376,"us":377,"ĠB":378,"Ġ[":379,"Ġimp":380,"Ġar":381,"Ġor":382,"ans":383,"ate":384,"ith":385,"Ġcan":386,"Ġfor":387,"achin":388,"Ġwords":389,"Ġlangua":390,"Ġprocess":391,"Ġyour":392,"ural":393,"Ġmodel":394,"achine":395,"LP":396,"NLP":397,"PE":398,"The":399,"],":400,"ad":401,"ded":402,"ev":403,"gh":404,"id":405,"im":406,"ld":407,"lp":408,"lu":409,"ly":410,"pl":411,"te":412,"tion":413,"tific":414,"um":415,"vis":416,"wn":417,"yte":418,"Ġen":419,"Ġhe":420,"Ġit":421,"Ġqu":422,"art":423,"ata":424,"orp":425,"Ġmu":426,"Ġman":427,"Ġsu":428,"ont":429,"ity":430,"out":431,"Ġcorp":432,"Ġcont":433,"ions":434,"ell":435,"Ġint":436,"ĠThe":437,"Ġdata":438,"Ġwith":439,"Ġval":440,"Ġvoc":441,"Ġtraining":442,"Ġtrans":443,"pervis":444,"abular":445,"form":446,"Ġartific":447,"Ġlanguage":448,"Ġmodels":449,"Ġvocabular":450,"pervised":451,"Ġartificial":452,"BPE":453,"Byte":454,"Machine":455,"This":456,"ak":457,"amp":458,"ave":459,"clu":460,"ding":461,"dded":462,"een":463,"equ":464,"eural":465,"gr":466,"gence":467,"her":468,"hes":469,"ies":470,"ive":471,"igence":472,"kn":473,"lions":474,"ms":475,"mal":476,"om":477,"oo":478,"op":479,"omp":480,"own":481,"pp":482,"pic":483,"pec":484,"pres":485,"ts":486,"tw":487,"ten":488,"tan":489,"ting":490,"ut":491,"uter":492,"ver":493,"vel":494,"vid":495,"wor":496,"ypic":497,"Ġ(":498,"Ġ2":499,"ĠI":500,"ĠL":501,"ĠP":502,"Ġr":503,"Ġex":504,"ĠNLP":505,"Ġtas":506,"Ġal":507,"Ġat":508,"Ġare":509,"Ġadded":510,"and":511,"atural":512,"ortan":513,"Ġmachine":514,"Ġmak":515,"Ġsiz":516,"Ġsent":517,"Ġsamp":518,"Ġsequ":519,"Ġsmal":520,"alle":521,"level":522,"Ġoften":523,"Ġbro":524,"Ġpart":525,"ous":526,"ough":527,"Ġcomp":528,"Ġfro":529,"Ġfam":530,"Ġfoc":531,"Ġinclu":532,"ĠThis":533,"ĠThes":534,"ĠToo":535,"Ġus":536,"Ġuse":537,"Ġbetw":538,"Ġdi":539,"oding":540,"ences":541,"Ġtokenization":542,"ased":543,"Ġlar":544,"Ġprogr":545,"Ġprovid":546,"Ġhum":547,"Ġhave":548,"ect":549,"illions":550,"Ġnet":551,"Ġneural":552,"Ġrepres":553,"Ġunkn":554,"000":555,"supervised":556,"uses":557,"ĠBBPE":558,"Ġimportan":559,"plic":560,"Ġensu":561,"Ġhelp":562,"Ġmuch":563,"Ġmany":564,"Ġsub":565,"Ġcorpus":566,"elligence":567,"Ġintelligence":568,"Ġwithout":569,"Ġtransform":570,"Ġvocabulary":571,"works":572,"ypical":573,"Ġtasks":574,"Ġsample":575,"Ġsmall":576,"Ġcomputer":577,"Ġfrom":578,"Ġfocuses":579,"ĠThese":580,"Ġbetween":581,"Ġprogram":582,"Ġprovides":583,"Ġnetworks":584,"Ġrepresent":585,"Ġunknown":586,"Ġimportant":587,"Ġtransformer":588}
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ tokenizers>=0.15.0
scripts/bbpe_trainer.py ADDED
@@ -0,0 +1,321 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Byte-Level BPE Tokenizer Training Pipeline
3
+
4
+ This module provides a comprehensive architecture for training Byte-Level BPE (BBPE) tokenizers
5
+ using Hugging Face's `tokenizers` library. It includes data preprocessing, training configuration,
6
+ and model serialization utilities.
7
+ """
8
+
9
+ import os
10
+ import json
11
+ from pathlib import Path
12
+ from typing import List, Optional, Union
13
+ from dataclasses import dataclass, field, asdict
14
+ from tokenizers import ByteLevelBPETokenizer, Tokenizer
15
+
16
+
17
+ @dataclass
18
+ class BBPEConfig:
19
+ """Configuration class for BBPE tokenizer training."""
20
+
21
+ # Vocabulary settings
22
+ vocab_size: int = 30000
23
+ min_frequency: int = 2
24
+
25
+ # Special tokens
26
+ special_tokens: List[str] = field(default_factory=lambda: [
27
+ "<pad>",
28
+ "<unk>",
29
+ "<s>",
30
+ "</s>",
31
+ "<mask>"
32
+ ])
33
+
34
+ # Byte-level settings
35
+ lowercase: bool = False
36
+ add_prefix_space: bool = True
37
+ trim_offsets: bool = False
38
+
39
+ # Training settings
40
+ show_progress: bool = True
41
+ initial_alphabet: List[str] = field(default_factory=list)
42
+
43
+ # Paths
44
+ data_dir: str = "data"
45
+ model_save_dir: str = "models"
46
+ model_name: str = "bbpe_tokenizer"
47
+
48
+ def to_dict(self) -> dict:
49
+ """Convert config to dictionary."""
50
+ return asdict(self)
51
+
52
+ def save(self, path: str):
53
+ """Save configuration to JSON file."""
54
+ with open(path, 'w', encoding='utf-8') as f:
55
+ json.dump(self.to_dict(), f, indent=2, ensure_ascii=False)
56
+
57
+ @classmethod
58
+ def load(cls, path: str) -> 'BBPEConfig':
59
+ """Load configuration from JSON file."""
60
+ with open(path, 'r', encoding='utf-8') as f:
61
+ config_dict = json.load(f)
62
+ return cls(**config_dict)
63
+
64
+
65
+ class BBPETrainer:
66
+ """
67
+ End-to-end trainer for Byte-Level BPE tokenizers.
68
+
69
+ This class handles the complete training pipeline including:
70
+ - Data loading and preprocessing
71
+ - Tokenizer initialization with byte-level encoding
72
+ - BPE training with configurable parameters
73
+ - Model saving and loading
74
+ """
75
+
76
+ def __init__(self, config: Optional[BBPEConfig] = None):
77
+ """
78
+ Initialize the BBPE trainer.
79
+
80
+ Args:
81
+ config: BBPEConfig instance. If None, default config is used.
82
+ """
83
+ self.config = config or BBPEConfig()
84
+ self.tokenizer: Optional[ByteLevelBPETokenizer] = None
85
+ self._setup_directories()
86
+
87
+ def _setup_directories(self):
88
+ """Create necessary directories for data and models."""
89
+ Path(self.config.data_dir).mkdir(parents=True, exist_ok=True)
90
+ Path(self.config.model_save_dir).mkdir(parents=True, exist_ok=True)
91
+
92
+ def initialize_tokenizer(self) -> ByteLevelBPETokenizer:
93
+ """
94
+ Initialize a new ByteLevelBPETokenizer with byte-level encoding.
95
+
96
+ Returns:
97
+ Initialized ByteLevelBPETokenizer instance
98
+ """
99
+ tokenizer = ByteLevelBPETokenizer(
100
+ add_prefix_space=self.config.add_prefix_space,
101
+ trim_offsets=self.config.trim_offsets,
102
+ lowercase=self.config.lowercase,
103
+ )
104
+ self.tokenizer = tokenizer
105
+ return tokenizer
106
+
107
+ def get_training_files(self) -> List[str]:
108
+ """
109
+ Get list of text files for training from the data directory.
110
+
111
+ Returns:
112
+ List of file paths to text files
113
+ """
114
+ data_path = Path(self.config.data_dir)
115
+ text_files = []
116
+
117
+ # Support multiple text file extensions
118
+ extensions = ['.txt', '.jsonl', '.json']
119
+
120
+ for ext in extensions:
121
+ text_files.extend(list(data_path.glob(f'*{ext}')))
122
+
123
+ if not text_files:
124
+ raise FileNotFoundError(
125
+ f"No training files found in {data_path}. "
126
+ f"Please add .txt, .json, or .jsonl files to this directory."
127
+ )
128
+
129
+ return [str(f) for f in text_files]
130
+
131
+ def train(self,
132
+ files: Optional[List[str]] = None,
133
+ config_override: Optional[dict] = None) -> ByteLevelBPETokenizer:
134
+ """
135
+ Train the BBPE tokenizer on the provided files.
136
+
137
+ Args:
138
+ files: List of file paths to train on. If None, uses files from data_dir.
139
+ config_override: Optional dictionary to override config parameters.
140
+
141
+ Returns:
142
+ Trained ByteLevelBPETokenizer instance
143
+ """
144
+ # Apply config overrides if provided
145
+ if config_override:
146
+ for key, value in config_override.items():
147
+ if hasattr(self.config, key):
148
+ setattr(self.config, key, value)
149
+
150
+ # Initialize tokenizer if not already done
151
+ if self.tokenizer is None:
152
+ self.initialize_tokenizer()
153
+
154
+ # Get training files
155
+ if files is None:
156
+ files = self.get_training_files()
157
+
158
+ print(f"Training on {len(files)} file(s)...")
159
+ for f in files:
160
+ print(f" - {f}")
161
+
162
+ # Train the tokenizer using the new API (tokenizers >= 0.15)
163
+ print("\nStarting training...")
164
+ self.tokenizer.train(
165
+ files=files,
166
+ vocab_size=self.config.vocab_size,
167
+ min_frequency=self.config.min_frequency,
168
+ special_tokens=self.config.special_tokens,
169
+ show_progress=self.config.show_progress,
170
+ )
171
+ print("Training completed!")
172
+
173
+ # Print vocabulary statistics
174
+ vocab_size = self.tokenizer.get_vocab_size()
175
+ print(f"\nVocabulary size: {vocab_size}")
176
+ print(f"Special tokens: {self.config.special_tokens}")
177
+
178
+ return self.tokenizer
179
+
180
+ def save(self, model_name: Optional[str] = None) -> str:
181
+ """
182
+ Save the trained tokenizer to disk.
183
+
184
+ Args:
185
+ model_name: Name for the saved model. If None, uses config.model_name.
186
+
187
+ Returns:
188
+ Path to the saved model directory
189
+ """
190
+ if self.tokenizer is None:
191
+ raise ValueError("No tokenizer to save. Please train first.")
192
+
193
+ name = model_name or self.config.model_name
194
+ save_path = Path(self.config.model_save_dir) / name
195
+ save_path.mkdir(parents=True, exist_ok=True)
196
+
197
+ # Save tokenizer files
198
+ self.tokenizer.save_model(str(save_path))
199
+
200
+ # Save configuration
201
+ config_path = save_path / "config.json"
202
+ self.config.save(str(config_path))
203
+
204
+ # Save tokenizer.json (full tokenizer state)
205
+ tokenizer_json_path = save_path / "tokenizer.json"
206
+ self.tokenizer.save(str(tokenizer_json_path))
207
+
208
+ print(f"\nTokenizer saved to: {save_path}")
209
+ print(f" - vocab.json")
210
+ print(f" - merges.txt")
211
+ print(f" - config.json")
212
+ print(f" - tokenizer.json")
213
+
214
+ return str(save_path)
215
+
216
+ def load(self, model_path: str) -> ByteLevelBPETokenizer:
217
+ """
218
+ Load a pre-trained tokenizer from disk.
219
+
220
+ Args:
221
+ model_path: Path to the directory containing tokenizer files.
222
+
223
+ Returns:
224
+ Loaded ByteLevelBPETokenizer instance
225
+ """
226
+ model_path = Path(model_path)
227
+
228
+ if not model_path.exists():
229
+ raise FileNotFoundError(f"Model path does not exist: {model_path}")
230
+
231
+ # Try to load tokenizer.json first (preferred method for tokenizers >= 0.15)
232
+ tokenizer_json = model_path / "tokenizer.json"
233
+ if tokenizer_json.exists():
234
+ # Use the generic Tokenizer class to load the full tokenizer state
235
+ base_tokenizer = Tokenizer.from_file(str(tokenizer_json))
236
+ # Wrap it as ByteLevelBPETokenizer for consistent API
237
+ self.tokenizer = ByteLevelBPETokenizer(
238
+ add_prefix_space=self.config.add_prefix_space,
239
+ trim_offsets=self.config.trim_offsets,
240
+ lowercase=self.config.lowercase,
241
+ )
242
+ # Copy the vocabulary and merges from the loaded tokenizer
243
+ self.tokenizer = base_tokenizer
244
+ else:
245
+ # Fall back to loading vocab.json and merges.txt
246
+ vocab_file = model_path / "vocab.json"
247
+ merges_file = model_path / "merges.txt"
248
+
249
+ if not vocab_file.exists() or not merges_file.exists():
250
+ raise FileNotFoundError(
251
+ f"Required files not found in {model_path}. "
252
+ f"Need either tokenizer.json or both vocab.json and merges.txt"
253
+ )
254
+
255
+ self.tokenizer = ByteLevelBPETokenizer.from_file(
256
+ str(vocab_file), str(merges_file)
257
+ )
258
+
259
+ # Load config if exists
260
+ config_file = model_path / "config.json"
261
+ if config_file.exists():
262
+ self.config = BBPEConfig.load(str(config_file))
263
+
264
+ print(f"Tokenizer loaded from: {model_path}")
265
+ return self.tokenizer
266
+
267
+ def encode(self, text: str, **kwargs) -> List[int]:
268
+ """Encode text to token IDs."""
269
+ if self.tokenizer is None:
270
+ raise ValueError("No tokenizer loaded. Please train or load first.")
271
+ return self.tokenizer.encode(text, **kwargs).ids
272
+
273
+ def decode(self, ids: List[int], **kwargs) -> str:
274
+ """Decode token IDs to text."""
275
+ if self.tokenizer is None:
276
+ raise ValueError("No tokenizer loaded. Please train or load first.")
277
+ return self.tokenizer.decode(ids, **kwargs)
278
+
279
+ def tokenize(self, text: str) -> List[str]:
280
+ """Tokenize text to token strings."""
281
+ if self.tokenizer is None:
282
+ raise ValueError("No tokenizer loaded. Please train or load first.")
283
+ return self.tokenizer.encode(text).tokens
284
+
285
+
286
+ def main():
287
+ """Example usage of the BBPE trainer."""
288
+ # Create configuration
289
+ config = BBPEConfig(
290
+ vocab_size=30000,
291
+ min_frequency=2,
292
+ special_tokens=["<pad>", "<unk>", "<s>", "</s>", "<mask>"],
293
+ data_dir="data",
294
+ model_save_dir="models",
295
+ model_name="my_bbpe_tokenizer",
296
+ )
297
+
298
+ # Initialize trainer
299
+ trainer = BBPETrainer(config)
300
+
301
+ # Train the tokenizer
302
+ trainer.train()
303
+
304
+ # Save the tokenizer
305
+ save_path = trainer.save()
306
+
307
+ # Test encoding/decoding
308
+ test_text = "Hello, world! This is a test of the BBPE tokenizer."
309
+ encoded = trainer.encode(test_text)
310
+ decoded = trainer.decode(encoded)
311
+ tokens = trainer.tokenize(test_text)
312
+
313
+ print(f"\nTest encoding:")
314
+ print(f" Input: {test_text}")
315
+ print(f" Tokens: {tokens}")
316
+ print(f" IDs: {encoded}")
317
+ print(f" Decoded: {decoded}")
318
+
319
+
320
+ if __name__ == "__main__":
321
+ main()
scripts/example_usage.py ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ EthioBBPE Example Usage
3
+
4
+ Demonstrates how to use the trained EthioBBPE tokenizer for Ethiopian languages.
5
+ """
6
+
7
+ from tokenizers import Tokenizer
8
+ import os
9
+
10
+ def load_tokenizer(model_path="models/EthioBBPE/tokenizer.json"):
11
+ """Load the trained EthioBBPE tokenizer."""
12
+ if not os.path.exists(model_path):
13
+ # Try demo model
14
+ demo_path = "models/demo_tokenizer/tokenizer.json"
15
+ if os.path.exists(demo_path):
16
+ print(f"⚠️ EthioBBPE model not found, using demo model instead.")
17
+ model_path = demo_path
18
+ else:
19
+ raise FileNotFoundError(
20
+ f"No tokenizer found at {model_path}. Please train a model first."
21
+ )
22
+
23
+ return Tokenizer.from_file(model_path)
24
+
25
+
26
+ def main():
27
+ print("🇪🇹 EthioBBPE Tokenizer - Example Usage\n")
28
+ print("=" * 50)
29
+
30
+ # Load tokenizer
31
+ tokenizer = load_tokenizer()
32
+ print(f"✅ Loaded tokenizer from: {tokenizer.model_filename}\n")
33
+
34
+ # Test texts in multiple Ethiopian languages
35
+ test_texts = [
36
+ ("Amharic", "ሰላም! እንዴት ነህ? የኢትዮጵያ ህዝብ በጣም ተቀራራቢ ነው።"),
37
+ ("Oromo", "Akkam! Akkam jirta? Ummanni Itoophiyaa baay'ee wal-qabaataa dha."),
38
+ ("Tigrinya", "ሰላም! ከመይ ኣለኻ? ህዝቢ ኢትዮጵያ ኣዝዩ ሓደ እዩ።"),
39
+ ("English", "Hello! How are you? The people of Ethiopia are very united."),
40
+ ("Mixed", "ሰላም Hello! እንዴት ነህ? How are you? 🇪🇹"),
41
+ ]
42
+
43
+ for lang_name, text in test_texts:
44
+ print(f"\n--- {lang_name} ---")
45
+ print(f"Original: {text}")
46
+
47
+ # Encode
48
+ encoded = tokenizer.encode(text)
49
+ print(f"Tokens ({len(encoded.tokens)}): {encoded.tokens[:20]}{'...' if len(encoded.tokens) > 20 else ''}")
50
+ print(f"IDs ({len(encoded.ids)}): {encoded.ids[:20]}{'...' if len(encoded.ids) > 20 else ''}")
51
+
52
+ # Decode
53
+ decoded = tokenizer.decode(encoded.ids)
54
+ print(f"Decoded: {decoded}")
55
+
56
+ # Verify round-trip
57
+ match = "✅" if decoded == text else "⚠️"
58
+ print(f"Round-trip: {match} {'Perfect match!' if decoded == text else 'Minor differences'}")
59
+
60
+ print("\n" + "=" * 50)
61
+ print("✨ Example usage complete!")
62
+ print("\nTo train your own EthioBBPE tokenizer:")
63
+ print(" python scripts/train_tokenizer.py --data_dir ./data --model_name EthioBBPE")
64
+
65
+
66
+ if __name__ == "__main__":
67
+ main()
scripts/train_tokenizer.py ADDED
@@ -0,0 +1,205 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """
3
+ Command-line interface for training BBPE tokenizers.
4
+
5
+ Usage:
6
+ python train_tokenizer.py --data_dir ./data --vocab_size 30000 --model_name my_tokenizer
7
+ """
8
+
9
+ import argparse
10
+ import sys
11
+ from pathlib import Path
12
+
13
+ # Add parent directory to path for imports
14
+ sys.path.insert(0, str(Path(__file__).parent))
15
+
16
+ from bbpe_trainer import BBPETrainer, BBPEConfig
17
+
18
+
19
+ def parse_args():
20
+ """Parse command-line arguments."""
21
+ parser = argparse.ArgumentParser(
22
+ description="Train a Byte-Level BPE (BBPE) tokenizer",
23
+ formatter_class=argparse.ArgumentDefaultsHelpFormatter,
24
+ )
25
+
26
+ # Data arguments
27
+ parser.add_argument(
28
+ "--data_dir",
29
+ type=str,
30
+ default="data",
31
+ help="Directory containing training text files (.txt, .json, .jsonl)",
32
+ )
33
+
34
+ parser.add_argument(
35
+ "--files",
36
+ type=str,
37
+ nargs="+",
38
+ default=None,
39
+ help="Specific files to train on (overrides data_dir)",
40
+ )
41
+
42
+ # Model arguments
43
+ parser.add_argument(
44
+ "--vocab_size",
45
+ type=int,
46
+ default=30000,
47
+ help="Target vocabulary size",
48
+ )
49
+
50
+ parser.add_argument(
51
+ "--min_frequency",
52
+ type=int,
53
+ default=2,
54
+ help="Minimum frequency for tokens to be included in vocabulary",
55
+ )
56
+
57
+ parser.add_argument(
58
+ "--special_tokens",
59
+ type=str,
60
+ nargs="+",
61
+ default=["<pad>", "<unk>", "<s>", "</s>", "<mask>"],
62
+ help="Special tokens to add to the vocabulary",
63
+ )
64
+
65
+ # Training options
66
+ parser.add_argument(
67
+ "--lowercase",
68
+ action="store_true",
69
+ help="Convert text to lowercase before tokenization",
70
+ )
71
+
72
+ parser.add_argument(
73
+ "--no_prefix_space",
74
+ action="store_true",
75
+ help="Disable adding prefix space (default: add prefix space)",
76
+ )
77
+
78
+ parser.add_argument(
79
+ "--show_progress",
80
+ action="store_true",
81
+ default=True,
82
+ help="Show training progress bar",
83
+ )
84
+
85
+ parser.add_argument(
86
+ "--no_progress",
87
+ action="store_false",
88
+ dest="show_progress",
89
+ help="Hide training progress bar",
90
+ )
91
+
92
+ # Output arguments
93
+ parser.add_argument(
94
+ "--model_save_dir",
95
+ type=str,
96
+ default="models",
97
+ help="Directory to save the trained tokenizer",
98
+ )
99
+
100
+ parser.add_argument(
101
+ "--model_name",
102
+ type=str,
103
+ default="bbpe_tokenizer",
104
+ help="Name for the saved tokenizer model",
105
+ )
106
+
107
+ # Config file arguments
108
+ parser.add_argument(
109
+ "--config_file",
110
+ type=str,
111
+ default=None,
112
+ help="Path to JSON config file (overrides other arguments)",
113
+ )
114
+
115
+ parser.add_argument(
116
+ "--save_config",
117
+ type=str,
118
+ default=None,
119
+ help="Path to save the configuration JSON file",
120
+ )
121
+
122
+ return parser.parse_args()
123
+
124
+
125
+ def main():
126
+ """Main entry point for CLI training."""
127
+ args = parse_args()
128
+
129
+ # Load config from file if provided
130
+ if args.config_file:
131
+ print(f"Loading configuration from {args.config_file}")
132
+ config = BBPEConfig.load(args.config_file)
133
+ else:
134
+ # Create config from arguments
135
+ config = BBPEConfig(
136
+ vocab_size=args.vocab_size,
137
+ min_frequency=args.min_frequency,
138
+ special_tokens=args.special_tokens,
139
+ lowercase=args.lowercase,
140
+ add_prefix_space=not args.no_prefix_space,
141
+ show_progress=args.show_progress,
142
+ data_dir=args.data_dir,
143
+ model_save_dir=args.model_save_dir,
144
+ model_name=args.model_name,
145
+ )
146
+
147
+ # Save config if requested
148
+ if args.save_config:
149
+ config.save(args.save_config)
150
+ print(f"Configuration saved to {args.save_config}")
151
+
152
+ # Initialize trainer
153
+ trainer = BBPETrainer(config)
154
+
155
+ # Get training files
156
+ if args.files:
157
+ print(f"Using specified files: {args.files}")
158
+ files = args.files
159
+ else:
160
+ files = None # Will use files from data_dir
161
+
162
+ # Train the tokenizer
163
+ try:
164
+ trainer.train(files=files)
165
+ except FileNotFoundError as e:
166
+ print(f"\nError: {e}")
167
+ print("\nTo fix this:")
168
+ print(f" 1. Add your training data to the '{args.data_dir}' directory")
169
+ print(" 2. Supported formats: .txt, .json, .jsonl")
170
+ print(" 3. Or specify files directly with --files flag")
171
+ sys.exit(1)
172
+
173
+ # Save the tokenizer
174
+ save_path = trainer.save()
175
+
176
+ # Test the tokenizer
177
+ print("\n" + "="*60)
178
+ print("TESTING TOKENIZER")
179
+ print("="*60)
180
+
181
+ test_texts = [
182
+ "Hello, world!",
183
+ "This is a test of the BBPE tokenizer.",
184
+ "Special characters: @#$%^&*()",
185
+ "Numbers: 12345 and words mixed together.",
186
+ ]
187
+
188
+ for text in test_texts:
189
+ encoded = trainer.encode(text)
190
+ tokens = trainer.tokenize(text)
191
+ decoded = trainer.decode(encoded)
192
+
193
+ print(f"\nInput: {text}")
194
+ print(f"Tokens: {tokens}")
195
+ print(f"IDs: {encoded[:20]}{'...' if len(encoded) > 20 else ''}")
196
+ print(f"Decoded: {decoded}")
197
+
198
+ print("\n" + "="*60)
199
+ print(f"Tokenizer training complete!")
200
+ print(f"Model saved to: {save_path}")
201
+ print("="*60)
202
+
203
+
204
+ if __name__ == "__main__":
205
+ main()