transformer-paper reading

2645 ワード

論文の原文:https://arxiv.org/abs/1706.03762コード実装:https://github.com/Kyubyong/transformer原文構造に従ってまとめを記録する
#1.Model Architecture 1.1.Encoder&Decoder stacks stacks=6 transformer sublayers=multi-head attention+FeedFormward Embedding dimension=512主な学習コード実装:1.self-attention 2.positional encoding 3.Masked Encoder input = [batchsize,seq_length,512] Encoder output = [batchsize,seq_length,512] ???? key?
1.2.Attention multi-heads = 8
a. Decoder Layer = 3 sublayers    
self-attention + Encoder-Decoder-attention + FeedwardNet   
Encoder-Decoder-attention = Keys,Values   Encoder; query       Decoderlayer   

b.Encoder self-attention,keys+values+querys              

c.Decoder self-attention,     masked  ,        Decoder              

コード実装、主にself-attentionの実装に注目する:
1.3 position-wise Feed-Forward Net順方向ネットワーク各位置のembeddingを2回線形変換原文記述:kernel size=1の2回のボリュームネットワーク(?)として想像できる
1.4 Embedding&softmax embedding layerは重みを共有しますが、パラメータのルート番号dmodel(?)を追加で乗算します.たとえば、embedding dimension=512で、22を乗算する必要があります.
1.5 positional Encoding位置符号化、事前に計算した数値を、該当位置のembeddingに直接加算すればよい
2.Why self-attention時間複雑度問題seq_を検討length=N; representation dimension=d; CNN kernel width=k self-attention = N^2d RNN = Nd^2 CNN = kNd^2 1.N 2.CNN kernelは距離の遠近を区別する.self-attentionすべての単語の距離は1です
#3.Traning
1.update weight = Adam optimizer *   Learning rate  

2.    = dropout + label smoothing
embedding layer    dropout
      =0.1

#4.Results 1.mutli-headは多すぎるべきではない.より複雑なモデルは一般的によりよく表現され、dropoutは重要である.自己学習のposition encodingは明らかな助けがありません
#参照1.seq2seq https://github.com/NLP-LOVE/ML-NLP/tree/master/NLP/16.5%20seq2seq各層のDecoderの入力=encoderの出力ベクトル+Decoderの前回ステップの出力2.Transformer http://jalammar.github.io/illustrated-transformer/3.公式APIhttps://github.com/tensorflow/tensor2tensor4.本明細書で参照する実装コードhttps://www.cnblogs.com/zhouxiaosong/p/11032431.html
#コード参照1.self-attention詳細はコードを参照:https://github.com/Kyubyong/transformer/blob/fb023bb097e08d53baf25b46a9da490beba51a21/modules.py#L153
   :   
1.  : [N, T_q, d_model]     : [N, T_q, d_model]   
2.multi-head   
3.decoder self-attention  padding_mask + senquence_mask   

2.encoder-decoder attention query:previous decoder output[N,T_q,d_model]key=value:encoder output[N,T_q,d_model]具体的な参照コード:https://github.com/Kyubyong/transformer/blob/fb023bb097e08d53baf25b46a9da490beba51a21/model.py#L111
   :
1.padding mask key_mask

3.Others 3.1 LR warmup実装3.2 add&normalization実装3.3 label smoothing実装
後続計画bert論文を学習し、そのコード実装のcreateを学習する.mask. 以上のコード実装のpadding_mask,sequence_mask感覚が足りない