Skip to content
AI.info

Computer vision

Document Vision and Layout Understanding

Learn how document systems combine page images, OCR, geometry, reading order, tables, forms, and field-level validation.

By the end you can

Key idea

A page is an interface, not a bag of words

Headings, columns, boxes, alignment, whitespace, and typography communicate relationships; two pages can contain the same words yet imply different records, totals, or obligations.

Document vision therefore asks more than “what text appears?” It asks which element belongs to which field, row, section, signature, or footnote.

The public datasets show how the annotation cost scales with structure. FUNSD, released in 2019, “comprises 199 real, fully annotated, scanned forms”, split 149 training and 50 testing, holding 22,512 and 8,973 words for 31,485 in total. It was built for “text detection, optical character recognition, spatial layout analysis, and entity labeling/linking”. Its annotation goes further than words. Each semantic entity carries “a list of links with other entities”, so a question entity is tied to its answer. Cheaper labelling scales further. PubLayNet, also from 2019, was built “by automatically matching the XML representations and the content of over 1 million PDF articles that are publicly available on PubMed Central”, and carries “over 360 thousand document images, where typical document layout elements are annotated”. RVL-CDIP, from 2015, is “a new labelled subset of the IIT-CDIP collection, containing 400,000 document images across 16 categories”.

DocLayNet paid for hands instead, and in doing so measured the thing every other dataset assumes. IBM Research published it in 2022: 80,863 manually annotated PDF pages across 11 layout classes and six document domains — financial reports, scientific articles, laws and regulations, government tenders, manuals, patents — carrying 91,104 annotation instances and 1,107,470 labelled boxes. A supervised group of 40 annotators was assembled and trained. After a 12-week training phase 8 of them did not pass the bar, and the remaining 32 annotated the 80K pages. Crucially, 7,059 pages were annotated twice and 1,591 three times. On that triple-annotated subset, trained annotators working blind to one another agree about what a region is only 82–83% of the time at mAP@0.5–0.95. Title lands at 60–72%, Picture at 69–71%, Table at 77–81%; only page-footers reach 93–94%. Of the models trained on the dataset the authors write: “We also demonstrate that these models fall approximately 10% behind the inter-annotator agreement.” A page is an interface that two trained people read differently one time in six.

Text accuracy can be high while document interpretation is wrong.

Visual

Five layers of a document understanding system

Each layer can fail independently and should be evaluated separately. The first layer is not a formality. The digit substitutions David Kriesel published in 2013 happened inside the JBIG2 compression of Xerox WorkCentre and ColorQube scanners, before any recognizer saw the page. A document whose text layer was later read with perfect character accuracy still carried an 8 where the paper said 6. Page capture is where evidence is created or destroyed. Every layer above it can only be as faithful as what it was handed.

FigureLayers · 5 layers
  1. 01

    Page capture

    Image quality, orientation, cropping, and page completeness.

  2. 02

    Visual regions

    Text blocks, tables, figures, signatures, stamps, and separators.

  3. 03

    Reading structure

    Order, hierarchy, columns, rows, and parent-child relationships.

  4. 04

    Semantic fields

    Invoice number, claimant, diagnosis, clause, or total.

  5. 05

    Business validation

    Cross-field checks, policy rules, and human review.

Comparison

Three ways to represent a page

Architecture choice depends on layout variability, annotation supply, and required evidence. The three options are not equally good at recovering structure, and that has been measured rather than argued. IBM Research Australia scored the field against its own table test set, PubTabNet, in 2020. The best off-the-shelf PDF tool of the coordinates-and-rules kind, Camelot, reached 73.0% TEDS. Tabula reached 67.9, Adobe Acrobat Pro working on images 53.7, PDFPlumber 40.4. The authors' own EDD model, working from the page image alone with no PDF text layer to lean on, reached 88.3%. The handcrafted pipeline is the one you can inspect line by line. It is also the one giving up roughly fifteen TEDS points to a model that was never told where the rules were.

FigureComparison · 3 columns

OCR plus rules

Recognized text is matched with coordinates and handcrafted logic.

  • Fast for stable templates
  • Easy to inspect
  • Fragile under redesign
  • Example: one vendor form

Region and graph models

Detected regions become nodes connected by spatial relations.

  • Uses page geometry
  • Supports tables and forms
  • Needs region supervision
  • Example: claims packets

Multimodal document models

Text, image patches, and layout coordinates are learned jointly.

  • Handles varied layouts
  • Can reuse pretraining
  • Requires careful grounding
  • Example: mixed invoices

Case

Feeding word positions to a text model moved 70.72 to 79.27

LayoutLM is the clearest case of a multimodal document model. Yiheng Xu and five colleagues fed each token's 2-D position on the page into a pre-trained text model, and presented the result at KDD in 2020. The abstract states the outcome in a single sentence: “It achieves new state-of-the-art results in several downstream tasks, including form understanding (from 70.72 to 79.27), receipt understanding (from 94.02 to 95.24) and document image classification (from 93.07 to 94.42).”

Read the three pairs against each other. Form understanding, where meaning depends most on which label sits above which box, went from 70.72 to 79.27. Receipt understanding, already at 94.02, reached 95.24. Document image classification went from 93.07 to 94.42. The text encoder did not change in any of the three. What entered it was the position of each word, which had been on the page all along, and which every text-only pipeline had been throwing away.

Reading order is a prediction, not a formatting detail

A naïve top-to-bottom pass can merge columns, attach captions to the wrong figure, or read a footer inside a table. That pass has a number. For EMNLP 2021, Wang and four colleagues built ReadingBank: 500,000 document pages, 400,000 training, 50,000 validation, 50,000 test. Its ground-truth reading order was recovered from Word XML metadata rather than guessed by a human. Against that ground truth, sorting the words of a page left-to-right and top-to-bottom scores 0.6972 average page-level BLEU, with an ARD of 8.46. Their LayoutReader model scores 0.9819 BLEU and 1.75 ARD on the same pages.

The result is not confined to their own model's output. Re-ordering the text lines emitted by Tesseract raised BLEU from 0.7532 to 0.9360, and for a commercial OCR API from 0.8530 to 0.9430. In both cases the characters were already recognised. Only the sequence was wrong. The abstract puts it plainly: “It performs almost perfectly in reading order detection and significantly improves both open-source and commercial OCR engines in ordering text lines in their results in our experiments.”

So reading order should be modeled and tested as its own output, with its own score. Use explicit relations such as “follows,” “belongs to row,” and “labels field.” Preserve page coordinates so reviewers can trace extracted values back to evidence.

A document pipeline should be able to answer: where on the page did this value come from?

Example

Table extraction failures that look deceptively plausible

Tables are relational structures, so cell-level OCR is only the beginning. For years the field's own standard scoring could not see the difference. The IBM team behind PubTabNet tested the adjacency-relation metric used in table competitions by damaging tables on purpose. Shifting 90% of the cells in a table's first row still leaves its F1 near 80%. The tree-edit-distance metric they proposed, TEDS, drops about 60 points on the same wrecked table. Their diagnosis of the older metric is that “as it only checks immediate adjacency relations between non-empty cells, it cannot detect errors caused by empty cells and misalignment of cells beyond immediate neighbors”. PubTabNet itself — 568k table images with HTML ground truth, released in 2020 — is what made the comparison possible, and TEDS bought its EDD model a 9.7% absolute margin over the prior state of the art.

Ground truth suffers from a version of the same disease. Microsoft released PubTables-1M in 2022: 947,642 fully annotated tables, with bounding boxes for every row, column and cell, blank cells included, in both image and PDF coordinates. Its authors named the defect they had to remove before the annotations were usable: “It also addresses a significant source of ground truth inconsistency observed in prior datasets called oversegmentation, using a novel canonicalization procedure.” One logical cell annotated as several is oversegmentation. A model trained against it learns to reproduce it.

  • Header drift: a column title is associated with the neighboring column after a page break — a misalignment beyond immediate neighbors, which is precisely the class of error adjacency scoring cannot detect.
  • Row merge: two wrapped line items become one record and alter the total, while every surviving cell remains adjacent to a plausible neighbor.
  • Sparse cells: empty values shift later columns when separators are weak; adjacency F1 checks non-empty cells only, so the shift can cost almost nothing on the scoreboard.
  • Nested header: a grouped heading applies to three columns but is attached to only one.
  • Oversegmentation: one logical cell is annotated or predicted as several — the ground-truth inconsistency PubTables-1M canonicalizes away.
  • Continuation page: repeated headers are treated as data rows.

Analogy

Reading a railway timetable

Row position, column heading, typography, and footnotes jointly determine the meaning of each number in a railway timetable. Copying every character correctly does not identify which train departs from which platform.

Every entry in a timetable is printed to the same grid, while business documents can contain free-form text, handwriting, and legal ambiguity. Layout is part of meaning. The timetable flatters the problem, because its grid is at least agreed. On real pages, trained annotators put a box around a Title and agree with each other 60–72% of the time.

Document understanding requires relationships between elements, not text alone.

Steps

Evaluate from regions to decisions

A useful test plan reports where information is lost, and each step needs a metric that can actually detect the failure it is meant to catch. Step 2 is where that bites twice. Score table structure with a measure that reads the whole grid: TEDS, or GriTS, which compares the ground-truth and predicted matrices of grid cells rather than counting independent cells. GriTS came from the PubTables-1M authors in a separate 2022 paper, and their dataset paper uses it to report table structure results. Then set the target for region detection against what people achieve rather than against a perfect score. DocLayNet's triple-annotated pages put human-versus-human agreement at 82–83% mAP@0.5–0.95 overall and 60–72% on Title, so a region detector reported at 85% is not obviously worse than a second annotator. Step 2 should also carry a reading-order score of its own. The left-to-right, top-to-bottom baseline sits at 0.6972 BLEU on ReadingBank, which is what a pipeline silently accepts when it never measures order at all.

FigureProcess · 5 steps
  1. 1. Verify page capture

    Measure missing pages, clipped regions, rotation, and unreadable scans.

  2. 2. Score structure

    Evaluate region detection, reading order, rows, columns, and table topology.

  3. 3. Score semantic fields

    Report exact match, normalized match, and confidence by field type.

  4. 4. Check consistency

    Apply totals, date ranges, identifiers, and cross-document rules.

  5. 5. Measure review effort

    Track correction time, escalation rate, and evidence traceability.

Key idea

Generation can normalize a document into something it never said

A generative model may repair grammar, infer missing units, or choose a common value when the scan is ambiguous; that behavior can make a page easier to read while corrupting evidence. This is not a hypothetical, and it does not require a language model to happen.

On 2 August 2013 the German computer scientist David Kriesel published evidence that Xerox WorkCentre and ColorQube scanners were silently substituting digits in scanned PDFs. A 6 printed on the page came out as an 8, 65 as 85, 60 as 80. The fault was not OCR at all. It was compression. Of the JBIG2 scheme the machines used, Kriesel wrote: “Images are cut into small segments, which are grouped by similarity.” One representative patch per group was stored and reused wherever that group appeared, so a numeral that merely resembled another was replaced by it. There was no recognition step to audit, no confidence score to threshold, and nothing on the output page to mark that a substitution had happened. Reporting the affair on 6 August 2013, The Register recorded Xerox confirming that JBIG2 compression carries “inherent tradeoffs under low resolution and quality settings”. Xerox eventually issued patches. Its own support article, covering the WorkCentre 7220/7225 and 7220i/7225i, is titled “Random Character Switching When Scanning Using JBIG2 Compression”.

That is the shape of the risk in general form: a component optimizing for a plausible output produced a plausible output. For high-stakes extraction, separate transcription from interpretation. Retain uncertainty, source regions, and abstention paths.

A polished field is not necessarily a faithful field.

Example

Practice: design a field extraction review

Use a three-page supplier invoice with one table, handwritten corrections, and a subtotal carried to the next page.

  • List the regions that must be detected before any field is interpreted, and set the pass mark against a human-agreement figure — trained annotators reach 82–83% mAP@0.5–0.95 on DocLayNet — rather than against a perfect score.
  • Define exact-match rules for invoice number, currency, tax, and total.
  • Specify how a reviewer will see the source crop for each extracted field, and score the carried table with a whole-grid measure such as TEDS or GriTS rather than a cell count.
  • Create one cross-field check that would catch a silent digit substitution of the 6→8 kind before the total reaches the ledger.
  • Choose a failure that should trigger full-document review rather than one-field correction.

Key takeaways