The alignment problem
An image of a word is a strip of pixels. The answer is a string of characters. Nothing says which columns of pixels belong to which character.
- : the number of frames, meaning columns of the feature map.
- : the number of characters in the label.
Labelling every column by hand would solve it and is exactly what nobody has. The training data is a picture and its transcription, with no alignment between them.
CTC, which sums over every alignment
- : one path, meaning one character or blank chosen at every frame.
- : the collapsing rule that turns a path into a string.
The network emits a distribution over the alphabet plus a blank symbol at every frame, and the probability of a transcription is the total probability of every path that collapses to it.
Collapsing removes repeats first and then blanks, so the blank is what allows a genuine double letter to survive.
The number of paths is exponential in , and the sum is still computed exactly by a forward-backward recursion in , which is the contribution of the method.
One line of text, in order
- Detect and crop the text region, then rectify it to a fixed height.
- Run a convolutional stack, producing a feature map one row tall and columns wide.
- Read those columns as a sequence through a recurrent or transformer layer.
- Project each frame to a distribution over the alphabet plus blank.
- Decode the frames into a string, and score the whole thing against the label with CTC during training.
Decoding, where a language model earns its place
Greedy decoding takes the most likely symbol at every frame and collapses the result. It is fast and it is not the most likely transcription, because many paths can share a string.
Beam search keeps several candidate strings and can add a language model score, which is what turns a plausible character sequence into a real word.
The length term is there because adding a log probability per character otherwise biases the search towards short outputs.
What actually breaks in production
Character error rate is the edit distance to the truth over the number of characters, and it is the metric to report because word accuracy hides near misses.
CTC assumes the output is monotonic in the input, which holds for a line of text and fails for anything with layout, so pages need detection and reading order before recognition ever runs.
Curved, rotated or low-contrast text fails at the rectification step rather than the recognition step, and that is where most of the remaining error lives.
Attention-based decoders remove the monotonic assumption and handle curved text better.
They pay for it by being able to hallucinate a plausible word that is not in the image, which CTC structurally cannot do.