How to use from the
Use from the
PEFT library
from peft import PeftModel
from transformers import AutoModelForCausalLM

base_model = AutoModelForCausalLM.from_pretrained("unsloth/qwen3-vl-2b-instruct-unsloth-bnb-4bit")
model = PeftModel.from_pretrained(base_model, "context212/alhazen-ocr")

Alhazen-OCR

QLoRA adapter on unsloth/Qwen3-VL-2B-Instruct for Arabic institutional OCR: printed forms, invoices, and handwriting-heavy pages.

Named after Ibn al-Haytham (Alhazen), the 11th-century scholar who founded the science of optics.

Results

CER / WER (lower is better), greedy decoding, 50 samples each on the held-out eval split and on external ahmedheakl/arocrbench_khatt:

Model Eval CER ↓ Eval WER ↓ KHATT CER ↓ KHATT WER ↓
Qwen3-VL-2B-Instruct (base) 0.792 0.947 1.893 1.801
Alhazen-OCR 0.328 0.504 0.841 1.193

Held-out character error: 0.79 β†’ 0.33. External KHATT handwriting: 1.89 β†’ 0.84 CER.

This release (khattmix) adds line-level KHATT handwriting (~30% of the mix) on top of synthetic printed, invoices, and paragraph handwriting; KHATT-bench transcript overlap is removed from train.

Training

  • Objective: QLoRA SFT, one epoch
  • LR: 2e-5 cosine, warmup 5%
  • Effective batch: 16 (8 Γ— grad accum 2) on A100 80GB
  • LoRA: r=16, RSLoRA, vision + language layers
  • Mix: 30% loay synthetic / 15% invoices / 30% KHATT lines / 23% KHATT paragraphs / 2% historical (18k train rows)

Usage

Serve the base with the adapter attached (vLLM example):

vllm serve Qwen/Qwen3-VL-2B-Instruct \
  --enable-lora \
  --lora-modules alhazen=context212/alhazen-ocr \
  --limit-mm-per-prompt '{"image": 1}' \
  --mm-processor-cache-gb 0 \
  --no-enable-prefix-caching

Prompt:

Extract all the text from this image, preserving the original reading order.

Keep temperature=0 for transcription.

Limitations

  • Tuned for Arabic institutional paperwork; not a general multilingual OCR.
  • KHATT remains harder than printed forms β€” scores above 1.0 CER mean many lines are still wrong.
  • Eval above is capped at 50 samples per split; treat as directional until a full-split rerun.

Citation

@misc{alhazen-ocr-2026,
  title        = {Alhazen-OCR},
  author       = {Context212},
  year         = {2026},
  howpublished = {\url{https://huggingface.co/context212/alhazen-ocr}}
}
Downloads last month
66
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Model tree for context212/alhazen-ocr

Adapter
(5)
this model