PubTables-1M: Towards comprehensive table extraction from unstructured documents
- Publication
- CVPR 2022Conference
- First submitted to arXiv
- arXiv:2110.00061
Cite this paper · BibTeX
The citation identifies the linked source version. It cites the original paper and its authors.
@misc{documentunderstandingpubtables1m2021,
title = {{PubTables-1M: Towards comprehensive table extraction from unstructured documents}},
author = {Brandon Smock and Rohith Pesala and Robin Abraham},
year = {2021},
eprint = {2110.00061},
archivePrefix = {arXiv},
url = {https://arxiv.org/abs/2110.00061}
}
Take a table from a paper. Its leftmost column reads “ΔSCA,” spanning four rows downward, and next to it are better, equal, worse, and Sum.
There are at least two ways to write this table in HTML. One is <td rowspan="4">ΔSCA</td>, a single cell spanning four rows; the other puts “ΔSCA” in the first row and stuffs three empty <td></td> cells underneath. The table's ruling lines aren't drawn, so the two versions look exactly the same in a browser.
To a reader it makes no difference; to a model learning table structure, it makes a big one. The first version tells the model “ΔSCA covers four rows”; the second tells it “ΔSCA covers only the first row, and the three cells below are empty.” If a dataset mixes both, tables that look the same end up with two different ground truths.
Brandon Smock, Rohith Pesala, and Robin Abraham of Microsoft call this phenomenon oversegmentation, and they measured it. In PubTabNet, 58.65% of the tables with one particular kind of subheading have at least one of those subheadings split apart; in FinTabNet, a dataset of financial-report tables, the figure is 98.87%.
Their response is a new dataset, PubTables-1M, with nearly a million tables, each first run through a cleanup called canonicalization so that tables that look the same are labeled only one way. Along the way, they also demonstrate a table model that needs no custom components, which people later came to call Table Transformer.
Defining the Problem
The authors split the job of pulling tables out of documents (table extraction) into three subtasks:

- Table detection (TD): find where the tables are on a full document page.
- Table structure recognition (TSR): work out how many columns and rows a table has and which cells are merged.
- Functional analysis (FA): tell which cells are keys and which are values, that is, column headers, row headers, and content.
Keep the light-blue rows in the right panel in mind. Rows like “Oral hygiene status” and “Caries status,” where only the first cell has text and every other cell is empty, are what the authors call a projected row header (PRH). A PRH is a shared subheading for the rows beneath it, and the 58.65% above is the share of tables where exactly this kind of row was split apart.
What Existing Data Lacked
From 2019 on, most large table datasets followed the same recipe. Find a batch of documents that come with both a PDF and a structured source file (HTML, XML, LaTeX), take the tables in the source as ground truth, then find some way to map them to positions on the PDF. TableBank has 145,000 tables, PubTabNet released 510,000, and FinTabNet has 113,000.
The authors see three gaps in these datasets.
First, incomplete location information. Source files record structure, not coordinates. FinTabNet, and the later version of PubTabNet that added coordinates, box only the cells that contain text, and only the text itself. Empty cells get no box, so information carried by whitespace, such as indentation and alignment within a cell, is lost too.
Second, no header information. Most datasets don't label column headers, and no large dataset labels row headers.
Third is the oversegmentation from the opening. Whoever wrote the source file only cared whether the printed table looked right; where the ruling lines are invisible, splitting one cell into three or writing three cells as one makes no visible difference. Used as ground truth, this causes two problems:

- It contradicts what the table means. The left panel (a) labels ΔSCA as covering only the first row, but anyone reading the table knows it covers the four rows better, equal, worse, and Sum. Teaching a model with this answer teaches it the wrong reading.
- One appearance, several answers. Even if you accept (a) as a reasonable reading, a dataset that contains both (a) and (b) gives the model contradictory feedback in training, and correct predictions can be marked wrong in evaluation.
So the question the authors set themselves is whether, without manual work, they can fill in the locations and headers of nearly a million tables and reduce the structure of each table to one unique labeling.
Solving the Problem
Align First, Then Fill In the Boxes
As with PubTabNet, the data comes from the open-access papers of PubMed Central (PMCOA). Each paper has both a PDF and an XML file, with the tables written as HTML tags inside the XML.
The first step is to line up the text on the two sides. The PDF side is broken into a long string of characters, each carrying its own box; the HTML side is another string of characters, each knowing which cell it belongs to. The authors align the two strings with the Needleman-Wunsch algorithm, a classic method for aligning DNA sequences in bioinformatics that tolerates a few mismatched characters. After alignment, the text of each cell has a location, and the union of the boxes of all the characters in a cell is what the authors call a text cell.
The second step derives every other box from the text cells:
- Table: the union of all text cells.
- Row: as wide as the table; its top and bottom come from the union of the text cells of the cells that “start or end in this row.”
- Column: as tall as the table; its left and right edges come from the union of the text cells of the cells that “start or end in this column.”
- Grid cell: the intersection of the union of the rows the cell occupies with the union of its columns.
The last one is the key. Grid cells come from intersecting rows and columns, so empty cells get boxes too. Neither PubTabNet nor FinTabNet has that.
Canonicalization: One Labeling per Table
Next comes merging the oversegmented cells. To merge them, you first have to assume what the table was “supposed to” look like.
The authors adopt the table model Wang proposed in 1996; Wang's own study found that 97% of tables fit it. Under this model, the column header and the row header are each a tree; for example, ΔSDM has three child nodes beneath it, better, equal, and Worse. From this the authors derive a few rules:
- Each tree node corresponds to exactly one cell.
- Each value is indexed by a unique set of keys, so each column of the content area corresponds to one leaf of the column-header tree, and each row to one leaf of the row-header tree.
- Internal nodes of the tree have at least two children; otherwise “a parent with only one child” and “the two merged into one cell” can't be told apart.
They also make assumptions about what causes oversegmentation. A cell gets split only when “splitting it doesn't change the appearance,” so centered text won't be split along the direction it's centered in; non-centered headers are usually split vertically, because text fills the horizontal space first and leaves more blank space below; and a PRH occupies only one row to begin with, so it can only be split horizontally.
The algorithm runs in two stages. First, fill in the headers:
- Split blank spanning cells into individual grid cells.
- If the first row starts with an empty cell, add the first row to the column header; then keep adding rows one at a time until every column has at least one complete cell that spans only that column.
- Label any row where only the first column has text and the rest are empty as a PRH.
- Below the column header, if the first column contains any spanning cell or empty cell, treat the first column as the row header.
Then merge cells:
- In the column header, merge vertically adjacent cells that span the same columns.
- In the column header, if the adjacent cells below a cell are all blank and all in the column header, merge downward; if the ones above are all blank, merge upward.
- Merge each PRH's entire row into one cell.
- In the row header, merge each cell downward with adjacent blank cells.
Walk through Figure 3. The first column, where ΔSCA sits, has empty cells below the column header, so step 4 marks the first column as the row header; step 4 of the merge stage then lets ΔSCA swallow the three empty cells below it, becoming one cell that spans four rows. The Sum column's header has an empty cell above it, and step 2 of the merge stage combines the two into one cell. The blank block in the top-left corner (which the authors call the stub head) corresponds to no header, so the authors handle it by convention, merging all blank cells in the same column.
The authors are upfront about the algorithm's scope. The rules were tuned to PMCOA's annotation habits, and other datasets may need other assumptions; the cleaned-up output isn't guaranteed to be error-free either, and the remaining errors are left to the quality checks that follow.
Automated Quality Checks
A million tables can't be inspected by hand, so the authors set up several automated gates:
- Discard tables where rows overlap rows or columns overlap columns; this usually means the alignment went wrong.
- Compare each cell's text in the XML with the text inside the grid cell on the PDF, and discard tables whose average normalized edit distance exceeds 0.05. When the two disagree, the PDF text wins.
- Every word within the table's area should fall inside some grid cell; discard tables whose average overlap ratio is below 0.9.
- Discard outlier tables with more than 100 objects.
The last check removes fewer than 0.1%. The authors stress that this is the first dataset to verify its annotations at the cell level and to be able to say what its quality guarantee is.
The Cleaned-Up Data
The structure recognition portion has 947,642 tables, split by document into training, validation, and test sets of 758,849, 94,959, and 93,834 tables; table detection has 575,000 pages.
Canonicalization changed 34.7% of the tables. Afterward, “complex” tables with spanning cells make up 52.7%; in the original annotations, only 40.1% were labeled complex. In other words, more than a tenth of the tables appeared to have no spanning cells in the original annotations when they had actually been chopped into a pile of small cells.
When comparing with other datasets, the authors can't measure all oversegmentation, because the other datasets have no header annotations. They measure only PRHs, since PRHs can be identified by rule:
| Dataset | Tables with PRH | With split PRH | Share |
|---|---|---|---|
| SciTSR | 342 | 54 | 15.79% |
| PubTabNet | 100,159 | 58,747 | 58.65% |
| FinTabNet | 25,637 | 25,348 | 98.87% |
| PubTables-1M | 153,705 | 0 | 0% |
Compiled from Table 2 of the paper. Only tables with at least five rows are counted, and the first four rows and the last row are skipped so that unannotated column headers or table footers aren't counted.
The FinTabNet row is interesting. It splits the PRH in almost every table, so internally it's actually very consistent; the trouble starts when it's mixed with other datasets. The same appearance has one answer in FinTabNet and another in PubTables-1M.
Tables as a Pile of Boxes
For the model, the authors treat all three subtasks as object detection, with images as input.
Table detection has just two classes, table and table rotated (a table rotated 90 degrees counterclockwise). Structure recognition and functional analysis are combined into one model with six classes:

- table
- table column
- table row
- table column header
- table projected row header
- table spanning cell
Grid cells don't need their own prediction. The intersection of any row with any column is a grid cell, which the authors call an implicit seventh class. These objects express hierarchy through physical overlap; for example, a spanning cell that covers several grid cells means those cells are merged.
There's a detail here. The boxes used for training are dilated. Two adjacent rows originally have a blank gap between them; the authors push each row's boundary outward until the two meet at the midline. Columns get the same treatment, and boxes of the other classes are aligned to match. The result is no gaps and no overlaps between rows, between columns, or between cells, each one butting up against the next as in the figure above.
Why do this? The paper says only that this extra padding is useful for learning. This note's reading is that a gap has no fixed width; the same two rows of text might be five pixels apart or twenty. A boundary that falls somewhere in blank space amounts to asking the model to guess a position with nothing to go on, and once pushed to the midline, every boundary has a definite answer. At scoring time, the authors pull the top and bottom edges of rows and the left and right edges of columns back in to hug the text, so the extra padding isn't counted as localization error.
The detector is DETR. The backbone is an ImageNet-pretrained ResNet-18, with six encoder and six decoder layers. Table detection uses 15 object queries and structure recognition uses 125, in each case slightly more than the largest number of objects in any single training image. One V100, 20 epochs of training, and the only data augmentation is random cropping and resizing. The only hyperparameter tuned was the learning rate, chosen from just three values. The baseline is Faster R-CNN, also with ResNet-18.
The model outputs a pile of boxes, which still have to be turned into a table. Inference adds a conflict-resolution step. If two spanning cells cover the same grid cell, for example, one of them has to be suppressed or have its box adjusted. Conceptually this is like NMS, except that “overlap” is defined by child objects rather than by pixels. Only after matching grid cells to text do you get HTML or CSV.
Where does the text come from? From the PDF's text layer, or from a separate OCR run. Table Transformer itself doesn't read text.
Discussion
Table Detection
| Model | AP | AP50 | AP75 | AR |
|---|---|---|---|---|
| Faster R-CNN | 0.825 | 0.985 | 0.927 | 0.866 |
| DETR | 0.966 | 0.995 | 0.988 | 0.981 |
Compiled from the table detection part of Table 3 of the paper.
AP50 only requires the predicted box to have an IoU above 0.5 with the ground truth, and both models are close to perfect; AP averages over IoU thresholds from 0.5 to 0.95, and the gap widens to 0.14. The authors' reading is that both models can find tables, but DETR's boxes are far more precise. The object detection metrics for structure recognition plus functional analysis follow the same pattern, with DETR at an AP of 0.912 and Faster R-CNN at 0.722.
Structure Recognition: Two Ways to Measure
Object detection AP measures whether the boxes are accurate; what structure recognition really cares about is whether the table is right. The authors use several metrics.
The strictest is AccCont, which counts a table as correct only if the text content of every cell is exactly right. More lenient is GriTS, which the authors proposed around the same time. It treats the ground truth and the prediction as matrices and and finds their most similar substructures, that is, picks some rows and some columns from each to form submatrices and of the same size, and then computes:
is the number of cells in a matrix, and is the similarity between two cells. The numerator is the sum of similarities over matched cells, multiplied by 2 and divided by the total cell count of both sides, which makes it an F-score in form. Swapping in an that compares cell topology, text content, or location gives GriTS_Top, GriTS_Con, and GriTS_Loc.
Compared with PubTabNet's TEDS, which treats a table as an HTML tree, GriTS treats the table directly as a two-dimensional grid. A table is a grid to begin with, and misaligned rows and columns show up more clearly in a matrix than in a tree.
In the results below, Acc is AccCont, and the GriTS column is GriTS_Con over all tables:
| Model | Test labels | Acc (simple) | Acc (complex) | GriTS |
|---|---|---|---|---|
| DETR-NC | original | 0.8678 | 0.5360 | 0.9761 |
| DETR-NC | canonical | 0.9349 | 0.2712 | 0.9588 |
| Faster R-CNN | canonical | 0.0867 | 0.1193 | 0.8538 |
| DETR | canonical | 0.9468 | 0.6944 | 0.9846 |
Compiled from Table 4 of the paper. DETR-NC is DETR trained on the original, non-canonicalized annotations.
This table has to be read row against row, and two things are hidden in it.
The first is the effect on training. Compare the first and last rows: each model is trained on its own set of annotations and scored on that same set. Whole-table accuracy on complex tables rises from 0.5360 to 0.6944, a gap of nearly 16 percentage points. Once the ground truth is consistent, the model learns well.
The second is the effect on evaluation. Look at the first two rows: the same DETR-NC, nothing changed except the set of test answers. Accuracy on simple tables jumps from 0.8678 to 0.9349. The authors' reading is that the original test annotations are themselves noisy, and for some tables the model actually got the answer right but was marked wrong by inconsistent ground truth.
In those same two rows, why does accuracy on complex tables drop instead, from 0.5360 to 0.2712? Because DETR-NC learned the oversegmented labeling, so of course its cells don't line up with the canonical answers. The two labelings aren't just a matter of “one is cleaner”; they are two different answers altogether.
The Faster R-CNN row shows how the metrics differ. Its GriTS is 0.8538, which doesn't look bad, yet its whole-table accuracy is only around 0.10. If a box is off by just a little, a cell's text lands in the neighboring cell, and the whole table no longer counts as correct. This note's guess is that this is also why the authors insist on reporting AccCont, since partial-credit metrics can easily make two models that are worlds apart in practice look about the same.
Limitations
The authors spell out several boundaries in the paper:
- The data consists only of PMCOA scientific papers. The canonicalization rules were also written for PMCOA's annotation habits.
- For row headers, only PRHs and the first column were inferred; full row headers weren't handled.
- Tables that span pages are out of scope.
The authors themselves later filled in the first point. Their 2023 paper Aligning benchmark datasets for table structure recognition applied the same canonicalization to FinTabNet and ICDAR-2013, leaving the model completely unchanged and fixing only the data. Whole-table accuracy on ICDAR-2013 rose from 65% to 75% for the model trained on PubTables-1M, from 42% to 65% for the one trained on FinTabNet, and from 69% to 81% for the one trained on both. These numbers agree with this paper's claim that fixing the data does more than changing the model.
Using It in Practice
The official repo is microsoft/table-transformer. It was later integrated into Hugging Face Transformers, and in August 2023 v1.1 weights were released, trained on PubTables-1M, on FinTabNet, and on both combined.
The weights came out somewhat later than the paper. When the paper went public in the fall of 2021, only the dataset was officially released. People waiting for weights on GitHub got the detection model in March 2022 and the structure recognition model only in May, and in between a third party posted its own trained version first. The dataset was originally hosted on Microsoft's Research Open Data platform; in November 2022 a permissions error made it impossible to download, the authors contacted the hosting team and heard nothing back, and so they uploaded the whole dataset to Hugging Face themselves.
The problems users run into most often all have answers in the issues:
- It doesn't read text. The official inference script doesn't run OCR; without text supplied, the output CSV and HTML have no content (#141).
- Leave a margin. The pretrained model saw table crops with a 30-pixel border added around them; crop too tightly and results get worse (#99).
- Middle rows of long tables go missing. The authors suspected 125 object queries weren't enough; users reported the same problem with fewer than 50 objects. Some eased it by stretching the table vertically, others by cutting it into pieces and merging the results, but neither is an official fix. As of late 2024, people were still asking how exactly to do the stretching (#110).
- Retraining falls short. Someone retrained on FinTabNet following the second paper and got lower scores than reported; the authors replied that the paper defines an epoch as 720,000 samples, so you need to train longer (#149).
Conclusion
The real star of PubTables-1M is the data. By aligning PDF and XML, it fills in every box, so even empty cells have locations; then, with rules derived from the tree structure of tables, it merges oversegmented cells back together so that tables that look the same have only one answer. Table Transformer shows that once the data is cleaned up, a barely tuned DETR can handle detection, structure recognition, and functional analysis at once, with whole-table accuracy on complex tables rising from 0.5360 to 0.6944.
To plug it into your own pipeline, the first step is preparing the text. The model only hands over boxes for rows, columns, and spanning cells; what's written in each cell has to be filled in from the PDF's text layer or a separate OCR pass.
That said, the cleanup rules were tuned to the annotation habits of PubMed papers. When the follow-up paper carried them over to FinTabNet and ICDAR-2013, it added several more steps beyond canonicalization to fix annotation errors and reconcile the two datasets' labeling conventions. Before applying them to layouts like financial reports or invoices, leaf through a few dozen of your own tables to see whether the rules need changing.