數學軟體應⽤ 344 Seq2seq model 重點 Seq2seq 字1 字2 回1 EOS 回1 回2 回k EOS Sutskever, I., Vinyals, O., & Le, Q. V. (2014). Sequence to sequence learning with neural networks. In Advances in neural information processing systems (pp. 3104-3112). 還記得我們對話機器 人 seq2seq model? c
數學軟體應⽤ 348 Encoder-Decoder 假如把我們的 RNN 叫做 , 我們有這個式⼦: f Decoder 也是⼀樣的! 但怕⼤家弄混, 我們 hidden states 改名⼦。 h t = f(h t−1 , x t ) h t = f(h t−1 , y t ) s t = f(s t−1 , y t )
數學軟體應⽤ 352 冒險01 Decoder 每次都參考原版的 !! c K. Cho, B. Van Merriënboer, C. Gulcehre, D. Bahdanau, F. Bougares, H. Schwenk, and Y. Bengio. Learning phrase representations using RNN encoder-decoder for statistical machine translation. arXiv:1406.1078, 2014. s t = f d (s t−1 , y t , c) 關鍵的表⽰向 c
數學軟體應⽤ 354 冒險01 我們 summary 的 c 其實不⼀定是要輸入串最後⼀個 hidden state。 也可以參考所有輸入時的 hidden states 算出來! D. Bahdanau, K. Cho, Y. Bengi. Neural machine translation by jointly learning to align and translate. arXiv:1409.0473. 2014. s t = f d (s t−1 , y t , c) c = q(h1, h2, …, hT) 關鍵的表⽰向 c
數學軟體應⽤ 358 Attention 這種注意⼒放在幾個 點的叫 attention D. Bahdanau, K. Cho, Y. Bengio, Neural machine translation by jointly learning to align and translate. arXiv:1409.0473. 2014.
數學軟體應⽤ 362 Attention 到底怎麼算? y i y i+1 s i s i+1 h 1 h 2 h T encoder decoder 目前關切的 query keys 一一算關 連強度 e 1 e 2 e T e j = a(s i , h j ) 用 attention 算出 e 1 , e 2 , …, e T
數學軟體應⽤ 367 Attenation is All You Need 不用 RNN, 可以做 Attention 嗎? A. Vaswani, N. Shazeer, N. Parmar, J. Uszkoreit, L. Jones, A. N. Gomez, L. Kaiser, I. Polosukhin. Attention is all you need. In Advances in Neural Information Processing Systems (NIPS), 2017. 帶起 transformer 風潮的 FAttention is All You NeedM
數學軟體應⽤ 373 其實和前⾯ RNN 的 Attention ⼀樣! q i k 1 k 2 k T e 1 e 2 e T ⽬前正在關注的 , 和所有的 做 attention, 依此決定各強度將 線性組合起來。 q j k i h i α 1 v 1 +α 2 v 2 + ⋯+α T v T query keys values
數學軟體應⽤ 378 進入 attention 程序 Attention 然後就進入「正常的」attention 程序。 q i k 1 k 2 k T 送入⼀個 query , 就和每⼀ 個 做 attention, 得到的 「強度」做 softmax 之後成 為 的係數。 q i k j v j 本⽂的 attention 只是做內積。
數學軟體應⽤ 396 要取代 CNN 的部份… 理論上 transformer 取代 CNN 原理上是 有點道理, 但像 Visual Transformer (ViT) 在 ICLR 2021 才發表 (雖然不是唯 ⼀類似⼯作)。 A. Dosovitskiy, L. Beyer, A. Kolesnikov, D. Weissenborn, X. Zhai, T. Unterthiner, M. Dehghani, M. Minderer, G. Heigold, S. Gelly, J. Uszkoreit and Neil Houlsby (Google). An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale. International Conference on Learning Representations (ICLR), 2021. arXiv: 2010.11929.
數學軟體應⽤ 397 甚⾄⼀路 MLP 也強強的! I. Tolstikhin, N. Houlsby, A. Kolesnikov, L. Beyer, X. Zhai, T. Unterthiner, J. Yung, D. Keysers, J. Uszkoreit, M. Lucic and A. Dosovitskiy (Google). MLP-Mixer: An all-MLP Architecture for Vision. arXiv: 2105.01601. 2021/05/04 放上 arXiv! 不⽤ CNN, 不⽤ transformer, 我們來處理圖形! Yann LeCun 說, 並不 是真的沒有⽤到 CNN...
數學軟體應⽤ 407 Word2Vec T. Mikolov, K. Chen, G. Corrado, J. Dean. Toutanova. Efficient Estimation of Word Representations in Vector Space. Proceedings of Workshop at ICLR, 2013.. 訓練好了有很多炫炫的功能。 巴黎 法國 義⼤利 羅⾺ 國王 男⼈ 女⼈ 皇后
數學軟體應⽤ 412 記憶或理解 word2vec 給我們⼀ 個啟發, 就是權 也 可以是我們⽇後要⽤ 的部份, 可以當成是 某種「記憶」。 w 11 w 12 ⋯ w 1N w 21 w 22 ⋯ w 2N ⋮ ⋮ ⋮ w i1 w i2 ⋯ w iN ⋮ ⋮ ⋮ w V1 w V2 ⋯ w VN W 其⾄這⼀⼩段網路想 成是「理解」。
數學軟體應⽤ 413 記憶或理解 h W x One-hot encoding T 0 0 ⋮ 1 ⋮ 0 w 11 w 12 ⋯ w 1N w 21 w 22 ⋯ w 2N ⋮ ⋮ ⋮ w i1 w i2 ⋯ w iN ⋮ ⋮ ⋮ w V1 w V2 ⋯ w VN WT x= h 就 word2vec 來說, 其實 也可以看成是隱藏層的輸 出! = h
數學軟體應⽤ 415 Bag of Words (BOW) 假設我們現在有個句子, , 每個 字是什麼字就放進那個字的「袋子」中。最後這 句話就數每個袋子有幾個字, 來表示這句話。 {w 1 , w 2 , …, w T } B 1 B 2 B 3 B V 2 0 3 0 [2, 0, 3, …, 0] 這句話就表示 成這個向量。
數學軟體應⽤ 419 ELMo 開創⾃然語⾔的「芝⿇街時代」! ELMo M.E. Peters, M. Neumann, M. Iyyer, M. Gardner, C. Clark, K. Lee, L. Zettlemoyer. Deep contextualized word representations. NAACL 2018. arXiv preprint arXiv:1802.05365v2. AI2
數學軟體應⽤ 423 引領⾃然語⾔新時代的 BERT BERT J. Devlin, M.W. Chang, K. Lee, K. Toutanova. BERT: Pre- training of Deep Bidirectional Transformers for Language Understanding. arXiv preprint arXiv:1810.04805v2. Google
數學軟體應⽤ 424 Transformer Vaswani, A., Shazeer, N., Parmar, N., Uszkoreit, J., Jones, L., Gomez, A. N., ... & Polosukhin, I. (2017). Attention is all you need. In Advances in Neural Information Processing Systems (pp. 5998-6008). 運⽤ self-attention, 避開 RNN 的缺點!
數學軟體應⽤ 432 XLNet XLNet Z. Yang, Z. Dai, Y Yang, J. Carbonell, R. Salakhutdinov, Q. V. Le. XLNet: Generalized Autoregressive Pretraining for Language Understanding. NeruIPS 2019. 使⽤ Transformer XL 使⽤ permutation 訓練法
數學軟體應⽤ 434 MegatronLM MegatronLM 超級火⼒展⽰ 8,300!! M. Shoeybi, M. M. A. Patwary, P. Puri, P. LeGresley, J. Casper, B. Catanzaro, Megatron-LM: Training Multi-Billion Parameter Language Models Using GPU Model Parallelism. arXiv:1909.08053 2019.
數學軟體應⽤ 442 輕 化 然後⼤家終於想到, 這樣軍備競賽下去, 很多場景其實不太能應⽤。 V. Sanh, L. Debut, J. Chaumond, T. Wolf. DistilBERT, a distilled version of BERT: smaller, faster, cheaper and lighter. NeruIPS 2019. 小巧版的 BERT 來了! DistilBERT
數學軟體應⽤ 443 DistilBERT DistilBERT 其實就是大 BERT 訓練小 BERT 的概念。 來, 我教你! G. Hinton, O. Vinyals, J. Dean. Distilling the knowledge in a neural network. arxiv: 1503.02531, 2015.