I’m not the expert for sentence translation. But if my understanding is correct, you could use nn.Transformer. Pass the sentence as src to encoder. The output of encoder and target should be passed to the decoder.