<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>Key Information Extraction From Documents: Evaluation And Generator?</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Oliver Bensch</string-name>
          <email>o.bensch@student.maastrichtuniversity.nl</email>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Mirela Popa</string-name>
          <email>mirela.popa@maastrichtuniversity.nl</email>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Constantin Spille</string-name>
          <email>c.spille@kigroup.de</email>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>KI Group GmbH</institution>
        </aff>
        <aff id="aff1">
          <label>1</label>
          <institution>Maastricht University</institution>
          ,
          <addr-line>6200 MD Maastricht</addr-line>
          ,
          <country country="NL">The Netherlands</country>
        </aff>
      </contrib-group>
      <abstract>
        <p>Extracting information from documents usually relies on natural language processing methods working on one-dimensional sequences of text. In some cases, for example, for the extraction of key information from semi-structured documents, such as invoice-documents, spatial and formatting information of text are crucial to understand the contextual meaning. Convolutional neural networks are already common in computer vision models to process and extract relationships in multidimensional data. Therefore, natural language processing models have already been combined with computer vision models in the past, to bene t from e.g. positional information and to improve performance of these key information extraction models. Existing models were either trained on unpublished data sets or on an annotated collection of receipts, which did not focus on PDF-like documents. Hence, in this research project a template-based document generator was created to compare state-of-theart models for information extraction. An existing information extraction model \Chargrid" (Katti et al., 2019) was reconstructed and the impact of a bounding box regression decoder, as well as the impact of an NLP pre-processing step was evaluated for information extraction from documents. The results have shown that NLP based pre-processing is bene cial for model performance. However, the use of a bounding box regression decoder increases the model performance only for elds that do not follow a rectangular shape.</p>
      </abstract>
      <kwd-group>
        <kwd>Key Information Extraction</kwd>
        <kwd>Document Generator</kwd>
        <kwd>Bounding Box Regression Decoder</kwd>
      </kwd-group>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>-</title>
      <p>Natural language processing (NLP) methods are widely used on one-dimensional
sequences of text. In some cases, for example, in the extraction of key information
of invoice documents, spatial information such as the position of text are crucial
to understand the contextual meaning.
? Supported by organization KI Group GmbH.</p>
      <p>
        Convolutional neural networks (CNNs) are already common in computer
vision (CV) models to process and extract relationships in multidimensional
data. CV models have been already combined with NLP models in the past
[
        <xref ref-type="bibr" rid="ref4">4</xref>
        ],[
        <xref ref-type="bibr" rid="ref2">2</xref>
        ],[
        <xref ref-type="bibr" rid="ref11">11</xref>
        ], to bene t from spatial information. However, existing models were
either trained on not published data sets [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ], [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ] or on a public available annotated
collection of receipts [
        <xref ref-type="bibr" rid="ref9">9</xref>
        ], which does not focus on PDF-like documents. Therefore,
no benchmark dataset is currently available for comparing or evaluating existing
models that extract information from documents.
      </p>
      <p>
        These complex models consist of several components, such as an encoder, a
semantic segmentation and bounding box regression that are trained on di erent
targets with di erent loss functions. All this results in a substantial increase
of the model's parameters and overall training time, e.g., the addition of the
bounding box regression decoder as used in [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ] increases the trainable parameters
by over 75 %. However, a detailed analysis of the e ects of those components on
overall model performance has not been published.
      </p>
      <p>
        In this research, a template based document generator is created to
generate datasets of semi-structured documents, that can be used to compare models
for information extraction from documents. Furthermore, this research evaluates
the possible bene ts of a bounding box regression decoder as the rst step to
analyse the e ect of the individual components. As BERTgrid has shown to
improve model performance by applying a NLP pre-processing step, this research
evaluates the bene ts of an NLP pre-processing step also on a generated dataset
of invoices. Therefore, the main contribution of this work resides in providing a
comparative analysis of state-of-the-art models on a publicly available dataset
[
        <xref ref-type="bibr" rid="ref5">5</xref>
        ], [
        <xref ref-type="bibr" rid="ref6">6</xref>
        ]. The accuracy achieved on various document elds is assessed and
discussed in sections 5 and 6.
2
      </p>
    </sec>
    <sec id="sec-2">
      <title>Related Work</title>
      <p>
        Chargrid [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ] proposed a model to extract information from documents using
an auto-encoder with CNNs. This model has shown to outperform NLP based
methods on key information extraction from documents.
      </p>
      <p>
        Chargrid uses the optical character recognition engine Tesseract [
        <xref ref-type="bibr" rid="ref8">8</xref>
        ] to one-hot
encode a documents characters per pixel with a dimension added representing
the background. These pixel vectors were down-scaled and fed as an input to
the model. BERTgrid [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ] replaces the one-hot encoded character vectors by word
embeddings, generated with BERT [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ]. Bertgrid was trained and evaluated on
the same closed dataset as Chargrid and has shown to improve performance on
list elds.
      </p>
      <p>
        Another state-of-the-art model that combines CV methods with NLP
methods is CUTIE [
        <xref ref-type="bibr" rid="ref11">11</xref>
        ]. CUTIE uses Tesseract to extract textual information of a
document. The detected text is rst mapped to a table and used as an input for
their proposed CUTIE-A and CUTIE-B models. The extracted table
information is compressed by an embedding layer, followed by CNN blocks to classify
the input.
      </p>
    </sec>
    <sec id="sec-3">
      <title>Method</title>
      <sec id="sec-3-1">
        <title>Template Based Document Generator</title>
        <p>
          The generation process can be seen in gure 1. First, all information to be
extracted from each document is generated in JSON-Format [
          <xref ref-type="bibr" rid="ref7">7</xref>
          ]. In a next step,
spatial information is added to each eld, using dynamic template elements from
previously manually generated templates. These templates also add elds that
should be displayed but not extracted. The resulting blocks are converted into
PDF-documents using PyMuPDF [
          <xref ref-type="bibr" rid="ref1">1</xref>
          ]. Positional information about the elds
and their labels are stored in JSON to generate data for model training.
        </p>
        <p>
          The generated PDF-documents are available online [
          <xref ref-type="bibr" rid="ref5">5</xref>
          ]. It can be seen that the
generated documents share features to real world examples. However, especially
the list item elds follow more complex structures in the industry.
The generated PDF-Documents are pre-processed for training, as described in
the Chargrid model [
          <xref ref-type="bibr" rid="ref4">4</xref>
          ]. The second evaluated model SpaCygrid does not use
characters as an input, rather a vector representation of the words, similar to
BERTgrid [
          <xref ref-type="bibr" rid="ref2">2</xref>
          ].
In this research, the model structure presented in Chargrid [
          <xref ref-type="bibr" rid="ref4">4</xref>
          ] is evaluated. To
evaluate the performance trade-o between the models components, di erent
compositions of this model are subsequently tested.
        </p>
        <p>The presented model follows the auto-encoder structure with one encoder
and up to three decoders which are composed of several CNN blocks. The rst
decoder forms the semantic segmentation decoder, while the two others form
the bounding box regression decoder. All three decoders are based on the same
structure and can be di erentiated from each other by the last convolutional
block, ending with a speci c convolutional layer for each decoder. The semantic
segmentation decoder uses a softmax activation function with an output
dimension of 364 256 F , where F describes the amount of elds to be extracted. The
last convolutional layer of the rst bounding box regression decoder, also called
the box mask decoder, uses a softmax activation function as well, but with an
output dimension of W H (2N ). Where N describes the amount of anchors,
with one foreground and one background layer per anchor. The second decoder
of the bounding box regression decoder uses a linear activation function. The
output dimensions of this decoder are W H (4N ), where positional as well
as eld size were encoded per anchor.</p>
        <p>The full model of the Chargrid paper further follows an U-Net structure.
This step increases the training parameters for the models by nearly the factor
two. Due to the size of the models and the resulting training and evaluation
time, the impact of this step is not yet evaluated in this research.
3.4</p>
      </sec>
      <sec id="sec-3-2">
        <title>Evaluation</title>
        <p>
          The output of the semantic segmentation decoder creates prediction masks for
each eld that should be extracted. OpenCV [
          <xref ref-type="bibr" rid="ref10">10</xref>
          ] is used to extract the bounding
boxes for each prediction. Tesseract is used to extract the words of each
document, including the position and size of these words. For each eld the overlap of
the extracted words is calculated and assigned to the prediction with an overlap
of over 50 percent. To receive a percentage score of text not matching the ground
truth meta information per eld, the sum of positive results is divided by the
total occurrences.
4
        </p>
      </sec>
    </sec>
    <sec id="sec-4">
      <title>Experiments</title>
      <p>Recognition performance of ve header elds (company-name, company-address,
invoice-number, invoice-amount and invoice-date) and three line item elds
(itemname, item-quantity and item-amount) are evaluated in this work.</p>
      <p>For the experiments, ten di erent templates are designed to generate 12.000
documents (8000 training, 1000 validation, 3000 test) in total. To create varying
documents, each eld is shifted by a random o set. The font "tiro" was used
during document creation to receive a constant OCR-Engine performance. All
three models were trained and evaluated once with the in Chargrid proposed
preprocessing method and once with the SpaCy pre-processed documents. Training
took, depending on model size, between 50 to 70 epochs to fully converge with
a training time of 8 hours for the smaller models, up to 16 hours for the models
using all three decoders.</p>
    </sec>
    <sec id="sec-5">
      <title>Results</title>
      <p>The header- eld results, which can be seen in table 1, and the list item eld
results, which can be seen in table 2, show that the ground truth masks, generated
in the pre-processing step, do not reach 100 percent in all cases.</p>
      <p>This error rate can be explained due to OCR-Engine miss-classi cations.
Characters like "7" were often classi ed as "1" by Tesseract for the used font
"tiro".</p>
      <p>The highest loss in performance can be observed in the invoice-amount elds
(99,8 percent to 95,2 percent) and the item-amount elds (76,3 percent to 75
percent). These elds end often with a single currency character, which does
not reach a 50% overlap with the predicted bounding box. Furthermore, the
ndings of BERTgrid could be con rmed, as the results show that the SpaCygrid
experiments outperform the Chargrid experiments, especially for the list item
elds, where the performance is improved by over 50%. It can be seen that in
most cases, where the bounding box decoder was added to the model, the results
do not reach the accuracy of the experiments without this decoder. The
addresselds and the item-names, which do not share a rectangular shape like the other
elds, achieve better results with the box mask decoder added to the model.</p>
    </sec>
    <sec id="sec-6">
      <title>Discussion</title>
      <p>Since no dataset was available to compare models for key information extraction
from documents, the template based document generator was used to generate
a benchmark dataset with 12.000 documents using 10 dynamic templates. The
experiments have shown that this dataset can be used to train, compare and
evaluate di erent models for information extraction of invoices in PDF-format.
The model using the semantic segmentation decoder only shows the best
overall performance when trained on the generated dataset, where most elds that
should be extracted follow a rectangular shape. The bounding box regression
decoder can be bene cial for masks with more complex eld structures. This
research project could con rm the ndings of the BERTgrid paper regarding
the bene ts of a NLP based pre-processing method, as the pre-processing step
with SpaCy improved the Chargrid results. Especially the performance gap in
the extraction of list item elds between Chargrid and the ground truth masks
could be drastically reduced with a performance increasing of over 50%. The
experiments have shown that the results for a speci c eld depend on the
selected overlap threshold, which has to be adjusted to the elds content to achieve
the best performance. It could be observed that the OCR pre-processing step is
crucial for the total model performance. The limited amount of di erent
templates and the accompanying limited variation of the elds positions result in
exceptional scores which are not expected to hold in real-world scenarios.
7</p>
    </sec>
    <sec id="sec-7">
      <title>Conclusion</title>
      <p>The created dataset with the document generator is a rst step to create a
common dataset for document processing. The presented work has shown that
it can be used to train, compare and evaluate di erent models for information
extraction of invoices in PDF format. Furthermore, it was shown that the use of a
bounding box regression decoder is bene cial for masks following a more complex
structure than a rectangle. More research with di erent types of templates are
needed to further investigate at which point the bounding box regression decoder
improves performance. The bene ts of a NLP based pre-processing step could
be approved, while the performance of the OCR-Engine is crucial in extracting
information from PDF-documents.
8</p>
    </sec>
    <sec id="sec-8">
      <title>Future Work</title>
      <p>The extension of the generator with more complex and varying templates would
be the next step to improve the relevance of the generator for real-world
scenarios. It should be investigated weather a semantic enrichment of the text with
domain ontologies can improve the results of the classi cation. With more
training data and resources, the e ect of model components that have been neglected
in this work can be evaluated as well to get a deeper understanding of the
different components e ect on model performance.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          1.
          <string-name>
            <given-names>Artifex</given-names>
            <surname>Software</surname>
          </string-name>
          ,
          <string-name>
            <surname>I.</surname>
          </string-name>
          :
          <article-title>Pymupdf is a python binding for mupdf { a lightweight pdf and xps viewer</article-title>
          ., https://mupdf.com/
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          2.
          <string-name>
            <surname>Denk</surname>
            ,
            <given-names>T.I.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Reisswig</surname>
            ,
            <given-names>C.</given-names>
          </string-name>
          : Bertgrid:
          <article-title>Contextualized embedding for 2d document representation and understanding</article-title>
          . CoRR abs/
          <year>1909</year>
          .04948 (
          <year>2019</year>
          ), http://arxiv. org/abs/
          <year>1909</year>
          .04948
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          3.
          <string-name>
            <surname>Devlin</surname>
            ,
            <given-names>J.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Chang</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Lee</surname>
            ,
            <given-names>K.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Toutanova</surname>
            ,
            <given-names>K.</given-names>
          </string-name>
          :
          <article-title>BERT: pre-training of deep bidirectional transformers for language understanding</article-title>
          . CoRR abs/
          <year>1810</year>
          .04805 (
          <year>2018</year>
          ), http://arxiv.org/abs/
          <year>1810</year>
          .04805
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          4.
          <string-name>
            <surname>Katti</surname>
            ,
            <given-names>A.R.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Reisswig</surname>
            ,
            <given-names>C.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Guder</surname>
            ,
            <given-names>C.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Brarda</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Bickel</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          , Hohne, J.,
          <string-name>
            <surname>Faddoul</surname>
            ,
            <given-names>J.B.</given-names>
          </string-name>
          :
          <article-title>Chargrid: Towards understanding 2d documents</article-title>
          . CoRR abs/
          <year>1809</year>
          .08799 (
          <year>2018</year>
          ), http://arxiv.org/abs/
          <year>1809</year>
          .08799
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          5.
          <string-name>
            <given-names>Oliver</given-names>
            <surname>Bensch</surname>
          </string-name>
          , Mirela Popa,
          <string-name>
            <surname>C.S.:</surname>
          </string-name>
          <article-title>Annotated invoice dataset</article-title>
          , https://drive. google.com/drive/folders/1ZSCW_LthTHUpigIDgfijLOR5ZSbksg_g
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          6.
          <string-name>
            <given-names>Oliver</given-names>
            <surname>Bensch</surname>
          </string-name>
          , Mirela Popa,
          <string-name>
            <surname>C.S.</surname>
          </string-name>
          :
          <article-title>Key information extraction from documents repository</article-title>
          , https://github.com/obensch/DocumentInformationExtraction
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          7.
          <string-name>
            <surname>Pezoa</surname>
            ,
            <given-names>F.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Reutter</surname>
            ,
            <given-names>J.L.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Suarez</surname>
            ,
            <given-names>F.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Ugarte</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Vrgoc</surname>
            ,
            <given-names>D.</given-names>
          </string-name>
          :
          <article-title>Foundations of json schema</article-title>
          . p.
          <volume>263</volume>
          {
          <fpage>273</fpage>
          . WWW '
          <volume>16</volume>
          ,
          <string-name>
            <surname>Int</surname>
          </string-name>
          .
          <source>World Wide Web Conferences Steering Committee</source>
          (
          <year>2016</year>
          ), https://doi.org/10.1145/2872427.2883029
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          8.
          <string-name>
            <surname>Smith</surname>
            ,
            <given-names>R.:</given-names>
          </string-name>
          <article-title>An overview of the tesseract ocr engine</article-title>
          .
          <source>In: Ninth Int. Conf. on Document Analysis and Recognition (ICDAR</source>
          <year>2007</year>
          ). vol.
          <volume>2</volume>
          , pp.
          <volume>629</volume>
          {
          <issue>633</issue>
          (
          <year>2007</year>
          ). https://doi.org/10.1109/ICDAR.
          <year>2007</year>
          .4376991
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          9. SROIE:
          <article-title>Icdar 2019 robust reading challenge on scanned receipts ocr and information extraction</article-title>
          , https://rrc.cvc.uab.es/?ch=
          <fpage>13</fpage>
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          10.
          <string-name>
            <surname>team</surname>
          </string-name>
          , O.:
          <article-title>Opencv (open source computer vision library) is an open source computer vision and machine learning software library</article-title>
          ., https://opencv.org
        </mixed-citation>
      </ref>
      <ref id="ref11">
        <mixed-citation>
          11.
          <string-name>
            <surname>Zhao</surname>
            ,
            <given-names>X.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Wu</surname>
            ,
            <given-names>Z.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Wang</surname>
            ,
            <given-names>X.</given-names>
          </string-name>
          :
          <article-title>CUTIE: learning to understand documents with convolutional universal text information extractor</article-title>
          . CoRR abs/
          <year>1903</year>
          .12363 (
          <year>2019</year>
          ), http://arxiv.org/abs/
          <year>1903</year>
          .12363
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>