March 28, 2024, 9:21 p.m. | /u/kessa231

Machine Learning www.reddit.com

Just skimmed their official implementation code and curious about this.
For example, in their Embedding module they declared and used lora parameters like this:

self.lora_A = nn.Parameter(self.weight.new_zeros((r, num_embeddings)))
self.lora_B = nn.Parameter(self.weight.new_zeros((embedding_dim, r)))
...
self.weight.data -= (self.lora_B @ self.lora_A).transpose(0, 1) * self.scaling
...
after_A = F.embedding(
x, self.lora_A.transpose(0, 1), self.padding_idx, self.max_norm,
self.norm_type, self.scale_grad_by_freq, self.sparse
)
result += (after_A @ self.lora_B.transpose(0, 1)) * self.scaling
...

So, why don't they just declare like this and use without transpose?

self.lora_A = nn.Parameter(self.weight.new_zeros((r, embedding_dim)))
self.lora_B …

code data embedding example implementation lora machinelearning parameters scaling

Data Architect

@ University of Texas at Austin | Austin, TX

Data ETL Engineer

@ University of Texas at Austin | Austin, TX

Lead GNSS Data Scientist

@ Lurra Systems | Melbourne

Senior Machine Learning Engineer (MLOps)

@ Promaton | Remote, Europe

AIML - Sr Machine Learning Engineer, Data and ML Innovation

@ Apple | Seattle, WA, United States

Senior Data Engineer

@ Palta | Palta Cyprus, Palta Warsaw, Palta remote