Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions paddlenlp/transformers/auto/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,15 @@ def __getitem__(self, key):
def _load_attr_from_module(self, model_type, attr):
module_name = model_type_to_module_name(model_type)
if module_name not in self._modules:
if "Tokenizer" in model_type:
if any(["Tokenizer" in name for name in [model_type, attr]]):
try:
self._modules[module_name] = importlib.import_module(
f".{module_name}.tokenizer", "paddlenlp.transformers"
)
except ImportError:
pass
if module_name not in self._modules:
if "Config" in model_type:
if any(["Config" in name for name in [model_type, attr]]):
try:
self._modules[module_name] = importlib.import_module(
f".{module_name}.configuration", "paddlenlp.transformers"
Expand Down
3 changes: 2 additions & 1 deletion paddlenlp/transformers/auto/tokenizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import importlib
import inspect
import io
import json
import os
Expand Down Expand Up @@ -460,7 +461,7 @@
return tokenizer_class_fast.from_pretrained(pretrained_model_name_or_path, *model_args, **kwargs)
else:
if tokenizer_class_py is not None:
if isinstance(tokenizer_class_py, str):
if inspect.isclass(tokenizer_class_py):

Check warning on line 464 in paddlenlp/transformers/auto/tokenizer.py

View check run for this annotation

Codecov / codecov/patch

paddlenlp/transformers/auto/tokenizer.py#L464

Added line #L464 was not covered by tests
return tokenizer_class_py.from_pretrained(pretrained_model_name_or_path, *model_args, **kwargs)
else:
# Use the first tokenizer class in the list
Expand Down