プリンキピア

第10章現代のリカレントニューラルネットワーク

10.5. Machine Translation and the Dataset10.5 機械翻訳とデータセット

Among the major breakthroughs that prompted widespread interest in modern RNNs was a major advance in the applied field of statistical machine translation. Here, the model is presented with a sentence in one language and must predict the corresponding sentence in another. Note that here the sentences may be of different lengths, and that corresponding words in the two sentences may not occur in the same order, owing to differences in the two language’s grammatical structure.
英語のヒント
現代のRNNへの広い関心を呼び起こした大きな突破口の一つに、統計的機械翻訳という応用分野での大きな進歩があった。ここでは、モデルにある言語の文が示され、別の言語での対応する文を予測しなければならない。ここでは文の長さが異なることがあり、また二つの言語の文法構造の違いのために、二つの文で対応する単語が同じ順序で現れないこともあることに注意してほしい。
Many problems have this flavor of mapping between two such “unaligned” sequences. Examples include mapping from dialog prompts to replies or from questions to answers. Broadly, such problems are called sequence-to-sequence (seq2seq) problems and they are our focus for both the remainder of this chapter and much of Section 11.
英語のヒント
多くの問題が、二つのこうした「整列していない」系列のあいだの写像という性質をもつ。例としては、対話の問いかけから返答への写像や、質問から回答への写像がある。大まかに言えば、こうした問題は系列から系列への(seq2seq)問題と呼ばれ、この章の残りと第11章の多くの焦点となる。
In this section, we introduce the machine translation problem and an example dataset that we will use in the subsequent examples. For decades, statistical formulations of translation between languages had been popular (Brown et al., 1990, Brown et al., 1988), even before researchers got neural network approaches working (methods were often lumped together under the term neural machine translation).
英語のヒント
この節では、機械翻訳の問題と、以降の例で使うデータセットの例を紹介する。何十年ものあいだ、言語間の翻訳の統計的な定式化は人気があった(Brown et al., 1990、Brown et al., 1988)。それは、研究者がニューラルネットワークの手法(しばしばニューラル機械翻訳という言葉で一括りにされた)を機能させるよりも前からのことである。
First we will need some new code to process our data. Unlike the language modeling that we saw in Section 9.3, here each example consists of two separate text sequences, one in the source language and another (the translation) in the target language. The following code snippets will show how to load the preprocessed data into minibatches for training.
英語のヒント
まず、データを処理するための新しいコードが必要になる。9.3節で見た言語のモデリングとは違って、ここでは各事例は二つの別々のテキスト系列からなる。一つは原言語のもの、もう一つは(その翻訳である)目標言語のものである。以下のコード片は、前処理したデータを訓練のためのミニバッチに読み込む方法を示す。
import os
import torch
from d2l import torch as d2l