Instructions to use g3ida/absir-arabic-ocr-1.6B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use g3ida/absir-arabic-ocr-1.6B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="g3ida/absir-arabic-ocr-1.6B") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("g3ida/absir-arabic-ocr-1.6B") model = AutoModelForMultimodalLM.from_pretrained("g3ida/absir-arabic-ocr-1.6B", device_map="auto") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] inputs = processor.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=256) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use g3ida/absir-arabic-ocr-1.6B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "g3ida/absir-arabic-ocr-1.6B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "g3ida/absir-arabic-ocr-1.6B", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker
docker model run hf.co/g3ida/absir-arabic-ocr-1.6B
- SGLang
How to use g3ida/absir-arabic-ocr-1.6B with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "g3ida/absir-arabic-ocr-1.6B" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "g3ida/absir-arabic-ocr-1.6B", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "g3ida/absir-arabic-ocr-1.6B" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "g3ida/absir-arabic-ocr-1.6B", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }' - Docker Model Runner
How to use g3ida/absir-arabic-ocr-1.6B with Docker Model Runner:
docker model run hf.co/g3ida/absir-arabic-ocr-1.6B
absir-arabic-ocr-1.6B
Page-level OCR for printed Arabic documents. A fine-tune of LiquidAI/LFM2.5-VL-1.6B that reads a full page image and returns its text in reading order, with light HTML structure:
<p>paragraphs,<h1>…<h6>headings<strong>,<sup>(note markers),<br>,<hr><table>for printed tables- the footnote block wrapped in
<footnotes>
Diacritics (tashkeel) are kept as printed.
Usage
import torch
from PIL import Image
from transformers import AutoModelForImageTextToText, AutoProcessor
repo = "g3ida/absir-arabic-ocr-1.6B"
processor = AutoProcessor.from_pretrained(repo)
model = AutoModelForImageTextToText.from_pretrained(repo, dtype=torch.bfloat16).to("cuda").eval()
prompt = ("Transcribe this page. Return the text with its original HTML "
"structure. Put the footnote block inside <footnotes>.")
messages = [{"role": "user", "content": [
{"type": "image", "image": Image.open("page.png").convert("RGB")},
{"type": "text", "text": prompt}]}]
inputs = processor.apply_chat_template(messages, add_generation_prompt=True, tokenize=True,
return_dict=True, return_tensors="pt").to("cuda")
out = model.generate(**inputs, max_new_tokens=2560, do_sample=False, repetition_penalty=1.05)
print(processor.decode(out[0, inputs["input_ids"].shape[1]:], skip_special_tokens=True))
Recommended decoding: greedy, repetition_penalty=1.05, max_new_tokens=2560.
The penalty matters for this model: it removes most repetition loops at a small
cost in median CER. Render PDF pages at ~170 DPI.
Evaluation
All three benchmarks are public and none were used for training. Other models' numbers are copied from the benchmark papers; ours were measured with the same data and scoring code where it is published.
KITAB-Bench — OCR, hindawi subset (200 book pages)
Hindawi is the only full-page printed-document subset of KITAB-Bench's OCR task, and we use all 200 of its pages. The other subsets are handwriting, scene text, slides, or synthetic single lines and words, which this page-level model was not built for. Every row is a score on the same 200 hindawi pages. Other models' numbers are their hindawi results from the KITAB-Bench paper (Table 9), not their whole-benchmark totals. Scored with the official KITAB-Bench preprocessing and metrics. Lower is better.
| Model | CER | WER |
|---|---|---|
| Gemini-2.0-Flash | 0.01 | 0.04 |
| absir-arabic-ocr-1.6B | 0.046* | 0.145* |
| Azure OCR | 0.06 | 0.28 |
| Qari | 0.11 | 0.15 |
| Surya | 0.15 | 0.20 |
| Qwen2.5-VL-7B | 0.27 | 0.42 |
| Tesseract | 0.31 | 0.72 |
| GPT-4o | 0.34 | 0.56 |
| GPT-4o-mini | 0.48 | 0.71 |
| PaddleOCR | 0.76 | 1.00 |
* The model returns HTML (<p>, <h1>, <footnotes>, …), but the hindawi
ground truth is plain text with no markup. We remove the tags from our output
(re.sub(r"<[^>]+>", " ", pred)) before scoring, so only the transcribed text is
compared. Everything else is KITAB-Bench's own pipeline, unchanged: its
preprocess_arabic_text normaliser, then torchmetrics CharErrorRate /
WordErrorRate over all 200 pages. Counting the tags as errors gives CER 0.073 /
WER 0.167. Greedy decoding without repetition penalty.
KITAB-Bench — table recognition (241 HTML tables)
TEDS, higher is better. The published models were prompted with KITAB-Bench's own table prompt. Ours is scored with the instruction it was trained on (the prompt above); with KITAB's prompt it scores 46.8.
| Model | TEDS |
|---|---|
| GPT-4o | 85.8 |
| Gemini-2.0-Flash | 83.1 |
| AIN-7B | 75.9 |
| GPT-4o-mini | 69.3 |
| absir-arabic-ocr-1.6B (trained prompt) | 64.6 |
| Qwen2.5-VL-7B | 59.3 |
| Qwen2-VL-7B | 57.8 |
| Surya | 50.2 |
| EasyOCR (Docling) | 49.1 |
| absir-arabic-ocr-1.6B (KITAB's prompt) | 46.8 |
| Tesseract (Docling) | 28.2 |
The 64.6 row uses the model's own prompt (see Usage). The 46.8 row uses KITAB's table
prompt. Greedy decoding with repetition_penalty=1.05.
Misraj-DocOCR (modern documents, out of domain)
Mean over pages, lower is better.
| Model | WER | CER |
|---|---|---|
| Baseer | 0.25 | 0.53 |
| Gemini-2.5-pro | 0.37 | 0.31 |
| Azure AI Document Intelligence | 0.44 | 0.27 |
| Dots.ocr | 0.50 | 0.40 |
| absir-arabic-ocr-1.6B | 0.69 | 0.58 |
| Nanonets | 0.71 | 0.55 |
| Qwen2.5-VL-32B | 0.76 | 0.59 |
| Qari | 0.76 | 0.64 |
| GPT-5 | 0.86 | 0.62 |
| Qwen2.5-VL-3B | 0.87 | 0.71 |
| Qwen2.5-VL-7B | 0.92 | 0.77 |
| GPT-4o-mini | 1.36 | 1.10 |
All 400 pages. Not a strict like-for-like comparison: ours is scored with markup
stripped and Arabic normalised (the paper does not publish its scoring code).
repetition_penalty=1.05. The mean is driven by a few runaway pages: the median
page has CER 0.23 / WER 0.36, and 11% of pages have CER above 1.
Sources: KITAB-Bench (arXiv:2502.14949, Tables 5 and 9), Baseer / Misraj-DocOCR (arXiv:2509.18174, Table 5).
Limitations
- Trained mostly on book pages. Modern documents, newspapers and dense multi-column layouts are weaker (see Misraj-DocOCR above), and hard pages can fall into repetition loops.
- The language model can occasionally replace a hard-to-read word with a fluent but different one. Treat output as a draft for critical use.
License
LFM Open License v1.0, inherited from the base model. See LICENSE.
- Downloads last month
- -