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

ValueError: You cannot perform fine-tuning on purely quantized models.

在使用peft 微调8bit 或者4bit 模型的时候,可能会报错:

You cannot perform fine-tuning on purely quantized models. Please attach trainable adapters on top of the quantized model to correctly perform fine-tuning. Please see: https://huggingface.co/docs/transformers/peft for more details"

查看trainer.py 代码

# At this stage the model is already loaded
if _is_quantized_and_base_model and not _is_peft_model(model):raise ValueError("You cannot perform fine-tuning on purely quantized models. Please attach trainable adapters on top of"" the quantized model to correctly perform fine-tuning. Please see: https://huggingface.co/docs/transformers/peft"" for more details")

_is_quantized_and_base_model检查是否是量化模型

 _is_quantized_and_base_model = getattr(model, "is_quantized", False) and not getattr(model, "_hf_peft_config_loaded", False)

_is_peft_model检查是否是PeftModel或者PeftMixedModel

def _is_peft_model(model):if is_peft_available():classes_to_check = (PeftModel,) if is_peft_available() else ()# Here we also check if the model is an instance of `PeftMixedModel` introduced in peft>=0.7.0: https://github.com/huggingface/transformers/pull/28321if version.parse(importlib.metadata.version("peft")) >= version.parse("0.7.0"):from peft import PeftMixedModelclasses_to_check = (*classes_to_check, PeftMixedModel)return isinstance(model, classes_to_check)return False

DEBUG:

1.加载模型的时候已经设置了量化参数,确定是量化模型;
2.使用了model = get_peft_model(model, config),为什么不是PeftModel,那model是什么类型呢?

<class 'src.peft.peft_model.PeftModelForCausalLM'>

这是因为在测试peft代码的时候,设置了使用本地peft代码,而不是安装的peft库,就导致类型出现了错误。

from src.peft import LoraConfig, TaskType, get_peft_model
改为
from peft import LoraConfig, TaskType, get_peft_model

修改后就可以训练了。


http://www.mrgr.cn/news/42674.html

相关文章:

  • 18.安卓逆向-frida基础-调试实战2
  • 多线程-初阶(1)
  • 利用Python输入n个用空格分隔的整数 ← list(map(int,input().split()))
  • ROS2(Robot Operating System 2)与树莓派(Raspberry Pi)
  • 基于拥堵模型的轻量级平台公交室内情况监控系统
  • Redis数据库与GO(二):list,set
  • C++教程一口气讲完!(万字讲解)♪(´▽`)上
  • 【Linux】进程地址空间、环境变量:从理论到实践(三)
  • 【Linux】-----进程第二弹(优先级,环境变量)
  • HAR笔记--事件相机(event camera)数据常见处理方法总结
  • 开源AI智能名片在打造人格化品牌平台中的应用:以抖音、快手、微博为例
  • csp-j模拟三补题报告
  • YouTube音视频合并批处理基于 FFmpeg的
  • 《Linux服务与安全管理》| 配置YUM源并验证
  • linux驱动:(21)ioctl接口(二)驱动与应用程序传递ioctl命令
  • 90后新生代女高音歌唱家李思思声乐大师课公益讲座即将开启
  • PyTorch实现卷积神经网络CNN
  • 生产消费者模式
  • 自动驾驶系列—颠覆未来驾驶:深入解析自动驾驶线控转向系统技术
  • 无IDEA不Java:快速掌握Java集成开发环境