albert.rst 4.2 KB
Newer Older
Lysandre's avatar
Lysandre committed
1
2
3
ALBERT
----------------------------------------------------

4
5
6
7
8
Overview
~~~~~~~~~~~~~~~~~~~~~

The ALBERT model was proposed in `ALBERT: A Lite BERT for Self-supervised Learning of Language Representations <https://arxiv.org/abs/1909.11942>`_
by Zhenzhong Lan, Mingda Chen, Sebastian Goodman, Kevin Gimpel, Piyush Sharma, Radu Soricut. It presents
9
two parameter-reduction techniques to lower memory consumption and increase the training speed of BERT:
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32

- Splitting the embedding matrix into two smaller matrices
- Using repeating layers split among groups

The abstract from the paper is the following:

*Increasing model size when pretraining natural language representations often results in improved performance on
downstream tasks. However, at some point further model increases become harder due to GPU/TPU memory limitations,
longer training times, and unexpected model degradation. To address these problems, we present two parameter-reduction
techniques to lower memory consumption and increase the training speed of BERT. Comprehensive empirical evidence shows
that our proposed methods lead to models that scale much better compared to the original BERT. We also use a
self-supervised loss that focuses on modeling inter-sentence coherence, and show it consistently helps downstream
tasks with multi-sentence inputs. As a result, our best model establishes new state-of-the-art results on the GLUE,
RACE, and SQuAD benchmarks while having fewer parameters compared to BERT-large.*

Tips:

- ALBERT is a model with absolute position embeddings so it's usually advised to pad the inputs on
  the right rather than the left.
- ALBERT uses repeating layers which results in a small memory footprint, however the computational cost remains
  similar to a BERT-like architecture with the same number of hidden layers as it has to iterate through the same
  number of (repeating) layers.

33
34
The original code can be found `here <https://github.com/google-research/ALBERT>`_.

35
AlbertConfig
Lysandre's avatar
Lysandre committed
36
37
38
39
40
41
~~~~~~~~~~~~~~~~~~~~~

.. autoclass:: transformers.AlbertConfig
    :members:


42
AlbertTokenizer
Lysandre's avatar
Lysandre committed
43
44
45
~~~~~~~~~~~~~~~~~~~~~

.. autoclass:: transformers.AlbertTokenizer
Lysandre Debut's avatar
Lysandre Debut committed
46
47
    :members: build_inputs_with_special_tokens, get_special_tokens_mask,
        create_token_type_ids_from_sequences, save_vocabulary
Lysandre's avatar
Lysandre committed
48
49


50
51
52
Albert specific outputs
~~~~~~~~~~~~~~~~~~~~~~~

Sylvain Gugger's avatar
Sylvain Gugger committed
53
54
55
56
.. autoclass:: transformers.modeling_albert.AlbertForPreTrainingOutput
    :members:

.. autoclass:: transformers.modeling_tf_albert.TFAlbertForPreTrainingOutput
57
58
59
    :members:


60
AlbertModel
Lysandre's avatar
Lysandre committed
61
62
63
64
65
66
~~~~~~~~~~~~~~~~~~~~

.. autoclass:: transformers.AlbertModel
    :members:


67
68
69
70
71
72
73
AlbertForPreTraining
~~~~~~~~~~~~~~~~~~~~~~~~~~

.. autoclass:: transformers.AlbertForPreTraining
    :members:


74
AlbertForMaskedLM
Lysandre's avatar
Lysandre committed
75
76
77
78
79
80
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. autoclass:: transformers.AlbertForMaskedLM
    :members:


81
AlbertForSequenceClassification
82
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Lysandre's avatar
Lysandre committed
83
84
85
86

.. autoclass:: transformers.AlbertForSequenceClassification
    :members:

87
88
89
90
91
92
93
94

AlbertForMultipleChoice
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. autoclass:: transformers.AlbertForMultipleChoice
    :members:


Sylvain Gugger's avatar
Sylvain Gugger committed
95
96
97
98
99
100
AlbertForTokenClassification
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. autoclass:: transformers.AlbertForTokenClassification
    :members:

Lysandre's avatar
Lysandre committed
101

102
AlbertForQuestionAnswering
Lysandre's avatar
Lysandre committed
103
104
105
106
107
108
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. autoclass:: transformers.AlbertForQuestionAnswering
    :members:


109
TFAlbertModel
Lysandre's avatar
Lysandre committed
110
111
112
113
114
115
~~~~~~~~~~~~~~~~~~~~

.. autoclass:: transformers.TFAlbertModel
    :members:


116
117
118
119
120
121
122
TFAlbertForPreTraining
~~~~~~~~~~~~~~~~~~~~~~~~~~

.. autoclass:: transformers.TFAlbertForPreTraining
    :members:


123
TFAlbertForMaskedLM
Lysandre's avatar
Lysandre committed
124
125
126
127
128
129
~~~~~~~~~~~~~~~~~~~~~~~~~~

.. autoclass:: transformers.TFAlbertForMaskedLM
    :members:


130
TFAlbertForSequenceClassification
Lysandre's avatar
Lysandre committed
131
132
133
134
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. autoclass:: transformers.TFAlbertForSequenceClassification
    :members:
135
136
137
138
139
140
141
142
143


TFAlbertForMultipleChoice
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. autoclass:: transformers.TFAlbertForMultipleChoice
    :members:


Sylvain Gugger's avatar
Sylvain Gugger committed
144
145
146
147
148
149
150
TFAlbertForTokenClassification
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. autoclass:: transformers.TFAlbertForTokenClassification
    :members:


151
152
153
154
155
TFAlbertForQuestionAnswering
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. autoclass:: transformers.TFAlbertForQuestionAnswering
    :members: