Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

peft 0.3.0如何设置adapater_name #38

Open
moseshu opened this issue May 4, 2023 · 8 comments
Open

peft 0.3.0如何设置adapater_name #38

moseshu opened this issue May 4, 2023 · 8 comments

Comments

@moseshu
Copy link

moseshu commented May 4, 2023

peft 的0.3.0在LoraModel里增加了一个adapter_name是,这个参数怎么填写?

@huangbaichao
Copy link

huangbaichao commented May 15, 2023

相同版本遇到相同问题。TypeError: LoraModel.init() missing 1 required positional argument: 'adapter_name'

@tu2022
Copy link

tu2022 commented May 16, 2023

相同版本遇到相同问题。TypeError: LoraModel.init() missing 1 required positional argument: 'adapter_name'

你可以换一个版本的peft,我换成了0.3.0.dev0的版本,可以运行

@huangbaichao
Copy link

0.3.0.dev0
你好,我手动安装找不到dev版本,dev版本的是要如何安装呢?能否再指点一下,非常感谢。

image

@tu2022
Copy link

tu2022 commented May 16, 2023

我之前是直接将peft的源码拉下来:git clone https://github.com/huggingface/peft.git
直接运行setup.py安装:python setup.py install。
不过我现在看setup.py的源代码已经更新到0.4.0.dev0了,我没试过0.4.0.dev0版本是否能运行,你可以试一下

@huangbaichao
Copy link

我之前是直接将peft的源码拉下来:git clone https://github.com/huggingface/peft.git 直接运行setup.py安装:python setup.py install。 不过我现在看setup.py的源代码已经更新到0.4.0.dev0了,我没试过0.4.0.dev0版本是否能运行,你可以试一下

非常感谢,我先试试0.3.0.dev0

@huangbaichao
Copy link

在其他地方看到一个写法,暂时解决了这个问题。或许这种方式依旧存在其他问题,欢迎看到的小伙伴指出。

  1. pip install peft==0.3.0
  2. 更改脚本中加载模型的方法
# 自定义模型加载方法
from peft import LoraConfig, get_peft_model, TaskType
import torch

# 自定义加载lora配置方法
def load_lora_config(model):
	config = LoraConfig(
	    task_type=TaskType.CAUSAL_LM, 
	    inference_mode=False,
	    r=8, 
	    lora_alpha=32, 
	    lora_dropout=0.1,
	    target_modules=["query_key_value"]
	)
	return get_peft_model(model, config)

# 加载模型
checkpoint = "THUDM/chatglm-6b"
model = AutoModel.from_pretrained(checkpoint, trust_remote_code=True, revision = 'main')

# 使用自定义的方法加载模型
model = load_lora_config(model)

@pansinm
Copy link

pansinm commented May 16, 2023

0.2.0 似乎能跑

pip install peft==0.2.0

@fxb392
Copy link

fxb392 commented Jun 7, 2023

自定义模型加载方法

from peft import LoraConfig, get_peft_model, TaskType

import torch

自定义加载lora配置方法

def load_lora_config(model):

config = LoraConfig(
    task_type=TaskType.CAUSAL_LM, 
    inference_mode=False,
    r=8, 
    lora_alpha=32, 
    lora_dropout=0.1,
    target_modules=["query_key_value"]
)
return get_peft_model(model, config)

加载模型

checkpoint = "THUDM/chatglm-6b"

model = AutoModel.from_pretrained(checkpoint, trust_remote_code=True, revision = 'main')

使用自定义的方法加载模型

model = load_lora_config(model)

@huangbaichao @lich99 为什么存在两种配置lora adapter的方式?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants