@@ -234,17 +234,16 @@ def infer_BPE_SP_from_tokenizer_name(self, tokenizer_name):
234234 Return true if the tokenizer is a BPE using encoded leading character space with byte-based tokens as in the
235235 usual sentencepiece tokenizers
236236 """
237- result = False
238237 # as we rely on the HuggingFace transformer and tokenizer libraries, we list the BPE tokenizer from the model
239238 # name - this list was created on January 2023
240239 bpe_sp_tokenizers = ["roberta" , "gpt2" , "albert" , "xlnet" , "marian" , "t5" , "camembert" , "bart" , "bigbird" ,
241240 "blenderbot" , "clip" , "flaubert" , "fsmt" , "xlm" , "longformer" , "marian" , "phobert" , "reformer" , "rembert" ]
242241 tokenizer_name = tokenizer_name .lower ()
243242 for bpe_tok in bpe_sp_tokenizers :
244243 if tokenizer_name .find (bpe_tok ) != - 1 :
245- result = True
246- break
247- return result
244+ return True
245+
246+ return type ( self . tokenizer . backend_tokenizer . model ). __name__ == "BPE"
248247
249248 def tokenize_and_align_features_and_labels (self , texts , chars , text_features , text_labels , maxlen = 512 ):
250249 """
@@ -322,7 +321,7 @@ def convert_single_text(self, text_tokens, chars_tokens, features_tokens, label_
322321
323322 # sub-tokenization
324323 encoded_result = self .tokenizer (text_tokens , add_special_tokens = True , is_split_into_words = True ,
325- max_length = max_seq_length , truncation = True , return_offsets_mapping = True )
324+ max_length = max_seq_length , truncation = True , return_offsets_mapping = True , padding = "max_length" )
326325
327326 input_ids = encoded_result .input_ids
328327 offsets = encoded_result .offset_mapping
0 commit comments