Learning to Extract Semantic Structure from Documents Using Multimodal Fully Convolutional Neural Network
- Publication
- CVPR 2017Conference
- First submitted to arXiv
- arXiv:1706.02337
Cite this paper · BibTeX
The citation identifies the linked source version. It cites the original paper and its authors.
@misc{documentunderstandingmfcn2017,
title = {{Learning to Extract Semantic Structure from Documents Using Multimodal Fully Convolutional Neural Network}},
author = {Xiao Yang and Ersin Yumer and Paul Asente and Mike Kraley and Daniel Kifer and C. Lee Giles},
year = {2017},
eprint = {1706.02337},
archivePrefix = {arXiv},
url = {https://arxiv.org/abs/1706.02337}
}
Open a PDF, and in less than a second your eyes know which part is the title, which is the body text, and which line is the caption under a figure.
A computer has a much harder time. To break a page into "paragraphs, section headings, lists, figures, tables, captions," most approaches before 2017 took two steps. First look at appearance, separating text regions from figures, tables and lines; then look at meaning, splitting the text regions into paragraphs, headings and captions. The first step is called page segmentation and the second logical structure analysis, and each comes with its own set of rules and hand-crafted features.
This paper comes from Penn State and Adobe; the first author, Xiao Yang, was interning at Adobe Research at the time. For Adobe this is a very practical problem, since all kinds of PDFs are exactly what Acrobat handles every day. The authors wanted a single fully convolutional network to do both steps at once, and, besides looking at the pixels, to read the text.
Defining the Problem
The authors call this task document semantic structure extraction (DSSE) and treat it as per-pixel classification. Each pixel is labeled as one of seven classes: background, figure, table, paragraph, section heading, list, and caption. At heart it is semantic segmentation.
So why not just take an off-the-shelf segmentation network? Look at the authors' example first:

The top row, (a), shows how "reading only the text goes wrong." The red box in all three images says Stan Lee: in the first it is an article title, in the second an author, in the third a photo caption. Identical text, completely different roles, and only the font size, the position and whether there's a picture nearby tell them apart.
The bottom row, (b), is the reverse, showing how "looking only at appearance goes wrong." The URL at the bottom of the ad on the left is set in large, bold type and looks like a section heading, but it's just a URL; on the right, a few lines starting with dashes look like a list, and only reading them reveals parenthetical remarks inside one paragraph.
So a reliable system has to look at both.
The other problem is data. Per-pixel classification needs per-pixel labels, and the public layout datasets of the time had only a few hundred to a few thousand pages each. Their classes were coarse too, usually just text, figure and table, with no section headings, lists or captions. For training a large fully convolutional network, there simply wasn't enough data.
How do you squeeze text into a convolutional network? And how do you train it without labeled data? Those are the two questions this paper answers.
Solving the Problem
The Whole Model

MFCN (multimodal fully convolutional network) has four parts:
- Encoder: four dilated blocks with three rounds of 2×2 max pooling in between.
- Decoder: alternating convolution and unpooling, ending with a class for every pixel.
- Auxiliary decoder: the same structure as the decoder; it reconstructs the input and exists only during training.
- Bridge: joins the text embedding map to the decoder.
Let's walk one page through it.
A Letter-Size Page Comes In
The authors scale every input image so its long side is under 384 pixels. A Letter-size document (8.5 × 11 inches) comes out at roughly .
Pause for a moment and think about what text looks like at this resolution. 11 inches map to 384 pixels, about 35 pixels per inch; ordinary 10 pt body text is of an inch tall, which works out to less than 5 pixels.
In other words, the body text the network sees is just stripes of gray texture, with the letters almost unreadable. The appearance branch can tell "there's a block of text here," but not what that block says. That's why the text has to be fed in separately later.
The image enters the encoder, and after three poolings the feature map goes from to , , and finally .
Seeing Far Enough: The Dilated Block
Why is the encoder built from dilated blocks? The authors give a failure case:

Cyan is list and yellow is paragraph. The upper-right corner of the list was labeled as paragraph.
That's not hard to understand. What separates a list from a few paragraphs is often only the tiny bullet at the far left of each item. For a pixel on the right half of the list, if its receptive field can't reach the bullet on the left, all it sees is an ordinary line of text, no different from a paragraph.
So the encoder needs a very large receptive field. Borrowing Inception's multiple branches and dilated convolution, the authors designed the dilated block: five convolutions side by side, with dilations .
A convolution with has its three sampling points 16 cells apart, so it spans 33 cells at once. At the deepest level of the encoder, each cell of the feature map corresponds to 8 pixels of the original image, so 33 cells is 264 pixels, about 90% of our page's 297-pixel width. This one branch alone can see an entire line from left to right.
The problem at the other end is things being too small. Section headings and captions usually take up only a line or two, and a bullet is only a few pixels; as max pooling goes deeper and deeper, these details easily disappear.
The authors' answer is skip connections plus unpooling. Each time the encoder pools, it records where the maximum was; when the decoder enlarges the feature map, it puts the values back in their original positions instead of spreading them out by bilinear interpolation, and it also takes in the features of the matching encoder layer.
Painting the Text into the Image
Next comes the reading. The authors assume the document's text has already been extracted by OCR; they use Tesseract.
To make text something a convolutional network can digest, the authors turn each sentence into a vector and then "paint" it back at its position on the page.
- Word vectors: trained with skip-gram on the 2016 English Wikipedia, 128 dimensions per word; words missing from the vocabulary get a vector built from subwords.
- Sentence vectors: the average of all the word vectors in a sentence.
- Text embedding map: every pixel inside a sentence's box is filled with that sentence's 128-dimensional vector; pixels that belong to no sentence are filled with 0.
Our page thus yields a text embedding map. Pixels covered by the same sentence have exactly the same values in all 128 channels.
This map enters the decoder through the Bridge, right after the last unpooling, that is, once the feature map is back at . The two are concatenated along the channel dimension and pass through a final stretch of convolutions to produce the segmentation.
In other words, the text information joins only at the very end of the network and never goes through the encoder. We'll see in the experiments what this placement does to the results.
No Data? Make Your Own
Per-pixel labeling is too expensive, so the authors simply generate documents themselves.
The first method is writing LaTeX. With the textblock environment of the textpos package, they place paragraphs, figures, tables, captions, section headings and lists at random on a page and compile single-, double- or triple-column PDFs. Since they positioned every element themselves, the labels come for free.
The content of the elements takes some care too, because MFCN relies on text to judge roles, so the text has to "look the part":
- Paragraphs: sentences sampled at random from the 2016 English Wikipedia.
- Section headings: section names taken only from the table-of-contents block of Wikipedia pages.
- Lists: all the items in one list come from the same Wikipedia page.
- Figures and captions: MS COCO photos with their descriptions, or images from web image search with the titles shown on the search results.
- Tables: table images found by searching with all kinds of keywords.
The second method is to collect 271 real documents with complex layouts, label every region, and then randomly replace each region with one of the generated elements above. The layout structure comes from real documents, while the content and labels come from the generator.
Together, the two methods generated 135,000 pages.

Read the paragraphs on these pages closely and you'll find the sentences don't actually connect; each one was pulled from a different part of Wikipedia. For the model this is no problem. What it has to learn is "paragraph sentences look like this, section-heading sentences look like that," not what the whole paragraph is about.
Extra Lessons from Real Documents
Synthetic documents can only vary their layouts so much. The authors also designed two tasks that need no class labels, so the model can learn from real documents as well.
The reconstruction task is the auxiliary decoder's job. Let the features at encoder layer be ( is the input image), and let the auxiliary decoder reconstruct ; the loss is:
This is the usual autoencoder trick, using reconstruction to force the encoder to retain more complete information.
The consistency task is more interesting. For a PDF document, parsing its drawing commands yields a pile of object boxes. You don't know the class of each box, but you do know that what's inside a box belongs to one object and shouldn't be cut into several pieces.
Let be the feature at position , a box of size , and the average of the features inside the box:
That is, the features of the pixels in one box should all move toward the box's average. A box usually contains thousands upon thousands of pixels, so the gradient can be approximated as:
The idea is a lot like center loss in face recognition; the difference is where the "center" comes from. In center loss, the center is the average of all samples of a class across the whole dataset; here it is just the average over one box in one image, and no class needs to be known.
Training and Post-processing
Training uses Adadelta with a mini-batch size of 2. Mini-batches of synthetic and real documents alternate. Synthetic documents get all three losses; real documents get only the two unsupervised ones, reconstruction and consistency. The classes differ widely in area, with paragraphs far larger than captions, so the classification loss is weighted by each class's total pixel count.
There is also an optional post-processing step that applies only to PDFs. Acrobat's auto-tagging feature supplies candidate boxes; the class probabilities of the pixels inside each box are averaged, and the whole block is assigned the most probable class. In the synthetic-document figure, the ragged edges of the raw output turning into neat rectangles is this step at work.
Discussion
Evaluation Setup
The authors used three datasets:
- ICDAR2015: the evaluation set of a page segmentation competition, 70 pages of magazines and technical articles, focused on appearance-based classes.
- SectLabel: 40 computer science papers, 347 pages, with every text line labeled with a semantic class.
- DSSE-200: 200 pages of magazines and academic papers labeled by the authors themselves, covering all six classes: figure, table, section heading, caption, list, and paragraph.
The main metric is per-pixel IoU. Architecture choices and ablations are all done on DSSE-200.
Architecture: Unpooling Contributes the Most
The first set of experiments uses neither text nor the unsupervised tasks and compares visual architectures only, all trained from scratch and evaluated on DSSE-200. The highlights of the paper's Table 1 (IoU, %):
| Model | Change | Caption | List | Mean |
|---|---|---|---|---|
| Model1 | Bilinear upsampling, no skip | 33.8 | 57.3 | 61.4 |
| Model2 | Add skip connections | 42.4 | 58.7 | 65.4 |
| Model3 | Switch to unpooling | 60.3 | 65.9 | 71.2 |
| Model4 | All convolutions | 60.2 | 64.6 | 69.5 |
| Model5 | Dilated block | 61.0 | 66.7 | 73.0 |
Unpooling has the biggest effect. From Model2 to Model3, mean IoU jumps from 65.4 to 71.2, and caption from 42.4 to 60.3. For small things, remembering where the pooled values came from matters far more than spreading them out by interpolation.
The dilation comparison is interesting too. Model4 only swaps every convolution for a fixed , and its mean actually drops to 69.5; Model5, with a block of several dilations side by side, beats both Model3 and Model4 in all seven classes, for a mean of 73.0. The authors adjusted each model's output channels to keep the parameter counts similar, so the gap doesn't come from having more parameters.
Text: Clear Gains on Synthetic Data, Only 0.3 on Real Documents
Next, Model5 gets the text embedding map and is fine-tuned on synthetic data. Mean IoU from the paper's Table 2:
| Evaluation data | No text | OCR text | Real text |
|---|---|---|---|
| DSSE-200 | 73.0 | 73.3 | - |
| Synthetic (200 images) | 79.6 | 82.2 | 86.0 |
Start with the synthetic row. Synthetic documents come with the correct original text, so you can compare "text extracted by OCR" with "the real text." With the real text, mean IoU rises from 79.6 to 86.0, a gain of 6.4; with OCR text, the gain is 2.6. Text does help, and OCR quality does limit it.
Now the DSSE-200 row: real documents with OCR text, and the mean rises by only 0.3. Broken down, the text classes improve, with section heading 58.3 → 59.4, list 66.7 → 68.4 and paragraph 77.1 → 79.3, while caption gains only 0.1; background actually drops from 84.6 to 83.9.
The authors' explanation is that synthetic documents are simpler than DSSE-200, so OCR is more accurate on them. That's one plausible reason. Another may be the injection point. Text joins only in the last stretch of the decoder, where the 128-dimensional sentence vectors pass through just a few final convolution layers before becoming a classification, leaving little room to interact with the visual features. The paper doesn't compare different injection points, so this is only this note's conjecture.
Whatever the reason, the "Multimodal" in this paper's title is worth 0.3 percentage points on real documents.
Unsupervised Tasks: Consistency Beats Reconstruction
The paper's Table 3 compares training objectives on the model with text (DSSE-200 mean IoU):
- Classification loss only: 73.3
- Plus reconstruction: 73.9
- Plus consistency: 75.4
- Plus both: 75.9
The consistency task brings 2.1 percentage points, far more than the 0.3 from text. The object boxes in a PDF carry no class; they only tell the model which pixels belong together, and that alone is enough to make the segmentation cleaner.
Which "unlabeled real documents" the semi-supervised training used, and how many pages, is stated neither in the main text nor in the appendix. Architecture selection was also done directly on the evaluation set, DSSE-200, without a separate validation split. The gaps between these numbers deserve a bit of a discount.
Against Prior Work
Last comes the comparison with existing methods, and both comparisons change some settings.
ICDAR2015 has only appearance-based classes, so the authors changed the last layer to three classes (background, figure, text) and fine-tuned only that layer. The result is an IoU of 94.5 on non-text regions and 91.0 on text regions, above Leptonica's 84.7/86.8 and Bukhari et al.'s 90.6/90.3; the figure IoU of 77.1 is above Fernández et al.'s 70.1.
SectLabel is labeled line by line. The original method (Luong et al.) first ran OCR and text-line localization with OmniPage, then classified each line. The authors reused the same set of text-line boxes, took the average of the pixel predictions inside a box as that line's class, and computed F1:
| Method | Heading | Caption | List | Paragraph |
|---|---|---|---|---|
| Luong et al. | 0.916 | 0.781 | 0.712 | 0.969 |
| MFCN | 0.919 | 0.893 | 0.793 | 0.969 |
Captions and lists improve the most, while section headings and paragraphs are nearly unchanged. MFCN also labels figures and tables at the same time, which the original method, handling only text lines, cannot do.
Open Source
The authors' project page later moved to GitHub Pages, where it hosts the supplementary material, the code, and a download link for DSSE-200.
The code is labeled "Code (exclude postprocessing)": a Torch7 project packaged in 2018, called deconv. Open model.lua and you find a pure image network with four convolution blocks, three poolings, and unpooling with skip connections, roughly Model3 from the ablation above. Dilated blocks, the text embedding map, the reconstruction and consistency losses: not a single one is there (wasn't this supposed to be Multimodal?).
The 135,000 synthetic pages that the conclusion says would be released don't appear on the project page either. The LaTeX generator for synthetic documents does come with the code, but you have to supply the figures, tables, corpus and caption text yourself.
So if you want to reproduce this paper, you get DSSE-200 for evaluation and the skeleton of a generator, and the rest is up to you.
Later Assessments
When the LayoutLM paper mentioned this work more than two years later, it said they "only used the network to assist heuristic algorithms to classify candidate bounding boxes rather than an end-to-end approach."
That description is only half right. The post-processing that tidies the results with PDF boxes is optional, and the DSSE-200 pages aren't PDFs, so it can't even be applied to them; every DSSE-200 number in Tables 1 to 3 is raw network output. Only on SectLabel, for a fair comparison with prior work on line-level labels, were text-line boxes borrowed.
The more real limitation is that a 384-pixel input can't read text, so text can come in only through external OCR plus averaged sentence vectors, and this text branch contributes very little on real documents.
Conclusion
To sum up:
- Task: merge page segmentation and logical structure analysis into one per-pixel classification problem that labels figures, tables, paragraphs, section headings, lists and captions in a single pass.
- Architecture: unpooling with skip connections helps small regions the most, raising caption IoU from 42.4 to 60.3; a block of several dilations side by side lets the network see a whole line.
- Text: sentence vectors are painted into a embedding map that joins the decoder. On synthetic data, real text adds 6.4; on real documents with OCR, only 0.3.
- Data: 135,000 labeled pages synthesized with LaTeX, plus learning from real documents through a consistency loss on PDF object boxes, which adds 2.1 on DSSE-200.
The way this paper handles text looks crude today: a sentence averaged into one vector and stuffed in at the very end of the network. But the Stan Lee examples make the case plainly that looking at a document's layout isn't enough; you also have to read it.
As for how to read the text and where to put it, Chargrid took a different approach the following year, moving the text to the very front of the network and going all the way down to individual characters.