Building a sequence-to-sequence model for text translation
In order to build our sequence-to-sequence model for translation, we will implement the encoder/decoder framework we outlined previously. This will show how the two halves of our model can be utilized together in order to capture a representation of our data using the encoder and then translate this representation into another language using our decoder. In order to do this, we need to obtain our data.
Preparing the data
By now, we know enough about machine learning to know that for a task like this, we will need a set of training data with corresponding labels. In this case, we will need sentences in one language with the corresponding translations in another language. Fortunately, the Torchtext
library that we used in the previous chapter contains a dataset that will allow us to get this.
The Multi30k
dataset in Torchtext
consists of approximately 30,000 sentences with corresponding translations in multiple languages...