Document AI in Google Cloud

Document AI in Google Cloud

A friendly, complete guide to teaching software to read invoices, forms, contracts and scanned papers: how Google's document processing service turns messy pages into clean data, how to build pipelines around it, and how to keep accuracy, cost and privacy under control.

Walk into almost any office and you will find paper, or at least the digital version of paper: invoices from suppliers, application forms from customers, bank statements, ID cards, contracts, medical forms and delivery receipts. Inside each of these documents is information that a business needs, such as an amount, a date, a name or a signature. For decades, people have typed this information into computer systems by hand, one page at a time.

Hand typing is slow, expensive and full of small mistakes. Document AI is Google Cloud’s service for teaching software to do this reading work. You give it a document, and it gives back neat, structured data. This guide explains Document AI from zero. Every new word is explained when it first appears, so you can follow along even if you have never worked with artificial intelligence or document processing.

WWhat Is Document AI?

Start with the big picture: what the service does and why people use it.

A document, in this guide, means any page-based file that people read: a scanned paper, a photograph of a receipt, a PDF, or a multi-page contract. Computers see a scanned page only as a picture, which is a grid of colored dots. They cannot tell that one group of dots says “Total: 1,250.00”. To use the information, the computer must first recognize the characters and then understand what they mean.

Document AI is a managed Google Cloud service that does both jobs. “Managed” means Google runs the machines, trains the base models and handles the scaling. You send in documents, and you receive structured results, such as “invoice number: INV-2041”, “due date: 15 December” and a table of line items. This turns the unstructured world of pages into the structured world of databases.

The service works through processors. A processor is a ready-to-use or trainable reader that is specialized for a certain kind of job. One processor is great at plain text recognition. Another understands invoices. Another can be trained to read your company’s own special forms. You pick the processor that matches your document, send your files to it, and read the answers.

Everyday Analogy

Imagine a mailroom with a team of clerks. One clerk is an expert at reading handwriting. Another is a specialist in invoices and knows exactly where the total and the due date usually hide. Another sorts incoming mail into piles. Document AI is that team in the cloud. You drop the pile on the desk, the right clerk picks it up, and you receive a tidy typed summary of each page.

What Document AI can do

  • Read text from printed and handwritten pages, in many languages, using optical character recognition.
  • Understand layout, such as headings, paragraphs, tables and lists.
  • Extract fields such as names, dates, amounts and addresses.
  • Understand special documents such as invoices, receipts, bank statements and identity documents with pretrained models.
  • Classify and split documents, for example telling an invoice from a contract, or separating a long scan into individual documents.
  • Learn your own documents through custom processors that you train or guide.
Pretrained
ready-made processors for common document types
Customizable
processors you can train or guide for your own documents
Managed
Google runs, scales and updates the service
i
Tip

Google updates Document AI often. New processors appear, names change and some older features are retired. Always confirm the current processor list, limits and recommended options in the official documentation before you design a system around this guide.

TThe Problem Document AI Solves

Every good tool begins with a pain. Here are the pains of paper and PDFs.

Pain 1: Manual data entry is slow and costly

A person typing invoice details into an accounting system may handle only a few dozen documents an hour. A large company may receive many thousands each day. The work needs many people, and those people could be doing more valuable tasks.

Pain 2: Humans make small mistakes

Typing “1,250.00” as “12,500.00” or swapping two digits in a bank account number is easy when you are tired. Such errors can cause wrong payments, angry customers and costly cleanup work.

Pain 3: Information is trapped

A scanned PDF looks like a document to a person, but to a computer it is just an image. You cannot search it, sort it or add up the amounts. Years of valuable information sit locked in file cabinets and storage folders.

Pain 4: Documents come in countless shapes

Every supplier designs their invoices differently. One puts the total at the bottom right, another at the top. Older software that relied on fixed positions, such as “the total is always at this spot”, breaks the moment a new layout arrives. A modern reader must understand meaning and context, not just coordinates.

Pain 5: Slow processing hurts business

When invoices wait days to be keyed in, suppliers get paid late and early-payment discounts are missed. When loan applications take weeks to process, customers walk away. Faster reading leads to faster decisions.

Pain 6: Compliance and audit demands

Regulated businesses must prove that they checked identity documents, verified income or archived records correctly. Automatic extraction creates consistent, searchable records that are easier to audit.

Everyday Analogy

A library full of unlabeled boxes of old letters is useless when you need one specific letter. Hiring someone to open each box, read each letter and write a catalog card makes the whole library searchable. Document AI writes those catalog cards automatically, in seconds per page instead of minutes.

CCore Concepts You Must Know

Eight ideas explain most of what you will meet in the console and the documentation.

Reader

Processor

A specialized reader you create inside your project. It takes documents in and returns structured results. Each processor has a type, such as OCR, invoice or custom.

Version

Processor Version

A specific snapshot of a processor’s model. Versions let you test a newer model, pin a stable one, and roll back if needed.

Reading

OCR

Optical Character Recognition: turning the image of text into real text characters that a computer can search and copy.

Result

Entity

A meaningful item found in a document, such as an invoice date, a supplier name or a total amount, with its type and value.

Result

Document Object

The structured answer for a document, holding the full text, pages, layout, tables, form fields and entities with locations on the page.

Trust

Confidence Score

A number showing how sure the model is about a result. Low confidence tells you a person should double-check.

Sorting

Classifier and Splitter

A classifier tells you what type of document a file is. A splitter finds where one document ends and the next begins within a long scan.

Custom

Workbench

The tools for creating your own processors: define the fields you want, label examples or give instructions, then test and deploy.

Handy words

TermWhat it meansEveryday picture
Structured dataInformation in neat fields, like a table rowA filled-in form
Unstructured dataInformation in free form, like a scanned pageA pile of loose letters
Bounding boxThe rectangle on the page where something was foundA highlighter box
Key-value pairA label and its value, like “Date” and “12 May”A form field and what you wrote in it
Normalized valueA cleaned, standard form of a value, such as a date in one agreed formatWriting every phone number the same way
LabelingMarking examples to teach a model what to findHighlighting answers in a textbook
UptrainingImproving a pretrained model using your own examplesGiving an experienced clerk some specific local training
Human reviewA person checking uncertain resultsA supervisor signing off a tricky case

AArchitecture and Processor Families

See the whole family of processors and how your application sits around them.

Document AI is a set of related readers that all work in the same way. You create a processor, send documents to it and receive a structured response. The difference is what each processor knows. Processors fall into a few families.

flowchart TB
  Docs["Your Documents - PDFs, Scans, Photos"] --> DAI["Document AI Service"]
  DAI --> G["General Processors"]
  DAI --> SP["Specialized Processors"]
  DAI --> CU["Custom Processors"]
  G --> G1["Enterprise Document OCR"]
  G --> G2["Form Parser"]
  G --> G3["Layout Parser"]
  SP --> S1["Invoices and Receipts"]
  SP --> S2["Bank Statements and Pay Slips"]
  SP --> S3["Identity Documents"]
  SP --> S4["Tax and Procurement Forms"]
  CU --> C1["Custom Extractor"]
  CU --> C2["Custom Classifier"]
  CU --> C3["Custom Splitter"]
    
Figure 1: The main families of Document AI processors. The exact catalog changes over time.

General processors

These work on almost any document. Enterprise Document OCR reads text, including handwriting and many languages. The Form Parser finds labels, values, tables and checkboxes in forms without being told what to look for. The Layout Parser understands the structure of a document, such as headings, paragraphs, lists and tables, and can split text into meaningful chunks for search and generative AI.

Specialized processors

These are pretrained for specific, common document types. They already know what fields to look for. Examples include invoices, receipts and expense documents, bank statements, pay slips, identity documents, and certain tax and procurement forms. Because they are pretrained for a document type, they usually give better results with no training effort. The exact list and country coverage differ, so check the catalog.

Custom processors

When your documents are unusual, such as a shipping form that only your company uses, you build a custom processor. A custom extractor finds the fields you define. A custom classifier sorts documents into the types you define. A custom splitter separates stacked documents. Modern custom extractors can use generative AI models to find fields with few or no labeled examples, and you can improve them with examples when more accuracy is needed.

The other parts around the processors

  • Your application or pipeline: the code that sends documents and uses the results, perhaps on Cloud Run or Cloud Run functions.
  • Cloud Storage: the usual place to keep incoming documents and output results, especially for batch jobs.
  • Authentication: service accounts and Identity and Access Management (IAM) control who may call the processors.
  • Client libraries and toolkits: helpers that make sending documents and reading results easier in popular programming languages.
  • Downstream systems: BigQuery, databases, accounting software and workflow tools that receive the extracted data.
Everyday Analogy

A hospital has general doctors who can look at any patient, specialists such as heart or eye doctors who know one area deeply, and the option to train a new specialist for a rare local condition. General, specialized and custom processors correspond to these three levels of expertise.

i
Good to Know

Earlier Google material mentioned a Document AI Warehouse for storing and managing documents. Its status has changed over time, so do not plan around it without confirming its current availability in the documentation.

HHow a Request Works Inside

Follow one invoice from your application, through Document AI and back.

sequenceDiagram
  participant App as Your Application
  participant Auth as Google Identity
  participant DAI as Document AI Processor
  participant Model as Reading Models
  App->>Auth: Prove who the application is
  Auth-->>App: Short-lived access credential
  App->>DAI: Send document file to the processor
  DAI->>Model: Read text and detect layout
  Model->>Model: Find fields, tables and entities
  Model-->>DAI: Structured result with confidence scores
  DAI-->>App: Document object with text, entities and locations
  App->>App: Validate, store or send for review
    
Figure 2: A document goes in, and a structured result with confidence scores comes back.

Step 1: Prove who you are

Your application runs under a service account, a special identity for programs, and receives a short-lived credential. This avoids storing passwords in code, and lets administrators control exactly what the program may do.

Step 2: Send the document

You send the file, such as a PDF or image, to a specific processor. For small and quick jobs you send the file directly in the request. For large collections you point the service at files stored in Cloud Storage.

Step 3: Read the page

The service first cleans up and analyzes the page image. It finds the text areas, recognizes the characters, detects lines and tables, and works out the reading order. This is the OCR and layout stage.

Step 4: Understand the content

Depending on the processor, further models then work out what the text means. A form parser links labels to their values. An invoice processor recognizes the supplier, the dates, the totals and the line items. A custom extractor finds the fields you defined.

Step 5: Return the structured answer

The result comes back as a Document object. It includes the full text, each page’s details, tables, form fields and entities. Each item has a confidence score and a location on the page, so you can show the original region to a reviewer.

Step 6: Use the result

Your own logic decides what happens next. You might check that the line items add up to the total, compare the supplier against an approved list, store the data in BigQuery, or send low-confidence results to a person.

Everyday Analogy

You show your ID at reception and get a one-hour visitor badge. You hand a folder to a clerk, who reads the pages, fills in a form with each field and marks the ones she is unsure about in pencil. You then check the pencilled items yourself before filing the form.

!
Watch Out

The service reads each document independently. It does not remember earlier documents. If you need to compare today’s invoice against last month’s, your own systems must store and compare the extracted data.

DData Flow and Document Lifecycle

A document arrives, is identified, read, checked, stored and finally archived. Here is that life story.

1

Document arrives

A file is uploaded by a customer, emailed to a mailbox, scanned by a clerk or dropped by a partner system into a Cloud Storage bucket.

2

Quality check and preparation

The pipeline checks the file type and size, and may check image quality, such as blur or skew, before spending money on processing.

3

Classify and split

If different document types arrive together, a classifier identifies each type and a splitter separates stacked documents into single ones.

4

Extract

The matching processor, such as the invoice parser, reads the document and returns text, fields, tables and confidence scores.

5

Validate

Business rules check the data: do the totals add up, is the date plausible, is the supplier known, does the number follow the expected pattern?

6

Review exceptions

Documents with low confidence or failed checks go to a person, who sees the original page next to the extracted fields and corrects them.

7

Deliver

Approved data is sent to the accounting system, database or workflow. The original file and the full result are archived.

8

Learn and improve

Corrections made by reviewers are collected and used to retrain or improve custom processors, and to adjust thresholds.

Straight-through processing

The goal of many projects is straight-through processing, where clean, high-confidence documents flow all the way from arrival to the business system without any human touching them. Humans focus only on the exceptions. Even a rate of seventy or eighty percent straight-through can transform the workload of a team.

i
Tip

Always keep the original file and the complete response. When a model improves or an auditor asks questions, you can go back to the source and re-process or prove what was received.

OOCR in Depth: Turning Pictures into Text

Everything starts with reading the characters correctly.

OCR, short for Optical Character Recognition, is the technology that looks at an image of text and produces the actual characters. Earlier OCR systems struggled with poor scans, unusual fonts and handwriting. Modern machine-learning-based OCR is much better, though it is still not perfect.

What good OCR gives you

  • The text itself: a full text version of each page, in reading order.
  • Structure: pages, blocks, paragraphs, lines and words, each with a position on the page.
  • Language detection: the service identifies the language used in each part of the document.
  • Handwriting: recognition of handwritten text in supported languages, usually less accurate than print.
  • Confidence per word: so you can find parts the model found hard to read.
  • Special features: options such as checkbox and selection mark detection, font style information, and reading of mathematical formulas, available through settings or add-on features.
  • Image quality signals: some processors can score how readable a page is, flagging blurry or dark scans.

What makes OCR fail

ProblemWhat happensWhat helps
Low resolutionLetters become fuzzy and are confused with each otherScan at a good resolution, commonly around 200 to 300 DPI
Skewed or rotated pagesLines of text slope, which harms reading orderLet the service auto-correct, or straighten scans beforehand
Shadows and bad lighting in photosDark patches hide lettersAsk users to retake photos in good light
Stamps, signatures and watermarks over textCharacters overlap and become unreadableClean scans, or use processors tuned to the form
Messy handwritingCharacters are guessed wronglyUse confidence thresholds and human review
Unusual fonts or very small printCharacters are misreadHigher scan quality and checking critical fields
Mixed languagesWrong language assumptions reduce accuracyProvide language hints where supported

Digital PDFs versus scanned PDFs

A PDF created directly by software, such as a bill produced by a billing system, often already contains real text inside it, so reading it is easy and accurate. A scanned PDF contains only a picture of each page, and needs full OCR. Document AI handles both, and combining embedded text with image reading can improve quality.

Everyday Analogy

Reading a crisp printed page is like reading a clean book. Reading a blurry photocopy of a photocopy, with coffee stains and handwritten notes in the margin, is much harder for anyone, human or machine. Better scans give better reading.

!
Watch Out

One wrong digit in a bank account number or an amount is serious, even if the rest of the page is perfect. For high-risk fields, add validation rules such as checksums and cross-checks, rather than trusting any single reading.

FForm Parser and Layout Parser

Understanding labels, values, tables, headings and structure in documents of any design.

Form Parser

A form is a page with labels and spaces for answers: “Name: ____”, “Date of birth: ____”. The Form Parser detects these key-value pairs automatically. It also finds tables, including their rows and columns, and detects checkboxes and whether they are ticked. You do not tell it what fields exist. It discovers them from the page itself. This makes it a great first choice when you have many different kinds of forms and do not yet know exactly what you need.

The trade-off is that the labels it returns are whatever text appears on the page. If two forms use “DOB” and “Date of Birth”, your own code must decide that these mean the same thing. If you need consistent field names, a specialized or custom extractor that outputs your own named fields is a better choice.

Layout Parser

The Layout Parser focuses on structure. It identifies headings, paragraphs, lists, tables and other building blocks, and keeps the document’s hierarchy. It can also break a long document into chunks, which are sensibly sized pieces that keep related text together, for example a heading with its paragraphs. These chunks are valuable for search and for generative AI systems that answer questions from documents, because feeding the system well-formed pieces gives better answers than chopping text at random.

Tables

Tables are one of the hardest parts of document reading. Rows may span pages, cells may merge, and lines may be missing. Both the Form Parser and Layout Parser try to rebuild tables as grids of rows and columns. Check the results on your own tricky tables, such as those with merged cells and multiple pages.

ProcessorBest atTypical use
Enterprise Document OCRGetting accurate text from pagesSearch, archives, input to other tools
Form ParserFinding labels, values, tables and checkboxes without setupExploring varied forms quickly
Layout ParserUnderstanding structure and creating chunksDocument search, question answering, summaries
Everyday Analogy

The form parser is like a helper who scans a paper form and writes down every “question: answer” pair he sees, using the words on the page. The layout parser is like a helper who draws an outline of a report, marking chapter titles, sections and tables, and cutting the report into sensible sections for easy lookup.

i
Good to Know

When you are unsure which processor to use, start with the general ones on a sample of your documents. Their results show you what the documents contain, and help you decide whether a specialized or custom processor is worth using.

SSpecialized Processors for Common Documents

Pretrained experts that already know what to look for.

Specialized processors are trained on large collections of a particular document type. They know which fields matter, how those fields usually appear and how to check them. They produce named fields with normalized values, so the output is ready to use with little additional work.

Finance

Invoice Parser

Finds supplier and customer details, invoice number, dates, totals, tax and line items, even when layouts differ between suppliers.

Finance

Receipt and Expense Parser

Reads merchant, date, items, tax and total from receipts, including photographed ones, for expense claims.

Banking

Bank Statement Parser

Extracts account details, statement period, balances and transaction lists.

Income

Pay Slip and Tax Form Parsers

Read earnings, deductions and employer details, and fields from certain official tax forms, useful for lending and onboarding.

Identity

Identity Document Parsers

Read names, dates of birth, document numbers and expiry dates from supported identity documents, such as licenses and passports.

Contracts

Contract and Procurement Parsers

Help find parties, dates, terms and other key details in agreements and purchasing documents.

Why use a specialized processor?

  • Faster to start: no training or labeling work is needed.
  • Better accuracy: trained on many examples of the exact document type.
  • Consistent field names: output uses standard names and cleaned values, such as dates and currency amounts in a regular format.
  • Built-in logic: some include helpful checks, such as comparing line items with totals.

Limits to remember

  • Coverage differs by country and document version. A processor trained for one country’s identity card may not read another’s.
  • Unusual layouts or unusual document versions can reduce accuracy.
  • Fields you care about may not be in the standard list. For those, use a custom extractor or combine tools.
  • Identity document processing supports business workflows, but it does not by itself prove that a document is genuine. Fraud checks need extra steps.
Everyday Analogy

A bank clerk who has seen ten thousand cheques can read a new cheque at a glance, because she knows where the amount, date and signature are expected to be. A general reader needs to figure out what everything on the page is. Specialized processors are the experienced clerks.

!
Watch Out

Identity documents and financial records are highly sensitive. Collect only what you must, protect them strictly, follow the privacy laws of your region, and never treat extraction alone as proof of identity.

CCustom Processors and Workbench

When your documents are special, create a reader that learns them.

Not every document is a common invoice. Companies have their own forms: a cargo manifest, an insurance claim sheet, an inspection report, a land record. Document AI Workbench provides the tools to create processors for such documents without needing deep machine learning skills.

Custom extractor

A custom extractor finds the fields you define. You list the fields, such as “claim number”, “incident date” and “damage description”, then provide guidance. There are two main ways to teach it.

  • With generative AI: modern custom extractors can use foundation models to locate your defined fields from little or no training data. You describe the field and may add a few examples, and the model finds it. This is fast to start and works well for many documents.
  • With labeled examples: you upload sample documents and mark where each field appears. The more varied and numerous the examples, the more accurate the processor tends to become. Labeling is slower, but it can give higher accuracy and more predictable results for stable, high-volume document types.

Uptraining a pretrained processor

If a specialized processor is almost right but misses a few fields, you can uptrain it. This means starting from the pretrained model and teaching it with a small number of your own labeled documents. The result keeps the general knowledge of the original while adapting to your needs.

Custom classifier and splitter

A custom classifier learns to sort documents into types you define, such as “invoice”, “purchase order” and “delivery note”. A custom splitter learns where one document ends and the next begins in a long scan, such as a batch of loan files scanned as a single PDF. Together they let one pipeline accept mixed piles of paper and route each piece to the correct processor.

Evaluating and versioning

After training, you test the processor on documents it has not seen, and look at measures such as how often fields are found correctly. You can then deploy a specific version, compare it with others and keep the previous version for roll-back. Good practice is to never replace a working production version without testing the new one on a representative sample.

flowchart TD
  Start["What Kind of Document?"] --> Q1{"Is it a common type with a pretrained processor?"}
  Q1 -->|"Yes"| Q2{"Does it give the fields you need?"}
  Q2 -->|"Yes"| A["Use the Specialized Processor"]
  Q2 -->|"Almost"| B["Uptrain the Specialized Processor"]
  Q1 -->|"No"| Q3{"Do you know the fields you need?"}
  Q3 -->|"No - exploring"| C["Use Form Parser or Layout Parser"]
  Q3 -->|"Yes"| Q4{"Do you have many labeled examples?"}
  Q4 -->|"No"| D["Use a Custom Extractor with Generative AI"]
  Q4 -->|"Yes"| E["Train a Custom Extractor with Labeled Examples"]
    
Figure 3: A simple way to choose the right type of processor.
Everyday Analogy

Training a new clerk can be done by giving a few written instructions and letting a smart person figure things out (generative approach), or by showing hundreds of marked-up examples until the clerk reaches expert level (labeled training). The first is quick to start, and the second can reach higher reliability on a stable workload.

i
Tip

Start with a small, varied sample of real documents, including the worst ones. Test accuracy before investing in large-scale labeling. Often the surprise is not the average document, but the strange one that breaks the rules.

UUnderstanding the Output

What comes back, how to read it, and how to decide what to trust.

Every processor returns a Document object, usually as JSON, which is a simple text format for labeled values and lists. It may look big at first, but it has a clear structure.

The main parts

  • Text: the complete text of the document, in reading order.
  • Pages: for each page, its size, detected language, and layout pieces such as blocks, paragraphs, lines and tokens, each with a position.
  • Tables: rows, header rows and cells, including references to the text they contain.
  • Form fields: pairs of labels and values with positions, produced by form parsing.
  • Entities: the named fields found by specialized or custom processors, each with a type, the text mentioned, a cleaned value, a confidence score and its location. Some entities contain smaller entities, such as an invoice line item holding a description, a quantity and a price.

Locations and anchors

Positions on the page are given as normalized coordinates, which are fractions of the page width and height from zero to one. This makes them independent of image size. You can draw a box on the original page for each field, which is exactly what review screens do. Many results refer to the main text by text anchors, which are start and end positions in the document’s text, so your code can pick out the exact piece.

Raw text versus normalized values

An entity often has both the text as written, such as “5th of Dec ’25”, and a normalized value, such as a standard date. Use normalized values for your systems and keep the raw text for review and audit. Always keep both.

Confidence scores

Each entity and many other parts carry a confidence score, a number between zero and one. A higher number means the model is more certain. It is not a guarantee. A confident answer can still be wrong, and a low-confidence answer can be right. The most useful way to use confidence is to set thresholds based on your own tests.

Confidence levelTypical actionWhy
High, above your upper thresholdAccept automatically if business checks passSpeeds up processing
Middle rangeSend to quick human review of that field onlyBalances speed and safety
Low, below your lower thresholdSend the whole document for full review or request a better scanAvoids bad data entering systems
Critical fields such as payment detailsUse stricter thresholds and extra validationMistakes here are costly
Everyday Analogy

A clerk returns a form with some answers in ink and a few in pencil with a question mark. The ink answers can go straight into the system. The pencilled ones need a quick look. Confidence scores are the ink and the pencil.

i
Good to Know

Open-source helper toolkits exist that make it easier to work with the output in common programming languages, for example by turning it into tables or highlighting fields on page images. Check the official documentation for current tools.

OOnline and Batch Processing

Two ways to send documents, depending on how fast and how many.

Online (synchronous) processing

In online processing, your application sends one document and waits for the answer in the same call. This is ideal when a user is waiting, such as a customer uploading a photo of an ID card during sign-up. Online requests have limits on file size and number of pages, so they suit small documents. Check the limits for your chosen processor, as they differ and can change.

Batch (asynchronous) processing

In batch processing, you point the service at many files in Cloud Storage and ask it to process them in the background. The call returns quickly with a long-running operation, which is a handle you can check later to see whether the job has finished. When done, the results are written as files to an output folder in Cloud Storage. Batch mode handles larger and longer documents and big collections, and is the right choice for overnight jobs and archives of historic paper.

QuestionOnlineBatch
Who is waiting?A user or system needing an immediate answerNobody, results are collected later
Document sizeSmall, with strict limitsLarger documents and many files
Input and outputDirectly in the request and responseFiles in and out of Cloud Storage
Typical useLive sign-up, instant receipt captureArchive digitization, nightly invoice runs
Error handlingImmediate error in the responseCheck the operation and per-file status

Limits and quotas

There are limits on pages per request, file size, requests per minute and the number of batch operations running at once. Defaults exist and many can be raised on request. Design your system to expect these limits: queue the work, slow down when needed and retry after a pause. Always read the current quota page, because numbers change.

Choosing the location

Processors are created in a location, such as a multi-region in the United States or Europe, or specific regions where offered. Your documents are processed in that location. Choose it to meet your data residency rules and to keep delay low, and remember that not every processor type is available in every location.

Everyday Analogy

Online processing is like handing a form to a clerk at the counter and waiting for her to stamp it. Batch processing is like leaving a box of forms in the office tray and picking up the stamped forms tomorrow morning.

i
Tip

Use online mode only where someone is truly waiting. Batch mode is usually better for throughput and for handling large or long documents, and makes it easier to manage failures one file at a time.

BBuilding an End-to-End Pipeline

How the pieces connect in a real system that handles thousands of documents a day.

A pipeline is a chain of automatic steps. Here is a typical document intake pipeline on Google Cloud.

flowchart LR
  In["Upload to Cloud Storage Inbox"] --> Evt["Event Notification via Pub/Sub or Eventarc"]
  Evt --> Orch["Cloud Run Orchestrator Service"]
  Orch --> Cls["Classifier Processor"]
  Cls --> Spl["Splitter Processor if Needed"]
  Spl --> Ext["Matching Extractor Processor"]
  Ext --> Val{"Checks Pass and Confidence High?"}
  Val -->|"Yes"| Auto["Auto-Approve and Save to BigQuery or ERP"]
  Val -->|"No"| Rev["Human Review Screen"]
  Rev --> Auto
  Orch --> Dead["Dead-Letter Queue for Failures"]
  Auto --> Arc["Archive Original and Result in Cloud Storage"]
    
Figure 4: A typical intake pipeline with classification, extraction, validation and human review.

Walking through the pipeline

  • Inbox: files land in a Cloud Storage bucket from uploads, scanners or partner transfers.
  • Trigger: a new file creates an event, sent through Pub/Sub or Eventarc, which wakes up the next step.
  • Orchestrator: a Cloud Run service decides what to do with each file. For complex flows, Workflows can coordinate the steps.
  • Classify and split: the classifier identifies the type, and the splitter separates stacked documents.
  • Extract: the right processor reads the document, such as the invoice parser for invoices.
  • Validate: business rules and confidence thresholds decide if the data is safe to accept.
  • Review: people handle the exceptions, using a screen that shows the original page and highlights fields.
  • Deliver and archive: clean data goes to BigQuery, a database or an accounting system, and everything is archived with the original.
  • Failures: files that cannot be processed go to a dead-letter queue where engineers can investigate.

Useful validation rules

  • Do line item amounts add up to the subtotal and the total?
  • Is the date a real date in a sensible range?
  • Does the supplier or customer exist in your master list?
  • Is this invoice number a duplicate of one already received?
  • Do account numbers pass their format checks?
  • Are required fields present?

Designing for retries and duplicates

Messaging systems may deliver an event more than once, and networks fail. Make each step idempotent, which means doing it twice has the same effect as doing it once. For example, use the file name and a content fingerprint to detect that a document was already processed, so no invoice is booked twice.

Everyday Analogy

It is like a well-run post room. Mail arrives in an inbox, a sorter identifies each item, specialists read the details, a checker confirms that everything adds up, and tricky cases go to a supervisor. Everything is photocopied into the archive, and anything undeliverable goes into its own tray.

GDocument AI with Generative AI and Search

Reading documents is the first step. Generative AI helps you ask questions and write summaries.

Many businesses want more than fields. They want to ask, “What are the termination clauses in these hundred contracts?” or “Summarize this claim file.” Generative AI models, such as Gemini in Vertex AI, are good at this, and Document AI helps feed them well.

The retrieval pattern

Retrieval-augmented generation, often called RAG, is a method where the system first searches your own documents for relevant passages, then gives those passages to a generative model so it can answer using real source material. This reduces made-up answers because the model is guided by your documents.

  • Parse: the Layout Parser reads documents and splits them into meaningful chunks that keep headings and tables together.
  • Index: chunks are stored in a search system, such as Vertex AI Search or a vector database, so they can be found by meaning.
  • Retrieve: when a user asks a question, the most relevant chunks are fetched.
  • Generate: a generative model writes an answer using those chunks, and can point to the sources.

Document AI versus using a generative model directly

Modern generative models can accept a document file directly and answer questions about it. This is flexible and quick to try. Document AI processors are more specialized: they return consistent, structured output, including positions and confidence scores, and are designed for high-volume, repeatable extraction. The best choice depends on the job.

QuestionDocument AI processorsGenerative model reading the file directly
OutputConsistent structure with confidence and positionsFlexible text or fields that depend on instructions
Best forHigh-volume, repeatable extractionAd-hoc questions, summaries, unusual documents
PredictabilityHighCan vary between runs
SetupChoose or build a processorWrite a good prompt
AuditabilityStrong, with locations of every fieldNeeds extra effort to show sources
Cost patternPer page, by processorBy amount of text and images processed

Combining them

A common design uses Document AI to read and structure documents, then generative AI for tasks on top, such as summarizing a long contract, explaining a clause in plain words, or drafting a reply. The structured extraction gives accuracy and traceability, and the generative layer provides flexibility.

Everyday Analogy

A court clerk who prepares a neat, indexed case file is the Document AI part. A lawyer who reads that file and writes an argument is the generative part. The lawyer works much better with a clean, indexed file than a messy pile of papers.

!
Watch Out

Generative models can state wrong things confidently. For legal, financial and medical documents, show the source passage next to every answer and keep a person responsible for important decisions.

PPerformance, Scalability and Accuracy Tuning

How to process large volumes quickly, and how to raise accuracy in practical ways.

Scaling the pipeline

Document AI itself is a managed service that scales on Google’s side, but it has quotas, and your own pipeline must respect them. Good habits include:

  • Queue the work: use Pub/Sub or Cloud Tasks to absorb bursts and release work at a steady, safe pace.
  • Run workers in parallel, but limit the total rate below your quota.
  • Retry with backoff: if the service says “too many requests” or has a short problem, wait and try again, waiting longer each time.
  • Use batch mode for volume: it manages large collections better than thousands of single calls.
  • Request quota increases early before a launch or a big migration.
  • Process once: keep a record of finished documents so restarts do not repeat work.

Raising accuracy without new models

Surprisingly, most accuracy gains come from the input and the surrounding logic, not from changing the model.

  • Improve the scan: resolution, straight pages, good lighting, clean glass and flat paper.
  • Send the right processor: classify first, so an invoice never goes to a receipt parser.
  • Split properly: process one document at a time rather than a stack.
  • Add validation rules: catch impossible values and mismatched totals.
  • Use lookup lists: match extracted supplier names against known suppliers and fix near matches.
  • Tune thresholds per field: a name can tolerate a lower confidence than a payment amount.
  • Learn from corrections: collect reviewer fixes and use them to uptrain or adjust.

Measuring properly

Create a test set of documents, labeled by people with the correct answers, that you never use for training. Run each new processor version against it and compare. Look at accuracy per field, not just overall, because one important field may be weak while the average looks fine. Keep measuring on fresh samples over time, since suppliers change their layouts and customers send new kinds of documents.

Everyday Analogy

A bakery that wants better bread does not only change the oven. It improves the flour, controls the temperature, weighs ingredients carefully and tastes each batch. Better inputs and a careful process matter as much as the oven.

i
Tip

Track what percentage of documents pass straight through. That single number tells you whether improvements are working, and it translates directly into saved hours of human work.

SSecurity and Privacy

Documents are full of private details. Protect them before, during and after processing.

Controlling access

Use Identity and Access Management (IAM) to control who may call processors, view results and manage settings. Use separate service accounts for separate applications, with only the permissions each needs. This is the principle of least privilege. Avoid sharing keys, and use short-lived credentials wherever possible.

Protecting data at rest and in transit

Connections to Google Cloud services are encrypted. Files in Cloud Storage and results in BigQuery are encrypted at rest by default. For stricter requirements, you can use customer-managed encryption keys through Cloud Key Management Service, where supported, to control and revoke access to the keys.

Data location

Choose processor locations that match your legal and company rules about where data may be processed and stored. Keep the input and output buckets in suitable locations too, since the pipeline spans several services.

Network boundaries

For sensitive projects, security perimeters such as VPC Service Controls can reduce the risk of data leaving a protected boundary, where supported. Private connectivity keeps traffic between your network and Google’s services off the public internet.

Data handling terms

Read Google’s current terms and documentation about how customer documents are processed, whether content is used to improve services, and what is logged or retained. Confirm these points with your legal and compliance teams before processing regulated data, such as financial, health or identity records.

Reducing exposure

  • Send only the pages you need, not entire archives without reason.
  • Use Sensitive Data Protection to find and mask or remove sensitive details from extracted text before sharing it widely.
  • Set retention rules: delete temporary files and outputs when they are no longer needed.
  • Restrict reviewers to the documents they handle, and log what they view.
  • Protect the results as carefully as the originals, because extracted data is easier to search and misuse.

Auditing

Cloud Audit Logs record administrative actions, and data access logs can be enabled where needed. Keep a record of which processor version produced each result, which supports audits and investigations.

Everyday Analogy

A bank’s document room has locked doors, a sign-in sheet, limited staff access, cameras and a rule that papers are shredded after their retention period. The digital version uses permissions, logs, encryption and retention rules for the same reasons.

!
Watch Out

Test and demo environments often contain real documents copied from production. Treat them with the same protection, or use synthetic and masked samples instead.

MMonitoring, Logging and Metrics

Watch both the health of the system and the quality of its answers.

There are two kinds of monitoring. Operational monitoring asks whether the system is working: are requests succeeding and how fast? Quality monitoring asks whether the answers are still good: is accuracy holding as document layouts change?

Operational signals

SignalWhy it mattersA warning sign
Pages processedDrives cost and shows demandUnexpected spikes
Error rate by codeShows failing calls and quota issuesRising errors or rate-limit responses
Processing latencyShows speed of online and batch jobsLonger times at the same volume
Queue depth and ageShows whether the pipeline keeps upBacklog that only grows
Dead-letter countShows files that cannot be processedAny sustained growth
Quota usageShows distance to limitsOften near the maximum

Quality signals

  • Straight-through rate: the share of documents that need no human touch.
  • Reviewer correction rate: how often people change an extracted field, per field and per supplier or form type.
  • Confidence distribution: a shift toward lower scores can signal new layouts or poorer scans.
  • Validation failures: a rise in mismatched totals points to a reading problem.
  • Document mix: new types or languages appearing that the pipeline was not designed for.
  • Processing time per document in human review: a hidden cost that can grow quietly.

Logging with care

Logs help you diagnose problems, but they can leak private content. Log file identifiers, processor versions, timings and statuses. Avoid logging the full extracted text or sensitive fields, unless there is a strong reason and strict access control.

Everyday Analogy

A factory checks that machines are running (operations), and also pulls random products off the line to check their quality (quality). A machine can run perfectly while producing faulty goods, so both checks matter.

CCost: Understanding the Bill

Document AI is mainly billed per page. Know what drives the price.

Document AI pricing is usage-based and set by Google, and it can change, so always use the official pricing page and calculator for current numbers. The general shape is stable and useful for planning.

Per Page

Pages Processed

Most processors are billed for each page they process. Simple OCR is generally cheaper per page than specialized or custom extraction.

By Type

Processor Type

Different processors have different prices. Specialized and generative extractors usually cost more per page than plain text reading.

Custom

Training and Hosting

Custom processors may carry charges for training and for keeping a version deployed, which can accrue over time even when idle.

Around It

Supporting Services

Cloud Storage, Cloud Run, Pub/Sub, BigQuery, networking and human review effort all add their own costs.

Ways to keep spending sensible

  • Choose the cheapest processor that does the job. Do not use a premium extractor when plain OCR is enough.
  • Classify before extracting. It avoids running expensive processors on the wrong document.
  • Send only needed pages. Remove blank pages, covers and attachments you will not use.
  • Reject bad files early. Check file type, size and basic quality before processing.
  • Remove duplicates. Do not process the same file twice.
  • Remove unused deployed versions. Undeploy test processor versions that nobody uses.
  • Count the human cost too. A slightly better and more expensive processor can save more in review time than it adds in price.
  • Set budgets and alerts, and limit retries so a bug cannot reprocess a whole archive repeatedly.
  • Label resources so billing reports show which team and project spend what.
Everyday Analogy

A print shop charges per page and charges more for color and special binding. Sending only the pages you need, in the simplest suitable format, keeps the bill down. Paying a bit more for a clean original can save time fixing mistakes later.

!
Watch Out

A loop that sends the same archive again and again, or retries failures without limit, can create a very large bill in hours. Add rate limits, budgets and alerts before going live.

AAdvantages, Disadvantages and Trade-offs

No tool is perfect. A good architect weighs both sides before choosing.

Advantages

  • Pretrained processors for common documents give fast starts with no training
  • Handles varying layouts better than fixed-position templates
  • Returns structured data with positions and confidence for review and audit
  • Custom processors cover your own special documents
  • Classifiers and splitters handle mixed piles of paper
  • Managed by Google, with scaling and model updates handled for you
  • Fits naturally with Cloud Storage, Pub/Sub, Cloud Run, BigQuery and Vertex AI
  • Supports both online and large batch processing
  • Layout parsing prepares documents well for search and generative AI

Disadvantages

  • Never perfectly accurate, so review and validation steps are needed
  • Quality depends strongly on scan quality and document condition
  • Specialized processor coverage varies by country and document version
  • Handwriting and messy layouts reduce accuracy
  • Per-page costs add up for very large archives
  • Custom processors need sample data and testing effort
  • Quotas and page limits require careful pipeline design
  • Product names, features and processor versions change over time

The main trade-offs, in plain words

  • Pretrained versus custom: pretrained is quick but fits only standard documents, custom fits your needs but takes effort.
  • Automation versus safety: higher straight-through rates save time but risk more errors without good validation.
  • Structure versus flexibility: processors give consistent output, generative models give flexible answers.
  • Cost versus accuracy: premium processors and cleaner scans cost more, but can reduce expensive manual correction.

Related tools at a glance

NeedTool to consider
Simple text detection from images, such as signs and labelsVision AI text detection features
Structured fields from business documentsDocument AI
Ad-hoc questions and summaries over documentsGenerative models in Vertex AI
Feelings, names and topics in extracted textCloud Natural Language API
Searching across many documents with natural questionsVertex AI Search
Finding and masking private dataSensitive Data Protection
Turning audio into textSpeech-to-Text
Changing languageCloud Translation

DDesign Patterns and Anti-patterns

A pattern is a proven way to solve a common problem. An anti-pattern is a tempting mistake that causes pain later.

Helpful patterns

Pattern

Classify, Split, Extract

Sort and separate mixed piles first, then send each document to the processor that understands it.

Pattern

Confidence-Based Routing

Auto-accept high-confidence, validated results, and send the rest to people with the page and highlighted fields.

Pattern

Validate Against Business Rules

Check totals, dates, duplicates and master data, because models read text but your rules know what makes sense.

Pattern

Feedback Loop

Collect reviewer corrections and use them to improve custom processors and tune thresholds.

Pattern

Pin and Test Versions

Use a specific processor version in production, test new versions on a fixed sample set, then switch deliberately.

Pattern

Store Original Plus Result

Keep the source file and the full response together, so you can audit, reprocess and explain any decision.

Anti-patterns to avoid

ANTI-PATTERN 01 Avoid
What people do

They trust every extracted value and push it straight into accounting or customer systems with no checks.

Why it hurts

Small misreads become wrong payments, wrong records and hard-to-trace errors.

Better approach

Use confidence thresholds, business rule validation and human review of exceptions, especially for money and identity fields.

ANTI-PATTERN 02 Avoid
What people do

They send everything to the most advanced, expensive processor, regardless of document type.

Why it hurts

Costs rise without any gain for simple documents, and the wrong processor may give worse results for some documents.

Better approach

Classify first and match each document type to the simplest processor that meets the accuracy you need.

ANTI-PATTERN 03 Avoid
What people do

They ignore scan quality and blame the AI when results are poor.

Why it hurts

Blurry, skewed or dark images limit accuracy no matter how good the model is, and the real fix is cheap and upstream.

Better approach

Set scanning standards, reject unreadable files early and ask for better images when quality is too low.

ANTI-PATTERN 04 Avoid
What people do

They switch to the newest processor version automatically in production without testing.

Why it hurts

A change in behavior can quietly break downstream rules, or reduce accuracy on your particular documents.

Better approach

Pin versions, compare new versions against a fixed test set and roll out deliberately, keeping the old version ready for roll-back.

ANTI-PATTERN 05 Avoid
What people do

They keep only the extracted fields and throw away the original files and the model’s full response.

Why it hurts

They cannot prove what was received, re-run with better models or investigate disputes.

Better approach

Archive the original and the response, with retention rules that match your legal needs.

BBest Practices and Common Mistakes

A checklist you can follow from the first day.

Best practices

  1. Start with business goals. Decide which fields, accuracy and speed would genuinely help, before choosing tools.
  2. Collect a realistic sample. Include good, average and awful documents, and have people label the correct answers.
  3. Try pretrained processors first. Move to custom only if they fall short.
  4. Standardize scanning. Aim for clear, straight, well-lit pages at a sensible resolution.
  5. Classify and split before extracting. One document type per processor call.
  6. Validate with business rules. Totals, dates, duplicates and master data checks catch many errors.
  7. Set per-field confidence thresholds. Be stricter for money and identity fields.
  8. Build a good review screen. Show the original page with highlighted fields, and make corrections quick.
  9. Use batch mode for volume and online mode only when someone is waiting.
  10. Queue, retry and make steps idempotent. Respect quotas and avoid duplicate processing.
  11. Pin processor versions and test new ones on a fixed sample set.
  12. Protect the data. Least-privilege access, suitable locations, encryption and retention rules.
  13. Monitor quality as well as uptime. Track straight-through and correction rates.
  14. Check the latest documentation. Processors, limits, locations and prices change.

Common mistakes

1

Testing only on clean samples

Demos with perfect documents look wonderful. Real mailrooms contain crumpled, faxed and photographed pages. Test with the worst.

2

Sending stacked scans as one document

A single PDF holding many documents confuses extraction. Use a splitter first.

3

Ignoring multi-page tables and line items

Teams check the header fields and forget that long tables span pages. Test line items and totals carefully.

4

Not planning for duplicates

The same invoice emailed twice is booked twice. Detect duplicates by number, supplier and amount.

5

Leaving test processors deployed

Unused deployed versions can keep costing money. Remove them when finished.

6

Never re-measuring accuracy

Suppliers redesign invoices and forms get new versions. Review samples regularly and retrain when needed.

RReal-World Usage Scenarios

Four illustrative stories show where Document AI fits. The companies below are imaginary examples to teach the ideas.

Scenario 1: A manufacturer processing supplier invoices

A manufacturer receives thousands of invoices a week from hundreds of suppliers, each in a different layout. Invoices arrive by email and are saved to a storage inbox. The invoice parser extracts supplier, number, dates and line items. Rules check totals and compare purchase order numbers. Most invoices flow straight to the accounting system, while mismatches appear on a review screen. Payment cycles shorten, and early-payment discounts are captured more often.

Scenario 2: A lender onboarding customers

A lending company asks applicants to upload an identity document, a bank statement and a pay slip. Specialized processors read each document, and the system cross-checks that the name and address match across them. Low-confidence reads prompt the applicant to retake a photo in better light immediately, while the application is still open. Fraud checks run as a separate step. Applications that took days now often finish the same day.

Scenario 3: A hospital digitizing patient forms

A clinic network scans decades of paper registration and consent forms. The layout parser and form parser extract text and checkboxes, and a custom extractor captures a few clinic-specific fields. Strict access controls, regional processing and masking of sensitive details protect privacy. Staff can now search records in seconds, instead of walking to a basement archive, and every extracted field links back to the scanned page for verification.

Scenario 4: A law firm exploring contracts

A law firm has thousands of agreements in many formats. The layout parser splits each contract into structured chunks, a search system indexes them, and a generative model answers questions such as “Which contracts allow early termination?” while showing the exact clauses. Lawyers confirm every answer against the source text, and the firm saves many hours of manual reading during due diligence.

The best document system is not the one that reads perfectly. It is the one that knows when it is unsure.

When Document AI is a strong choice

  • You process many documents with varied layouts and need structured data.
  • You have standard document types that pretrained processors already understand.
  • You need positions and confidence for review and audit.
  • You want to feed clean, structured chunks into search or generative AI.
  • You prefer a managed service over building and hosting your own models.

When to think twice

  • You only need simple text from a handful of images, where a lighter OCR tool may suffice.
  • Your volume is very small and manual entry is cheap.
  • Your documents are extremely rare or unusual and you cannot gather sample data.
  • Your rules forbid sending the documents to an external managed service, or the data location does not meet requirements.

FFrequently Asked Questions

Quick answers to questions that beginners ask most often.

Q1Do I need machine learning skills to use Document AI?
No, not for pretrained processors. You send a document and receive results. Basic programming knowledge or help from a developer is enough. Custom processors are easier than building models from scratch, but they still need sample documents and testing.
Q2What is the difference between OCR and Document AI?
OCR turns an image of text into characters. Document AI includes OCR but goes further: it understands layout, forms, tables and the meaning of fields, and returns structured data.
Q3Which processor should I start with?
If a pretrained processor exists for your document type, such as invoices, start there. If you are exploring varied forms, try the Form Parser. If you need structure and chunks for search, try the Layout Parser. If you only need text, use OCR.
Q4How accurate is it?
Accuracy varies by document type, scan quality, language and layout. It can be very high on clean, common documents and lower on poor scans and handwriting. Measure it on your own labeled sample, and design for review of uncertain results.
Q5Can it read handwriting?
Yes, for supported languages, but handwriting is harder than print and results are usually less accurate. Use confidence thresholds and review for important handwritten fields.
Q6Can it handle documents in other languages?
It supports many languages for text recognition, though coverage differs for handwriting and for specialized processors. Check the current language lists and test your own documents.
Q7What is the difference between online and batch processing?
Online processing sends one document and waits for the result, suited to small files and live users. Batch processing handles many or larger files from Cloud Storage in the background and writes results back as files.
Q8Can I train it on my own forms?
Yes. You can create custom processors with Workbench, using generative extraction with few or no examples, or training with labeled examples, and you can uptrain some pretrained processors with your own data.
Q9How do I handle a PDF containing many different documents?
Use a splitter to separate the individual documents and a classifier to identify their types, then send each part to the matching processor.
Q10Is Document AI the same as using Gemini on a PDF?
No. Gemini and similar models can read a document and answer flexible questions. Document AI processors give consistent, structured results with confidence scores and positions, built for repeatable high-volume extraction. Many solutions combine both.
Q11How is it priced?
Mostly per page processed, with different prices for different processor types, and possible charges for custom processor training and hosting. Check Google’s pricing page for current numbers and set budgets and alerts.
Q12Is my data safe?
Google Cloud provides encryption, access controls, data location choices and audit logs. Your own configuration matters too. Review Google’s current data handling terms and involve your legal and security teams for sensitive documents.
Q13What is the easiest way to try it?
Pick ten to twenty real, non-sensitive documents, including a few messy ones. Try them in the console with a general processor and with a specialized one if it fits. Compare the results with what you expected, then delete any test processors and files when you finish.

SSummary and Key Takeaways

Remember These Points

  • What it is: Document AI is Google Cloud’s managed service for reading documents and turning pages into structured data, using processors for text, layout, forms, common document types and your own custom needs.
  • Pick the right reader: use OCR for text, Form Parser to explore forms, Layout Parser for structure and chunks, specialized processors for invoices, receipts, statements and identity documents, and custom processors for your own forms.
  • Read the output with care: every field comes with a location and a confidence score. Keep both the raw text and the normalized value, and set thresholds from your own tests.
  • Build a pipeline, not just a call: classify and split, extract, validate against business rules, route exceptions to people, deliver the clean data and archive the original with the result.
  • Choose the processing mode: online for live users and small files, batch for volume and large documents, and respect quotas with queues, retries and idempotent steps.
  • Improve accuracy upstream: better scans, correct classification, validation rules and lookup lists usually help more than changing models. Learn from reviewer corrections.
  • Combine with generative AI wisely: Document AI gives accurate, traceable structure, while generative models add summaries and question answering. Always show sources for important answers.
  • Protect and control cost: use least-privilege access, suitable locations and retention rules, choose the cheapest suitable processor, set budgets, and always check Google’s latest documentation, because processors, limits and prices change.