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

What does the multi_lora_a and multi_lora_b mean in the code? #20

Open
CaffreyR opened this issue Oct 3, 2022 · 3 comments
Open

What does the multi_lora_a and multi_lora_b mean in the code? #20

CaffreyR opened this issue Oct 3, 2022 · 3 comments

Comments

@CaffreyR
Copy link

CaffreyR commented Oct 3, 2022

Hi, may I ask that what does the multi_lora_a mean ? Is there any paper that has explained it ? Many thanks!

if self.scaling_rank:

@HaokunLiu
Copy link
Collaborator

It's a notation from LoRA. LoRA uses the product of two matrices BA to create a low-rank matrix. In the original LoRA design, BA should be added to W. Multi means instead of adding to W, we use elementwise multiplication. In fact, if we (i) change add to multiply, (ii) set the rank is set to 1, and (iii) only keep the three internal parameters, we can derive IA3 from LoRA.

@CaffreyR
Copy link
Author

CaffreyR commented Oct 4, 2022

Hi @HaokunLiu , is there any work that shows the equation of this method? What is the meaning of elementwise multiplication? Thanks!

@HaokunLiu
Copy link
Collaborator

HaokunLiu commented Oct 18, 2022

Wait, somehow I didn't see your reply. Sorry.
For the equation of LoRA, you can refer to their paper. https://arxiv.org/abs/2106.09685
Element-wise multiplication simply means when you have two tensors of the same shape (or one tensor is expandable to have the same shape as the other), for instance X = (5, 3, 16) 3D-tensor, Y = (3, 16) 2D-matrix. you do multiplication at every location. So the output Z = (5, 3, 16) 3D-tensor will be Z_(i,j,k) = X(i,j,k) * Y(j,k), for all the i in {0,1,...,3}, j in {0, 1,2}, and k in {0, 1, ..., 16).

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

2 participants