torch.nn.Embedding explained (+ Character-level language model)

แชร์
ฝัง
  • เผยแพร่เมื่อ 7 พ.ย. 2024

ความคิดเห็น • 78

  • @yuehpo-peng
    @yuehpo-peng ปีที่แล้ว +6

    It's so satisfying that you type anything.

  • @the_osbm
    @the_osbm ปีที่แล้ว +6

    I love this man, and your keyboard sounds are the cherry on top.

    • @mildlyoverfitted
      @mildlyoverfitted  9 หลายเดือนก่อน

      Hehe:) Thank you!

    • @blaine_stl
      @blaine_stl 5 หลายเดือนก่อน

      @@mildlyoverfitted what kind of keyboard are you using?

  • @TheRovardotter
    @TheRovardotter 3 ปีที่แล้ว +1

    At first, I did not understand the typing as sped up. Was very impressed by your typing skills.

    • @mildlyoverfitted
      @mildlyoverfitted  3 ปีที่แล้ว +1

      Haha:D Just for the record I am not trying to make it look as if I was a fast typist. I speed up the typing parts because otherwise the videos would get ridiculously long:)

    • @TheRovardotter
      @TheRovardotter 3 ปีที่แล้ว +1

      @@mildlyoverfitted nice vid by the way!

  • @DikkeHamster
    @DikkeHamster 3 ปีที่แล้ว +7

    Cool to see the embedding evolution at the end!

  • @namanjaswani8925
    @namanjaswani8925 3 ปีที่แล้ว +3

    What an explaination !

  • @culturosityofficial
    @culturosityofficial 3 ปีที่แล้ว +1

    Seeing the steps to how the embeddings worked under the hood got me through my assignment, thank you!

  • @LyurGG
    @LyurGG 3 ปีที่แล้ว +2

    Okay but what keyboard setup are you using. Or is it a sound effect?

    • @mildlyoverfitted
      @mildlyoverfitted  3 ปีที่แล้ว

      Actually, this is a result of speeding up the footage of me typing. I am using Adobe Premiere Pro.

  • @fuat7775
    @fuat7775 2 ปีที่แล้ว +4

    Thank you for this video, very clear. BTW, you can use higer dimensions for embedding and use PCA to reduce into two dimensions when you need to plot

    • @mildlyoverfitted
      @mildlyoverfitted  2 ปีที่แล้ว +1

      Thank you:) Yeh, great point:) I think I just wanted to make the video as short as possible:)

  • @kajalchaurasia950
    @kajalchaurasia950 2 ปีที่แล้ว +1

    Just a thought
    Create a model for your videos.
    Input : Raw video
    Output : Normal speed where you are speaking and fast forward where you're typing.

  • @IqweoR
    @IqweoR 3 ปีที่แล้ว +5

    Very informational, definitely looking forward seeing your next videos!

    • @mildlyoverfitted
      @mildlyoverfitted  3 ปีที่แล้ว

      Thank you! If you have any topic suggestions I would love to hear them!

  • @azmyin
    @azmyin ปีที่แล้ว +1

    Thank you very much sir. Deeply appreciate your hands on approach to teaching how to use embedding layer with LSTMs

  • @thepresistence5935
    @thepresistence5935 2 ปีที่แล้ว +1

    bro, what keyboard are you using. sound was amazing.

    • @mildlyoverfitted
      @mildlyoverfitted  2 ปีที่แล้ว +1

      Logitec MX keys. Not a mechanical keyboard. The sound is augmented by the speedup effect.

    • @thepresistence5935
      @thepresistence5935 2 ปีที่แล้ว

      @@mildlyoverfitted Thanks a lot

  • @Danny-we4vz
    @Danny-we4vz ปีที่แล้ว

    Very thocky! What switches are you using?

  • @redone9553
    @redone9553 2 ปีที่แล้ว +1

    Amazing quality! I'd love to know how you approach learning ML? Do you "just" visit courses at university and read math books? And what book/course would you recommend? Really appreciate an answer. Thanks!

    • @mildlyoverfitted
      @mildlyoverfitted  2 ปีที่แล้ว +4

      It is a tough question because IMO everybody is different and has a different background. With that being said I learned some math, stats and basic ML+DL at my university. Since leaving the university, I have been working in the industry doing ML on a daily basis. Additionally, I have been working on hobby projects in my free time (e.g. this TH-cam channel).
      So I would definitely recommend learning some maths first (calculus + linear algebra) and then learning ML+DL basics. Everything from then on should be as practical (=coding) and as regular (=getting an ML day job or coming up with ML projects) as possible. So IMO rather than studying an entire book or a going through an entire course it is better to work on a specific project and focus only on the theory/technologies that are needed for this project.
      I hope it helps but again everybody is different:)

    • @redone9553
      @redone9553 2 ปีที่แล้ว

      @@mildlyoverfitted amazing! Really appreciate your long answer! Thanks, you helped me! Right now I study Bishop's famous book but your right, it's becoming boring and tedious and practical projects keep oneself motivated. Best greetings (:

  • @vijayabhaskar-j
    @vijayabhaskar-j 3 ปีที่แล้ว +8

    Please tell me you're speeding up the portion of the video where you type, if not you're making others look like peasants in typing.

    • @mildlyoverfitted
      @mildlyoverfitted  3 ปีที่แล้ว +6

      LOL! Of course I am speeding them up! ~3x when writing code, ~6x when writing docstrings. Otherwise the videos would get too long!

  • @ろんサトシ
    @ろんサトシ 3 ปีที่แล้ว +2

    What's the keyboard? Sounds great when typing.

    • @mildlyoverfitted
      @mildlyoverfitted  3 ปีที่แล้ว

      Logitech MX Keys. I think it is mostly the fact that my mic is right next to it. It's not a mechanical keyboard and it is not that "loud" in real life.

  • @locorocozhong3941
    @locorocozhong3941 2 ปีที่แล้ว

    dude your keyboard as weird typing sound, what keyboard are you using? Btw the video is nice

    • @mildlyoverfitted
      @mildlyoverfitted  9 หลายเดือนก่อน

      Logitech MX Keys:) Thank you!

  • @peter62709
    @peter62709 3 ปีที่แล้ว +4

    Actually found this very helpful! The sped up typing sound was a bit annoying, but the content was great and it was well paced.

    • @mildlyoverfitted
      @mildlyoverfitted  3 ปีที่แล้ว +1

      Thanks a lot for your feedback! Really appreciate it:) Yeh, the keyboard sound is something I also worried about. I will try to turn down the volume in my next videos, however, if you have other suggestions I would be more than happy to hear them:)

    • @randomforrest9251
      @randomforrest9251 3 ปีที่แล้ว +4

      @@mildlyoverfitted I actually enjoyed it a lot. Gave some hhkb asmr vibes

    • @connorsheehan4598
      @connorsheehan4598 3 ปีที่แล้ว +2

      I think the keyboard sound is great, probably just a preference thing

    • @gnorts_mr_alien
      @gnorts_mr_alien ปีที่แล้ว

      @@mildlyoverfitted yah came here for the embeddings, stayed for the nice keyboard sounds

  • @navins2246
    @navins2246 7 หลายเดือนก่อน +1

    Doing ML in vim is absolutely gigachad

  • @mrigankanath7337
    @mrigankanath7337 3 ปีที่แล้ว +3

    Hey great video!! liked and subscribed, Hey I really wanted if you could make a video on how to work with attention layers in Pytorch? AS you know they are very cool but there is lack of resources on how to use it in your custom model.
    It will be really great! Thanks!!

    • @mildlyoverfitted
      @mildlyoverfitted  3 ปีที่แล้ว +2

      Thank you for the comment! That is a good idea:)))

  • @ofeknourian8913
    @ofeknourian8913 2 ปีที่แล้ว

    At 11:30 shouldn't you take the last layer of h instead of averaging over all of h? from my understanding the last layer of h represent the last prediction of the sequence.

    • @mildlyoverfitted
      @mildlyoverfitted  2 ปีที่แล้ว

      Hey there! Great question. I guess taking the last layer of the hidden state is definitely a possibility. However, if the `n_layers=1` it does not make a difference.

  • @dddaaa931
    @dddaaa931 2 ปีที่แล้ว +1

    Thanks for your vedio i search a long time for this step and can not find a good answer

  • @mikhaeldito
    @mikhaeldito 2 ปีที่แล้ว

    Thanks so much for the video. Could you explain again how Embedding can accommodate unseen vocab? Thanks in advance.

    • @mildlyoverfitted
      @mildlyoverfitted  2 ปีที่แล้ว

      Thank you. I guess the standard approach is to have a special entry in the vocabulary (like UNKNOWN) and whenever you stumble upon an unseen word/token/category you just use this special entry.
      The above strategy is exactly what BERT tokenizer does: github.com/huggingface/transformers/blob/6e535425feae20ca61a8b10ae5e8a7fab4d394ba/src/transformers/models/bert/tokenization_bert.py#L134-L136

  • @trenvert123
    @trenvert123 ปีที่แล้ว

    I liked the typing sound. I feel like the video is very information dense. I like it, but I'm having a very hard time parsing through everything. I think it's great for condensing this complex problem into a 20 minute video, when in reality, this video would have to be +1 1/2 hours to cover everything on word embedding alone. I think I'll come back to it at a later date when I have studied more. I'm still trying to understand how word embeddings work, and how word2vec like skip-gram allows them to represent similar words closer within the vector space.

  • @beizhou2488
    @beizhou2488 3 ปีที่แล้ว +1

    Are you interested in implementing reinforcement learning papers?

    • @mildlyoverfitted
      @mildlyoverfitted  3 ปีที่แล้ว

      Sure, are there any that you find particularly interesting?

  • @coc2912
    @coc2912 ปีที่แล้ว

    excellent

  • @popamaji
    @popamaji 3 ปีที่แล้ว

    I didn't watch the video carefully but does it explain how nn.embedding code is been written or it's just the behaviour of nn.embeddings is explained in the first of video?

    • @mildlyoverfitted
      @mildlyoverfitted  3 ปีที่แล้ว

      Great question:) This video shows the behavior and usage of `torch.nn.Embedding`. Its actual implementation is not discussed.

    • @popamaji
      @popamaji 3 ปีที่แล้ว +1

      @@mildlyoverfitted thanx for your awesome videos. can you make one for implementation, it would be great

    • @mildlyoverfitted
      @mildlyoverfitted  3 ปีที่แล้ว +1

      That is an interesting suggestion! Thanks!

  • @ifthikhanmohamed1681
    @ifthikhanmohamed1681 ปีที่แล้ว

    text.txt what contains i got key error

    • @mildlyoverfitted
      @mildlyoverfitted  ปีที่แล้ว

      Hello! Can you maybe describe your problem in more detail?

  • @djfl58mdlwqlf
    @djfl58mdlwqlf 2 ปีที่แล้ว

    are you coding with vim...?
    how is that even possible lol
    how can i get those codes beautifully painted

    • @mildlyoverfitted
      @mildlyoverfitted  2 ปีที่แล้ว

      Yes. I am using this plugin: github.com/morhetz/gruvbox

  • @harshmankodiya9397
    @harshmankodiya9397 2 ปีที่แล้ว

    bro is rolling a dice at 10x speed

  • @AlokMalik18
    @AlokMalik18 2 ปีที่แล้ว +1

    I came from an internet search, without seeing like to dislike ratio I have no idea what's the quality of this video is. Please bring back dislike button youtube.

    • @mildlyoverfitted
      @mildlyoverfitted  2 ปีที่แล้ว

      Totally agree! I hate the fact that they removed it.

  • @iamragulsurya
    @iamragulsurya 7 หลายเดือนก่อน

    Name of the font?

    • @mildlyoverfitted
      @mildlyoverfitted  7 หลายเดือนก่อน

      So the theme I am using is here: github.com/morhetz/gruvbox . The README talks about the fonts I believe.

  • @The8thJester
    @The8thJester 2 ปีที่แล้ว +1

    Thank you so much for this video! Do you perhaps have any suggestion on where my model might be going wrong? It seems that no matter what, my model always converges to outputting only space characters. I guess that's the most common character after all, but it's not quite what we're looking for is it? Thanks again!

    • @mildlyoverfitted
      @mildlyoverfitted  2 ปีที่แล้ว

      Interesting! I would try to make sure that you are able to overfit on a small training set/a single batch of samples. This way you can be sure that the model has "enough power" to do the task. Then I would move on to training on all your data while monitoring your train/test loss and metrics!
      Hope that helps!

  • @saodeyipi9609
    @saodeyipi9609 2 ปีที่แล้ว

    how can you type so fast, jz??

    • @mildlyoverfitted
      @mildlyoverfitted  2 ปีที่แล้ว

      Heh, it is not my real typing speed. The video is sped up so that it is shorter.

  • @sumithhh9379
    @sumithhh9379 3 ปีที่แล้ว

    How the embedding weights are getting updated with a forward and backard pass. I understand the backprop but couldn't understand this.
    Please also reduce your typing sound. It feels like you are firing bullets instead or key strokes :).

    • @mildlyoverfitted
      @mildlyoverfitted  3 ปีที่แล้ว

      Thank you for your comment! The weights are updated when the `optimizer.step()` is called and PyTorch takes care of the technical details.
      Regarding the typing sound, I actually turned it down in all of my recent videos!

  • @koiRitwikHai
    @koiRitwikHai ปีที่แล้ว

    Very informative video. Applause.
    I am just wondering ... why BERT does not use any norm in its embeddings? 1:40

  • @iraklimachabeli6659
    @iraklimachabeli6659 2 ปีที่แล้ว

    First of all thank you , very good intro combining embedding and LSTM.
    I run example and curious why in generate_text you use new_ch=np.random.choice( ..., p=probs) ,probs is logits[0] which is probability of next char being first element in vocab (which is ' ' blank char).
    I'd expect something like new_ch =dataset.ix2ch[ logits.argmax().item() ]

    • @mildlyoverfitted
      @mildlyoverfitted  2 ปีที่แล้ว

      Thank you for your comment! If I am not mistaken, `logits[0]` actually extracts the first and only sample from the batch. Or in other words, it is there to get rid of the batch dimension.
      Hope that helps:)

  • @sahhaf1234
    @sahhaf1234 2 ปีที่แล้ว +2

    impossible to understand.. as clear as mud..