15
15
16
16
import os
17
17
from shutil import copyfile
18
- from typing import Dict , List , Literal , Optional , Tuple , Union
18
+ from typing import Dict , List , Optional , Tuple , Union
19
19
20
20
import numpy as np
21
21
import sentencepiece as spm
@@ -232,7 +232,6 @@ def _pad(
232
232
max_length : Optional [int ] = None ,
233
233
padding_strategy : PaddingStrategy = PaddingStrategy .DO_NOT_PAD ,
234
234
pad_to_multiple_of : Optional [int ] = None ,
235
- padding_side : Optional [Literal ["right" , "left" ]] = None ,
236
235
return_attention_mask : Optional [bool ] = None ,
237
236
) -> dict :
238
237
"""
@@ -248,16 +247,13 @@ def _pad(
248
247
- PaddingStrategy.LONGEST Pad to the longest sequence in the batch
249
248
- PaddingStrategy.MAX_LENGTH: Pad to the max length (default)
250
249
- PaddingStrategy.DO_NOT_PAD: Do not pad
251
- The tokenizer padding sides are defined in ` padding_side` argument :
250
+ The tokenizer padding sides are defined in self. padding_side:
252
251
253
252
- 'left': pads on the left of the sequences
254
253
- 'right': pads on the right of the sequences
255
254
pad_to_multiple_of: (optional) Integer if set will pad the sequence to a multiple of the provided value.
256
255
This is especially useful to enable the use of Tensor Core on NVIDIA hardware with compute capability
257
256
>= 7.5 (Volta).
258
- padding_side: (optional) The side on which the model should have padding applied.
259
- Should be selected between ['right', 'left'].
260
- Default value is picked from the class attribute of the same name.
261
257
return_attention_mask:
262
258
(optional) Set to False to avoid returning attention mask (default: set to model specifics)
263
259
"""
@@ -272,7 +268,7 @@ def _pad(
272
268
273
269
required_input = encoded_inputs [self .model_input_names [0 ]]
274
270
encoded_inputs = super ()._pad (
275
- encoded_inputs , max_length , padding_strategy , pad_to_multiple_of , padding_side , return_attention_mask
271
+ encoded_inputs , max_length , padding_strategy , pad_to_multiple_of , return_attention_mask
276
272
)
277
273
if attention_mask is not None and len (np .shape (attention_mask )) > 2 :
278
274
encoded_inputs ["attention_mask" ] = attention_mask
@@ -525,7 +521,6 @@ def _pad(
525
521
max_length : Optional [int ] = None ,
526
522
padding_strategy : PaddingStrategy = PaddingStrategy .DO_NOT_PAD ,
527
523
pad_to_multiple_of : Optional [int ] = None ,
528
- padding_side : Optional [Literal ["right" , "left" ]] = None ,
529
524
return_attention_mask : Optional [bool ] = None ,
530
525
) -> dict :
531
526
"""
@@ -541,16 +536,13 @@ def _pad(
541
536
- PaddingStrategy.LONGEST Pad to the longest sequence in the batch
542
537
- PaddingStrategy.MAX_LENGTH: Pad to the max length (default)
543
538
- PaddingStrategy.DO_NOT_PAD: Do not pad
544
- The tokenizer padding sides are defined in ` padding_side` argument :
539
+ The tokenizer padding sides are defined in self. padding_side:
545
540
546
541
- 'left': pads on the left of the sequences
547
542
- 'right': pads on the right of the sequences
548
543
pad_to_multiple_of: (optional) Integer if set will pad the sequence to a multiple of the provided value.
549
544
This is especially useful to enable the use of Tensor Core on NVIDIA hardware with compute capability
550
545
>= 7.5 (Volta).
551
- padding_side: (optional) The side on which the model should have padding applied.
552
- Should be selected between ['right', 'left'].
553
- Default value is picked from the class attribute of the same name.
554
546
return_attention_mask:
555
547
(optional) Set to False to avoid returning attention mask (default: set to model specifics)
556
548
"""
@@ -565,7 +557,7 @@ def _pad(
565
557
566
558
required_input = encoded_inputs [self .model_input_names [0 ]]
567
559
encoded_inputs = super ()._pad (
568
- encoded_inputs , max_length , padding_strategy , pad_to_multiple_of , padding_side , return_attention_mask
560
+ encoded_inputs , max_length , padding_strategy , pad_to_multiple_of , return_attention_mask
569
561
)
570
562
if attention_mask is not None and len (np .shape (attention_mask )) > 2 :
571
563
encoded_inputs ["attention_mask" ] = attention_mask
0 commit comments