About a third of the agreements that reach us are scans. Execution versions signed in counterpart, faxed once in 2014 and scanned twice since. Compliance certificates photographed on a phone. Amendment letters with a wet-ink signature and a coffee ring. The model that reads the text does not care how the text got there, but the numbers it reads do, and a surprising share of our accuracy work has gone into the step before reading.
This is what moved the needle, in the order we would do it again. The measurements come from the 22 scanned agreements in our test set, scored on field accuracy: did the value that reached the register match the one a person read off the page. Raw OCR with one engine gave us 88 percent. The first pass now sits at 96.9 on scans, and the routed second read takes them to the same 99.7 as the rest of the set.
1. Find out whether you need OCR at all
Half the scans we receive already have a text layer. Some are fine. Some were produced by a broken font map, so every ligature is a box and every digit is shifted by one. Before recognising anything, extract the layer and score it by the share of tokens that hit a dictionary of English plus the agreement's own defined terms. Above 97 percent, use the layer. Below 90, treat the page as an image. In between, recognise and reconcile both.
2. Do layout before recognition
A credit agreement is not a page of prose. It has two-column schedules, footnoted thresholds, a running header repeating the section title, a stamp reading EXECUTION VERSION at forty-five degrees, and a fax banner carrying a date that is not the date of the agreement. Run layout detection first and label every region. Recognise body text, tables and footnotes separately. Drop stamps, banners and headers before they become part of a definition. This single change took us from 88 to 93 percent.
3. Prepare the image
Deskew, then dewarp if the scan came from a book cradle. Upsample to 300 dpi if the source is lower, because most engines were tuned there. Binarise adaptively rather than with a global threshold, so a shaded margin does not become a black bar. None of this is new. All of it gets skipped in a hurry.
4. Keep the word boxes and the confidence
Most pipelines throw away everything but the text. Keep the bounding box and the confidence for every word. The box is what lets a citation point at a place on a page rather than a string. The confidence is what lets you decide, later, which fields a person should look at. Without it, review is a coin toss. With it, scans went from 93 to 95.
5. Re-read the digits
General-purpose OCR is trained mostly on prose and treats digits as rare characters. A 3 becomes an 8, a comma becomes a full stop, and a threshold of 3.50x becomes 8.50x with high confidence. For every region layout tagged as numeric, run a second pass with a digits-and-punctuation model and compare. Disagreement is a signal in itself.
6. Reconcile against structure
Agreements are full of checks that cost nothing. Section numbers run in sequence. Totals in a schedule add up. A step-down decreases. A date in a compliance certificate falls inside the period it certifies. Every one of those that fails is a recognition error far more often than a drafting error. Digit re-reads and structural checks together took scans from 95 to 96.9 on the first pass.
7. Small caps are the enemy of defined terms
Many templates set defined terms in small capitals. Engines read them as full capitals, so Consolidated EBITDA becomes CONSOLIDATED EBITDA and no longer matches the definitions index. Normalise case when matching terms, and keep the original casing for the citation.
8. Route by field, not by page
Page-level confidence hides the problem. A page can be 99 percent confident on average and 60 percent on the one number that matters. Aggregate confidence to the field: the span that produced the value, whether the digits re-read agreed, whether reconciliation passed. On scans, 85 percent of fields go straight through and the lowest 15 percent go to a person. That second read is the whole distance from 96.9 to 99.7, and the review note works through how the budget is set.
9. Measure fields, not characters
Character error rate is the metric OCR vendors quote, and it barely moved between the second and fourth rows of our figure. Fields moved from 93 to 96.9. A single wrong digit in a threshold is one character and one hundred percent of the damage. Score what the register will hold.
OCR quality is not how many characters you got right. It is how many covenants you would have tested against the wrong number.
Everything above runs on every scan we receive, and none of it slows the path: a scanned certificate landing still has every affected test recomputed inside nine seconds. The residual errors are now mostly handwriting in amendment margins and tables where a ruled line dropped out and two columns merged. Both go to a person. Both are getting rarer.