【大模型】解决报错ValueError: Tokenizer class Qwen2Tokenizer does not exist or is not currently imported.

【大模型】解决报错ValueError: Tokenizer class Qwen2Tokenizer does not exist or is not currently imported.

运行Qwen1.5-7B-Chat大模型时报错:

2024-04-29 17:50:54,192 - INFO - intel_extension_for_pytorch auto imported
Traceback (most recent call last):
  File "/root/xx/llm/ipex/test-xpu.py", line 16, in <module>
    tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/xx/miniconda3/envs/llm-ipex/lib/python3.11/site-packages/transformers/models/auto/tokenization_auto.py", line 699, in from_pretrained
    raise ValueError(
ValueError: Tokenizer class Qwen2Tokenizer does not exist or is not currently imported.

环境

  • ubuntu 22.04
  • python 3.11

错误信息

2024-04-29 17:50:54,192 - INFO - intel_extension_for_pytorch auto imported
Traceback (most recent call last):
  File "/root/xx/llm/ipex/test-xpu.py", line 16, in <module>
    tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/xx/miniconda3/envs/llm-ipex/lib/python3.11/site-packages/transformers/models/auto/tokenization_auto.py", line 699, in from_pretrained
    raise ValueError(
ValueError: Tokenizer class Qwen2Tokenizer does not exist or is not currently imported.

重点错误:

ValueError: Tokenizer class Qwen2Tokenizer does not exist or is not currently imported.

解决方法

  • 查看 transformers 版本
pip list|grep transformer

输出信息:

transformers                4.31.0

  • 错误分析
    transformers 的版本太低导致的imported错误
ValueError: Tokenizer class Qwen2Tokenizer does not exist or is not currently imported.
  • 解决方法
    升级 transformers 版本,如下:
pip install  transformers==4.40  -i https://mirrors.aliyun.com/pypi/simple/

查看transformers 的版本可以在 https://pypi.org/project/transformers/ 查看,推荐用最新的版本!!

测试

运行推理,正常执行!!!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

szZack

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值