calfa-ai
amidda1.0Line4B
Available on FriendliAI
Run this model inference on single tenant GPU with unmatched speed and reliability at scale.
Model Details
Model Provider
calfa-ai
Model Tree
Input Modalities
Output Modalities
Supported Functionality
GLM-5.3 is live. Run Z.ai's latest model on Friendli Model APIs. Try it today ➜
calfa-ai
Available on FriendliAI
Run this model inference on single tenant GPU with unmatched speed and reliability at scale.
Model Details
Model Provider
calfa-ai
Model Tree
Input Modalities
Output Modalities
Supported Functionality
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 |
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.
bash
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:
bash
pip install causal-conv1d flash-linear-attention
python
import torchfrom PIL import Imagefrom transformers import AutoModelForImageTextToText, AutoProcessormodel_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.
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.
bash
git clone https://github.com/TheoMoins/DocWorkflowcd DocWorkflowpip install -e .
yaml
run_name: "amidda1.0Line4B"output_dir: "results"device: "cuda"data:test: "path/to/your/alto/data"tasks:htr:type: VLMLineHTRconfig:model_name: "calfa-ai/amidda1.0Line4B"device_map: "auto"max_new_tokens: 128line_batch_size: 8max_pixels: 401408prompt: >Transcribe the handwritten text in this line image.Output ONLY the transcription.
bash
docworkflow -c amidda1.0Line4B.yml predict -t htr -d test
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).
bibtex
@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},}
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.