Guide · OCR Training Data
How to Build OCR Training Data Without Real Documents
Real documents are the worst possible source of OCR training data: they're full of PII, expensive to label, and legally radioactive. Here's how synthetic document generation solves all three problems — and what a production-quality synthetic OCR dataset actually needs.
Why real documents fail as training data
Every scanned invoice, contract, or form in your archive contains names, addresses, account numbers, and dollar amounts belonging to real people and companies. Using them as training data means privacy review, redaction pipelines, data-processing agreements, and — in regulated industries — often a flat "no" from legal. Even when cleared, real documents arrive unlabeled: someone still has to transcribe the ground truth, at roughly $1–5 per page for accurate word-level annotation.
Synthetic documents invert the economics. Because the generator composes the document, it knows every word, box, and table cell before rendering — ground truth is free, perfect, and automatic. And because every entity is fabricated, there is no PII to leak, redact, or review.
What a usable synthetic OCR dataset requires
1. Ground truth captured before corruption
The single most common failure in homemade generators is recovering "ground truth" from the rendered file — which breaks the moment you add noise. A proper pipeline records a canonical document model (titles, paragraphs, tables, merged cells) first, then renders and degrades. The clean model remains the label even when the page is 80% corrupted.
2. Controllable degradation
OCR models trained only on clean pages collapse on real scans. You need a degradation spectrum — from pristine to barely legible — modeled on actual OCR failure modes (character substitution, broken glyphs), not just Gaussian blur. A continuous 0–100% slider lets you build curriculum datasets: train on clean, fine-tune on progressively degraded twins of the same documents (same seed, different quality).
3. Layout diversity
A dataset of 50,000 invoices teaches your model to read invoices. Real pipelines see letters, memos, forms, receipts, court filings, spreadsheets, and email printouts. Aim for 20+ structurally distinct document types with varied fonts, layouts, and table structures.
4. Standard annotation formats
Your labels are only useful if your training stack can read them. The de facto standards: COCO for word/text detection, LayoutLM JSONL for token classification with normalized boxes, FUNSD for form understanding (question/answer/header roles with links), and DocVQA for document question answering. See our guides on each format below.
5. Deterministic splits and reproducibility
Type-balanced train/validation/test splits with a fixed seed, checksummed outputs, and a replayable recipe file mean a colleague can regenerate your exact dataset — the difference between a science experiment and a shell script you ran once.
A concrete workflow
# 1. Generate a seeded, mixed-type dataset with annotations + splits
docsetgen --count 3000 --quality 100 --seed 42
# 2. Generate degraded twins of the same documents
docsetgen --count 3000 --quality 40 --seed 42
# 3. Train detection on COCO export, token classification on LayoutLM JSONL
# 4. Evaluate on the held-out test split; validate against manifest.jsonl
Because both runs share a seed, every degraded page has a pixel-aligned clean twin and identical ground truth — exact before/after pairs for denoising or robustness training.
Frequently asked questions
Is synthetic data legal to use for commercial ML training?
Yes, provided the generator's license permits it. DocSet Generator output is the customer's to use for any lawful purpose, including commercial ML training, with no attribution required.
How much synthetic data do I need to train an OCR model?
Fine-tuning an existing model (LayoutLM, Donut, TrOCR) typically needs 1,000–10,000 labeled pages. Training detection from scratch needs far more. Synthetic generation makes the marginal page essentially free — DocSet Generator produces ~300 clean docs/second.
Will a model trained on synthetic documents work on real ones?
Yes, if the synthetic data covers realistic layouts and degradation. The standard practice is synthetic pre-training followed by a small real-data fine-tune — the synthetic phase does the heavy lifting on layout and noise robustness.
Generate this data yourself, locally
DocSet Generator is a $199 one-time desktop app (Windows & Linux) that produces synthetic documents across 33 types with controllable OCR degradation, ground truth, and ML-ready COCO / LayoutLM / FUNSD / DocVQA exports — all offline, with zero real PII.