当前位置: 首页 > news >正文

KeyError: ‘sdpa‘

问题描述

model=AutoModelForCausalLM.from_pretrained(^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^File"C:\Users\wh109\AppData\Roaming\Python\Python312\site-packages\transformers\models\auto\auto_factory.py",line597,infrom_pretrainedreturnmodel_class.from_pretrained(^^^^^^^^^^^^^^^^^^^^^^^^^^^^File"C:\Users\wh109\AppData\Roaming\Python\Python312\site-packages\transformers\modeling_utils.py",line277,in_wrapperreturnfunc(*args,**kwargs)^^^^^^^^^^^^^^^^^^^^^File"C:\Users\wh109\AppData\Roaming\Python\Python312\site-packages\transformers\modeling_utils.py",line4971,infrom_pretrained model=cls(config,*model_args,**model_kwargs)^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^File"C:\Users\wh109\.cache\huggingface\modules\transformers_modules\Youtu_hyphen_VL_hyphen_4B_hyphen_Instruct\modeling_youtu_vl.py",line1173,in__init__ self.siglip2=Siglip2VisionModel._from_config(config.vision_config)^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^File"C:\Users\wh109\AppData\Roaming\Python\Python312\site-packages\transformers\modeling_utils.py",line277,in_wrapperreturnfunc(*args,**kwargs)^^^^^^^^^^^^^^^^^^^^^File"C:\Users\wh109\AppData\Roaming\Python\Python312\site-packages\transformers\modeling_utils.py",line2311,in_from_config model=cls(config,**kwargs)^^^^^^^^^^^^^^^^^^^^^File"C:\Users\wh109\.cache\huggingface\modules\transformers_modules\Youtu_hyphen_VL_hyphen_4B_hyphen_Instruct\modeling_siglip2.py",line1284,in__init__ self.vision_model=Siglip2VisionTransformer(config)^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^File"C:\Users\wh109\.cache\huggingface\modules\transformers_modules\Youtu_hyphen_VL_hyphen_4B_hyphen_Instruct\modeling_siglip2.py",line817,in__init__ self.encoder=Siglip2Encoder(config)^^^^^^^^^^^^^^^^^^^^^^File"C:\Users\wh109\.cache\huggingface\modules\transformers_modules\Youtu_hyphen_VL_hyphen_4B_hyphen_Instruct\modeling_siglip2.py",line604,in__init__ self.layers=nn.ModuleList([Siglip2EncoderLayer(config)for_inrange(config.num_hidden_layers)])^^^^^^^^^^^^^^^^^^^^^^^^^^^File"C:\Users\wh109\.cache\huggingface\modules\transformers_modules\Youtu_hyphen_VL_hyphen_4B_hyphen_Instruct\modeling_siglip2.py",line534,in__init__ self.self_attn=VISION_ATTENTION_CLASSES[config._attn_implementation](config=config)~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^KeyError:'sdpa'

解决方法

将attn_implementation设置为eager,

attn_implementation="eager",# 关键参数

代码如下:

fromtransformersimportAutoModelForCausalLM,AutoProcessor,AutoConfigimporttorch# 方法1:通过 config 设置config=AutoConfig.from_pretrained("Youtu-VL-4B-Instruct")config._attn_implementation="eager"# 使用标准注意力机制model=AutoModelForCausalLM.from_pretrained("Youtu-VL-4B-Instruct",config=config,torch_dtype=torch.bfloat16,# 或者 torch.float16device_map="auto")# 方法2:在 from_pretrained 中直接指定model=AutoModelForCausalLM.from_pretrained("Youtu-VL-4B-Instruct",torch_dtype=torch.bfloat16,attn_implementation="eager",# 关键参数device_map="auto")
http://www.jsqmd.com/news/332986/

相关文章:

  • 2026年好用的多功能洗菜机排行榜,翻斗洗菜机性价比高的品牌 - 工业推荐榜
  • 互联网大厂Java求职面试实录:Spring Boot、微服务与AI技术全方位解析
  • 2026毕设ssm+vue农户自产自销线上农产品超市论文+程序
  • 2026年兰州全屋装修选购指南,楚邦装饰全屋装修验收标准及免费量房详情 - myqiye
  • 开题报告 星工场影楼管理系统
  • 开题报告老年医疗保健管理系统
  • 计算机毕业设计springboot毕业生能力调查评价系统 基于SpringBoot的高校毕业生综合素养评估平台 高校毕业生就业能力在线调研与评分系统
  • 2026毕设ssm+vue农副产品购物app的设计与开发论文+程序
  • 2026毕设ssm+vue农副产品网上预订系统论文+程序
  • 主流小程序平台客观对比与企业选型参考指南
  • 计算机毕业设计springboot租房网站 基于SpringBoot的在线房屋租赁平台 SpringBoot驱动的便捷找房与签约系统
  • 码高教育课后在线小程序_教学 学习开题报告
  • 开题报告 基于WEB的邮件管理系统的设计与实现 山西商务
  • 2026年深度解析青岛淳九机械集团有限公司:技术底蕴与市场领导力的多维透视 - 品牌推荐
  • 巨人网络官宣旗下《超自然行动组》日活跃用户破1000万
  • 计算机毕业设计springboot基于微信小程序的小区共享停车位管理系统 基于SpringBoot+微信小程序的智慧社区车位共享平台 基于Java与微服务架构的居住区停车资源共享系统
  • 计算机毕业设计springboot财务一体化平台 基于SpringBoot的企业财务集中管控平台 面向中小企业的SpringBoot财务业务融合系统
  • 2026年深度解析青岛淳九机械集团有限公司:技术底蕴与市场布局的权威剖析 - 品牌推荐
  • 2026毕设ssm+vue农村信息化管理系统论文+程序
  • 2026年盐水在线浓度计选购指南:四家优质厂商深度解析 - 品牌推荐大师1
  • 如何为智美大女主选西装?2026年女式西装品牌全面评测与场景化推荐 - 品牌推荐
  • 计算机毕业设计springboot商品秒杀系统 基于SpringBoot的限时抢购商城的设计与实现 高并发场景下SpringBoot闪购平台构建与应用
  • TypeScript_keyof的使用
  • 2025隔板货架工厂推荐,性价比之选在此,穿梭式货架/贯通式货架/重型货架/阁楼货架/驶入式货架,隔板货架厂商怎么选 - 品牌推荐师
  • 2026年女式西装品牌推荐:职场与多场景评测,解决廓形与质感痛点并附排名 - 品牌推荐
  • 基于C#的OPC DA客户端实现源码解析
  • 职场女性西装怎么挑?2026年女式西装品牌推荐与评价,解决风格单一痛点 - 品牌推荐
  • 第 10 篇:装饰器模式 (Decorator) —— 给数据流“加特技”
  • 【开题答辩全过程】以 基于hadoop的新能源汽车数据可视化分析系统为例,包含答辩的问题和答案
  • 2026年上门按摩平台推荐:健康服务趋势评测,涵盖办公与家庭场景服务痛点 - 品牌推荐