第10章現代のリカレントニューラルネットワーク
10.6. The Encoder–Decoder Architecture10.6 エンコーダ・デコーダ構造
In general sequence-to-sequence problems like machine translation (Section 10.5), inputs and outputs are of varying lengths that are unaligned. The standard approach to handling this sort of data is to design an encoder–decoder architecture (Fig. 10.6.1) consisting of two major components: an encoder that takes a variable-length sequence as input, and a decoder that acts as a conditional language model, taking in the encoded input and the leftwards context of the target sequence and predicting the subsequent token in the target sequence.
英語のヒント
Fig. 10.6.1図10.6.1
The encoder–decoder architecture.
英語のヒント
エンコーダ・デコーダ構造。
Let’s take machine translation from English to French as an example. Given an input sequence in English: “They”, “are”, “watching”, “.”, this encoder–decoder architecture first encodes the variable-length input into a state, then decodes the state to generate the translated sequence, token by token, as output: “Ils”, “regardent”, “.”. Since the encoder–decoder architecture forms the basis of different sequence-to-sequence models in subsequent sections, this section will convert this architecture into an interface that will be implemented later.
英語のヒント
英語からフランス語への機械翻訳を例にとろう。英語の入力系列「They」「are」「watching」「.」が与えられると、このエンコーダ・デコーダ構造は、まず可変長の入力を状態へと符号化し、次にその状態を復号して、翻訳された系列「Ils」「regardent」「.」をトークンごとに出力として生成する。エンコーダ・デコーダ構造は以降の節のさまざまな系列から系列へのモデルの土台となるので、この節では、この構造を後で実装するインターフェースにする。
from torch import nn
from d2l import torch as d2l