layoutlm.rst 3.11 KB
Newer Older
Minghao Li's avatar
Minghao Li committed
1
LayoutLM
Sylvain Gugger's avatar
Sylvain Gugger committed
2
-----------------------------------------------------------------------------------------------------------------------
Minghao Li's avatar
Minghao Li committed
3
4

Overview
Sylvain Gugger's avatar
Sylvain Gugger committed
5
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Minghao Li's avatar
Minghao Li committed
6

Sylvain Gugger's avatar
Sylvain Gugger committed
7
8
The LayoutLM model was proposed in the paper `LayoutLM: Pre-training of Text and Layout for Document Image
Understanding <https://arxiv.org/abs/1912.13318>`__ by Yiheng Xu, Minghao Li, Lei Cui, Shaohan Huang, Furu Wei, and
9
Ming Zhou. It's a simple but effective pretraining method of text and layout for document image understanding and
Sylvain Gugger's avatar
Sylvain Gugger committed
10
information extraction tasks, such as form understanding and receipt understanding.
Minghao Li's avatar
Minghao Li committed
11
12
13

The abstract from the paper is the following:

Sylvain Gugger's avatar
Sylvain Gugger committed
14
*Pre-training techniques have been verified successfully in a variety of NLP tasks in recent years. Despite the
15
widespread use of pretraining models for NLP applications, they almost exclusively focus on text-level manipulation,
Sylvain Gugger's avatar
Sylvain Gugger committed
16
17
18
19
20
while neglecting layout and style information that is vital for document image understanding. In this paper, we propose
the \textbf{LayoutLM} to jointly model interactions between text and layout information across scanned document images,
which is beneficial for a great number of real-world document image understanding tasks such as information extraction
from scanned documents. Furthermore, we also leverage image features to incorporate words' visual information into
LayoutLM. To the best of our knowledge, this is the first time that text and layout are jointly learned in a single
21
framework for document-level pretraining. It achieves new state-of-the-art results in several downstream tasks,
Sylvain Gugger's avatar
Sylvain Gugger committed
22
23
including form understanding (from 70.72 to 79.27), receipt understanding (from 94.02 to 95.24) and document image
classification (from 93.07 to 94.42).*
Minghao Li's avatar
Minghao Li committed
24
25
26
27

Tips:

- LayoutLM has an extra input called :obj:`bbox`, which is the bounding boxes of the input tokens.
Sylvain Gugger's avatar
Sylvain Gugger committed
28
29
- The :obj:`bbox` requires the data that on 0-1000 scale, which means you should normalize the bounding box before
  passing them into model.
Minghao Li's avatar
Minghao Li committed
30
31
32
33
34

The original code can be found `here <https://github.com/microsoft/unilm/tree/master/layoutlm>`_.


LayoutLMConfig
Sylvain Gugger's avatar
Sylvain Gugger committed
35
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Minghao Li's avatar
Minghao Li committed
36
37
38
39
40
41

.. autoclass:: transformers.LayoutLMConfig
    :members:


LayoutLMTokenizer
Sylvain Gugger's avatar
Sylvain Gugger committed
42
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Minghao Li's avatar
Minghao Li committed
43
44
45
46
47
48

.. autoclass:: transformers.LayoutLMTokenizer
    :members:


LayoutLMModel
Sylvain Gugger's avatar
Sylvain Gugger committed
49
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Minghao Li's avatar
Minghao Li committed
50
51
52
53
54
55

.. autoclass:: transformers.LayoutLMModel
    :members:


LayoutLMForMaskedLM
Sylvain Gugger's avatar
Sylvain Gugger committed
56
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Minghao Li's avatar
Minghao Li committed
57
58
59
60
61
62

.. autoclass:: transformers.LayoutLMForMaskedLM
    :members:


LayoutLMForTokenClassification
Sylvain Gugger's avatar
Sylvain Gugger committed
63
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Minghao Li's avatar
Minghao Li committed
64
65
66

.. autoclass:: transformers.LayoutLMForTokenClassification
    :members: