AI document processing: how a purchase-order parsing pipeline works

AI document processing reads documents such as invoices, purchase orders and order confirmations and turns them into structured data your systems can use. Modern pipelines combine OCR with language models: you describe the fields you want, and a text or vision model fills them in from each document, whatever its layout. The model is the easy part. The work is in defining the schema for each document source, picking the right model per source, catching the small errors that look correct, and fixing parsers as senders change their documents. We run one of these pipelines for a distribution team that receives purchase order acknowledgments from many suppliers, and this article is what it has taught us.

Key takeaways

  • AI document processing (also called intelligent document processing, or IDP) is OCR plus a model that understands layout and meaning, plus your own rules for what counts as valid output.
  • One schema and parser per document source works better than one parser for everything. In our purchase-order pipeline each supplier and customer account has its own.
  • Test text-based and vision-based extraction for each source. Neither wins everywhere.
  • The costly errors are plausible ones: a wrong unit of measure or a shifted promised date passes a format check and reaches your order data.
  • Plan for upkeep from day one. Suppliers change their documents, so a parsing pipeline is a service you keep fixing, not a project you finish.

What is AI document processing?

It is software that takes a document (a PDF, a scan, an email attachment) and returns the fields you need as structured data, usually JSON, ready for your ERP, order system or spreadsheet. Older systems relied on OCR plus fixed templates, which broke when a layout moved. Current tools add machine learning and language models that read a document more the way a person does.

The large cloud providers each offer a version. Amazon Textract Core "detects and extracts printed text, handwriting, forms, tables, and layout information" from documents and includes specialized processing for invoices and receipts, with a separate API for that task. Azure Document Intelligence has prebuilt models, including one for invoices, and custom models: a "custom template" model for "static layouts" and a "custom neural" model for semistructured documents, with invoices and purchase orders named as examples. Google Document AI groups its processors into digitising (OCR), extracting (a custom extractor, form parser, layout parser and pretrained parsers) and classifying.

Alongside them are parsing services built around language models. Airparser, which our pipeline uses, describes its engine as using "Text LLM, Vision LLM and AI OCR engines": you describe the data to extract as an extraction schema, send documents by email, upload or API, and export results by webhook, API or automation tools such as Zapier.

Is AI document processing a fit for your documents?

It fits when three things are true:

  • The same kind of document arrives often, from many senders. Invoices, purchase orders, order acknowledgments, delivery notes, claim forms.
  • Each sender uses its own layout. If every document came from one template, a simple rule-based extractor would do.
  • Someone types these fields in today. That person's time, and the errors they catch or miss, are your baseline.

It is a weak fit for a handful of documents a month, or where every field must be judged by an expert. Volume and layout variety decide how much automation pays.

How does a purchase-order parsing pipeline work?

The purchase order parsing pipeline we built serves an e-commerce distribution team. After the team places an order, each supplier sends back a purchase order acknowledgment: its confirmation of what it will ship, in what quantity and units, at what price and by which date. Every supplier words and lays these out differently. Our parsing layer turns them into structured data. In outline:

  1. Each document goes to its own parser, the one for that supplier and customer account.
  2. A schema defines the output. Each supplier and customer account has its own JSON schema: the fields to extract, their types and what each one means.
  3. A model reads the document. For each supplier we tested text-based and vision-based extraction and use the one that reads that supplier's documents best.
  4. The structured result goes onward into the team's order data.
  5. Errors are fixed at the parser. When a field comes out wrong, the fix goes into that supplier's schema or parser, so the same mistake is less likely to come back.

Alongside the parsers we also designed purchase order PDFs for several customers. It is the same problem from the other side: a clear, consistent document is easier for every system downstream to read.

Why one schema per supplier instead of one for everything?

Because the meaning of a field changes between suppliers, not just its position. One supplier quotes quantity in cases, another in single units; one gives a ship date, another a delivery date. A single shared schema forces the model to guess which one it is looking at. A schema per supplier and customer account can say exactly what each field means for that sender, and a fix for one supplier cannot break another.

The cost is more parsers to maintain. In our experience that is the better trade: each one is small and can be tested on its own supplier's documents.

Text model or vision model?

Test both on real documents from each source. A text model works from the text extracted from the file. That suits clean, digitally generated PDFs. A vision model looks at the page as an image. That helps when meaning depends on layout: tables whose columns are not obvious from the raw text, or scans.

In our pipeline the choice is made per supplier, after testing, and we keep tuning parsers for accuracy and efficiency. Do not decide this once for the whole project.

What goes wrong, and how do you catch it?

The errors that matter are not the ones that crash anything. They are values that look right. In our pipeline, two kinds we have had to fix are unit-of-measure mismatches and wrong promised dates. A quantity of 10 read as units when the supplier meant cases is still a valid number. A wrong promised date is still a valid date. Both reach the order data unless something stops them.

Model providers now offer "structured outputs" that force a model's reply into your JSON schema. Anthropic's documentation describes this as ensuring "valid, parseable output", and OpenAI's says it "constrains completed, non-refusal model output to your supplied JSON Schema". That removes broken JSON. It does not make the values correct, and both vendors still tell you to handle refusals and cut-off replies. Checking the values is your job.

So add your own checks after extraction:

  • Compare against what you already know. The acknowledgment should match the purchase order you sent: the same items, quantities in comparable units, and dates that make sense.
  • Define units per supplier. Write each supplier's unit conventions into its schema instead of hoping the model infers them.
  • Route doubtful documents to a person with the document and the extracted fields side by side, rather than letting them through silently.
  • Keep a test set per supplier. A few real documents with the correct output, run again after every parser or model change.

Should you buy a service, use a cloud API or build on a model directly?

It depends on your volume, your systems and how much control you need over each source.

Route Good when Watch for
Parsing service built on language models (for example Airparser) Many senders, quick start, results go to a spreadsheet, webhook or automation tool You work within the service's features and hosting terms
Cloud document AI (Textract, Azure Document Intelligence, Google Document AI) You already run on that cloud; prebuilt models match your document types Custom models need labelled examples; you build the pipeline around the API
Your own pipeline on a model API with structured outputs Unusual documents, strict validation, deep integration with your own systems You own the testing, monitoring and every fix

These are vendors' descriptions of their own products, not our benchmark. Whatever you choose, the schema, the checks after extraction and the upkeep are your work. Extraction is usually one step in a larger flow: our guide to AI agents vs automation explains why a model that extracts while ordinary code does the rest is often the right design, and our workflow automation service connects the output to the systems that act on it.

What does it take to keep it running?

Ongoing attention. Suppliers redesign documents, add fields and change how they write dates, units or part numbers. Our work on this pipeline did not end at launch: it continues with fixing parsing errors as they appear and tuning parsers. Three habits help:

  • Log every correction a person makes, by supplier, so you can see which parser needs work.
  • Write handover notes for resolving parsing errors, so the operations team can fix common issues without waiting for a developer. We wrote these for this team.
  • Rerun each supplier's test set after any change to its parser or the model behind it.

What drives the cost?

We do not publish prices, because they depend on the work. The drivers are the number of document sources, how different their layouts are, how strict the checks after extraction must be, document volume and model usage, the systems the output feeds, and who maintains the parsers afterwards.

If you have a stack of documents someone retypes every week, our AI document processing solution sets up a pipeline like this one, run by us or installed in your own cloud, and our AI agents and automation service builds custom pipelines around your systems.

FAQ

What is the difference between OCR and AI document processing?

OCR turns an image of text into text. AI document processing goes further: it works out which text is the quantity, which is the date and which is the part number, and returns those as fields in a structured format your systems can use.

Can AI read scanned or photographed documents?

Yes. Vision models and OCR engines read scans and images, and some services also read handwriting. Quality still depends on the scan, so test with the worst documents you actually receive, not the cleanest.

How accurate is AI document extraction?

It depends on your documents, not on a published average. Measure it on a test set of your own real documents with the correct fields, per sender, and decide in advance which errors need a person to review them.

Do we need a separate parser for every supplier?

For documents that vary a lot between senders, it usually pays. A schema per supplier lets you state what each field means for that sender and fix one supplier without affecting the others.

Does structured output from the model mean the data is correct?

No. It guarantees the shape of the output, such as the field names and types. A wrong unit or date can still fill a valid field, so check values against your own records.

Sources (6 links)
Share this article