sidskarki commited on
Commit
8d4c971
·
verified ·
1 Parent(s): 35caf15

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +50 -0
README.md ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ language:
4
+ - ne
5
+ - en
6
+ tags:
7
+ - nepali
8
+ - devanagari
9
+ - tokenizer
10
+ - tokenizer-extension
11
+ ---
12
+
13
+ # Phi-4 — Nepali Extended Tokenizer
14
+
15
+ Extended tokenizer for Phi-4 with ~15K added high-value Nepali/Devanagari tokens.
16
+
17
+ ## Token Efficiency
18
+
19
+ | | Nepali tok/word |
20
+ |---|---:|
21
+ | Original Phi-4 | 7.10 |
22
+ | **Extended (this)** | **3.41** |
23
+ | **Reduction** | **51.9%** |
24
+
25
+ ## How It Was Built
26
+
27
+ 1. Trained a 32K SentencePiece BPE tokenizer on a 7.49GB cleaned Nepali corpus
28
+ 2. Selected tokens that the Phi-4 base tokenizer splits into 3+ subtokens (delta vocabulary approach)
29
+ 3. Added ~15K high-value Nepali tokens to the base tokenizer
30
+
31
+ The extended tokenizer is a drop-in replacement for the original. To use the new tokens effectively, the model needs continued pretraining on Nepali text (see the [Qwen3-4B Nepali model](https://huggingface.co/sidskarki/qwen3-4b-nepali) for a full CPT+SFT example).
32
+
33
+ ## Usage
34
+
35
+ ```python
36
+ from transformers import AutoTokenizer
37
+
38
+ tokenizer = AutoTokenizer.from_pretrained("sidskarki/phi4-nepali-tokenizer")
39
+ tokens = tokenizer.tokenize("नेपालको राजधानी काठमाडौं हो")
40
+ print(tokens, len(tokens))
41
+ ```
42
+
43
+ ## Context
44
+
45
+ Part of a [17-model Nepali tokenizer benchmark](https://siddhantskarki.com/case-studies/nepali-tokenizer) measuring the Nepali token tax across modern LLM tokenizers.
46
+
47
+ ## Links
48
+
49
+ - **Code:** [github.com/sidskarkii/nepali-tokenizer](https://github.com/sidskarkii/nepali-tokenizer)
50
+ - **Case study:** [siddhantskarki.com/case-studies/nepali-tokenizer](https://siddhantskarki.com/case-studies/nepali-tokenizer)