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

lora微调后的模型需要进行合并吗 #885

Closed
HiXxxSss opened this issue Feb 6, 2025 · 3 comments
Closed

lora微调后的模型需要进行合并吗 #885

HiXxxSss opened this issue Feb 6, 2025 · 3 comments

Comments

@HiXxxSss
Copy link

HiXxxSss commented Feb 6, 2025

我微调后的模型似乎没有学习到知识。需要和原始模型的权重进行合并吗?微调的脚本是:internvl_chat/shell/internvl2.5/2nd_finetune/internvl2_5_2b_dynamic_res_2nd_finetune_lora.sh

@yuecao0119
Copy link
Collaborator

你好,

需要合并权重的,可以参考教程的merging-lora-weights部分。

@Mr-Jin2
Copy link

Mr-Jin2 commented Feb 7, 2025

你好,

需要合并权重的,可以参考教程的merging-lora-weights部分。

再请教您一下,merge是必须的吗?看起来merge只是将lora权重融合到原始模型中方便推理,如果不merge,理论上应该也能正常出结果吧?

@HiXxxSss
Copy link
Author

HiXxxSss commented Feb 7, 2025

你好,

需要合并权重的,可以参考教程的merging-lora-weights部分。

您好,感谢您的回复。我尝试使用教程里的方法进行merge,但是效果依旧不佳。具体来说,我在原有模型的基础上加入了分类头实现分类。数据有6w+条。微调快结束时模型输出的分类概率以及真实标签例如:
tensor([[0.0081, 0.9492, 0.0074, 0.0066, 0.0063, 0.0076, 0.0070, 0.0068],
[0.9570, 0.0061, 0.0061, 0.0064, 0.0059, 0.0061, 0.0063, 0.0059],
[0.9531, 0.0066, 0.0064, 0.0068, 0.0064, 0.0066, 0.0066, 0.0064],
[0.9570, 0.0059, 0.0067, 0.0065, 0.0065, 0.0063, 0.0067, 0.0061],
[0.0067, 0.0056, 0.0052, 0.0056, 0.0050, 0.0064, 0.9609, 0.0062],
[0.0065, 0.0058, 0.0064, 0.9570, 0.0059, 0.0063, 0.0068, 0.0065],
[0.9570, 0.0060, 0.0062, 0.0062, 0.0062, 0.0062, 0.0060, 0.0062],
[0.9570, 0.0060, 0.0062, 0.0064, 0.0064, 0.0062, 0.0062, 0.0062]],
dtype=torch.bfloat16) tensor([1, 0, 0, 0, 6, 3, 0, 0])
但不论是merge前还是merge后的模型进行测试,对各个类别的输出概率却几乎一致。可以向您请教一下为什么吗?

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

3 participants