Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: AttributeError: module 'paddlenlp.transformers.ernie.tokenizer' has no attribute 'ErnieFastTokenizer' #6666

Closed
1 task done
wuhaoyupku opened this issue Aug 9, 2023 · 1 comment · Fixed by #8367
Assignees
Labels
bug Something isn't working triage

Comments

@wuhaoyupku
Copy link

软件环境

paddle-bfloat                  0.1.7
paddle2onnx                    1.0.5
paddlefsl                      1.1.0
paddlenlp                      2.5.2
paddlepaddle-gpu               2.4.1
x2paddle                       1.4.0

重复问题

  • I have searched the existing issues

错误描述

推理的时候报错:
AttributeError: module 'paddlenlp.transformers.ernie.tokenizer' has no attribute 'ErnieFastTokenizer'

稳定复现步骤 & 代码

使用model_zoo/ernie-3.0的示例代码,修改了
tokenizer = AutoTokenizer.from_pretrained(model_args.model_name_or_path, use_fast=True)
用来使用 FastTokenizer。
训练完成之后,模型的tokenizer_config.json里面 tokenizer_class:"ErnieFastTokenizer"

然后加载模型进行推理,报错
AttributeError: module 'paddlenlp.transformers.ernie.tokenizer' has no attribute 'ErnieFastTokenizer'
推理的时候也是用
tokenizer = AutoTokenizer.from_pretrained(model_args.model_name_or_path, use_fast=True)

查看了一下tokenizer代码:
if init_class:
class_name = cls._name_mapping[init_class]
import_class = import_module(f"paddlenlp.transformers.{class_name}.tokenizer")
tokenizer_class = getattr(import_class, init_class)
if use_fast:
fast_tokenizer_class = cls._get_fast_tokenizer_class(init_class, class_name)
tokenizer_class = fast_tokenizer_class if fast_tokenizer_class else tokenizer_class
return tokenizer_class

在这个地方:
tokenizer_class = getattr(import_class, init_class)

确实是没有对tokenizer_config.json里面 tokenizer_class:"ErnieFastTokenizer" 进行处理的,因为use_fast的分支在后面。

@wuhaoyupku wuhaoyupku added the bug Something isn't working label Aug 9, 2023
@github-actions github-actions bot added the triage label Aug 9, 2023
@wuhaoyupku wuhaoyupku changed the title [Bug]: [Bug]: AttributeError: module 'paddlenlp.transformers.ernie.tokenizer' has no attribute 'ErnieFastTokenizer' Aug 10, 2023
@w5688414
Copy link
Contributor

w5688414 commented May 7, 2024

感谢您的反馈

#8367

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants