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权重也合并进去,怎么操作? #6

Closed
apachemycat opened this issue May 29, 2023 · 3 comments
Closed

如果要把LoRA权重也合并进去,怎么操作? #6

apachemycat opened this issue May 29, 2023 · 3 comments
Labels
help wanted Extra attention is needed question Further information is requested

Comments

@apachemycat
Copy link

说明中只有合并原模型与Dif的,如果继续合并Lora模型怎么做?
合并Lora模型后,还能在此基础上继续Fine tuning或者Instrct tuning吗?

@MikeDean2367
Copy link
Collaborator

您好,是可以继续合并的,代码可以参考此处。在合并完成后,您会得到一个完整的权重,从代码的可行性上来说是可以继续fine-tune或者instruct tune的。

@zxlzr zxlzr added the question Further information is requested label May 30, 2023
@apachemycat
Copy link
Author

多谢,我看了您提供的参考,我有个疑问
多LoRA权重合并也是支持的,意味着Base模型上分别用两套数据集训练出来两套LoRA 权重是可以了,这样吧两个权重合并到Base上,与先合并一个权重,然后在这个合并的结果上继续训练,然后再把训练好的权重合并到之前合并的结果里,这两种有什么区别?

@MikeDean2367
Copy link
Collaborator

您好,我没有理解您的意思。我们的模型训练分为两个阶段,第一个阶段是使用中英语料进行全量二次预训练,没有使用LoRA;第二个阶段是用第一步的模型,使用我们构建的指令数据集,使用LoRA微调。

您的问题中提到了多LoRA,在我们的实验中没有这个情况。如果您指的是Chinese LLaMA仓库的话,建议您去咨询他们。(我的理解是他那边的同时合并,并不意味着同时训练,而是使用的您提到的第二种训练,假设base是A,我在A基础上训练了LoRA B,在A+B的基础上训练了LoRA C,那么最后有3个权重,分别是A,B,C,合并的时候可以是先合并(A+B)+C,也可以是A+(B+C),因此您从合并的顺序来推导出训练的顺序是不唯一的)。

最后从技术层面讨论一下这两个的区别。首先对于第一个情况,是一种并行合并,我的理解是分别训练,即用预训练语料在原版LLaMA上用LoRA训练,得到一个权重,用指令语料在原版LLaMA上再次用LoRA训练得到一个权重,最后再将两个LoRA进行合并,这个训练做法没有问题,但是这两个训练过程本来就是独立无关的,因此这种合并是不合理的,在我的知识范围内,这个做法不存在理论支持。对于第二个情况才是正确的且合理的。

@zxlzr zxlzr added the help wanted Extra attention is needed label May 31, 2023
@zxlzr zxlzr closed this as completed May 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants