# Maatru

*Released.* Bidirectional Tanglish ↔ Tamil conversion & spoken text normalization, version 1, 4 December 2026.

Maatru (மாற்று, change) is a 300M-parameter byte-level sequence-to-sequence model (`google/byt5-small`) that converts Tanglish to Tamil script, Tamil script to readable Tanglish, and written Tamil numbers, currency, dates and units into spoken Tamil words, all in one model with zero `<unk>` tokens.

[Download on Hugging Face](https://huggingface.co/zhagaramlabs/maatru-v1) [Dataset on Hugging Face](https://huggingface.co/datasets/zhagaramlabs/maatru-tanglish-pairs) [Code on GitHub](https://github.com/zhagaramlabs/lab/blob/main/scripts/train_maatru_v1.py)

- **3.10%** CER on Tanglish to Tamil (`rom2ta:`), ~96.9% character accuracy on unseen sentences
- **0.008%** CER on Tamil to Tanglish (`ta2rom:`), with 99.33% exact match
- **100.0%** digit-free output on spoken text normalization (`norm:`), at 1.95% CER

## 1. Use it

Prefix each input with `rom2ta:` (Tanglish to Tamil), `ta2rom:` (Tamil to Tanglish), or `norm:` (written Tamil to spoken words). It loads directly with Hugging Face `transformers`.

```python
import torch
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM

model_id = "zhagaramlabs/maatru-v1"
tok = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForSeq2SeqLM.from_pretrained(model_id, dtype=torch.bfloat16)

prompts = [
    "rom2ta: vanakkam, naalaikku office meeting patthu manikku.",
    "ta2rom: தமிழ் மொழி மிகவும் இனிமையானது.",
    "norm: இந்த மாதம் மின்கட்டணம் ₹1,250. கடைசி தேதி 15/08/2026.",
]
inputs = tok(prompts, return_tensors="pt", padding=True)
out = model.generate(**inputs, max_new_tokens=256)
for p, y in zip(prompts, tok.batch_decode(out, skip_special_tokens=True)):
    print(p, "=>", y)
```

## 2. Why byte-level

Everyday Tanglish has no fixed spelling: the same person writes `vanakam`, `vannakkam` and `vanakkam`, drops vowel lengths, and mixes `zh`, `l` and `z`. Subword tokenizers fragment unseen spellings and split Tamil Unicode characters mid-letter.

Because ByT5 reads and writes UTF-8 bytes directly, Maatru never emits `<unk>` and handles arbitrary spelling variants, code-mixed English words, punctuation and numeric formats inside a single 300M-parameter model.

## 3. Uraikal Track E results

Evaluated on 1,500 strictly unseen test sentences (0% normalized-text overlap with training, D4 benchmark denylisted):

| Task | Prefix | Sentences | CER | Full-sentence exact match | Notes |
|---|---|---:|---:|---:|---|
| E1: Tanglish → Tamil | `rom2ta:` | 600 | **3.10%** | 29.5% | ~96.9% char accuracy |
| E2: Tamil → Tanglish | `ta2rom:` | 600 | **0.008%** | **99.33%** | Near-exact |
| E3: Written → spoken Tamil | `norm:` | 300 | **1.95%** | **87.33%** | **100.0% digit-free** |
| **Overall Track E** | all | 1,500 | **1.58%** | **69.0%** | 11.3 sentences/sec (H100 bf16) |

## 4. How it was built

- **Base model.** `google/byt5-small` (Apache 2.0, 300M parameters).
- **Data.** [maatru-tanglish-pairs](https://huggingface.co/datasets/zhagaramlabs/maatru-tanglish-pairs): 60,500 examples (58,000 train, 1,000 validation, 1,500 test) drawn from Sangraha, Project Madurai, IndicTTS, Thirukkural and `uraikal.tn` spoken-normalization pairs, deduplicated by normalized Tamil text with 0% overlap across splits and D4 denylisted.
- **Phonetic verification.** Every `(tamil, tanglish)` pair passes `uraikal.phonetic.cross_script_similarity >= 0.80` (mean 0.954).
- **Compute.** 3 epochs, effective batch size 64 (`32 × 2`), learning rate `3e-4`, `bf16` on 1 NVIDIA H100 (~15 minutes).

## 5. Limits

- Full-sentence exact match on `rom2ta:` is 29.5% even though character accuracy is ~96.9%, because Tamil has valid orthographic variants (such as `ல`/`ள`/`ழ` and `ன`/`ண`/`ந`) where ambiguous romanizations like `na` or `la` can map to more than one word without broader context.
- Tanglish inputs in the training set were generated with controlled spelling noise rather than mined from real messaging logs.
- As a byte-level encoder-decoder, inference is slower on very long paragraphs than subword models; pass sentences or short utterances for lowest latency.

## 6. Licence and citation

- **Weights and code:** Apache 2.0 (matching `google/byt5-small`). Training script in [lab](https://github.com/zhagaramlabs/lab/blob/main/scripts/train_maatru_v1.py).
- **Dataset:** CC BY 4.0, at [zhagaramlabs/maatru-tanglish-pairs](https://huggingface.co/datasets/zhagaramlabs/maatru-tanglish-pairs).

```bibtex
@misc{maatru2026,
  title  = {Maatru v1: Bidirectional Tanglish-Tamil Conversion and Spoken Text Normalization},
  author = {{Zhagaram Labs}},
  year   = {2026},
  url    = {https://zhagaramlabs.com/models/maatru/}
}
```

## 7. Versions

| Version | Released | What changed |
|---|---|---|
| 1 | 4 December 2026 | First release: 300M ByT5-small model covering `rom2ta:`, `ta2rom:` and `norm:` in one checkpoint. |

## Related

- [Thedal](/models/thedal/), our cross-script Tamil and Tanglish retrieval embedding model.
- [All our models](/#models), released and in progress.
