1 / 31

Transformer

Transformer. BERT. 李宏毅 Hung-yi Lee. Transformer. Seq2seq model with “Self-attention”. Sequence. Next layer. Previous layer. Using CNN to replace RNN. Hard to parallel !. Sequence. Filters in higher layer can consider longer sequence. Next layer. ……. ……. ……. ……. Previous layer.

williem
Download Presentation

Transformer

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Transformer BERT 李宏毅 Hung-yi Lee

  2. Transformer Seq2seq model with “Self-attention”

  3. Sequence Next layer Previous layer Using CNN to replace RNN Hard to parallel !

  4. Sequence Filters in higher layer can consider longer sequence Next layer …… …… …… …… Previous layer Using CNN to replace RNN Hard to parallel (CNN can parallel)

  5. is obtained based on the whole input sequence. Self-Attention , , , can be parallelly computed. Self-Attention Layer You can try to replace any thing that has been done by RNN with self-attention.

  6. Self-attention : query (to match others) https://arxiv.org/abs/1706.03762 : key (to be matched) : information to be extracted Attention is all you need.

  7. Self-attention d is the dim of and 拿每個 query q 去對每個 key k做 attention Scaled Dot-Product Attention: dot product

  8. Self-attention Soft-max

  9. Self-attention Considering the whole sequence

  10. Self-attention 拿每個 query q 去對每個 key k做 attention

  11. Self-attention , , , can be parallelly computed. Self-Attention Layer

  12. Self-attention = = =

  13. Self-attention (ignore for simplicity)

  14. Self-attention

  15. Self-attention =

  16. Self-attention = = = = = 反正就是一堆矩陣乘法,用 GPU 可以加速

  17. Multi-head Self-attention (2 heads as example)

  18. Multi-head Self-attention (2 heads as example)

  19. Multi-head Self-attention (2 heads as example) =

  20. Positional Encoding + • No position information in self-attention. • Original paper: each position has a unique positional vector (not learned from data) • In other words: each appends a one-hot vector = ……… 0 1 i-th dim + 0 …

  21. = + -1 1 source of image: http://jalammar.github.io/illustrated-transformer/

  22. Review: https://www.youtube.com/watch?v=ZjfjPzXw6og&feature=youtu.be Seq2seq with Attention Self-Attention Layer Self-Attention Layer Encoder Decoder

  23. https://ai.googleblog.com/2017/08/transformer-novel-neural-network.htmlhttps://ai.googleblog.com/2017/08/transformer-novel-neural-network.html

  24. Transformer machine learning Using Chinese to English translation as example Encoder Decoder machine 機 器 學 習 <BOS>

  25. Transformer Layer Norm: Batch Size https://arxiv.org/abs/1607.06450 Layer Norm Batch Norm: https://www.youtube.com/watch?v=BZh1ltr5Rkg + Batch Layer … attend on the input sequence Masked: attend on the generated sequence

  26. Attention Visualization https://arxiv.org/abs/1706.03762

  27. Attention Visualization The encoder self-attention distribution for the word “it” from the 5th to the 6th layer of a Transformer trained on English to French translation (one of eight attention heads). https://ai.googleblog.com/2017/08/transformer-novel-neural-network.html

  28. Multi-head Attention

  29. Example Application • If you can use seq2seq, you can use transformer. Summarizer Document Set https://arxiv.org/abs/1801.10198

  30. Universal Transformer https://ai.googleblog.com/2018/08/moving-beyond-translation-with.html

  31. Self-Attention GAN https://arxiv.org/abs/1805.08318

More Related