Skip to content
Inference Academy

Document AI: OCR, layout, tables and extraction

How machines read documents: classic OCR pipelines, layout analysis and table structure recognition, OCR-specialised vision-language models and general VLMs; what each gets wrong; and how to measure document AI with character and word error rates, field accuracy and table cell accuracy, with runnable metrics.

By

15 min · verified 2026-11Pro
Share

A large share of business data lives in PDFs, scans, photos of receipts and forms. Document AI turns them into text, structure and fields. The document processing lesson covers the pipeline for RAG; this lesson looks at the models underneath and how to measure them.

#Three generations of approach

Approach How it works Strengths Weaknesses
Classic OCR (for example Tesseract, PaddleOCR) Detect text lines, recognise characters Fast, runs on CPU, mature Reading order, tables, handwriting, complex layouts
Layout and table models plus OCR Detect regions (title, paragraph, table, figure) and table structure, then OCR each region Structure and reading order; Markdown or JSON output; runs locally Pipelines of several models; unusual layouts
Vision-language models (OCR-specialised small VLMs, or general VLMs) Read the page image and generate text, Markdown or fields directly Messy layouts, forms, charts, handwriting; one model; can follow an extraction schema Slower, GPU needed, can invent plausible values

Most production systems combine them: a fast parser for clean digital pages, layout-aware conversion for structured documents, and a VLM for the hard pages and for field extraction (how VLMs work).

#What goes wrong

  • Reading order: two-column pages read straight across; footnotes inserted mid-sentence.
  • Tables: merged cells, multi-line cells and tables split across pages; values attached to the wrong row.
  • Characters: O versus 0, l versus 1, decimal commas, lost minus signs. One wrong digit in a total matters more than a hundred wrong letters elsewhere.
  • Hallucination (VLMs): a blurred value replaced with a plausible one. This is the most dangerous error because it looks right.
  • Rotation, low resolution, stamps and handwriting.

Pro content

Keep reading with Inference Academy Pro

Unlock the rest of this lesson, plus every advanced lesson, hands-on lab, the larger playground models and completion certificates.

Still to come in this lesson

  1. Measuring document AI
  2. Making extraction reliable
  3. Running it locally
  4. Exercises

You will be able to answer

  • Two parsers have the same character error rate on an invoice, but one has the total wrong. What does that show?
  • A table has every cell's text right but two values swapped between rows. Which metric catches it?
  • When is a general vision-language model a good choice for document extraction?
  • What does layout analysis add on top of OCR?
  • How should you guard against a VLM inventing a number in an extracted invoice?