PEFT LoRA Explained in Detail - Fine-Tune your LLM on your local GPU

Поділитися
Вставка
  • Опубліковано 27 гру 2024

КОМЕНТАРІ • 89

  • @Blessed-by-walking-show
    @Blessed-by-walking-show Рік тому +11

    Most underrated channel on YT. Deserves a million subs. Thanks.

  • @jett_royce
    @jett_royce 7 місяців тому +1

    Great video that doesn't hand-wave away the mathematical and implementation details. Exactly the kind of content I love. Thank you!

  • @Shionita
    @Shionita Рік тому +1

    I'm having so many flashbacks from my PCA classes😅, you explain much better than my teacher btw...

  • @ad_academy
    @ad_academy 10 місяців тому

    BEST video on PEFT and LORA..I was not able to undertsand the concepts from other videos, by searching more on YT I land up on this video and I understood whole concepts. JUST AWESOMEEEEEEE..

  • @ianmatejka3533
    @ianmatejka3533 Рік тому +7

    Outstanding video, the best one I have seen on LoRA!
    I have one question about the SVD decomposition procedure:
    A full fine tune of a large model such as LLaMa would require loading the entire model tensors onto the GPU and adjusting them by delta(phi) for all the parameters.
    In LoRA, delta(phi) is replaced with 2 smaller SVD matrices that are trained and then multiplied back into the full size and added to the original parameters.
    My question is this.
    When you generate the 2 smaller SVD matrices, you still need to load in the full size tensor to then decompose. In PEFT, are the 2 SVD matrices calculated once at the beginning for all the different tensors before fine tuning occurs? Also how is it possible to backpropagate through the 2 smaller matrices without combining them back together on the GPU?

    • @pumplove81
      @pumplove81 Рік тому +5

      very thoughtful query.. forced me to read the paper :) .. basically you are right about loading the initial full sized matrices but then they are frozen for the rest of the fine tuning process and then the lower ranked / decomposed matrices kick in ..they DO NOT need to be recombined since the idea is NOT to create an exact replica of the information contained in the pre trained model. All we need is a close approximation which is provided by combining these 2 lower ranked johnnies ( U multiplied with top N ranked singular values AND Vt mult with top N ranked sv's)..and since they are both trainable , these are the weights that will then be used. So during inference, you will have the impact of both the pre trained LLM / LM and then the task specific representations of the LoRA ..this is what i have understood ..if there's a fallacy here, please do point out .. i love to be wrong ..helps better learnin

    • @auresdz701
      @auresdz701 11 місяців тому

      @@pumplove81 Anyways we need to do feed-forward through the original model + BA. Maybe we will just have a gain not to store a lot of gradients during backprop.

  • @suryanshsinghrawat961
    @suryanshsinghrawat961 Рік тому

    Best video on LORA ever! Simply can't get better than this 🏆

    • @code4AI
      @code4AI  Рік тому

      My subscriber are the best!

  • @R8man012
    @R8man012 4 місяці тому

    According to the study in the video, does Lora really achieve better results than full fine tuning of all parameters of the entire model? Does this mean that it is not only less demanding on computing resources, but also has better performance?

  • @changtimwu
    @changtimwu Рік тому

    Thank you for explaining. I previously believed that LoRa was a stable diffusion generating beauty,

  • @bhavulgauri7832
    @bhavulgauri7832 Рік тому +3

    This is so well done. You inspired me to create similar content as well. Hats off!

  • @SandeepGupta1304
    @SandeepGupta1304 Рік тому

    This is really awesome... you nailed it. Such explanation can only come from deep understanding. Thank you very much..

  • @uraskarg710
    @uraskarg710 Рік тому

    Best video and explanation on LoRA, thank you for your efforts!

  • @auresdz701
    @auresdz701 11 місяців тому

    I still do not understand how LORA preserves previous information of the original dataset? Lets say our base model is a bert trained on wikipedia, when using LORA, lets consider the first block of attention, we feed forward the input features to the original weights and to the BA matrix, then we add the two results. In this way the next layer inputs are changed whereas the weights in the next layers expects something else. I still don't get it.

  • @ricosrealm
    @ricosrealm Рік тому

    Superb video. Excellent presentation of all the concepts and easy to understand. You have a great teaching style sir.

  • @ko-Daegu
    @ko-Daegu Рік тому

    what tool r u using for the presentation i love the smooth transitions

  • @BradleyKieser
    @BradleyKieser Рік тому +2

    Absolutely brilliantly explained. Love this guy's style of teaching and his casual humour. Do we have to drop to int8 for PEFT?

  • @davidromero1373
    @davidromero1373 Рік тому

    Hi a question, can we use lora to just reduce the size of a model and run inference, or we have to train it always?

  • @ruchaapte5124
    @ruchaapte5124 6 місяців тому

    Superb video :) Very clear and concise explanation. Thank you.

    • @code4AI
      @code4AI  6 місяців тому

      Thank you for this comment. Appreciate it if people take time for a feedback.

  • @sk8l8now
    @sk8l8now Рік тому +21

    It doesn't get better than this ❤

  • @aurko-c1d
    @aurko-c1d Рік тому

    Every matrix can be represented as a product of matrices BA. Could this be used to compress models?

    • @krittaprottangkittikun4190
      @krittaprottangkittikun4190 11 місяців тому +1

      Just my guess, I think you might be able to compress the models for storage but when you actually want to do inference you need to decompress it before use.

  • @johnosborne6175
    @johnosborne6175 Рік тому +1

    Great presentation! A nomenclature question for you, in Figure 1 in the LoRA paper they have "B=0" and "A=Nu(0,sigma^2). I'm not sure how that relates to the description of A and B, can you give any insight?

    • @johnosborne6175
      @johnosborne6175 Рік тому +1

      I'll answer my own question - it looks like the Figure 1 is just showing initialization. I had forgotten that N is the symbol for the Gaussian distribution, so it is just saying they are initializing A with a Gaussian distribution with a mean of 0 and initialization B = 0 since the initial delta for weights is zero at the start of training.

  • @JuanUys
    @JuanUys Рік тому

    I'm currently looking for a resource on how to pick `modules_to_save` for LoraConfig (and perhaps the other values too, although those just seem like accuracy trade-offs too). Will update here if I can answer my own question.

  • @steventan8416
    @steventan8416 Рік тому

    very clear explaination on low-rank and LLM

  • @jakeh1829
    @jakeh1829 Рік тому

    Hi boss, I have a question: If I finetune 4 LoRA models based on an LLM (e.g. Llama13b), each LoRA trained on a specific task. Can I deploy all the 5 models on the same GPU (includes the parameters of 4 LoRAs and the base model)? For example, let's suppose each adapter takes 0.5GB vram and the base model takes 26GB vram on the GPU; is it possible to deploy all sets of LoRAs and the base model on the same GPU with the usage of 28GB? (26+0.5*4=28GB)

    • @jaskiratsinghsodhi
      @jaskiratsinghsodhi Рік тому

      The deployment framework needs to provide this support. technically saying this should be possible if the architecture supports switching instead of just sequentially calculating
      Not sure if such support exists in any framework. But then again I don't have knowledge of all frameworks.

  • @faisalq4092
    @faisalq4092 Рік тому

    does it work on models i trained using tf? or just the models imported from the hugging face library?

  • @KA-kp1me
    @KA-kp1me Рік тому

    hmm, so assuming I have a model X with multiple lora adapters trained on specific tasks. Is it possible to merge all those adapters back to single model? Just curious :)

  • @paturibharath7948
    @paturibharath7948 Рік тому

    outstanding video. Brilliantly explained complex topics.. I have one question, Can we do Lora to multi modal architectures like Donut which is a combination of Swing transformer + Bard ? Any pointers to do this

    • @code4AI
      @code4AI  Рік тому

      If you have access to Bard, to inject additional tensors, and then fine-tune Bard, on its compute infrastructure, you work for Google and know the answer to your question.

  • @sayhellojoel
    @sayhellojoel Рік тому

    Thanks for the great video! Is OpenAI using adapters or a similar technology for the fine-tuning they offer on GPT-3 base models?

    • @code4AI
      @code4AI  Рік тому

      I have not seen any official documentation by the company about this ...

    • @digitalsoultech
      @digitalsoultech Рік тому

      Open AI are not releasing how they are trained the AI

  • @ArgenisLeon
    @ArgenisLeon Рік тому

    This is Gold. Thanks for this amazing content.

    • @code4AI
      @code4AI  Рік тому

      Great feedback. Thanks.

  • @debashisghosh3133
    @debashisghosh3133 Рік тому +3

    Beautiful...Beautiful...

    • @code4AI
      @code4AI  Рік тому

      Appreciate your positive feedback! Thank you!

  • @ekbastu
    @ekbastu Рік тому

    Subscribed!
    Champion explanation. Thank you

  • @siyuanma2323
    @siyuanma2323 Рік тому +2

    Some hidden gem!

  • @xidian2008
    @xidian2008 Рік тому

    where can I download the PPTs

  • @proterotype
    @proterotype 10 місяців тому

    Dude, you’re like a gift

  • @Rise2Excel-wi3gy
    @Rise2Excel-wi3gy 9 місяців тому

    Top notch explanation 💯🔥

  • @Philip8888888
    @Philip8888888 Рік тому

    This was an amazing explanation. Thank you.

  • @akashbhandari867
    @akashbhandari867 Рік тому

    Great video again sir.
    I need some guidance from you.
    Let's say i have a very large text lines those are belongs to doctor's CMS dataset, their publication and clinical trials.
    I want to train a pretrained model with thses datasets.
    After request questions would looks like: who is the best urologist at New York?
    Can you guide to take a correct path to achieve this.
    Like with language model should I pick to fine tune on my data.
    My previous experience:
    1. Langchain interface, llm=openAI and chromadb.
    Result are too good but openai is not a open source.
    2. Same as above but this time i used llm = Dolly 2.0 12b/7b model. Result's are not accurate. They even can't count the number of paper published by doctor.
    So now I want to fine tune a pretrained model with my data.
    Can you suggest me how can achieve this.
    Or any better approach?

  • @wobblynl1742
    @wobblynl1742 Рік тому

    Dude your explanations are 💯👌

  • @gossipGirlMegan
    @gossipGirlMegan Рік тому

    Love the speed of explaination!
    Clean and accurate!

  • @cedricmanouan2333
    @cedricmanouan2333 Рік тому

    Just Wow !!!
    This is a great video!

  • @gurudevilangovan
    @gurudevilangovan Рік тому

    Thank you for the amazing video!

  • @avinashkaur1406
    @avinashkaur1406 Рік тому

    Such great content! Is it possible to get the slides? Thanks!

  • @toromanow
    @toromanow Рік тому

    Wunderbar. Vielen Dank.

  • @wilfredomartel7781
    @wilfredomartel7781 Рік тому

    Reaaallly amazing explanation👏👏👏

  • @YiyunZhou-w4f
    @YiyunZhou-w4f Рік тому +1

    Amazing explanation!!!!

    • @code4AI
      @code4AI  Рік тому

      Glad you think so!

  • @mohamedahmed-fn8qb
    @mohamedahmed-fn8qb Рік тому +1

    Amazing explaining ❤️

  • @hughding7433
    @hughding7433 Рік тому

    讲得非常好,awesome impressive!

  • @chia-hsuanchang6609
    @chia-hsuanchang6609 Рік тому

    Wonderful explanation!

  • @GauravVirmani-d6t
    @GauravVirmani-d6t Рік тому

    Absolute gem

  • @BlueDopamine
    @BlueDopamine Рік тому

    Nice Explanation Very Good

  • @EkShunya
    @EkShunya Рік тому

    WoW everytime, thank you

    • @code4AI
      @code4AI  Рік тому

      Thank you for this feedback.

  • @echofloripa
    @echofloripa Рік тому

    You lost me at the linear algebra, I decided I will abstract that part 🤣

  • @oorcinus
    @oorcinus Рік тому

    Quantification and quantization are two very different things.

    • @code4AI
      @code4AI  Рік тому +1

      Quantization is the mapping of a k-bit integer to a real element in Domain D, or
      (1) Compute a normalization constant N that transforms the input tensor T into the range of the domain D of the target quantization data type Q, (2) for each element of T/N find the closest corresponding value q(i) in the domain D, (3) store the index i corresponding to q(i) in the quantized output tensor T(Q). That is so easy in information theory, that when I compare it to real physics, I smile and think of it as a singular quantification problem. And beliefs manifest themselves in language. Good point!

    • @oorcinus
      @oorcinus Рік тому

      @@code4AI Well, FWIW, quantization sort of just happens in real physics, if you go far enough ;)

  • @snehotoshbanerjee1938
    @snehotoshbanerjee1938 Рік тому

    Fantastic!!

  • @sourabharsh16
    @sourabharsh16 Рік тому

    very well explained.

    • @code4AI
      @code4AI  Рік тому

      Thank you for your feedback!

  • @supriyochakrabortybme
    @supriyochakrabortybme Рік тому

    Thank You

  • @riser9644
    @riser9644 Рік тому

    Wow awesome videos ❤

  • @dyjiang1350
    @dyjiang1350 Рік тому

    You spend a lot of time talk about SVD, how does it related to LoRA, does Lora use SVD in it algorithm?

    • @jaskiratsinghsodhi
      @jaskiratsinghsodhi Рік тому

      Thats what he tried to show as far as I understood, the equations for decomposition are the same.

  • @mohit0901
    @mohit0901 11 місяців тому

    NICE !!!

  • @666kaotik666
    @666kaotik666 Рік тому

    kudos

  • @alealejandroooooo
    @alealejandroooooo Рік тому

    Subscribed.

  • @efexzium
    @efexzium Рік тому

    letters and voice is one of the best ways to confuse an audience. There is plenty of studies that prove this the brain can only do one thing at a time.

  • @keshav2136
    @keshav2136 Рік тому

    👍🏻

  • @TL-fe9si
    @TL-fe9si Рік тому

    Comment for the algorithm👏

  • @fire17102
    @fire17102 Рік тому +2

    First 🦄