PHD: Pixel-Based Language Modeling of Historical Documents
Paper · 2023 · Nadav Borenstein, Phillip Rust, Desmond Elliott et al.
Summary
A scanned newspaper contains more than the words a reader can transcribe. Its type, spacing and arrangement can help a reader work out where an item begins or how to interpret a damaged line. Optical character recognition, or OCR, turns an image into text so that ordinary language software can process it. But a transcription can lose visual context and introduce errors of its own, especially when the original print is worn or the scan is blurred. PHD asks whether a language model can learn directly from document images and use what it learns to answer questions about them.
The authors adapt PIXEL, an approach that learns by filling in missing regions of rendered text. PHD divides square image crops into patches, hides groups of adjacent patches and learns to reconstruct the missing pixels from their surroundings. The original image supplies the target, so this stage can use newspaper scans without matching transcriptions. Because suitable historical scans are scarce, the authors first render modern books and encyclopedia text in varied type and add effects such as blur, stains and ink showing through the page. They then continue training on real historical newspapers from Caribbean collections.
The reconstructions frequently recover the appearance of the missing print. Short gaps and partly obscured words can come out clearly, while longer completions often blur. An apparently convincing font or line of print is therefore easier to assess than the accuracy of the words inside it. The authors also test whether the learned representations support language tasks. On a noisy image version of GLUE, a benchmark for modern English, PHD scores 67.2 on average. It leads the other systems that take an image directly in that comparison and comes close to the systems that use OCR before processing the text.
The historical question answering experiment asks PHD to mark where an answer appears in a scan. The underlying adverts were placed by enslavers seeking people who had escaped enslavement. On the balanced test set, PHD scores 74.7 on binary accuracy, which measures whether it correctly decides if the scan contains an answer. BERT, given manual transcriptions, scores 78.3. The gap is larger for the patch accuracy measure, where PHD scores 20.0 and BERT scores 52.0. The experiment shows that the original images can support useful answer finding while making clear how much harder it is to locate the full answer than to decide that one is present. OCR helps construct the image labels for this experiment, even though PHD receives an image at prediction time.
Deep dive: PHD: Pixel-Based Language Modeling of Historical Documents
PHD learns from historical newspaper images and tests whether it can recover missing print and locate answers without transcribing the scans. · about 34 minutes to read
The problem and its context
What a transcription leaves behind
Digitisation lets historians examine material from collections that would otherwise take much longer to survey. A researcher might want to find notices about a recurring subject or collect details reported across many issues of a newspaper. The paper describes how language software can speed up this collection stage and leave more time for examining the evidence. The common route from archive to language software runs through OCR, which identifies printed characters and returns a text representation.
That conversion changes the evidence available to the next stage. A picture, a heading in a distinctive typeface and a change in the arrangement of a page can all carry information. A text transcription may preserve the words near such features while leaving the features themselves out. The paper illustrates the issue with a full newspaper page. A complete page has a visual organization that cannot be recovered simply by reading off the recognized characters as a sequence.
OCR can also change the textual evidence it is intended to preserve. The paper identifies deteriorated pages, old typefaces, unfamiliar language, non-text elements and poor scan quality as sources of difficulty. These problems can occur together. A faint character in a damaged line is already hard to read, and the surrounding spelling may offer less help to a recognizer accustomed to contemporary text. The resulting file can contain character errors even when its general appearance is that of ordinary prose.
Those errors matter to a system that takes discrete text units as input. Tokenization divides a sequence of characters into units the system can process. The paper points out that historical OCR produces many unfamiliar word forms. A recognition error can turn a familiar word into a string whose units differ from those the system encountered during training. By the time the language stage sees that string, it no longer has the shape of the original letters available to help resolve the ambiguity. The authors connect this difficulty to earlier reports of weaker performance on historical material than on modern language.
Previous work described in the paper addresses the problem at several points. Some researchers improve the recognition stage itself. Others correct OCR output or normalize historical writing so that it resembles the modern text expected by downstream software. These approaches can make documents more accessible to existing tools. They also create a chain of decisions, and an error made while recognizing or normalizing a word can affect every subsequent task that uses it. PHD changes the entry point to this chain by giving the language system the image.
Availability is a separate issue from accuracy. For some languages, the authors note, a suitable OCR system is difficult to obtain or yields poor results. Training a new recognizer takes effort and resources. A pretraining objective that uses images without transcriptions could make a larger share of an archive usable as training material. The authors present this as part of the reason to explore the approach. Their own evaluation concerns English, where recognizers already offer a strong point of comparison.
Why direct image input still leaves a training question
The paper places PHD among approaches that combine vision and language. Some earlier systems already work with document images but also use an OCR transcript as an input. Such a system can take account of visual features while drawing on a recognizer for the words. Its dependence on recognition remains, since the two representations enter the same pipeline. PHD aims to use a scan directly even when a reliable text version of it is unavailable.
Other earlier systems take images without running a separate recognizer on them. Donut, for example, uses an image encoder and generates text with a decoder. Its pretraining teaches it to produce the text from document images, and it can then be adapted to tasks that call for text outputs. The important distinction for PHD is the target needed during pretraining. Donut may avoid a separate OCR component when it is used, but it still learns an image-to-text task that requires the corresponding text. Donut
The paper discusses Dessurt and Pix2Struct in the same context. In its account of these approaches, masking removes parts of an input image and training calls for text from regions of the image. Masking creates a reason to use context, but a text prediction still has to be checked against a transcription. For historical collections, the authors argue that independent ground-truth text for a large set of scans can be difficult to secure. Using the original pixels as the answer to the training exercise changes which collections can supply examples. Pix2Struct
The authors also cite an earlier use of masked image training on document patches. As they describe it, that work concentrates on problems such as detecting tables, classifying documents and analyzing layout. These tasks help establish why document images matter, but a system can frequently use page structure to make progress on them. PHD is aimed at tasks where the content of the written language matters directly. Deciding whether a paragraph contains the information requested by a question is a different test from identifying the form of the paragraph.
PIXEL provides a starting point because its pretraining already uses missing pixels as targets. It normally begins with a string and renders that string for the encoder to read. The PHD authors want the encoder to read actual scans, whose lines, typography and defects need not match PIXEL’s renderer. Their task is therefore both architectural and practical. They need a spatial arrangement that suits a document crop, enough images to learn from and evaluations that can tell whether the encoder has learned something beyond the appearance of print.
The method, step by step
From a strip of rendered text to a square document crop
The easiest way to understand the training exercise is to imagine a small newspaper crop with some areas covered. Around a covered region, the visible print may show the height of the letters and the baseline of the line. If a word is partly covered, it may also show clues to which letters are missing. If the cover hides whole words, the context may help narrow down what belongs there. The exercise asks PHD to fill in the covered areas of the image. The uncovered version supplies the target for checking its guesses.
PIXEL provides the basic architecture. A renderer turns a text string into an image. An encoder converts patches of that image into numerical representations, called embeddings. During pretraining, a decoder uses the representations to predict pixels in the missing areas. During adaptation to a downstream task, the reconstruction decoder gives way to an output head suited to that task. The learned encoder can then contribute features to a decision about the whole input or to a prediction about individual locations.
The paper compares the pretraining idea to BERT’s use of missing input and surrounding context. The analogy concerns the exercise of recovering what was hidden. The target in PHD is an area of an image, which can contain part of a character, pieces of adjacent lines or empty space. This difference becomes important when a missing region could plausibly contain several different words. A prediction in pixels ultimately has to render the result as an image. BERT
PIXEL’s training renderer normally makes an image of 16 × 8464 pixels. The paper gives its patch grid as 1 × 529. A character is at most 16 pixels high and takes up approximately a patch. This layout suits a string laid out along a single strip. It gives a language encoder visual input while retaining much of the spatial simplicity of a line of text. The scale also makes it possible for a patch to carry a substantial part of a character.
PHD instead accepts 368 × 368 pixels, arranged as 23 × 23 patches. The patch size is 16 × 16 pixels, as in PIXEL. The encoder and reconstruction decoder follow the patch-based design of ViT-MAE, a masked autoencoder architecture for images. In PHD’s square crop, a region can extend both along a line and across lines. A grid boundary is fixed by pixel position, so it can fall in the middle of a letter or word. The training target remains well defined even in these cases because it is taken from the original image grid. Masked Autoencoders
From document images to task predictions
The steps in order.
The diagram spans pretraining and downstream use. The masking and pixel reconstruction steps first operate on artificial crops and then on real newspaper crops. The downstream head is introduced after that reconstruction training, at the checkpoint chosen for the particular evaluation. There is no pretraining requirement to assign a word, letter or language category to each patch. The patch grid sets a coordinate system that can later be reused to report where an answer is visible.
Making artificial scans from modern writing
The first training phase needs more images than the authors can readily obtain in historical collections. They generate images as training proceeds from BookCorpus and English Wikipedia, the same text sources used for BERT in the paper’s account. Those sources provide the written content, while the rendering procedure determines how it will appear. In particular, the sources are modern. An image made to resemble an old page can still contain contemporary wording, a distinction that matters when interpreting later evaluations.
The generation procedure breaks the source text at newline boundaries to obtain paragraphs. It chooses a paragraph and a starting position at random, then takes the rest of that paragraph from the selected position onwards. It also draws a font and font size from a list used in earlier work on Dessurt. A Jinja template puts the span and typography into a fixed-size web layout. WeasyPrint renders the layout as a PNG image that fits the encoder’s input dimensions.
The first paragraph may leave a substantial area blank. A short span can do so simply because it has few lines, and small print can have the same effect. When the remaining blank area exceeds 10% of the image, the generator makes another image to occupy that space. It can repeat this operation until the available region is sufficiently filled. The paper’s illustration shows the initial placement of a paragraph, the addition of further material and the application of visual degradation.
The decision about what to add has a bias toward continuity. In 80% of those choices, the system keeps the existing font and takes the next paragraph. In 20%, it samples a different paragraph and a new font. The first choice allows part of the input to read as consecutive writing. The second allows an abrupt change of subject or type within a crop, as can occur when the edge of an item shares the image with the beginning of another. These probabilities describe the generation procedure for filling spare space, rather than the composition of the historical archive.
The generator then modifies the image to approximate conditions seen in old scans. The paper describes blur, random rotation, salt-and-pepper noise and simulated print showing through. It also lists effects such as stains, lines, holes and variation in the background color. They create different problems for a reader. Blur makes nearby shapes harder to distinguish. A stain can affect a whole area. Print showing through introduces patterns that resemble the type the encoder is supposed to read.
Since the degradation happens before the pretraining exercise, the image to reconstruct is the generated scan with its surface effects. The masks remove parts of that image, and the decoder tries to reproduce those parts. This setup exposes the encoder to imperfect print without supplying a clean transcription as a second target. The related question of whether PHD can restore the original wording of badly damaged documents requires evidence beyond reconstructing missing patches of these training images.
Turning full newspaper pages into training examples
The real scans come from the Caribbean Newspapers, 1718–1876 collection and from the Danish Royal Library. The latter supplies English-Danish newspapers published in Santa Cruz, now Saint Croix, between 1770–1850. The paper describes the collections as varied in format and content within a limited geographic and historical range. During this phase the text comes from the surviving documents themselves, along with the typography and irregularities present in their scans.
A full newspaper page cannot simply be shrunk to the encoder’s input dimensions without changing the scale of its print. The authors instead use the layout package Eynollah to identify paragraph regions and their reading order. They crop out those regions, resize each paragraph to a width of 368 pixels and join the pieces in reading order. This produces a long image with one column at a consistent width. The method preserves visual features inside the extracted passages while replacing the full page’s original arrangement of columns.
The next step moves a square window down that column. Each crop measures 368 × 368 pixels and the window moves by a stride of 128 pixels. Successive crops can therefore include some of the same printed material with different boundaries. This is useful for creating inputs from a long column, but it makes the level of the data split important. Dividing crops independently could put neighboring views of the same material on opposite sides of an evaluation split. The paper reserves 5% of newspaper issues for validation and uses the other issues for training.
The corpus statistics distinguish issues from crops. The Caribbean collection contributes 7,487 issues, with 1,675,172 crops in the training column and 87,721 in the held-out column of the paper’s table. The Danish Royal Library contributes 5,661 issues, with 300,780 training crops and 15,159 held-out crops. Across the collections the table reports 13,148 issues, 1,975,952 training crops and 102,880 held-out crops. The table calls the held-out column test scans, while the description of the issue-level split calls it validation.
The preprocessing establishes an important boundary around the term “document image.” PHD is trained on local images made from newspaper pages in reading order. It does not have to discover that reading order from a full-page image during the reconstruction exercise. The print, spacing and local structure can still be informative, and the encoder does not need to read a transcription to use them. Full-page layout analysis is a separate job in this pipeline.
What is hidden and how the training proceeds
Pretraining randomly covers 28% of the input patches. The authors put down rectangular masks with widths sampled uniformly from [2, 6] patches and heights sampled uniformly from [2, 4] patches. They place the rectangles at random positions. A block of neighboring patches can hide more continuous material than the same patches scattered individually. With a contiguous gap, the remaining letters may provide a clue to the word, or the model may have to rely on surrounding words and lines for context.
The encoder works from the visible patches and produces patch embeddings. The decoder learns to use such representations to recover the pixels in the hidden regions. A patch of reconstructed background and a patch containing a letter both belong to the same image prediction problem. The paper presents the objective in terms of the masked pixels it seeks to recover. Its explanation of the experiment does not specify a separate equation for choosing among alternative words, since the decoder predicts the image directly.
Pretraining begins with 1M steps on the artificial images, using a batch size of 176 and the AdamW optimizer. The batch size was the largest the authors could fit on their system. During the first 50k steps, the learning rate warms up linearly to 1.5e−4. It then follows a cosine decay to a minimum of 1e−5. The authors continue with 100k additional steps on real historical crops, using the same stated hyper-parameters apart from omitting the warm-up in that phase. They report 10 days of pretraining on 2 × 80GB Nvidia A100 GPUs.
This is a sequence of training phases. The artificial images make it possible to start with plentiful readable content in varied visual conditions. The newspaper continuation then exposes the encoder to actual historical print and language. The later evaluations use the checkpoint appropriate to each stated setup. The modern benchmark experiments use the checkpoint before the newspaper phase. The historical question answering experiment starts from the checkpoint after that phase and then applies further supervised training.
Converting language tasks to image tasks
For GLUE, the authors render each input example using a template related to the one used for artificial pretraining. An example has a sentence s₁ and may have a second sentence s₂. If both occur, the rendering places a line break between them. This keeps a visible boundary while giving PHD an image of the whole example. The correct output for the language task is the same label or score associated with the original example.
The authors make clean and noisy versions. The clean rendering uses a fixed font and omits degradation and augmentation. The noisy rendering varies fonts and applies image degradation. The distinction provides a controlled way to ask what happens when the same kind of language problem is made visually harder. For downstream adaptation, or fine-tuning, the reconstruction decoder is replaced by a task head. GLUE uses mean pooling, which combines the patch embeddings into a representation for the decision about the whole example.
The question answering setup uses the grid more directly. In the visual adaptation of SQuAD-v2, q is the question, c is the context passage and a is an answer span in c when the example has an answer. The authors render c as the image I. The classifier is meant to indicate which parts of I contain the answer, so the training procedure needs a way to map the span a to coordinates on the image. The text and its known answer are the starting point for this work. SQuAD
The procedure runs Tesseract on I to get a transcription and uses fuzzy string matching to look for the known answer. Fuzzy matching is meant to find a likely match even when the recognized string differs from the answer. The paper expresses a successful lookup as follows.
â ∈ ĉ
Here â is the matched answer string found by the lookup, ĉ is the context string produced by OCR, and ∈ indicates that the former was found within the latter. The hats distinguish the strings obtained through recognition and matching from the original answer a and original context c. Tesseract associates the matched words with image coordinates, which the authors then convert to patch coordinates.
The label construction can be written as the binary patch rule described in the paper.
M[p] = 1 if p contains part of the located answer, 0 otherwise
Here M is the answer mask, p is a patch of the context image I, and M[p] is the label at that patch. The equality sign assigns the label. A value of 1 marks an intersection with the answer’s image location and 0 marks the remaining patches. When the answer cannot be located by the labeling procedure, the visual example has no labeled answer. The predicted mask, denoted M̂ in the paper, supplies corresponding patch labels from the classifier.
The pipeline keeps image and labels aligned if an augmentation changes the coordinates. It also renders the question, joins it to the image of the context and crops the result to fit the input. There are clean and noisy visual versions of SQuAD. The authors report that in about 15% of cases the recognition and matching procedure fails to find the answer. The visual version consequently contains a higher proportion of examples without a labeled answer than the text version. That issue concerns how the experiment is labeled, even though PHD receives the question and context as pixels when it makes predictions.
The historical dataset starts from the Runaway Slaves in Britain project. It contains over 800 adverts printed between 1700 and 1780. The project’s manual transcriptions and annotations provide more than 50 kinds of attributes, such as age, clothing and physical description. For a given advert and attribute, the authors use the transcription as the context, take the annotated value as the answer and manually write a question about the attribute. The resulting question is tied to information readers can check against the advert.
For the historical image input, the authors use the original advert scan in place of a newly rendered context. They process the examples along the lines of the visual SQuAD setup and do not add synthetic noise to these images. They reserve 20% of the dataset for testing. The historical checkpoint first learns the patch classification task on noisy SQuAD. It then undergoes adaptation to the advert questions. This transfer gives it supervised experience with the output format before the final stage on historical material.
For SQuAD, the reported settings include a learning rate of 6.75e−6, a batch size of 128, a dropout probability of 0.0 and a weight decay of 1e−5. The run lasts 50,000 steps. The historical adaptation takes an additional 1000 steps following SQuAD training. For that adaptation, the authors increase the dropout probability to 0.2 and keep the other reported settings. They release the datasets, trained encoders and code for the project under the name pixel-bw.
Experiments and results
Recovering print on held-out newspaper crops
The most direct test of pretraining is to cover an area of a held-out scan and inspect what the decoder puts in its place. The paper shows images with the covered regions outlined so a reader can compare the reconstruction with the visible print around it and with the original. In the examples, the output can match the local type style and continue the shape and spacing of a line. This is evidence that the reconstruction can use features specific to the surrounding document.
The content is less consistent than the appearance. Short gaps can yield legible text, especially if part of the word is still visible. Larger gaps frequently yield blurry letter shapes. Even when the decoder puts something at the expected place on the line, the resulting image may be too indistinct to establish which word it predicted. The authors therefore describe the form and the text separately when they assess the examples.
They also try a more targeted test. Tesseract reads a held-out scan and proposes word locations. A randomly selected recognized word supplies the location for a heuristic mask, so the authors can ask how the decoder handles a missing word instead of whatever happens to fall in an arbitrary rectangle. The examples include a sharp and correct reconstruction, blurry output and a legible prediction of the wrong word. A clear image can therefore be judged wrong in a way that an ambiguous blur often cannot.
The proposed explanation for some of the blur is that several completions may be plausible. In a discrete text predictor, a reader could inspect the weights assigned to competing words. An image puts the prediction into pixel values, where different plausible letter patterns can be hard to distinguish if they contribute to the same reconstruction. The paper offers this as an interpretation of the examples. It does not measure the contribution of particular candidate words to a blurry region or report a word recovery rate.
Modern language benchmarks in clean and noisy images
GLUE tests whether the encoder trained to reconstruct images can be adapted to decisions about the language in them. The benchmark contains different kinds of problems. Some require a prediction about a single sentence, while others ask the system to use the relationship between sentences. The paper reports F1 for QQP and MRPC, Matthews correlation for COLA, and Spearman’s rank correlation for STS-B. It uses accuracy for the remaining tasks. The average is the aggregate of the reported task scores, so it should be read as a benchmark average across metrics.
The baseline designs give several ways to read the result. CLIP supplies image features from a ViT-L/14 encoder. The authors fit a linear predictor to those features while leaving the image encoder fixed. For classification they use logistic regression, and for the STS-B similarity scores they use linear regression. Donut is fine-tuned to turn each image into a textual output representing a label or a similarity score. These systems can both take an image directly, but they use different pretraining and adaptation procedures. CLIP
The paper notes that CLIP has ∼ 427M parameters and is about 5× the size of PHD. It also had more pretraining data and time, while the comparison gives PHD full fine-tuning and trains only the linear predictor on CLIP’s features. Donut has ∼ 200M parameters and uses its own full adaptation setup. In the baseline experiment its input is resized to 320 × 320 pixels. The results compare the authors’ actual implementations of these systems. Their scores reflect several design and training choices in addition to the choice of pretraining objective.
For the OCR baselines, Tesseract converts noisy rendered examples back into text. BERT and PIXEL then learn from that output. In this setup PIXEL renders the recognized string in its usual image format, so the original visual evidence has already passed through recognition. The appendix describes making the OCR training data from 5 epochs of noisy examples, while using fixed validation sets without that oversampling. Because noisy OCR makes the sentence boundary hard to preserve, a sentence pair is processed as a single sequence. The authors also report baseline averages over 5 random initializations.
The clean text reference scores give a sense of what the underlying benchmark permits when a system has access to the original strings. BERT’s reported GLUE average in that condition is 80.0, and PIXEL’s is 74.1. On the clean rendered images, PHD averages 67.9, Donut 57.2 and the CLIP linear probe 52.7. PHD makes substantial progress on the benchmark with an image as input, while the original-text comparisons quantify the cost still visible when it has to read the rendered input for itself.
System averages on noisy visual GLUE
PHD leads the direct image systems and scores near the OCR pipelines.
The numbers
| System or setting | GLUE average score |
|---|---|
| CLIP linear probe | 52.9 |
| Donut | 57.3 |
| PHD (this paper) | 67.2 |
| OCR followed by PIXEL | 68.5 |
| OCR followed by BERT | 69.2 |
The noisy average puts PHD close to the OCR pipelines, with different rankings on individual tasks. On noisy STS-B, which measures how well predictions order sentence pairs by similarity, PHD scores 80.4 in Spearman’s rank correlation. The corresponding OCR scores are 68.4 for BERT and 68.8 for PIXEL. In the same visual condition CLIP scores 57.9 and Donut 20.6. The paper’s Donut setup represents a numerical similarity rating as a string, so the comparison on this task includes differences in how systems express their answer as well as how they read the sentences.
The COLA results show a different pattern. On the noisy version of this grammatical acceptability task, PHD scores 15.1 in Matthews correlation, compared with 39.7 for OCR followed by BERT and 30.3 for OCR followed by PIXEL. PHD scores 15.9 on the clean images. That low clean-image result matters when interpreting the noisy result. Visual degradation alone is an incomplete explanation for PHD’s difficulty with the task, since the score is also low when the images use fixed rendering without degradation.
Several other tasks show strong noisy-image scores. PHD reaches 81.8 in accuracy on QNLI, 83.9 in accuracy on SST-2 and 80.4 in F1 on QQP. On noisy QNLI, the corresponding OCR pipeline scores are 82.7 with BERT and 81.5 with PIXEL. These results show why the paper describes PHD as competitive with OCR pipelines across GLUE while still placing the OCR pipelines ahead on the overall average. Recovering sentence meaning appears tractable for some tasks even when the input presents difficult print conditions.
Finding answers in modern and historical images
The question answering experiment measures each prediction in several ways. Binary accuracy asks only if the prediction agrees with the label on whether the context has an answer. This can reward a correct judgment about answer presence even when the predicted location is wrong. Patch accuracy measures the overlap of the predicted and labeled answer patches, averaged over examples with an answer. The paper also reports a more permissive measure, One Overlap, which credits a prediction that shares at least a patch with the labeled answer.
The test sets are balanced for answer presence. This matters because the presence metric would otherwise depend heavily on the proportion of examples with a labeled answer. For text SQuAD, the BERT comparison uses the balanced validation set, with the original text available rather than Tesseract output. For the historical task, BERT is adapted on the manual transcriptions and evaluated on the balanced held-out set. PHD’s historical result uses the actual scans and the supervised transfer procedure from noisy visual SQuAD.
On the balanced SQuAD evaluation, BERT on text records 72.3 in binary accuracy, 47.3 in patch accuracy and 53.9 in One Overlap, using the names in the results table. PHD on clean images reports 60.3 in binary accuracy, 16.4 in patch accuracy and 42.2 in One Overlap. On noisy images, PHD reports 61.7, 14.4 and 41.2 on those same metrics, respectively. Answer presence is slightly higher in the noisy condition, while both location measures are lower. This gives a more precise account of the comparison than treating noise as a uniform loss.
The historical experiment produces a higher binary accuracy than either visual SQuAD condition. This is PHD applied to a different domain with another stage of supervised training. It addresses a practical question that rendered SQuAD cannot answer by itself. An advert gives the encoder authentic historical print, and the question comes from a real annotation about what the advert says. The test asks whether the encoder can indicate where a reader should look to verify the answer.
Binary accuracy on the balanced historical advert test set
PHD approaches the transcription-based result in deciding whether an answer is present.
The numbers
| System or setting | accuracy % |
|---|---|
| BERT on manual transcriptions | 78.3 |
| PHD on original scans (this paper) | 74.7 |
On that same test set, One Overlap is 48.8 for PHD and 55.8 for BERT. Patch accuracy is 20.0 for PHD and 52.0 for BERT. The location metrics qualify the binary result. Declaring that an answer exists still leaves open whether the output points to the right line. Marking part of the right region can help orient a reader while leaving the answer only partly localized. The stronger difference on patch accuracy matters for any use that depends on more precise boundaries.
Patch accuracy on the balanced historical advert test set
The transcription-based comparison leads by more on patch accuracy than on the other reported measures.
The numbers
| System or setting | patch accuracy |
|---|---|
| BERT on manual transcriptions | 52.0 |
| PHD on original scans (this paper) | 20.0 |
The paper also displays patch-based saliency maps for historical test examples. The maps give a visual account of the regions associated with a prediction and allow comparison with the annotated answer area. The main examples include a successful prediction and a failure. For this task that distinction is useful because the output is meant to point into the document itself. An example that puts the predicted evidence beside the annotated evidence gives a reader a way to inspect what the aggregate scores compress.
What the ablations show
The paper reports no ablation that removes a component from PHD under a matched setup, but it does offer clean and noisy comparisons, reconstruction probes, a retrieval study and visual inspection of answers.
What changes when the input is degraded
The clean and noisy visual benchmarks come closest to controlled tests of a particular influence on performance. Both use the patch encoder and the same kinds of language tasks, while the noisier version adds random fonts and degradation. That changes the reading conditions without introducing a different benchmark of reasoning or grammatical knowledge. The comparison can therefore show whether the way the language is presented has a large effect within these constructed settings.
PHD’s GLUE average is 67.9 on clean images and 67.2 on noisy images. The aggregate movement conceals differences among tasks. MNLI accuracy is 70.1 on clean images and 68.0 on noisy ones. SST-2 accuracy is 82.5 on the clean images and 83.9 on the noisy ones. In the sentence similarity task, the Spearman score is 80.2 on clean images and 80.4 on noisy images. The paper’s numbers show that the aggregate result cannot be taken to imply that every task responds in the same direction.
The similar GLUE averages support the authors’ claim of resilience to the kinds of variation they introduced. They leave the source of the resilience open. The images vary in more than one way, so the comparison does not isolate blur from font variation, rotation or other transformations. Nor does it compare an encoder pretrained with the degradation procedure against an otherwise matched encoder pretrained without it. The experiment establishes observed performance under the chosen noise conditions. It does not assign that performance to an individual augmentation.
Visual SQuAD adds a distinction between finding that an answer exists and locating it. PHD’s noisy-image binary accuracy is 61.7 compared with 60.3 on clean images. Its patch accuracy instead goes from 16.4 on clean images to 14.4 on noisy ones. For One Overlap, the clean score is 42.2 and the noisy score is 41.2. This is consistent with a system retaining some information about what the passage says even when noise makes the exact patch boundaries harder to predict. The results do not establish how reliably those differences would recur across repeated runs.
The comparisons across GLUE systems answer a related question about the overall pipeline. Given the baseline choices, PHD is a stronger direct image system on average than the tested Donut and CLIP configurations. OCR followed by BERT or PIXEL yields higher noisy averages. That ranking cannot isolate the effect of predicting pixels from the effects of architecture, training data or the amount of adaptation. The clean and noisy PHD comparisons concern input conditions. The comparisons between systems concern complete methods.
Which gaps can be filled
The reconstruction examples test what becomes visible when the missing area changes. With part of a word still present, the decoder has clues from its letter shapes and the line around it. When the mask removes more print, those clues become less specific. The paper’s examples show that PHD can preserve visual regularities across a gap even when its guess about the wording is difficult to read. Good continuity of type and spacing is therefore evidence of learning about the image, with the correctness of the underlying words still to be checked.
The targeted word masks make the unit of interpretation clearer. The experiment starts with a word that Tesseract has identified and then covers its location. The resulting examples expose distinct outcomes: a correct and readable completion, a readable but incorrect completion, and output that cannot be read confidently. The second outcome shows why sharpness alone is an inadequate measure of success. The third shows why an automatic exact-word assessment is difficult to apply across the reconstructions.
The authors discuss running OCR over the completed patches and comparing the output with the OCR on the originals. This would give an automatic procedure for scoring some of the examples. Because the decoder’s blur can defeat OCR independently of the intended word, its recognition failures would make the score difficult to interpret. The paper consequently relies on inspection and uses the examples to show the range of observed outcomes. It does not establish a measured relationship between mask extent and exact reconstruction accuracy.
What the representations capture for retrieval
The retrieval analyses ask whether the encoder can help group scans even when the decoder is no longer reconstructing missing image regions. The authors take a random sample of 1000 test images and represent each one by averaging the final layer’s patch embeddings. They then use t-SNE to make the relationships among those image representations easier to inspect in fewer dimensions. The plotted groups appear to reflect visual resemblance and the organization of the print.
That inspection establishes why a retrieval experiment needs to consider more than the appearance of a cluster. Scans of similar typography or layout may sit close together while covering unrelated subjects. Conversely, several scans about the same subject might be set in different type or surrounded by different material. A picture of the embedding space can show which inputs collect together, while a reading of the retrieved examples is needed to check whether their contents also agree.
The authors then embed 1M random newspaper crops and use sample images as queries. They include adverts from the British historical dataset and examples of shipping notices. For each query they rank corpus images by cosine similarity, which compares the direction of their numerical representations. They manually inspect the ten most similar results. The query is itself an image. This is a test of using a source fragment to find related source fragments in a large collection.
Some of the matches concern the same sort of subject as the query, which suggests that the embeddings can carry information about the language. Many matches are semantically poor. The paper’s shipping examples also illustrate why form and content are hard to separate in this experiment. A notice may repeatedly include fields about such things as a route, cargo or the ship’s captain. Shared structure can make similar notices look alike even when the exact information differs. The study offers qualitative evidence about information retrieval and search.
The authors suggest that specialized fine-tuning might improve how well the embeddings reflect meaning, and mention SentenceBERT’s training scheme as an example of the kind of approach they have in mind. Their retrieval experiment uses the representations they already have. It sets out a possible use of those representations and illustrates why an evaluation would need to distinguish semantic relevance from visual resemblance. It does not report the result of the proposed specialized training.
What the answer maps add
The historical answer maps complement the numerical measures by letting a reader inspect location errors on the same image as the source. A binary answer-presence score cannot reveal whether the predicted region corresponds to the annotation. One Overlap can tell that some patch coincides with it, while leaving unanswered how the rest of the prediction is distributed. Seeing the mask and the target together makes the practical consequences of the prediction easier to understand.
The maps are also an especially direct illustration of the output format. An answer region is tied to the surviving print, so a person can inspect the artifact at the point where the encoder indicates evidence. The authors show that this format can expose both good and poor predictions. They offer examples of visual interpretation instead of a comparison that isolates the reason why one question succeeds and another fails. The maps alone cannot establish how the encoder used each visible part of the image to reach a decision.
Limitations
Limits identified by the authors
The authors restrict their experiments to English. They point out that this is a high-resource language with effective OCR alternatives, while the motivation for a recognition-free route may be particularly strong for languages whose recognizers are poor or unavailable. The paper demonstrates a way of training on images without paired text. Its empirical results cannot establish how well the encoder or its training recipe would transfer to writing systems, languages or font traditions that were outside the evaluation. Low-resource languages
The historical pretraining data come from a newspaper corpus assembled from Caribbean collections. The resulting range of documents is useful for studying newspaper crops, but it leaves generalization to other kinds of historical sources unresolved. The authors also emphasize that most of the pretraining material is modern text. Its typesetting and appearance are deliberately varied, yet a synthetic image with contemporary wording presents a different language distribution from an authentic historical page. Continued pretraining on newspapers addresses part of this difference within the available collection.
The authors identify evaluation of reconstruction as an open problem. Judging type and layout by eye is easier than assigning a reliable word-level score to a blurry patch. A few readable recoveries establish that recovery is possible. The full output still needs a measure that can distinguish a wrong word from a poorly rendered prediction and account for the difficulty of a given gap. The authors point out that reliance on qualitative reconstruction assessment also limits its usefulness for deciding which training choices are best for downstream tasks.
The supervised language evaluation is narrow relative to the intended scope. GLUE and SQuAD were designed around modern language, and the paper relies on one historical question answering dataset. The choice to test a checkpoint trained on synthetic scans for the modern tasks makes their interpretation clearer as modern-language experiments. It also leaves little direct measurement of how the final historical checkpoint handles the variety of genres and tasks a historian may encounter.
The paper also cites limits on compute. The authors were able to train a relatively small encoder for a limited schedule, and the GLUE hyper-parameters were chosen from a small set of preliminary runs. A broader hyper-parameter search or more extensive training might affect the results. That possibility does not show which benchmarks would improve or by how much. The authors present it as a constraint on what they could test.
Limits visible in the experimental design
The strongest meaning of “OCR-free” here concerns how the encoder reads its input and how the reconstruction stage gets its training targets. Pretraining on real scans can obtain a target by exposing the original pixels. During question answering, PHD receives an image of the question and passage. But the visual question answering training procedure uses Tesseract and string matching to build spatial supervision, and the historical dataset draws on manual transcriptions and annotations to define the questions and their answers. Those are real dependencies when considering the amount of preparation required for the demonstrated application.
The SQuAD conversion introduces a further uncertainty about the target. A context can contain the answer in its printed text and still receive no spatial label for it if recognition and matching fail. Balancing the evaluation for answer presence helps keep the reported binary metric interpretable within the constructed data. It does not fix the earlier failure to locate particular answers, and it does not ensure that the same answerable cases are presented to the text and image systems. Recognition errors can therefore affect the labels even though recognition is absent from PHD’s prediction pipeline.
Image and text question answering also make different demands on the systems being compared. BERT starts with a string whose words are already available and returns an answer from that representation. PHD must work out the written content and identify a region made up of image patches. A patch can intersect the answer while also containing adjacent print. The reported comparison is informative about the end-to-end setups, but its gap cannot be interpreted directly as a gap in comprehension, independently of reading and spatial localization.
The historical QA results are strongest for detecting whether evidence exists and weaker at marking that evidence precisely. This distinction should carry through to interpretations of usefulness. A historian who receives a rough indication of where to look can inspect the original. A use that expects to extract the complete answer automatically needs more from the output than a positive presence judgment or a partial overlap. The paper gives results on these measures, but it does not validate a complete workflow for replacing manual examination of the answer.
Question recurrence gives another reason to be cautious about comparing the two datasets. The authors themselves suggest that the historical collection may be easier for PHD because questions recur across different adverts. A repeated question can establish what kind of information to look for, while the context still determines whether the answer is present and what it is. Since the datasets also differ in subject, layout and training procedure, the higher historical binary score cannot identify the effect of repetition by itself. It establishes performance on the particular historical task.
The historical adaptation also combines several changes. The final checkpoint has seen real newspaper scans, has been trained on noisy visual SQuAD and has been fine-tuned on the advert data. The paper does not report a matched historical comparison that skips the newspaper pretraining phase or the SQuAD transfer stage. The final result therefore tests the combined pipeline. It cannot show how much historical exposure contributed on its own or whether each part of the sequence was needed for the observed accuracy.
Another boundary is imposed by cropping. The authors argue that images contain context lost in plain text, and their approach clearly keeps local visual information available. Their newspaper preprocessing nevertheless establishes the reading order externally and presents part of a linearized column. A figure elsewhere on a page or the relationship between columns may fall outside that crop altogether. The results support an encoder of local document regions. They leave open what could be gained from the full page and what it would take to encode it.
The retrieval study has a similar evidential boundary. The authors inspect high-ranking examples for a small set of query types and find both semantically related and unrelated results. There is no benchmark score that gives a collection-wide rate of relevant retrieval. Visual resemblance also offers a plausible explanation for some of the matches. The evidence supports further exploration of scan embeddings as a search representation while leaving the quality of a practical semantic search system unmeasured.
What came after
No later studies are documented here, so there is no established follow-up result to attribute to PHD. The paper itself leaves several questions open. It proposes a broader historical corpus and better ways to evaluate reconstructions, especially where the intended word cannot be read confidently from the predicted image. It also raises the possibility of training embeddings specifically for semantic retrieval. The results reported for PHD concern its original training and evaluation setup. Whether those extensions improve recovery, retrieval or precise answer localization remains unresolved.
Cite
Cite as Nadav Borenstein, Phillip Rust, Desmond Elliott and Isabelle Augenstein. 2023. PHD: Pixel-Based Language Modeling of Historical Documents. Proceedings of the 2023 Conference on Empirical Methods in Natural Language Processing.
@inproceedings{borenstein2023phd,
title = {{PHD: Pixel-Based Language Modeling of Historical Documents}},
author = {Nadav Borenstein, Phillip Rust, Desmond Elliott and Isabelle Augenstein},
booktitle = {Proceedings of the 2023 Conference on Empirical Methods in Natural Language Processing},
year = {2023},
doi = {10.18653/v1/2023.emnlp-main.7},
url = {https://doi.org/10.18653/v1/2023.emnlp-main.7}
}This page in Markdown https://md.research.elamur.ai/free/en/papers/borenstein-2023-phd-pixel-based-language-modeling/