プリンキピア

第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 𝐡t) and the text that was already generated (decoder hidden states 𝐬t′−1). This yields 𝐜t′, which is updated after any decoding time step t′. Suppose that the input sequence is of length T. In this case the context variable is the output of attention pooling:
英語のヒント
10.7節の系列から系列への構造、特に(10.7.3)で導入した表記に従う。鍵となる考えは、状態、つまり原文の文を要約する文脈変数𝐜を固定したままにせず、元のテキスト(エンコーダの隠れ状態𝐡t)と、すでに生成したテキスト(デコーダの隠れ状態𝐬t′−1)の両方の関数として、動的に更新することである。これにより𝐜t′が得られ、これは任意の復号の時間ステップt′の後で更新される。入力系列の長さをTとする。この場合、文脈変数は注意プーリングの出力である。
𝐜t′=∑t=1Tα(𝐬t′−1,𝐡t)𝐡t.(11.4.1)
We used 𝐬t′−1 as the query, and 𝐡t as both the key and the value. Note that 𝐜t′ is then used to generate the state 𝐬t′ 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 T but rather it proceeds up to t′−1). For instance, see Chan et al. (2015) for a description of this strategy, as applied to speech recognition.
英語のヒント
𝐬t′−1をクエリとして使い、𝐡tをキーとバリューの両方として使った。その後、𝐜t′は、状態𝐬t′を生成し、新しいトークンを生成するのに使われることに注意してほしい((10.7.3)を参照)。特に、注意の重みαは、(11.3.7)で定義した加法注意のスコア関数を使って、(11.3.3)のように計算される。注意を使うこのRNNのエンコーダ・デコーダ構造を、図11.4.2に描く。このモデルは後に、すでに生成したトークンもデコーダでさらなる文脈として含めるように変更されたことに注意してほしい(つまり、注意の和はTで止まらず、t′−1まで進む)。たとえば、音声認識に当てはめたこの戦略の説明については、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のエンコーダ・デコーダモデルの層。