Statistical Machine Translation Foundations › Word Alignment

Michael BrenndoerferNovember 26, 202616 min read
Language AI HandbookAll chapters
Part 27 of 67Machine Translation and Speech Translation
Chapter 190Statistical Machine Translation Foundations › Word Alignment
Reading section 3 of 12 · Word Alignment · 16 minSection 3 of 12 · 16 min

Section 3 of 12 · 16 min read

Reading settings

Definitions

Choose how many terms have tooltips.

Article links

Make inline references clickable

Notes & comments

A parallel corpus gives you sentence pairs with the word links unobserved. The IBM equations below use e\mathbf{e} for the sentence the alignment model conditions on and f\mathbf{f} for the sentence it generates. In the noisy-channel scoring direction above, e\mathbf{e} is the candidate translation and f\mathbf{f} is the observed input. In the English–Zeta fixture below, the forward aligner conditions on the English input and generates Zeta. The same alignment equations work in either direction.

An IBM alignment a\mathbf{a} maps each generated position to a conditioning position. If aj=ia_j=i, then token eie_i generates token fjf_j. The indices are:

  • a=(a1,…,aJ)\mathbf{a} = (a_1, \dots, a_J) assigns one conditioning position to each generated position.
  • aja_j is the conditioning position assigned to generated position jj.
  • ii ranges from 00 to II, with 00 denoting NULL.
  • eie_i is the conditioning token at position ii.
  • fjf_j is the generated token at position jj.

The conditioning sentence gets an extra position e0=NULLe_0 = \text{NULL} for generated tokens without an aligned conditioning word. This covers some articles, particles, morphological differences, and insertions caused by stylistic or tokenization differences.

Word Alignment

Token correspondence across the two sentences can be many-to-many. A directional IBM model assigns each generated position to one conditioning position, which may be NULL. Combining two directional models can recover a richer set of links.

Each generated token has one parent in a directional IBM model. The worked pipeline combines predictions from two directions to allow several links at a token. The symmetrization step below shows how.

The IBM models use latent alignments to estimate lexical probabilities from sentence-level bitext. In a phrase-based pipeline, the resulting links determine which spans are eligible for phrase extraction. A misplaced link can block an otherwise eligible phrase pair.

IBM Model 1

Model 1 makes the most brutal simplification possible: it ignores word order entirely and assumes every alignment is equally likely.

The generative story is:

  1. Condition on a generated length JJ. To assign probabilities across lengths, specify a separate distribution for JJ.
  2. For each generated position j=1,…,Jj = 1, \dots, J, choose a conditioning position aj∈{0,1,…,I}a_j \in \{0, 1, \dots, I\} uniformly.
  3. Generate fjf_j from eaje_{a_j} with probability t(fj∣eaj)t(f_j \mid e_{a_j}).

The variables are:

  • JJ is the generated sentence length.
  • jj indexes generated tokens from 11 to JJ.
  • aja_j is the conditioning position assigned to generated position jj.
  • II is the number of conditioning tokens excluding NULL.
  • t(fj∣eaj)t(f_j \mid e_{a_j}) is the lexical probability of emitting fjf_j given eaje_{a_j}.

Because the alignment is uniform over the (I+1)J(I+1)^J possible functions, summing over alignments gives

P(f∣e)=ϵ(I+1)J∏j=1J∑i=0It(fj∣ei),P(\mathbf{f} \mid \mathbf{e}) = \frac{\epsilon}{(I+1)^J} \prod_{j=1}^{J} \sum_{i=0}^{I} t(f_j \mid e_i),

where:

  • ϵ=P(J∣e)\epsilon = P(J\mid\mathbf{e}): the normalized probability of the generated length, held fixed while fitting lexical parameters
  • (I+1)J(I+1)^J: the number of possible alignments, since each generated position independently selects one of I+1I+1 conditioning positions (including NULL)
  • t(fj∣ei)t(f_j \mid e_i): the lexical probability that conditioning token eie_i emits generated token fjf_j
  • e0=NULLe_0 = \text{NULL}: the extra conditioning position that can emit insertions

At fixed generated length JJ, the prior gives each of the (I+1)J(I+1)^J alignments probability 1/(I+1)J1/(I+1)^J. Conditional on an alignment, the generated tokens contribute ∏jt(fj∣eaj)\prod_j t(f_j \mid e_{a_j}). Multiplying gives P(f,a∣e,J)P(\mathbf{f},\mathbf{a}\mid\mathbf{e},J). Sum over alignments and multiply by the normalized length probability P(J∣e)P(J\mid\mathbf{e}) to obtain the marginal above. For their Model 1 fit, Brown et al. used the same positive factor for every generated length and conditioning sentence. A positive constant over unbounded lengths gives an unnormalized score. Over a set of KK allowed lengths, a constant of 1/K1/K gives a uniform length distribution. Brown et al. (1993), §4.1

Each lexical factor depends only on the link aja_j at one generated position. The sum over the possible alignments therefore becomes a product of per-position sums. With I≥1I\geq 1, direct enumeration visits (I+1)J(I+1)^J alignments, exponential in JJ. Model 1 evaluates the per-position sums in O((I+1)J)O((I+1)J). The HMM below has dependent links and uses a recurrence to sum its paths.

The exponential growth in the number of alignments is the reason the factoring property matters. The figure makes the scale of the enumeration problem visible.

PythonIn [3]
CollapseExpand
import numpy as np
from book_plot_style import PALETTE

sentence_lengths = np.arange(1, 11)
source_lengths = [4, 9, 19]
alignment_counts = np.array(
    [
        [(length + 1) ** n for n in sentence_lengths]
        for length in source_lengths
    ],
    dtype=float,
)
series_labels = [f"source length {length}" for length in source_lengths]
series_colors = [PALETTE["primary"], PALETTE["amber"], PALETTE["muted"]]
series = list(zip(series_labels, alignment_counts, series_colors))
VisualizationOut [4]
CollapseExpand
Three curves on a logarithmic count axis show alignment counts growing with target length for source lengths 4, 9, and 19.
The number of Model 1 alignments grows exponentially with target sentence length for each fixed source sentence length shown. The factorized E-step avoids enumerating those alignments.

The lexical table has one entry per pair of conditioning and generated word types. Two 50,000-word vocabularies give 2.5 billion entries before adding a NULL row. Each normalized row has one fewer independent parameter than entries. In unsmoothed Model 1, a word pair absent from all cross-sentence co-occurrences receives zero expected count. For rows with positive total count, those absent pairs get zero probability in the M-step.

When the model assigns positive probability to the observed sentence pair, the common length factor cancels from the alignment posterior and leaves the best alignment unchanged. With the factor held fixed, its logarithm adds a constant to the lexical objective and leaves the EM updates unchanged.

Learning Alignment with EM

We never observe a\mathbf{a}, so we use expectation maximization. The derivation follows the standard latent-variable recipe, and it is worth walking through because the update has an unusually clean form.

If we knew the alignments, we could count links for each lexical pair and normalize each conditioning row. If we knew the lexical probabilities, Model 1 would let us find a most probable alignment by picking a highest-scoring conditioning position for each generated token. EM uses the current posterior to allocate fractional counts, then re-estimates the lexical probabilities.

The E-step evaluates P(a∣e,f;θ(t))P(\mathbf{a} \mid \mathbf{e}, \mathbf{f}; \theta^{(t)}). For Model 1 this posterior factors over generated positions. Positive probability for the observed pair under the current parameters ensures every denominator below is positive. For each position jj, the posterior probability that its parent is position ii is

P(aj=i∣e,f;θ(t))=t(fj∣ei)∑i′=0It(fj∣ei′).P(a_j = i \mid \mathbf{e}, \mathbf{f}; \theta^{(t)}) = \frac{t(f_j \mid e_i)}{\sum_{i'=0}^{I} t(f_j \mid e_{i'})}.

where:

  • aja_j: the latent conditioning position that generated position jj
  • ii: a candidate conditioning position from 00 through II, including NULL
  • t(fj∣ei)t(f_j \mid e_i): the current lexical probability of emitting fjf_j from eie_i
  • ∑i′=0It(fj∣ei′)\sum_{i'=0}^{I} t(f_j \mid e_{i'}): the sum over all conditioning positions

Let D\mathcal{D} be the corpus of sentence pairs, counted with multiplicity, and let QQ denote the expected complete-data log-likelihood:

Q(θ∣θ(t))=∑(e,f)∈D∑aP(a∣e,f;θ(t))log⁡P(f,a∣e;θ).Q(\theta \mid \theta^{(t)}) = \sum_{(\mathbf{e},\mathbf{f}) \in \mathcal{D}} \sum_{\mathbf{a}} P(\mathbf{a} \mid \mathbf{e}, \mathbf{f}; \theta^{(t)}) \log P(\mathbf{f}, \mathbf{a} \mid \mathbf{e}; \theta).

Since log⁡P(f,a∣e;θ)\log P(\mathbf{f}, \mathbf{a} \mid \mathbf{e}; \theta) is a sum of log⁡t(fj∣eaj)\log t(f_j \mid e_{a_j}) terms plus fixed terms, the M-step can operate on expected counts. For one sentence pair, sum the posterior contributions for all matching tokens and positions:

c(f∣e;e,f)=∑j:fj=f∑i:ei=et(fj∣ei)∑i′=0It(fj∣ei′).c(f \mid e; \mathbf{e}, \mathbf{f}) = \sum_{j: f_j=f} \sum_{i: e_i=e} \frac{t(f_j \mid e_i)}{\sum_{i'=0}^{I} t(f_j \mid e_{i'})}.

The masses for one generated occurrence sum to one across conditioning positions. The count cc aggregates occurrences by word type. If a generated word occurs twice or a conditioning word occupies two positions, each occurrence contributes separately.

where:

  • c(f∣e;e,f)c(f \mid e; \mathbf{e}, \mathbf{f}): expected number of links from type ee to type ff for this sentence pair
  • t(f∣e)t(f \mid e): the current lexical probability of emitting type ff from type ee
  • t(fj∣ei)t(f_j \mid e_i): each contribution uses the tokens at the selected positions
  • ∑i′=0It(fj∣ei′)\sum_{i'=0}^{I} t(f_j \mid e_{i'}): the sum at this generated position includes NULL at i′=0i'=0

The M-step sums these expected counts over the corpus and normalizes each row with positive total count:

t(f∣e)=∑(e,f)∈Dc(f∣e;e,f)∑f′∑(e,f)∈Dc(f′∣e;e,f).t(f \mid e) = \frac{\sum_{(\mathbf{e},\mathbf{f}) \in \mathcal{D}} c(f \mid e; \mathbf{e}, \mathbf{f})}{\sum_{f'} \sum_{(\mathbf{e},\mathbf{f}) \in \mathcal{D}} c(f' \mid e; \mathbf{e}, \mathbf{f})}.

The E-step costs O((I+1)J)O((I+1)J) per sentence pair because the posterior factors over generated positions. The IBM training sequence used simpler models to initialize richer ones.

Two properties matter for interpreting results:

  • Exact EM never decreases the observed-data likelihood. A uniform positive initialization allows observed co-occurrences to accumulate positive counts.
  • The posterior is normalized over conditioning positions for each generated occurrence. Two positions with identical conditioning tokens receive equal posterior mass for that occurrence.

EM maximizes a lower bound given by the expected complete-data log-likelihood plus the entropy of the current alignment posterior. The bound touches the observed log-likelihood at the current parameters. In Model 1 the observed log-likelihood is, up to fixed terms, a sum of logs of positive affine functions of the lexical probabilities. It is concave over the row simplices, so any local maximum on that feasible set is global, although multiple maximizers can exist. This property of Model 1 does not apply to every model trained with EM.

If the conditioning sentence contains two copies of “the,” their contributions to each generated article's posterior are equal. Other positions, including NULL, compete through their lexical probabilities. Model 1 cannot choose between those two copies from position alone.

Adding Word Order: IBM Model 2

Model 1 gives the same alignment prior to every conditioning position. Model 2 can learn, for example, that a generated token at position 3 tends to align near the start in a given length pair.

Model 2 replaces the uniform prior with a(i∣j,I,J)a(i \mid j, I, J), the probability of choosing conditioning position ii for generated position jj:

P(f∣e)=ϵ∏j=1J∑i=0It(fj∣ei) a(i∣j,I,J).P(\mathbf{f} \mid \mathbf{e}) = \epsilon \prod_{j=1}^{J} \sum_{i=0}^{I} t(f_j \mid e_i) \, a(i \mid j, I, J).

The sum still factors over generated positions. Expected counts for aa accumulate separately for each generated position and length pair, then normalize over conditioning positions. A table fitted for one length pair does not directly supply a row for another. Sharing parameters, as in the diagonal prior used by fast_align, can reduce this dependence on individual length pairs.

Train an English-conditioned model and a French-conditioned model separately to estimate two sets of positional probabilities. When their Viterbi predictions are converted to a common pair of axes, they can disagree.

An absolute-position table can learn that position 20 frequently aligns to position 22 and that position 3 frequently aligns to position 5. Its rows fit those tendencies separately. The HMM below shares a displacement score across positions and conditions on the previous link.

HMM Alignment

To condition each link on the preceding one, use a first-order Markov chain. Vogel, Ney, and Tillmann (1996) proposed this alignment model. The simplified joint below conditions on the generated length JJ.

P(f,a∣e,J)=∏j=1Jt(fj∣eaj) p(aj∣aj−1,I),P(\mathbf{f}, \mathbf{a} \mid \mathbf{e},J) = \prod_{j=1}^{J} t(f_j \mid e_{a_j}) \, p(a_j \mid a_{j-1}, I),

One way to parameterize the transition is to assign a nonnegative score c(i−i′)c(i-i\prime) to a displacement and normalize over the available destinations:

p(i∣i′,I)=c(i−i′)∑i′′=0Ic(i′′−i′).p(i \mid i', I) = \frac{c(i - i')}{\sum_{i''=0}^{I} c(i'' - i')}.

The jump score c(i−i′)c(i-i') depends on displacement. The normalized transition probability can still vary with absolute position because some destinations are unavailable near the ends of the source sentence.

As in the hidden Markov models in Part VI: Sequence Labeling, forward-backward computes alignment posteriors and Viterbi recovers a highest-scoring alignment. In this simplified recurrence, the JJ generated positions are time steps and the I+1I+1 conditioning positions are states, counting NULL. There is also a start distribution for the first link. Scanning all ordered state pairs at each step costs O(J(I+1)2)O(J(I+1)^2), compared with (I+1)J(I+1)^J complete alignment paths. Lexical probabilities supply the emission scores.

HMM alignment learns jumps from one alignment position to the next. fast_align uses a different prior, a log-linear reparameterization of IBM Model 2 that favors the diagonal while choosing each generated position's link independently. Dyer, Chahuneau, and Smith (2013), sections 2–3.

Fertility, Distortion, and IBM Models 3–5

In Models 1 and 2 and the HMM formulation above, each generated position chooses one conditioning position. Several generated positions can choose the same one. The number of generated positions that choose a conditioning token is its fertility.

A concrete example makes the gap obvious. Translating English "the" into a language without articles, or translating a compound German noun into an English multiword phrase, requires dropping or expanding a single source word into zero or several target words. Models 1 and 2 can technically represent these outcomes, since a source word may be selected zero or many times, but they have no parameter that says "this word usually expands into two target words." The count is emergent noise rather than modeled structure.

Model 3 represents fertility explicitly. The joint weight of a sentence and alignment is the following term of Brown et al.'s marginalization. The formula applies to alignments with 0≤ϕ0≤M0 \le \phi_0 \le M. Brown et al. (1993), section 4.4, equations 31–32.

P(f,a∣e)=(Mϕ0)p0M−ϕ0p1ϕ0[∏i=1Iϕi! n(ϕi∣ei)][∏j=1Jt(fj∣eaj)][∏j: aj≠0d(j∣aj,I,J)].P(\mathbf{f},\mathbf{a}\mid\mathbf{e}) = \binom{M}{\phi_0}p_0^{M-\phi_0}p_1^{\phi_0} \left[\prod_{i=1}^{I}\phi_i!\,n(\phi_i\mid e_i)\right] \left[\prod_{j=1}^{J}t(f_j\mid e_{a_j})\right] \left[\prod_{j:\,a_j\ne 0}d(j\mid a_j,I,J)\right].

The terms distinguish ordinary fertility from the NULL insertion process.

  • e=(e1,…,eI)\mathbf{e}=(e_1,\dots,e_I) is the conditioning sentence and e0e_0 denotes NULL.
  • f=(f1,…,fJ)\mathbf{f}=(f_1,\dots,f_J) is the generated sentence. The alignment index aja_j specifies which conditioning token generated fjf_j.
  • ϕi=#{j:aj=i}\phi_i=\#\{j:a_j=i\} counts the generated words linked to eie_i. The non-NULL count is M=J−ϕ0M=J-\phi_0.
  • n(ϕi∣ei)n(\phi_i\mid e_i) is the fertility distribution for a non-NULL conditioning token.
  • p1p_1 is the probability that an ordinary generated word triggers an additional NULL word. The complementary probability is p0=1−p1p_0=1-p_1.
  • t(fj∣eaj)t(f_j\mid e_{a_j}) supplies the lexical probability for every generated word, including those linked to NULL.
  • d(j∣aj,I,J)d(j\mid a_j,I,J) supplies the placement probability for a word linked to a non-NULL conditioning position.

For each ordinary token, the factor ϕi!\phi_i! counts the interchangeable orderings of its generated words before placement.

  • The leading binomial term gives the probability of drawing exactly ϕ0\phi_0 NULL words from MM opportunities.
  • The placement process fills the remaining slots with NULL words in uniformly random order.
  • The NULL placement probability 1/ϕ0!1/\phi_0! cancels the ϕ0!\phi_0! orderings of those words. This leaves no NULL factor in the ordinary fertility or distortion products.

For example, if two ordinary words are generated and p1=1/4p_1=1/4, the probability of one NULL insertion is (21)(3/4)(1/4)=3/8\binom21(3/4)(1/4)=3/8. The binomial term accounts for either ordinary word triggering the insertion.

Fertility and Distortion

Fertility counts the words emitted by a conditioning token. Fertility zero drops that token. Distortion assigns scores to placements. Model 3 can assign mass to colliding ordinary placements, so its distribution is deficient when restricted to valid output strings.

Fertility couples the alignment decisions, so Model 3 loses the factoring shortcut used by Models 1 and 2. Brown and colleagues approximate the E-step by summing over move and swap neighborhoods around several candidate alignments. They find these candidates with local search, including searches that hold one alignment link fixed. Model 4 adds relative placement, and Model 5 tracks vacant positions to avoid assigning probability mass to overlapping placements. Och and Ney's Model 6 combines the Model 4 and HMM alignment distributions log-linearly, bringing together their complementary notions of positional locality. Brown et al. (1993), §4.4, Equation 44, Och and Ney (2003), section 2.3.1.

The standalone GIZA++ defaults run five iterations each of Model 1, the HMM, Model 3, and Model 4. Model 2 is configurable and defaults to zero iterations in that release. The Moses training wrapper sets three iterations each for Models 3 and 4 by default and accepts overrides. In both cases, stages can initialize from simpler models to refine the alignments. GIZA++ defaults, Moses training wrapper.

Alignment Heuristics in Practice

A directional IBM model assigns one conditioning parent to each generated position. One conditioning word can still generate several words in that direction. Whether a single direction can encode a link set depends on which side needs multiple parents. Suppose we annotate the two-token idiom “clam up” and its gloss “fall silent” as a unit, linking each word to both words on the other side. In that annotation, either direction would need two parents for a generated position.

The standard remedy is to train two models, one in each direction, and combine their output:

  • Intersection Aef∩AfeA_{\text{ef}} \cap A_{\text{fe}}: keeps only links present in both directions. Relative to union, it cannot increase gold-link recall.
  • Union Aef∪AfeA_{\text{ef}} \cup A_{\text{fe}}: keeps links from either direction. The precision of the additional links depends on what each aligner got right.
  • Grow-diag-final-and: start from the intersection and consider neighbors in the union. In the growing phase, add a link if at least one endpoint is unaligned. In the final passes, test both endpoints and accept a link when both are still unaligned.

The Moses training script defaults to grow-diag-final, with grow-diag-final-and as an option. The final stage of the former can add a link with one endpoint still free. The worked example uses one final pass with the stricter AND rule.

The “diag” step permits diagonal neighbors of links already in the working alignment. A final pass can find isolated links that the growth phase cannot reach. Its endpoint test uses the alignment as it stands when each link is considered.

Alignment Quality Is Measured Against Sparse Gold Data

Alignment Error Rate (AER) uses both sure and possible human-annotated links. Links in the sure set determine the recall term, and links in the possible set, which includes the sure set, count toward the precision term. Och and Ney (2003) evaluated alignment predictions against annotated Hansards sentences. Results depend on the language pair, domain, and annotation protocol.

Our collaborative experiment below makes the symmetrization tradeoff visible: on a synthetic corpus with exact gold alignments, intersection, union, and grow-diag-final-and land at different F1 values, and none of them is universally best.

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