跪拜 Guibai
← All articles
Frontend · JavaScript · AI Programming

A 1.5M-Parameter OCR Model Now Runs Entirely in the Browser

By 小帅不太帅 ·
Read original on juejin.cn ↗ Google Translate ↗ Alt translation

Client-side OCR at 6MB eliminates server costs, latency, and data-leaving-the-device privacy concerns for a workload that previously required backend infrastructure. A model this small also challenges the reflex to reach for multi-billion-parameter multimodal models when a narrow specialist outperforms them on the actual task.

Summary

PP-OCRv6 Tiny achieves 80.6% text detection and 73.5% recognition accuracy across 49 languages while weighing just 1.5M parameters. The model splits the task into two stages: a detection network locates text boxes, and a recognition network reads the characters inside each box. Together with a dictionary file, the total download is roughly 6MB.

In-browser inference works by converting the PaddleOCR model to ONNX format and loading it through Microsoft's onnxruntime-web, which tries WebGPU, WebGL, and WASM backends in sequence. WASM provides the broadest compatibility and is fast enough for a model this small; GPU backends can help but introduce CPU-GPU transfer overhead that may not pay off at this scale.

A live demo at ocr.laifuyou.com runs entirely on-device with no server round-trips, no queues, and no per-token billing. The source code is available on GitHub.

Takeaways
PP-OCRv6 Tiny is a 1.5M-parameter OCR model that runs in the browser at ~6MB total download size.
The model handles 49 languages (Japanese excluded due to vocabulary size) with 80.6% detection and 73.5% recognition accuracy.
Text detection accuracy beats general multimodal models like Qwen3-VL-235B, which scored 46.8% on the same benchmark.
OCR splits into two steps: detection finds text regions, recognition reads the characters inside each region.
Paddle2ONNX converts the trained model to ONNX format; onnxruntime-web executes it in the browser with WebGPU, WebGL, or WASM backends.
WASM is the most compatible backend and is sufficient for small models; GPU backends may not be faster due to data-transfer overhead.
Three tiers are available: Tiny (1.5M, ~6MB), Small (7.7M, ~30MB), and Medium (34.5M, ~132MB), all sharing the same architecture.
Conclusions

OCR is a recognition problem, not a generation problem: the answer already exists in the pixels, so a narrow model can outperform a general-purpose LLM that must model far more than visual patterns.

Extreme parameter compression works when the task boundary is narrow. Tiny sacrifices the recognition encoder and uses distillation to recover accuracy, dropping Japanese support because the vocabulary alone would bloat the model.

The browser is quietly becoming a viable AI runtime. WASM plus WebGPU/WebGL gives JavaScript access to near-native inference speeds, and a single npm package replaces a Python server stack for small models.

Atwood's Law is playing out for AI inference: anything that can be compiled to WASM and run in JavaScript eventually will be, shifting compute from the server back to the client for latency-sensitive, privacy-sensitive workloads.

Concepts & terms
ONNX (Open Neural Network Exchange)
A standard format for representing machine learning models, allowing models trained in one framework (e.g., PaddlePaddle) to be run in another runtime (e.g., onnxruntime-web in the browser).
WebAssembly (WASM)
A binary instruction format that browsers execute at near-native speed. Code written in C, C++, or Rust can be compiled to WASM, enabling performance-critical workloads like AI inference to run client-side without plugins.
CTC Decoding (Connectionist Temporal Classification)
An algorithm that converts a sequence of per-frame probability distributions (from the recognition model) into a final text string, handling variable-length outputs without requiring pre-segmented input.
DBNet (Differentiable Binarization Network)
A text detection architecture that produces a probability map of text regions, then applies a differentiable binarization step to extract precise bounding boxes. Used as the detection stage in PP-OCRv6.
Source: juejin.cn ↗ Google Translate ↗ Backup ↗