File tree Expand file tree Collapse file tree 2 files changed +10
-1
lines changed
paddlenlp/transformers/auto Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -178,7 +178,12 @@ def tokenizer_class_from_name(class_name: str):
178
178
179
179
return getattr (module , class_name )
180
180
except AttributeError :
181
- raise ValueError (f"Tokenizer class { class_name } is not currently imported." )
181
+ try :
182
+ module = importlib .import_module (f".{ module_name } .tokenizer_fast" , "paddlenlp.transformers" )
183
+
184
+ return getattr (module , class_name )
185
+ except AttributeError :
186
+ raise ValueError (f"Tokenizer class { class_name } is not currently imported." )
182
187
183
188
for config , tokenizers in TOKENIZER_MAPPING ._extra_content .items ():
184
189
for tokenizer in tokenizers :
Original file line number Diff line number Diff line change @@ -48,6 +48,10 @@ def test_from_pretrained_cache_dir(self):
48
48
# check against double appending model_name in cache_dir
49
49
self .assertFalse (os .path .exists (os .path .join (tempdir , model_name , model_name )))
50
50
51
+ def test_from_pretrained_tokenizer_fast (self ):
52
+ tokenizer = AutoTokenizer .from_pretrained ("intfloat/e5-base-v2" , use_fast = True )
53
+ self .assertIsInstance (tokenizer , BertTokenizerFast )
54
+
51
55
def test_new_tokenizer_registration (self ):
52
56
try :
53
57
AutoConfig .register ("custom" , CustomConfig )
You can’t perform that action at this time.
0 commit comments