Back to paper library
Paper notesarXiv 2019ICDAR 2019

PubLayNet

One Fish, Two Dishes

Original paper

PubLayNet: largest dataset ever for document layout analysis

Paper authors

Xu Zhong · Jianbin Tang · Antonio Jimeno Yepes

Publication
ICDAR 2019Conference
First submitted to arXiv
arXiv:1908.07836
Cite this paper · BibTeX

The citation identifies the linked source version. It cites the original paper and its authors.

@misc{documentunderstandingpublaynet2019,
  title = {{PubLayNet: largest dataset ever for document layout analysis}},
  author = {Xu Zhong and Jianbin Tang and Antonio Jimeno Yepes},
  year = {2019},
  eprint = {1908.07836},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1908.07836}
}
On this page

If you want to train a layout analysis model, the first problem is often not the model but the data.

The layout datasets from the various ICDAR competitions and the U.S. National Library of Medicine's MARG are all around a few hundred pages. Next to ImageNet's million-plus images and COCO's hundred-thousand-plus, that's several orders of magnitude short. Detectors had to be pretrained on natural images first and then fine-tuned on these few hundred pages.

Two years earlier, MFCN chose to synthesize its own documents with LaTeX, generating 135,000 pages in one go. Synthetic documents come with free labels, but their layouts and content are cobbled together and always fall short of real documents.

Three authors at IBM Research Australia found another way. Every open-access paper on PubMed Central comes in two versions at once: a PDF for people to read and an XML file for machines. The XML says which part is the title, which is body text, and where the figures and tables are; the PDF has the position of every character on the page.

Line up the two versions, and you have your labels.

Defining the Problem

Layout analysis means finding every block on a document page and saying whether it is a paragraph, a title, a list, a table or a figure.

Around 2017, people found that this could be done directly as object detection, with detectors such as Faster R-CNN and Mask R-CNN carried over as they are. The remaining bottleneck was data volume. Labeling one document page by hand means drawing dozens of boxes, and every new type of document has to be labeled all over again, so the cost just won't come down.

Can a layout dataset on the scale of COCO be generated automatically, without manual labeling? And can models trained on such a dataset be used on other documents? Those are the two questions this paper sets out to answer.

Solving the Problem

Two Versions of One Article

Original Fig. 1: four images side by side. (a) is a PDF page of a paper, with two sets of fundus photographs at top left, a lab test table on the right, and discussion paragraphs and a list below; (b) is the XML for the same page content, showing tags such as table-wrap, caption and list-item; (c) is PDFMiner's parse of (a), with red boxes for text blocks, blue boxes for text lines, green boxes for images and yellow boxes for geometric shapes; (d) is the layout annotation produced by matching (b) against (c), with red for title, green for text, blue for figure, yellow for table and cyan for list.
Original Fig. 1, Zhong et al., from PDF page 2, arXiv license, scholarly quotation.

Read from left to right, this figure is the whole method.

  1. (a) PDF: a real journal paper page with photos, a table, paragraphs and a list.
  2. (b) XML: the structured version of the same article. <table-wrap> is a table, <caption> a caption, <list-item> a list item, and <title>Discussion</title> a section heading.
  3. (c) PDFMiner's parse: the coordinates of every text block, every image and every line in the PDF. This step knows the positions but not the roles.
  4. (d) Annotation: match each block in (c) to a node in (b), taking the position from the PDF and the class from the XML.

In October 2018, the authors downloaded 1,162,856 articles with complete XML from PubMed Central's FTP and ran every one of them through this process.

Only Five Classes

XML has a great many node types, and some can't be told apart even by a person looking at the image, author affiliations and copyright statements for instance. The authors merged them into five layout classes:

ClassXML content included
TextAuthors, affiliations, article information, copyright, abstract, body and appendix paragraphs, figure and table footnotes
TitleArticle title, standalone section and subsection headings, standalone figure and table labels
ListLists
TableTable bodies
FigureFigure bodies

These five were chosen because they differ clearly in appearance so models can learn them, they are common in documents from every field, and they are useful for downstream tasks (text classification, entity recognition, figure and table understanding).

A few detailed rules affect the results later on. A section heading written on the same line as the first line of a paragraph counts as text, not title; a figure or table label stuck to its caption text also counts as text. A nested list counts as a single object, and subfigures aren't labeled separately either.

How to Match the Strings

Matching PDF text blocks to XML nodes sounds like plain string matching, but in practice the text on the two sides often differs in small ways.

The first step is cleaning the XML. Nodes such as math formulas (tex-math, disp-formula) are removed first, because leaving them in would interfere with matching the other nodes. Table, figure and list nodes are all moved into one branch, and then the nodes of the whole XML tree are split into five groups: body-type nodes whose order matches the reading order (title, abstract, section headings, paragraphs), miscellaneous nodes whose order may not match (authors, affiliations, copyright, acknowledgments), figures, tables and lists.

The second step is Unicode normalization. The strings on both sides are converted to NFKD form.

This step looks unremarkable, but an example shows why it's needed. When a PDF is typeset, the two letters "fi" are often printed as a single ligature character, fi (U+FB01), while the XML has an ordinary f and i. NFKD splits the ligature back into two letters, and only then do the two sides match. Compatibility characters like this are very common in typeset PDFs.

Only the third step is the matching itself. The authors run a fuzzy search with Levenshtein distance, adjusting the maximum allowed distance dmax⁡d_{\max} to the target string's length ll:

dmax⁡={0.2 l,l≤200.15 l,20<l≤400.1 l,l>40d_{\max} = \begin{cases} 0.2\,l, & l \le 20 \\ 0.15\,l, & 20 < l \le 40 \\ 0.1\,l, & l > 40 \end{cases}

A 30-character string is allowed an edit distance of 0.15×30=4.50.15 \times 30 = 4.5; a 400-character paragraph is allowed 40. The paper doesn't explain where these ratios come from. Judging by the numbers, short strings get a looser ratio, and a reasonable reading is that scattered differences such as hyphenation, spaces and special symbols make up a larger share of a short string.

Matching is done line by line. A single PDFMiner text block can span several XML nodes; a section heading and the paragraph under it, for example, may be parsed as one block. So the authors take each line of the text block and look for it, in order, in the XML node's text. If the XML node has ended but the text block hasn't, they cut the text block in two at that line, give the first part to this node, and keep looking for the second part in the next node.

Figures and Tables Have No Text, So How Do You Label Them?

Text can be matched by string, but a figure's body has no text to match. The authors use a process of elimination.

Original Fig. 2: a page from a Nature Communications paper. The green box is the area enclosing all labeled text (Main text box); the brown box is the caption (Caption box); the blue box is the largest area that fits between the top of the caption and the previous labeled text (Potential box); the red box is the final figure-body annotation (Annotation), enclosing all the images, lines and text blocks inside the blue box.
Original Fig. 2, Zhong et al., from PDF page 3, arXiv license, scholarly quotation.

Let's walk through this figure:

  1. Once all the text has been labeled, compute the smallest box that encloses all the labeled text and treat it as the main text area (green box).
  2. The caption has already been found by string matching (brown box).
  3. Going up from the top of the caption to the previous labeled text, the largest box that fits inside the main text area is "where the figure might be" (blue box).
  4. Finally, find all the images, geometric shapes and text blocks inside the blue box and take their smallest bounding box; that's the figure body (red box).

Tables use the same method with the direction reversed: the authors assume the table body is always below the table's caption.

Growing Polygons from Text Lines

So that models such as Mask R-CNN, which need masks, can be trained too, the authors also generated segmentation polygons for the text classes.

Original Fig. 3: four text lines of different widths (blue bars), wrapped by a red polygon that follows their outer edges. The second line is wider than the first, so the polygon bulges out on the right; the third line is narrower than the lines above and below it, so the polygon pulls in on both the left and right; the bottom line is wider again. The whole polygon is made only of horizontal and vertical edges.
Original Fig. 3, Zhong et al., from PDF page 4, arXiv license, scholarly quotation.

The method scans the edges of the text lines. The top edge of the first line and the bottom edge of the last line become the polygon's upper and lower boundaries. On the right side, the right edge of each line is scanned from top to bottom, and wherever a line is wider or narrower than the one above it, a right-angle turn is inserted; the left side is scanned from bottom to top by the same rule. The result is a polygon with only horizontal and vertical edges that follows the paragraph's actual shape.

Figures and tables are almost all rectangles, so their bounding boxes serve directly as masks.

Quality Control: 99%

Automatic labeling is bound to make mistakes. PDFMiner, for instance, parses some complex inline formulas into text completely different from the XML; the strings don't match, and the whole paragraph goes unlabeled.

The authors define an annotation quality: within the main text area, "the area of the labeled text blocks, images and geometric shapes" divided by "the area of all text blocks, images and geometric shapes." An ordinary page whose quality is below 99% is thrown out entirely.

99% is a very strict threshold: if even a short stretch of a page fails to match, the page is dropped. A paper's first page is a special case. Submission dates, copyright statements and editorial information appear in the PDF but are often written differently in the XML, so the threshold for first pages is relaxed to 90%.

With over a million source articles, losing some pages is no great loss. The authors would rather have a bit less, as long as it's clean.

Splitting by Journal

Last comes the split into training, validation and test sets. Instead of splitting pages at random, the authors split by journal, so pages from one journal appear in only one of the sets.

This tests whether the model can handle the layouts of journals it hasn't seen. If pages from one journal appeared in both the training and test sets, a model could score well just by memorizing the templates.

The validation and test sets come from medium-sized journals (no more than 2,000 pages, but with at least 320 figures, 140 tables and 20 lists), half going to validation and half to test. They were checked by hand, with pages containing serious errors removed and those with moderate errors corrected. All other journals go into the training set, with at most 200 pages containing lists, 50 containing tables, 50 containing figures, 50 first pages and 25 ordinary pages sampled from each journal, so that big journals can't dominate.

The counts from the paper's Table II:

TrainValTest
Pages340,39111,85811,983
Text instances2,376,70293,52895,780
Title instances633,35919,90820,340
List instances81,8504,5615,156
Table instances103,0574,9055,166
Figure instances116,6924,9135,333

That adds up to over 360,000 pages and more than 3.5 million instances. In the paper's words, it is one to two orders of magnitude larger than any existing layout dataset.

Discussion

How well do off-the-shelf detectors do when trained on PubLayNet? Does pretraining on PubLayNet help in a table detection competition? On a completely different type of document, is PubLayNet a better initialization than ImageNet or COCO? The authors answer each question with one of three experiments.

Detectors Can Learn It

The authors trained Faster R-CNN and Mask R-CNN with Detectron on an ImageNet-pretrained ResNeXt-101-64x4d backbone, for 180,000 iterations on 8 GPUs. The metric is COCO's mAP@[0.50:0.95], the average over IoU thresholds from 0.5 to 0.95, which is very strict about box placement.

Test set results from the paper's Table III:

ClassFaster R-CNNMask R-CNN
Text0.9130.917
Title0.8120.828
List0.8850.887
Table0.9430.947
Figure0.9450.955
Mean0.9000.907

Both models average above 0.9, with Mask R-CNN slightly ahead. Tables and figures are the most accurate; the authors explain that they have regular shapes, differ a lot from the other classes, and have a lower error rate in the training labels. Titles do worst, because a title is usually a single line with a small box, so a slight offset drags down the IoU and the score with it.

An mAP of 0.9 sounds high, but keep in mind it was measured on the same source. The test journals weren't seen in training, but they're all biomedical papers on PubMed Central, whose typesetting styles are similar to begin with.

Original Fig. 5: Mask R-CNN predictions on eight test-set pages, with green boxes for text, red for title, yellow for table, blue for figure and cyan for list. On the first page, the table at the top and the three scatter plots below it are boxed together as one large figure; on the second page, a table and the flowchart below it are boxed as one figure; several pages in the middle have numbered recommendation items labeled as lists.
Original Fig. 5, Zhong et al., from PDF page 6, arXiv license, scholarly quotation.

The authors also show some failures. On the leftmost page, the model boxes the table at the top and the three scatter plots below it as a single figure; on the second page, it boxes a table together with a flowchart as one figure. Both errors have to do with how "figure body" is defined: when a table and a figure sit right against each other, even a person has to read the captions to know where to cut. The authors also admit that some errors come from noise in PubLayNet itself.

170 Pages Tie 1,600

The second experiment is the ICDAR 2013 table detection competition, whose documents are PDFs from European government agencies, very different from biomedical papers.

The authors took the pages containing tables from the training set, kept only the table labels, and trained a table detector. They then fine-tuned it for 200 iterations on the 170 sample pages the competition provides, and finally evaluated it on the official 238-page test set with the official tools. The image-input methods from the paper's Table IV:

MethodPrecisionRecallF1
Faster R-CNN (PubLayNet pretrained)0.9720.9640.968
Mask R-CNN (PubLayNet pretrained)0.9400.9550.947
DeepDeSRT (Schreiber et al., 2017)0.9740.9620.968
Tran et al. (2015)0.9520.9640.958

Faster R-CNN's F1 is the same 0.968 as DeepDeSRT's. The difference is that DeepDeSRT was fine-tuned on 1,600 images, starting from a general object detection model, while the PubLayNet-pretrained version used only 170 pages.

This is the most convincing set of numbers in the paper. Note, though, that it ties rather than beats the earlier result, and that Mask R-CNN actually does worse (0.947).

A Different Kind of Document

The third experiment puts the models to work on U.S. health insurance plan descriptions (Summary Plan Description, SPD). Each insurer typesets these documents its own way, the formats are all over the place, and they look nothing like academic papers.

The authors hand-labeled 20 SPD documents, 2,131 pages in all, with 9,379 text blocks, 2,500 tables and 820 lists, and used 5-fold cross-validation (16 documents for training and 4 for testing in each fold, split by document). The four approaches compared are using the PubLayNet model directly (zero-shot) and fine-tuning from PubLayNet, COCO or ImageNet initialization.

Average mAP from the paper's Table V:

ApproachFaster R-CNNMask R-CNN
PubLayNet, zero-shot0.4700.465
Fine-tuned from PubLayNet0.6410.663
Fine-tuned from COCO0.6110.620
Fine-tuned from ImageNet0.5840.602

Start with the first row. A model that scores 0.9 on PubLayNet averages only 0.47 when used directly on insurance plans. The layout regularities of academic papers barely apply to insurance documents.

Now the last three rows. After fine-tuning, the PubLayNet-initialized version is best, 3 to 4 percentage points above COCO and about 6 above ImageNet. A model that has seen lots of documents really is a better starting point.

There are exceptions, though. Broken down by class, Faster R-CNN detects tables better from COCO initialization (0.560) than from PubLayNet initialization (0.541), and Mask R-CNN on tables is only slightly ahead (0.596 vs 0.588). The authors explain that insurance plan tables look too different from academic paper tables for PubLayNet's table knowledge to carry over.

Only One Kind of Document

In their discussion the authors admit that PubLayNet is made up entirely of scientific literature, which is its biggest limitation. By splitting by journal and capping the samples per journal, they squeezed as much variety as they could out of more than 6,500 journals, but however much academic paper layouts vary, they never break out of the "title, abstract, two-column body, figures and tables with captions" mold.

Three years later, DocLayNet, also from IBM but published by its Zurich team, put it more bluntly. PubLayNet and DocBank come only from PubMed and arXiv, their layout diversity is badly lacking, and accuracy drops noticeably when the models are applied to diverse layouts. Their answer was to go back to manual labeling: 80,863 pages from sources spanning financial reports, scientific papers, laws and regulations, government tenders, user manuals and patents.

Another problem is noise. There are several reports on GitHub, including zero-height boxes in the validation set (#17), and table labels that treat a horizontal line or a figure as a table, or box only half of a table (#25, #32). The authors' reply in #32 was candid, saying plainly that "the data set has some noise."

Automatic labeling buys scale, and the price is that users have to deal with these errors themselves. The authors' advice in #17 was to drop the whole page whenever you hit a bad box, because that page probably has other errors nobody has caught.

Where Is the Labeling Code?

By now you might be wondering whether, with the method described this clearly, you could run the same pipeline on other documents that come with XML.

You can't, because the code was never released. In 2020 someone asked about the PDF–XML matching code in issue #20, and the authors replied that it was "related to our IP protection" and couldn't be open-sourced. Asked whether they could share just the part that extracts labels from the XML, the answer was "that is what our IP lawyer told us." Asked further whether they could at least release the aligned data, the reply in early 2021 was that it still couldn't be released.

So PubLayNet is a dataset whose "method is in the paper and code is with the lawyers" (the labeling is automatic; the refusals are done by hand).

The Dataset Disappeared

PubLayNet was first hosted on Box and moved to IBM's data platform, DAX, at the end of 2019. On July 8, 2025, Antonio Jimeno Yepes, one of the authors, personally opened an issue on GitHub (#46) titled "PubLayNet dataset, no longer available from IBM DAX":

IBM does not seem to be providing an alternative location. This means that the data set is no longer available.

Jimeno Yepes asked everyone who had ever downloaded it to put the data on Hugging Face or contact the authors directly. Someone posted a Kaggle link, which turned out to hold only one of the seven files; eventually a Hugging Face mirror uploaded by a user in 2022 turned up, and the next day the README was changed to point there.

The ICDAR 2019 best paper, the layout dataset billed as the "largest ever," ended up surviving on community backups.

Conclusion

PubLayNet's core observation is that the PDF and the XML of the same article are each other's answer key. Match the two, filter out poorly matched pages with a 99% quality threshold, and you get layout labels for 360,000 pages and 3.5 million instances, without a single box in the training set drawn by hand.

This data lets detectors reach an mAP above 0.9 on documents of the same kind, and lets table detection tie a 1,600-page result with only 170 pages. PubTabNet later reused the same method to find tables and went on to table structure recognition. On insurance documents, zero-shot falls to 0.47, and once fine-tuned, the PubLayNet initialization is still the best of the four approaches, tables excepted.

Before using PubLayNet-pretrained weights on your own documents, run a zero-shot pass first to see how big the gap is, then decide how many pages to label for fine-tuning. Keep a particularly close eye on tables, the one class out of three that benefits least from this pretraining.

And if you have a complete copy of PubLayNet, make an extra backup.