Source-linked AI summary

BERTgrid: Contextualized Embedding for 2D Document Representation and Understanding

Timo I. Denk, Christian Reisswig

arXiv:1909.04948v2cs.CLcs.CVcs.LG

TL;DR

Document layout can carry crucial semantic information, but conventional NLP discards it, making tasks such as tabulated-data extraction harder or sometimes impossible. BERTgrid places contextualized BERT vectors for word pieces in a 2D document grid and uses that representation as input to a fully convolutional extraction model. 65.48% ± 0.58 for [C+BERTgrid] is 6.02% (relative) above the baseline.

  • Problem

    Document layout can carry crucial semantic information, but conventional NLP discards it, making tasks such as tabulated-data extraction harder or sometimes impossible.

    Source: §1 · p. 1
  • Method

    BERTgrid places contextualized BERT vectors for word pieces in a 2D document grid and uses that representation as input to a fully convolutional extraction model.

    Source: §1 · p. 1, §2.1 · p. 2, §2.2 · p. 2
  • Results

    65.48% ± 0.58 for [C+BERTgrid] is 6.02% (relative) above the baseline.

    Source: §3.3 · p. 4
  • Takeaways & Limitations

    BERTgrid uses abundant unlabeled data to ease learning for downstream tasks such as invoice key-value extraction where layout carries semantic information.

    Source: §4 · p. 4

    BERT has access to the serialized text S, not document D; future work could use 2D positional encodings during language-model pre-training and inference.

    Source: §3.3 · p. 4

Abstract

from arXiv · show

For understanding generic documents, information like font sizes, column layout, and generally the positioning of words may carry semantic information that is crucial for solving a downstream document intelligence task. Our novel BERTgrid, which is based on Chargrid by Katti et al. (2018), represents a document as a grid of contextualized word piece embedding vectors, thereby making its spatial structure and semantics accessible to the processing neural network. The contextualized embedding vectors are retrieved from a BERT language model. We use BERTgrid in combination with a fully convolutional network on a semantic instance segmentation task for extracting fields from invoices. We demonstrate its performance on tabulated line item and document header field extraction.

1 Introduction

Document layout carries semantic information that text-only sequences discard, while processing raw pixels requires a model to learn both text and semantics. BERTgrid adds contextualized embeddings to a spatial grid and improves on Chargrid for invoice extraction.

1 Introduction

  • Document layout can carry crucial semantic information, but conventional NLP discards it and raw-pixel processing must learn text as well as semantics.Serializing a document can lose information needed for extracting tabulated data.Source: §1 · p. 1
  • Chargrid and CUTIE preserve document spatial arrangement in a grid, with reported benefits over sequential inputs for tabulated or spatially arranged text.The cited approaches construct a 2D grid of characters or words.Source: §1 · p. 1
  • BERTgrid adds contextualized word-piece embeddings to a grid document representation and evaluates it on invoice tables and headers.The embeddings come from a BERT language model pre-trained on unlabeled documents from the target domain.Source: §1 · p. 1
  • 65.48% ± 0.58 was achieved, improving on the Chargrid baseline of 61.76% ± 0.72 for invoice information extraction.The authors report significant improvements on an invoice dataset previously described by Katti et al. (2018).Source: §1 · pp. 1–2

2 Method

BERTgrid places contextualized word-piece embeddings in a spatial document grid. The resulting representation feeds a fully convolutional extraction model, with additional input variants combining character-, word-, and BERT-based representations.

2.1 BERTgrid document representation

  • The document is serialized line by line, and its word pieces are embedded in the grid using dense contextualized vectors rather than character-level one-hot encodings.The grid is constructed from word-piece positions.Source: §2.1 · p. 2
  • BERTgrid assigns contextualized BERT vectors to word-piece positions in a 2D grid, using zero vectors for background.The embedding uses the second-to-last BERT hidden layer; word pieces are associated with bounding boxes.Source: §2.1 · p. 2

2.2 Models

  • The extraction pipeline obtains words and positions, builds the BERTgrid, then feeds it to the same fully convolutional encoder-decoder and segmentation and bounding-box tasks used by Katti et al. (2018).Predicted masks and boxes are compared with the document data to obtain extracted strings.Source: §2.2 · p. 2
  • [C+BERTgrid] adds a Chargrid branch to the BERTgrid model and merges the branches by adding their hidden representations.The related [Wordgrid] and [C+Wordgrid] variants use non-contextualized word2vec embeddings trained on unlabeled invoices.Source: §2.2 · p. 2

3 Experiments

On invoice extraction, contextualized grid representations achieve the strongest reported results. The experiments also describe the datasets and metric, and note that BERT receives serialized text rather than the document representation D.

3.1 Data

  • The 12k labeled invoices are split 10k/1k/1k, with disjoint vendors across sets; a separate 700k-invoice unlabeled dataset supports BERT pre-training and word2vec embeddings.The invoices span many vendors and mixed languages, mostly English.Source: §3.1 · p. 3

3.2 Metric

  • The evaluation measure pools insertions, deletions, and modifications across the test set; it can be negative, while 1 denotes perfect extraction.The measure is described as similar to edit distance.Source: §3.2 · p. 3

3.3 Results and discussion

  • 65.48% ± 0.58 mean absolute performance for [C+BERTgrid] is 6.02% (relative) above the baseline; contextualized representations achieve the best extraction scores.[Wordgrid] performs worse on all fields, attributed to out-of-vocabulary words, while [C+Wordgrid] beats the baseline on most fields.Source: Table 1 · p. 4, §3.3 · p. 4
  • The authors assume BERTgrid's performance stems from word-piece-level embedding and contextualization; [C+Wordgrid] and [C+BERTgrid] also converge faster than [Chargrid].Words such as “avenue,” “street,” and “drive” can map to approximately the same embedding vector despite differing character-level representations.Source: §3.3 · p. 4
  • Pre-training on unlabeled invoices distills invoice-language knowledge into BERT parameters, which the authors say eases downstream extraction.They contrast BERT's capacity to capture complex dependencies with simpler non-contextualized embeddings such as word2vec.Source: §3.3 · p. 4
  • BERT receives serialized S rather than document D; the authors identify 2D positional encodings as future work for preserving layout during language-model pre-training and inference.Source: §3.3 · p. 4

4 Conclusions

BERTgrid is a contextualized, grid-based representation for 2D documents that uses unlabeled data and is reported as superior to Chargrid and Wordgrid baselines for invoice key-value extraction.

  • BERTgrid embeds word pieces with contextualized vectors in a 2D grid, using abundant unlabeled data to support downstream tasks such as invoice key-value extraction.The paper reports BERTgrid as superior to Chargrid and Wordgrid baselines.Source: §4 · p. 4
Loading 1909.04948v2…