AI Agentic Handbook
Chunking & Ingestion

OCR (optical character recognition)

Budding levelReviewed Oct 2026 · fast-movingIn 2 interview questions

Turning pictures of text — scans, photos, faxes — into text a computer can actually read. Mistakes here spread into everything downstream.

In plain English

Scanned documents and photos are just pictures. Nothing can search the words in them until optical character recognition (OCR) converts the shapes of letters into real text.

If OCR reads 'O' as '0' or '1' as 'l', your search and your AI answers inherit those mistakes — so it is worth looking at the OCR output before building anything on top of it.

Analogy

A typist copying a faded photocopy: fast, mostly right, and quietly wrong on smudged digits and handwriting until somebody notices much later.

Common pitfall

OCR output reads fluently, which makes it easy to trust. A 2% character error rate is about one wrong character every ten words — plenty to mangle part numbers, invoice totals and dates.

How it actually works

Classic OCR (Tesseract 5, LSTM-based) detects text lines and recognises characters; on clean 300-DPI printed scans it achieves character error rates (CER) around 1–2%, rising sharply below 200 DPI, on skewed photos, tables and handwriting. Managed services (AWS Textract, Google Document AI, Azure AI Document Intelligence) add layout, tables, forms and handwriting at ~$1.50 per 1,000 pages for plain text detection (list prices, Oct 2026, illustrative). Open models such as PaddleOCR and docTR, and vision LLMs, handle harder layouts; vision LLMs can silently 'correct' or invent text, so they need confidence checks on numbers.

Production concerns: deskew and binarise before recognition, request word-level confidence and route low-confidence pages to a stronger engine or human review, keep bounding boxes so citations can highlight the source region, and store the OCR engine and version in Chunk metadata. OCR errors hurt BM25 most (an exact token 'P0L-4471' no longer matches 'POL-4471') and dense retrieval less. OCR usually runs inside Layout-aware parsing.

What I'd ship on day one

Preprocess (deskew, 300 DPI, binarise), Tesseract 5 or PaddleOCR with word confidences, escalate pages with mean confidence <80 to a managed OCR service, keep bounding boxes and engine version per page, and send identifier fields (policy numbers, MRNs, invoice ids) with confidence <90 to human review.

Worked example

Insurance claims intake: 400k faxed and photographed forms per month. Tesseract on raw images: CER 6.8%, policy-number exact-match 71%. After deskew, 300-DPI resampling and routing pages with mean confidence <80 to Textract (22% of pages): CER 1.9%, policy-number match 96%.

Cost: 88k Textract pages × $1.50/1k ≈ $130/month, versus ~$600/month if every page went to Textract.

In the interview

Show the routing rather than a single tool: 'Cheap OCR on everything, confidence per page, escalate the worst 15–25% to a managed engine or a vision model, and human review for the fields that move money — policy numbers, amounts. I measure character error rate on a 200-page labelled sample per source.' Expect 'why not just a vision LLM everywhere?' — cost at volume, and its habit of inventing plausible digits without flinching.

Pages in400k
Tesseract conf ≥80312k
Escalated to Textract88k
Human review (IDs)4k
Confidence routing: cheap OCR first, expensive engines only for hard pages.
EngineStrengthPrice (Oct 2026)
Tesseract 5Clean print, freeCPU only
Textract / Doc AITables, forms, handwriting~$1.50/1k pages text
Vision LLMOdd layouts~1.5–2k tokens/page
Illustrative list prices; check current pricing.

Numbers worth knowing

Tesseract CER
~1–2% clean 300-DPI print; 5–10%+ on faxes/photosprinted Latin script, no handwriting
Managed OCR price
~$1.50 per 1,000 pagesplain text detection, Textract / Document AI list price (illustrative, Oct 2026)
Words per character error at 2% CER
~1 error per 8–10 wordsaverage English word ≈ 5–6 characters with space

How to decide

WhenDo this
Born-digital PDFs with a text layerSkip OCR; extract the text layer.
Clean scans, high volumeTesseract or PaddleOCR with confidence routing.
Forms, handwriting or tables in scansManaged OCR with forms/tables features, human review for money fields.

Cost maths

Monthly = pages × (escalation rate × managed price + review rate × human cost). 400k pages, 22% escalated at $1.50/1k = $132; 1% human review at an assumed $0.10/page = $400. All-managed would be $600 plus review. Self-hosted Tesseract at ~1 s/page needs ~110 CPU-hours/month ≈ $5.

Operating it

Time to scale up when…
  • CER on the labelled sample above 3% for any source: add preprocessing or escalate that source
  • Escalation rate above 40%: the cheap engine is the wrong tool for this source
  • Identifier exact-match below 95%: add human review for those fields
What to monitor
  • Mean OCR confidence per source per day: alert on a drop >10 points
  • Identifier validation failure rate (regex/checksum): alert above 2%
  • Escalation rate to managed OCR: alert on a 2× jump (cost and quality signal)

When it goes wrong

What users saw

Claims adjusters could not find claims by policy number for one broker's submissions.

How it was caught

Search-zero-results rate for policy-number queries was 30% for that broker vs 3% overall.

Root cause

The broker switched to low-resolution phone photos; Tesseract read 'O' as '0' and '1' as 'I', and nothing checked confidence.

Fix

Confidence routing to managed OCR, a policy-number regex plus checksum validation, and fuzzy matching (edit distance 1) for identifier search.

Sources

  1. Tesseract OCR — tesseract-ocr, 2024docs
  2. Docling Technical Report — Auer et al. (IBM Research), 2024paper

Check yourself

Three questions. Every option is explained once you answer.

1ConceptWhy do OCR errors hurt BM25 retrieval more than dense retrieval?
2ScenarioA bank ingests a mix of born-digital PDF statements and photographed handwritten forms containing account numbers. Which setup follows the page's defaults?
3Calculation1M pages/month. 18% are escalated to managed OCR at $1.50 per 1,000 pages, and 1% go to human review at $0.10/page. What is the monthly escalation-plus-review cost?