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
e4d56e81
Unverified
Commit
e4d56e81
authored
Oct 17, 2022
by
Ethan Joseph
Committed by
GitHub
Oct 17, 2022
Browse files
add return types for tf gptj, xlm, and xlnet (#19638)
parent
2af36f95
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
13 deletions
+13
-13
src/transformers/models/gptj/modeling_tf_gptj.py
src/transformers/models/gptj/modeling_tf_gptj.py
+5
-5
src/transformers/models/xlm/modeling_tf_xlm.py
src/transformers/models/xlm/modeling_tf_xlm.py
+7
-7
src/transformers/models/xlnet/modeling_tf_xlnet.py
src/transformers/models/xlnet/modeling_tf_xlnet.py
+1
-1
No files found.
src/transformers/models/gptj/modeling_tf_gptj.py
View file @
e4d56e81
...
@@ -387,7 +387,7 @@ class TFGPTJMainLayer(tf.keras.layers.Layer):
...
@@ -387,7 +387,7 @@ class TFGPTJMainLayer(tf.keras.layers.Layer):
output_hidden_states
=
None
,
output_hidden_states
=
None
,
return_dict
=
None
,
return_dict
=
None
,
training
=
False
,
training
=
False
,
):
)
->
Union
[
TFBaseModelOutputWithPast
,
Tuple
[
tf
.
Tensor
]]
:
if
input_ids
is
not
None
and
inputs_embeds
is
not
None
:
if
input_ids
is
not
None
and
inputs_embeds
is
not
None
:
raise
ValueError
(
"You cannot specify both input_ids and inputs_embeds at the same time"
)
raise
ValueError
(
"You cannot specify both input_ids and inputs_embeds at the same time"
)
...
@@ -684,7 +684,7 @@ class TFGPTJModel(TFGPTJPreTrainedModel):
...
@@ -684,7 +684,7 @@ class TFGPTJModel(TFGPTJPreTrainedModel):
output_hidden_states
:
Optional
[
bool
]
=
None
,
output_hidden_states
:
Optional
[
bool
]
=
None
,
return_dict
:
Optional
[
bool
]
=
None
,
return_dict
:
Optional
[
bool
]
=
None
,
training
:
Optional
[
bool
]
=
False
,
training
:
Optional
[
bool
]
=
False
,
):
)
->
Union
[
TFBaseModelOutputWithPast
,
Tuple
[
tf
.
Tensor
]]
:
r
"""
r
"""
use_cache (`bool`, *optional*, defaults to `True`):
use_cache (`bool`, *optional*, defaults to `True`):
If set to `True`, `past_key_values` key value states are returned and can be used to speed up decoding (see
If set to `True`, `past_key_values` key value states are returned and can be used to speed up decoding (see
...
@@ -789,7 +789,7 @@ class TFGPTJForCausalLM(TFGPTJPreTrainedModel, TFCausalLanguageModelingLoss):
...
@@ -789,7 +789,7 @@ class TFGPTJForCausalLM(TFGPTJPreTrainedModel, TFCausalLanguageModelingLoss):
output_hidden_states
:
Optional
[
bool
]
=
None
,
output_hidden_states
:
Optional
[
bool
]
=
None
,
return_dict
:
Optional
[
bool
]
=
None
,
return_dict
:
Optional
[
bool
]
=
None
,
training
:
Optional
[
bool
]
=
False
,
training
:
Optional
[
bool
]
=
False
,
):
)
->
Union
[
TFCausalLMOutputWithPast
,
Tuple
[
tf
.
Tensor
]]
:
r
"""
r
"""
labels (`np.ndarray` or `tf.Tensor` of shape `(batch_size, sequence_length)`, *optional*):
labels (`np.ndarray` or `tf.Tensor` of shape `(batch_size, sequence_length)`, *optional*):
Labels for language modeling. Note that the labels **are shifted** inside the model, i.e. you can set
Labels for language modeling. Note that the labels **are shifted** inside the model, i.e. you can set
...
@@ -893,7 +893,7 @@ class TFGPTJForSequenceClassification(TFGPTJPreTrainedModel, TFSequenceClassific
...
@@ -893,7 +893,7 @@ class TFGPTJForSequenceClassification(TFGPTJPreTrainedModel, TFSequenceClassific
output_hidden_states
:
Optional
[
bool
]
=
None
,
output_hidden_states
:
Optional
[
bool
]
=
None
,
return_dict
:
Optional
[
bool
]
=
None
,
return_dict
:
Optional
[
bool
]
=
None
,
training
:
Optional
[
bool
]
=
False
,
training
:
Optional
[
bool
]
=
False
,
):
)
->
Union
[
TFSequenceClassifierOutputWithPast
,
Tuple
[
tf
.
Tensor
]]
:
r
"""
r
"""
labels (`np.ndarray` or `tf.Tensor` of shape `(batch_size,)`, *optional*):
labels (`np.ndarray` or `tf.Tensor` of shape `(batch_size,)`, *optional*):
Labels for computing the sequence classification/regression loss. Indices should be in `[0, ...,
Labels for computing the sequence classification/regression loss. Indices should be in `[0, ...,
...
@@ -1016,7 +1016,7 @@ class TFGPTJForQuestionAnswering(TFGPTJPreTrainedModel, TFQuestionAnsweringLoss)
...
@@ -1016,7 +1016,7 @@ class TFGPTJForQuestionAnswering(TFGPTJPreTrainedModel, TFQuestionAnsweringLoss)
output_hidden_states
:
Optional
[
bool
]
=
None
,
output_hidden_states
:
Optional
[
bool
]
=
None
,
return_dict
:
Optional
[
bool
]
=
None
,
return_dict
:
Optional
[
bool
]
=
None
,
training
:
Optional
[
bool
]
=
False
,
training
:
Optional
[
bool
]
=
False
,
):
)
->
Union
[
TFQuestionAnsweringModelOutput
,
Tuple
[
tf
.
Tensor
]]
:
r
"""
r
"""
start_positions (`np.ndarray` or `tf.Tensor` of shape `(batch_size,)`, *optional*):
start_positions (`np.ndarray` or `tf.Tensor` of shape `(batch_size,)`, *optional*):
Labels for position (index) of the start of the labelled span for computing the token classification loss.
Labels for position (index) of the start of the labelled span for computing the token classification loss.
...
...
src/transformers/models/xlm/modeling_tf_xlm.py
View file @
e4d56e81
...
@@ -362,7 +362,7 @@ class TFXLMMainLayer(tf.keras.layers.Layer):
...
@@ -362,7 +362,7 @@ class TFXLMMainLayer(tf.keras.layers.Layer):
output_hidden_states
=
None
,
output_hidden_states
=
None
,
return_dict
=
None
,
return_dict
=
None
,
training
=
False
,
training
=
False
,
):
)
->
Union
[
TFBaseModelOutput
,
Tuple
[
tf
.
Tensor
]]
:
# removed: src_enc=None, src_len=None
# removed: src_enc=None, src_len=None
if
input_ids
is
not
None
and
inputs_embeds
is
not
None
:
if
input_ids
is
not
None
and
inputs_embeds
is
not
None
:
...
@@ -721,7 +721,7 @@ class TFXLMModel(TFXLMPreTrainedModel):
...
@@ -721,7 +721,7 @@ class TFXLMModel(TFXLMPreTrainedModel):
output_hidden_states
=
None
,
output_hidden_states
=
None
,
return_dict
=
None
,
return_dict
=
None
,
training
=
False
,
training
=
False
,
):
)
->
Union
[
TFBaseModelOutput
,
Tuple
[
tf
.
Tensor
]]
:
outputs
=
self
.
transformer
(
outputs
=
self
.
transformer
(
input_ids
=
input_ids
,
input_ids
=
input_ids
,
attention_mask
=
attention_mask
,
attention_mask
=
attention_mask
,
...
@@ -858,7 +858,7 @@ class TFXLMWithLMHeadModel(TFXLMPreTrainedModel):
...
@@ -858,7 +858,7 @@ class TFXLMWithLMHeadModel(TFXLMPreTrainedModel):
output_hidden_states
:
Optional
[
bool
]
=
None
,
output_hidden_states
:
Optional
[
bool
]
=
None
,
return_dict
:
Optional
[
bool
]
=
None
,
return_dict
:
Optional
[
bool
]
=
None
,
training
:
bool
=
False
,
training
:
bool
=
False
,
):
)
->
Union
[
TFXLMWithLMHeadModelOutput
,
Tuple
[
tf
.
Tensor
]]
:
transformer_outputs
=
self
.
transformer
(
transformer_outputs
=
self
.
transformer
(
input_ids
=
input_ids
,
input_ids
=
input_ids
,
attention_mask
=
attention_mask
,
attention_mask
=
attention_mask
,
...
@@ -931,7 +931,7 @@ class TFXLMForSequenceClassification(TFXLMPreTrainedModel, TFSequenceClassificat
...
@@ -931,7 +931,7 @@ class TFXLMForSequenceClassification(TFXLMPreTrainedModel, TFSequenceClassificat
return_dict
:
Optional
[
bool
]
=
None
,
return_dict
:
Optional
[
bool
]
=
None
,
labels
:
Optional
[
Union
[
np
.
ndarray
,
tf
.
Tensor
]]
=
None
,
labels
:
Optional
[
Union
[
np
.
ndarray
,
tf
.
Tensor
]]
=
None
,
training
:
bool
=
False
,
training
:
bool
=
False
,
):
)
->
Union
[
TFSequenceClassifierOutput
,
Tuple
[
tf
.
Tensor
]]
:
r
"""
r
"""
labels (`tf.Tensor` of shape `(batch_size,)`, *optional*):
labels (`tf.Tensor` of shape `(batch_size,)`, *optional*):
Labels for computing the sequence classification/regression loss. Indices should be in `[0, ...,
Labels for computing the sequence classification/regression loss. Indices should be in `[0, ...,
...
@@ -1038,7 +1038,7 @@ class TFXLMForMultipleChoice(TFXLMPreTrainedModel, TFMultipleChoiceLoss):
...
@@ -1038,7 +1038,7 @@ class TFXLMForMultipleChoice(TFXLMPreTrainedModel, TFMultipleChoiceLoss):
return_dict
:
Optional
[
bool
]
=
None
,
return_dict
:
Optional
[
bool
]
=
None
,
labels
:
Optional
[
Union
[
np
.
ndarray
,
tf
.
Tensor
]]
=
None
,
labels
:
Optional
[
Union
[
np
.
ndarray
,
tf
.
Tensor
]]
=
None
,
training
:
bool
=
False
,
training
:
bool
=
False
,
):
)
->
Union
[
TFMultipleChoiceModelOutput
,
Tuple
[
tf
.
Tensor
]]
:
if
input_ids
is
not
None
:
if
input_ids
is
not
None
:
num_choices
=
shape_list
(
input_ids
)[
1
]
num_choices
=
shape_list
(
input_ids
)[
1
]
seq_length
=
shape_list
(
input_ids
)[
2
]
seq_length
=
shape_list
(
input_ids
)[
2
]
...
@@ -1162,7 +1162,7 @@ class TFXLMForTokenClassification(TFXLMPreTrainedModel, TFTokenClassificationLos
...
@@ -1162,7 +1162,7 @@ class TFXLMForTokenClassification(TFXLMPreTrainedModel, TFTokenClassificationLos
return_dict
:
Optional
[
bool
]
=
None
,
return_dict
:
Optional
[
bool
]
=
None
,
labels
:
Optional
[
Union
[
np
.
ndarray
,
tf
.
Tensor
]]
=
None
,
labels
:
Optional
[
Union
[
np
.
ndarray
,
tf
.
Tensor
]]
=
None
,
training
:
bool
=
False
,
training
:
bool
=
False
,
):
)
->
Union
[
TFTokenClassifierOutput
,
Tuple
[
tf
.
Tensor
]]
:
r
"""
r
"""
labels (`tf.Tensor` of shape `(batch_size, sequence_length)`, *optional*):
labels (`tf.Tensor` of shape `(batch_size, sequence_length)`, *optional*):
Labels for computing the token classification loss. Indices should be in `[0, ..., config.num_labels - 1]`.
Labels for computing the token classification loss. Indices should be in `[0, ..., config.num_labels - 1]`.
...
@@ -1248,7 +1248,7 @@ class TFXLMForQuestionAnsweringSimple(TFXLMPreTrainedModel, TFQuestionAnsweringL
...
@@ -1248,7 +1248,7 @@ class TFXLMForQuestionAnsweringSimple(TFXLMPreTrainedModel, TFQuestionAnsweringL
start_positions
:
Optional
[
Union
[
np
.
ndarray
,
tf
.
Tensor
]]
=
None
,
start_positions
:
Optional
[
Union
[
np
.
ndarray
,
tf
.
Tensor
]]
=
None
,
end_positions
:
Optional
[
Union
[
np
.
ndarray
,
tf
.
Tensor
]]
=
None
,
end_positions
:
Optional
[
Union
[
np
.
ndarray
,
tf
.
Tensor
]]
=
None
,
training
:
bool
=
False
,
training
:
bool
=
False
,
):
)
->
Union
[
TFQuestionAnsweringModelOutput
,
Tuple
[
tf
.
Tensor
]]
:
r
"""
r
"""
start_positions (`tf.Tensor` of shape `(batch_size,)`, *optional*):
start_positions (`tf.Tensor` of shape `(batch_size,)`, *optional*):
Labels for position (index) of the start of the labelled span for computing the token classification loss.
Labels for position (index) of the start of the labelled span for computing the token classification loss.
...
...
src/transformers/models/xlnet/modeling_tf_xlnet.py
View file @
e4d56e81
...
@@ -1166,7 +1166,7 @@ class TFXLNetModel(TFXLNetPreTrainedModel):
...
@@ -1166,7 +1166,7 @@ class TFXLNetModel(TFXLNetPreTrainedModel):
output_hidden_states
:
Optional
[
bool
]
=
None
,
output_hidden_states
:
Optional
[
bool
]
=
None
,
return_dict
:
Optional
[
bool
]
=
None
,
return_dict
:
Optional
[
bool
]
=
None
,
training
:
bool
=
False
,
training
:
bool
=
False
,
):
)
->
Union
[
TFXLNetModelOutput
,
Tuple
[
tf
.
Tensor
]]
:
outputs
=
self
.
transformer
(
outputs
=
self
.
transformer
(
input_ids
=
input_ids
,
input_ids
=
input_ids
,
attention_mask
=
attention_mask
,
attention_mask
=
attention_mask
,
...
...
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