Skip to content
All notes

How we trained a Lao OCR model for $0

A Lao line reader that runs in the browser, trained on a free cloud GPU: what we did, the numbers, and what it still gets wrong.

  • AI
  • OCR
  • Lao language
  • ONNX

Our free Lao OCR tool reads scanned Lao documents directly in the visitor's browser — the page never leaves the device. This note explains how we built the reader behind it, and what it cost: nothing.

Two readers, each doing what it is good at

The tool uses two models together:

  • Tesseract (open source) finds the text lines and ruled tables on the page and reads English.
  • Our own Lao line reader then reads each Lao line again. It is a small neural network (a CRNN with about 2.8 million parameters) that looks at one line image and outputs Lao characters.

Splitting the job this way kept the new model small and focused: it never has to understand page layout, only one line at a time.

Data: real documents, split the honest way

We trained on line images cut from real Lao documents with known text — about 190,000 lines, plus generated lines for rare characters. The most important rule: split by document, not by line. If lines from the same document appear in both training and test data, the scores look better than they really are. We test on documents the model has never seen.

Training on a free GPU

The full training run took about two and a half hours on a free Kaggle T4 GPU. The finished model is converted to ONNX and compressed to 8-bit numbers: 2.9 MB, with the same accuracy as the full-size version. In the browser it runs with onnxruntime-web in a background worker, and it is skipped on slow connections, where the tool falls back to Tesseract alone.

The numbers

Measured as wrong characters per 100, on the same held-out data:

Tesseract aloneWith our Lao reader
Single Lao lines1.7–2.00.8
Whole pages (82 documents never seen in training)3.1–3.32.2–2.5

Whole pages score worse than single lines because layout mistakes — a missed line, a broken table — count too.

What we learned along the way

  • Check the reference text. Three of the "worst" pages were not OCR mistakes at all: the stored correct text belonged to another page or another version of the law.
  • Faint print is not an empty page. A rule that skipped pages with little ink was dropping light scans; it now also counts dark pixels.
  • Junk Latin letters are a signal. When the English model turns poorly printed Lao into random Latin letters, the Lao reader reads that line again.

What it still gets wrong

Stamps, handwriting, diagrams, photos of screens and sideways tables. Names, numbers and dates should always be checked before the text is used. For a page that must be right, the tool offers an optional AI re-check that uses credits.