Loading
Skip to case study

Document processing case study

Invoice Processing on AWS

A pipeline that reads supplier invoices with AWS, pulls out the seven fields accounts need, and decides whether each invoice can go straight through or needs a person to check it.

Type
Independent project
Data
8 fictional invoices
Status
In progress
7 of 8invoices got the right outcome from Textract alone
12 of 56fields came out wrong, 8 of them the currency
0wrong amounts or dates
28offline tests, none of which call AWS

The problem

Supplier invoices arrive as PDFs, and every supplier lays theirs out differently. To pay one, accounts need seven fields from it:

Paying a wrong total is worse than paying late, so the pipeline never guesses. Every invoice ends up accepted or needs_review, and a review always comes with its reasons.

How it works

Each fictional invoice PDF is uploaded to Amazon S3 and read by Amazon Textract. Claude Haiku 5.5 on Amazon Bedrock turns Textract’s plain text into typed JSON. Claude’s fields, and Textract’s own fields as a baseline, are checked by the same three rules: types, required fields, and subtotal plus tax equalling the total. Each invoice is then accepted or marked needs_review with its reasons.
Textract’s own fields take the dashed path, so there’s a baseline to compare Claude against. Open full size

The AWS services, briefly

Amazon S3
File storage. Files are kept in a container called a bucket. Each invoice PDF is uploaded here so Textract can read it.
Amazon Textract
Reads text from scanned documents and PDFs (OCR). Its AnalyzeExpense feature also tries to find invoice fields like the supplier and the total.
Amazon Bedrock
One AWS API for AI models from several companies. Here it runs Anthropic’s Claude Haiku 5.5, which reads Textract’s text and returns the fields as JSON.

The first results

Eight fictional invoices, each testing something different, in five layouts. An answer key records the values printed on each and the outcome a perfect reading should get. So far, only the Textract-only baseline has run.

Textract alone, against the answer key
InvoiceWhat it testsShould beTextractFields it got wrong
Northwind OfficeComplete and correctacceptedacceptedcurrency
Bluegum ConsultingDate written out in wordsacceptedacceptedsupplier (“BC”), currency
Harbour PrintNo invoice numberneeds_reviewneeds_reviewcurrency
Kestrel ITTotal $10 more than subtotal + taxneeds_reviewneeds_reviewinvoice number, supplier (split over two lines), currency
Coastal CateringTotal 1 cent off from roundingacceptedacceptedcurrency
Summit FreightNo currency printed, only “$”needs_reviewacceptedsupplier (“SF”), currency
Tui TimberNew Zealand supplier: NZD, 15% GSTacceptedacceptedcurrency
Corner CafeReceipt with no subtotal printedneeds_reviewneeds_reviewcurrency

Every $ became USD

Textract reported US dollars on all eight, even invoices that print AUD or NZD. Summit Freight prints no currency at all, so it should have gone to review, but the guessed USD let it through.

Logos read as names

On the two banner layouts, Textract took the supplier’s initials from the logo (“BC”, “SF”) as the business name.

Right outcome, wrong reason

Kestrel IT went to review as it should, but partly because Textract missed its invoice number on the sidebar layout, not only because of the bad total.

It did get every amount and every date right, including the date written in words. The ABNs and due dates printed next to the invoice number and invoice date didn’t fool it.

Key decisions

Read, never infer

Claude is told to return only values printed on the invoice: no working out a missing subtotal, and no currency guessed from a $ sign. A gap goes to review.

A schema, not free text

Claude must answer in a JSON schema built from a Pydantic model. Amounts come back as text and become exact decimals, so money never passes through a float.

The same rules for both

Textract’s fields and Claude’s go through identical validation, and the answer key comes from the same data as the PDFs, so the comparison is fair.

Where it’s up to

The Claude step is built and tested against a fake client, but it hasn’t run yet: on a brand-new AWS account, every Bedrock model quota starts at zero, and the increase for Claude Haiku 5.5 is still pending.

Built

  • A generator for 8 fictional invoices in 5 layouts, with an answer key
  • Upload to S3 and reading with Textract
  • The Textract-only baseline, run on all 8
  • The Claude on Bedrock step, with structured outputs
  • Validation rules shared by both paths
  • 28 offline tests with stubbed AWS and Claude responses

Next

  • Run the Claude step on all 8 once the quota is approved
  • Score every field for both paths automatically
  • Measure the real cost per invoice