Custom OCR for hard scripts: reading Urdu-Nastaliq when off-the-shelf models fail
Some scripts break standard OCR completely. Here is what it took to train a custom Urdu-Nastaliq model that actually reads, and why we open-sourced it.
Rapit Labs · Machine Learning
Most OCR is a solved problem right up until it is not. Feed a standard engine clean printed English and it sings. Feed it Urdu written in the Nastaliq style and it returns garbage: a stream of characters that no reader would recognise. That is the problem we ran into building Nawadiraat, a multilingual literature platform, and it is a good example of when off-the-shelf AI simply is not enough.
Why Nastaliq is hard
Nastaliq is a beautiful, deeply contextual script. Letters change shape depending on their neighbours, words cascade diagonally, and dense ligatures and diacritics stack in ways that flat, left-to-right OCR was never designed to handle. The baseline Tesseract Urdu model produced output that was effectively unusable: not slightly wrong, but wrong enough that no search or spell-check could be built on top of it.
How we trained a custom Urdu OCR model
The fix was not a clever prompt. It was data and training. We fine-tuned a custom Tesseract model, urd_naw, from the base Urdu model on 12,748 curated Urdu image-and-text pairs, trained right-to-left. The result recognises ligatures and diacritics markedly better than the baseline, cleanly enough that a real search experience and a from-scratch multilingual spell-checker could be built on top of it.
When a model returns garbage, the answer is rarely a better prompt. It's usually better data.
Why we open-sourced it
We contributed urd_naw back to Tesseract's tessdata_contrib repository, publicly and under a permissive licence. Low-resource scripts suffer from a chicken-and-egg problem: nobody builds tools because the models are bad, and the models stay bad because nobody builds tools. Putting a genuinely usable Urdu-Nastaliq model in the open is a small push against that. It also happens to be good practice: the same technique generalises to any hard, under-served script, and we would rather advance the whole field than hoard one model.
The takeaway
If a standard model fails on your data, that is not a dead end. It is a signal that your problem is specific enough to be worth training for. Curate the data, fine-tune from a sensible base, and measure against the real task, not a generic benchmark. Sometimes the highest-leverage thing you can build is the model everyone else assumed was impossible.
Keep reading
- Private by design: shipping production AI that never leaves your buildingOn-premise AI has a reputation for being slow, clunky and second-best. It isn't anymore. Here is how we run RAG, voice agents and document AI fully on-premise and air-gapped, with the patterns and trade-offs that actually matter.
- The real latency of a production voice AI agentEveryone quotes model benchmarks. Callers experience wall-clock time. Here is the actual per-stage voice AI latency of a live phone agent, and the one trick that makes it feel instant.
Let's build your AI advantage.
Book a strategy call and walk away with a clear, technical plan, whether you build custom or start from an accelerator.