Meenakshi: Tamil Handwritten Word OCR
Meenakshi reads single handwritten Tamil words from images. It is a fine-tuned version of Microsoft's trocr-large-handwritten with a Tamil character-level decoder vocabulary.
Scope: word-level only. It reads one cropped word at a time, not a line or a page. See Limitations.
Results
Evaluated on the held-out test split (16,184 word images), never used for training or checkpoint selection.
| Metric | Value |
|---|---|
| Character Error Rate (CER) | 1.04% |
| Character accuracy (1 − CER) | 98.96% |
| Word accuracy (exact match) | 93.06% |
Word accuracy counts a word correct only if every character matches, so it is a stricter number than character accuracy.
Checkpoint selection. Training ran for 17,000 steps (~14.4 epochs) before early stopping ended it; the checkpoint kept is step 9,000 (~7.6 epochs), the point of lowest validation CER:
| Step | Epoch | Validation CER | Validation word accuracy |
|---|---|---|---|
| 9,000 (released) | 7.60 | 1.10% | 92.53% |
| 11,000 | 9.29 | 1.24% | 91.85% |
| 12,000 | 10.14 | 1.29% | 91.75% |
| 15,000 | 12.67 | 1.20% | 92.33% |
| 16,000 | 13.51 | 1.55% | 89.65% |
| 17,000 | 14.36 | 1.45% | 90.48% |
Validation CER after step 9,000 stayed within 1.1–1.6% without a sustained improvement, which is why training stopped there.
Model details
| Architecture | VisionEncoderDecoderModel: ViT-Large image encoder (24 layers, hidden size 1024, 384×384 input) + 12-layer TrOCR decoder |
| Base model | microsoft/trocr-large-handwritten |
| Tokenizer | Custom character-level tokenizer built from the training data: 70 characters from the Tamil Unicode block, plus a hyphen, plus 4 special tokens (vocabulary size 75) |
| Max output length | 48 tokens |
| Language | Tamil (ta) |
| Input | An image of one handwritten word |
| Output | The Tamil text of that word |
The encoder and decoder transformer layers are initialized from the English TrOCR checkpoint; the decoder's embedding and output layers were resized and re-learned for the Tamil character vocabulary.
Training data
Trained on the Tamil portion of IIIT-INDIC-HW-WORDS:
| Split | Word images |
|---|---|
| Train | 75,736 |
| Validation | 11,598 |
| Test | 16,184 |
A fixed vocabulary of 13,294 Tamil words is used as a lookup table: each image's ground truth in the source files is a numeric index into this list rather than the word text itself. Average image size is about 1120×288 pixels (median in this run: 1569×293; the median width:height ratio is 5.6:1, noticeably wider than typical word crops, since TrOCR resizes every image to a square before reading it).
Training procedure
- Method: full fine-tuning (all encoder and decoder weights updated), not LoRA
- Hardware:
- Per-GPU batch size: 32 (global batch size 64 across 2 GPUs)
- Learning rate: 3e-5, 10% warmup, linear decay
- Label handling: an explicit end-of-sequence token is appended to every label so the model learns when to stop generating
- Checkpointing: evaluated every 1,000 steps on validation CER; the best checkpoint by CER was kept; training stopped automatically after 6 epochs without improvement
- Decoding used for the reported results: beam search, 5 beams, max length 48,
no_repeat_ngram_size=0(character tokens legitimately repeat, so n-gram blocking is disabled) - Image preprocessing: no aspect-ratio padding. A short pilot compared padding word images toward a 2:1 width:height ratio against leaving them as-is before TrOCR's standard resize to a 384×384 square; at matching training budgets, padding gave a higher CER (1.99% vs. 1.77% at epoch ~1.9; 1.76% vs. 1.52% on the test split), so the released model uses unpadded images.
How to use
import torch
from PIL import Image
from transformers import TrOCRProcessor, VisionEncoderDecoderModel
repo_id = "Artificial-Soul/meenakshi_tamil_trocr"
device = "cuda" if torch.cuda.is_available() else "cpu"
processor = TrOCRProcessor.from_pretrained(repo_id)
model = VisionEncoderDecoderModel.from_pretrained(repo_id).to(device).eval()
image = Image.open("word.jpg").convert("RGB") # a crop containing ONE word
pixel_values = processor(images=image, return_tensors="pt").pixel_values.to(device)
with torch.no_grad():
generated_ids = model.generate(pixel_values, max_length=48, num_beams=5)
print(processor.batch_decode(generated_ids, skip_special_tokens=True)[0])
You may see a warning that encoder.pooler.* weights are newly initialized. This is harmless: TrOCR never uses that layer.
Limitations
- Single words only. Feeding this model a sentence, line, or paragraph image gives poor output, because the image encoder squeezes the whole image to a fixed 384×384 input and the model has never seen multi-word images.
- Wide word crops are compressed. Tamil words in this dataset are often quite wide relative to their height (median 5.6:1). The fixed-size square resize compresses that width substantially, which can blur fine distinctions between visually similar characters. Padding images toward a less extreme aspect ratio before resizing was tried and made results worse (see Training procedure), so do not pad images before passing them to this model — feed crops as-is.
- Evaluation is in-distribution. The reported numbers come from the IIIT-INDIC-HW-WORDS test split. Accuracy on other handwriting styles, scan qualities, or words very different from the training vocabulary (e.g. rare proper nouns) has not been measured and may be lower.
- Not for unsupervised use on high-stakes documents. Even at over 98% character accuracy, errors occur. For legal, official, or financial records, keep a human review step.
Using Meenakshi on full documents
To read a full page, run a text/line detector first, split the page into lines, split each line into words, and pass each word crop to this model. Join words with spaces and lines with newlines.
Intended use
Tamil handwritten word recognition for research, education, and as the recognition stage of a larger document-digitization pipeline, or as a base for further fine-tuning on domain-specific handwriting.
Acknowledgements
- Microsoft Research for TrOCR and the pretrained
trocr-large-handwrittencheckpoint. - Santhoshini Gongidi and C V Jawahar (CVIT, IIIT Hyderabad) for the IIIT-INDIC-HW-WORDS dataset.
- Compute:
Licensing note
Model weights are released under the MIT license, matching the base TrOCR model. Please also check the IIIT-INDIC-HW-WORDS dataset's own terms before redistributing derived work.
Citation
If you use this model, please cite the dataset and the original TrOCR paper.
@inproceedings{gongidi2021indichw,
title = {INDIC-HW-WORDS: A Dataset for Indic Handwritten Text Recognition},
author = {Gongidi, Santhoshini and Jawahar, C V},
booktitle = {International Conference on Document Analysis and Recognition (ICDAR)},
year = {2021}
}
@inproceedings{li2023trocr,
title = {TrOCR: Transformer-based Optical Character Recognition with Pre-trained Models},
author = {Li, Minghao and Lv, Tengchao and Chen, Jingye and Cui, Lei and Lu, Yijuan and Florencio, Dinei and Zhang, Cha and Li, Zhoujun and Wei, Furu},
booktitle = {Proceedings of the AAAI Conference on Artificial Intelligence},
year = {2023},
url = {https://arxiv.org/abs/2109.10282}
}