使用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

相关推荐
回眸&啤酒鸭3 天前
【回眸】Minicart 电商购物车核心功能落地指南
人工智能
一隅论数智3 天前
给AI一张“业务概念地图“:本体如何从哲学走向企业智能
大数据·人工智能·经验分享·笔记·学习·学习方法·政务
默_笙3 天前
🍙 给每个请求过安检:FastAPI 是怎么把校验写进类型注解的
python
AI的探索之旅3 天前
97 个 OpenCV 实例(三十):双目立体,从标定到点云
人工智能·opencv·计算机视觉
AlbertZein3 天前
Step-5-Preview 上手实测:3D 游戏、金融分析、网页设计一次跑完
人工智能·aigc
LaughingZhu3 天前
Product Hunt 每日热榜 | 2026-09-19
人工智能·深度学习·神经网络·搜索引擎·百度
qq_426003963 天前
启动playwright录制codegen生成自动化测试脚本
python·自动化
虎头金猫3 天前
4K 视频总卡在公网带宽?用 N1 + OpenList 把网盘播放链路重新理顺
运维·服务器·网络·python·容器·beautifulsoup·pandas
美狐美颜SDK开放平台3 天前
开发直播APP时如何接入视频美颜SDK?开发流程与注意事项
android·人工智能·计算机视觉·音视频·直播美颜sdk