Home

Awesome

DocBank

DocBank is a new large-scale dataset that is constructed using a weak supervision approach. It enables models to integrate both the textual and layout information for downstream tasks. The current DocBank dataset totally includes 500K document pages, where 400K for training, 50K for validation and 50K for testing.

News

Introduction

For document layout analysis tasks, there have been some image-based document layout datasets, while most of them are built for computer vision approaches and they are difficult to apply to NLP methods. In addition, image-based datasets mainly include the page images and the bounding boxes of large semantic structures, which are not fine-grained token-level annotations. Moreover, it is also time-consuming and labor-intensive to produce human-labeled and fine-grained token-level text block arrangement. Therefore, it is vital to leverage weak supervision to obtain fine-grained labeled documents with minimum efforts, meanwhile making the data be easily applied to any NLP and computer vision approaches.

To this end, we build the DocBank dataset, a document-level benchmark with fine-grained token-level annotations for layout analysis. Distinct from the conventional human-labeled datasets, our approach obtains high quality annotations in a simple yet effective way with weak supervision.

Statistics of DocBank

The DocBank dataset consists of 500K document pages with 12 types of semantic units.

Semantic Structure Statistics of DocBank

SplitAbstractAuthorCaptionDateEquationFigureFooterListParagraphReferenceSectionTableTitleTotal
Train25,38725,909106,7236,391161,14090,42938,48244,927398,08644,813180,77419,63821,688400,000
6.35%6.48%26.68%1.60%40.29%22.61%9.62%11.23%99.52%11.20%45.19%4.91%5.42%100.00%
Dev3,1643,28613,44379720,15411,4634,8045,60949,7595,54922,6662,3742,70850,000
6.33%6.57%26.89%1.59%40.31%22.93%9.61%11.22%99.52%11.10%45.33%4.75%5.42%100.00%
Test3,1763,27713,47683220,24411,3784,8765,55349,7625,64122,3842,5052,72950,000
6.35%6.55%26.95%1.66%40.49%22.76%9.75%11.11%99.52%11.28%44.77%5.01%5.46%100.00%
Total31,72732,472133,6428,020201,538113,27048,16256,089497,60756,003225,82424,51727,125500,000
6.35%6.49%26.73%1.60%40.31%22.65%9.63%11.22%99.52%11.20%45.16%4.90%5.43%100.00%

Year Statistics of DocBank

YearTrainDevTestALL
201465,97616.49%8,27016.54%8,11216.22%82,35816.47%
201577,87919.47%9,61719.23%9,70019.40%97,19619.44%
201687,00621.75%10,97021.94%10,99021.98%108,96621.79%
201791,58322.90%11,62323.25%11,46422.93%114,67022.93%
201877,55619.39%9,52019.04%9,73419.47%96,81019.36%
Total400,000100.00%50,000100.00%50,000100.00%500,000100.00%

Comparison of DocBank with existing document layout analysis datasets

Dataset#Pages#UnitsImage-based?Text-based?Fine-grained?Extendable?
Article Regions1009
GROTOAP2119,33422
PubLayNet364,2325
TableBank417,2341
DocBank500,00012

Baseline

As the dataset was fully annotated at token-level, we consider the document layout analysis task as a text-based sequence labeling task.

Under this setting, we evaluate three representative pre-trained language models on our dataset including BERT, RoBERTa and LayoutLM to validate the effectiveness of DocBank.

To verify the performance of the models from different modalities on DocBank, we train the Faster R-CNN model on the object detection format of DocBank and unify its output with the sequence labeling models to evaluate.

Metrics

As the inputs of our model are serialized 2-D documents, the typical BIO-tagging evaluation is not suitable for our task. The tokens of each semantic unit may discontinuously distribute in the input sequence.

In this case, we proposed a new metric, especially for text-based document layout analysis methods. For each kind of document semantic structure, we calculated their metrics individually. The definition is as follows:

<img src='Metrics.png' width=500>

Settings

Our baselines of BERT and RoBERTa are built upon the HuggingFace's Transformers while the LayoutLM baselines are implemented with the codebase in LayoutLM's official repository. We used 8 V100 GPUs with a batch size of 10 per GPU. It takes 5 hours to fine-tune 1 epoch on the 400K document pages. We used the BERT and RoBERTa tokenizers to tokenize the training samples and optimized the model with AdamW. The initial learning rate of the optimizer is 5e-5. We split the data into a max block size of N=512. We use the Detectron2 to train the Faster R-CNN model on DocBank. We use the Faster R-CNN algorithm with the ResNeXt-101 as the backbone network architecture, where the parameters are pre-trained on the ImageNet dataset.

Results

The evaluation results of BERT, RoBERTa and LayoutLM

ModelsAbstractAuthorCaptionEquationFigureFooterListParagraphReferenceSectionTableTitleMacro average
bert-base0.92940.84840.86290.81521.00000.78050.71330.96190.93100.90810.82960.94420.8770
roberta-base0.92880.86180.89440.82481.00000.80140.73530.96460.93410.93370.83890.95110.8891
layoutlm-base0.98160.85950.95970.89471.00000.89570.89480.97880.93380.95980.86330.95790.9316
bert-large0.92860.85770.86500.81771.00000.78140.69600.96190.92840.90650.83200.94300.8765
roberta-large0.94790.87240.90810.83701.00000.83920.74510.96650.93340.94070.84940.94610.8988
layoutlm-large0.97840.87830.95560.89741.00000.91460.90040.97900.93320.95960.86790.95520.9350
X1010.97170.82270.94350.89380.88120.90290.90510.96820.87980.94120.83530.91580.9051
X101 & layoutlm-base0.98150.89070.96690.94300.99900.92920.93000.98430.94370.96640.88180.95750.9478
X101 & layoutlm-large0.98020.89640.96660.94400.99940.93520.92930.98440.94300.96700.88750.95310.9488

We evaluate six models on the test set of DocBank. We notice that the LayoutLM gets the highest scores on the {abstract, author, caption, equation, figure, footer, list, paragraph, section, table, title} labels. The RoBERTa model gets the best performance on the "reference" label but the gap with the LayoutLM is very small. This indicates that the LayoutLM architecture is significantly better than the BERT and RoBERTa architecture in the document layout analysis task.

We also evaluate the ResNeXt-101 model and two ensemble models combining ResNeXt-101 and LayoutLM. The output of the ResNeXt-101 model is the bounding boxes of semantic structures. To unify the outputs of them, we mark the tokens inside each bounding box by the label of the corresponding bounding box. After that, we calculate the metrics following the above equation.

Model Zoo and Scripts

The trained models are available for download in the DocBank Model Zoo.

We provide a script to convert PDF files to the DocBank format data. You can run the PDF processing script pdf_process.py in the scripts directory. You may need to install some dependencies of this script through the pip package installer.

cd scripts
python pdf_process.py   --data_dir /path/to/pdf/directory \
                        --output_dir /path/to/data/output/directory

Get Data

**Please DO NOT re-distribute our data.**

If you use the corpus in published work, please cite it referring to the "Paper and Citation" Section.

We provide 100 samples for previewing as well as the index files of training, validation, and test sets in the indexed_files directory.

In this work, we normalize all the bounding boxes using the size of the PDF pages and scale each value into a range of 0-1000 to fit various layouts of documents.

The annotations and original document pictures of the DocBank dataset can be download from HuggingFace.

Paper and Citation

DocBank: A Benchmark Dataset for Document Layout Analysis

Minghao Li, Yiheng Xu, Lei Cui, Shaohan Huang, Furu Wei, Zhoujun Li, Ming Zhou

https://arxiv.org/abs/2006.01038

@misc{li2020docbank,
    title={DocBank: A Benchmark Dataset for Document Layout Analysis},
    author={Minghao Li and Yiheng Xu and Lei Cui and Shaohan Huang and Furu Wei and Zhoujun Li and Ming Zhou},
    year={2020},
    eprint={2006.01038},
    archivePrefix={arXiv},
    primaryClass={cs.CL}
}