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
7b262b96
Unverified
Commit
7b262b96
authored
Mar 22, 2022
by
Adam Montgomerie
Committed by
GitHub
Mar 22, 2022
Browse files
Funnel type hints (#16323)
* add pt funnel type hints * add tf funnel type hints
parent
deb61e5f
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
254 additions
and
219 deletions
+254
-219
src/transformers/models/funnel/modeling_funnel.py
src/transformers/models/funnel/modeling_funnel.py
+162
-129
src/transformers/models/funnel/modeling_tf_funnel.py
src/transformers/models/funnel/modeling_tf_funnel.py
+92
-90
No files found.
src/transformers/models/funnel/modeling_funnel.py
View file @
7b262b96
This diff is collapsed.
Click to expand it.
src/transformers/models/funnel/modeling_tf_funnel.py
View file @
7b262b96
...
@@ -16,8 +16,9 @@
...
@@ -16,8 +16,9 @@
import
warnings
import
warnings
from
dataclasses
import
dataclass
from
dataclasses
import
dataclass
from
typing
import
Dict
,
Optional
,
Tuple
from
typing
import
Dict
,
Optional
,
Tuple
,
Union
import
numpy
as
np
import
tensorflow
as
tf
import
tensorflow
as
tf
from
...activations_tf
import
get_tf_activation
from
...activations_tf
import
get_tf_activation
...
@@ -39,6 +40,7 @@ from ...modeling_tf_outputs import (
...
@@ -39,6 +40,7 @@ from ...modeling_tf_outputs import (
)
)
from
...modeling_tf_utils
import
(
from
...modeling_tf_utils
import
(
TFMaskedLanguageModelingLoss
,
TFMaskedLanguageModelingLoss
,
TFModelInputType
,
TFMultipleChoiceLoss
,
TFMultipleChoiceLoss
,
TFPreTrainedModel
,
TFPreTrainedModel
,
TFQuestionAnsweringLoss
,
TFQuestionAnsweringLoss
,
...
@@ -1093,7 +1095,7 @@ FUNNEL_INPUTS_DOCSTRING = r"""
...
@@ -1093,7 +1095,7 @@ FUNNEL_INPUTS_DOCSTRING = r"""
FUNNEL_START_DOCSTRING
,
FUNNEL_START_DOCSTRING
,
)
)
class
TFFunnelBaseModel
(
TFFunnelPreTrainedModel
):
class
TFFunnelBaseModel
(
TFFunnelPreTrainedModel
):
def
__init__
(
self
,
config
,
*
inputs
,
**
kwargs
):
def
__init__
(
self
,
config
:
FunnelConfig
,
*
inputs
,
**
kwargs
)
->
None
:
super
().
__init__
(
config
,
*
inputs
,
**
kwargs
)
super
().
__init__
(
config
,
*
inputs
,
**
kwargs
)
self
.
funnel
=
TFFunnelBaseLayer
(
config
,
name
=
"funnel"
)
self
.
funnel
=
TFFunnelBaseLayer
(
config
,
name
=
"funnel"
)
...
@@ -1107,16 +1109,16 @@ class TFFunnelBaseModel(TFFunnelPreTrainedModel):
...
@@ -1107,16 +1109,16 @@ class TFFunnelBaseModel(TFFunnelPreTrainedModel):
@
unpack_inputs
@
unpack_inputs
def
call
(
def
call
(
self
,
self
,
input_ids
=
None
,
input_ids
:
Optional
[
TFModelInputType
]
=
None
,
attention_mask
=
None
,
attention_mask
:
Optional
[
Union
[
np
.
ndarray
,
tf
.
Tensor
]]
=
None
,
token_type_ids
=
None
,
token_type_ids
:
Optional
[
Union
[
np
.
ndarray
,
tf
.
Tensor
]]
=
None
,
inputs_embeds
=
None
,
inputs_embeds
:
Optional
[
Union
[
np
.
ndarray
,
tf
.
Tensor
]]
=
None
,
output_attentions
=
None
,
output_attentions
:
Optional
[
bool
]
=
None
,
output_hidden_states
=
None
,
output_hidden_states
:
Optional
[
bool
]
=
None
,
return_dict
=
None
,
return_dict
:
Optional
[
bool
]
=
None
,
training
=
False
,
training
:
bool
=
False
,
**
kwargs
,
**
kwargs
,
):
)
->
Union
[
Tuple
[
tf
.
Tensor
],
TFBaseModelOutput
]
:
return
self
.
funnel
(
return
self
.
funnel
(
input_ids
=
input_ids
,
input_ids
=
input_ids
,
attention_mask
=
attention_mask
,
attention_mask
=
attention_mask
,
...
@@ -1141,7 +1143,7 @@ class TFFunnelBaseModel(TFFunnelPreTrainedModel):
...
@@ -1141,7 +1143,7 @@ class TFFunnelBaseModel(TFFunnelPreTrainedModel):
FUNNEL_START_DOCSTRING
,
FUNNEL_START_DOCSTRING
,
)
)
class
TFFunnelModel
(
TFFunnelPreTrainedModel
):
class
TFFunnelModel
(
TFFunnelPreTrainedModel
):
def
__init__
(
self
,
config
,
*
inputs
,
**
kwargs
):
def
__init__
(
self
,
config
:
FunnelConfig
,
*
inputs
,
**
kwargs
)
->
None
:
super
().
__init__
(
config
,
*
inputs
,
**
kwargs
)
super
().
__init__
(
config
,
*
inputs
,
**
kwargs
)
self
.
funnel
=
TFFunnelMainLayer
(
config
,
name
=
"funnel"
)
self
.
funnel
=
TFFunnelMainLayer
(
config
,
name
=
"funnel"
)
...
@@ -1155,16 +1157,16 @@ class TFFunnelModel(TFFunnelPreTrainedModel):
...
@@ -1155,16 +1157,16 @@ class TFFunnelModel(TFFunnelPreTrainedModel):
)
)
def
call
(
def
call
(
self
,
self
,
input_ids
=
None
,
input_ids
:
Optional
[
TFModelInputType
]
=
None
,
attention_mask
=
None
,
attention_mask
:
Optional
[
Union
[
np
.
ndarray
,
tf
.
Tensor
]]
=
None
,
token_type_ids
=
None
,
token_type_ids
:
Optional
[
Union
[
np
.
ndarray
,
tf
.
Tensor
]]
=
None
,
inputs_embeds
=
None
,
inputs_embeds
:
Optional
[
Union
[
np
.
ndarray
,
tf
.
Tensor
]]
=
None
,
output_attentions
=
None
,
output_attentions
:
Optional
[
bool
]
=
None
,
output_hidden_states
=
None
,
output_hidden_states
:
Optional
[
bool
]
=
None
,
return_dict
=
None
,
return_dict
:
Optional
[
bool
]
=
None
,
training
=
False
,
training
:
bool
=
False
,
**
kwargs
,
**
kwargs
,
):
)
->
Union
[
Tuple
[
tf
.
Tensor
],
TFBaseModelOutput
]
:
return
self
.
funnel
(
return
self
.
funnel
(
input_ids
=
input_ids
,
input_ids
=
input_ids
,
...
@@ -1192,7 +1194,7 @@ class TFFunnelModel(TFFunnelPreTrainedModel):
...
@@ -1192,7 +1194,7 @@ class TFFunnelModel(TFFunnelPreTrainedModel):
FUNNEL_START_DOCSTRING
,
FUNNEL_START_DOCSTRING
,
)
)
class
TFFunnelForPreTraining
(
TFFunnelPreTrainedModel
):
class
TFFunnelForPreTraining
(
TFFunnelPreTrainedModel
):
def
__init__
(
self
,
config
,
**
kwargs
):
def
__init__
(
self
,
config
:
FunnelConfig
,
**
kwargs
)
->
None
:
super
().
__init__
(
config
,
**
kwargs
)
super
().
__init__
(
config
,
**
kwargs
)
self
.
funnel
=
TFFunnelMainLayer
(
config
,
name
=
"funnel"
)
self
.
funnel
=
TFFunnelMainLayer
(
config
,
name
=
"funnel"
)
...
@@ -1203,16 +1205,16 @@ class TFFunnelForPreTraining(TFFunnelPreTrainedModel):
...
@@ -1203,16 +1205,16 @@ class TFFunnelForPreTraining(TFFunnelPreTrainedModel):
@
replace_return_docstrings
(
output_type
=
TFFunnelForPreTrainingOutput
,
config_class
=
_CONFIG_FOR_DOC
)
@
replace_return_docstrings
(
output_type
=
TFFunnelForPreTrainingOutput
,
config_class
=
_CONFIG_FOR_DOC
)
def
call
(
def
call
(
self
,
self
,
input_ids
=
None
,
input_ids
:
Optional
[
TFModelInputType
]
=
None
,
attention_mask
=
None
,
attention_mask
:
Optional
[
Union
[
np
.
ndarray
,
tf
.
Tensor
]]
=
None
,
token_type_ids
=
None
,
token_type_ids
:
Optional
[
Union
[
np
.
ndarray
,
tf
.
Tensor
]]
=
None
,
inputs_embeds
=
None
,
inputs_embeds
:
Optional
[
Union
[
np
.
ndarray
,
tf
.
Tensor
]]
=
None
,
output_attentions
=
None
,
output_attentions
:
Optional
[
bool
]
=
None
,
output_hidden_states
=
None
,
output_hidden_states
:
Optional
[
bool
]
=
None
,
return_dict
=
None
,
return_dict
:
Optional
[
bool
]
=
None
,
training
=
False
,
training
:
bool
=
False
,
**
kwargs
**
kwargs
):
)
->
Union
[
Tuple
[
tf
.
Tensor
],
TFFunnelForPreTrainingOutput
]
:
r
"""
r
"""
Returns:
Returns:
...
@@ -1259,16 +1261,16 @@ class TFFunnelForPreTraining(TFFunnelPreTrainedModel):
...
@@ -1259,16 +1261,16 @@ class TFFunnelForPreTraining(TFFunnelPreTrainedModel):
@
add_start_docstrings
(
"""Funnel Model with a `language modeling` head on top."""
,
FUNNEL_START_DOCSTRING
)
@
add_start_docstrings
(
"""Funnel Model with a `language modeling` head on top."""
,
FUNNEL_START_DOCSTRING
)
class
TFFunnelForMaskedLM
(
TFFunnelPreTrainedModel
,
TFMaskedLanguageModelingLoss
):
class
TFFunnelForMaskedLM
(
TFFunnelPreTrainedModel
,
TFMaskedLanguageModelingLoss
):
def
__init__
(
self
,
config
,
*
inputs
,
**
kwargs
):
def
__init__
(
self
,
config
:
FunnelConfig
,
*
inputs
,
**
kwargs
)
->
None
:
super
().
__init__
(
config
,
*
inputs
,
**
kwargs
)
super
().
__init__
(
config
,
*
inputs
,
**
kwargs
)
self
.
funnel
=
TFFunnelMainLayer
(
config
,
name
=
"funnel"
)
self
.
funnel
=
TFFunnelMainLayer
(
config
,
name
=
"funnel"
)
self
.
lm_head
=
TFFunnelMaskedLMHead
(
config
,
self
.
funnel
.
embeddings
,
name
=
"lm_head"
)
self
.
lm_head
=
TFFunnelMaskedLMHead
(
config
,
self
.
funnel
.
embeddings
,
name
=
"lm_head"
)
def
get_lm_head
(
self
):
def
get_lm_head
(
self
)
->
TFFunnelMaskedLMHead
:
return
self
.
lm_head
return
self
.
lm_head
def
get_prefix_bias_name
(
self
):
def
get_prefix_bias_name
(
self
)
->
str
:
warnings
.
warn
(
"The method get_prefix_bias_name is deprecated. Please use `get_bias` instead."
,
FutureWarning
)
warnings
.
warn
(
"The method get_prefix_bias_name is deprecated. Please use `get_bias` instead."
,
FutureWarning
)
return
self
.
name
+
"/"
+
self
.
lm_head
.
name
return
self
.
name
+
"/"
+
self
.
lm_head
.
name
...
@@ -1282,17 +1284,17 @@ class TFFunnelForMaskedLM(TFFunnelPreTrainedModel, TFMaskedLanguageModelingLoss)
...
@@ -1282,17 +1284,17 @@ class TFFunnelForMaskedLM(TFFunnelPreTrainedModel, TFMaskedLanguageModelingLoss)
)
)
def
call
(
def
call
(
self
,
self
,
input_ids
=
None
,
input_ids
:
Optional
[
TFModelInputType
]
=
None
,
attention_mask
=
None
,
attention_mask
:
Optional
[
Union
[
np
.
ndarray
,
tf
.
Tensor
]]
=
None
,
token_type_ids
=
None
,
token_type_ids
:
Optional
[
Union
[
np
.
ndarray
,
tf
.
Tensor
]]
=
None
,
inputs_embeds
=
None
,
inputs_embeds
:
Optional
[
Union
[
np
.
ndarray
,
tf
.
Tensor
]]
=
None
,
output_attentions
=
None
,
output_attentions
:
Optional
[
bool
]
=
None
,
output_hidden_states
=
None
,
output_hidden_states
:
Optional
[
bool
]
=
None
,
return_dict
=
None
,
return_dict
:
Optional
[
bool
]
=
None
,
labels
=
None
,
labels
:
Optional
[
Union
[
np
.
ndarray
,
tf
.
Tensor
]]
=
None
,
training
=
False
,
training
:
bool
=
False
,
**
kwargs
,
**
kwargs
,
):
)
->
Union
[
Tuple
[
tf
.
Tensor
],
TFMaskedLMOutput
]
:
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 masked language modeling loss. Indices should be in `[-100, 0, ...,
Labels for computing the masked language modeling loss. Indices should be in `[-100, 0, ...,
...
@@ -1341,7 +1343,7 @@ class TFFunnelForMaskedLM(TFFunnelPreTrainedModel, TFMaskedLanguageModelingLoss)
...
@@ -1341,7 +1343,7 @@ class TFFunnelForMaskedLM(TFFunnelPreTrainedModel, TFMaskedLanguageModelingLoss)
FUNNEL_START_DOCSTRING
,
FUNNEL_START_DOCSTRING
,
)
)
class
TFFunnelForSequenceClassification
(
TFFunnelPreTrainedModel
,
TFSequenceClassificationLoss
):
class
TFFunnelForSequenceClassification
(
TFFunnelPreTrainedModel
,
TFSequenceClassificationLoss
):
def
__init__
(
self
,
config
,
*
inputs
,
**
kwargs
):
def
__init__
(
self
,
config
:
FunnelConfig
,
*
inputs
,
**
kwargs
)
->
None
:
super
().
__init__
(
config
,
*
inputs
,
**
kwargs
)
super
().
__init__
(
config
,
*
inputs
,
**
kwargs
)
self
.
num_labels
=
config
.
num_labels
self
.
num_labels
=
config
.
num_labels
...
@@ -1358,17 +1360,17 @@ class TFFunnelForSequenceClassification(TFFunnelPreTrainedModel, TFSequenceClass
...
@@ -1358,17 +1360,17 @@ class TFFunnelForSequenceClassification(TFFunnelPreTrainedModel, TFSequenceClass
)
)
def
call
(
def
call
(
self
,
self
,
input_ids
=
None
,
input_ids
:
Optional
[
TFModelInputType
]
=
None
,
attention_mask
=
None
,
attention_mask
:
Optional
[
Union
[
np
.
ndarray
,
tf
.
Tensor
]]
=
None
,
token_type_ids
=
None
,
token_type_ids
:
Optional
[
Union
[
np
.
ndarray
,
tf
.
Tensor
]]
=
None
,
inputs_embeds
=
None
,
inputs_embeds
:
Optional
[
Union
[
np
.
ndarray
,
tf
.
Tensor
]]
=
None
,
output_attentions
=
None
,
output_attentions
:
Optional
[
bool
]
=
None
,
output_hidden_states
=
None
,
output_hidden_states
:
Optional
[
bool
]
=
None
,
return_dict
=
None
,
return_dict
:
Optional
[
bool
]
=
None
,
labels
=
None
,
labels
:
Optional
[
Union
[
np
.
ndarray
,
tf
.
Tensor
]]
=
None
,
training
=
False
,
training
:
bool
=
False
,
**
kwargs
,
**
kwargs
,
):
)
->
Union
[
Tuple
[
tf
.
Tensor
],
TFSequenceClassifierOutput
]
:
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, ...,
...
@@ -1418,7 +1420,7 @@ class TFFunnelForSequenceClassification(TFFunnelPreTrainedModel, TFSequenceClass
...
@@ -1418,7 +1420,7 @@ class TFFunnelForSequenceClassification(TFFunnelPreTrainedModel, TFSequenceClass
FUNNEL_START_DOCSTRING
,
FUNNEL_START_DOCSTRING
,
)
)
class
TFFunnelForMultipleChoice
(
TFFunnelPreTrainedModel
,
TFMultipleChoiceLoss
):
class
TFFunnelForMultipleChoice
(
TFFunnelPreTrainedModel
,
TFMultipleChoiceLoss
):
def
__init__
(
self
,
config
,
*
inputs
,
**
kwargs
):
def
__init__
(
self
,
config
:
FunnelConfig
,
*
inputs
,
**
kwargs
)
->
None
:
super
().
__init__
(
config
,
*
inputs
,
**
kwargs
)
super
().
__init__
(
config
,
*
inputs
,
**
kwargs
)
self
.
funnel
=
TFFunnelBaseLayer
(
config
,
name
=
"funnel"
)
self
.
funnel
=
TFFunnelBaseLayer
(
config
,
name
=
"funnel"
)
...
@@ -1444,17 +1446,17 @@ class TFFunnelForMultipleChoice(TFFunnelPreTrainedModel, TFMultipleChoiceLoss):
...
@@ -1444,17 +1446,17 @@ class TFFunnelForMultipleChoice(TFFunnelPreTrainedModel, TFMultipleChoiceLoss):
)
)
def
call
(
def
call
(
self
,
self
,
input_ids
=
None
,
input_ids
:
Optional
[
TFModelInputType
]
=
None
,
attention_mask
=
None
,
attention_mask
:
Optional
[
Union
[
np
.
ndarray
,
tf
.
Tensor
]]
=
None
,
token_type_ids
=
None
,
token_type_ids
:
Optional
[
Union
[
np
.
ndarray
,
tf
.
Tensor
]]
=
None
,
inputs_embeds
=
None
,
inputs_embeds
:
Optional
[
Union
[
np
.
ndarray
,
tf
.
Tensor
]]
=
None
,
output_attentions
=
None
,
output_attentions
:
Optional
[
bool
]
=
None
,
output_hidden_states
=
None
,
output_hidden_states
:
Optional
[
bool
]
=
None
,
return_dict
=
None
,
return_dict
:
Optional
[
bool
]
=
None
,
labels
=
None
,
labels
:
Optional
[
Union
[
np
.
ndarray
,
tf
.
Tensor
]]
=
None
,
training
=
False
,
training
:
bool
=
False
,
**
kwargs
,
**
kwargs
,
):
)
->
Union
[
Tuple
[
tf
.
Tensor
],
TFMultipleChoiceModelOutput
]
:
r
"""
r
"""
labels (`tf.Tensor` of shape `(batch_size,)`, *optional*):
labels (`tf.Tensor` of shape `(batch_size,)`, *optional*):
Labels for computing the multiple choice classification loss. Indices should be in `[0, ..., num_choices]`
Labels for computing the multiple choice classification loss. Indices should be in `[0, ..., num_choices]`
...
@@ -1514,7 +1516,7 @@ class TFFunnelForMultipleChoice(TFFunnelPreTrainedModel, TFMultipleChoiceLoss):
...
@@ -1514,7 +1516,7 @@ class TFFunnelForMultipleChoice(TFFunnelPreTrainedModel, TFMultipleChoiceLoss):
}
}
]
]
)
)
def
serving
(
self
,
inputs
:
Dict
[
str
,
tf
.
Tensor
]):
def
serving
(
self
,
inputs
:
Dict
[
str
,
tf
.
Tensor
])
->
TFMultipleChoiceModelOutput
:
output
=
self
.
call
(
input_ids
=
inputs
)
output
=
self
.
call
(
input_ids
=
inputs
)
return
self
.
serving_output
(
output
=
output
)
return
self
.
serving_output
(
output
=
output
)
...
@@ -1535,7 +1537,7 @@ class TFFunnelForMultipleChoice(TFFunnelPreTrainedModel, TFMultipleChoiceLoss):
...
@@ -1535,7 +1537,7 @@ class TFFunnelForMultipleChoice(TFFunnelPreTrainedModel, TFMultipleChoiceLoss):
FUNNEL_START_DOCSTRING
,
FUNNEL_START_DOCSTRING
,
)
)
class
TFFunnelForTokenClassification
(
TFFunnelPreTrainedModel
,
TFTokenClassificationLoss
):
class
TFFunnelForTokenClassification
(
TFFunnelPreTrainedModel
,
TFTokenClassificationLoss
):
def
__init__
(
self
,
config
,
*
inputs
,
**
kwargs
):
def
__init__
(
self
,
config
:
FunnelConfig
,
*
inputs
,
**
kwargs
)
->
None
:
super
().
__init__
(
config
,
*
inputs
,
**
kwargs
)
super
().
__init__
(
config
,
*
inputs
,
**
kwargs
)
self
.
num_labels
=
config
.
num_labels
self
.
num_labels
=
config
.
num_labels
...
@@ -1555,17 +1557,17 @@ class TFFunnelForTokenClassification(TFFunnelPreTrainedModel, TFTokenClassificat
...
@@ -1555,17 +1557,17 @@ class TFFunnelForTokenClassification(TFFunnelPreTrainedModel, TFTokenClassificat
)
)
def
call
(
def
call
(
self
,
self
,
input_ids
=
None
,
input_ids
:
Optional
[
TFModelInputType
]
=
None
,
attention_mask
=
None
,
attention_mask
:
Optional
[
Union
[
np
.
ndarray
,
tf
.
Tensor
]]
=
None
,
token_type_ids
=
None
,
token_type_ids
:
Optional
[
Union
[
np
.
ndarray
,
tf
.
Tensor
]]
=
None
,
inputs_embeds
=
None
,
inputs_embeds
:
Optional
[
Union
[
np
.
ndarray
,
tf
.
Tensor
]]
=
None
,
output_attentions
=
None
,
output_attentions
:
Optional
[
bool
]
=
None
,
output_hidden_states
=
None
,
output_hidden_states
:
Optional
[
bool
]
=
None
,
return_dict
=
None
,
return_dict
:
Optional
[
bool
]
=
None
,
labels
=
None
,
labels
:
Optional
[
Union
[
np
.
ndarray
,
tf
.
Tensor
]]
=
None
,
training
=
False
,
training
:
bool
=
False
,
**
kwargs
,
**
kwargs
,
):
)
->
Union
[
Tuple
[
tf
.
Tensor
],
TFTokenClassifierOutput
]
:
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]`.
...
@@ -1614,7 +1616,7 @@ class TFFunnelForTokenClassification(TFFunnelPreTrainedModel, TFTokenClassificat
...
@@ -1614,7 +1616,7 @@ class TFFunnelForTokenClassification(TFFunnelPreTrainedModel, TFTokenClassificat
FUNNEL_START_DOCSTRING
,
FUNNEL_START_DOCSTRING
,
)
)
class
TFFunnelForQuestionAnswering
(
TFFunnelPreTrainedModel
,
TFQuestionAnsweringLoss
):
class
TFFunnelForQuestionAnswering
(
TFFunnelPreTrainedModel
,
TFQuestionAnsweringLoss
):
def
__init__
(
self
,
config
,
*
inputs
,
**
kwargs
):
def
__init__
(
self
,
config
:
FunnelConfig
,
*
inputs
,
**
kwargs
)
->
None
:
super
().
__init__
(
config
,
*
inputs
,
**
kwargs
)
super
().
__init__
(
config
,
*
inputs
,
**
kwargs
)
self
.
num_labels
=
config
.
num_labels
self
.
num_labels
=
config
.
num_labels
...
@@ -1633,18 +1635,18 @@ class TFFunnelForQuestionAnswering(TFFunnelPreTrainedModel, TFQuestionAnsweringL
...
@@ -1633,18 +1635,18 @@ class TFFunnelForQuestionAnswering(TFFunnelPreTrainedModel, TFQuestionAnsweringL
)
)
def
call
(
def
call
(
self
,
self
,
input_ids
=
None
,
input_ids
:
Optional
[
TFModelInputType
]
=
None
,
attention_mask
=
None
,
attention_mask
:
Optional
[
Union
[
np
.
ndarray
,
tf
.
Tensor
]]
=
None
,
token_type_ids
=
None
,
token_type_ids
:
Optional
[
Union
[
np
.
ndarray
,
tf
.
Tensor
]]
=
None
,
inputs_embeds
=
None
,
inputs_embeds
:
Optional
[
Union
[
np
.
ndarray
,
tf
.
Tensor
]]
=
None
,
output_attentions
=
None
,
output_attentions
:
Optional
[
bool
]
=
None
,
output_hidden_states
=
None
,
output_hidden_states
:
Optional
[
bool
]
=
None
,
return_dict
=
None
,
return_dict
:
Optional
[
bool
]
=
None
,
start_positions
=
None
,
start_positions
:
Optional
[
Union
[
np
.
ndarray
,
tf
.
Tensor
]]
=
None
,
end_positions
=
None
,
end_positions
:
Optional
[
Union
[
np
.
ndarray
,
tf
.
Tensor
]]
=
None
,
training
=
False
,
training
:
bool
=
False
,
**
kwargs
,
**
kwargs
,
):
)
->
Union
[
Tuple
[
tf
.
Tensor
],
TFQuestionAnsweringModelOutput
]
:
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.
...
...
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