auto.rst 1.6 KB
Newer Older
thomwolf's avatar
thomwolf committed
1
2
AutoModels
-----------
thomwolf's avatar
thomwolf committed
3

thomwolf's avatar
thomwolf committed
4
5
6
7
8
9
10
11
In many cases, the architecture you want to use can be guessed from the name or the path of the pretrained model you are supplying to the ``from_pretrained`` method.

AutoClasses are here to do this job for you so that you automatically retreive the relevant model given the name/path to the pretrained weights/config/vocabulary.

There are two types of AutoClasses:

- ``AutoModel``, ``AutoConfig`` and ``AutoTokenizer``: instantiating these ones will directly create a class of the relevant architecture (ex: ``model = AutoModel.from_pretrained('bert-base-cased')`` will create a instance of ``BertModel``)
- All the others (``AutoModelWithLMHead``, ``AutoModelForSequenceClassification``...)  are standardized Auto classes for finetuning. Instantiating these will create instance of the same class (``AutoModelWithLMHead``, ``AutoModelForSequenceClassification``...) comprising (i) the relevant base model class (as mentioned just above) and (ii) a standard fine-tuning head on top, convenient for the task.
thomwolf's avatar
thomwolf committed
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27


``AutoConfig``
~~~~~~~~~~~~~~~~~~~~~

.. autoclass:: pytorch_transformers.AutoConfig
    :members:


``AutoModel``
~~~~~~~~~~~~~~~~~~~~~

.. autoclass:: pytorch_transformers.AutoModel
    :members:


thomwolf's avatar
thomwolf committed
28
29
30
31
32
33
34
35
36
37
38
39
40
41
``AutoModelWithLMHead``
~~~~~~~~~~~~~~~~~~~~~~~~~

.. autoclass:: pytorch_transformers.AutoModelWithLMHead
    :members:


``AutoModelForSequenceClassification``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. autoclass:: pytorch_transformers.AutoModelForSequenceClassification
    :members:


thomwolf's avatar
thomwolf committed
42
43
44
45
46
``AutoTokenizer``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. autoclass:: pytorch_transformers.AutoTokenizer
    :members: