auto.rst 2.67 KB
Newer Older
1
AutoClasses
thomwolf's avatar
thomwolf committed
2
-----------
thomwolf's avatar
thomwolf committed
3

4
In many cases, the architecture you want to use can be guessed from the name or the path of the pretrained model you
5
are supplying to the :obj:`from_pretrained()` method.
6
AutoClasses are here to do this job for you so that you automatically retrieve the relevant model given the name/path
7
to the pretrained weights/config/vocabulary.
thomwolf's avatar
thomwolf committed
8

9
10
Instantiating one of :class:`~transformers.AutoConfig`, :class:`~transformers.AutoModel`, and
:class:`~transformers.AutoTokenizer` will directly create a class of the relevant architecture. For instance
thomwolf's avatar
thomwolf committed
11
12


13
14
15
16
17
18
19
20
21
22
23
.. code-block:: python

    model = AutoModel.from_pretrained('bert-base-cased')

will create a model that is an instance of :class:`~transformers.BertModel`).

There is one class of :obj:`AutoModel` for each task, and for each backend (PyTorch or TensorFlow).


AutoConfig
~~~~~~~~~~
thomwolf's avatar
thomwolf committed
24

25
.. autoclass:: transformers.AutoConfig
thomwolf's avatar
thomwolf committed
26
27
28
    :members:


29
30
AutoTokenizer
~~~~~~~~~~~~~
Lysandre's avatar
Lysandre committed
31
32
33
34
35

.. autoclass:: transformers.AutoTokenizer
    :members:


36
37
AutoModel
~~~~~~~~~
thomwolf's avatar
thomwolf committed
38

39
.. autoclass:: transformers.AutoModel
thomwolf's avatar
thomwolf committed
40
41
42
    :members:


43
44
AutoModelForPreTraining
~~~~~~~~~~~~~~~~~~~~~~~
thomwolf's avatar
thomwolf committed
45
46
47
48
49

.. autoclass:: transformers.AutoModelForPreTraining
    :members:


50
51
AutoModelWithLMHead
~~~~~~~~~~~~~~~~~~~
thomwolf's avatar
thomwolf committed
52

Lysandre's avatar
Lysandre committed
53
.. autoclass:: transformers.AutoModelWithLMHead
thomwolf's avatar
thomwolf committed
54
    :members:
Lysandre's avatar
Lysandre committed
55
56


57
58
AutoModelForSequenceClassification
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Lysandre's avatar
Lysandre committed
59
60
61
62
63

.. autoclass:: transformers.AutoModelForSequenceClassification
    :members:


64
65
AutoModelForMultipleChoice
~~~~~~~~~~~~~~~~~~~~~~~~~~
Lysandre's avatar
Lysandre committed
66

67
.. autoclass:: transformers.AutoModelForMultipleChoice
Lysandre's avatar
Lysandre committed
68
69
70
    :members:


71
72
AutoModelForTokenClassification
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Lysandre's avatar
Lysandre committed
73
74
75
76

.. autoclass:: transformers.AutoModelForTokenClassification
    :members:

77
78
79
80
81
82
83
84
85
86

AutoModelForQuestionAnswering
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. autoclass:: transformers.AutoModelForQuestionAnswering
    :members:


TFAutoModel
~~~~~~~~~~~
87
88
89
90
91

.. autoclass:: transformers.TFAutoModel
    :members:


92
93
TFAutoModelForPreTraining
~~~~~~~~~~~~~~~~~~~~~~~~~
94
95
96
97
98

.. autoclass:: transformers.TFAutoModelForPreTraining
    :members:


99
100
TFAutoModelWithLMHead
~~~~~~~~~~~~~~~~~~~~~
101
102
103
104
105

.. autoclass:: transformers.TFAutoModelWithLMHead
    :members:


106
107
TFAutoModelForSequenceClassification
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
108
109
110
111
112

.. autoclass:: transformers.TFAutoModelForSequenceClassification
    :members:


113
114
TFAutoModelForMultipleChoice
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
115

116
.. autoclass:: transformers.TFAutoModelForMultipleChoice
117
118
119
    :members:


120
121
TFAutoModelForTokenClassification
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
122
123
124

.. autoclass:: transformers.TFAutoModelForTokenClassification
    :members:
125
126
127
128
129
130
131


TFAutoModelForQuestionAnswering
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. autoclass:: transformers.TFAutoModelForQuestionAnswering
    :members: