Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
transformers
Commits
378142af
Unverified
Commit
378142af
authored
Oct 28, 2020
by
Sylvain Gugger
Committed by
GitHub
Oct 28, 2020
Browse files
Rename add_start_docstrings_to_callable (#8120)
parent
6241c873
Changes
55
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
134 additions
and
118 deletions
+134
-118
src/transformers/modeling_layoutlm.py
src/transformers/modeling_layoutlm.py
+4
-4
src/transformers/modeling_longformer.py
src/transformers/modeling_longformer.py
+9
-7
src/transformers/modeling_lxmert.py
src/transformers/modeling_lxmert.py
+4
-4
src/transformers/modeling_mmbt.py
src/transformers/modeling_mmbt.py
+2
-2
src/transformers/modeling_mobilebert.py
src/transformers/modeling_mobilebert.py
+11
-9
src/transformers/modeling_openai.py
src/transformers/modeling_openai.py
+5
-5
src/transformers/modeling_prophetnet.py
src/transformers/modeling_prophetnet.py
+11
-6
src/transformers/modeling_rag.py
src/transformers/modeling_rag.py
+7
-7
src/transformers/modeling_reformer.py
src/transformers/modeling_reformer.py
+6
-6
src/transformers/modeling_roberta.py
src/transformers/modeling_roberta.py
+8
-8
src/transformers/modeling_squeezebert.py
src/transformers/modeling_squeezebert.py
+7
-7
src/transformers/modeling_t5.py
src/transformers/modeling_t5.py
+3
-3
src/transformers/modeling_tf_albert.py
src/transformers/modeling_tf_albert.py
+8
-8
src/transformers/modeling_tf_bart.py
src/transformers/modeling_tf_bart.py
+3
-3
src/transformers/modeling_tf_bert.py
src/transformers/modeling_tf_bert.py
+9
-9
src/transformers/modeling_tf_ctrl.py
src/transformers/modeling_tf_ctrl.py
+3
-3
src/transformers/modeling_tf_distilbert.py
src/transformers/modeling_tf_distilbert.py
+9
-7
src/transformers/modeling_tf_electra.py
src/transformers/modeling_tf_electra.py
+8
-8
src/transformers/modeling_tf_flaubert.py
src/transformers/modeling_tf_flaubert.py
+8
-3
src/transformers/modeling_tf_funnel.py
src/transformers/modeling_tf_funnel.py
+9
-9
No files found.
src/transformers/modeling_layoutlm.py
View file @
378142af
...
...
@@ -23,7 +23,7 @@ from torch.nn import CrossEntropyLoss
from
.activations
import
ACT2FN
from
.configuration_layoutlm
import
LayoutLMConfig
from
.file_utils
import
add_code_sample_docstrings
,
add_start_docstrings
,
add_start_docstrings_to_
callable
from
.file_utils
import
add_code_sample_docstrings
,
add_start_docstrings
,
add_start_docstrings_to_
model_forward
from
.modeling_outputs
import
BaseModelOutput
,
BaseModelOutputWithPooling
,
MaskedLMOutput
,
TokenClassifierOutput
from
.modeling_utils
import
(
PreTrainedModel
,
...
...
@@ -607,7 +607,7 @@ class LayoutLMModel(LayoutLMPreTrainedModel):
for
layer
,
heads
in
heads_to_prune
.
items
():
self
.
encoder
.
layer
[
layer
].
attention
.
prune_heads
(
heads
)
@
add_start_docstrings_to_
callable
(
LAYOUTLM_INPUTS_DOCSTRING
.
format
(
"(batch_size, sequence_length)"
))
@
add_start_docstrings_to_
model_forward
(
LAYOUTLM_INPUTS_DOCSTRING
.
format
(
"(batch_size, sequence_length)"
))
@
add_code_sample_docstrings
(
tokenizer_class
=
_TOKENIZER_FOR_DOC
,
checkpoint
=
"layoutlm-base-uncased"
,
...
...
@@ -744,7 +744,7 @@ class LayoutLMForMaskedLM(LayoutLMPreTrainedModel):
def
get_output_embeddings
(
self
):
return
self
.
cls
.
predictions
.
decoder
@
add_start_docstrings_to_
callable
(
LAYOUTLM_INPUTS_DOCSTRING
.
format
(
"(batch_size, sequence_length)"
))
@
add_start_docstrings_to_
model_forward
(
LAYOUTLM_INPUTS_DOCSTRING
.
format
(
"(batch_size, sequence_length)"
))
@
add_code_sample_docstrings
(
tokenizer_class
=
_TOKENIZER_FOR_DOC
,
checkpoint
=
"layoutlm-base-uncased"
,
...
...
@@ -832,7 +832,7 @@ class LayoutLMForTokenClassification(LayoutLMPreTrainedModel):
def
get_input_embeddings
(
self
):
return
self
.
layoutlm
.
embeddings
.
word_embeddings
@
add_start_docstrings_to_
callable
(
LAYOUTLM_INPUTS_DOCSTRING
.
format
(
"(batch_size, sequence_length)"
))
@
add_start_docstrings_to_
model_forward
(
LAYOUTLM_INPUTS_DOCSTRING
.
format
(
"(batch_size, sequence_length)"
))
@
add_code_sample_docstrings
(
tokenizer_class
=
_TOKENIZER_FOR_DOC
,
checkpoint
=
"layoutlm-base-uncased"
,
...
...
src/transformers/modeling_longformer.py
View file @
378142af
...
...
@@ -27,7 +27,7 @@ from .configuration_longformer import LongformerConfig
from
.file_utils
import
(
add_code_sample_docstrings
,
add_start_docstrings
,
add_start_docstrings_to_
callable
,
add_start_docstrings_to_
model_forward
,
replace_return_docstrings
,
)
from
.modeling_outputs
import
(
...
...
@@ -1181,7 +1181,7 @@ class LongformerModel(LongformerPreTrainedModel):
attention_mask
=
global_attention_mask
+
1
return
attention_mask
@
add_start_docstrings_to_
callable
(
LONGFORMER_INPUTS_DOCSTRING
.
format
(
"batch_size, sequence_length"
))
@
add_start_docstrings_to_
model_forward
(
LONGFORMER_INPUTS_DOCSTRING
.
format
(
"batch_size, sequence_length"
))
@
replace_return_docstrings
(
output_type
=
BaseModelOutputWithPooling
,
config_class
=
_CONFIG_FOR_DOC
)
def
forward
(
self
,
...
...
@@ -1308,7 +1308,7 @@ class LongformerForMaskedLM(LongformerPreTrainedModel):
def
get_output_embeddings
(
self
):
return
self
.
lm_head
.
decoder
@
add_start_docstrings_to_
callable
(
LONGFORMER_INPUTS_DOCSTRING
.
format
(
"batch_size, sequence_length"
))
@
add_start_docstrings_to_
model_forward
(
LONGFORMER_INPUTS_DOCSTRING
.
format
(
"batch_size, sequence_length"
))
@
replace_return_docstrings
(
output_type
=
MaskedLMOutput
,
config_class
=
_CONFIG_FOR_DOC
)
def
forward
(
self
,
...
...
@@ -1412,7 +1412,7 @@ class LongformerForSequenceClassification(LongformerPreTrainedModel):
self
.
init_weights
()
@
add_start_docstrings_to_
callable
(
LONGFORMER_INPUTS_DOCSTRING
.
format
(
"batch_size, sequence_length"
))
@
add_start_docstrings_to_
model_forward
(
LONGFORMER_INPUTS_DOCSTRING
.
format
(
"batch_size, sequence_length"
))
@
add_code_sample_docstrings
(
tokenizer_class
=
_TOKENIZER_FOR_DOC
,
checkpoint
=
"allenai/longformer-base-4096"
,
...
...
@@ -1521,7 +1521,7 @@ class LongformerForQuestionAnswering(LongformerPreTrainedModel):
self
.
init_weights
()
@
add_start_docstrings_to_
callable
(
LONGFORMER_INPUTS_DOCSTRING
.
format
(
"batch_size, sequence_length"
))
@
add_start_docstrings_to_
model_forward
(
LONGFORMER_INPUTS_DOCSTRING
.
format
(
"batch_size, sequence_length"
))
@
replace_return_docstrings
(
output_type
=
QuestionAnsweringModelOutput
,
config_class
=
_CONFIG_FOR_DOC
)
def
forward
(
self
,
...
...
@@ -1655,7 +1655,7 @@ class LongformerForTokenClassification(LongformerPreTrainedModel):
self
.
init_weights
()
@
add_start_docstrings_to_
callable
(
LONGFORMER_INPUTS_DOCSTRING
.
format
(
"batch_size, sequence_length"
))
@
add_start_docstrings_to_
model_forward
(
LONGFORMER_INPUTS_DOCSTRING
.
format
(
"batch_size, sequence_length"
))
@
add_code_sample_docstrings
(
tokenizer_class
=
_TOKENIZER_FOR_DOC
,
checkpoint
=
"allenai/longformer-base-4096"
,
...
...
@@ -1742,7 +1742,9 @@ class LongformerForMultipleChoice(LongformerPreTrainedModel):
self
.
init_weights
()
@
add_start_docstrings_to_callable
(
LONGFORMER_INPUTS_DOCSTRING
.
format
(
"batch_size, num_choices, sequence_length"
))
@
add_start_docstrings_to_model_forward
(
LONGFORMER_INPUTS_DOCSTRING
.
format
(
"batch_size, num_choices, sequence_length"
)
)
@
add_code_sample_docstrings
(
tokenizer_class
=
_TOKENIZER_FOR_DOC
,
checkpoint
=
"allenai/longformer-base-4096"
,
...
...
src/transformers/modeling_lxmert.py
View file @
378142af
...
...
@@ -30,7 +30,7 @@ from .file_utils import (
ModelOutput
,
add_code_sample_docstrings
,
add_start_docstrings
,
add_start_docstrings_to_
callable
,
add_start_docstrings_to_
model_forward
,
replace_return_docstrings
,
)
from
.modeling_utils
import
PreTrainedModel
...
...
@@ -893,7 +893,7 @@ class LxmertModel(LxmertPreTrainedModel):
def
set_input_embeddings
(
self
,
new_embeddings
):
self
.
embeddings
.
word_embeddings
=
new_embeddings
@
add_start_docstrings_to_
callable
(
LXMERT_INPUTS_DOCSTRING
.
format
(
"batch_size, sequence_length"
))
@
add_start_docstrings_to_
model_forward
(
LXMERT_INPUTS_DOCSTRING
.
format
(
"batch_size, sequence_length"
))
@
add_code_sample_docstrings
(
tokenizer_class
=
_TOKENIZER_FOR_DOC
,
checkpoint
=
"unc-nlp/lxmert-base-uncased"
,
...
...
@@ -1145,7 +1145,7 @@ class LxmertForPreTraining(LxmertPreTrainedModel):
return
new_qa_logit_layer
@
add_start_docstrings_to_
callable
(
LXMERT_INPUTS_DOCSTRING
.
format
(
"batch_size, sequence_length"
))
@
add_start_docstrings_to_
model_forward
(
LXMERT_INPUTS_DOCSTRING
.
format
(
"batch_size, sequence_length"
))
@
replace_return_docstrings
(
output_type
=
LxmertForPreTrainingOutput
,
config_class
=
_CONFIG_FOR_DOC
)
def
forward
(
self
,
...
...
@@ -1368,7 +1368,7 @@ class LxmertForQuestionAnswering(LxmertPreTrainedModel):
return
new_qa_logit_layer
@
add_start_docstrings_to_
callable
(
LXMERT_INPUTS_DOCSTRING
.
format
(
"batch_size, sequence_length"
))
@
add_start_docstrings_to_
model_forward
(
LXMERT_INPUTS_DOCSTRING
.
format
(
"batch_size, sequence_length"
))
@
add_code_sample_docstrings
(
tokenizer_class
=
_TOKENIZER_FOR_DOC
,
checkpoint
=
"unc-nlp/lxmert-base-uncased"
,
...
...
src/transformers/modeling_mmbt.py
View file @
378142af
...
...
@@ -20,7 +20,7 @@ import torch
import
torch.nn
as
nn
from
torch.nn
import
CrossEntropyLoss
,
MSELoss
from
.file_utils
import
add_start_docstrings
,
add_start_docstrings_to_
callable
,
replace_return_docstrings
from
.file_utils
import
add_start_docstrings
,
add_start_docstrings_to_
model_forward
,
replace_return_docstrings
from
.modeling_outputs
import
BaseModelOutputWithPooling
,
SequenceClassifierOutput
from
.modeling_utils
import
ModuleUtilsMixin
from
.utils
import
logging
...
...
@@ -187,7 +187,7 @@ class MMBTModel(nn.Module, ModuleUtilsMixin):
self
.
transformer
=
transformer
self
.
modal_encoder
=
ModalEmbeddings
(
config
,
encoder
,
transformer
.
embeddings
)
@
add_start_docstrings_to_
callable
(
MMBT_INPUTS_DOCSTRING
)
@
add_start_docstrings_to_
model_forward
(
MMBT_INPUTS_DOCSTRING
)
@
replace_return_docstrings
(
output_type
=
BaseModelOutputWithPooling
,
config_class
=
_CONFIG_FOR_DOC
)
def
forward
(
self
,
...
...
src/transformers/modeling_mobilebert.py
View file @
378142af
...
...
@@ -37,7 +37,7 @@ from .file_utils import (
ModelOutput
,
add_code_sample_docstrings
,
add_start_docstrings
,
add_start_docstrings_to_
callable
,
add_start_docstrings_to_
model_forward
,
replace_return_docstrings
,
)
from
.modeling_outputs
import
(
...
...
@@ -837,7 +837,7 @@ class MobileBertModel(MobileBertPreTrainedModel):
for
layer
,
heads
in
heads_to_prune
.
items
():
self
.
encoder
.
layer
[
layer
].
attention
.
prune_heads
(
heads
)
@
add_start_docstrings_to_
callable
(
MOBILEBERT_INPUTS_DOCSTRING
.
format
(
"batch_size, sequence_length"
))
@
add_start_docstrings_to_
model_forward
(
MOBILEBERT_INPUTS_DOCSTRING
.
format
(
"batch_size, sequence_length"
))
@
add_code_sample_docstrings
(
tokenizer_class
=
_TOKENIZER_FOR_DOC
,
checkpoint
=
"google/mobilebert-uncased"
,
...
...
@@ -970,7 +970,7 @@ class MobileBertForPreTraining(MobileBertPreTrainedModel):
if
output_embeddings
is
not
None
and
self
.
config
.
tie_word_embeddings
:
self
.
_tie_or_clone_weights
(
output_embeddings
,
self
.
get_input_embeddings
())
@
add_start_docstrings_to_
callable
(
MOBILEBERT_INPUTS_DOCSTRING
.
format
(
"batch_size, sequence_length"
))
@
add_start_docstrings_to_
model_forward
(
MOBILEBERT_INPUTS_DOCSTRING
.
format
(
"batch_size, sequence_length"
))
@
replace_return_docstrings
(
output_type
=
MobileBertForPreTrainingOutput
,
config_class
=
_CONFIG_FOR_DOC
)
def
forward
(
self
,
...
...
@@ -1088,7 +1088,7 @@ class MobileBertForMaskedLM(MobileBertPreTrainedModel):
if
output_embeddings
is
not
None
and
self
.
config
.
tie_word_embeddings
:
self
.
_tie_or_clone_weights
(
output_embeddings
,
self
.
get_input_embeddings
())
@
add_start_docstrings_to_
callable
(
MOBILEBERT_INPUTS_DOCSTRING
.
format
(
"batch_size, sequence_length"
))
@
add_start_docstrings_to_
model_forward
(
MOBILEBERT_INPUTS_DOCSTRING
.
format
(
"batch_size, sequence_length"
))
@
add_code_sample_docstrings
(
tokenizer_class
=
_TOKENIZER_FOR_DOC
,
checkpoint
=
"google/mobilebert-uncased"
,
...
...
@@ -1184,7 +1184,7 @@ class MobileBertForNextSentencePrediction(MobileBertPreTrainedModel):
self
.
init_weights
()
@
add_start_docstrings_to_
callable
(
MOBILEBERT_INPUTS_DOCSTRING
.
format
(
"batch_size, sequence_length"
))
@
add_start_docstrings_to_
model_forward
(
MOBILEBERT_INPUTS_DOCSTRING
.
format
(
"batch_size, sequence_length"
))
@
replace_return_docstrings
(
output_type
=
NextSentencePredictorOutput
,
config_class
=
_CONFIG_FOR_DOC
)
def
forward
(
self
,
...
...
@@ -1276,7 +1276,7 @@ class MobileBertForSequenceClassification(MobileBertPreTrainedModel):
self
.
init_weights
()
@
add_start_docstrings_to_
callable
(
MOBILEBERT_INPUTS_DOCSTRING
.
format
(
"batch_size, sequence_length"
))
@
add_start_docstrings_to_
model_forward
(
MOBILEBERT_INPUTS_DOCSTRING
.
format
(
"batch_size, sequence_length"
))
@
add_code_sample_docstrings
(
tokenizer_class
=
_TOKENIZER_FOR_DOC
,
checkpoint
=
"google/mobilebert-uncased"
,
...
...
@@ -1361,7 +1361,7 @@ class MobileBertForQuestionAnswering(MobileBertPreTrainedModel):
self
.
init_weights
()
@
add_start_docstrings_to_
callable
(
MOBILEBERT_INPUTS_DOCSTRING
.
format
(
"batch_size, sequence_length"
))
@
add_start_docstrings_to_
model_forward
(
MOBILEBERT_INPUTS_DOCSTRING
.
format
(
"batch_size, sequence_length"
))
@
add_code_sample_docstrings
(
tokenizer_class
=
_TOKENIZER_FOR_DOC
,
checkpoint
=
"google/mobilebert-uncased"
,
...
...
@@ -1460,7 +1460,9 @@ class MobileBertForMultipleChoice(MobileBertPreTrainedModel):
self
.
init_weights
()
@
add_start_docstrings_to_callable
(
MOBILEBERT_INPUTS_DOCSTRING
.
format
(
"batch_size, num_choices, sequence_length"
))
@
add_start_docstrings_to_model_forward
(
MOBILEBERT_INPUTS_DOCSTRING
.
format
(
"batch_size, num_choices, sequence_length"
)
)
@
add_code_sample_docstrings
(
tokenizer_class
=
_TOKENIZER_FOR_DOC
,
checkpoint
=
"google/mobilebert-uncased"
,
...
...
@@ -1555,7 +1557,7 @@ class MobileBertForTokenClassification(MobileBertPreTrainedModel):
self
.
init_weights
()
@
add_start_docstrings_to_
callable
(
MOBILEBERT_INPUTS_DOCSTRING
.
format
(
"batch_size, sequence_length"
))
@
add_start_docstrings_to_
model_forward
(
MOBILEBERT_INPUTS_DOCSTRING
.
format
(
"batch_size, sequence_length"
))
@
add_code_sample_docstrings
(
tokenizer_class
=
_TOKENIZER_FOR_DOC
,
checkpoint
=
"google/mobilebert-uncased"
,
...
...
src/transformers/modeling_openai.py
View file @
378142af
...
...
@@ -33,7 +33,7 @@ from .file_utils import (
ModelOutput
,
add_code_sample_docstrings
,
add_start_docstrings
,
add_start_docstrings_to_
callable
,
add_start_docstrings_to_
model_forward
,
replace_return_docstrings
,
)
from
.modeling_outputs
import
BaseModelOutput
,
CausalLMOutput
,
SequenceClassifierOutput
...
...
@@ -427,7 +427,7 @@ class OpenAIGPTModel(OpenAIGPTPreTrainedModel):
for
layer
,
heads
in
heads_to_prune
.
items
():
self
.
h
[
layer
].
attn
.
prune_heads
(
heads
)
@
add_start_docstrings_to_
callable
(
OPENAI_GPT_INPUTS_DOCSTRING
)
@
add_start_docstrings_to_
model_forward
(
OPENAI_GPT_INPUTS_DOCSTRING
)
@
add_code_sample_docstrings
(
tokenizer_class
=
_TOKENIZER_FOR_DOC
,
checkpoint
=
"openai-gpt"
,
...
...
@@ -543,7 +543,7 @@ class OpenAIGPTLMHeadModel(OpenAIGPTPreTrainedModel):
def
get_output_embeddings
(
self
):
return
self
.
lm_head
@
add_start_docstrings_to_
callable
(
OPENAI_GPT_INPUTS_DOCSTRING
)
@
add_start_docstrings_to_
model_forward
(
OPENAI_GPT_INPUTS_DOCSTRING
)
@
add_code_sample_docstrings
(
tokenizer_class
=
_TOKENIZER_FOR_DOC
,
checkpoint
=
"openai-gpt"
,
...
...
@@ -629,7 +629,7 @@ class OpenAIGPTDoubleHeadsModel(OpenAIGPTPreTrainedModel):
def
get_output_embeddings
(
self
):
return
self
.
lm_head
@
add_start_docstrings_to_
callable
(
OPENAI_GPT_INPUTS_DOCSTRING
)
@
add_start_docstrings_to_
model_forward
(
OPENAI_GPT_INPUTS_DOCSTRING
)
@
replace_return_docstrings
(
output_type
=
OpenAIGPTDoubleHeadsModelOutput
,
config_class
=
_CONFIG_FOR_DOC
)
def
forward
(
self
,
...
...
@@ -754,7 +754,7 @@ class OpenAIGPTForSequenceClassification(OpenAIGPTPreTrainedModel):
self
.
init_weights
()
@
add_start_docstrings_to_
callable
(
OPENAI_GPT_INPUTS_DOCSTRING
)
@
add_start_docstrings_to_
model_forward
(
OPENAI_GPT_INPUTS_DOCSTRING
)
@
add_code_sample_docstrings
(
tokenizer_class
=
_TOKENIZER_FOR_DOC
,
checkpoint
=
"openai-gpt"
,
...
...
src/transformers/modeling_prophetnet.py
View file @
378142af
...
...
@@ -25,7 +25,12 @@ from torch import Tensor, nn
from
.activations
import
ACT2FN
from
.configuration_prophetnet
import
ProphetNetConfig
from
.file_utils
import
ModelOutput
,
add_start_docstrings
,
add_start_docstrings_to_callable
,
replace_return_docstrings
from
.file_utils
import
(
ModelOutput
,
add_start_docstrings
,
add_start_docstrings_to_model_forward
,
replace_return_docstrings
,
)
from
.modeling_outputs
import
BaseModelOutput
from
.modeling_utils
import
PreTrainedModel
from
.utils
import
logging
...
...
@@ -1138,7 +1143,7 @@ class ProphetNetEncoder(ProphetNetPreTrainedModel):
def
set_input_embeddings
(
self
,
value
):
self
.
word_embeddings
=
value
@
add_start_docstrings_to_
callable
(
PROPHETNET_STANDALONE_INPUTS_DOCSTRING
)
@
add_start_docstrings_to_
model_forward
(
PROPHETNET_STANDALONE_INPUTS_DOCSTRING
)
@
replace_return_docstrings
(
output_type
=
BaseModelOutput
,
config_class
=
_CONFIG_FOR_DOC
)
def
forward
(
self
,
...
...
@@ -1254,7 +1259,7 @@ class ProphetNetDecoder(ProphetNetPreTrainedModel):
def
set_input_embeddings
(
self
,
value
):
self
.
word_embeddings
=
value
@
add_start_docstrings_to_
callable
(
PROPHETNET_STANDALONE_INPUTS_DOCSTRING
)
@
add_start_docstrings_to_
model_forward
(
PROPHETNET_STANDALONE_INPUTS_DOCSTRING
)
@
replace_return_docstrings
(
output_type
=
ProphetNetDecoderModelOutput
,
config_class
=
_CONFIG_FOR_DOC
)
def
forward
(
self
,
...
...
@@ -1570,7 +1575,7 @@ class ProphetNetModel(ProphetNetPreTrainedModel):
def
get_decoder
(
self
):
return
self
.
decoder
@
add_start_docstrings_to_
callable
(
PROPHETNET_INPUTS_DOCSTRING
)
@
add_start_docstrings_to_
model_forward
(
PROPHETNET_INPUTS_DOCSTRING
)
@
replace_return_docstrings
(
output_type
=
ProphetNetSeq2SeqModelOutput
,
config_class
=
_CONFIG_FOR_DOC
)
def
forward
(
self
,
...
...
@@ -1674,7 +1679,7 @@ class ProphetNetForConditionalGeneration(ProphetNetPreTrainedModel):
def
get_input_embeddings
(
self
):
return
self
.
prophetnet
.
word_embeddings
@
add_start_docstrings_to_
callable
(
PROPHETNET_INPUTS_DOCSTRING
)
@
add_start_docstrings_to_
model_forward
(
PROPHETNET_INPUTS_DOCSTRING
)
@
replace_return_docstrings
(
output_type
=
ProphetNetSeq2SeqLMOutput
,
config_class
=
_CONFIG_FOR_DOC
)
def
forward
(
self
,
...
...
@@ -1865,7 +1870,7 @@ class ProphetNetForCausalLM(ProphetNetPreTrainedModel):
def
get_output_embeddings
(
self
):
return
self
.
lm_head
@
add_start_docstrings_to_
callable
(
PROPHETNET_STANDALONE_INPUTS_DOCSTRING
)
@
add_start_docstrings_to_
model_forward
(
PROPHETNET_STANDALONE_INPUTS_DOCSTRING
)
@
replace_return_docstrings
(
output_type
=
ProphetNetDecoderLMOutput
,
config_class
=
_CONFIG_FOR_DOC
)
def
forward
(
self
,
...
...
src/transformers/modeling_rag.py
View file @
378142af
...
...
@@ -21,7 +21,7 @@ import torch
from
.configuration_rag
import
RagConfig
from
.configuration_utils
import
PretrainedConfig
from
.file_utils
import
add_start_docstrings_to_
callable
,
replace_return_docstrings
from
.file_utils
import
add_start_docstrings_to_
model_forward
,
replace_return_docstrings
from
.modeling_outputs
import
ModelOutput
from
.modeling_utils
import
PreTrainedModel
from
.retrieval_rag
import
RagRetriever
...
...
@@ -459,7 +459,7 @@ RAG_FORWARD_INPUTS_DOCSTRING = r"""
"""
@
add_start_docstrings_to_
callable
(
RAG_START_DOCSTRING
)
@
add_start_docstrings_to_
model_forward
(
RAG_START_DOCSTRING
)
class
RagModel
(
RagPreTrainedModel
):
def
__init__
(
self
,
...
...
@@ -502,7 +502,7 @@ class RagModel(RagPreTrainedModel):
self
.
question_encoder
=
question_encoder
self
.
generator
=
generator
@
add_start_docstrings_to_
callable
(
RAG_FORWARD_INPUTS_DOCSTRING
)
@
add_start_docstrings_to_
model_forward
(
RAG_FORWARD_INPUTS_DOCSTRING
)
@
replace_return_docstrings
(
output_type
=
RetrievAugLMOutput
,
config_class
=
_CONFIG_FOR_DOC
)
def
forward
(
self
,
...
...
@@ -658,7 +658,7 @@ class RagModel(RagPreTrainedModel):
)
@
add_start_docstrings_to_
callable
(
@
add_start_docstrings_to_
model_forward
(
"""
A RAG-sequence model impementation. It performs RAG-sequence specific marginalization in the forward pass.
"""
,
...
...
@@ -687,7 +687,7 @@ class RagSequenceForGeneration(RagPreTrainedModel):
def
set_retriever
(
self
,
retriever
:
RagRetriever
):
self
.
rag
.
retriever
=
retriever
@
add_start_docstrings_to_
callable
(
RAG_FORWARD_INPUTS_DOCSTRING
)
@
add_start_docstrings_to_
model_forward
(
RAG_FORWARD_INPUTS_DOCSTRING
)
@
replace_return_docstrings
(
output_type
=
RetrievAugLMMarginOutput
,
config_class
=
_CONFIG_FOR_DOC
)
def
forward
(
self
,
...
...
@@ -984,7 +984,7 @@ class RagSequenceForGeneration(RagPreTrainedModel):
return
output
@
add_start_docstrings_to_
callable
(
@
add_start_docstrings_to_
model_forward
(
"""
A RAG-token model impementation. It performs RAG-token specific marginalization in the forward pass.
"""
,
...
...
@@ -1080,7 +1080,7 @@ class RagTokenForGeneration(RagPreTrainedModel):
log_prob_sum
=
seq_logprobs
+
doc_logprobs
.
unsqueeze
(
-
1
).
unsqueeze
(
-
1
)
return
torch
.
logsumexp
(
log_prob_sum
,
dim
=
1
)
@
add_start_docstrings_to_
callable
(
RAG_FORWARD_INPUTS_DOCSTRING
)
@
add_start_docstrings_to_
model_forward
(
RAG_FORWARD_INPUTS_DOCSTRING
)
@
replace_return_docstrings
(
output_type
=
RetrievAugLMMarginOutput
,
config_class
=
_CONFIG_FOR_DOC
)
def
forward
(
self
,
...
...
src/transformers/modeling_reformer.py
View file @
378142af
...
...
@@ -36,7 +36,7 @@ from .file_utils import (
ModelOutput
,
add_code_sample_docstrings
,
add_start_docstrings
,
add_start_docstrings_to_
callable
,
add_start_docstrings_to_
model_forward
,
)
from
.modeling_outputs
import
CausalLMOutput
,
MaskedLMOutput
,
QuestionAnsweringModelOutput
,
SequenceClassifierOutput
from
.modeling_utils
import
PreTrainedModel
,
apply_chunking_to_forward
...
...
@@ -1991,7 +1991,7 @@ class ReformerModel(ReformerPreTrainedModel):
for
layer
,
heads
in
heads_to_prune
.
items
():
self
.
encoder
.
layer
[
layer
].
attention
.
prune_heads
(
heads
)
@
add_start_docstrings_to_
callable
(
REFORMER_INPUTS_DOCSTRING
)
@
add_start_docstrings_to_
model_forward
(
REFORMER_INPUTS_DOCSTRING
)
@
add_code_sample_docstrings
(
tokenizer_class
=
_TOKENIZER_FOR_DOC
,
checkpoint
=
"google/reformer-crime-and-punishment"
,
...
...
@@ -2195,7 +2195,7 @@ class ReformerModelWithLMHead(ReformerPreTrainedModel):
def
get_output_embeddings
(
self
):
return
self
.
lm_head
.
decoder
@
add_start_docstrings_to_
callable
(
REFORMER_INPUTS_DOCSTRING
)
@
add_start_docstrings_to_
model_forward
(
REFORMER_INPUTS_DOCSTRING
)
@
add_code_sample_docstrings
(
tokenizer_class
=
_TOKENIZER_FOR_DOC
,
checkpoint
=
"google/reformer-crime-and-punishment"
,
...
...
@@ -2309,7 +2309,7 @@ class ReformerForMaskedLM(ReformerPreTrainedModel):
def
get_output_embeddings
(
self
):
return
self
.
lm_head
.
decoder
@
add_start_docstrings_to_
callable
(
REFORMER_INPUTS_DOCSTRING
)
@
add_start_docstrings_to_
model_forward
(
REFORMER_INPUTS_DOCSTRING
)
@
add_code_sample_docstrings
(
tokenizer_class
=
_TOKENIZER_FOR_DOC
,
checkpoint
=
"google/reformer-crime-and-punishment"
,
...
...
@@ -2389,7 +2389,7 @@ class ReformerForSequenceClassification(ReformerPreTrainedModel):
self
.
init_weights
()
@
add_start_docstrings_to_
callable
(
REFORMER_INPUTS_DOCSTRING
)
@
add_start_docstrings_to_
model_forward
(
REFORMER_INPUTS_DOCSTRING
)
@
add_code_sample_docstrings
(
tokenizer_class
=
_TOKENIZER_FOR_DOC
,
checkpoint
=
"google/reformer-crime-and-punishment"
,
...
...
@@ -2491,7 +2491,7 @@ class ReformerForQuestionAnswering(ReformerPreTrainedModel):
self
.
init_weights
()
@
add_start_docstrings_to_
callable
(
REFORMER_INPUTS_DOCSTRING
)
@
add_start_docstrings_to_
model_forward
(
REFORMER_INPUTS_DOCSTRING
)
@
add_code_sample_docstrings
(
tokenizer_class
=
_TOKENIZER_FOR_DOC
,
checkpoint
=
"google/reformer-crime-and-punishment"
,
...
...
src/transformers/modeling_roberta.py
View file @
378142af
...
...
@@ -27,7 +27,7 @@ from .configuration_roberta import RobertaConfig
from
.file_utils
import
(
add_code_sample_docstrings
,
add_start_docstrings
,
add_start_docstrings_to_
callable
,
add_start_docstrings_to_
model_forward
,
replace_return_docstrings
,
)
from
.modeling_outputs
import
(
...
...
@@ -595,7 +595,7 @@ class RobertaModel(RobertaPreTrainedModel):
for
layer
,
heads
in
heads_to_prune
.
items
():
self
.
encoder
.
layer
[
layer
].
attention
.
prune_heads
(
heads
)
@
add_start_docstrings_to_
callable
(
ROBERTA_INPUTS_DOCSTRING
.
format
(
"(batch_size, sequence_length)"
))
@
add_start_docstrings_to_
model_forward
(
ROBERTA_INPUTS_DOCSTRING
.
format
(
"(batch_size, sequence_length)"
))
@
add_code_sample_docstrings
(
tokenizer_class
=
_TOKENIZER_FOR_DOC
,
checkpoint
=
"roberta-base"
,
...
...
@@ -718,7 +718,7 @@ class RobertaForCausalLM(RobertaPreTrainedModel):
def
get_output_embeddings
(
self
):
return
self
.
lm_head
.
decoder
@
add_start_docstrings_to_
callable
(
ROBERTA_INPUTS_DOCSTRING
.
format
(
"batch_size, sequence_length"
))
@
add_start_docstrings_to_
model_forward
(
ROBERTA_INPUTS_DOCSTRING
.
format
(
"batch_size, sequence_length"
))
@
replace_return_docstrings
(
output_type
=
CausalLMOutput
,
config_class
=
_CONFIG_FOR_DOC
)
def
forward
(
self
,
...
...
@@ -838,7 +838,7 @@ class RobertaForMaskedLM(RobertaPreTrainedModel):
def
get_output_embeddings
(
self
):
return
self
.
lm_head
.
decoder
@
add_start_docstrings_to_
callable
(
ROBERTA_INPUTS_DOCSTRING
.
format
(
"batch_size, sequence_length"
))
@
add_start_docstrings_to_
model_forward
(
ROBERTA_INPUTS_DOCSTRING
.
format
(
"batch_size, sequence_length"
))
@
add_code_sample_docstrings
(
tokenizer_class
=
_TOKENIZER_FOR_DOC
,
checkpoint
=
"roberta-base"
,
...
...
@@ -956,7 +956,7 @@ class RobertaForSequenceClassification(RobertaPreTrainedModel):
self
.
init_weights
()
@
add_start_docstrings_to_
callable
(
ROBERTA_INPUTS_DOCSTRING
.
format
(
"batch_size, sequence_length"
))
@
add_start_docstrings_to_
model_forward
(
ROBERTA_INPUTS_DOCSTRING
.
format
(
"batch_size, sequence_length"
))
@
add_code_sample_docstrings
(
tokenizer_class
=
_TOKENIZER_FOR_DOC
,
checkpoint
=
"roberta-base"
,
...
...
@@ -1039,7 +1039,7 @@ class RobertaForMultipleChoice(RobertaPreTrainedModel):
self
.
init_weights
()
@
add_start_docstrings_to_
callable
(
ROBERTA_INPUTS_DOCSTRING
.
format
(
"batch_size, num_choices, sequence_length"
))
@
add_start_docstrings_to_
model_forward
(
ROBERTA_INPUTS_DOCSTRING
.
format
(
"batch_size, num_choices, sequence_length"
))
@
add_code_sample_docstrings
(
tokenizer_class
=
_TOKENIZER_FOR_DOC
,
checkpoint
=
"roberta-base"
,
...
...
@@ -1133,7 +1133,7 @@ class RobertaForTokenClassification(RobertaPreTrainedModel):
self
.
init_weights
()
@
add_start_docstrings_to_
callable
(
ROBERTA_INPUTS_DOCSTRING
.
format
(
"batch_size, sequence_length"
))
@
add_start_docstrings_to_
model_forward
(
ROBERTA_INPUTS_DOCSTRING
.
format
(
"batch_size, sequence_length"
))
@
add_code_sample_docstrings
(
tokenizer_class
=
_TOKENIZER_FOR_DOC
,
checkpoint
=
"roberta-base"
,
...
...
@@ -1242,7 +1242,7 @@ class RobertaForQuestionAnswering(RobertaPreTrainedModel):
self
.
init_weights
()
@
add_start_docstrings_to_
callable
(
ROBERTA_INPUTS_DOCSTRING
.
format
(
"batch_size, sequence_length"
))
@
add_start_docstrings_to_
model_forward
(
ROBERTA_INPUTS_DOCSTRING
.
format
(
"batch_size, sequence_length"
))
@
add_code_sample_docstrings
(
tokenizer_class
=
_TOKENIZER_FOR_DOC
,
checkpoint
=
"roberta-base"
,
...
...
src/transformers/modeling_squeezebert.py
View file @
378142af
...
...
@@ -23,7 +23,7 @@ from torch.nn import CrossEntropyLoss, MSELoss
from
.activations
import
ACT2FN
from
.configuration_squeezebert
import
SqueezeBertConfig
from
.file_utils
import
add_code_sample_docstrings
,
add_start_docstrings
,
add_start_docstrings_to_
callable
from
.file_utils
import
add_code_sample_docstrings
,
add_start_docstrings
,
add_start_docstrings_to_
model_forward
from
.modeling_outputs
import
(
BaseModelOutput
,
BaseModelOutputWithPooling
,
...
...
@@ -518,7 +518,7 @@ class SqueezeBertModel(SqueezeBertPreTrainedModel):
for
layer
,
heads
in
heads_to_prune
.
items
():
self
.
encoder
.
layer
[
layer
].
attention
.
prune_heads
(
heads
)
@
add_start_docstrings_to_
callable
(
SQUEEZEBERT_INPUTS_DOCSTRING
.
format
(
"(batch_size, sequence_length)"
))
@
add_start_docstrings_to_
model_forward
(
SQUEEZEBERT_INPUTS_DOCSTRING
.
format
(
"(batch_size, sequence_length)"
))
@
add_code_sample_docstrings
(
tokenizer_class
=
_TOKENIZER_FOR_DOC
,
checkpoint
=
"squeezebert/squeezebert-mnli-headless"
,
...
...
@@ -605,7 +605,7 @@ class SqueezeBertForMaskedLM(SqueezeBertPreTrainedModel):
def
get_output_embeddings
(
self
):
return
self
.
lm_head
@
add_start_docstrings_to_
callable
(
SQUEEZEBERT_INPUTS_DOCSTRING
.
format
(
"(batch_size, sequence_length)"
))
@
add_start_docstrings_to_
model_forward
(
SQUEEZEBERT_INPUTS_DOCSTRING
.
format
(
"(batch_size, sequence_length)"
))
@
add_code_sample_docstrings
(
tokenizer_class
=
_TOKENIZER_FOR_DOC
,
checkpoint
=
"squeezebert/squeezebert-uncased"
,
...
...
@@ -683,7 +683,7 @@ class SqueezeBertForSequenceClassification(SqueezeBertPreTrainedModel):
self
.
init_weights
()
@
add_start_docstrings_to_
callable
(
SQUEEZEBERT_INPUTS_DOCSTRING
.
format
(
"(batch_size, sequence_length)"
))
@
add_start_docstrings_to_
model_forward
(
SQUEEZEBERT_INPUTS_DOCSTRING
.
format
(
"(batch_size, sequence_length)"
))
@
add_code_sample_docstrings
(
tokenizer_class
=
_TOKENIZER_FOR_DOC
,
checkpoint
=
"squeezebert/squeezebert-mnli-headless"
,
...
...
@@ -767,7 +767,7 @@ class SqueezeBertForMultipleChoice(SqueezeBertPreTrainedModel):
self
.
init_weights
()
@
add_start_docstrings_to_
callable
(
@
add_start_docstrings_to_
model_forward
(
SQUEEZEBERT_INPUTS_DOCSTRING
.
format
(
"(batch_size, num_choices, sequence_length)"
)
)
@
add_code_sample_docstrings
(
...
...
@@ -861,7 +861,7 @@ class SqueezeBertForTokenClassification(SqueezeBertPreTrainedModel):
self
.
init_weights
()
@
add_start_docstrings_to_
callable
(
SQUEEZEBERT_INPUTS_DOCSTRING
.
format
(
"(batch_size, sequence_length)"
))
@
add_start_docstrings_to_
model_forward
(
SQUEEZEBERT_INPUTS_DOCSTRING
.
format
(
"(batch_size, sequence_length)"
))
@
add_code_sample_docstrings
(
tokenizer_class
=
_TOKENIZER_FOR_DOC
,
checkpoint
=
"squeezebert/squeezebert-mnli-headless"
,
...
...
@@ -948,7 +948,7 @@ class SqueezeBertForQuestionAnswering(SqueezeBertPreTrainedModel):
self
.
init_weights
()
@
add_start_docstrings_to_
callable
(
SQUEEZEBERT_INPUTS_DOCSTRING
.
format
(
"(batch_size, sequence_length)"
))
@
add_start_docstrings_to_
model_forward
(
SQUEEZEBERT_INPUTS_DOCSTRING
.
format
(
"(batch_size, sequence_length)"
))
@
add_code_sample_docstrings
(
tokenizer_class
=
_TOKENIZER_FOR_DOC
,
checkpoint
=
"squeezebert/squeezebert-mnli-headless"
,
...
...
src/transformers/modeling_t5.py
View file @
378142af
...
...
@@ -30,7 +30,7 @@ from .file_utils import (
DUMMY_INPUTS
,
DUMMY_MASK
,
add_start_docstrings
,
add_start_docstrings_to_
callable
,
add_start_docstrings_to_
model_forward
,
replace_return_docstrings
,
)
from
.modeling_outputs
import
BaseModelOutput
,
BaseModelOutputWithPast
,
Seq2SeqLMOutput
,
Seq2SeqModelOutput
...
...
@@ -943,7 +943,7 @@ class T5Model(T5PreTrainedModel):
for
layer
,
heads
in
heads_to_prune
.
items
():
self
.
encoder
.
layer
[
layer
].
attention
.
prune_heads
(
heads
)
@
add_start_docstrings_to_
callable
(
T5_INPUTS_DOCSTRING
)
@
add_start_docstrings_to_
model_forward
(
T5_INPUTS_DOCSTRING
)
@
replace_return_docstrings
(
output_type
=
Seq2SeqModelOutput
,
config_class
=
_CONFIG_FOR_DOC
)
def
forward
(
self
,
...
...
@@ -1086,7 +1086,7 @@ class T5ForConditionalGeneration(T5PreTrainedModel):
def
get_decoder
(
self
):
return
self
.
decoder
@
add_start_docstrings_to_
callable
(
T5_INPUTS_DOCSTRING
)
@
add_start_docstrings_to_
model_forward
(
T5_INPUTS_DOCSTRING
)
@
replace_return_docstrings
(
output_type
=
Seq2SeqLMOutput
,
config_class
=
_CONFIG_FOR_DOC
)
def
forward
(
self
,
...
...
src/transformers/modeling_tf_albert.py
View file @
378142af
...
...
@@ -28,7 +28,7 @@ from .file_utils import (
ModelOutput
,
add_code_sample_docstrings
,
add_start_docstrings
,
add_start_docstrings_to_
callable
,
add_start_docstrings_to_
model_forward
,
replace_return_docstrings
,
)
from
.modeling_tf_outputs
import
(
...
...
@@ -747,7 +747,7 @@ class TFAlbertModel(TFAlbertPreTrainedModel):
super
().
__init__
(
config
,
*
inputs
,
**
kwargs
)
self
.
albert
=
TFAlbertMainLayer
(
config
,
name
=
"albert"
)
@
add_start_docstrings_to_
callable
(
ALBERT_INPUTS_DOCSTRING
.
format
(
"batch_size, sequence_length"
))
@
add_start_docstrings_to_
model_forward
(
ALBERT_INPUTS_DOCSTRING
.
format
(
"batch_size, sequence_length"
))
@
add_code_sample_docstrings
(
tokenizer_class
=
_TOKENIZER_FOR_DOC
,
checkpoint
=
"albert-base-v2"
,
...
...
@@ -778,7 +778,7 @@ class TFAlbertForPreTraining(TFAlbertPreTrainedModel):
def
get_output_embeddings
(
self
):
return
self
.
albert
.
embeddings
@
add_start_docstrings_to_
callable
(
ALBERT_INPUTS_DOCSTRING
.
format
(
"batch_size, sequence_length"
))
@
add_start_docstrings_to_
model_forward
(
ALBERT_INPUTS_DOCSTRING
.
format
(
"batch_size, sequence_length"
))
@
replace_return_docstrings
(
output_type
=
TFAlbertForPreTrainingOutput
,
config_class
=
_CONFIG_FOR_DOC
)
def
call
(
self
,
inputs
,
**
kwargs
):
r
"""
...
...
@@ -847,7 +847,7 @@ class TFAlbertForMaskedLM(TFAlbertPreTrainedModel, TFMaskedLanguageModelingLoss)
def
get_output_embeddings
(
self
):
return
self
.
albert
.
embeddings
@
add_start_docstrings_to_
callable
(
ALBERT_INPUTS_DOCSTRING
.
format
(
"batch_size, sequence_length"
))
@
add_start_docstrings_to_
model_forward
(
ALBERT_INPUTS_DOCSTRING
.
format
(
"batch_size, sequence_length"
))
@
add_code_sample_docstrings
(
tokenizer_class
=
_TOKENIZER_FOR_DOC
,
checkpoint
=
"albert-base-v2"
,
...
...
@@ -930,7 +930,7 @@ class TFAlbertForSequenceClassification(TFAlbertPreTrainedModel, TFSequenceClass
config
.
num_labels
,
kernel_initializer
=
get_initializer
(
config
.
initializer_range
),
name
=
"classifier"
)
@
add_start_docstrings_to_
callable
(
ALBERT_INPUTS_DOCSTRING
.
format
(
"batch_size, sequence_length"
))
@
add_start_docstrings_to_
model_forward
(
ALBERT_INPUTS_DOCSTRING
.
format
(
"batch_size, sequence_length"
))
@
add_code_sample_docstrings
(
tokenizer_class
=
_TOKENIZER_FOR_DOC
,
checkpoint
=
"albert-base-v2"
,
...
...
@@ -1018,7 +1018,7 @@ class TFAlbertForTokenClassification(TFAlbertPreTrainedModel, TFTokenClassificat
config
.
num_labels
,
kernel_initializer
=
get_initializer
(
config
.
initializer_range
),
name
=
"classifier"
)
@
add_start_docstrings_to_
callable
(
ALBERT_INPUTS_DOCSTRING
.
format
(
"batch_size, sequence_length"
))
@
add_start_docstrings_to_
model_forward
(
ALBERT_INPUTS_DOCSTRING
.
format
(
"batch_size, sequence_length"
))
@
add_code_sample_docstrings
(
tokenizer_class
=
_TOKENIZER_FOR_DOC
,
checkpoint
=
"albert-base-v2"
,
...
...
@@ -1104,7 +1104,7 @@ class TFAlbertForQuestionAnswering(TFAlbertPreTrainedModel, TFQuestionAnsweringL
config
.
num_labels
,
kernel_initializer
=
get_initializer
(
config
.
initializer_range
),
name
=
"qa_outputs"
)
@
add_start_docstrings_to_
callable
(
ALBERT_INPUTS_DOCSTRING
.
format
(
"batch_size, sequence_length"
))
@
add_start_docstrings_to_
model_forward
(
ALBERT_INPUTS_DOCSTRING
.
format
(
"batch_size, sequence_length"
))
@
add_code_sample_docstrings
(
tokenizer_class
=
_TOKENIZER_FOR_DOC
,
checkpoint
=
"albert-base-v2"
,
...
...
@@ -1212,7 +1212,7 @@ class TFAlbertForMultipleChoice(TFAlbertPreTrainedModel, TFMultipleChoiceLoss):
"""
return
{
"input_ids"
:
tf
.
constant
(
MULTIPLE_CHOICE_DUMMY_INPUTS
)}
@
add_start_docstrings_to_
callable
(
ALBERT_INPUTS_DOCSTRING
.
format
(
"batch_size, num_choices, sequence_length"
))
@
add_start_docstrings_to_
model_forward
(
ALBERT_INPUTS_DOCSTRING
.
format
(
"batch_size, num_choices, sequence_length"
))
@
add_code_sample_docstrings
(
tokenizer_class
=
_TOKENIZER_FOR_DOC
,
checkpoint
=
"albert-base-v2"
,
...
...
src/transformers/modeling_tf_bart.py
View file @
378142af
...
...
@@ -25,7 +25,7 @@ from tensorflow.keras.layers import Dense, LayerNormalization
from
.activations_tf
import
ACT2FN
from
.configuration_bart
import
BartConfig
from
.file_utils
import
add_start_docstrings
,
add_start_docstrings_to_
callable
,
replace_return_docstrings
from
.file_utils
import
add_start_docstrings
,
add_start_docstrings_to_
model_forward
,
replace_return_docstrings
from
.modeling_tf_outputs
import
TFBaseModelOutput
,
TFBaseModelOutputWithPast
,
TFSeq2SeqLMOutput
,
TFSeq2SeqModelOutput
# Public API
...
...
@@ -827,7 +827,7 @@ class TFBartModel(TFPretrainedBartModel):
causal_lm_mask
=
causal_attention_mask
(
tgt_len
,
tgt_len
,
mask_dtype
)
return
decoder_input_ids
,
decoder_padding_mask
,
causal_lm_mask
@
add_start_docstrings_to_
callable
(
BART_INPUTS_DOCSTRING
)
@
add_start_docstrings_to_
model_forward
(
BART_INPUTS_DOCSTRING
)
@
replace_return_docstrings
(
output_type
=
TFSeq2SeqModelOutput
,
config_class
=
_CONFIG_FOR_DOC
)
def
call
(
self
,
...
...
@@ -961,7 +961,7 @@ class TFBartForConditionalGeneration(TFPretrainedBartModel):
self
.
model
=
TFBartModel
(
config
,
name
=
"model"
)
self
.
use_cache
=
config
.
use_cache
@
add_start_docstrings_to_
callable
(
BART_INPUTS_DOCSTRING
)
@
add_start_docstrings_to_
model_forward
(
BART_INPUTS_DOCSTRING
)
@
replace_return_docstrings
(
output_type
=
TFSeq2SeqLMOutput
,
config_class
=
_CONFIG_FOR_DOC
)
def
call
(
self
,
...
...
src/transformers/modeling_tf_bert.py
View file @
378142af
...
...
@@ -28,7 +28,7 @@ from .file_utils import (
ModelOutput
,
add_code_sample_docstrings
,
add_start_docstrings
,
add_start_docstrings_to_
callable
,
add_start_docstrings_to_
model_forward
,
replace_return_docstrings
,
)
from
.modeling_tf_outputs
import
(
...
...
@@ -793,7 +793,7 @@ class TFBertModel(TFBertPreTrainedModel):
self
.
bert
=
TFBertMainLayer
(
config
,
name
=
"bert"
)
@
add_start_docstrings_to_
callable
(
BERT_INPUTS_DOCSTRING
.
format
(
"batch_size, sequence_length"
))
@
add_start_docstrings_to_
model_forward
(
BERT_INPUTS_DOCSTRING
.
format
(
"batch_size, sequence_length"
))
@
add_code_sample_docstrings
(
tokenizer_class
=
_TOKENIZER_FOR_DOC
,
checkpoint
=
"bert-base-cased"
,
...
...
@@ -824,7 +824,7 @@ class TFBertForPreTraining(TFBertPreTrainedModel):
def
get_output_embeddings
(
self
):
return
self
.
bert
.
embeddings
@
add_start_docstrings_to_
callable
(
BERT_INPUTS_DOCSTRING
.
format
(
"batch_size, sequence_length"
))
@
add_start_docstrings_to_
model_forward
(
BERT_INPUTS_DOCSTRING
.
format
(
"batch_size, sequence_length"
))
@
replace_return_docstrings
(
output_type
=
TFBertForPreTrainingOutput
,
config_class
=
_CONFIG_FOR_DOC
)
def
call
(
self
,
inputs
,
**
kwargs
):
r
"""
...
...
@@ -881,7 +881,7 @@ class TFBertForMaskedLM(TFBertPreTrainedModel, TFMaskedLanguageModelingLoss):
def
get_output_embeddings
(
self
):
return
self
.
bert
.
embeddings
@
add_start_docstrings_to_
callable
(
BERT_INPUTS_DOCSTRING
.
format
(
"batch_size, sequence_length"
))
@
add_start_docstrings_to_
model_forward
(
BERT_INPUTS_DOCSTRING
.
format
(
"batch_size, sequence_length"
))
@
add_code_sample_docstrings
(
tokenizer_class
=
_TOKENIZER_FOR_DOC
,
checkpoint
=
"bert-base-cased"
,
...
...
@@ -1043,7 +1043,7 @@ class TFBertForNextSentencePrediction(TFBertPreTrainedModel):
self
.
bert
=
TFBertMainLayer
(
config
,
name
=
"bert"
)
self
.
nsp
=
TFBertNSPHead
(
config
,
name
=
"nsp___cls"
)
@
add_start_docstrings_to_
callable
(
BERT_INPUTS_DOCSTRING
.
format
(
"batch_size, sequence_length"
))
@
add_start_docstrings_to_
model_forward
(
BERT_INPUTS_DOCSTRING
.
format
(
"batch_size, sequence_length"
))
@
replace_return_docstrings
(
output_type
=
TFNextSentencePredictorOutput
,
config_class
=
_CONFIG_FOR_DOC
)
def
call
(
self
,
inputs
,
**
kwargs
):
r
"""
...
...
@@ -1098,7 +1098,7 @@ class TFBertForSequenceClassification(TFBertPreTrainedModel, TFSequenceClassific
config
.
num_labels
,
kernel_initializer
=
get_initializer
(
config
.
initializer_range
),
name
=
"classifier"
)
@
add_start_docstrings_to_
callable
(
BERT_INPUTS_DOCSTRING
.
format
(
"batch_size, sequence_length"
))
@
add_start_docstrings_to_
model_forward
(
BERT_INPUTS_DOCSTRING
.
format
(
"batch_size, sequence_length"
))
@
add_code_sample_docstrings
(
tokenizer_class
=
_TOKENIZER_FOR_DOC
,
checkpoint
=
"bert-base-cased"
,
...
...
@@ -1191,7 +1191,7 @@ class TFBertForMultipleChoice(TFBertPreTrainedModel, TFMultipleChoiceLoss):
"""
return
{
"input_ids"
:
tf
.
constant
(
MULTIPLE_CHOICE_DUMMY_INPUTS
)}
@
add_start_docstrings_to_
callable
(
BERT_INPUTS_DOCSTRING
.
format
(
"batch_size, num_choices, sequence_length"
))
@
add_start_docstrings_to_
model_forward
(
BERT_INPUTS_DOCSTRING
.
format
(
"batch_size, num_choices, sequence_length"
))
@
add_code_sample_docstrings
(
tokenizer_class
=
_TOKENIZER_FOR_DOC
,
checkpoint
=
"bert-base-cased"
,
...
...
@@ -1315,7 +1315,7 @@ class TFBertForTokenClassification(TFBertPreTrainedModel, TFTokenClassificationL
config
.
num_labels
,
kernel_initializer
=
get_initializer
(
config
.
initializer_range
),
name
=
"classifier"
)
@
add_start_docstrings_to_
callable
(
BERT_INPUTS_DOCSTRING
.
format
(
"batch_size, sequence_length"
))
@
add_start_docstrings_to_
model_forward
(
BERT_INPUTS_DOCSTRING
.
format
(
"batch_size, sequence_length"
))
@
add_code_sample_docstrings
(
tokenizer_class
=
_TOKENIZER_FOR_DOC
,
checkpoint
=
"bert-base-cased"
,
...
...
@@ -1400,7 +1400,7 @@ class TFBertForQuestionAnswering(TFBertPreTrainedModel, TFQuestionAnsweringLoss)
config
.
num_labels
,
kernel_initializer
=
get_initializer
(
config
.
initializer_range
),
name
=
"qa_outputs"
)
@
add_start_docstrings_to_
callable
(
BERT_INPUTS_DOCSTRING
.
format
(
"batch_size, sequence_length"
))
@
add_start_docstrings_to_
model_forward
(
BERT_INPUTS_DOCSTRING
.
format
(
"batch_size, sequence_length"
))
@
add_code_sample_docstrings
(
tokenizer_class
=
_TOKENIZER_FOR_DOC
,
checkpoint
=
"bert-base-cased"
,
...
...
src/transformers/modeling_tf_ctrl.py
View file @
378142af
...
...
@@ -20,7 +20,7 @@ import numpy as np
import
tensorflow
as
tf
from
.configuration_ctrl
import
CTRLConfig
from
.file_utils
import
add_code_sample_docstrings
,
add_start_docstrings
,
add_start_docstrings_to_
callable
from
.file_utils
import
add_code_sample_docstrings
,
add_start_docstrings
,
add_start_docstrings_to_
model_forward
from
.modeling_tf_outputs
import
TFBaseModelOutputWithPast
,
TFCausalLMOutputWithPast
from
.modeling_tf_utils
import
(
TFCausalLanguageModelingLoss
,
...
...
@@ -547,7 +547,7 @@ class TFCTRLModel(TFCTRLPreTrainedModel):
super
().
__init__
(
config
,
*
inputs
,
**
kwargs
)
self
.
transformer
=
TFCTRLMainLayer
(
config
,
name
=
"transformer"
)
@
add_start_docstrings_to_
callable
(
CTRL_INPUTS_DOCSTRING
)
@
add_start_docstrings_to_
model_forward
(
CTRL_INPUTS_DOCSTRING
)
@
add_code_sample_docstrings
(
tokenizer_class
=
_TOKENIZER_FOR_DOC
,
checkpoint
=
"ctrl"
,
...
...
@@ -602,7 +602,7 @@ class TFCTRLLMHeadModel(TFCTRLPreTrainedModel, TFCausalLanguageModelingLoss):
return
{
"inputs"
:
inputs
,
"past"
:
past
,
"use_cache"
:
kwargs
[
"use_cache"
]}
@
add_start_docstrings_to_
callable
(
CTRL_INPUTS_DOCSTRING
)
@
add_start_docstrings_to_
model_forward
(
CTRL_INPUTS_DOCSTRING
)
@
add_code_sample_docstrings
(
tokenizer_class
=
_TOKENIZER_FOR_DOC
,
checkpoint
=
"ctrl"
,
...
...
src/transformers/modeling_tf_distilbert.py
View file @
378142af
...
...
@@ -25,7 +25,7 @@ from .file_utils import (
MULTIPLE_CHOICE_DUMMY_INPUTS
,
add_code_sample_docstrings
,
add_start_docstrings
,
add_start_docstrings_to_
callable
,
add_start_docstrings_to_
model_forward
,
)
from
.modeling_tf_outputs
import
(
TFBaseModelOutput
,
...
...
@@ -579,7 +579,7 @@ class TFDistilBertModel(TFDistilBertPreTrainedModel):
super
().
__init__
(
config
,
*
inputs
,
**
kwargs
)
self
.
distilbert
=
TFDistilBertMainLayer
(
config
,
name
=
"distilbert"
)
# Embeddings
@
add_start_docstrings_to_
callable
(
DISTILBERT_INPUTS_DOCSTRING
.
format
(
"batch_size, sequence_length"
))
@
add_start_docstrings_to_
model_forward
(
DISTILBERT_INPUTS_DOCSTRING
.
format
(
"batch_size, sequence_length"
))
@
add_code_sample_docstrings
(
tokenizer_class
=
_TOKENIZER_FOR_DOC
,
checkpoint
=
"distilbert-base-uncased"
,
...
...
@@ -630,7 +630,7 @@ class TFDistilBertForMaskedLM(TFDistilBertPreTrainedModel, TFMaskedLanguageModel
def
get_output_embeddings
(
self
):
return
self
.
vocab_projector
.
input_embeddings
@
add_start_docstrings_to_
callable
(
DISTILBERT_INPUTS_DOCSTRING
.
format
(
"batch_size, sequence_length"
))
@
add_start_docstrings_to_
model_forward
(
DISTILBERT_INPUTS_DOCSTRING
.
format
(
"batch_size, sequence_length"
))
@
add_code_sample_docstrings
(
tokenizer_class
=
_TOKENIZER_FOR_DOC
,
checkpoint
=
"distilbert-base-uncased"
,
...
...
@@ -718,7 +718,7 @@ class TFDistilBertForSequenceClassification(TFDistilBertPreTrainedModel, TFSeque
)
self
.
dropout
=
tf
.
keras
.
layers
.
Dropout
(
config
.
seq_classif_dropout
)
@
add_start_docstrings_to_
callable
(
DISTILBERT_INPUTS_DOCSTRING
.
format
(
"batch_size, sequence_length"
))
@
add_start_docstrings_to_
model_forward
(
DISTILBERT_INPUTS_DOCSTRING
.
format
(
"batch_size, sequence_length"
))
@
add_code_sample_docstrings
(
tokenizer_class
=
_TOKENIZER_FOR_DOC
,
checkpoint
=
"distilbert-base-uncased"
,
...
...
@@ -800,7 +800,7 @@ class TFDistilBertForTokenClassification(TFDistilBertPreTrainedModel, TFTokenCla
config
.
num_labels
,
kernel_initializer
=
get_initializer
(
config
.
initializer_range
),
name
=
"classifier"
)
@
add_start_docstrings_to_
callable
(
DISTILBERT_INPUTS_DOCSTRING
.
format
(
"batch_size, sequence_length"
))
@
add_start_docstrings_to_
model_forward
(
DISTILBERT_INPUTS_DOCSTRING
.
format
(
"batch_size, sequence_length"
))
@
add_code_sample_docstrings
(
tokenizer_class
=
_TOKENIZER_FOR_DOC
,
checkpoint
=
"distilbert-base-uncased"
,
...
...
@@ -895,7 +895,9 @@ class TFDistilBertForMultipleChoice(TFDistilBertPreTrainedModel, TFMultipleChoic
"""
return
{
"input_ids"
:
tf
.
constant
(
MULTIPLE_CHOICE_DUMMY_INPUTS
)}
@
add_start_docstrings_to_callable
(
DISTILBERT_INPUTS_DOCSTRING
.
format
(
"batch_size, num_choices, sequence_length"
))
@
add_start_docstrings_to_model_forward
(
DISTILBERT_INPUTS_DOCSTRING
.
format
(
"batch_size, num_choices, sequence_length"
)
)
@
add_code_sample_docstrings
(
tokenizer_class
=
_TOKENIZER_FOR_DOC
,
checkpoint
=
"distilbert-base-uncased"
,
...
...
@@ -1007,7 +1009,7 @@ class TFDistilBertForQuestionAnswering(TFDistilBertPreTrainedModel, TFQuestionAn
assert
config
.
num_labels
==
2
,
f
"Incorrect number of labels
{
config
.
num_labels
}
instead of 2"
self
.
dropout
=
tf
.
keras
.
layers
.
Dropout
(
config
.
qa_dropout
)
@
add_start_docstrings_to_
callable
(
DISTILBERT_INPUTS_DOCSTRING
.
format
(
"batch_size, sequence_length"
))
@
add_start_docstrings_to_
model_forward
(
DISTILBERT_INPUTS_DOCSTRING
.
format
(
"batch_size, sequence_length"
))
@
add_code_sample_docstrings
(
tokenizer_class
=
_TOKENIZER_FOR_DOC
,
checkpoint
=
"distilbert-base-uncased"
,
...
...
src/transformers/modeling_tf_electra.py
View file @
378142af
...
...
@@ -11,7 +11,7 @@ from .file_utils import (
ModelOutput
,
add_code_sample_docstrings
,
add_start_docstrings
,
add_start_docstrings_to_
callable
,
add_start_docstrings_to_
model_forward
,
replace_return_docstrings
,
)
from
.modeling_tf_outputs
import
(
...
...
@@ -719,7 +719,7 @@ class TFElectraModel(TFElectraPreTrainedModel):
self
.
electra
=
TFElectraMainLayer
(
config
,
name
=
"electra"
)
@
add_start_docstrings_to_
callable
(
ELECTRA_INPUTS_DOCSTRING
.
format
(
"batch_size, sequence_length"
))
@
add_start_docstrings_to_
model_forward
(
ELECTRA_INPUTS_DOCSTRING
.
format
(
"batch_size, sequence_length"
))
@
add_code_sample_docstrings
(
tokenizer_class
=
_TOKENIZER_FOR_DOC
,
checkpoint
=
"google/electra-small-discriminator"
,
...
...
@@ -749,7 +749,7 @@ class TFElectraForPreTraining(TFElectraPreTrainedModel):
self
.
electra
=
TFElectraMainLayer
(
config
,
name
=
"electra"
)
self
.
discriminator_predictions
=
TFElectraDiscriminatorPredictions
(
config
,
name
=
"discriminator_predictions"
)
@
add_start_docstrings_to_
callable
(
ELECTRA_INPUTS_DOCSTRING
.
format
(
"batch_size, sequence_length"
))
@
add_start_docstrings_to_
model_forward
(
ELECTRA_INPUTS_DOCSTRING
.
format
(
"batch_size, sequence_length"
))
@
replace_return_docstrings
(
output_type
=
TFElectraForPreTrainingOutput
,
config_class
=
_CONFIG_FOR_DOC
)
def
call
(
self
,
...
...
@@ -858,7 +858,7 @@ class TFElectraForMaskedLM(TFElectraPreTrainedModel, TFMaskedLanguageModelingLos
def
get_output_embeddings
(
self
):
return
self
.
generator_lm_head
@
add_start_docstrings_to_
callable
(
ELECTRA_INPUTS_DOCSTRING
.
format
(
"batch_size, sequence_length"
))
@
add_start_docstrings_to_
model_forward
(
ELECTRA_INPUTS_DOCSTRING
.
format
(
"batch_size, sequence_length"
))
@
add_code_sample_docstrings
(
tokenizer_class
=
_TOKENIZER_FOR_DOC
,
checkpoint
=
"google/electra-small-generator"
,
...
...
@@ -971,7 +971,7 @@ class TFElectraForSequenceClassification(TFElectraPreTrainedModel, TFSequenceCla
self
.
electra
=
TFElectraMainLayer
(
config
,
name
=
"electra"
)
self
.
classifier
=
TFElectraClassificationHead
(
config
,
name
=
"classifier"
)
@
add_start_docstrings_to_
callable
(
ELECTRA_INPUTS_DOCSTRING
.
format
(
"batch_size, sequence_length"
))
@
add_start_docstrings_to_
model_forward
(
ELECTRA_INPUTS_DOCSTRING
.
format
(
"batch_size, sequence_length"
))
@
add_code_sample_docstrings
(
tokenizer_class
=
_TOKENIZER_FOR_DOC
,
checkpoint
=
"google/electra-small-discriminator"
,
...
...
@@ -1072,7 +1072,7 @@ class TFElectraForMultipleChoice(TFElectraPreTrainedModel, TFMultipleChoiceLoss)
"""
return
{
"input_ids"
:
tf
.
constant
(
MULTIPLE_CHOICE_DUMMY_INPUTS
)}
@
add_start_docstrings_to_
callable
(
ELECTRA_INPUTS_DOCSTRING
.
format
(
"batch_size, num_choices, sequence_length"
))
@
add_start_docstrings_to_
model_forward
(
ELECTRA_INPUTS_DOCSTRING
.
format
(
"batch_size, num_choices, sequence_length"
))
@
add_code_sample_docstrings
(
tokenizer_class
=
_TOKENIZER_FOR_DOC
,
checkpoint
=
"google/electra-small-discriminator"
,
...
...
@@ -1192,7 +1192,7 @@ class TFElectraForTokenClassification(TFElectraPreTrainedModel, TFTokenClassific
config
.
num_labels
,
kernel_initializer
=
get_initializer
(
config
.
initializer_range
),
name
=
"classifier"
)
@
add_start_docstrings_to_
callable
(
ELECTRA_INPUTS_DOCSTRING
.
format
(
"batch_size, sequence_length"
))
@
add_start_docstrings_to_
model_forward
(
ELECTRA_INPUTS_DOCSTRING
.
format
(
"batch_size, sequence_length"
))
@
add_code_sample_docstrings
(
tokenizer_class
=
_TOKENIZER_FOR_DOC
,
checkpoint
=
"google/electra-small-discriminator"
,
...
...
@@ -1275,7 +1275,7 @@ class TFElectraForQuestionAnswering(TFElectraPreTrainedModel, TFQuestionAnswerin
config
.
num_labels
,
kernel_initializer
=
get_initializer
(
config
.
initializer_range
),
name
=
"qa_outputs"
)
@
add_start_docstrings_to_
callable
(
ELECTRA_INPUTS_DOCSTRING
.
format
(
"batch_size, sequence_length"
))
@
add_start_docstrings_to_
model_forward
(
ELECTRA_INPUTS_DOCSTRING
.
format
(
"batch_size, sequence_length"
))
@
add_code_sample_docstrings
(
tokenizer_class
=
_TOKENIZER_FOR_DOC
,
checkpoint
=
"google/electra-small-discriminator"
,
...
...
src/transformers/modeling_tf_flaubert.py
View file @
378142af
...
...
@@ -25,7 +25,12 @@ import tensorflow as tf
from
transformers.activations_tf
import
get_tf_activation
from
.configuration_flaubert
import
FlaubertConfig
from
.file_utils
import
ModelOutput
,
add_code_sample_docstrings
,
add_start_docstrings
,
add_start_docstrings_to_callable
from
.file_utils
import
(
ModelOutput
,
add_code_sample_docstrings
,
add_start_docstrings
,
add_start_docstrings_to_model_forward
,
)
from
.modeling_tf_outputs
import
TFBaseModelOutput
from
.modeling_tf_utils
import
TFPreTrainedModel
,
TFSharedEmbeddings
,
get_initializer
,
keras_serializable
,
shape_list
from
.modeling_tf_xlm
import
(
...
...
@@ -217,7 +222,7 @@ class TFFlaubertModel(TFFlaubertPreTrainedModel):
super
().
__init__
(
config
,
*
inputs
,
**
kwargs
)
self
.
transformer
=
TFFlaubertMainLayer
(
config
,
name
=
"transformer"
)
@
add_start_docstrings_to_
callable
(
FLAUBERT_INPUTS_DOCSTRING
)
@
add_start_docstrings_to_
model_forward
(
FLAUBERT_INPUTS_DOCSTRING
)
@
add_code_sample_docstrings
(
tokenizer_class
=
_TOKENIZER_FOR_DOC
,
checkpoint
=
"jplu/tf-flaubert-small-cased"
,
...
...
@@ -721,7 +726,7 @@ class TFFlaubertWithLMHeadModel(TFFlaubertPreTrainedModel):
langs
=
None
return
{
"inputs"
:
inputs
,
"langs"
:
langs
}
@
add_start_docstrings_to_
callable
(
FLAUBERT_INPUTS_DOCSTRING
)
@
add_start_docstrings_to_
model_forward
(
FLAUBERT_INPUTS_DOCSTRING
)
@
add_code_sample_docstrings
(
tokenizer_class
=
_TOKENIZER_FOR_DOC
,
checkpoint
=
"jplu/tf-flaubert-small-cased"
,
...
...
src/transformers/modeling_tf_funnel.py
View file @
378142af
...
...
@@ -27,7 +27,7 @@ from .file_utils import (
ModelOutput
,
add_code_sample_docstrings
,
add_start_docstrings
,
add_start_docstrings_to_
callable
,
add_start_docstrings_to_
model_forward
,
replace_return_docstrings
,
)
from
.modeling_tf_outputs
import
(
...
...
@@ -1148,7 +1148,7 @@ class TFFunnelBaseModel(TFFunnelPreTrainedModel):
super
().
__init__
(
config
,
*
inputs
,
**
kwargs
)
self
.
funnel
=
TFFunnelBaseLayer
(
config
,
name
=
"funnel"
)
@
add_start_docstrings_to_
callable
(
FUNNEL_INPUTS_DOCSTRING
.
format
(
"batch_size, sequence_length"
))
@
add_start_docstrings_to_
model_forward
(
FUNNEL_INPUTS_DOCSTRING
.
format
(
"batch_size, sequence_length"
))
@
add_code_sample_docstrings
(
tokenizer_class
=
_TOKENIZER_FOR_DOC
,
checkpoint
=
"funnel-transformer/small-base"
,
...
...
@@ -1168,7 +1168,7 @@ class TFFunnelModel(TFFunnelPreTrainedModel):
super
().
__init__
(
config
,
*
inputs
,
**
kwargs
)
self
.
funnel
=
TFFunnelMainLayer
(
config
,
name
=
"funnel"
)
@
add_start_docstrings_to_
callable
(
FUNNEL_INPUTS_DOCSTRING
.
format
(
"batch_size, sequence_length"
))
@
add_start_docstrings_to_
model_forward
(
FUNNEL_INPUTS_DOCSTRING
.
format
(
"batch_size, sequence_length"
))
@
add_code_sample_docstrings
(
tokenizer_class
=
_TOKENIZER_FOR_DOC
,
checkpoint
=
"funnel-transformer/small"
,
...
...
@@ -1192,7 +1192,7 @@ class TFFunnelForPreTraining(TFFunnelPreTrainedModel):
self
.
funnel
=
TFFunnelMainLayer
(
config
,
name
=
"funnel"
)
self
.
discriminator_predictions
=
TFFunnelDiscriminatorPredictions
(
config
,
name
=
"discriminator_predictions"
)
@
add_start_docstrings_to_
callable
(
FUNNEL_INPUTS_DOCSTRING
.
format
(
"batch_size, sequence_length"
))
@
add_start_docstrings_to_
model_forward
(
FUNNEL_INPUTS_DOCSTRING
.
format
(
"batch_size, sequence_length"
))
@
replace_return_docstrings
(
output_type
=
TFFunnelForPreTrainingOutput
,
config_class
=
_CONFIG_FOR_DOC
)
def
call
(
self
,
...
...
@@ -1259,7 +1259,7 @@ class TFFunnelForMaskedLM(TFFunnelPreTrainedModel, TFMaskedLanguageModelingLoss)
self
.
funnel
=
TFFunnelMainLayer
(
config
,
name
=
"funnel"
)
self
.
lm_head
=
TFFunnelMaskedLMHead
(
config
,
self
.
funnel
.
embeddings
,
name
=
"lm_head"
)
@
add_start_docstrings_to_
callable
(
FUNNEL_INPUTS_DOCSTRING
.
format
(
"batch_size, sequence_length"
))
@
add_start_docstrings_to_
model_forward
(
FUNNEL_INPUTS_DOCSTRING
.
format
(
"batch_size, sequence_length"
))
@
add_code_sample_docstrings
(
tokenizer_class
=
_TOKENIZER_FOR_DOC
,
checkpoint
=
"funnel-transformer/small"
,
...
...
@@ -1335,7 +1335,7 @@ class TFFunnelForSequenceClassification(TFFunnelPreTrainedModel, TFSequenceClass
self
.
funnel
=
TFFunnelBaseLayer
(
config
,
name
=
"funnel"
)
self
.
classifier
=
TFFunnelClassificationHead
(
config
,
config
.
num_labels
,
name
=
"classifier"
)
@
add_start_docstrings_to_
callable
(
FUNNEL_INPUTS_DOCSTRING
.
format
(
"batch_size, sequence_length"
))
@
add_start_docstrings_to_
model_forward
(
FUNNEL_INPUTS_DOCSTRING
.
format
(
"batch_size, sequence_length"
))
@
add_code_sample_docstrings
(
tokenizer_class
=
_TOKENIZER_FOR_DOC
,
checkpoint
=
"funnel-transformer/small-base"
,
...
...
@@ -1421,7 +1421,7 @@ class TFFunnelForMultipleChoice(TFFunnelPreTrainedModel, TFMultipleChoiceLoss):
"""
return
{
"input_ids"
:
tf
.
constant
(
MULTIPLE_CHOICE_DUMMY_INPUTS
)}
@
add_start_docstrings_to_
callable
(
FUNNEL_INPUTS_DOCSTRING
.
format
(
"batch_size, num_choices, sequence_length"
))
@
add_start_docstrings_to_
model_forward
(
FUNNEL_INPUTS_DOCSTRING
.
format
(
"batch_size, num_choices, sequence_length"
))
@
add_code_sample_docstrings
(
tokenizer_class
=
_TOKENIZER_FOR_DOC
,
checkpoint
=
"funnel-transformer/small-base"
,
...
...
@@ -1534,7 +1534,7 @@ class TFFunnelForTokenClassification(TFFunnelPreTrainedModel, TFTokenClassificat
config
.
num_labels
,
kernel_initializer
=
get_initializer
(
config
.
initializer_range
),
name
=
"classifier"
)
@
add_start_docstrings_to_
callable
(
FUNNEL_INPUTS_DOCSTRING
.
format
(
"batch_size, sequence_length"
))
@
add_start_docstrings_to_
model_forward
(
FUNNEL_INPUTS_DOCSTRING
.
format
(
"batch_size, sequence_length"
))
@
add_code_sample_docstrings
(
tokenizer_class
=
_TOKENIZER_FOR_DOC
,
checkpoint
=
"funnel-transformer/small"
,
...
...
@@ -1613,7 +1613,7 @@ class TFFunnelForQuestionAnswering(TFFunnelPreTrainedModel, TFQuestionAnsweringL
config
.
num_labels
,
kernel_initializer
=
get_initializer
(
config
.
initializer_range
),
name
=
"qa_outputs"
)
@
add_start_docstrings_to_
callable
(
FUNNEL_INPUTS_DOCSTRING
.
format
(
"batch_size, sequence_length"
))
@
add_start_docstrings_to_
model_forward
(
FUNNEL_INPUTS_DOCSTRING
.
format
(
"batch_size, sequence_length"
))
@
add_code_sample_docstrings
(
tokenizer_class
=
_TOKENIZER_FOR_DOC
,
checkpoint
=
"funnel-transformer/small"
,
...
...
Prev
1
2
3
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment