加载中…
加载中…
This is our fine-tuned version of HAFITH, not a model trained from scratch. It uses SigLIP2 NaFlex, a projection connector, and a TrOCR decoder with an Arabic tokenizer (698 million distinct parameters).
We adapted the released checkpoint to 81,672 manuscript line images and continued full-model training with R-Drop. The selected checkpoint is update 2,500. Exported recognition weights are lossless FP32 Safetensors shards; 8-bit storage was used only for optimizer states during training.
Strict corpus scores on 10,173 held-out line crops, with matched BF16 inference, 512 patches, and a 128-token generation limit:
| Model | CER | WER |
|---|---|---|
| Released HAFITH | 16.35% | 48.31% |
| Our fine-tuned checkpoint | 12.33% | 36.15% |
These are our local results, not the original published benchmark or the evaluation engineer's setup. On 32 Quran pages assembled from 481 cached crops, stripped CER was 17.02%. That test did not use the included layout pipeline. See evaluation.json for details. Training exposure, near duplicates, and some crop references remain incompletely audited.
Download this repository, install requirements.txt, then:
from PIL import Image
from hafith_htr import Recognizer
reader = Recognizer(".", device="cuda", precision="fp32")
text = reader.recognize_line(Image.open("line.png"))
Use device="cpu" for CPU inference. T4 deployment defaults to FP32; FP16 requires validation. Long lines may reach the generation limit. No LLM correction is applied.
The layout/ assets come from HAFITH's page models; they were not trained by us. Recognition code retains the upstream MIT notice; weight provenance is in release.json and NOTICE.
This release replaces the earlier CNN–Transformer–CTC model. That version remains available at tag legacy-v2-cnn-ctc-20261027.
mdnaseif/hafith