Text Locked Inside a Picture
A scanned invoice looks like a document to a person and like a grid of pixels to a computer. Nothing in the file says that a certain cluster of dark dots is the letter «R», that a row of them forms the word «Total», or that the number to its right is the amount someone has to pay. Optical character recognition (OCR) is the task of turning that image back into text. Document AI is the broader task of working out what the text means: which number is the date, which is the tax, which block is a table and which is a footnote.
The two problems used to be handled by separate tools. OCR produced a stream of characters, and some other program, often a pile of hand-written rules, tried to pull fields out of it.
Reading Checks With Convolutions
One of the first large commercial uses of neural networks was reading handwriting. In 1998 Yann LeCun, Léon Bottou, Yoshua Bengio and Patrick Haffner published «Gradient-Based Learning Applied to Document Recognition» in the Proceedings of the IEEE. The paper described LeNet-5, a convolutional network for recognizing handwritten digits.
The paper also described a full system for reading the amounts written on bank checks. It combined convolutional character recognizers with what the authors called graph transformer networks, which searched over the possible ways of cutting a written amount into characters and picked the most consistent reading. According to the abstract, the system was deployed commercially and read several million checks per day.
That detail is easy to skip, but it says something about where deep learning came from. Long before image classification contests, convolutional networks were earning money by reading digits that bank clerks would otherwise have typed by hand.
Tesseract and the Classic Pipeline
Printed text was handled by a different line of engines. Tesseract, probably the best known, was developed at Hewlett-Packard between 1984 and 1994. It was entered in the 1995 UNLV Annual Test of OCR Accuracy as an HP research prototype, then sat unused until HP released it as open source in late 2005. Ray Smith, its original developer, described its design in a 2007 paper at the International Conference on Document Analysis and Recognition (ICDAR).
The classic Tesseract pipeline shows what OCR looked like before deep learning took over. First the page is binarized into black and white. Then the engine finds connected blobs of ink, groups them into text lines (including lines that are slightly curved or skewed), splits lines into words and words into candidate characters. Each candidate is matched against learned character shapes, and a dictionary helps choose between close alternatives.
Every stage in this chain can fail on its own. A coffee stain merges two letters into one blob. A tight font makes «rn» look like «m». An error early in segmentation cannot be repaired later, because the classifier only ever sees the pieces it was given.
Lines Instead of Characters
The fix was to stop cutting text into characters at all. In 2015 Baoguang Shi, Xiang Bai and Cong Yao proposed the CRNN, published in IEEE Transactions on Pattern Analysis and Machine Intelligence in 2017. A convolutional network reads an image of a whole word or line and produces a sequence of feature columns from left to right. A bidirectional LSTM reads those columns, and a Connectionist Temporal Classification (CTC) layer turns the output into text.
CTC was built for speech, where nobody marks which audio frame belongs to which sound. A text line has the same problem in space. CTC lets the network learn from an image and its transcript alone, adding a special blank symbol and summing over every alignment that collapses to the correct string. The authors pointed out that the model could be trained on word-level labels, with no annotation of where individual characters were. Tesseract moved in this direction too: version 4, released in 2018, added an LSTM based line recognizer.
Transformers came next. TrOCR (Minghao Li and colleagues at Microsoft, AAAI 2023) used a pre-trained image transformer as the encoder and a pre-trained text transformer as the decoder, generating wordpieces one at a time. It dropped both the convolutional backbone and the external language model, and the paper reported state-of-the-art results on printed, handwritten and scene text.
Case: Two Words per CAPTCHA
By the mid 2000s, large book digitization projects were running into a hard limit. OCR handled clean modern print well, but old, faded or damaged pages produced words no engine could read with confidence. Luis von Ahn and colleagues at Carnegie Mellon turned this into a security system. Their paper «reCAPTCHA: Human-Based Character Recognition via Web Security Measures» appeared in Science in 2008.
The idea was to show each user two words. One was a control word whose answer was known. The other was a word that OCR programs had failed to read. If the user typed the control word correctly, their answer for the unknown word counted as a vote, and a reading was accepted once it collected enough votes (the paper used a threshold of 2.5 votes). The authors reported word accuracy above 99 percent, matching the standard of professional transcribers who type each text twice and compare. At the time the system ran on more than 40,000 websites and had transcribed over 440 million words.
The case is a reminder that for most of OCR’s history the hard examples were solved by people. The machine did the easy pages and passed the rest to someone else.
Layout Is Part of the Meaning
Reading text correctly is only half the job. Consider a receipt. The string «12.50» could be the price of one item, the subtotal, the tax or the total, and the only clue is where it sits on the page and what is written next to it. A language model that sees the OCR output as one flat sequence loses that information.
LayoutLM (Yiheng Xu and colleagues at Microsoft Research Asia, KDD 2020) addressed this directly. It took the BERT architecture and added two-dimensional position embeddings: alongside each word, the model receives the coordinates of the word’s bounding box on the page. It was pre-trained on about 11 million scanned documents from the IIT-CDIP collection using a masked language modeling task, so the model learned that words in certain positions tend to go with certain other words.
The gains were large on tasks where layout matters. On FUNSD, a form understanding benchmark, LayoutLM reached an F1 score of 0.79, against 0.71 for RoBERTa-Large, which sees only the text. On the SROIE receipt extraction task it reached 96.0 percent.
Skipping the OCR Step
LayoutLM still depends on an OCR engine to supply the words and their boxes, and whatever that engine gets wrong reaches the model as fact. Donut (Geewook Kim and colleagues at NAVER CLOVA, ECCV 2022) removed the dependency. It is a transformer that reads the raw document image and writes its output directly, often as structured text such as a list of fields and values. The authors listed three reasons for dropping OCR: its computational cost, its poor flexibility across languages and document types, and the way its errors propagate into everything downstream.
Training such a model needs a huge amount of document images with known text, so the team also released SynthDoG, a generator of synthetic documents in several languages. Pre-training taught Donut to read; fine-tuning taught it particular tasks such as receipt parsing, document classification or answering questions about a page.
Question answering is now one of the main ways these systems are evaluated. DocVQA, introduced by Minesh Mathew, Dimosthenis Karatzas and C. V. Jawahar at WACV 2021, asks questions about real document images, and answering many of them requires reading a table or connecting a label to a value printed elsewhere on the page. Large multimodal language models have since been trained on the same kind of data, and many document pipelines now send the page image straight to one of them.
Case: A Scanner That Rewrote the Numbers
In 2013 the German computer scientist David Kriesel noticed that numbers in documents scanned on Xerox WorkCentre machines did not always match the originals. A 6 could become an 8. This happened only when scanning, not when copying, and the altered pages looked completely normal.
The cause was not OCR but the JBIG2 compression standard. In one of its modes, JBIG2 finds patches of the image that look alike and stores a single copy, reusing it everywhere it appears. On small, low resolution print, a 6 and an 8 were similar enough to be treated as the same patch. Xerox confirmed that JBIG2 was responsible and released a patch that disabled the pattern matching option.
The scanner did exactly what document models are now asked to do: it decided which marks on a page were the same symbol. It just did it without saying so.
Reflection
Old OCR failed loudly. When Tesseract misread a smudged line, the output was a string of broken characters like «T0taI: $1Z.5O», and any person who looked at it knew to check the paper. The Xerox case shows the other kind of failure, where the system replaces one clean symbol with another clean symbol and nothing looks wrong. Models that go straight from image to fluent, structured output tend to fail in that second way, because they produce text that looks finished even when the image was unclear. As these systems take over invoices, contracts and medical forms, the useful question is less how often they are right and more whether a person can tell when they are wrong. A confidence score per field, or a link back to the exact region of the page each value came from, can be worth more than another point of benchmark accuracy.
By: Max Johnson B.
Deja una respuesta