--- language: he tags: - ocr - handwriting - hebrew - onnx - android license: mit --- # Hebrew handwriting OCR: on-device model files Files downloaded by the Android app (github.com/cyttic/android-hwrg), which runs the whole pipeline on the phone. | File | What | |---|---| | `line_int8.onnx` | CTC line model `cyttic/exp35-trocr-base-en-ctc-seqhead-allreal-synpunct` (TrOCR-base ViT encoder + 2-layer transformer CTC head, 198 classes), ONNX opset 17, dynamic int8 (all constant-weight MatMuls except the ViT layer-2 MLP fc2, kept in fp32). Inputs: `pixel_values` (B, 3, 384, 384) in [-1, 1], `cols` (B,) int64; output `log_probs` (B, 288, 198). | | `line_large_int8.onnx` | CTC line model `cyttic/exp35-trocr-large-en-ctc-seqhead-allreal-synpunct` (TrOCR-large ViT encoder, 24 layers + 2-layer transformer CTC head), same inputs/outputs; dynamic int8 except the ViT layer-0 MLP fc2 (fp32). Decoded with the punctuation-aware LM fusion (alpha 0.3, beta 0.6, LM on Hebrew letters + space). | | `charset.json` | `chars[k]` = character of class k; `chars[0]` = CTC blank. | | `heb_char6_kn.bin.gz` | Character 6-gram LM, interpolated Kneser-Ney (Ben-Yehuda + DictaGen text), binary layout in `tools/export_lm.py`. | | `mlm_tiny_int8.onnx` | Language check (optional second pass): **`dicta-il/dictabert-tiny`** by Dicta (CC BY 4.0, not MIT), converted to ONNX; the 128k x 312 word table in int8 with one scale per row, everything else fp32. Inputs `input_ids`, `attention_mask` (R, L) int64 with `[MASK]` at `pos` (R,), `tgt` (R,) = the original token; output `logp` (R,) = ln P(tgt at pos). The app keeps the line decoder's 16 best lines and picks the one with the best beam score + 0.25 x PLL + 2.0 x word pieces. Made by `tools/export_mlm.py`. | | `dictabert_vocab.txt` | dictabert-tiny's WordPiece vocabulary (line number = token id; CC BY 4.0, Dicta). | The line finder is `PaddlePaddle/PP-OCRv5_server_det_onnx` (Apache-2.0), downloaded from its own repo. License: MIT for our files; `mlm_tiny_int8.onnx` and `dictabert_vocab.txt` are derived from dicta-il/dictabert-tiny and stay under its CC BY 4.0 license (Shmidman et al., DictaBERT, 2023).