CoolFace
Modelpublic

amad-iq/amad-vlm5

sourceHugging Faceapache-2.0updated 24d agoView on Hugging Face
1likes299downloads
Model Card

amad-vlm5

<div align="center"> <img src="https://huggingface.co/amad-iq/amad-vlm5/resolve/main/tre.png" alt="amad-vlm5 Arabic OCR hero image" width="92%" style="border: 2px solid #38bdf8; border-radius: 20px; padding: 4px; box-shadow: 0 10px 28px rgba(56, 189, 248, 0.22);" /> </div>

أمد للحلول البرمجية هي شركة عراقية مقرّها النجف الأشرف، متخصصة في تقديم الحلول البرمجية والتقنية للمنازل والشركات ودوائر الدولة. تهدف الشركة إلى بناء حلول ذكية وعملية تساعد الأفراد والمؤسسات على تطوير أعمالهم، تحسين الكفاءة، وأتمتة الإجراءات بطريقة سهلة وموثوقة.

تعمل أمد للحلول البرمجية على تقديم تقنيات حديثة تدعم التحول الرقمي، وتسهم في بناء مستقبل أكثر ذكاءً واستدامة.

amad-vlm5 is a 7B Arabic OCR vision-language model. Given an image of Arabic text — printed, handwritten, historical, scanned, or synthetic — it returns the transcription. It is fine-tuned from Qwen2.5-VL-7B-Instruct.

It is a thinking model: on dense, page-level documents it first reasons inside a <think>…</think> block and then emits the transcription. On short line-level images it usually answers directly. Your application should keep only the text after the last </think> (see Handling the thinking block).

Results on KITAB-Bench

KITAB-Bench ocr-eval, all 13 datasets, 3,760 images, scored on the final transcription only with the benchmark's unmodified metrics and Arabic normalization.

ModelCHrF ↑CER ↓WER ↓
amad-vlm581.050.250.36
AIN-7B78.330.200.28
Gemini-2.0-Flash77.950.130.32
GPT-4o61.010.310.55
Qwen2.5VL-7B49.231.201.41
GPT-4o-mini47.210.430.71
EasyOCR45.470.580.89
Tesseract39.620.540.84
Qwen2VL-7B33.941.481.55
Surya20.614.955.61
Paddle16.730.791.02

Baselines are the published KITAB-Bench numbers. Read these two caveats before quoting a rank:

  1. 1.Training overlap. 552 benchmark images (khatt 200/200, onlinekhatt 181/200, muharaf 171/200) also occur in the model's training data. Excluding those three datasets entirely, the score is CHrF 77.35 / CER 0.32 / WER 0.43 over the remaining 3,160 images.
  2. 2.Two outliers dominate CER. Two of the 3,760 outputs degenerate into a repeated phrase; without them CER is 0.13 and WER 0.28. CHrF, which is bounded, is the more stable summary.

Per-dataset results (final-answer scoring, 4,096 tokens):

DatasetSamplesCER ↓WER ↓CHrF ↑
patsocr5000.010.0696.28
onlinekhatt2000.020.0895.75
khatt2000.030.1693.83
synthesizear5000.040.1591.66
muharaf2000.050.1490.55
isippt5000.050.2190.27
arabicocr500.020.0995.17
historicalbooks100.210.3870.82
hindawi2000.240.3869.44
evarest8000.290.5268.45
adab2000.170.5966.45
khattparagraph2000.710.8862.45
historyar2001.451.0662.56

Methodology note. amad-vlm5 is a thinking VLM. For OCR scoring, only the final transcription is evaluated; reasoning text is removed before metric calculation. The benchmark was run with greedy decoding in a 4-bit-quantized inference configuration; the bf16 and GGUF files in this release were not separately re-benchmarked, so small differences from the table are expected.

Files

RepositoryContentsSizeUse
`amad-iq/amad-vlm5` (this repo)bf16 safetensors16.60 GBTransformers, vLLM, further fine-tuning
`amad-iq/amad-vlm5-GGUF`amad-vlm5-f16.gguf15.24 GBllama.cpp / LM Studio, full precision
amad-vlm5-q8_0.gguf8.10 GBllama.cpp / LM Studio, near-lossless
amad-vlm5-q4_k_m.gguf4.68 GBllama.cpp / LM Studio, smallest
mmproj-amad-vlm5-f16.gguf1.35 GBRequired alongside any GGUF above

The GGUF language model files do not work without the mmproj file — it carries the vision encoder. Download it into the same folder as the model file.

Quick start

Transformers

python
import re
import torch
from transformers import AutoProcessor, Qwen2_5_VLForConditionalGeneration

repo = "amad-iq/amad-vlm5"
model = Qwen2_5_VLForConditionalGeneration.from_pretrained(
    repo, dtype=torch.bfloat16, device_map="auto"
)
processor = AutoProcessor.from_pretrained(repo)

messages = [{
    "role": "user",
    "content": [
        {"type": "image", "image": "page.png"},
        {"type": "text", "text": "Extract the text in the image. Give me the final text, nothing else."},
    ],
}]
inputs = processor.apply_chat_template(
    messages, add_generation_prompt=True, tokenize=True,
    return_dict=True, return_tensors="pt",
).to(model.device)

with torch.inference_mode():
    out = model.generate(
        **inputs, max_new_tokens=4096, do_sample=False, repetition_penalty=1.05
    )
raw = processor.batch_decode(out[:, inputs["input_ids"].shape[1]:], skip_special_tokens=True)[0]
text = re.sub(r"<think>.*?</think>", "", raw, flags=re.S).strip()
print(text)

llama.cpp

bash
llama-mtmd-cli \
  -m amad-vlm5-q8_0.gguf \
  --mmproj mmproj-amad-vlm5-f16.gguf \
  --image page.png \
  -p "Extract the text in the image. Give me the final text, nothing else." \
  -n 4096 --temp 0 --repeat-penalty 1.05

LM Studio

Search for amad-iq/amad-vlm5-GGUF in LM Studio, download a model file together with mmproj-amad-vlm5-f16.gguf, load the model, and attach an image. Set the context length to at least 8192 and the maximum output tokens to 4096 or more.

Handling the thinking block

The model may emit <think>…</think> before the transcription. <think> is ordinary text, not a special token, so it appears in decoded output. Keep only what follows the last </think>:

python
import re
def final_text(raw: str) -> str:
    if "</think>" in raw:
        raw = raw.rsplit("</think>", 1)[1]
    return re.sub(r"^<think>.*", "", raw, flags=re.S).strip()

If the output contains <think> but no </think>, the generation ran out of budget before finishing; raise max_new_tokens and retry.

Intended use and training data

amad-vlm5 is intended for transcribing Arabic-script text from images: books, manuscripts, forms, screenshots, and handwritten notes. It was fine-tuned on a mixture of public Arabic OCR datasets covering printed, handwritten, historical, and synthetic text, including some subsets that overlap with KITAB-Bench (see the caveat above). It is not a general assistant and has not been evaluated for languages other than Arabic and English.

Limitations

  • Runaway reasoning (≈0.6% of benchmark pages). On some very dense pages the model reasons for the entire budget and never emits a transcription. Detect this by the missing </think> and retry with a larger budget or a different crop.
  • Repetition loops (rare). Greedy decoding can occasionally lock onto a repeated phrase and run to the token limit. A repetition penalty of 1.05 mitigates this.
  • Quantized variants are not separately benchmarked. Expect Q4KM to be slightly worse than Q8_0 or bf16 on handwritten and historical material.

License

Released under the Apache 2.0 license, the same license as the Qwen2.5-VL-7B-Instruct base model.