trocr-tunisian-arabic โ€” handwritten Tunisian Arabic recognition

A TrOCR vision-encoder/decoder fine-tuned for handwritten Tunisian Arabic, with a 30k-token Arabic-native vocabulary.

Why this exists

Cloud OCR services handle printed Arabic reasonably and handwritten dialectal Arabic poorly. For the use case this was built for, they were not an option at all: Tunisian legal documents contain privileged client data that cannot leave the premises under the country's data-protection regime. That ruled out every managed service and required a model that runs fully offline.

Intended use

Offline extraction of handwritten Arabic from structured forms.

Built for and deployed in Wathiqa, which turns handwritten Tunisian legal forms into structured, searchable client records without any cloud dependency.

This is a word-level model. In Wathiqa it sits behind a segmentation stage: the ink mask is dilated horizontally by a kernel scaled to text height โ€” Arabic joins letters within a word but not between words, so inter-word gaps are the reliable separator โ€” and the resulting components are read right to left. Feeding a full unsegmented line will not work well.

Usage

Where it sits in a real pipeline

Wathiqa routes each field type to a purpose-built engine rather than asking one model to cover everything:

Field type Engine
Arabic text, names, notes This model
CIN, passport, number, phone, date Dedicated digit recogniser with a constrained alphabet and shape validation
Printed captions EasyOCR (Arabic + Latin)
Checkboxes Fill-ratio detector
Signatures Ink-presence detector

That routing exists because these are genuinely different problems, and the limitations below are the reason.

Limitations

  • Trained on isolated words, not lines or sentences. Word segmentation is the caller's responsibility.
  • Not for digits. Numeric fields need a separate path โ€” a word model asked for a digit string produces confident nonsense. Wathiqa isolates characters, constrains the alphabet to 0-9 and separators, then validates the assembled value against the field's expected shape.
  • Not for printed text. Printed captions are a different problem and route elsewhere.
  • A blank crop returns confident nonsense rather than silence. Empty-field detection must happen before the model is called; Wathiqa reports fields with no ink as empty and never sends them to a model.
  • Trained on Tunisian handwriting. Performance on other regional Arabic hands is untested.

Training

Fine-tuned from microsoft/trocr-base-handwritten on handwritten Tunisian Arabic, with the decoder vocabulary replaced by a 30k-token Arabic-native vocabulary.

Related work

Model Purpose
Ghazouaniwala/emotions_speech Speaker-independent speech emotion recognition
Ghazouaniwala/silma-tts-derja Tunisian Derja speech synthesis

Citation

@misc{ghazouani2025trocrtunisian,
  author = {Ghazouani, Wala Eddine},
  title  = {trocr-tunisian-arabic: handwritten Tunisian Arabic recognition},
  year   = {2025},
  url    = {https://huggingface.co/Ghazouaniwala/trocr-tunisian-arabic}
}

Built by Wala Eddine Ghazouani ยท GitHub ยท LinkedIn

Downloads last month
4
Safetensors
Model size
0.5B params
Tensor type
F32
ยท
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Model tree for Ghazouaniwala/trocr-tunisian-arabic

Finetuned
(49)
this model