r"""Instantiates one of the base model classes of the library
r"""Instantiates one of the base model classes of the library
from a pre-trained model configuration.
from a pre-trained model configuration.
The `from_pretrained()` method takes care of returning the correct model class instance
The `from_pretrained()` method takes care of returning the correct model class instance
...
@@ -477,11 +477,11 @@ class TFAutoModel(object):
...
@@ -477,11 +477,11 @@ class TFAutoModel(object):
classTFAutoModelForPreTraining(object):
classTFAutoModelForPreTraining(object):
r"""
r"""
:class:`~transformers.TFAutoModelForPreTraining` is a generic model class
:class:`~transformers.TFAutoModelForPreTraining` is a generic model class
that will be instantiated as one of the model classes of the library -with the architecture used for pretraining this model– when created with the `TFAutoModelForPreTraining.from_pretrained(pretrained_model_name_or_path)`
that will be instantiated as one of the model classes of the library -with the architecture used for pretraining this model– when created with the `TFAutoModelForPreTraining.from_pretrained(pretrained_model_name_or_path)`
class method.
class method.
This class cannot be instantiated using `__init__()` (throws an error).
This class cannot be instantiated using `__init__()` (throws an error).
"""
"""
def__init__(self):
def__init__(self):
...
@@ -493,7 +493,7 @@ class TFAutoModelForPreTraining(object):
...
@@ -493,7 +493,7 @@ class TFAutoModelForPreTraining(object):
@classmethod
@classmethod
deffrom_config(cls,config):
deffrom_config(cls,config):
r"""Instantiates one of the base model classes of the library
r"""Instantiates one of the base model classes of the library
from a configuration.
from a configuration.
Note:
Note:
...
@@ -532,7 +532,7 @@ class TFAutoModelForPreTraining(object):
...
@@ -532,7 +532,7 @@ class TFAutoModelForPreTraining(object):
r"""Instantiates one of the model classes of the library -with the architecture used for pretraining this model– from a pre-trained model configuration.
r"""Instantiates one of the model classes of the library -with the architecture used for pretraining this model– from a pre-trained model configuration.
The `from_pretrained()` method takes care of returning the correct model class instance
The `from_pretrained()` method takes care of returning the correct model class instance
based on the `model_type` property of the config object, or when it's missing,
based on the `model_type` property of the config object, or when it's missing,
...
@@ -630,27 +630,27 @@ class TFAutoModelForPreTraining(object):
...
@@ -630,27 +630,27 @@ class TFAutoModelForPreTraining(object):
classTFAutoModelWithLMHead(object):
classTFAutoModelWithLMHead(object):
r"""
r"""
:class:`~transformers.TFAutoModelWithLMHead` is a generic model class
:class:`~transformers.TFAutoModelWithLMHead` is a generic model class
that will be instantiated as one of the language modeling model classes of the library
that will be instantiated as one of the language modeling model classes of the library
when created with the `TFAutoModelWithLMHead.from_pretrained(pretrained_model_name_or_path)`
when created with the `TFAutoModelWithLMHead.from_pretrained(pretrained_model_name_or_path)`
class method.
class method.
The `from_pretrained()` method takes care of returning the correct model class instance
The `from_pretrained()` method takes care of returning the correct model class instance
based on the `model_type` property of the config object, or when it's missing,
based on the `model_type` property of the config object, or when it's missing,
falling back to using pattern matching on the `pretrained_model_name_or_path` string:
falling back to using pattern matching on the `pretrained_model_name_or_path` string:
@@ -252,8 +252,8 @@ class TFGPT2MainLayer(tf.keras.layers.Layer):
...
@@ -252,8 +252,8 @@ class TFGPT2MainLayer(tf.keras.layers.Layer):
self.wte.vocab_size=self.wte.weight.shape[0]
self.wte.vocab_size=self.wte.weight.shape[0]
def_prune_heads(self,heads_to_prune):
def_prune_heads(self,heads_to_prune):
"""Prunes heads of the model.
"""Prunes heads of the model.
heads_to_prune: dict of {layer_num: list of heads to prune in this layer}
heads_to_prune: dict of {layer_num: list of heads to prune in this layer}
"""
"""
raiseNotImplementedError
raiseNotImplementedError
...
@@ -417,8 +417,8 @@ class TFGPT2MainLayer(tf.keras.layers.Layer):
...
@@ -417,8 +417,8 @@ class TFGPT2MainLayer(tf.keras.layers.Layer):
classTFGPT2PreTrainedModel(TFPreTrainedModel):
classTFGPT2PreTrainedModel(TFPreTrainedModel):
"""An abstract class to handle weights initialization and
"""An abstract class to handle weights initialization and
a simple interface for downloading and loading pretrained models.
a simple interface for downloading and loading pretrained models.
"""
"""
config_class=GPT2Config
config_class=GPT2Config
...
@@ -698,34 +698,34 @@ class TFGPT2DoubleHeadsModel(TFGPT2PreTrainedModel):
...
@@ -698,34 +698,34 @@ class TFGPT2DoubleHeadsModel(TFGPT2PreTrainedModel):
training=False,
training=False,
):
):
r"""
r"""
mc_token_ids (:obj:`tf.Tensor` or :obj:`Numpy array` of shape :obj:`(batch_size, num_choices)`, `optional`, default to index of the last token of the input)
mc_token_ids (:obj:`tf.Tensor` or :obj:`Numpy array` of shape :obj:`(batch_size, num_choices)`, `optional`, default to index of the last token of the input)
Index of the classification token in each input sequence.
Index of the classification token in each input sequence.
Selected in the range ``[0, input_ids.size(-1) - 1[``.
Selected in the range ``[0, input_ids.size(-1) - 1[``.
Return:
Return:
Examples::
Examples::
>>> import tensorflow as tf
>>> import tensorflow as tf
>>> from transformers import GPT2Tokenizer, TFGPT2DoubleHeadsModel
>>> from transformers import GPT2Tokenizer, TFGPT2DoubleHeadsModel
"""An abstract class to handle weights initialization and
"""An abstract class to handle weights initialization and
a simple interface for downloading and loading pretrained models.
a simple interface for downloading and loading pretrained models.
"""
"""
config_class=OpenAIGPTConfig
config_class=OpenAIGPTConfig
...
@@ -630,31 +632,31 @@ class TFOpenAIGPTDoubleHeadsModel(TFOpenAIGPTPreTrainedModel):
...
@@ -630,31 +632,31 @@ class TFOpenAIGPTDoubleHeadsModel(TFOpenAIGPTPreTrainedModel):
training=False,
training=False,
):
):
r"""
r"""
mc_token_ids (:obj:`tf.Tensor` or :obj:`Numpy array` of shape :obj:`(batch_size, num_choices)`, `optional`, default to index of the last token of the input)
mc_token_ids (:obj:`tf.Tensor` or :obj:`Numpy array` of shape :obj:`(batch_size, num_choices)`, `optional`, default to index of the last token of the input)
Index of the classification token in each input sequence.
Index of the classification token in each input sequence.
Selected in the range ``[0, input_ids.size(-1) - 1]``.
Selected in the range ``[0, input_ids.size(-1) - 1]``.
Return:
Return:
Examples::
Examples::
>>> import tensorflow as tf
>>> import tensorflow as tf
>>> from transformers import OpenAIGPTTokenizer, TFOpenAIGPTDoubleHeadsModel
>>> from transformers import OpenAIGPTTokenizer, TFOpenAIGPTDoubleHeadsModel