-
Notifications
You must be signed in to change notification settings - Fork 547
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
Lora微调后要怎么加载测试呢? #298
Comments
问的太对了哥,给我愁死了,这readme写的八成是写错了,那个msg应该是model |
我也是很疑惑 |
先对模型进行合并,就可以推理了 |
怎么合并呢?哪里有示例或者demo吗
…On Fri, 28 Jun 2024 at 7:53 PM, lyc728 ***@***.***> wrote:
先对模型进行合并,就可以推理了
—
Reply to this email directly, view it on GitHub
<#298 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/A26FH73GSP2KYPQ3CFOQXW3ZJUXBVAVCNFSM6AAAAABJ5H5MTSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCOJWGUZTQMBXGQ>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
谢谢 昨天在issues看到了合并的方法 就可以用了 |
|
合并后的模型和基础模型对比,效果明显么 |
写成model会报错,就用msg就好了,不用管返回值。但是在运行的时候,显存占多少啊?我这里24G显存不够用,多显卡运行又报错 |
有没有运行全量微调后加载测试的,我使用官方提供的lora微调的加载测试的会报错 |
Lora finetune后,用官方代码调试,device='auto' 改成自己的device, 比如cpu or gpu(否则报错:‘NotImplementedError: Cannot copy out of meta tensor; no data!’),测试通过,结果正常。 |
@MonkeyNi 您好,请问用官方代码加载lora,到了msg = model.load_state_dict(vpm_resampler_embedtokens_weight, strict=False),之后具体怎么进行测试啊 |
参考chat代码就行 |
更新最新代码再试下 |
from chat import MiniCPMVChat, img2base64 torch.manual_seed(0) from peft import AutoPeftModelForCausalLM model = AutoPeftModelForCausalLM.from_pretrained( vpm_resampler_embedtokens_weight = torch.load(f"{path_to_adapter}/vpm_resampler_embedtokens.pt") msg = model.load_state_dict(vpm_resampler_embedtokens_weight, strict=False) im_64 = img2base64('./assets/airplane.jpeg') msgs = [{"role": "user", "content": "Tell me the model of this aircraft."}] inputs = {"image": im_64, "question": json.dumps(msgs)} |
这看起来是对的 |
微调之后,能不能用自定义的数据集,对模型进行测试?能的话咋搞 |
from peft import AutoPeftModelForCausalLM path_to_adapter="xxxxxx/output_minicpmv2_lora/checkpoint-200" vpm_resampler_embedtokens_weight = torch.load(f"{path_to_adapter}/vpm_resampler_embedtokens.pt") model.load_state_dict(vpm_resampler_embedtokens_weight, strict=False) im_64 = img2base64('xxxxxxxxxx') msgs = [{"role": "user", "content": "What is the car mileage?"}] inputs = {"image": im_64, "question": json.dumps(msgs)} Traceback (most recent call last): |
试试改成model.chat(mage=im_64, msgs=json.dumps(msgs),tokenizer=tokenizer) |
finetune/readme.md下面写的加载lora方法的方法只有一部分,请问具体要怎么加载测试呢?
The text was updated successfully, but these errors were encountered: