Transformer Positional Embeddings With A Numerical Example.

Поделиться
HTML-код
  • Опубликовано: 13 янв 2025

Комментарии • 28

  • @tacticalnom97d
    @tacticalnom97d 2 года назад +11

    Amazingly explained. This is the first sane, proper mathematical explanation I have found for Positional Encoding. Keep up the excellent work!!

  • @sach2274
    @sach2274 Год назад +30

    I think when you are trying to get the positional encoding for boy(p=1)
    it must be sin(1/10000^2*0/4)
    not sin(1/100000^2*1/4)
    and similarly with cos, for i =0 and 1
    for i=2 and 3 it is correct.

    • @MrFromminsk
      @MrFromminsk Год назад +3

      yeah, I was also wondering about this error. Thanks for confirming my suspicion

  • @beizhou2488
    @beizhou2488 3 года назад +2

    Pellucid explanation! Please keep the nice work going. Like the whole series of your tutorials.

  • @manohar_marri
    @manohar_marri 3 года назад +14

    For the boy token; i=0; for the first two positions right ? You have used I=1; Correct me if I’m wrong

    • @王爸爸-h5x
      @王爸爸-h5x 2 года назад

      you‘re right ,maybe it‘s just a pen slip

  • @sarahkhan3217
    @sarahkhan3217 Месяц назад

    The division by 2 relates to splitting the embedding dimensions for sine and cosine computations and is independent of the number of sentences or words.

  • @samc6368
    @samc6368 Месяц назад

    Typo in calculation at 5:06, as i=0 for first 2 items of sin and cos for "boy", you have as 1.

  • @findritesh
    @findritesh 11 месяцев назад

    great job explaining this concept!

  • @atmismahir
    @atmismahir 11 месяцев назад

    thank you for the clear math. I still couldn't get how the word order is preserved though. Is there any visual representation or mathematical illustration of how the positions are preserved?

  • @gigabytechanz9646
    @gigabytechanz9646 Год назад

    Very clear explanation. Thank you!

  • @Adhbutham
    @Adhbutham 5 месяцев назад +2

    Why is cosine of 0 = 0?? I think there is an error

  • @sudhansubaladas2322
    @sudhansubaladas2322 2 года назад +4

    Nice explaination...but, .Why u have divided i by 2? I didn't get this part...can u plz tell ..??

    • @sudhansubaladas2322
      @sudhansubaladas2322 2 года назад

      @@machinelearningwithpytorch yae understood...this is to make i to 0 and 1...so, that we can give sin and cos formula easily... 0 uses sine and 1 uses cosine....I am right???

    • @sudhansubaladas2322
      @sudhansubaladas2322 2 года назад

      @@machinelearningwithpytorch I have one more query ...Suppose the word "good" occurs in sentence 1 at position 0 and in sentence 5, the word "good" occurs in position 4, then whether their positional encoding will be the same?? Can you please tell? Are positional Embedding and positional encoding is same??

    • @openodia
      @openodia Год назад

      @@sudhansubaladas2322 Yes, for odd positions we are using Cosine and for even positions we are using sine.

    • @openodia
      @openodia Год назад

      @@sudhansubaladas2322 No, their positional encoding will be different as p value will change.

    • @liam15williams
      @liam15williams Год назад +1

      do you find out
      why we divide i by 2?

  • @shelleychristiesantoso7535
    @shelleychristiesantoso7535 3 года назад

    thank you for the clear and concise explanation.

  • @lllilllllill7900
    @lllilllllill7900 2 года назад

    Thank you for your excellent work~

  • @raquelhortabartomeu2384
    @raquelhortabartomeu2384 2 года назад +6

    Not a bad explanation but the formula is no explained in detail and I believe there's an error when you always use i=1 for the word boy

  • @ssenukim
    @ssenukim 2 года назад +1

    Is there any possible error if embedding vector size is odd number , so that positional encoding vector doesn't have not sin&cos pairs but only have sin at last component?

  • @chuckcarlson7940
    @chuckcarlson7940 2 года назад

    Why is the word embedding not messed up when you add numbers to each of it's dimensions? Wouldn't it now represent a different word?

  • @rounhi
    @rounhi 3 года назад

    Just keep on. Wonderful!

  • @서로워
    @서로워 2 года назад +1

    Can you explain sparse attention? please please

  • @liam15williams
    @liam15williams Год назад

    i don'r get why we divide two