AMIDDA 1.0 Line 4B

A foundation Vision Language Model for line-level Arabic handwritten text recognition (HTR), pre-trained on AMIDDA and developed at Calfa. Not designed for production.

Unlike the per-corpus specialised models that preceded it, this is a single generic model covering Maghrebi and Oriental Arabic manuscripts, Urdu lithographs, Persian, and modern Arabic handwriting.

Base model Qwen3.5-VL-4B-Instruct
Training data AMIDDA, 53,420 training lines from 8 corpora
Method LoRA fine-tuning, r = 64, adapter merged into the base weights
Task Line-level HTR on pre-segmented images

Presented at HIP 2026 @ ICDAR 2026. See the system report for data, training procedure, and full results.

Results

CER (%) on the AMIDDA test split (6,684 lines), per source corpus. Lower is better. The CTC row gives the per-corpus specialised RNN baselines for perspective; they are not a single generic model.

Method baybars iskandar khatt muharaf rasam1 rasam2 rasm tarima Overall
AMIDDA 1.0 Line 4B 13.4 15.9 9.8 30.1 25.0 27.6 37.4 24.2 23.1
QARI-OCR v0.3, zero-shot 140.1 113.6 50.9 105.9 114.6 100.6 71.2 85.1 104.3
Gemini 3 Flash, 25-shot ICL 11.2 11.8 7.5 22.5 16.5 29.0 21.1 25.6 18.3
CTC, one RNN per corpus 7.8 — 6.1 9.5 3.6 4.9 8.9 3.9 6.4

Intended use

The model expects a cropped image of a single text line and returns its transcription. It is not a page-level OCR system: segmentation must be performed beforehand.

Transcriptions preserve the text as written in the original document, without normalization, modernization, or editorial correction. Diacritics (tashkil) are transcribed only where the training guidelines record them, which varies across source corpora; see the transcription_guidelines column of AMIDDA.

Dependencies

pip install "transformers>=5.9" torch accelerate pillow

transformers>=5.9 is required: earlier versions do not implement the qwen3_5 architecture.

The Qwen3.5 backbone alternates linear-attention and full-attention layers. Without the optimised kernels, transformers silently falls back to reference PyTorch implementations that are correct but much slower. On CUDA, install them:

pip install causal-conv1d flash-linear-attention

Usage

import torch
from PIL import Image
from transformers import AutoModelForImageTextToText, AutoProcessor

model_id = "calfa-ai/amidda1.0Line4B"
PROMPT = "Transcribe the handwritten text in this line image. Output ONLY the transcription."

processor = AutoProcessor.from_pretrained(model_id, max_pixels=401408)
model = AutoModelForImageTextToText.from_pretrained(
    model_id, dtype=torch.bfloat16, device_map="auto"
)
model.eval()

image = Image.open("path/to/line_image.jpg").convert("RGB")

messages = [{
    "role": "user",
    "content": [
        {"type": "image", "image": image},
        {"type": "text", "text": PROMPT},
    ],
}]

inputs = processor.apply_chat_template(
    messages,
    tokenize=True,
    add_generation_prompt=True,
    return_dict=True,
    return_tensors="pt",
    enable_thinking=False,
).to(model.device)

with torch.no_grad():
    generated = model.generate(**inputs, max_new_tokens=128, do_sample=False)

trimmed = generated[0][inputs["input_ids"].shape[1]:]
print(processor.decode(trimmed, skip_special_tokens=True).strip())

enable_thinking=False is required.

Usage with DocWorkflow

Training and evaluation were carried out with DocWorkflow, adapted to Arabic script. DocWorkflow handles ALTO XML input/output, line extraction, batching, and scoring in one pipeline.

git clone https://github.com/TheoMoins/DocWorkflow
cd DocWorkflow
pip install -e .
run_name: "amidda1.0Line4B"
output_dir: "results"
device: "cuda"

data:
  test: "path/to/your/alto/data"

tasks:
  htr:
    type: VLMLineHTR
    config:
      model_name: "calfa-ai/amidda1.0Line4B"
      device_map: "auto"
      max_new_tokens: 128
      line_batch_size: 8
      max_pixels: 401408
      prompt: >
        Transcribe the handwritten text in this line image.
        Output ONLY the transcription.
docworkflow -c amidda1.0Line4B.yml predict -t htr -d test

Related resources

All Arabic HTR resources are gathered in the Arabic HTR collection.

Training corpora: AMIDDA aggregates RASAM-1, RASAM-2, TARIMA, BAYBARS, ISKANDAR, KHATT, MUHARAF, and RASM (British Library, not redistributed).

Citation

@unpublished{vidalgorene:hal-05693582,
  TITLE = {{Is a Generic Dataset and Foundation VLM for Arabic HTR Worth It? Lessons from AMIDDA}},
  AUTHOR = {Vidal-Gor{\`e}ne, Chahan and Lucas, No{\"e}mie and Salah, Cl{\'e}ment and Decours-Perez, Ali{\'e}nor},
  URL = {https://enc.hal.science/hal-05693582},
  NOTE = {working paper or preprint},
  YEAR = {2026},
  MONTH = Jul,
  KEYWORDS = {Arabic HTR ; Vision-Language Models ; In-Context Learning ; Data Bootstrapping ; DISTAM},
  PDF = {https://enc.hal.science/hal-05693582v1/file/main.pdf},
  HAL_ID = {hal-05693582},
  HAL_VERSION = {v1},
}

License

The weights are released under Apache 2.0, following the Qwen3.5-VL-4B-Instruct base model. This covers the model only: the training data is mixed-license, and each AMIDDA sub-dataset carries its own terms. RASM is not redistributed.

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

Dataset used to train calfa-ai/amidda1.0Line4B

Collection including calfa-ai/amidda1.0Line4B