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

相关推荐
JK Chen几秒前
faster_whisper,视频转文字,并生成字幕文件
python·whisper·音视频
一点一木7 小时前
🚀 2026 年 4 月 GitHub 十大热门项目排行榜 🔥
人工智能·github
做怪小疯子8 小时前
华为笔试0429
python·numpy
Warson_L8 小时前
Dictionary
python
淡海水8 小时前
【AI模型】常见问题与解决方案
人工智能·深度学习·机器学习
HIT_Weston8 小时前
65、【Agent】【OpenCode】用户对话提示词(费米估算)
人工智能·agent·opencode
njsgcs8 小时前
我的知识是以图片保存的,我的任务状态可能也与图片有关,我把100张知识图片丢给vlm实时分析吗
人工智能
星爷AG I9 小时前
20-4 长时工作记忆(AGI基础理论)
人工智能·agi
#卢松松#9 小时前
用秒悟(meoo)制作了一个GEO查询小工具。
人工智能·创业创新
zandy10119 小时前
Agentic BI 架构实战:当AI Agent接管数据建模、指标计算与可视化全链路
人工智能·架构