01

Valid JSON can contain the wrong invoice

An invoice extractor returns perfectly formatted JavaScript Object Notation (JSON): the supplier name is present, the amount is numeric, and every expected field appears. But the total comes from a different invoice on the same scanned page. The downstream payment workflow accepts the record because its parser found no error.

Structured output from a large language model (LLM) makes its response easier for software to consume. A record becomes usable only when the application checks its meaning against the source and the receiving workflow.

02

Define what each field means

Begin with the receiving system. Specify which fields it requires, their types, allowed values, and the meaning of an absent value. An unknown tax amount should remain distinguishable from a tax amount of zero. An unreadable purchase order reference should have a defined path through review.

JSON Schema can require properties and restrict unexpected fields. Listing a field under properties alone leaves it optional; the schema must also require it if the receiving service expects it to be present in every record. 1

Each field in the schema should serve a downstream need. Asking for twenty speculative fields gives the model more opportunities to infer information the source never supplied. Consider retaining a source page or passage reference alongside each extracted value.

Decide what one extracted record represents before choosing its fields. A PDF with several invoices needs a separate record for each invoice, reliably linked to its pages. Otherwise the model can assemble a convincing record from unrelated sections, and a single document identifier will not help a reviewer locate the mistake.

The receiving application may handle a missing value differently from one that is unreadable or does not apply. Represent those states explicitly and decide which the application accepts. Requiring a string should not force the model to invent a default and make incomplete extraction look like complete business data.

03

Validate in separate stages

First check that the response can be parsed and conforms to the schema. Then apply rules the business already understands. Invoice dates must follow the agreed interpretation, currencies must be supported, and line totals should reconcile within an explicit rounding tolerance.

Where possible, check extracted references against authoritative systems. A plausible supplier identifier may belong to an inactive vendor, or a purchase order may belong to another legal entity. The application should reject those records with specific reasons.

An amount can pass every arithmetic check and still come from the wrong document. Compare critical values with their source in a separate validation step, preserving document boundaries during extraction. If ambiguity remains in a field with serious consequences, send it to someone who can inspect the original.

Keep normalization visible. An invoice may show a comma as a decimal separator or use a date whose day and month are ambiguous. Store the original text where it matters, along with the normalized value and the rule used. A reviewer can then tell whether the error came from reading the document or interpreting its notation.

Agree with the downstream owner which checks block processing and which only need attention. An unknown currency might make an amount unusable; a missing optional contact number may be harmless. If every warning goes to manual review, people can learn to approve the queue quickly, weakening scrutiny of consequential fields.

04

Bound the correction loop

A failed validation can trigger a correction request containing the source and the exact problem. For example, ask the model to revisit the total because the extracted line amounts do not reconcile. Set an attempt limit and retain the original response so reviewers can see what changed.

Do not let retries continue until the output happens to satisfy a validator. A model could change a value to make the arithmetic work without reading it correctly. After the permitted attempts, reject the record or send it for review with the failed checks attached.

Give each record an explicit processing state, such as extracted, validation failed, review required, or accepted. Downstream systems should consume only the states they are authorized to use. Records awaiting review should not feed the production table unnoticed.

Open each review case with the disputed value beside its source passage. Show why the record failed, which fields the reviewer can correct, and what follows submission. Corrections must rerun the relevant checks: changing a total can fix one error while creating a mismatch with the line items.

Accepting an extracted record does not authorize payment. The receiving workflow may still require duplicate detection and payment approval. The integration should preserve those controls while the extraction service supplies a traceable candidate record and validation result.

05

Keep accepted data traceable

Store the source identifier, extraction configuration, schema version, validation results, and any human correction with the accepted record. Apply access and retention controls to that material. A reviewer should be able to reconstruct how an invoice became a payable item without searching through unrelated conversations.

Count review cases by failure reason and document family to see how much work remains for people. Also inspect a sample of accepted records, since a plausible wrong value may never reach the review queue. For invoices, compare critical amounts and supplier associations with the original pages.

Before replacing the extraction configuration for a changed supplier layout, run representative old and new documents. Keep corrected examples under appropriate access controls so the team can test the same failures again. The downstream owner needs records suitable for a defined purpose and an affordable review path for what the extractor cannot establish.

06

Design the review handoff around the disputed field

Show the reviewer the candidate value beside the relevant source page or region. Include the failed rule and the receiving system's expected meaning. Asking someone to approve a large JSON object without its source makes the review harder and encourages checks based on appearance. A reviewer correcting an invoice total should be able to see which invoice the extractor associated with the record.

Keep the original extraction alongside the correction and record who accepted the revised value. Then rerun dependent checks: changing a currency can alter which amount rules apply. Review should produce a defined record state with a reason, rather than silently bypassing validation. If the source remains unreadable, retain an unresolved result and request a better input instead of forcing a value into a required field.

07

Version the meaning of the accepted record

An extraction contract needs a version even when its JSON shape stays the same. Suppose an invoice field named total changes from an amount before tax to the amount payable. The value may remain a valid number, and the object may still pass the same structural rules. Record the meaning expected by the receiver, including currency, units, rounding, and whether discounts are included. Keep that contract version with each accepted result. When the meaning changes, decide which earlier records need reprocessing and which must retain their original interpretation. Avoid quietly applying today's field definition to historical outputs that were accepted under another rule.

Build a small reviewed test set around disagreements the receiving workflow cares about. Include a clear invoice, a credit note, two invoices in one file, an unreadable amount, and a document with a total in another currency. Specify the expected record or unresolved state for each input before comparing extractor versions. Measure acceptance errors separately from extraction errors: an incorrect candidate routed to review has a different operational effect from the same candidate entering a payment workflow as accepted. Count rejected correct records as well, because excessive rejection can move the workload back to manual processing without improving the accepted results enough to justify it.

Keep evaluation inputs separate from the changing production queue so results can be reproduced. For each test run, capture the extraction configuration, schema version, business-rule version, and resulting disposition. Investigate a changed answer at the field level before deciding that a newer model is better overall. If a corrected rule affects accepted records, identify those records through their recorded versions and route them through an explicit revalidation process. Revalidation should not silently trigger another downstream action. The receiver needs to distinguish a corrected data record from a new invoice submission. Agree that behavior with the workflow owner before enabling automatic acceptance, and retain a route for records whose source still cannot establish the required meaning.

08

References

JSON Schema · Object reference including required and additional properties

09

Related

Where to read next on the same subject.