Neural Machine Translation › The Translation Problem as Conditional Generation

Michael BrenndoerferNovember 26, 20264 min read
Language AI HandbookAll chapters
Part 27 of 67Machine Translation and Speech Translation
Chapter 191Neural Machine Translation › The Translation Problem as Conditional Generation
Reading section 2 of 12 · The Translation Problem as Conditional Generation · 4 minSection 2 of 12 · 4 min

Section 2 of 12 · 4 min read

Reading settings

Definitions

Choose how many terms have tooltips.

Article links

Make inline references clickable

Notes & comments

Let the source sentence be a sequence of tokens x=(x1,…,xm)x = (x_1, \dots, x_m) and the target be y=(y1,…,yn)y = (y_1, \dots, y_n). Their lengths and vocabulary sizes can differ. In the likelihood and decoding formulas, a completed target sequence includes its final EOS token. The length nn counts that EOS but excludes the BOS prompt marker and padding. The worked example reports lexical lengths without EOS.

A vocabulary of VV symbols gives VnV^n unrestricted strings of length nn. 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:

P(y∣x)=∏t=1nP(yt∣y<t,x)P(y \mid x) = \prod_{t=1}^{n} P\big(y_t \mid y_{<t}, x\big)

Each factor is a conditional distribution over the target vocabulary given the source and the target prefix. A neural network parameterizes this with weights θ\theta:

Pθ(yt∣y<t,x)=softmax⁡(Wo gθ(y<t,x))ytP_\theta(y_t \mid y_{<t}, x) = \operatorname{softmax}\big(W_o\, g_\theta(y_{<t}, x)\big)_{y_t}

Here gθg_\theta produces a hidden vector of size dd, and Wo∈RV×dW_o \in \mathbb{R}^{V \times d} projects it onto target-vocabulary logits. The subscript yty_t 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:

P(y∣x)∝exp⁡(∑iλifi(x,y))P(y \mid x) \propto \exp\left(\sum_{i} \lambda_i f_i(x, y)\right)

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!

Newsletter

Stay up to date

Get new articles, book updates, and notes on AI and technology.

Unsubscribe at any time. Privacy policy