The client had a pile of scanned paperwork: big files where invoices, shipping forms and other pages were all mixed up. The question was whether some truckloads had been paid for twice.
The system does three things. It picks out the invoices and shipping forms by comparing every page with a few examples of each. It reads the picked pages into rows of a table: invoice number, load number, amount and so on. Then it does the bookkeeping: for every refund, find the charge it cancels, and see whether that charge is still on the books. Every amount it read was compared with the client's own records before anyone relied on it.
Sorting and reading at once. I first asked one model to say what a page was and read it in the same step. It mixed the page types up badly. Splitting the work fixed it: one step sorts, the other reads, and the reader gets instructions written for that kind of page.
Pages that look alike. Order sheets and tickets share a layout with invoices, and the shipping forms were blurrier scans than the rest. One cut-off did not suit every page type, so each got its own, and two more rounds removed the near-misses.
Crooked scans. When a page was scanned at an angle, the end of the invoice number was often lost while the amount was still right. If the amount agreed with the client's records and the number nearly did, the number was corrected and the page marked for a person to check.
One load, several spellings. The same load number showed up with extra zeros in front, a letter at the end or an added digit, depending on which system printed it. Comparing only the digits matched most of them. The rest went on a short list for a person.
Trusting the invoice codes. Invoice numbers end in a code that is meant to say original, credit or correction. My first rule believed those codes, and the totals came out absurd. The codes were not used the same way every time, so I ignored them and matched each refund to a charge of the same size on the same load.