第11章注意機構とTransformer
11.4.1. Model11.4.1 モデル
We follow the notation introduced by the sequence-to-sequence architecture of Section 10.7, in particular (10.7.3). The key idea is that instead of keeping the state, i.e., the context variable summarizing the source sentence, as fixed, we dynamically update it, as a function of both the original text (encoder hidden states ) and the text that was already generated (decoder hidden states ). This yields , which is updated after any decoding time step . Suppose that the input sequence is of length . In this case the context variable is the output of attention pooling:
英語のヒント
(11.4.1)
We used as the query, and as both the key and the value. Note that is then used to generate the state and to generate a new token: see (10.7.3). In particular, the attention weight is computed as in (11.3.3) using the additive attention scoring function defined by (11.3.7). This RNN encoder–decoder architecture using attention is depicted in Fig. 11.4.2. Note that later this model was modified so as to include the already generated tokens in the decoder as further context (i.e., the attention sum does not stop at but rather it proceeds up to ). For instance, see Chan et al. (2015) for a description of this strategy, as applied to speech recognition.
英語のヒント
をクエリとして使い、をキーとバリューの両方として使った。その後、は、状態を生成し、新しいトークンを生成するのに使われることに注意してほしい((10.7.3)を参照)。特に、注意の重みは、(11.3.7)で定義した加法注意のスコア関数を使って、(11.3.3)のように計算される。注意を使うこのRNNのエンコーダ・デコーダ構造を、図11.4.2に描く。このモデルは後に、すでに生成したトークンもデコーダでさらなる文脈として含めるように変更されたことに注意してほしい(つまり、注意の和はで止まらず、まで進む)。たとえば、音声認識に当てはめたこの戦略の説明については、Chan et al. (2015)を見てほしい。
Fig. 11.4.2図11.4.2
Layers in an RNN encoder–decoder model with the Bahdanau attention mechanism.
英語のヒント
Bahdanauの注意機構をもつRNNのエンコーダ・デコーダモデルの層。