quadevs

Local AI model for faded faxes

A custom OCR model, trained on our own hardware, reads faded medical faxes that commercial OCR engines turned into nonsense. It runs on the processing server's CPU. A word enters the archive only when the model is sure of it, and patient data never leaves the company network.

A fax, a lens and a server with a small neural network inside a locked boundary, and a clean page with two dotted lines

What is a custom OCR model?

A custom OCR model is a text reader trained on one kind of document, here faded medical faxes. Ours is a local AI model: it is trained and served on the company's own machines, so no page, crop or extracted word goes to a cloud service. Patient data on each page stays on the servers that already hold it: HIPAA-compliant OCR with no outside vendor and no new business associate agreement.

Faxes no OCR engine could read

Medical records arrived as faxes and as scans of scans. Many pages held small images at fax resolution, with medication and problem lists a person could barely make out. Every commercial OCR engine we tuned returned nonsense on the worst parts. Those pages went into the clinical archive as pictures nobody could search.

Image classify and OCR pipeline Scan and fax image clean-up Clinical document watcher Tool-use agent · production

Two shortcuts were closed. Cloud vision models read the test pages correctly, but patient data may not leave the company network, so they could never go live. General local vision models did worse. On faded text they guessed with confidence and put one drug name in place of another. In a clinical record, a confident wrong word does more harm than a gap.

OCR model training on a 4 GB GPU

The work had two layers. The first is an opt-in endpoint in the document-processing API, built on .NET 10 and LEADTOOLS. It renders the page at a higher resolution, copies it to grayscale, scales it up and sharpens it before recognition. A strict gate then checks each word. A word is written back onto the page only when its characters clear the confidence bar; every other word stays as the original ink. The standard conversion path is unchanged, and each endpoint chooses whether to use the new one.

Healthcare SEO program Document reformat at scale Mobile medication selector Multilingual clinic platform

The second layer is the reader. We fine-tuned a compact transformer OCR model, TrOCR with LoRA adapters, on this one kind of damage. The training ran on our own consumer GPU with 4 GB of memory, on data from local sources only. Synthetic pairs copy the exact damage: medical text is rendered, cut to fax resolution, compressed and scaled up again. Line crops from real faded pages were labelled by a larger local teacher model. Golden pairs came from documents that had a second, readable copy in the archive.

Decoding is limited to a medical lexicon, so drug names and ICD codes stay real words, and an unsure read is marked as unsure. The model runs as ONNX on the server's CPUs. That makes it on-premise OCR from end to end: production needs no GPU and makes no cloud call.

Stack and engineering choices

  • TrOCR encoder-decoder with a LoRA fine-tune.
  • Training on a 4 GB consumer GPU.
  • ONNX inference on server CPUs.
  • Synthetic pairs that copy fax damage.
  • Real line crops labelled by a teacher model.
  • Decoding limited to a medical lexicon.
  • Per-word confidence gate.
  • Opt-in endpoint, standard path unchanged.

Readable pages and no invented words

Fax OCR on the benchmark documents changed most on the narrative parts. Where the engines returned nonsense, the model now reads most of the text, checked against transcripts made by hand. The hardest small print is either read within the confidence gate or left as the original ink. No invented word enters the archive: a word nobody can read stays visibly unreadable.

The loop repeats inside the network. A new kind of damage needs new synthetic pairs and one more LoRA pass on the same GPU, and serving stays on CPUs. The same setup fits other on-premise AI work on patient documents, since training and serving both stay on the company's own machines.