Document PipelineField engagement

A document pipeline is won or lost on the scans it actually receives, and the clean pages a benchmark ships with say little about them.

Fractional CTO and lead engineer.
96.8%
accuracy
50,000+
documents a month
~50
parts, not 11,000 blocks
한›
ㅎinitial
ㅏmedial
ㄴfinal
ONE LINE, FOUR SCRIPTS
한국어Hangul
漢字Hanja
A1Latin
2024digits
Hangul is composed, not enumerated, and one line can mix four scripts. Decode the parts and route the scripts apart.
What was at stake

Everything downstream of a text recogniser inherits its mistakes. A missed character is a search that finds nothing. A wrong digit is a wrong figure in a database. A wrong field is a wrong decision made by someone who never saw the page. No model further down the line can recover a character the recogniser failed to read, so the recogniser's accuracy is the ceiling for everything built on top of it.

How this works

Korean writes its letters into syllable blocks, so a recogniser can learn the letters or memorise the blocks.

Optical character recognition runs in stages. The image is cleaned up: straightened, flattened, de-speckled and converted to sharp black and white. The page is then divided into regions such as paragraphs, columns, tables and stamps, and a reading order is worked out across them. Only then does recognition begin, cutting each line into pieces and mapping each piece to an output from a fixed set, often called the label space. A recogniser learns by seeing many examples of every item in that set, so the size of the set largely decides how much labelled data it needs.

Korean is written in Hangul, an alphabet whose letters are not written in a row. They are stacked into square syllable blocks. Each block begins with a consonant, includes a vowel, and may end with a further consonant, and the shape of the vowel decides whether the parts sit side by side or one above the other. The rules are regular, which is why roughly fifty letter forms can produce on the order of eleven thousand distinct blocks. A reader of Korean sees the block. Underneath, it is a small composition.

That gives a recogniser two options. It can treat every block as its own item, which makes the label space enormous and leaves rare blocks with few examples, so the model struggles exactly on the blocks it sees least. Or it can recognise the parts and assemble the block from them, which keeps the label space small and lets a rare block benefit from training on common blocks that share its parts. Real documents add one more layer. A single line can mix Korean with Latin letters, digits and sometimes Chinese characters, and some shapes look alike across scripts. A circle can be a Korean consonant, a Latin letter or a zero. Knowing which script a run of text belongs to is part of reading it correctly.

A line of textmay mix Korean, Latin letters and digits
Runs of one scriptrouted apart before recognition
Syllable blockson the order of eleven thousand possible
Letters inside each blockroughly fifty parts to learn
The page shows blocks. The script is built from letters.
FigureWhat a recogniser is actually looking at on a Korean page. The visible unit is the syllable block, but each block is assembled from a small set of letters by regular rules. Recognising at the level of the letters is what keeps the problem small enough to train.
The constraint

Korean is written in syllable blocks, and each block is assembled from smaller letters. The unit on the page is a composition, and one line can mix Korean with other scripts. That makes the choice of modelling unit decisive. Compose from roughly fifty parts, or enumerate on the order of eleven thousand whole blocks, and the decision sets whether the labelled data requirement is manageable or a fortune. Most failures are also settled before recognition runs, in preprocessing, on real scans that arrive skewed, warped, low in resolution and degraded.

Syllable blocks, learned directly~11,172
Jamo parts, composed~51
Model the fifty parts, not the eleven thousand wholes. The same decision separates a recognizer that needs a fortune in labels from one that does not.
Where it usually breaks

Most OCR errors are decided before the recogniser sees a single character.

Recognition gets the attention, and preprocessing decides the outcome. A page scanned at a slight angle, photocopied twice and stamped across the text presents the recogniser with shapes it was never trained on. If the page is not straightened, cleaned and brought to a usable resolution first, no recogniser will read it reliably. The same is true of layout. A table read row by row across its columns produces correct characters in a meaningless order.

The second pattern is the clean benchmark. Engines are usually evaluated on typed, high-resolution, single-script samples. An archive of real documents looks nothing like that. A system tuned to the benchmark reports high accuracy and then fails on the pages that matter, and because the failures are spread across thousands of documents, nobody notices until a downstream search or report goes wrong.

01

The skewed, degraded page

A slight tilt, a warp near the binding or fax noise turns legible characters into unfamiliar shapes before recognition even starts.

02

The shuffled table

Characters are read correctly and in the wrong order. Columns merge, rows split, and the structure that gave the numbers meaning is gone.

03

The borrowed shape

A character from one script is read as a lookalike from another. A Korean letter becomes a Latin one or a digit, and the word around it breaks.

04

The rare block

A model that memorised whole blocks has seen some of them only a handful of times. Those are the blocks it gets wrong, and they are often names and technical terms.

05

The benchmark that was too clean

Accuracy measured on pristine samples says nothing about the archive. The real error rate stays unknown until it shows up downstream.

The benchmark page
Straight, flat, high resolution
preprocessing barely needed
One script throughout
no lookalike confusion
Plain paragraphs
reading order is obvious
The page actually received
Skewed, warped, low resolution
bleed, stamps, fax noise
Korean, Latin and digits on one line
shapes that look alike across scripts
Tables and columns
order and structure must be recovered
Accuracy on the left column predicts very little about the right.
FigureThe page a benchmark tests and the page this pipeline actually receives. An engine that does well on the left meets skew, low resolution, stamps and mixed scripts on the right. Every difference between the two columns is a place where accuracy is lost before recognition starts.
The fork

The reflex, and the fix.

Road not taken

Tune an off-the-shelf, English-centric engine

Pull

Running in an afternoon, and fine on clean typed samples.

Why not

It has no model of a composed script, no handling for mixed-script lines, and nothing for real scan damage. It fails exactly where the documents live.

Road taken

Build for the script and the scans as they are

Accepted

Composition-aware recognition, routing by script, an evaluation set built from real documents, and a strategy for synthetic data.

Bought

Accuracy on the documents actually received, at production volume.

Decision

Model the structure of the script and meet each scan where it is, because both are decided before recognition runs.

How it was built
01Preprocess
›
02Layout
›
03Recognize
›
04Post-process
›
05Evaluate
01

Meet the scan where it is

Deskew, dewarp, denoise, normalise resolution and binarise until the page is clean, level and legible. Most OCR failures are decided at this stage, before recognition runs at all.

02

Structure before text

Layout analysis recovers regions, reading order across columns, and table structure. A correct stream of characters in the wrong order is still a wrong document.

03

The modelling unit

Decoding the script as composed parts keeps the set of outputs small and the model efficient with data, where enumerating thousands of whole blocks would not. Scripts are routed apart, so a character from one is never mistaken for a block from another, which is the most common mixed-script error.

04

Manufacturing the data the archive cannot supply

Labelled scans in this script are scarce. So training pairs are generated from real text set in many fonts, then degraded to look like the actual archive: low resolution, ink bleed, stamps, fax noise. The closer the synthetic damage matches the real damage, the more of the accuracy carries over.

Inside the key decisions

What each choice cost, and what it bought.

ARecognising letters and assembling blocks

Treating each syllable block as a single class is the simpler model to build, and every off-the-shelf approach leans that way. It means on the order of eleven thousand classes, each needing its own examples, and the rare ones never getting enough. Recognising the roughly fifty parts and composing them into blocks takes more careful decoding, because the parts have to be assembled according to the script's rules. In return the label space is small, the data requirement is manageable, and a rare block is read as reliably as a common one because its parts are familiar.

BSpending the effort on preprocessing and layout

It is tempting to put every hour into the recogniser, because that is where the modelling is. Most of the errors on real scans were decided earlier, in skew, warp, noise and resolution, and in reading order across columns and tables. Investing there first was less visible work. It raised the ceiling for everything after it, because the recogniser finally received pages that looked like what it was trained on.

CSynthesising data damaged to match the archive

Labelled scans of real documents in this script are scarce and costly to produce. Generating training pairs from real text in many fonts is cheap, but clean synthetic text teaches a model to read clean text. The useful step was degrading it deliberately to resemble the archive, with low resolution, bleed, stamps and fax noise. Matching the damage takes iteration against real pages. It is what makes accuracy learned on synthetic data carry over to documents nobody labelled.

DMeasuring per script and per quality, with a confidence on every field

A single accuracy figure averages away the places where a pipeline fails. Breaking error rates down by script and by document quality showed exactly where the problems were. Attaching a confidence to every field meant uncertain output could be sent to a person, so the pipeline could run at volume without asking anyone to trust every field equally.

~50
letter parts to learn, composed into blocks
11,000
whole syllable blocks to learn, one by one
each block needs its own examplesrare blocks starvenames and terms suffer most
Same script, same pages. A very different amount of labelled data.
FigureThe modelling unit decision in two numbers. A recogniser that composes syllables learns roughly fifty parts. One that enumerates whole blocks has to learn around eleven thousand, each needing its own labelled examples. The difference decides whether the data requirement is manageable.
How it was measured

A single headline number hides where a system fails. This work was scored on the dimensions that actually decide whether it holds in production, measured on real, held-out cases rather than the demo path.

Character error rate per scriptCharacter error rate per document qualityReview rateThroughput at production volume
The gate
Is the recogniser confident in this field?
Flows downstream
no reviewer time spent on it
Flagged for a reviewer
handwriting, damage, unfamiliar layouts
96.8% accuracy at 50,000+ documents a month, with a reviewer checking only the fields that need it.
FigureWhat happens to each recognised field at production volume. The pipeline reaches 96.8% accuracy across 50,000+ documents a month, and the remaining doubt is not hidden. Each field carries a confidence, and the uncertain ones go to a person.
figures

What it produces
Without this discipline

Blocks dropped or split into the wrong syllables, scripts mistaken for one another, tables flattened into a shuffled list, and one opaque output with no indication of what to trust.

This system

96.8% accuracy at 50,000+ documents a month, with composed syllables correct, scripts kept apart, tables preserved, reading order intact, and a confidence on every field so a reviewer checks only what needs it.

composition-awaremixed-script routingsynthetic degradationper-script evaluation
The operating envelope

What it owns, and what it hands to a person.

Handled with confidence
Printed text across the supported scripts
Tables and columns
Skew, noise, low DPI, common scan degradation
Flagged for review
Low-confidence fields
Ambiguous mixed runs
Out of scope by design
Free handwriting
Severe damage
Wholly novel layouts
The honest limit

It is strong on printed text across scripts and levels of degradation. Handwriting, severe damage and wholly new layouts remain hard. That is exactly why low-confidence output is flagged for a person and never asserted.

What it generalizes to

A document pipeline succeeds or fails on the documents that actually arrive. Model the structure of the script, route what differs, manufacture the data that reality withholds, and measure where the system fails in production, which is often far from where the benchmark says it fails.

What to take from this

A text recogniser sets the accuracy ceiling for everything built on its output, because no later step can recover a character it failed to read.

For a script that composes characters from parts, recognising the parts keeps the label space small and the data requirement manageable.

Most OCR errors on real documents are decided in preprocessing and layout, before recognition runs, so that is where effort pays first.

Synthetic training data transfers to real documents only when it is damaged in the same ways as the real archive.

Measure error by script and by document quality, and attach a confidence to every field, so review effort goes only where it is needed.

How we engage

You have a system like this one.
Tell us where it stands.

Whether it is failing, not yet built, or about to meet a scale it has never seen, we can tell you what we see.

Start a conversation
mostafa@opulion.dev · Response within 24 hours · By inquiry