Identity & document AI · Jun-Jul 2026
Offline vision-language extraction for Tunisian Arabic & French
Extracts structured JSON from Tunisian identity and business documents by reading the image directly with a small quantised vision-language model - no Tesseract, no PaddleOCR. Fully offline, CPU-only, engineered to a hard 2 GB RAM budget.
What it did, and what it measured
- Shipped two swappable VLMs behind one registry - a 2B model with strong Arabic at 20-40 s, and a 500M model at 3-8 s - with a benchmark script so each deployment chooses on measured hardware rather than assumption.
- Held the memory budget with named levers: mmap weight loading, 1024-token context, CPU-only inference, capped image width, optional KV-cache quantisation. Fully deterministic decoding.
- Rebuilt the ground-truth dataset from scratch after diagnosing that the supplied labels were machine-OCR pseudo-labels - only 13 of 48 entries had a valid number, because 120 of 201 cards were rotated in their source photos. Designed a resumable hand-transcription runbook with an append-only ledger and a skip-rather-than-guess rule, then produced a verified dataset plus a 5,000-document synthetic corpus.
Stack
PythonQwen2-VL-2B / SmolVLM-500M (GGUF)llama.cppOpenCVPydantic v2TyperFastAPIDocker
Repo and demo
This is client work, so the source is not public. Happy to walk through the architecture, the scorecards and the trade-offs on a call.