Bina 0.4 Microscopy
A 9.55M-parameter Persian page OCR that runs on a laptop CPU. Microscopy is the smallest member of the Bina 0.4 family. It reads whole pages and crops (printed text, handwriting, forms, screenshots, newspapers, math, letters) and accepts images or PDFs.
As of 29 November 2026, on the 193-crop Persian OCR benchmark (34 entries) only Bina 0.4 Rizeh (7.5× larger) and six Google models (Gemini 4 Argon, Neon, Carbon, Hydrogen, Gemini 3.7 Flash and Gemma 4 31B) score better than Microscopy. It beats the best models from Anthropic, OpenAI, Alibaba, Meta, xAI, DeepSeek and every other lab on the board, and Bina 0.4 Koochik at about 66× its size.
| Microscopy | Rizeh | Koochik | |
|---|---|---|---|
| Parameters | 9.55M | 71.2M | 630.8M |
| 193-crop benchmark, CER ↓ | 19.08 | 18.66 | 20.82 |
| Speed, CPU, full handwritten page | 0.55 s (0.42 s INT8, 0.28 s INT8 --single) |
needs a GPU | needs a GPU |
How Bina 0.4 compares
The 193-crop Persian OCR benchmark (Reza2kn/persian-ocr-bench-submitted10-bbox-crops) has 34 entries as of 29 November 2026. Below are the three Bina 0.4 models next to the best model from each other lab, all re-scored from saved predictions with the same scorer (no-space CER after Bina fair_text normalization; on the radar, accuracy = 100 − CER).
Every model that scores better than the Bina 0.4 family on this scorer is from Google (Gemini 4 Argon, Neon, Carbon and Hydrogen, Gemini 3.7 Flash, Gemma 4 31B). All three Bina 0.4 models score better than the best Alibaba (Qwen 3.8 Flash, 22.53), Anthropic (Claude Opus 5 Fast, 22.62) and OpenAI (GPT-5.6 Sol, 31.75) models.
The three Bina 0.4 models alone, axes magnified
Each axis runs from the weakest to the strongest of the three, so small differences are visible. Ranges: forms 91–94%, screens 92–97%, prose 62–69%, math 84–88%, newspaper 81–92%, tables 40–61% accuracy.
Quick run
hf download Reza2kn/Bina-0.4-Microscopy --local-dir Bina-0.4-Microscopy
cd Bina-0.4-Microscopy
pip install -r requirements.txt # no PyTorch needed: runs on ONNX Runtime
python microscopy.py examples/demo.png --out results
python microscopy.py scan1.jpg letter.pdf --out results
python microscopy.py scan1.jpg --reader reader.int8.onnx # about 1.5x faster
Each page produces <name>.txt (text in reading order) and <name>.json (every line with its box, text and confidence, plus which detector was used). Every PDF page becomes its own result: letter-p001.txt, letter-p002.txt and so on.
From Python:
from PIL import Image
from microscopy import Microscopy
ocr = Microscopy() # ONNX Runtime on CPU (PyTorch on a GPU, if installed and available)
result = ocr(Image.open("page.jpg"))
print(result["text"])
for line in result["lines"]:
print(line["box"], line["confidence"], line["text"])
Options and tips
- Runtime. Everything runs on ONNX Runtime on the CPU by default; PyTorch is not needed.
--reader reader.int8.onnxis about 1.3× faster (0.42 vs 0.55 s per full handwritten page) for +0.2 to +0.4 CER. Combined with--singlea page takes 0.28 s. The two detector branches run in parallel threads (4 ONNX Runtime threads each);Microscopy(parallel=False)runs them one after the other on small machines. With PyTorch and a CUDA GPU,--backend torch --device cudareads the lines on the GPU (0.22 s/page; the detectors stay on the CPU). --singleuses only the main detector (8.84M, about twice as fast on CPU). It is just as good on handwriting and most print, but clearly weaker on tables (70.8 vs 58.0 CER).--dpisets the PDF render resolution (default 200). 200–300 dpi is right for normal documents. Going higher does not help: pages are detected at a 1024-pixel long side anyway.- Very dense pages (a full broadsheet newspaper page at 3000+ px) are shrunk to 1024 px for line detection, so small print can be missed. For those, crop columns or regions and send them separately. Crops of any size work without settings.
- Photos of documents: straighten and crop to the page if you can. Rotated pages are not corrected automatically.
- Light text on dark backgrounds (banners, slide titles, dark table headers) is detected and read inverted automatically.
- Confidences are model scores, not calibrated probabilities. Lines below 0.5 are dropped.
Other runtimes
The same pipeline, checked against this repo on the 193 crops and the 50 handwriting pages:
| Package | For | 193 CER | dev50 CER | CPU s/page* |
|---|---|---|---|---|
| this repo, ONNX FP32 (default) | Python, any OS | 19.09 | 14.46 | 0.55 |
this repo, --reader reader.int8.onnx |
Python, faster CPU | 19.50 | 14.66 | 0.42 |
this repo, --backend torch |
Python + PyTorch (GPU) | 19.08 | 14.46 | 1.17 |
| Bina-0.4-Microscopy-ONNX | browsers (WebGPU/WASM), Node, any ONNX Runtime; FP32/FP16/INT8 | 19.06 | 14.42 | 0.99 (Node) |
| Bina-0.4-Microscopy-LiteRT | Android, iOS, embedded (TensorFlow Lite) | 19.09 | 14.46 | 0.47 |
| Bina-0.4-Microscopy-Rust | one native binary (ONNX Runtime linked in, or pure-Rust tract) | 19.06 | 14.45 | 0.56 (0.44 INT8) |
| Bina-0.4-Microscopy-CoreML | iPhone, iPad, Mac (Core ML; detectors on the GPU) | same text as ONNX† | 0.49 on an M2† |
* full handwritten pages (dev50) on the same x86 machine, both detectors running in parallel (4 threads each). Small CER differences come from float rounding in image resizing.
† measured on an Apple M2, where ONNX Runtime FP32 takes 1.18 s/page on the same pages; identical text to ONNX FP32 on those pages, and on the 193 crops the FP32 Core ML reader matches ONNX exactly (FP16: 0.02 CER apart).
Results
All scores are character error rates in %, lower is better, measured with the same scorer for every model. "No-space CER" removes spaces after the Bina fair_text normalization. The public 193 scorer is the frozen original scorer shipped with Rizeh (benchmark_scoring.py), which keeps spaces.
193-crop benchmark (Reza2kn/persian-ocr-bench-submitted10-bbox-crops, revision 906b97f)
| Category | Microscopy 9.55M | Microscopy --single 8.84M |
Rizeh 71.2M | Koochik 630.8M |
|---|---|---|---|---|
| Forms | 6.80 | 7.09 | 7.47 | 8.23 |
| Screenshots | 4.02 | 4.16 | 4.37 | 7.22 |
| Prose | 33.15 | 33.19 | 32.38 | 36.84 |
| Math | 13.68 | 13.76 | 13.35 | 15.07 |
| Newspaper | 9.62 | 9.68 | 9.12 | 17.75 |
| Tables | 58.00 | 70.82 | 54.71 | 40.59 |
| Overall | 19.08 | 20.30 | 18.66 | 20.82 |
Microscopy's figures come from the package in this repo. Rizeh's come from its repaired public run (validation/submitted10-public-predictions.jsonl in the Rizeh repo), and Koochik's from its repaired-tables run.
The wider board (same 193 crops, everything re-scored here)
| # | Model | No-space CER ↓ | Public CER ↓ | Public WER ↓ | Similarity ↑ |
|---|---|---|---|---|---|
| 1 | Gemini 4 Argon | 12.72 | 23.35 | 27.18 | 90.16 |
| 2 | Gemini 4 Neon | 15.43 | 22.03 | 27.44 | 89.75 |
| 3 | Gemini 4 Carbon | 15.46 | 26.67 | 28.59 | 89.82 |
| 4 | Gemini 4 Hydrogen | 15.49 | 22.62 | 28.44 | 89.45 |
| 5 | Gemini 3.7 Flash | 17.90 | 25.36 | 30.53 | 86.87 |
| 6 | Gemma 4 31B | 18.24 | 1270.30 | 32.10 | 85.24 |
| 7 | Bina 0.4 Rizeh (71.2M) | 18.66 | 21.27 | 36.83 | 87.55 |
| 8 | Bina 0.4 Microscopy (9.55M) | 19.08 | 22.64 | 39.77 | 85.92 |
| 9 | Bina 0.4 Koochik (630.8M) | 20.82 | 25.14 | 34.58 | 86.38 |
| 10 | Qwen 3.8 Flash | 22.53 | 29.17 | 40.99 | 81.60 |
| 11 | Claude Opus 5 Fast | 22.62 | 28.09 | 36.56 | 84.08 |
| 12 | Gemini 3.1 Pro Preview | 22.97 | 45.54 | 39.16 | 85.40 |
| 13 | Bina Koochik 0.1 | 26.94 | 31.02 | 41.03 | 83.98 |
| 14 | OCRia nano 1 | 29.69 | 32.97 | 55.84 | 74.35 |
| 15 | GPT-5.6 Sol | 31.75 | 36.23 | 45.80 | 77.39 |
| 16 | Muse Spark 1.2 Contributor | 33.39 | 36.61 | 52.02 | 73.73 |
| 17 | Grok 4.6 | 37.18 | 40.96 | 54.12 | 70.31 |
| 18 | Bina 0.3 | 38.68 | 40.79 | 51.56 | 82.18 |
| 19 | OCRia 1 | 40.13 | 51.09 | 63.78 | 71.36 |
| 20 | Nemotron 3.5 Parse | 42.26 | 49.74 | 67.25 | 55.25 |
| 21 | DeepSeek V4 Flash Vision Exp | 45.66 | 48.96 | 64.54 | 47.93 |
| 22 | Inkling 2 Mini | 49.70 | 536.19 | 68.32 | 56.96 |
| 23 | Kimi K3 | 58.98 | 60.99 | 67.90 | 57.45 |
| 24 | Surya OCR 2.5 | 59.39 | 74.29 | 66.64 | 55.21 |
| 25 | Surya 2 | 78.31 | 99.83 | 70.65 | 53.82 |
| 26 | GLM 5.3 Flash | 78.87 | 79.98 | 87.14 | 23.80 |
| 27 | Unlimited OCR | 86.73 | 107.14 | 119.69 | 32.10 |
| 28 | MiniCPM-V 4.7 1B (RaahNaame r29) | 110.78 | 135.09 | 181.37 | 63.92 |
| 29 | dots.mocr | 188.08 | 192.28 | 198.51 | 56.92 |
| 30 | Ternary Bonsai 2 27B | 321.66 | 358.05 | 395.69 | 65.27 |
| 31 | MiniCPM-V 4.7 1B | 353.80 | 353.81 | 386.41 | 41.25 |
Ranked by no-space CER. Older runs of Rizeh and Koochik and a Gemma 4 26B A4B run that failed with HTTP 404 errors are left out. On the public scorer, which counts spaces, Microscopy also scores below Gemini 4 Argon and Carbon. CER above 100 means the model produced more wrong text than there was text, for example through repetition or HTML output.
50 handwriting pages (dev50, full page including printed form text)
| Microscopy | Microscopy --single |
Rizeh | Koochik |
|---|---|---|---|
| 14.45 | 14.76 | 10.89 | 9.60 |
Full handwritten pages are where the larger models still lead. About half of Microscopy's gap here is reading order on busy forms, not misread characters: scored without regard to order, it reaches 9.5.
Financial lines and symbols (60 generated lines)
These are generated Persian financial lines with ٪, +, <, >, mixed Persian/Latin digits and simulated scan damage. They are cleaner than real documents.
| Microscopy | Rizeh | Koochik | |
|---|---|---|---|
| CER ↓ | 9.60 | 11.24 | 3.63 |
| Exact lines ↑ | 36/60 | 26/60 | 47/60 |
٪ read ↑ |
30/30 | 26/30 | 22/30 |
+ read ↑ |
2/12 | 3/12 | 4/12 |
< / > read ↑ |
4/12 | 4/12 | 1/12 (3 flipped) |
All three models often drop +, < and >. Do not rely on them for those symbols in financial documents without a check.
How it works
- Line detection. Two 0.71M-parameter detectors (inverted-residual encoder + FPN, DB-style kernel maps at half resolution) run on the page at a 1024-pixel long side.
- The main detector learned from synthetic pages, real scans and, by distillation, from the probability maps of Rizeh's 38.4M Surya-based line detector. No Surya weights are included here.
- The second detector is tuned for real printed scans and tables.
- Reading. A 19-block CTC line reader (8.13M parameters, 1,617-symbol vocabulary) reads each 64-pixel-high line crop. It was distilled from Bina 0.4 Rizeh's recognizer, then fine-tuned on about 190k real line crops cut by the detector itself from training pages and matched to their true text.
- Router. Each page is read once per detector, and the reading with more confident text is kept.
- Assembly. Right-to-left reading order: columns split at gaps wider than 0.4 line heights, then rows. Tiny noise boxes and duplicate reads are removed. There is no learned layout model.
All thresholds were chosen on training-distribution pages, not on the benchmarks. The 193-crop and dev50 sets have been used repeatedly during development, so they are development benchmarks, not untouched held-out tests.
Files:
| File | What it is | Parameters |
|---|---|---|
reader.onnx |
CTC line reader (ONNX, used by default) | 8,134,873 |
reader.int8.onnx |
the same reader, INT8 convolutions (--reader) |
8,134,873 |
reader.safetensors |
CTC line reader (PyTorch weights, --backend torch) |
8,134,873 |
det_main.onnx |
main line detector | 706,017 |
det_print.onnx |
print/table line detector | 706,017 |
vocab.json |
1,617-symbol vocabulary | |
microscopy.py |
the whole pipeline and CLI, about 270 lines | |
bina_rtl.py |
right-to-left text helper |
Limitations
- Tables are weak (58 CER on the 193 tables). Koochik is much better at tables.
- Busy handwritten forms: reading order on exam sheets and forms with many labels is the largest error source.
- Symbols
+,<,>are often dropped (see above). - Very dense full pages lose small print, because detection runs at 1024 px. Crop such pages into regions first.
- Historical manuscripts (old nastaliq and shekasteh) are not supported.
- Persian-first. Latin text and digits are read, but other languages were not a goal.
License
CC BY-NC 4.0, matching the non-commercial training data.
فارسی
بینا ۰٫۴ میکروسکوپی کوچکترین عضو خانوادهی OCR فارسی بینا ۰٫۴ است: ۹٫۵۵ میلیون پارامتر، روی CPU لپتاپ حدود ۰٫۸ ثانیه برای هر صفحه. متن چاپی، دستنویس، فرم، تصویر صفحهنمایش، روزنامه و ریاضی را از تصویر یا PDF میخواند.
تا ۲۹ نوامبر ۲۰۲۶، روی بنچمارک ۱۹۳ برش (۳۴ مدل) فقط بینا ۰٫۴ ریزه (۷٫۵ برابر بزرگتر) و شش مدل گوگل (Gemini 4 Argon، Neon، Carbon، Hydrogen، Gemini 3.7 Flash و Gemma 4 31B) از میکروسکوپی بهترند. میکروسکوپی از بهترین مدلهای Anthropic، OpenAI، Alibaba، Meta، xAI، DeepSeek و بقیهی آزمایشگاهها، و از بینا ۰٫۴ کوچیک با حدود ۶۶ برابر حجم، بهتر است.
pip install -r requirements.txt
python microscopy.py page.jpg document.pdf --out results
محدودیتها: جدولها هنوز ضعیفاند، ترتیب خواندن فرمهای شلوغ دستنویس جای بهبود دارد، و علامتهای + و < و > گاهی جا میافتند.


