--- license: cc-by-nc-nd-4.0 language: - en - hi - kn - ta - te - ml - mr - es - zh - ar - ru pipeline_tag: token-classification tags: - tokenizer - bpe - multilingual - indic-languages - luna - text-generation --- # LUNA 1B Tokenizer (Asterizer) The **multilingual BPE tokenizer family** for the LUNA-1B model — a custom, Indic-aware tokenizer ("Asterizer") trained on the 240 GB LUNA multilingual corpus. It ships in three vocabulary sizes: **128K**, **64K**, and **8K**. This is the successor to the original [LUNA-Tokenizer](https://huggingface.co/ASTERIZER/LUNA-Tokenizer) (EleutherAI/Pythia-160m GPT-NeoX, vocab 50,304), which powers the smaller LUNA-100M / LUNA-300M models. ## Why a new tokenizer The original GPT-NeoX tokenizer — like `cl100k_base` — is **English-optimized**. On Indic scripts (Kannada, Tamil, Telugu, Malayalam, Hindi) it fragments a single script character into multiple tokens, bloating sequence length and wasting compute. The Asterizer tokenizer is trained on a multilingual corpus, so it compresses Indic text dramatically better **while staying at parity on English and code**. --- ## Benchmark — multilingual compression Measured on a fixed **15-language probe set** (English, Hindi, Kannada, Tamil, Telugu, Malayalam, Marathi, Kanglish, Python, JavaScript, Spanish, Chinese, Arabic, Russian) — **2,144 bytes total**. **Lower tokens = better.** ### Totals | Tokenizer | Vocab | Total tokens | Bytes/token | vs GPT-NeoX | |---|---|---:|---:|---:| | **GPT-NeoX 50K (old LUNA)** | 50,304 | 945 | 2.27 | 1.00× (baseline) | | **Asterizer 128K** | 128K | **335** | **6.40** | **2.82× (−65%)** | | **Asterizer 64K** | 64K | **392** | **5.47** | **2.41× (−58%)** | | **o200k_base** (GPT-4o) | 200K | 350 | 6.13 | 2.70× (−63%) | | **cl100k_base** (GPT-3.5/4) | 100K | 925 | 2.32 | 1.02× (−2%) | **Headline:** Asterizer 128K compresses multilingual text **2.8× better** than the old LUNA tokenizer, and even **edges out OpenAI's o200k_base** (335 vs 350 tokens) on this Indic-heavy set. `cl100k_base` is just as poor as the old tokenizer on Indic scripts. ### Per-language tokens (lower = better) | Language | GPT-NeoX 50K | Asterizer 128K | Asterizer 64K | o200k_base | cl100k_base | |---|---:|---:|---:|---:|---:| | English (general) | 18 | 20 | 22 | 17 | 18 | | English (technical) | 19 | 19 | 22 | 18 | 18 | | Hindi | 79 | **25** | 30 | 23 | 81 | | **Kannada** | 185 | **26** | 34 | 37 | 185 | | **Tamil** | 107 | **20** | 22 | 30 | 108 | | **Telugu** | 109 | **18** | 21 | 31 | 122 | | **Malayalam** | 134 | **20** | 23 | 29 | 135 | | Marathi | 69 | 26 | 32 | 26 | 67 | | Kanglish (Latin-script) | 29 | 27 | 27 | 25 | 26 | | Python | 33 | 29 | 31 | 26 | 25 | | JavaScript | 27 | 27 | 29 | 23 | 21 | | Spanish | 22 | 19 | 24 | 15 | 19 | | Chinese | 37 | 18 | 24 | 20 | 29 | | Arabic | 39 | 20 | 22 | 15 | 39 | | Russian | 38 | 21 | 29 | 15 | 32 | ### Indic-language improvement (old → 128K) | Language | Old tokens | 128K tokens | Compression | |---|---:|---:|---:| | **Kannada** | 185 | 26 | **7.1× fewer** | | **Malayalam** | 134 | 20 | **6.7× fewer** | | **Telugu** | 109 | 18 | **6.1× fewer** | | **Tamil** | 107 | 20 | **5.4× fewer** | | **Hindi** | 79 | 25 | **3.2× fewer** | | **Marathi** | 69 | 26 | **2.7× fewer** | ### English & code — not degraded The efficiency gain on Indic scripts does **not** come at the cost of English or code: - **English general:** 20 tokens (128K) vs 18 (old) — within 2 tokens, negligible. - **English technical:** 19 vs 19 — exact parity. - **Python:** 29 (128K) vs 33 (old) — Asterizer is **better**. - **JavaScript:** 27 vs 27 — parity. --- ## Wider baseline comparison (8K smoke run, 55 probes) The 8K build's fertility report benchmarks Asterizer against six industry tokenizers on `mean_bytes_per_token` over a 20 MB corpus sample (higher = better compression): | Tokenizer | Mean bytes/token | |---|---:| | o200k_base | 4.73 | | Gemma2 | 4.18 | | Llama3 | 3.20 | | Qwen2.5 | 3.15 | | **Sarvam (Indic)** | 2.89 | | **Asterizer** | 2.87 | | cl100k_base | 2.69 | Asterizer is competitive with the Indic-specialized **Sarvam** tokenizer — winning **34 of 55** head-to-head probes against it — while far exceeding `cl100k_base` on Indic text. --- ## Files | Directory | Vocab | Contents | |---|---|---| | `128K/` | 128K | `tokenizer.json`, `tokenizer_config.json`, `special_tokens_map.json`, `fertility_report.json`, `manifest.json` | | `64K/` | 64K | same bundle | | `8K/` | 8K | same bundle | ### Tokenizer features - **Class:** `PreTrainedTokenizerFast` (Hugging Face `tokenizers`) - **Type:** BPE (byte-level), trained with `asterizer` v1.0 (seed 42) - **Corpus:** 240 GB LUNA multilingual corpus (41.8M documents, 213.7 GB) - **Special tokens:** `<|bos|>`, `<|endoftext|>`, `<|pad|>`, plus 29 chat/tool/FIM/multimodal tokens (`<|im_start|>`, `<|tool_call|>`, `<|fim_prefix|>`, `<|image|>`, etc.) - **Chat template:** ChatML-style (`<|im_start|>` / `<|im_end|>`) - **`model_max_length`:** 1,048,576 ## Usage ```python from transformers import AutoTokenizer tok = AutoTokenizer.from_pretrained("ASTERIZER/LUNA-1B-Tokenizer", subfolder="128K") ids = tok.encode("ಇದು ಕನ್ನಡ ಭಾಷೆಯ ಪರೀಕ್ಷಾ ವಾಕ್ಯ.") print(tok.decode(ids)) ``` ## Related - [LUNA-Tokenizer](https://huggingface.co/ASTERIZER/LUNA-Tokenizer) — original small tokenizer (100M/300M) - [LUNA-1B Tokenizer Collection](https://huggingface.co/collections/ASTERIZER/luna-1b-tokenizer-6a9123d33ef778aa988fde53) - [ASTERIZER](https://huggingface.co/ASTERIZER) ## License `other` — the tokenizer artifacts derive from the LUNA multilingual corpus; verify upstream corpus terms before redistribution.