Machine translation converts text or speech from one natural language into another. In a sequence-to-sequence model, the source sequence X becomes a target sequence Y; the sequences can differ in length, and multiple valid translations may exist. section 11.0 section 11.2
Sequence-to-sequence models handle translation by separating the input and output stages, rather than requiring one output per input token. English-to-French translation illustrates the need to model different word orders and non-one-to-one relationships between words. section 11.0 section 11.2
A small translation dataset can be prepared for training by:
- Loading paired English and French sentences, then lowercasing text and removing punctuation. section 11.2.1
- Limiting sentence length and assigning vocabulary IDs to words. section 11.2.1
- Adding start-of-sentence, end-of-sentence, and padding tokens; padding batches to a shared length. section 11.2.1
Translation is not one-to-one
“What a nice day” can translate as “quelle belle journée.” A single English word such as “run” can also have multiple French translations. section 11.2 section 11.2.1
for i in range(10):
print(all_data[i])
('go', 'va')
('run', 'cours')
('run', 'courez')
('wow', 'ça alors')
('fire', 'au feu')
('help', "à l'aide")
('jump', 'saute')
('stop', 'ça suffit')
('stop', 'stop')
('stop', 'arrête toi')
Inspect sample English-French pairs, including several different translations for “stop.” section 11.2.1









