Paweł Labuda Portfolio
  • About me
  • Experience
  • Projects
  • Realizations
  • Blog
  1. You are here:  
  2. Blog
  3. Computer Vision & Multimodal AI
  4. OCR Is Not Enough: Building a Document Understanding Pipeline With Validation and Human Review
Computer Vision & Multimodal AI May 6, 2026 17 min read

OCR Is Not Enough: Building a Document Understanding Pipeline With Validation and Human Review

  • evaluation and experimentation
  • ocr and document ai
  • production ml

OCR Is Not Enough: Building a Document Understanding Pipeline With Validation and Human Review

Details
Category: Computer Vision & Multimodal AI
  • evaluation and experimentation
  • ocr and document ai
  • production ml

OCR is often described as converting an image into text. That definition is correct, but it is too narrow for most production document workflows.

A business system rarely needs an unstructured transcript of an invoice, application form, delivery note, or contract. It needs specific fields, their locations, validation results, and a decision about whether the extracted record can be accepted automatically.

The distinction matters because a plausible OCR result can still be operationally wrong. A number may be recognized correctly but assigned to the wrong field. A date may have valid syntax but represent the delivery date instead of the invoice date. A tax identifier may contain one visually confused character while still looking credible to a reviewer.

The main argument of this article is that OCR should be treated as one component of a document understanding system. Recognition produces candidate text. Layout analysis, field extraction, validation, and review routing determine whether that text can be trusted.

The business decision is whether to accept the record

Consider an invoice-processing workflow. The system receives a scanned document and must create a structured record containing the vendor, invoice date, tax identifier, and total amount.

The downstream system may use that record to schedule a payment, match a purchase order, calculate tax, or route an exception. A wrong field can therefore create duplicate payments, accounting mismatches, compliance errors, or manual investigation.

The desired result is not simply: Return all text visible on the page.

The actual requirement is: Extract the required fields, preserve their visual evidence, validate them, and accept only the values that satisfy the workflow policy.

Invoice fields have different validation rules and failure costs.
Field Expected evidence Example failure Possible consequence
Vendor Name near the supplier address or header The buyer name is extracted instead The invoice is assigned to the wrong account
Invoice date Date associated with the invoice label The delivery date is selected The payment schedule is calculated incorrectly
Total amount Amount linked to the final total A subtotal or line amount is selected The wrong amount enters the payment workflow
Tax identifier Identifier associated with the vendor The customer identifier is selected Tax matching and compliance checks fail

The document can be mostly correct while the one field controlling payment is wrong. Document-level accuracy is therefore too coarse for this decision.

The standard approach stops after recognition

The simplest OCR workflow accepts an image, detects text, recognizes characters, and returns a string or a list of words.

This approach is useful when the task is search indexing, archival transcription, or making scanned text selectable. It can also be a reasonable first stage for documents with predictable reading order and no structured extraction requirement.

It becomes insufficient when the meaning of a value depends on its location and relation to surrounding elements.

Consider the number 1,204.80. Depending on the page, it may represent a subtotal, tax amount, balance due, unit price, or total payment. Recognition can determine which characters are present. It cannot determine the business role of the value from the characters alone.

The document structure provides additional evidence. The meaning may depend on a nearby label, table column, page region, typography, or relation to another field.

The LayoutLM architecture was designed to model text together with two-dimensional layout information for document image understanding. The broader lesson is not that every system must use LayoutLM. It is that document position and text content are related signals rather than independent outputs.

The dangerous failure is silent acceptance

An unreadable result usually creates a visible failure. A missing value can be routed to manual processing.

A plausible but incorrect value is more dangerous because it may pass through the workflow without attracting attention.

For example, OCR may read the letter O as the digit 0 inside a tax identifier. The result can have the correct length and expected prefix. A format check may pass even though the identifier does not correspond to the supplier.

A total amount can also be recognized with high confidence while field assignment is wrong. The OCR engine may have read the characters accurately; the parsing stage selected the subtotal instead of the balance due.

This distinction separates three failure classes:

Recognition, assignment, and validation failures require different corrections.
Failure class What went wrong Likely engineering response
Recognition error The characters were read incorrectly Improve image quality, text detection, or recognition
Assignment error The correct text was mapped to the wrong field Improve layout analysis, entity extraction, or relation modeling
Validation error An invalid or inconsistent value was accepted Add business rules, master-data checks, or stricter review policy

These failures should not be compressed into one OCR accuracy number because they occur in different system components.

The correct output is a field with evidence

Let a document image be denoted by \(D\). An OCR stage produces a collection of recognized text elements:

$$O(D) = \left\{ \left( t_i, b_i, s_i \right) \right\}_{i=1}^{n}$$

For element \(i\), \(t_i\) is the recognized text, \(b_i\) is its bounding box, and \(s_i\) is the recognition score produced by the OCR system.

A field extractor maps these elements into a structured field:

$$z_j = \left( v_j, B_j, c_j \right)$$

Here, \(v_j\) is the extracted value for field \(j\), \(B_j\) identifies the source region or regions, and \(c_j\) is the extraction score.

The extraction score may combine several signals, including OCR recognition, field classification, spatial relations, and parser confidence. It should be treated as a model-specific score until evaluation shows how it relates to real error probability.

A validation function evaluates the extracted value:

$$r_j = V_j(v_j, D, M)$$

The input \(M\) represents external context such as vendor master data, known purchase orders, currency rules, or document-specific constraints.

A simple automatic acceptance rule is:

$$Accept(z_j) = \mathbf{1} \left\{ c_j \geq \tau_j \land r_j = pass \right\}$$

The threshold \(\tau_j\) is field-specific. A descriptive note may tolerate more uncertainty than a payment amount or regulatory identifier.

The pipeline should separate perception from policy

A practical document workflow contains several related but distinct stages.

Document understanding separates visual processing from acceptance policy.
Stage Responsibility Produced evidence
Image preparation Correct rotation, crop pages, and improve usable contrast Processed image and transformation metadata
Text and layout recognition Detect text regions and recognize their content Text, coordinates, page number, and recognition scores
Field extraction Assign text regions to document fields Candidate values and source regions
Validation Apply formats, arithmetic checks, and external data matching Validation status and failure reasons
Routing Accept the field, request review, or reject the document Operational status and audit record

The model does not need to own the final acceptance policy. Deterministic checks and workflow rules are often more appropriate for constraints that can be tested exactly.

For example, a language or vision model may identify the candidate tax identifier. A deterministic validator can then check its format, checksum, and match against approved vendor data.

The pipeline needs point-level visual evidence

Every important field should preserve the region from which it was extracted.

A bounding box is not cosmetic metadata. It allows the system to display the original evidence, compare competing candidates, and show a reviewer why the value was selected.

The source evidence may include one box, several related boxes, or a cropped region containing the field label and value. Table extraction may require row and column coordinates rather than one rectangular region.

The evidence reference should remain connected to the original document version. If preprocessing changes the page orientation or dimensions, the system must either preserve the coordinate transformation or store the processed image used by the model.

Confidence is a routing signal, not a proof of correctness

OCR and document models often return confidence-like scores. These scores can support review routing, but they should not be interpreted automatically as calibrated probabilities.

A score of 0.90 does not necessarily mean that the field is correct in 90 percent of comparable cases. The relationship depends on the model, document type, field, image quality, and method used to generate the score.

Thresholds should therefore be selected on reviewed validation data. The team should measure how often fields above the threshold are still wrong and how much manual review the threshold creates.

Confidence is also only one signal. A high-confidence value should still be reviewed when it violates a business rule. A lower-confidence value may be accepted when several independent checks strongly support it, although that policy should be validated carefully.

A field-level routing example

The following example combines field-specific confidence thresholds with deterministic validation.

The values are synthetic and represent one invoice record. The code does not run OCR. It demonstrates the decision layer that receives candidate fields from an OCR or document understanding model.

from dataclasses import dataclass
from datetime import date
from decimal import Decimal, InvalidOperation
import re


@dataclass(frozen=True)
class ExtractedField:
    name: str
    value: str
    confidence: float
    critical: bool


KNOWN_VENDORS = {"ACME Marine", "Northwind Parts"}

CONFIDENCE_THRESHOLDS = {
    "invoice_date": 0.90,
    "vendor": 0.90,
    "total_amount": 0.95,
    "tax_id": 0.95,
}


def validate(field: ExtractedField) -> list[str]:
    reasons = []

    if field.confidence < CONFIDENCE_THRESHOLDS[field.name]:
        reasons.append("low_confidence")

    if field.name == "invoice_date":
        try:
            date.fromisoformat(field.value)
        except ValueError:
            reasons.append("invalid_date")

    elif field.name == "vendor":
        if field.value not in KNOWN_VENDORS:
            reasons.append("unknown_vendor")

    elif field.name == "total_amount":
        try:
            amount = Decimal(field.value.replace(",", ""))
            if amount <= 0:
                reasons.append("non_positive_amount")
        except InvalidOperation:
            reasons.append("invalid_amount")

    elif field.name == "tax_id":
        if re.fullmatch(r"PL\d{10}", field.value) is None:
            reasons.append("invalid_tax_id")

    return reasons


fields = [
    ExtractedField("invoice_date", "2026-07-20", 0.96, True),
    ExtractedField("vendor", "ACME Marine", 0.91, True),
    ExtractedField("total_amount", "1,204.80", 0.78, True),
    ExtractedField("tax_id", "PL58312O9384", 0.97, True),
]

document_status = "accepted"

for field in fields:
    reasons = validate(field)
    field_status = "accepted" if not reasons else "needs_review"

    if field.critical and reasons:
        document_status = "needs_review"

    print(f"{field.name:14s} status={field_status:12s} reasons={reasons}")

print(f"document_status={document_status}")

The following output was produced by executing the code:

Console output
invoice_date   status=accepted     reasons=[]
vendor         status=accepted     reasons=[]
total_amount   status=needs_review reasons=['low_confidence']
tax_id         status=needs_review reasons=['invalid_tax_id']
document_status=needs_review
Document field validation with confidence thresholds and review reasons
Document review is triggered by low amount confidence and an invalid tax ID format.

The result exposes two different reasons for review

The invoice date and vendor are accepted because they meet their confidence thresholds and pass their deterministic checks.

The total amount is routed to review because its confidence score of 0.78 is below the field threshold of 0.95. The value is syntactically valid and positive, but the recognition evidence is not strong enough for automatic acceptance.

The tax identifier has a score of 0.97, but it still requires review. Its value contains the letter O where the rule requires a digit. The validation layer catches an error that a confidence-only policy would accept.

The complete document is marked needs_review because both fields are defined as critical. A different application could accept the document provisionally while blocking only the payment action.

The example demonstrates the control logic. It does not show that the selected thresholds are suitable for real invoices. Thresholds should be derived from reviewed documents and the cost of false acceptance.

Document acceptance should depend on critical fields

A document may contain dozens of extracted fields, but not all of them have the same operational importance.

A missing optional description may have little effect. A wrong total amount may make the entire record unsafe for automated payment.

Let \(C\) be the set of fields classified as critical. A strict document policy can be written as:

$$AcceptDocument(D) = \mathbf{1} \left\{ Accept(z_j) = 1 \text{ for every } j \in C \right\}$$

This policy is conservative because one failed critical field routes the complete document to review.

Other workflows can use partial acceptance. Correct header fields may be saved while one table or amount remains pending. The system should make that state explicit rather than presenting the record as fully validated.

Validation should use document and external consistency

Format validation is useful but limited. A correctly formatted value can still be assigned to the wrong field or refer to the wrong entity.

Stronger validation can compare several parts of the document. For an invoice, the subtotal, tax, discount, and total can be checked through arithmetic consistency. The vendor name, tax identifier, and bank account can be checked against master data.

Validation signals catch errors that OCR confidence alone cannot detect.
Validation type Example Detected failure
Format validation Date parses and tax identifier matches the required pattern Character substitution or malformed value
Document consistency Subtotal plus tax minus discount equals total Wrong amount selected from another part of the page
External consistency Vendor name and identifier match master data Value belongs to the buyer or another company

Validation failures should preserve their reason. A reviewer can resolve a low-confidence character differently from an unknown vendor or an inconsistent invoice total.

The evaluation unit must match the workflow

Character Error Rate measures how many character edits are needed to transform recognized text into reference text. It is useful for evaluating transcription quality but does not directly measure whether the correct business fields were extracted.

A document system should be evaluated at several levels.

Evaluation should preserve recognition, extraction, and workflow outcomes.
Level Example metric Question answered
Text recognition Character Error Rate or Word Error Rate Were the visible characters recognized correctly?
Field extraction Exact match, normalized match, or entity F1 Were the correct values assigned to the correct fields?
Automation policy False acceptance rate and review rate Does the routing policy automate the right cases?
Operational outcome Correction time or downstream rejection rate Does the complete workflow reduce work without introducing unacceptable errors?

The FUNSD dataset illustrates why form understanding extends beyond OCR. Its annotations include text, spatial information, semantic entities, and relations between entities. These elements support evaluation of document structure rather than transcription alone.

False acceptance is usually more important than average accuracy

Suppose a system automatically accepts 80 percent of extracted payment amounts. Among the accepted fields, 0.5 percent are wrong.

That 0.5 percent is the false acceptance rate for the automated path. Depending on invoice volume and payment value, it may be more important than the average accuracy across all fields.

Define the automatically accepted field set as \(A\). If \(y_i\) indicates whether field \(i\) is correct, the false acceptance rate is:

$$FAR = \frac{ \sum_{i \in A} \mathbf{1}\{y_i = 0\} }{ |A| }$$

The review rate is the proportion of fields routed to human review:

$$ReviewRate = \frac{ N_{review} }{ N_{all} }$$

Lowering the confidence threshold may reduce review workload while increasing false acceptance. Raising it may reduce risk while removing much of the automation benefit.

The threshold should therefore be selected from the trade-off between error cost and review capacity, not from an arbitrary round number.

Confidence thresholds must be validated by field and document type

A single confidence threshold for every field is unlikely to reflect the workflow accurately.

Dates, short identifiers, long descriptions, and monetary values have different error patterns. Printed invoices, photographed receipts, handwritten forms, and engineering drawings also produce different score distributions.

I would validate thresholds separately across three dimensions:

  • field type and operational importance,
  • document family and source channel,
  • image-quality conditions such as rotation, compression, and low contrast.

A threshold should not be transferred to a new document population without checking whether its error relationship remains stable.

The validation set should contain realistic document defects

Clean benchmark pages are not enough for production evaluation.

The test set should contain naturally occurring variation, including unusual layouts, missing fields, poor scans, multi-page records, tables, stamps, and overlapping annotations. Synthetic degradation can supplement this set but should not replace real failure examples.

The split design should also prevent near-duplicate templates or documents from appearing in both training and evaluation data. Otherwise, the system may appear to generalize while mainly recognizing familiar layouts.

I would preserve three test groups:

  • representative documents from normal production traffic,
  • difficult cases and known historical failures,
  • documents requiring review, rejection, or partial acceptance.

The third group is necessary because a system evaluated only on extractable documents is not tested on its ability to stop.

Human review needs visual context and precise reasons

A review interface should not show only the extracted string.

The reviewer needs the page region, field label, candidate value, confidence or score, and validation reason. For ambiguous cases, it may also be useful to display alternative candidates.

The interface should separate recognition correction from field reassignment. Changing 1,2O4.80 to 1,204.80 is different from deciding that the recognized value is a subtotal rather than a total.

This distinction improves correction data. A recognition error should train or evaluate the OCR component, while a field-assignment error belongs to layout parsing or information extraction.

Corrections are useful only when their provenance is preserved

Reviewed fields can become valuable evaluation and training examples, but only when the correction is stored with enough context.

The record should preserve the original prediction, corrected value, source region, document type, model version, and review reason. Without those elements, later teams may know that a value changed but not which component failed.

Human review is not automatically ground truth. Reviewers can make mistakes, interpret ambiguous fields differently, or follow inconsistent policies.

Critical datasets should therefore include reviewer guidance, quality checks, and adjudication for disputed examples.

OCR-free document models do not remove validation

Some multimodal document models process page images directly rather than relying on a separately exposed OCR engine. This can simplify parts of the architecture and allow visual and textual information to interact more closely.

It does not remove the need for evidence and validation.

A generated field can still be unsupported, assigned incorrectly, or inconsistent with master data. The system must still identify where the answer came from, determine whether it satisfies business rules, and decide whether automatic acceptance is justified.

The implementation boundary may move, but the operational questions remain.

How I would operationalize the workflow

I would organize the system into three control layers:

  1. Perception control: preserve page images, text regions, coordinates, model scores, and preprocessing metadata.
  2. Decision control: apply field-specific validation, confidence policies, document rules, and review routing.
  3. Evaluation control: measure field accuracy, false acceptance, review workload, correction reasons, and segment stability.

The model version, parser version, validation policy, and document schema should be recorded for every processed document. Otherwise, a later correction cannot be connected reliably to the system that produced it.

Deployment should also preserve a rollback path. A new extractor can improve average accuracy while increasing false acceptance for one invoice template or supplier group.

What the pipeline cannot guarantee

A validation rule can reject malformed values, but it cannot prove that every accepted value has the correct semantic role.

Master data may be stale or incomplete. Arithmetic checks may pass for the wrong combination of fields. Confidence scores may shift after a scanner, document template, or model version changes.

Human review also introduces cost and inconsistency. A policy that sends almost every document to review may achieve low automated error while providing little practical automation.

The purpose of the pipeline is not to eliminate uncertainty. It is to expose uncertainty before provisional OCR output becomes an operational fact.

Key takeaways

  • OCR recognizes text, while document understanding connects text with layout, field meaning, validation, and workflow decisions.
  • Automatic acceptance should combine field-level model evidence with deterministic and external consistency checks.
  • The most important production metrics include false acceptance, review workload, field accuracy, and correction cost rather than only document-level OCR accuracy.

Sources

  1. Smith, R. (2007). An Overview of the Tesseract OCR Engine. Ninth International Conference on Document Analysis and Recognition, 629-633.
  2. Xu, Y., Li, M., Cui, L., Huang, S., Wei, F., and Zhou, M. (2020). LayoutLM: Pre-training of Text and Layout for Document Image Understanding. Proceedings of the 26th ACM SIGKDD International Conference on Knowledge Discovery and Data Mining, 1192-1200.
  3. Jaume, G., Ekenel, H. K., and Thiran, J.-P. (2019). FUNSD: A Dataset for Form Understanding in Noisy Scanned Documents. 2019 International Conference on Document Analysis and Recognition Workshops, 1-6.
← Previous article Useful AI Agents Need Boundaries: Designing Tool Use, Stops, and Human Review Next article Image and Video Models Beyond Generation: Evaluating Visual Embeddings and Temporal Retrieval →
← Back to Blog

More articles

Random Forest From First Principles: Bagging, OOB Evaluation, Tuning, and Interpretation

A single decision tree is easy to inspect, but it can be unstable. A small change in the training sample may change an early split, which changes the branches below it and can produce a different prediction.

Random Forest addresses this weakness by training many randomized trees and combining their outputs. Each tree sees a different bootstrap sample, and each split considers only a random subset of features. The trees are therefore related, but they are not identical.

Read more …

An Uncertainty Budget for LLM Systems: Finding Risk Across Retrieval, Tools, and Generation

An LLM system does not become reliable because the model is fluent. It becomes reliable when weak evidence, incomplete tool results, unsupported claims, and uncertain decisions are detected before they create operational harm.

The difficulty is that uncertainty rarely belongs to one component. A weak answer can result from incomplete retrieval, poor context construction, unsupported generation, stale memory, partial tool output, invalid formatting, or inconsistent human review.

Read more …

Causal Overlap Before Estimation: Diagnosing Support, Trimming, and Estimand Change

Causal inference can fail before an estimator is selected. The problem is not always the regression formula, matching algorithm, weighting method, or model family. It is often whether treated and untreated observations are sufficiently comparable for the intended causal question.

If one treatment group occupies regions of the covariate space that have almost no counterpart in the other group, the estimate starts depending on extrapolation. A model can still return a numerical effect and a narrow confidence interval, but the data may provide little direct support for the comparison.

Read more …

Paweł Labuda

AI engineering portfolio, personal projects, technical notes, and blog.

Be in touch mail pawel.labuda@itvix.pl

All rights reserved 
© 2026 IT Vix
Privacy Policy Cookie Policy
Built as a technical notebook for learning, building, and sharing.

This website uses cookies. Using the website means that you agree.

Privacy Policy Cookie Policy