Karb-4B - Ukrainian handwritten document recognition
2 min readupdated
Karb-4B is a specialized 4.03B-parameter language model built on Qwen/Qwen3.5-4B for comprehensive document analysis. It handles page layout detection, region classification (7 classes), and character-level transcription in a single pass. Optimized for Ukrainian handwritten texts, it delivers high accuracy on the RUKOPYS v3 dataset. It suits researchers, archivists, and developers digitizing old manuscripts, historical documents, or forms.
Key features
- High accuracy: 94.55% Composite metric on the official RUKOPYS v3 test.
- Vocabulary optimization: reduced vocabulary from 248K to 24.5K tokens to speed up inference.
- Compact format: region encoding via a flat tuple instead of JSON, reducing sequence length.
- Quantization options: available in BF16, plus FP8 and AWQ quantized versions to save VRAM.
What you can do
- Archive digitization: recognize handwriting in historical Ukrainian documents and letters.
- Structure analysis: automatically split pages into tables, formulas, printed text, and illustrations.
- Pipeline integration: use the model via vLLM or Transformers for batch processing of scans.
Example
Example of model initialization and layout parsing using Transformers:
import torch
from PIL import Image, ImageOps
from transformers import AutoModelForImageTextToText, AutoProcessor
MODEL_ID = "Deelle/Karb-4B"
processor = AutoProcessor.from_pretrained(MODEL_ID, trust_remote_code=True)
model = AutoModelForImageTextToText.from_pretrained(MODEL_ID, dtype="auto", trust_remote_code=True).to("cuda")
image = ImageOps.exif_transpose(Image.open("document.jpg")).convert("RGB")
Read more
DetailsBenchmarks: Composite 94.55%, Page CER 6.53%, Det F1 95.42%
VRAM requirements: from 4.36 GiB (AWQ) to 9.29 GiB (BF16)
Limitations: trained on RUKOPYS v2.2, general VQA capabilities removed during vocabulary pruning
License: Apache 2.0










Comments