Knowledge: Documents

How AI reads documents: OCR, layout and visual search

Most business documents are not clean text but scans, forms, tables and multi-column PDFs. Whether AI can pull the right answer out of them is usually decided at the reading stage, long before a language model ever answers. There are three ways to make documents machine-readable, and each has its own point of failure.

A page with abstract grey blocks and table grids, topped with a clear acrylic sheet marked with thin orange outlines around the page's blocksAI-GENERATED
UPDATED
12 September 2026
READING TIME
18 min

Short answer

AI understands documents in three ways: optical character recognition turns pixels into characters, layout-aware models map those characters onto headings, tables and fields, and visual search models compare a question directly with the image of the page. For exact values, recognised text is hard to avoid. For finding the right page, visual search is often more robust.

Definition

Document analysis: Document analysis is the automated processing of documents as text, structure and image. It covers optical character recognition, which turns pixels into characters, layout analysis, which determines headings, tables and reading order, and visual search, which compares pages directly as images. The goal is either to extract values reliably, or to find the right page for a question.

In the glossary: Optical character recognition, Visual document search, Late interaction, Multimodal model, Computer vision, Embedding, Retrieval, Gold-standard test set, Evaluation

01

What does it mean for AI to understand a document?

AI understands a document when it does three things: recognise the characters, map them onto the page's structure, such as a table cell, heading or form field, and connect both to a question or a target schema. Each layer builds on the one beneath it, so errors at the bottom propagate upward.

A digitally created PDF already contains a text layer, whereas a scan is only pixels. An invoice table is unambiguous to the eye, but to a machine it starts out as a set of characters with coordinates. Whether the number 240 is a quantity or an amount is not written in the digits themselves, but in the column they sit in.

LayerQuestionTypical techniqueTypical failure
CharactersWhich letters and digits are here?Optical character recognition (OCR)Confused characters, dropped umlauts, unreadable scans
StructureWhat does this character belong to?Layout analysis, layout-aware modelsColumns merged, table rows shifted, reading order wrong
MeaningDoes the page answer my question?Extraction into a schema, semantic or visual searchCorrect text found on the wrong page, or the wrong field filled in
Three layers of document understanding

All three layers keep coming up. How retrieved passages become an answer with a citation is covered in Retrieval-augmented generation explained. Where documents fit into the bigger picture of capturing, finding and maintaining knowledge is covered in Knowledge management with AI.

02

How does a classic OCR pipeline work?

A classic OCR pipeline first prepares the image: deskewing, rotation and contrast. A layout analysis step then finds text blocks and lines, a recognition model reads each line, and post-processing checks the result against dictionaries or formats. The output is text with coordinates that can be searched, copied and processed further.

The classic OCR pipeline
  1. 01Prepare the imageDeskew, rotate, adjust contrast
  2. 02Find the layoutBlocks, columns, lines
  3. 03Recognise linesCharacter sequence per line
  4. 04Post-processDictionary, formats, confidence
  5. 05Text with coordinatesSearchable, verifiable

Modern OCR tools no longer recognise letter by letter but read whole lines with neural networks. The open-source engine Tesseract, for example, includes a recognition system based on recurrent networks (LSTM) that, according to the project documentation, works as a line recogniser and needs roughly ten times the compute of the older recogniser (Tesseract documentation). The gain in accuracy comes at the cost of compute.

The pipeline's weak point is rarely character recognition itself, but the step before it. If layout analysis misses two columns, recognition reads straight across the column boundary, and every line produces a grammatically plausible but factually wrong sentence. The result looks clean and is still useless. These silent errors are exactly what makes OCR the most common source of error in document projects, as the glossary entry on OCR also notes.

03

What can layout-aware models do when they read text and position together?

Layout-aware models process each word's position on the page as well, often together with the image itself. That lets them learn that a value to the right of "Date" is a date, and a number in the third table column is an amount. They handle form and table tasks noticeably better than models that only see the character sequence.

LayoutLM (Xu et al., KDD 2020) laid the groundwork: the model was the first to be pre-trained jointly on text and layout positions, and according to the paper improved the form-understanding score from 70.72 to 79.27. Successors such as LayoutLMv3 (Huang et al., ACM Multimedia 2022) process text and image patches in a single transformer and learn which parts of the image belong to which words.

A second branch skips upstream OCR entirely. Donut (Kim et al., ECCV 2022) reads the page image directly and produces structured output. The authors justify this with three drawbacks of classic pipelines: the compute cost of OCR, poor flexibility across languages and document types, and OCR errors propagating into every downstream step. Today's multimodal language models, which process image and text together, continue that line (multimodal model).

Layout analysis as a task in its own right

How well a system recognises blocks depends heavily on the documents it learned from. The DocLayNet dataset (Pfitzmann et al., KDD 2022) was annotated by humans, distinguishes 11 layout classes and deliberately covers a range of document types. The authors show that models trained on it generalise better across document types than models that have only seen scientific papers.

Three ways to read a page

CriterionClassic OCRLayout-aware modelOCR-free image model
InputPage imageText, coordinates, often the imagePage image
OutputText with coordinatesFields, classes, structureStructured text or an answer
StrengthTraceable, copyable, good for full textForms, tables, fixed fieldsNo OCR errors as a starting point
WeaknessLoses structureDepends on OCR quality and training documentsHarder to verify, can invent values
VerifiabilityHigh: every character has a positionMedium: fields come with a confidence scoreLower: output has no direct source location

04

How does visual document search work with models like ColPali?

Visual document search splits every page into many small image patches and computes a vector for each one. The search query is likewise broken into vectors, one per token. During matching, every query token looks for its best-matching patch, and the top scores are summed. That lets the search find pages whose information sits in the layout.

ColPali (Faysse et al., arXiv 2024, published at ICLR 2025) embeds document page images directly, according to the paper, and matches them using the late interaction principle. The authors introduced the ViDoRe benchmark alongside it, because existing search systems mostly score extracted text and ignore visual cues such as tables, charts and font sizes. By their measurements, the approach outperforms classic pipelines while also being simpler to build.

  1. Capture pages as images

    Every page is rendered or scanned. No OCR is needed for the search itself.

  2. Embed the patches

    The model divides the page into a grid of small patches and produces a vector for each one, so a single page ends up described by many vectors.

  3. Embed the query

    The question is broken into tokens, and each one gets its own vector.

  4. Compare late

    For every query token, only the most similar page patch counts. The sum of these best scores becomes the page's score. The method is called MaxSim and comes from ColBERT (Khattab and Zaharia, SIGIR 2020).

  5. Re-rank the candidates

    In practice, a faster search often narrows down the candidates first, and the expensive comparison only runs over those pages.

The main drawback is storage: many vectors per page take up a multiple of the index a single text vector would need. Smaller models shift that calculation. ModernVBERT (Teiletche et al., arXiv 2025) needs only 250 million parameters and, according to the paper, outperforms models up to ten times its size once fine-tuned for document search. The OCR-free document stack lays out the building blocks, and Late interaction explained goes deeper on the late interaction principle.

05

Extraction or search: which task should document AI actually solve?

Extraction and search need different things. Extraction transfers values into a fixed schema, such as a date, case number or reading, and needs exact characters to do it. Search must find the right page for a question and tolerates small character errors as long as the page turns up. Naming the task first picks the right technique.

Which technique fits which task

CriterionExtractionSearch and question answeringMaking an archive searchable
GoalTransfer values into fieldsFind the matching page for a questionMake a collection searchable and citable
Needs exact charactersYesNo, the page is what countsYes, for full text and citations
Obvious coreOCR plus layout-aware extraction with validation rulesVisual search or hybrid text searchOCR with a text layer, complemented by visual search
Key metricShare of correctly filled fieldsRecall within the first k resultsCharacter error rate and findability
Typical riskA plausible but wrong valueThe right answer pulled from the wrong pageSilent errors in the text that nobody notices

Many projects need both. A proven pattern is to split the work: visual search finds the handful of relevant pages, and only those get a thorough OCR pass whose result is cited or processed further. That keeps the expensive stage small and stops OCR errors from spoiling the search in the first place. Classic OCR alongside visual search describes this split using a concrete model.

06

Why do tables, scans and handwriting fail so often?

Tables, scans and handwriting fail because their information does not sit in the characters alone. In tables it sits in rows and columns, in scans the image itself is already degraded, and in handwriting the characters themselves vary. Public benchmarks show that no single approach leads across all document types, so testing on your own collection is what decides it.

568,000table images with HTML structure in the PubTabNet dataset, alongside the TEDS table metricZhong et al., arXiv 2019
94.36%human accuracy on DocVQA, a question-answering test over 12,000 document imagesMathew et al., WACV 2021
19layout categories in the OmniDocBench benchmark, which covers nine document sources up to handwritingOuyang et al., CVPR 2025
CaseWhat goes wrongWhat helps
TablesCells shift, merged cells and header rows get lostRecognise and measure table structure specifically, for example with TEDS; for search, compare the page as an image
Tables spanning pagesThe continuation is read as a new table with no header rowProcess across pages, or carry header rows forward deliberately
Poor scansSkew, shadows, stamps over the textPre-process the image, check scan resolution, flag uncertain spots
Multi-column pagesReading order jumps between columnsLayout analysis with reading order, spot-check against the original
HandwritingHigh error rate, large variation between writersSet expectations accordingly, always route handwritten fields to human review
Charts and drawingsCarry information but almost no textVisual search to find them, description by a multimodal model only with review
Difficult cases and effective countermeasures

The authors of OmniDocBench (Ouyang et al., CVPR 2025) find that classic pipelines and end-to-end vision-language models each have their own strengths and weaknesses depending on document type. That is an argument against picking an approach purely by leaderboard rank.

07

When is classic OCR still the better choice?

Classic OCR is the better choice whenever you need the actual characters: for full-text search across an archive, for quoting and copying, as an audit trail, for handing exact values to other systems, and for documents whose information sits almost entirely in running text. Visual search delivers a page, not text, and does not substitute for any of these tasks.

  • Full text and quotes: A result that a person needs to copy or quote verbatim requires recognised text.
  • Audit trail: Anyone who has to prove which word at which position a value came from needs characters with coordinates.
  • Running text with simple layout: For reports, minutes or contracts with plain formatting, text search is cheaper and good enough.
  • Handing off to systems: Databases and line-of-business applications expect values, not page images.

Common assumptions about document AI

08

How do you check the quality of document AI?

You check document AI quality layer by layer: character error rate for OCR, structural fidelity for tables, share of correct fields for extraction, and recall for search. The basis is a test set of your own, difficult documents with verified expected values. A single overall score hides which layer the error actually comes from.

LayerMetricWhat it shows
CharactersCharacter error rate (CER) and word error rate (WER)Share of inserted, missing or swapped characters or words against the reference
StructureTree-edit distance for tables (TEDS)How close the recognised table structure, including cell content, is to the correct one
ExtractionField accuracy by field typeWhich fields are reliable and which belong under review
SearchRecall within the first k results (Recall@k)Whether the right page is even among the candidates
Metrics per layer

Checklist

Building a test set for document AI

0 of7

For the team comparing approaches. Nothing here is saved.

Checking AI answers goes deeper on how to judge a system's answers against the documents it retrieved, that is, faithfulness to the source and relevance.

09

How do you pick the right approach for your own document collection?

Three questions decide the right approach: does the task need exact characters or the right page? Does the layout carry the information, as in tables and forms? And are the documents allowed to leave your own network? The answers determine whether OCR, visual search or a combination takes centre stage, and what gets tested first.

Decision path

OCR, visual search, or both?

Three questions that show where a test should start.

    All questions and results as a list
    • Does the end result need to be exact values or citable text?
      • Yes, continue with: Do users also need to ask the collection open-ended questions?
      • No, it is about finding things, continue with: Does the information often sit in tables, forms, charts or scans?
    • Do users also need to ask the collection open-ended questions?
      • Yes, Result: Test a combination
      • No, Result: Extraction with validation rules
    • Does the information often sit in tables, forms, charts or scans?
      • Yes, Result: Visual search first
      • No, mostly running text, Result: Text search is probably enough
    • Result: Test a combinationWhat to work out: which pages visual search should find first, and which of those get a thorough OCR pass. The test set then needs both reference pages for questions and reference values for fields.
    • Result: Extraction with validation rulesWhat to work out: which fields are needed, which validation rules protect them, and at what uncertainty level a person decides instead. Layout-aware models are worth comparing against plain OCR.
    • Result: Visual search firstWhat to work out: which documents your current search fails on, and how large the index gets with many vectors per page. A small model is often the more honest place to start.
    • Result: Text search is probably enoughWhat to work out: whether the existing text layer is clean, and whether a hybrid search combining keywords and meaning covers what users actually ask. Visual search can always be added later.

    The third question, whether documents may leave the building, changes the choice more than any leaderboard. OCR, layout models and compact visual search models all run on your own hardware today. Local language models explains what running models locally requires.

    iiterate Technologies GmbH builds AI applications and custom software from architecture through implementation to operation, on client infrastructure or in EU hosting, with a focus on RAG, local language models and integration with existing systems (Services).

    Read more on iiterate.de

    Frequently asked questions

    Can a multimodal language model replace OCR entirely?

    For some tasks, yes, such as answering a question about a single page. As a replacement for traceable OCR it only works with caveats, because its output carries no per-character coordinates and it can plausibly invent values. Wherever values get processed further or quoted, checking against the source location is necessary.

    Does document AI work with German documents and umlauts?

    Broadly yes, though quality varies between models more than it does for English text. Umlauts in poor scans, long compound words, technical abbreviations and older typefaces are the critical cases. Public benchmarks say little about this. A test set built from your own German documents quickly shows which approach holds up.

    How much more storage does visual search need than text search?

    Considerably more, because a page is described not by one vector but by many. The exact factor depends on the model, vector size, compression and page count. It is common to put a faster search in front and only run the expensive comparison over the candidates. Work through the index size against your own page count before deciding.

    How do you handle tables that span multiple pages?

    Processing page by page loses the header row on the continuation, leaving values with no meaning attached. The fix is a method that reads several pages together, or post-processing that carries header rows forward onto continuations. Such tables deliberately belong in the test set, because benchmarks rarely include them.

    Do documents have to go into a cloud for AI analysis?

    No. OCR, layout models and compact models for visual search can all run on your own hardware, so documents never leave the network. The limit sits more with very large vision-language models, whose hardware needs grow accordingly. Local language models covers which model size fits which hardware.

    What is the difference between layout analysis and extraction?

    Layout analysis determines which regions of a page are a heading, paragraph, table, figure or form field, and in what order they should be read. Extraction uses that structure to transfer specific values into a fixed schema. Good layout analysis is therefore a precondition for reliable extraction, but it does not replace it.

    Read on

    Related topics

    Sources

    1. 01 ColPali: Efficient Document Retrieval with Vision Language Models arXiv (ICLR 2025), 2024 · arxiv.org
    2. 02 ModernVBERT: Towards Smaller Visual Document Retrievers arXiv, 2025 · arxiv.org
    3. 03 ColBERT: Efficient and Effective Passage Search via Contextualized Late Interaction over BERT arXiv (SIGIR 2020), 2020 · arxiv.org
    4. 04 LayoutLM: Pre-training of Text and Layout for Document Image Understanding arXiv (KDD 2020), 2019 · arxiv.org
    5. 05 LayoutLMv3: Pre-training for Document AI with Unified Text and Image Masking arXiv (ACM Multimedia 2022), 2022 · arxiv.org
    6. 06 OCR-free Document Understanding Transformer arXiv (ECCV 2022), 2021 · arxiv.org
    7. 07 DocLayNet: A Large Human-Annotated Dataset for Document-Layout Analysis arXiv (KDD 2022), 2022 · arxiv.org
    8. 08 Image-based table recognition: data, model, and evaluation arXiv, 2019 · arxiv.org
    9. 09 DocVQA: A Dataset for VQA on Document Images arXiv (WACV 2021), 2020 · arxiv.org
    10. 10 OmniDocBench: Benchmarking Diverse PDF Document Parsing with Comprehensive Annotations arXiv (CVPR 2025), 2024 · arxiv.org
    11. 11 Overview of the new neural network system in Tesseract 4.00 Tesseract OCR Projekt, o. J. · tesseract-ocr.github.io

    Let us talk about your project

    Whether it is a prototype, an internal tool or an AI application: describe briefly what you are building or want to take into production.

    Arthur C. Clarke

    “Any sufficiently advanced technology is indistinguishable from magic.”