Notes012 min read
Zero inference APIs: ML in the browser tab
VeriLens, VeriDoc Studio and DocuForge run detection, OCR and forensics client-side. What it took to make “the document never leaves the device” true.
Document intelligence is usually a black-box API: upload the passport, receive a verdict. Three of my projects take the opposite constraint — every stage runs in the browser and, after the initial load, there are zero network calls. The constraint shaped almost every engineering decision.
Make every stage replaceable
VeriDoc Studio verifies Aadhaar, PAN, Driving Licence, Passport and Voter ID through eight stages — image-quality scoring, WASM OCR, type classification, field parsing, checksum validation, ONNX face detection and ELA forgery analysis. Every stage resolves through a ModelRegistry, so the OCR engine, the classifier or the face detector can be swapped for a fine-tuned model without touching the UI.
Aadhaar numbers are validated with the real Verhoeff checksum UIDAI uses, and the parser corrects the classic OCR confusions (O→0, I/L→1) behind digit-presence guards so it never “corrects” a genuine letter.
Benchmark the exact engines you ship
DocuForge runs five forensic engines — Error Level Analysis, copy-move detection, noise consistency, EXIF forensics and JPEG quantisation analysis — each a vanilla ES2017 module producing a heatmap and a score, fused with a weighting that favours spatial evidence. The important part is how it is measured: the production engines run end-to-end in Chromium under Playwright against a reproducible 64-document dataset, including recompression and noise attacks.
ROC-AUC 0.947 on the clean split and 0.936 after JPEG q60 laundering — measured on the code that ships, not on a Python re-implementation of it.
Keep a research path back into the browser
Both projects carry a PyTorch layer: DocuForge trains an EfficientNet-B0 over ELA maps of CASIA v2 with an evaluation harness and a model card; VeriDoc goes from synthetic cards through LoRA fine-tuning to ONNX export. The loop closes when a trained model drops back into the registry and the same Playwright suite decides whether it earned its place.
- Payload is a budget line — see When INT8 was the wrong answer.
- Everything is vendored; a CDN outage cannot break a verification.
- End-to-end tests are the accuracy gate, because the browser is the runtime.
- WebAssembly
- ONNX
- Forensics