BroadRouter

Arabic OCR vs vision LLMs: reading Arabic documents and invoices

By the BroadNet Inference team · 5 min read · Published

Classic OCR turns Arabic page images into raw text; a vision LLM reads the image and returns the fields you ask for, such as vendor, date and total, as JSON. For invoices and receipts a vision LLM usually saves the parsing step. On BroadNet Inference, Qwen3.8 27B, DeepSeek V4.1 Flash and BroadNet Gemma 4 VL 26B accept images.

Parcels on a conveyor labelled "FRAGILE", "ZERBRECHLICH" and "取扱注意", with the text "From printed text to useful data."

For Arabic invoices, receipts and forms you need to act on, use a vision LLM: it reads the image and returns the fields you ask for, such as vendor, VAT number, date and total, as JSON. Use classic optical character recognition (OCR) for full-text search of long scanned pages or offline work. Either way, check numbers in code.

Arabic makes both routes harder than they are for English, for the reasons below.

Why is Arabic OCR hard?

  • Connected script. Arabic letters join, and most have up to four shapes (isolated, initial, medial, final). OCR engines must segment a word they cannot see the edges of.
  • Dots carry meaning. ب ت ث ن ي share one base shape and differ only by dots. A low-resolution scan or a crease can turn one letter into another.
  • Two directions on one line. An invoice line such as “المجموع: 1,250.00 SAR” mixes right-to-left Arabic with left-to-right numbers and Latin text. OCR output often comes back in the wrong visual order, which the Unicode bidirectional algorithm then reorders again when displayed.
  • Two digit sets. Gulf and Egyptian documents often print Eastern Arabic numerals (٠١٢٣٤٥٦٧٨٩) instead of 0–9, sometimes both on the same page.
  • Fonts and stamps. Decorative Naskh and Ruq’ah headings, company stamps over the total and thermal-receipt fading all hurt recognition.

OCR or vision LLM: what does each give you?

Classic OCR Vision LLM
Output Raw text, often with word positions Whatever you ask for: fields, JSON, a summary, a translation
Layout understanding You write rules or templates The model infers it (“the total is at the bottom right”)
New invoice layouts New template or rule Usually works without changes
Translation Separate step Same request
Predictability Deterministic for the same input Can vary; validate outputs
Hallucination risk Low (misreads, but does not invent) Real: can produce a plausible but wrong value
Best for Full-text search of long scanned documents, archives Invoices, receipts, IDs, forms you need to act on

The key trade-off: OCR misreads but does not invent. A vision LLM understands, but can hallucinate a plausible value. A good pipeline uses the LLM for understanding and code for checking.

How do you read an Arabic invoice with a vision LLM?

Send the image as a base64 data URL inside the message content and ask for exactly the fields you want. The vision invoice guide has the full walk-through; the core looks like this:

import base64, json, os
from openai import OpenAI

client = OpenAI(base_url="https://inference.broadnet.ai/v1", api_key=os.environ["BROADNET_API_KEY"])
image = base64.b64encode(open("invoice.jpg", "rb").read()).decode()

prompt = """Read this invoice. Reply with JSON only, using these keys:
vendor_name (as written, Arabic script if Arabic), vendor_vat_number, invoice_number,
invoice_date (YYYY-MM-DD), currency (ISO code), subtotal, vat_amount, total,
line_items (list of {description, quantity, unit_price, amount}).
Convert Eastern Arabic numerals to Western digits. Use null for anything you cannot read."""

r = client.chat.completions.create(
    model="broadnet/qwen3.8-27b",
    max_tokens=3000,  # reasoning comes first
    messages=[{"role": "user", "content": [
        {"type": "text", "text": prompt},
        {"type": "image_url", "image_url": {"url": "data:image/jpeg;base64," + image}},
    ]}],
)
data = json.loads(r.choices[0].message.content)

Three details that save debugging time:

  1. Say which numeral system you want. “Convert Eastern Arabic numerals to Western digits” avoids a mix of ١٢٥٠ and 1250 in your database.
  2. Ask for null, not a guess. Models are more likely to invent a value when every key must be filled.
  3. Keep names in the original script. Transliterating “مؤسسة النور للتجارة” into Latin letters invites spelling variants. Store the Arabic and translate separately if you need English.

If the model returns an empty answer, it ran out of max_tokens while reasoning; see reasoning tokens and empty responses. For a stricter JSON shape, see structured output with JSON schema; the free JSON schema generator builds a schema from a sample invoice.

How do you catch misread numbers?

Treat every extracted value as a claim to check in code, not as data. Line items must sum to the subtotal, subtotal plus VAT must equal the total, dates must parse and not be in the future, and the currency should match the vendor’s country. Saudi VAT numbers have a fixed length and format, which makes a cheap extra check. A misread digit almost always breaks a sum, so arithmetic checks catch most of the errors that matter. Anything that fails goes to a human review queue with the image beside the extracted fields.

The full pipeline, with a Pydantic schema, arithmetic validators, one retry with the error message and a review queue, is in extract invoice and receipt data to JSON with a vision LLM.

Which vision model should read Arabic documents?

Three chat models on BroadNet Inference accept images:

Model Input / output per 1M tokens Context Notes
Qwen3.8 27B $0.175 / $2.17 262,144 The model BroadNet tested in Arabic
DeepSeek V4.1 Flash $0.175 / $0.52 1,048,576 Also on unlimited flat plans
BroadNet Gemma 4 VL 26B $0.10 / $0.22 32,768 Cheapest of BroadNet’s vision models; works on free credit and the $0.50 hourly key

BroadNet reports that Qwen3.8 27B wrote fluent Arabic, understood Gulf and Egyptian dialects and translated Arabic and English accurately in its tests. BroadNet does not publish an OCR or document-extraction benchmark, so measure field accuracy on your own documents. A practical setup is Gemma 4 VL 26B for simple receipts and a second pass with Qwen3.8 27B for anything that fails validation. The Gemma 4 VL 26B vs Qwen3.8 27B comparison sets the two side by side.

What does a vision LLM cost per page?

On pay-as-you-go keys an image is billed as input tokens at the model’s input price, and larger images use more tokens. Resize phone photos to roughly 1,500–2,000 pixels on the long side: Arabic dots need enough resolution, but a 12-megapixel photo mostly adds cost. Read usage.prompt_tokens on a few real images to get your cost per page. On an unlimited DeepSeek V4.1 Flash plan, BroadNet’s docs say images are part of the plan’s unlimited use. The token math per image and per page is worked out in vision LLM cost per image.

When does classic OCR still win?

  • Long scanned books and archives where you need every word for search, not a few fields.
  • Strict reproducibility, where the same input must always produce the same text.
  • Offline or on-device processing with no network.

Open-source engines such as Tesseract list Arabic (ara) trained data and run offline. A hybrid also works well: OCR the page for searchable text, and send the image to a vision LLM for the fields you act on. Which cloud OCR APIs list Arabic, printed and handwritten, and what each costs per 1,000 pages is in the Arabic OCR API comparison.

Privacy

Invoices and IDs contain names, tax numbers and bank details. BroadNet Inference does not retain images, prompts or answers after the request; see zero data retention. Apply the same rule to your own storage: keep the extracted fields you need and delete images you no longer have to keep.

Questions

Is a vision LLM more accurate than OCR for Arabic?

It depends on the document. Vision LLMs are usually better at understanding layout and pulling named fields from invoices and receipts. Dedicated OCR can be more predictable on long, clean printed pages. Test both on a sample of your documents.

Can vision LLMs read handwritten Arabic?

Sometimes, on clear handwriting. Accuracy drops quickly with cursive or rushed writing. Route low-confidence handwritten fields to a human reviewer.

Which BroadNet model is cheapest for reading images?

BroadNet Gemma 4 VL 26B, at $0.10 per 1M input tokens. It also works on the free starting credit and with a flat-price hourly key.

How do I convert Eastern Arabic numerals to Western digits?

Ask the model to return Western digits, then enforce it in code. In Python, text.translate(str.maketrans("٠١٢٣٤٥٦٧٨٩", "0123456789")) converts any Eastern Arabic digits that slip through. Persian digits (۰–۹) use different code points, so add them if your documents come from Iran or Afghanistan.

Can the model translate the Arabic labels to English?

Yes. Ask for English keys and keep the original Arabic values, or ask for both. Keep names in the original script to avoid transliteration errors.

Read as MarkdownAsk ChatGPTAsk ClaudeAsk Perplexity