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

相关推荐
IT_陈寒43 分钟前
Vite的热更新突然不香了,排查三小时差点砸键盘
前端·人工智能·后端
用户8356290780512 小时前
Python 实现 PDF 文件加密与解密方法
后端·python
用户8356290780512 小时前
使用 Python 冻结与拆分 Excel 窗格教程
后端·python
阿里云大数据AI技术3 小时前
构建高转化海外电商搜索:阿里云OpenSearch行业算法版的全链路智能优化策略实战
人工智能·搜索引擎
Awu12273 小时前
⚡从零开发 Agent CLI(五)实现一个可治理、可扩展的工具系统
前端·人工智能·claude
字节跳动视频云技术团队3 小时前
让 Agent 成为音视频工作台:AI MediaKit CLI + Skill 发布
人工智能·音视频开发
魏祖潇3 小时前
framework 整合实战——DDD/TDD/SDD 三件套在 framework 仓的真实落地
人工智能·后端
Token炼金师4 小时前
去噪扩散:从随机噪声到高保真图像的数学之路
人工智能·aigc
这个DBA有点耶4 小时前
AI写的SQL跑崩了生产库,这锅谁背?
数据库·人工智能·程序员
阿里云大数据AI技术4 小时前
阿里云 EMR AI 助手正式发布:从问答工具到全栈智能运维助手
运维·人工智能