# Tamil Token-Cost Calculator

Interactive zero-backend calculator to compare estimated token counts, tokens per word, relative fertility, and API cost per 1M words across major tokenizers on Tamil, Tanglish, or mixed Tamil+English text.

- Interactive tool: https://zhagaramlabs.com/tools/token-cost/
- P1 paper (19 open tokenizers on D4): https://zhagaramlabs.com/papers/tamil-tokenizers/
- P4 paper (Qwen3.5 + Ta-32k extension): https://zhagaramlabs.com/papers/qwen-tamil-extension/
- Ezhuthu-64k model card: https://zhagaramlabs.com/models/ezhuthu/

## Calibration data (D4.web / D4.literature)

Exact word count, Tamil letter (எழுத்து) count, UTF-8 byte length, and Qwen3 `\p{L}+` pre-tokenizer cuts are computed directly in the browser. Per-tokenizer token counts and API costs are client-side estimates calibrated to Zhagaram Labs' D4 benchmark (`uraikal/results/d4.json`, `tokenizer_d4_fresh.json`, and P4 Table 2).

| Tokenizer | Vocab | D4.web tok/word | D4.literature tok/word | Pre-tok cut (web) | Byte cut (web) | Source |
|---|---:|---:|---:|---:|---:|---|
| Qwen3.5 + Ta-32k (ours) | 280k | 1.67 | 1.93 | 0.0% | 0.0% | P4 measured |
| Agaram-2.5B | 64k | 1.68 | 1.93 | 0.0% | <0.1% | D4 measured |
| Ezhuthu-64k (ours) | 64k | 1.78 | 1.97 | 0.0% | 0.0% | D4 measured |
| Gemma 3 | 262k | 2.44 | 2.69 | 0.0% | <0.1% | D4 measured |
| Sarvam-30B | 262k | 2.44 | 2.69 | 0.0% | <0.1% | D4 measured |
| GPT-4o (o200k) | 200k | 3.19 | 3.41 | 0.0% | 2.2% | D4 (`openai/gpt-oss-20b`) |
| Qwen3.5 (stock) | 248k | 4.28 | 4.34 | 0.0% | 3.2% | D4 measured |
| Claude (API ref.) | — | ~4.60 | ~4.75 | — | — | Closed-source reference estimate |
| DeepSeek-V3 | 129k | 4.96 | 4.94 | <0.1% | 21.8% | D4 measured |
| Qwen3 | 152k | 9.99 | 10.02 | 98.8% | 99.5% | D4 measured |
| Llama 3.1 | 128k | 12.19 | 12.26 | 98.8% | 100.0% | D4 measured |

For exact local measurements on any Hugging Face tokenizer, install `uraikal`:

```bash
pip install "uraikal[tokenizers]"
```
