OCR
Optical Character Recognition and Multimodal Transcription
From a picture of a page to text we can search, count and cite, and how to tell whether we can trust it.
DHG 502 Digital Approaches in Historical Research  ·  Week 6  ·  ← → navigate  ·  1–6 sections  ·  G go to slide  ·  F fullscreen

Today’s route

1
What is OCR?
and why historians care
→
2
Preparing images
before the model sees them
→
3
Measuring errors
CER, WER and friends
4
Three papers
Old Russian, Manchu, handwriting
→
5
Vision–language models
how the pipeline works
This week’s readings

What is OCR?

Optical Character Recognition: turning an image of text into machine-readable text.
For handwriting the task is usually called HTR, Handwritten Text Recognition.
Input: pixels
Preface page of the Hongloumeng, a woodblock-style print
346 × 578 pixels ≈ 200,000 numbers. The computer sees no characters at all.
→
Output: characters (Unicode)
紅樓夢小說本名石頭記作
者相傳不一究未知出自何人
First two columns of the page, transcribed.
  • text you can search, copy, count and quote
  • plus, depending on the tool, layout, line breaks, confidence scores
  • the transcript is only as good as the recognition: OCR output is a model’s reading, not the source

Why should historians care?

Search

Find every mention of a person, place or term across thousands of pages instead of reading them one by one.

Compute

Collocations, networks, topic models, stylometry: all of them start from text, not from images.

Scale and cost

Manual transcription is the slowest and costliest step of digitization.

Way of getting a transcriptCost or speed
Professional transcription serviceUS$ 6–12 per page; one day to two weeks
Student research assistantabout 5–7 pages per day
Transkribus (HTR software)about US$ 0.27 per page; about 40 s per page
Multimodal LLM (Humphries et al. 2024)cents per page; 50 pages in about 30 s
Figures from Humphries et al., “Unlocking the Archives” (2024), 2024 prices; they will have changed.
A scan is a picture; a transcript is data. OCR is the first step of the source-to-data workflow, and every later result inherits its errors.

A short history of machine reading

1960sTemplate matching

Compare each character with stored shapes. Needs clean input and known fonts.

Late 1990s–2000sMachine learning

Pattern classifiers; ABBYY FineReader and open-source Tesseract become standard.

2010sDeep networks

CNN + LSTM models; Transkribus brings HTR to historians. One model per script or hand.

Late 2010s–Transformers

Attention-based recognizers such as TrOCR, usually fine-tuned on your own pages.

2023–Multimodal LLMs

General models that read an image and follow a prompt: GPT-4, Gemini, Claude, Qwen-VL, Llama Vision.

The big shift

Before: a specialist per collection

  • one model for one script, hand or collection
  • needs transcribed pages to train (about 75 pages for a new hand, Humphries et al.)
  • poor out of the box on new material
→

Now: a generalist, used with a prompt

  • one model for many scripts and tasks
  • used out of the box: image plus instruction in, text out
  • strong, but it brings a language prior (see the case studies)
What changes for the historian: less training data and tooling, more responsibility for checking the output.

The classic OCR / HTR workflow

1 Imagescan, photo, microfilm
→
2 Preprocessingdeskew, light, binarize, crop, resize
→
3 Layout analysisregions, columns, text lines, reading order
→
4 Recognitionline image → characters
→
5 Correctionautomatic and human
→
6 Textplain text, PAGE XML, TEI…

Example: building ground truth for 18th-century Russian books

  • layout regions: a fine-tuned YOLOv8 detector
  • text lines: a pre-trained Riksarkivet model
  • first transcription: TrOCR fine-tuned on 495 pages
  • 100% manual correction in the eScriptorium interface
Levchenko 2025

Where do multimodal LLMs fit?

  • They can do steps 3–5 in one call: page in, text out.
  • But steps 1–2 are still yours, and so is step 5: checking.
  • Layout, line count and image quality still decide how well they do (next sections).

Garbage in, garbage out

Simulated phone photo of a book page: tilted, unevenly lit, noisy
Simulated “phone photo”: a library scan of the Hongloumeng preface, tilted 4°, unevenly lit, with noise added.
Archival images are rarely clean. Humphries et al. built a test set the way historians actually work:
  • 13 pages from black-and-white microfilm
  • 11 photographed with a phone or handheld camera
  • 8 shot in a dark room with poor contrast, 6 somewhat blurry
What typically goes wrong:
tiltuneven light, shadowslow contrastnoise, blurbleed-throughstamps and marginsJPEG artifactslow resolution
The Manchu OCR paper names the same culprits: “severe tilt, low-resolution or heavily compressed scans, uneven illumination, and strong background noise can all degrade recognition accuracy.”

A preprocessing recipe, step by step

  1. 1
    DeskewStraighten the page. Even 2–3° of tilt hurts line detection.
  2. 2
    Even out the lightEstimate the background and divide it out; stretch the contrast.
  3. 3
    BinarizeLight denoising, then every pixel becomes black or white.
  4. 4
    CropKeep the text block; drop table, fingers, stamps and margins.
  5. 5
    Resize and saveEnough pixels per character; lossless format.
Tools: OpenCV or scikit-image (Python), ImageMagick, ScanTailor, or the built-in cleanup of Transkribus and eScriptorium.
All of it is a few lines of code; an AI coding assistant can write the script for your collection.

Binarization: black or white, but where is the line?

Starting point
Deskewed photo, uneven light
One global threshold
Otsu on the raw photo: the dark right side turns into a black smear
Adaptive (local) threshold
A threshold per neighborhood: better, but speckled and thin
Flatten light, then Otsu
Clean strokes, readable stamps and frame
Global: one cut-off for the page. Otsu’s method picks it automatically by separating the pixel histogram into two classes. Adaptive: the cut-off is computed locally.
Binarization throws information away: faint strokes, red seals, bleed-through. Many modern models do better on the grayscale or colour original. Test both on a sample.

In practice: what the Manchu paper did to its images

Synthetic training word: original (top) → preprocessed (bottom)
Original and preprocessed synthetic Manchu word images
Chung & Choi 2026, Fig. 2. White-on-black with noise → inverted to black-on-white, denoised, contrast-enhanced, resized.
Scanned archive word
→
After processing
Figs. 3–4: a word cut out of the Old Manchu Archives by an OpenCV pipeline (binarization, denoising, segmentation), then inverted, contrast-enhanced and resized.
  • The real scans were normalized to look like the synthetic training images: same polarity, same size, same contrast.
  • Black-on-white, fixed dimensions, denoised: the model assumes such input.
The authors say it plainly: performance “is noticeably sensitive to deviations from these conditions,” and their model works on single words, so layout and line segmentation errors upstream would propagate.
Principle: the closer your image is to what the model has seen, the better it reads. Preprocessing is how you close the gap.

Resolution: pixels per character

≈ 300 ppi
≈ 100 ppi
≈ 50 ppi
≈ 25 ppi
Same 18th-century line as in Levchenko 2025 (Fig. 4), downsampled and enlarged again.
  • 300 ppi is the usual scanning standard for print.
  • Levchenko excluded all images below 150 ppi, citing evidence that LLM OCR degrades at low resolution.
  • dpi is only a label. Humphries’ images were tagged 96 dpi, yet were 1,200–1,750 px wide. What the model sees is pixels, and what matters is pixels per character.
  • Rule of thumb (ours, not from the papers): aim for characters at least ~20–30 px tall; small print and dense Chinese pages need more.
Photograph from close, with the page filling the frame. Higher resolution never hurts; you can always downscale later, but never recover detail.

Size, format, and how much to send at once

Size limits

Models cap the image they accept. Llama 3.2 Vision handles up to 1120 × 1120 px (Manchu paper); bigger pages are downscaled, and small type disappears. Crop or tile large pages instead.

Format

Archive in lossless TIFF/PNG. Heavy JPEG compression leaves artifacts that read as strokes or diacritics, and the Manchu paper lists “heavily compressed scans” among the failure causes.

Unit of input

One line, a sliding window of a few lines, or the full page? More context helps, but dense pages raise errors and hallucinations.

Levchenko 2025: CER (%) by input unit, 18th-century Russian (CER = character error rate, defined in the next section)
ModelFull pageSingle lineSliding window
Gemini-2.5-Pro3.369.357.83
Qwen-2.5-VL5.817.708.87
Claude-3.77.325.637.35
GPT-4o9.2323.7511.93
Full page wins for most models, but not for all: there is no universal best setting, so run a small test on your own material. For weaker models, line count and layout complexity were the strongest predictors of error (r up to 0.55 and 0.39).

Do multimodal LLMs still need preprocessing?

Sometimes not

Humphries et al. sent phone photos and microfilm scans as they were, no preprocessing and no fine-tuning, and got CER 5.7–7% on handwriting from 33 different hands.

Often yes

The fine-tuned Manchu models and classic engines (Tesseract, CRNN, Transkribus models) assume normalized input, and fall apart on skewed, noisy or low-resolution scans.

A sensible default checklist
Decide with data, not habit: transcribe 10–20 pages by hand once, then compare pipelines (raw vs. cleaned) by their error rates. That is the next section.

How do we measure an OCR error?

Compare the OCR output (hypothesis) with a human-made ground truth (reference) and count the edits needed to turn one into the other.

Substitution

a wrong symbol
history → hystory

Insertion

a symbol that is not in the source
history → hisstory

Deletion

a symbol that is missing
history → histry

The minimum number of such edits is the Levenshtein (edit) distance. Count it on characters and divide: CER. Count it on words and divide: WER.
The reference itself matters: Levchenko’s ground truth was checked by a second annotator (character-level agreement 99.93%); human transcribers are not error-free either.

Character error rate (CER)

Referencedigital hi–story
OCR outputdlgital hisstory
1 substitution   i → l     1 insertion   an extra “s”
CER = S + D + IN N = number of characters in the reference
CER = 1 + 0 + 115 = 13.3%

Word error rate (WER)

Reference
theoldmanuscriptwasdamaged
OCR output
thecoldmanuscriptwasdamaged
1 substitution   old → cold    1 deletion   “was” missing
WER = 1 + 1 + 05 words = 40%

The same pair, by characters

insert “c” (1) + delete “was ” (4) = 5 edits / 30 characters → CER 16.7%, WER 40%.

Why WER is bigger

One wrong letter spoils the whole word. In HTR, WER is usually about 3–4× the CER (Humphries et al.).
Which one? WER reflects what a reader or a search engine experiences; CER shows how the model fails and works for languages without word spaces.

What counts as an error? Strict vs. modified

Strict: any difference in capitalization, punctuation or spelling is an error.
Modified: ignore case and punctuation, and do not count a spelling that was “corrected” (employ’d → employed).
English handwriting, 50 pagesCER strictCER mod.WER strictWER mod.
Transkribus PyLaia10.37.627.017.4
Transkribus Titan8.06.619.713.2
Claude Sonnet 3.57.35.715.98.9
Gemini 1.5 Pro8.56.718.811.0
GPT-4o11.09.023.014.1
Humphries et al. 2024, Tables 1–4 (%).
A third or more of the word-level errors were only about capitalization, punctuation or old spelling.
Decide in advance what counts. Searching a corpus? Modified is fine. Editing a text or studying orthography? Strict, and consider an orthography-specific metric (next slide).

Beyond CER and WER

MetricWhat it tells youUsed in
Word accuracy (exact match)share of words (or word images) perfectly rightManchu
Character F1precision and recall of matched characters; e.g. 3 of 5 characters found, none wrong: P = 1, R = 0.6, F1 = 0.75Manchu
Line exact-match rateshare of lines with no error at allRussian
Case-insensitive CERisolates recognition from capitalization errorsRussian
HCPRHistorical Character Preservation Rate: how many period-specific letters (і/ї, ѣ, ъ) survive (we use it in Case 1)Russian
AIRArchaic Insertion Rate: how often obsolete letters are insertedRussian
HCPR and AIR are tailored to the historian’s question: they measure the very thing a generic CER cannot see. Define the errors that matter for your source.

How good is “good enough”?

Word error rate (%) of different transcribers. Lower is better.
Professional service (guaranteed)
1
LLM, then LLM correction (best case)
3.5
Humans, speech / clinical notes
4–10
LLM out of the box, Claude 3.5
8.9 modified / 15.9 strict
Transkribus on hands it has not seen
15–50
Non-expert humans, early modern Italian
35–43
Humphries et al. 2024 (cited studies; English handwriting 1761–1827, except the last bar). Bars drawn on a 0–50% axis.

Case 1: 18th-century Russian print

Levchenko, “Evaluating LLMs for Historical Document OCR” (RANLP workshop, 2025)
Excerpt of an 18th-century Russian book in Civil font
Levchenko 2025, Fig. 4: Civil font, 1750–1800. Note the variable “ш”, sometimes close to “т”.

The data

1,029 pages from 428 books, never published online: a test the models cannot have memorized.

The task

Diplomatic transcription: keep the period spelling, hyphens, line breaks and even printers’ errors.

The contest

12 models (GPT, Claude, Gemini, Qwen, Llama) against Tesseract, Surya and Transkribus.

Result 1: general LLMs beat classic OCR, with no training

Tesseract 4.0
21.6
Transkribus PyLaia
26.9
Surya (multilingual)
46.0
Gemini-2.5-Pro
3.4
Gemini-2.5-Flash
4.9
Qwen-2.5-VL
5.8
Claude-3.5
6.8
GPT-4o
9.2
Llama-4-Scout
15.9
TrOCR, fine-tuned on this corpus
1.8
Character error rate (%), lower is better. Classic engines: 100-page sample. LLMs: full corpus, full-page mode. Levchenko 2025, Tables 1 and 3.

Result 2: “over-historicization”

Expected error: the model modernizes old spellings. Observed: models also insert archaic letters that were not in the book, letters Peter the Great’s reforms had already removed from the Civil font.
ѧforяlittle yus; reflexive endings, after palatalized consonants
ѡin…omega; prepositions and prefixes
ꙋforуmonograph uk; specific word positions
ѿforот“ot” ligature
59%
of files in which GPT-4o inserted archaic characters
Model familyTypical archaic insertions
GPT-4o, GPT-4.1ѡ ѧ ꙋ ѿ ꙗ
o4-mini, Gemini-2.5-Flashѧ ѭ ѥ
Claude-3.7, Qwen-2.5minimal
The text looks more “authentic” than the source, and a researcher who trusts it would conclude that this printing still used pre-Petrine letters. A character-level score cannot tell.
Levchenko 2025, §5 and Table 5. Other models listed in the paper are omitted.

A good CER can hide a bad error where it matters

CER, all characters  vs.  error on period-specific characters
Gemini-2.5-Pro
3.4
9.8
Gemini-2.5-Flash
4.9
12.9
Claude-3.5
6.8
15.2
GPT-4o
9.2
20.7
Llama-4-Scout
15.9
42.2
Full-page mode, Levchenko 2025, Table 3 (%).
Every model does worse on the characters that make the text period-specific than on characters in general: for the best model about three times worse. For a historian these are the characters that matter most.

Why would a model do that?

  • No period tags. Training data mixes Church Slavonic, pre-reform, 18th-century and post-1918 Russian, and the model does not know which one you mean.
  • “Old-looking” cues become a generic signal. Yus letters, omega and diacritics say historical text, so the model adds them.
  • Visual noise. Faded ink, bleed-through or worn type look like diacritics; models “err on the side of complexity.”
  • Family signatures. OpenAI, Anthropic and Google models show different error profiles, probably from different training data.
Levchenko’s interpretation; the paper does not have access to training data.

Everyday errors, all models

TruthOutputWhy
їіthe most common substitution
ъьhard vs. soft sign
штvariable 18th-c. glyph shapes
Not all errors are equal. A random typo is noise; an insertion that always points the same way is bias, and bias survives in your counts, collocations and arguments.

Result 3: should an LLM correct the OCR?

Idea: run OCR first, then give an LLM the image and the draft text and ask for a corrected transcript.

Levchenko (Russian print, 18th c.)

  • Image + OCR text: no better than direct OCR for the stronger models; they “re-perform OCR.”
  • Text only: consistently worse.
advice: pick the best OCR model, skip correction

Humphries et al. (English handwriting, 1761–1827)

  • Claude correcting Gemini’s draft: modified CER 4.1%, WER 7.0% (reductions of 63% and 38%).
  • Correcting Transkribus output: modified WER down to 3.5%.
advice: transcribe, then correct
Same idea, opposite verdicts. For a historian the stakes are specific: does correction restore the source, or normalize it toward what the model finds likely?

Why might the results differ?

Reasons 1–2 are Humphries’ own explanation; 3–4 are our interpretation, not tested in either paper.
For discussion: for your own source, would you accept a correction that improves modified WER but changes the spelling? Which of the two papers is closer to your material?

Case 2: Manchu word images

Chung & Choi, Computational Humanities Research 2 (2026)
The Manchu words manju gisun, written vertically
manju gisun, “Manchu language.” Written vertically; letters change shape by position.
  • Problem: Manchu (endangered, essential for Qing history) has no practical OCR for real archival documents.
  • Training data: 60,000 synthetic word images rendered from a 130,917-word dictionary in several typefaces.
  • Models: three open VLMs (Llama-3.2-11B-Vision, Qwen2.5-VL-7B, -3B), fine-tuned with LoRA (a light-weight method).
  • Test: 753 word images from real scans of seven Qing sources, five handwritten and two printed.
You are an expert OCR system for Manchu script. Extract the text from the provided image with perfect accuracy. Format your answer exactly as follows: first line with ‘Manchu:’ followed by the Manchu script, then a new line with ‘Roman:’ followed by the romanized transliteration.
The prompt used in the paper (Chung & Choi 2026).

Result: a great score on synthetic data is not a great score on your sources

synthetic test  vs.  real archival words   word accuracy, %
Llama-3.2-11B-Vision
fine-tuned VLM
98.6
87.4
CRNN
classic CNN + LSTM
99.9
56.8
Qwen2.5-VL-7B
86.3
33.7
Qwen2.5-VL-3B
83.5
27.8

What still goes wrong in Manchu

  • Position-dependent letters. A Manchu letter changes form as initial, medial or final, and some vowels are “visually indistinguishable in isolation.”
  • Systematic confusion. On real words the three vowels a, i, e account for 47.5% of all Llama’s character errors (a alone 22.2%).
  • The same language knowledge cuts both ways. The authors credit VLMs for “linguistic knowledge to maintain coherence even when characters are visually ambiguous,” the same prior that makes a Russian model reach for ѧ.
1 in 8
real words still wrong (87.4% word accuracy). “Manual post-correction by domain experts” is needed before scholarly use.
9–15 s per word image on a 48 GB GPU: full pages and entire archives are not yet practical.
Scope matters: single, pre-cut words; formal Qing documents only; no layout or line segmentation. It is a proof of concept, not an archive-ready tool.

What the two cases teach

From a specialist recognizer to a vision–language model

Classic: CRNN

CNNsees strokes
→
LSTMreads left→right
→
CTCletters
  • trained for one script or collection
  • needs cut-out lines and transcribed training pages
  • no knowledge of language beyond its training data

New: VLM

Vision encodersees the page
→
Language modelwrites the text
  • general-purpose: many scripts and tasks
  • takes a prompt: “transcribe,” “keep the old spelling”
  • language prior: knows what words look like
Evidence from Manchu: the CRNN fell from 99.9% to 56.8% on real words, the fine-tuned VLM from 98.6% to 87.4%. The same language knowledge that makes a VLM robust is what made the Russian models “historicize.”

The pipeline, from page to text

image tokens text tokens one token at a time
1Scan / photopage image
1Preprocessingdeskew · binarize · crop · resize
Patchesimage cut into a grid of small tiles
Vision encoder(a ViT) turns each patch into a vector
2Text prompt“Transcribe this page exactly. Keep line breaks and the original orthography. Do not correct or translate.”
3Language decoder (LLM)
Reads image tokens and prompt tokens together, using attention.
Then predicts the most probable next token: a character or part of a word.
Image evidence + language prior → next token
↺ each new token is fed back in
temperature 0 → always the top choice
4OCR text
紅樓夢小說本名石頭記作者相傳…
Where you intervene
1 image quality
2 prompt and context
3 model, version, settings
4 evaluation and correction
The decoder is a black box; the rest is your method.

Inside the decoder: one token at a time

The model sees one long sequence and keeps extending it. (Tokens simplified; real tokenizers split text differently.)
img₁img₂img₃…img₂₅₆ Transcribethispage…
↑ image tokens from the vision encoder    ↑ prompt tokens    ↓ generated tokens appear one by one
紅樓夢小說本名石頭記作⟨end⟩
Interactive demos: attention · softmax temperature

Where “over-historicization” can come from

A toy illustration of one decoding step. The numbers are invented for teaching, not measured.

What the pixels say

The glyph is worn and blurry
я
0.40
ѧ
0.34
а
0.20
×

What the language prior expects

“historical text, old orthography”
я
0.15
ѧ
0.55
а
0.12
→

Decision

weighted together
ѧ
wins
A letter that was not printed is written down, confidently.

The prompt is part of your method

Levchenko, baseline (one text line)
Extract the OCR text from this 18th-century Russian book line. Preserve the original Old Russian orthography.
Humphries et al. (system message, abridged)
Your task is to accurately transcribe handwritten historical documents, minimizing the CER and WER. Work character by character, word by word, line by line, transcribing the text exactly as it appears on …
A template for your own sources (ours, adapt it and test it):
Task: transcribe this page. Language and period: Russian, printed c. 1760, Civil font. Style: diplomatic. Keep original spelling, hyphens and line breaks. Do not modernize, correct, or add letters not visible. Unclear: write [?] instead of guessing. Output: the text only.

A responsible workflow

LLM post-correction is not a free fix (Case 1, Result 3): Levchenko and Humphries disagree. Test it on your own sources.
Contamination: if your pages are online, the model may have seen them in training. Prefer unpublished sources for benchmarks.

Recap

1
OCR turns images into text. That text is a model’s reading, not the source.
2
Prepare images: deskew, even light, binarize if it helps, crop, enough pixels per character, lossless format.
3
CER and WER = (S + D + I) / N. Define what counts, and add a metric for the errors you care about.
4
Bias, not just noise: LLMs “over-historicize” (Russian); synthetic scores fail on real documents (Manchu).
5
VLMs = vision encoder + language decoder + your prompt: image evidence combined with a language prior.
6
Validate on your own sources, log the model, and spot-check against the image.

Sources