Encoder-Decoder RNNのAttention

machinelearning

Encoder-Decoder RNNは入力用のEncoderと出力用のDecoderの2つのLSTMを組み合わせたもので、EncoderのStateはDecoderに繋げる。

Encoder-Decoder RNN

したがって入力データはDecoderに渡されるStateにまとめられることになるが、 出力ごとに入力時系列の重要な部分は異なるため、特定の部分に注目できるようにすると良い結果が期待できる。 次の論文ではAttention Layerを追加することでこれを行い翻訳の精度を向上させている。

Minh-Thang Luong, Hieu Pham, Christopher D. Manning (2015) Effective Approaches to Attention-based Neural Machine Translation

Attention LayerはEncoderの出力とDecoderの対象の出力からどの部分を重要とするかを表すAlign weights a(t)と Encoderの出力を掛けたものをContext vector c(t)として出力する。 scoreにはそのまま掛けたものや(h_{dec}h_{enc})、重みとDecoderの出力のみを掛ける(Wh_{dec})といったものが使われる。

Attention Layer

Align weightsとContext vectorの式