meet5568 commited on
Commit
9f2ce12
·
verified ·
1 Parent(s): ce06ff0

Model card

Browse files
Files changed (1) hide show
  1. README.md +84 -0
README.md ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - hi
4
+ - ne
5
+ license: apache-2.0
6
+ tags:
7
+ - tokenizer
8
+ - sentencepiece
9
+ - devanagari
10
+ - hindi
11
+ - nepali
12
+ ---
13
+
14
+ # LMA Phase 1 — Hindi and Nepali tokenizers
15
+
16
+ Two independent sentencepiece tokenizers, one per language, trained from
17
+ scratch for a pair of ~25M-parameter decoder-only Transformers.
18
+
19
+ **They share nothing** — not merges, not pieces, not a vocabulary file. Hindi
20
+ and Nepali both use the Devanagari block (U+0900–U+097F), so keeping the two
21
+ corpora and the two vocabularies separate is the central constraint of the
22
+ project rather than an afterthought.
23
+
24
+ | language | algorithm | vocab | trained on | corpus tokens |
25
+ |---|---|---|---|---|
26
+ | Hindi | unigram | 10,000 | 2,016,377 of 4,032,755 lines (50%, sampled at random) | 655.2M |
27
+ | Nepali | unigram | 10,000 | 2,539,821 of 5,079,643 lines (50%, sampled at random) | 558.9M |
28
+
29
+ ## How these were chosen
30
+
31
+ Twenty models were compared: five vocabulary sizes (8k, 10k, 12k, 14k, 16k)
32
+ across two algorithms (BPE, unigram), for both languages. Every model read the
33
+ same 10% random sample of its language's training split, so differences between
34
+ them are differences between models rather than between samples.
35
+
36
+ **Unigram beat BPE at every vocabulary size in both languages** — ten paired
37
+ comparisons, no exceptions, by 1.2–2.7% fertility.
38
+
39
+ **Vocabulary 10,000 was selected over 16,000** despite 16k tokenizing better.
40
+ The embedding matrix is `vocab_size × 512` parameters against a 25M budget, so
41
+ 16k spends 33% of the whole model on a lookup table while 10k spends 20%. The
42
+ selection rule is the smallest vocabulary whose fertility is within 8% of the
43
+ best, which trades ~5–7% fertility for ~3.1M parameters returned to the
44
+ transformer layers.
45
+
46
+ **Hindi** — fertility 1.3250 tokens/word, 3.7749 chars/token, 0 UNK, 0.289% byte-fallback, 201 unused pieces.
47
+ **Nepali** — fertility 1.4620 tokens/word, 4.5208 chars/token, 0 UNK, 0.178% byte-fallback, 239 unused pieces.
48
+
49
+ **UNK is impossible.** `byte_fallback=True` decomposes any unseen character
50
+ into byte tokens, so the UNK count is zero by construction rather than by luck.
51
+
52
+ ## Training data
53
+
54
+ | | Hindi | Nepali |
55
+ |---|---|---|
56
+ | final corpus | 5,094,185 docs / 2.588B chars | 6,755,888 docs / 2.513B chars |
57
+ | training split | 3,564,832 docs / 1.798B chars | 4,726,832 docs / 1.752B chars |
58
+
59
+ Splits are document-level, stratified by source, 70/15/15 by characters, with
60
+ one whole source held out per language as an unseen-domain test set. The
61
+ tokenizers saw the training split only.
62
+
63
+ The corpora are at
64
+ [meet5568/lma_datasets](https://huggingface.co/datasets/meet5568/lma_datasets).
65
+
66
+ ## Usage
67
+
68
+ ```python
69
+ import sentencepiece as spm
70
+ from huggingface_hub import hf_hub_download
71
+
72
+ path = hf_hub_download("meet5568/lma_models", "tokenizer/hindi/hi_tokenizer.model")
73
+ sp = spm.SentencePieceProcessor(model_file=path)
74
+ print(sp.encode("भारत एक विशाल देश है।", out_type=str))
75
+ ```
76
+
77
+ ## Limitations
78
+
79
+ Unigram's memory scales with total corpus length — it builds a suffix array
80
+ over every character — at roughly 10.6 GB of RAM per GB of text, measured. The
81
+ full training split would need about 49 GB, so the final unigram models were
82
+ trained on 50% of it. A control experiment found fertility differing in the
83
+ fourth decimal place between 81.6% and 100% of the lines, so this is a hardware
84
+ limit rather than a quality one, but it is stated rather than implied.