一句话概括:在Transformer模型中加入相对位置表示,可以提升翻译结果的质量。
Transformer:采用encoder-decoder框架
-
encoder里面有多层,每一层包括两个子层 self-attention 和 FFN(a position-wise feed-forward layer),子层之间通过 layer normalization 连接,层与层之间通过 residual 连接。
-
decoder里面同样可以定义多层。每一层包括三个子层 self-attention 、encoder-decoder attention 和 FFN,子层之间通过 layer normalization 连接 ,层与层之间通过 residual 连接。decoder 的 self-attention 使用 masking 防止生成当前输出的时候看到未来的输出结果。
A t t e n t i o n ( Q , K , V ) = s o f t m a x ( Q K T d k ) V Attention(Q,K,V) = softmax(\frac{QK^T}{\sqrt d_k})V Attention(Q,K,V)=softmax(dkQKT)V
F F N ( x ) = m a x ( 0 , x i W 1 + b 1 ) W 2 + b 2 FFN(x)=max(0,x_iW_1+b1)W_2+b2 FFN(x)=max(0,xi