Neural Machine Translation › The Translation Problem as Conditional Generation
Language AI HandbookAll chapters Let the source sentence be a sequence of tokens and the target be . Their lengths and vocabulary sizes can differ. In the likelihood and decoding formulas, a completed target sequence includes its final EOS token. The length counts that EOS but excludes the BOS prompt marker and padding. The worked example reports lexical lengths without EOS.
A vocabulary of symbols gives unrestricted strings of length . A completed target uses only a subset of this space because its first EOS is its last token. The chain rule lets us score one candidate by evaluating the model at its successive prefixes. Searching for the best completed sequence still requires a decoding strategy.
We factorize with the chain rule, exactly as any language model does:
Each factor is a conditional distribution over the target vocabulary given the source and the target prefix. A neural network parameterizes this with weights :
Here produces a hidden vector of size , and projects it onto target-vocabulary logits. The subscript selects the gold token during training. The maximum-likelihood loss takes the negative logarithm of that probability. At inference, the decoder scores candidate continuations, including the end-of-sequence token when ranking completed sequences.
This factorization hides three distinct subproblems that statistical MT attacked separately:
- Lexical transfer. Which target words correspond to which source words? "Katze" for "cat", but also "chat" and "gato" depending on the language pair. Beyond single words, lexical transfer must handle multi-word expressions ("kick the bucket"), idioms, and collocations that do not decompose word-for-word.
- Reordering. Consider “because she reads the book” and “weil sie das Buch liest.” The English verb “reads” precedes its object, while “liest” follows its object in the German example. The same source and target positions need not correspond. The model also needs to handle cases where one position corresponds to several, such as an idiom rendered with a longer phrase.
- Fluency. The target-side language model supplies a separate score in a phrase-based SMT system. To test fluency in an output, inspect whether the words fit the target construction, including agreement and idiomatic phrasing where relevant.
SMT combined these as separate features in a log-linear model:
The features can include phrase-translation, lexical, reordering, length, and target-language scores. Och (2003) describes minimum error rate training for tuning feature weights. Koehn et al. (2003) show how to extract phrase pairs from word alignments.
The log-score is a weighted sum of the supplied features. With fixed weights and no interaction feature, its sensitivity to the language-model score is the same whether the phrase-table score is high or low. A feature that combines both scores would let the model express a different relationship.
In the end-to-end model, lexical choices, order, and well-formedness all contribute to the conditional output. We train the components through the same translation loss.
Why joint learning helps
Compare where each design allows the training signal and the source context to enter.
Translation loss can reach the encoder. If phrase extraction excludes a useful phrase pair, that pair is unavailable to that phrase-based decoder. In the differentiable model below, gradients from the translation loss can flow through cross-attention into the encoder. The gradient gives a direction for a parameter update.
The attention weights are continuous. A softmax assigns weights across source positions. The weighted sum and the softmax can be differentiated when training the model. A discrete choice of one alignment would require a different treatment.
The encoder sees surrounding words. Compare “on the bank of the river” with “at the bank to withdraw cash.” In a contextual encoder, the representation at “bank” can depend on those surrounding tokens. Test the two sentences if you want to know whether the model uses the distinction in practice.
What NMT did not fix
When evaluating an NMT system, check the types of failure the intended application cannot tolerate. Four useful diagnostic cases are:
- Hallucination. The model can produce fluent output with content that appears nowhere in the source.
- Off-target translation. A multilingual model can silently translate into the wrong language.
- Length and coverage failures. Compare the source and translation for omitted or repeated content.
- Sparse training coverage. Inspect how many examples in your bitext cover the intended language pair and domain.
Use these cases when you compare model, preprocessing, and decoding changes.
Comments
Add to the conversation
A question, a correction, or an example from your own work.
No comments yet. Be the first to share your thoughts!