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

Initialization for LoRA weights A and B initialized #1728

Open
4 tasks
sanaullah-06 opened this issue May 13, 2024 · 1 comment
Open
4 tasks

Initialization for LoRA weights A and B initialized #1728

sanaullah-06 opened this issue May 13, 2024 · 1 comment

Comments

@sanaullah-06
Copy link

System Info

Screenshot 2024-05-13 195549

The comment and code are contradictory please anyone explain it to me.

Who can help?

@BenjaminBossan

Information

  • The official example scripts
  • My own modified scripts

Tasks

  • An officially supported task in the examples folder
  • My own task or dataset (give details below)

Reproduction

nn.init.zeros_(self.lora_embedding_B[adapter_name])
nn.init.normal_(self.lora_embedding_A[adapter_name])

Expected behavior

nil.

@BenjaminBossan
Copy link
Member

You're right, the comment doesn't match the code. After a quick glance at the LoRA paper, I don't see an explicit mention of how LoRA should be initialized for embedding layers. When checking the reference implementation by Microsoft, they, do, however, use the same scheme as we do:

https://github.com/microsoft/LoRA/blob/4c0333854cb905966f8cc4e9a74068c1e507c7b7/loralib/layers.py#L55-L60

Therefore, I think the code is correct.

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