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
cfd623a8
Unverified
Commit
cfd623a8
authored
Sep 05, 2022
by
Sofia Oliveira
Committed by
GitHub
Sep 05, 2022
Browse files
Add type hints to XLM-Roberta-XL models (#18475)
* Add type hints to XLM-Roberta-XL models * Format
parent
17c634fd
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
73 additions
and
73 deletions
+73
-73
src/transformers/models/xlm_roberta_xl/modeling_xlm_roberta_xl.py
...sformers/models/xlm_roberta_xl/modeling_xlm_roberta_xl.py
+73
-73
No files found.
src/transformers/models/xlm_roberta_xl/modeling_xlm_roberta_xl.py
View file @
cfd623a8
...
@@ -881,21 +881,21 @@ class XLMRobertaXLForCausalLM(XLMRobertaXLPreTrainedModel):
...
@@ -881,21 +881,21 @@ class XLMRobertaXLForCausalLM(XLMRobertaXLPreTrainedModel):
@
replace_return_docstrings
(
output_type
=
CausalLMOutputWithCrossAttentions
,
config_class
=
_CONFIG_FOR_DOC
)
@
replace_return_docstrings
(
output_type
=
CausalLMOutputWithCrossAttentions
,
config_class
=
_CONFIG_FOR_DOC
)
def
forward
(
def
forward
(
self
,
self
,
input_ids
=
None
,
input_ids
:
Optional
[
torch
.
LongTensor
]
=
None
,
attention_mask
=
None
,
attention_mask
:
Optional
[
torch
.
FloatTensor
]
=
None
,
token_type_ids
=
None
,
token_type_ids
:
Optional
[
torch
.
LongTensor
]
=
None
,
position_ids
=
None
,
position_ids
:
Optional
[
torch
.
LongTensor
]
=
None
,
head_mask
=
None
,
head_mask
:
Optional
[
torch
.
FloatTensor
]
=
None
,
inputs_embeds
=
None
,
inputs_embeds
:
Optional
[
torch
.
FloatTensor
]
=
None
,
encoder_hidden_states
=
None
,
encoder_hidden_states
:
Optional
[
torch
.
FloatTensor
]
=
None
,
encoder_attention_mask
=
None
,
encoder_attention_mask
:
Optional
[
torch
.
FloatTensor
]
=
None
,
labels
=
None
,
labels
:
Optional
[
torch
.
LongTensor
]
=
None
,
past_key_values
=
None
,
past_key_values
:
Optional
[
Tuple
[
Tuple
[
torch
.
FloatTensor
]]]
=
None
,
use_cache
=
None
,
use_cache
:
Optional
[
bool
]
=
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
,
):
)
->
Union
[
Tuple
,
CausalLMOutputWithCrossAttentions
]
:
r
"""
r
"""
encoder_hidden_states (`torch.FloatTensor` of shape `(batch_size, sequence_length, hidden_size)`, *optional*):
encoder_hidden_states (`torch.FloatTensor` of shape `(batch_size, sequence_length, hidden_size)`, *optional*):
Sequence of hidden-states at the output of the last layer of the encoder. Used in the cross-attention if
Sequence of hidden-states at the output of the last layer of the encoder. Used in the cross-attention if
...
@@ -1040,19 +1040,19 @@ class XLMRobertaXLForMaskedLM(XLMRobertaXLPreTrainedModel):
...
@@ -1040,19 +1040,19 @@ class XLMRobertaXLForMaskedLM(XLMRobertaXLPreTrainedModel):
)
)
def
forward
(
def
forward
(
self
,
self
,
input_ids
=
None
,
input_ids
:
Optional
[
torch
.
LongTensor
]
=
None
,
attention_mask
=
None
,
attention_mask
:
Optional
[
torch
.
FloatTensor
]
=
None
,
token_type_ids
=
None
,
token_type_ids
:
Optional
[
torch
.
LongTensor
]
=
None
,
position_ids
=
None
,
position_ids
:
Optional
[
torch
.
LongTensor
]
=
None
,
head_mask
=
None
,
head_mask
:
Optional
[
torch
.
FloatTensor
]
=
None
,
inputs_embeds
=
None
,
inputs_embeds
:
Optional
[
torch
.
FloatTensor
]
=
None
,
encoder_hidden_states
=
None
,
encoder_hidden_states
:
Optional
[
torch
.
Tensor
]
=
None
,
encoder_attention_mask
=
None
,
encoder_attention_mask
:
Optional
[
torch
.
FloatTensor
]
=
None
,
labels
=
None
,
labels
:
Optional
[
torch
.
LongTensor
]
=
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
,
):
)
->
Union
[
Tuple
,
MaskedLMOutput
]
:
r
"""
r
"""
labels (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *optional*):
labels (`torch.LongTensor` 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, ...,
...
@@ -1152,17 +1152,17 @@ class XLMRobertaXLForSequenceClassification(XLMRobertaXLPreTrainedModel):
...
@@ -1152,17 +1152,17 @@ class XLMRobertaXLForSequenceClassification(XLMRobertaXLPreTrainedModel):
)
)
def
forward
(
def
forward
(
self
,
self
,
input_ids
=
None
,
input_ids
:
Optional
[
torch
.
LongTensor
]
=
None
,
attention_mask
=
None
,
attention_mask
:
Optional
[
torch
.
FloatTensor
]
=
None
,
token_type_ids
=
None
,
token_type_ids
:
Optional
[
torch
.
LongTensor
]
=
None
,
position_ids
=
None
,
position_ids
:
Optional
[
torch
.
LongTensor
]
=
None
,
head_mask
=
None
,
head_mask
:
Optional
[
torch
.
FloatTensor
]
=
None
,
inputs_embeds
=
None
,
inputs_embeds
:
Optional
[
torch
.
FloatTensor
]
=
None
,
labels
=
None
,
labels
:
Optional
[
torch
.
LongTensor
]
=
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
,
):
)
->
Union
[
Tuple
,
SequenceClassifierOutput
]
:
r
"""
r
"""
labels (`torch.LongTensor` of shape `(batch_size,)`, *optional*):
labels (`torch.LongTensor` 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, ...,
...
@@ -1250,17 +1250,17 @@ class XLMRobertaXLForMultipleChoice(XLMRobertaXLPreTrainedModel):
...
@@ -1250,17 +1250,17 @@ class XLMRobertaXLForMultipleChoice(XLMRobertaXLPreTrainedModel):
)
)
def
forward
(
def
forward
(
self
,
self
,
input_ids
=
None
,
input_ids
:
Optional
[
torch
.
LongTensor
]
=
None
,
token_type_ids
=
None
,
token_type_ids
:
Optional
[
torch
.
LongTensor
]
=
None
,
attention_mask
=
None
,
attention_mask
:
Optional
[
torch
.
FloatTensor
]
=
None
,
labels
=
None
,
labels
:
Optional
[
torch
.
LongTensor
]
=
None
,
position_ids
=
None
,
position_ids
:
Optional
[
torch
.
LongTensor
]
=
None
,
head_mask
=
None
,
head_mask
:
Optional
[
torch
.
FloatTensor
]
=
None
,
inputs_embeds
=
None
,
inputs_embeds
:
Optional
[
torch
.
FloatTensor
]
=
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
,
):
)
->
Union
[
Tuple
,
MultipleChoiceModelOutput
]
:
r
"""
r
"""
labels (`torch.LongTensor` of shape `(batch_size,)`, *optional*):
labels (`torch.LongTensor` of shape `(batch_size,)`, *optional*):
Labels for computing the multiple choice classification loss. Indices should be in `[0, ...,
Labels for computing the multiple choice classification loss. Indices should be in `[0, ...,
...
@@ -1347,17 +1347,17 @@ class XLMRobertaXLForTokenClassification(XLMRobertaXLPreTrainedModel):
...
@@ -1347,17 +1347,17 @@ class XLMRobertaXLForTokenClassification(XLMRobertaXLPreTrainedModel):
)
)
def
forward
(
def
forward
(
self
,
self
,
input_ids
=
None
,
input_ids
:
Optional
[
torch
.
LongTensor
]
=
None
,
attention_mask
=
None
,
attention_mask
:
Optional
[
torch
.
FloatTensor
]
=
None
,
token_type_ids
=
None
,
token_type_ids
:
Optional
[
torch
.
LongTensor
]
=
None
,
position_ids
=
None
,
position_ids
:
Optional
[
torch
.
LongTensor
]
=
None
,
head_mask
=
None
,
head_mask
:
Optional
[
torch
.
FloatTensor
]
=
None
,
inputs_embeds
=
None
,
inputs_embeds
:
Optional
[
torch
.
FloatTensor
]
=
None
,
labels
=
None
,
labels
:
Optional
[
torch
.
LongTensor
]
=
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
,
):
)
->
Union
[
Tuple
,
TokenClassifierOutput
]
:
r
"""
r
"""
labels (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *optional*):
labels (`torch.LongTensor` 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]`.
...
@@ -1458,18 +1458,18 @@ class XLMRobertaXLForQuestionAnswering(XLMRobertaXLPreTrainedModel):
...
@@ -1458,18 +1458,18 @@ class XLMRobertaXLForQuestionAnswering(XLMRobertaXLPreTrainedModel):
)
)
def
forward
(
def
forward
(
self
,
self
,
input_ids
=
None
,
input_ids
:
Optional
[
torch
.
LongTensor
]
=
None
,
attention_mask
=
None
,
attention_mask
:
Optional
[
torch
.
FloatTensor
]
=
None
,
token_type_ids
=
None
,
token_type_ids
:
Optional
[
torch
.
LongTensor
]
=
None
,
position_ids
=
None
,
position_ids
:
Optional
[
torch
.
LongTensor
]
=
None
,
head_mask
=
None
,
head_mask
:
Optional
[
torch
.
FloatTensor
]
=
None
,
inputs_embeds
=
None
,
inputs_embeds
:
Optional
[
torch
.
FloatTensor
]
=
None
,
start_positions
=
None
,
start_positions
:
Optional
[
torch
.
LongTensor
]
=
None
,
end_positions
=
None
,
end_positions
:
Optional
[
torch
.
LongTensor
]
=
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
,
):
)
->
Union
[
Tuple
,
QuestionAnsweringModelOutput
]
:
r
"""
r
"""
start_positions (`torch.LongTensor` of shape `(batch_size,)`, *optional*):
start_positions (`torch.LongTensor` 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