使用LLM模型的tokenizer报错AttributeError: ‘dict‘ object has no attribute ‘model_type‘

代码

python 复制代码
from transformers import AutoTokenizer
...
model_path = "/.../models/Qwen/Qwen2.5-0.5B-Instruct"
    train_data_path = "/...dataset/datasettrain.json"
    tokenizer = AutoTokenizer.from_pretrained(model_path, trust_remote_code=True)

报错:

plaintext 复制代码
AttributeError: 'dict' object has no attribute 'model_type'

解决方法:

把transformers版本改一下。(报错时我使用的是transformers== 4.57.2)

改成transformers==4.57.1即可

参考地址:

https://github.com/vllm-project/vllm/issues/29368

相关推荐
HIT_Weston3 小时前
45、【Agent】【OpenCode】本地代理分析(请求&接收回调)
人工智能·agent·opencode
知行合一。。。3 小时前
Python--04--数据容器(总结)
开发语言·python
架构师老Y3 小时前
008、容器化部署:Docker与Python应用打包
python·容器·架构
逻辑君3 小时前
认知神经科学研究报告【20260010】
人工智能·深度学习·神经网络·机器学习
星河耀银海3 小时前
远控体验分享:安全与实用性参考
人工智能·安全·微服务
lifewange3 小时前
pytest-类中测试方法、多文件批量执行
开发语言·python·pytest
企业架构师老王4 小时前
2026企业架构演进:科普Agent(龙虾)如何从“极客玩具”走向实在Agent规模化落地?
人工智能·ai·架构
GreenTea4 小时前
一文搞懂Harness Engineering与Meta-Harness
前端·人工智能·后端
pluvium274 小时前
记对 xonsh shell 的使用, 脚本编写, 迁移及调优
linux·python·shell·xonsh
鬼先生_sir4 小时前
Spring AI Alibaba 1.1.2.2 完整知识点库
人工智能·ai·agent·源码解析·springai