Raqim_OCR_Arabic (رقيم)

Arabic handwritten-text recognition model: Qwen/Qwen3-VL-2B-Instruct fine-tuned with LoRA (merged) on historical handwritten Arabic manuscript lines from aamijar/muharaf-public.

Test split CER WER
Base model (zero-shot, n=300) 1.1281 1.1144
Raqim-OCR (n=1334) 0.1737 0.4494

Input: one cropped text-line image. Output: the Arabic transcription. Peak training VRAM: 10.9 GB.

Usage

from transformers import AutoModelForImageTextToText, AutoProcessor
from PIL import Image
repo = "Youssefx64/Raqim_OCR_Arabic"
processor = AutoProcessor.from_pretrained(repo)
model = AutoModelForImageTextToText.from_pretrained(repo, dtype="auto", device_map="auto")
prompt = processor.apply_chat_template(
    [{"role": "user", "content": [{"type": "image"}, {"type": "text", "text": "Transcribe the Arabic handwriting in this image exactly as written."}]}],
    add_generation_prompt=True, tokenize=False)
enc = processor(text=[prompt], images=[Image.open("line.png").convert("RGB")], return_tensors="pt").to(model.device)
out = model.generate(**enc, max_new_tokens=160, do_sample=False)
print(processor.batch_decode(out[:, enc["input_ids"].shape[1]:], skip_special_tokens=True)[0])

License and data

Trained on Muharaf (Saeed et al., 2024), released under CC BY-NC-SA 4.0, so this model is non-commercial, share-alike. Please cite: Muharaf: Manuscripts of Handwritten Arabic Dataset for Cursive Text Recognition (arXiv:2406.09630).

Limitations

Trained on line-level crops of historical manuscripts; full pages need a line-segmentation step first. Modern print and other scripts are out of scope.

Downloads last month
26
Safetensors
Model size
2B params
Tensor type
F16
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for Youssefx64/Raqim_OCR_Arabic

Adapter
(126)
this model
Adapters
1 model

Dataset used to train Youssefx64/Raqim_OCR_Arabic

Collection including Youssefx64/Raqim_OCR_Arabic

Paper for Youssefx64/Raqim_OCR_Arabic