Skip to content
sinc-LLMBook a 15-minute call

How to Test Whether an AI Extractor Confuses Invoice and Purchase Order Numbers

Move labels, swap values, and remove a field in controlled invoice fixtures. Grade both the extracted value and the source location before enabling automatic posting.

On this page

By Mario Alexandre · November 26, 2026 · 3 min read

An invoice extractor can return a genuine identifier from the page and still fill the wrong field. Give it the same invoice twice with the invoice and purchase order label-value pairs in opposite positions. The invoice number should stay the same, and the evidence should move with it. Then keep the layout fixed and swap the values. The answer should change while the evidence stays in the invoice field's location.

Build a small set of invoices you can grade by hand

Use identifiers of the same format so that a prefix gives the answer away in neither document. Pick a synthetic one-page layout with two labeled positions. In this illustrative fixture, position A is the top-left box and B is the top-right box. Keep the renderer, page size, typography, and remaining text fixed. Render each document through the same intake path as a real file, including OCR if the workflow uses it.

Fixture Box A Box B Expected invoice number Expected evidence
Baseline Invoice no. 730041 Purchase order no. 730042 730041 A
Move both label-value pairs Purchase order no. 730042 Invoice no. 730041 730041 B
Swap values only from baseline Invoice no. 730042 Purchase order no. 730041 730042 A
Remove invoice value from baseline Invoice no. with blank value Purchase order no. 730042 null with reason absent No value span

On the first pair, an extractor that reads box A regardless of the label returns 730042 on the moved layout. On the third fixture, an extractor that repeats the identifier from the baseline returns 730041 even though the invoice field now displays 730042. The blank fixture catches substitution when the only visible identifier belongs to the purchase order. Apply the same checks to the purchase order field when the output contract includes it. A full field swap is easier to diagnose when you see both assignments.

Score the value and the assignment

Before running the extractor, annotate each expected value and its evidence from the rendered document. Record the page and bounding box or the OCR span for the value and its label. Choose a matching rule that handles measurement variation while keeping nearby boxes distinct. Compare identifiers as strings so leading zeros stay meaningful. Normalize whitespace only where the business record treats it as insignificant.

Give the value and evidence separate outcomes. A correct string paired with the purchase order box is a value pass and an evidence failure. A read of the invoice box with a wrong digit fails the value check. A missing field passes only when the returned status matches the absence condition and no value span is asserted. If both labels carry the same identifier in your documents, add a fixture for it. The evidence score still distinguishes the fields when the strings match.

Check both the role and value against independent annotations. Google Document AI's evaluation guide describes comparing predicted entities with test annotations and reporting precision and recall per label. The location test here adds a separate requirement for workflows where a reviewer must be able to trace an extracted value to its source. Google Cloud Document AI evaluation guide

Add an equal-value control when identical identifiers are legitimate. With invoice no. 730041 in A and purchase order no. 730041 in B, an invoice result of 730041 linked to A passes both checks. The same result linked to B passes the value check and fails the field assignment. Keep an unreadable value in a separate fixture from an empty field so the review route can distinguish unreadable evidence from confirmed absence.

Gate the affected posting route

Treat a purchase order number copied into the invoice field as a critical failure if that field controls posting or duplicate detection. Send the affected layout family to review while you diagnose it. Keep OCR text and location data alongside the extraction result. If the expected label and value survived OCR, inspect how extraction associates them. If either is missing or displaced in OCR, isolate that stage before changing the extraction prompt.

Start with the fixture table and the equal-value control and record the two outcomes for each. After a fix, run them again and check a fresh layout you held aside. The controlled set isolates a specific confusion, and the fresh case checks whether the correction carries to another layout. For the surrounding evaluation and release process, see the sinc-LLM guide to evaluation harness failure modes.