File tree 2 files changed +3
-1
lines changed
examples/pytorch/question-answering
src/transformers/models/roberta
2 files changed +3
-1
lines changed Original file line number Diff line number Diff line change @@ -283,6 +283,7 @@ def main():
283
283
cache_dir = model_args .cache_dir ,
284
284
revision = model_args .model_revision ,
285
285
use_auth_token = True if model_args .use_auth_token else None ,
286
+ ort = training_args .ort ,
286
287
)
287
288
tokenizer = AutoTokenizer .from_pretrained (
288
289
model_args .tokenizer_name if model_args .tokenizer_name else model_args .model_name_or_path ,
Original file line number Diff line number Diff line change @@ -1414,6 +1414,7 @@ class RobertaForQuestionAnswering(RobertaPreTrainedModel):
1414
1414
def __init__ (self , config ):
1415
1415
super ().__init__ (config )
1416
1416
self .num_labels = config .num_labels
1417
+ self .ort = config .ort
1417
1418
1418
1419
self .roberta = RobertaModel (config , add_pooling_layer = False )
1419
1420
self .qa_outputs = nn .Linear (config .hidden_size , config .num_labels )
@@ -1480,7 +1481,7 @@ def forward(
1480
1481
if len (end_positions .size ()) > 1 :
1481
1482
end_positions = end_positions .squeeze (- 1 )
1482
1483
# sometimes the start/end positions are outside our model inputs, we ignore these terms
1483
- ignored_index = start_logits .size (1 )
1484
+ ignored_index = start_logits .size (1 ) if not self . ort else 344
1484
1485
start_positions .clamp_ (0 , ignored_index )
1485
1486
end_positions .clamp_ (0 , ignored_index )
1486
1487
You can’t perform that action at this time.
0 commit comments