model.rst 1.36 KB
Newer Older
thomwolf's avatar
thomwolf committed
1
2
3
Models
----------------------------------------------------

Sylvain Gugger's avatar
Sylvain Gugger committed
4
5
6
The base classes :class:`~transformers.PreTrainedModel` and :class:`~transformers.TFPreTrainedModel` implement the
common methods for loading/saving a model either from a local file or directory, or from a pretrained model
configuration provided by the library (downloaded from HuggingFace's AWS S3 repository).
7

Sylvain Gugger's avatar
Sylvain Gugger committed
8
9
:class:`~transformers.PreTrainedModel` and :class:`~transformers.TFPreTrainedModel` also implement a few methods which
are common among all the models to:
10
11
12
13

- resize the input token embeddings when new tokens are added to the vocabulary
- prune the attention heads of the model.

Sylvain Gugger's avatar
Sylvain Gugger committed
14
15
16
17
The other methods that are common to each model are defined in :class:`~transformers.modeling_utils.ModuleUtilsMixin`
(for the PyTorch models) and :class:`~transformers.modeling_tf_utils.TFModuleUtilsMixin` (for the TensorFlow models).


thomwolf's avatar
thomwolf committed
18
19
20
``PreTrainedModel``
~~~~~~~~~~~~~~~~~~~~~

21
.. autoclass:: transformers.PreTrainedModel
thomwolf's avatar
thomwolf committed
22
    :members:
LysandreJik's avatar
LysandreJik committed
23

Patrick von Platen's avatar
Patrick von Platen committed
24

Sylvain Gugger's avatar
Sylvain Gugger committed
25
26
27
28
29
30
``ModuleUtilsMixin``
~~~~~~~~~~~~~~~~~~~~

.. autoclass:: transformers.modeling_utils.ModuleUtilsMixin
    :members:

Patrick von Platen's avatar
Patrick von Platen committed
31

LysandreJik's avatar
LysandreJik committed
32
33
34
``TFPreTrainedModel``
~~~~~~~~~~~~~~~~~~~~~

35
.. autoclass:: transformers.TFPreTrainedModel
LysandreJik's avatar
LysandreJik committed
36
    :members:
Sylvain Gugger's avatar
Sylvain Gugger committed
37
38
39
40
41
42
43


``TFModelUtilsMixin``
~~~~~~~~~~~~~~~~~~~~~

.. autoclass:: transformers.modeling_tf_utils.TFModelUtilsMixin
    :members:
Sylvain Gugger's avatar
Sylvain Gugger committed
44
45
46
47
48
49


Generative models
~~~~~~~~~~~~~~~~~

Coming soon