Parallel Data Mining and Quality Control › Sentence Alignment

Michael BrenndoerferNovember 26, 20267 min read
Language AI HandbookAll chapters
Part 27 of 67Machine Translation and Speech Translation
Chapter 192Parallel Data Mining and Quality Control › Sentence Alignment
Reading section 4 of 14 · Sentence Alignment · 7 minSection 4 of 14 · 7 min

Section 4 of 14 · 7 min read

Reading settings

Definitions

Choose how many terms have tooltips.

Article links

Make inline references clickable

Notes & comments

Mining produces candidate document pairs. Within a document pair, you still need to figure out which sentence in one language corresponds to which sentence in the other. This is sentence alignment.

Check for boilerplate, sidebars, and differences in paragraph breaks even after accepting a page pair. Pairing sentences solely by position fails when one side inserts a navigation sentence or the translation reorders sentences.

There is a deeper reason alignment is hard: translation is not a sentence-by-sentence operation, even when humans try to make it one. A translator may merge two short source sentences into one, split a long sentence into three, reorder clauses across sentence boundaries, or drop a sentence entirely because it is redundant in the target language. Alignment algorithms therefore have to consider not just one-to-one matches but many-to-many groupings, and they have to do so without knowing in advance where the boundaries are.

The next four sections compare alignment signals based on length, dictionaries, machine translation, and multilingual embeddings.

Length-based alignment (Gale-Church)

Gale and Church (1993) modeled the relationship between the character lengths of translated segments. The teaching model here conditions on the source length. For positive source and target character counts l1l_1 and l2l_2, the model assumes:

l2−c⋅l1∼N(0,s2l1)l_2 - c \cdot l_1 \sim \mathcal{N}(0, s^2 l_1)

where:

  • l1l_1: the length in characters of the source sentence
  • l2l_2: the length in characters of the target sentence
  • cc: the average length ratio between the two languages
  • s2s^2: a variance parameter that scales the Gaussian noise
  • N(0,s2l1)\mathcal{N}(0, s^2 l_1): a normal distribution with mean 00 and variance s2l1s^2 l_1, which makes the spread of the difference grow with the source length

With s2s^2 fixed, the standard deviation grows like the square root of l1l_1. For a given absolute residual, the quadratic penalty relative to the peak is smaller for longer source segments.

The conditional log density in this teaching model, for l1>0l_1>0 and s2>0s^2>0, is:

log⁡p(l2∣l1)=−12log⁡(2πs2l1)−(l2−cl1)22s2l1\log p(l_2 \mid l_1) = -\frac{1}{2} \log(2 \pi s^2 l_1) - \frac{(l_2 - c l_1)^2}{2 s^2 l_1}

The example uses s2=7.5s^2=7.5 as an illustrative coefficient. The original aligner estimated length and variance from its own corpus, used a pooled length in the residual normalization, and converted a two-sided normal-tail probability into a distance. The example below uses a Gaussian log density and illustrative move penalties, so its scores and decisions can differ from the original program.

The figure compares each curve to its own peak to isolate the change in width.

VisualizationOut [4]
CollapseExpand
Three Gaussian log-density curves peak at zero target length residual. The longest source segment has the widest curve.
Gaussian log density relative to its peak for three source lengths. The horizontal axis is the target length residual $l_2 - c l_1$, in characters. At a fixed drop from the peak, a longer source segment permits a greater absolute residual.

Given this model, alignment becomes a dynamic program. Let D(i,j)D(i, j) be the best score for aligning the first ii source sentences with the first jj target sentences. The recurrences are:

D(i,j)=max⁡(a,b)∈M[D(i−a,j−b)+q(a,b)+g(li−a:i,mj−b:j)]D(i, j) = \max_{(a, b) \in \mathcal{M}} \left[ D(i - a, j - b) + q(a,b) + g(l_{i-a:i}, m_{j-b:j}) \right]

where:

  • D(i,j)D(i, j): the best score for aligning the first ii source sentences with the first jj target sentences
  • M⊆{(1,0),(0,1),(1,1),(2,1),(1,2),(2,2)}\mathcal{M} \subseteq \{(1,0), (0,1), (1,1), (2,1), (1,2), (2,2)\}: the set of allowed alignment patterns, where (a,b)(a, b) means aa source sentences align to bb target sentences
  • (a,b)(a, b): one allowed pattern, taking aa source and bb target sentences
  • li−a:il_{i-a:i}: the sum of the lengths of the source sentences in the segment
  • mj−b:jm_{j-b:j}: the sum of the lengths of the target sentences in the segment
  • q(a,b)q(a,b): the log weight for the move shape
  • gg: the conditional log density for two nonempty segments, or zero for a gap, whose cost comes from qq

Set D(0,0)=0D(0,0)=0, initialize other states to minus infinity, and consider only predecessors with valid indices. With a fixed move set of bounded segment size, the DP takes O((n+1)(m+1))O((n+1)(m+1)) time and space for documents with nn and mm sentences. Similar character counts can still produce a wrong or over-grouped alignment because the score has no lexical signal.

The set M\mathcal{M} of allowed moves is where the algorithm's assumptions live. The (1,1)(1,1) move handles the common case. The (1,0)(1,0) and (0,1)(0,1) moves allow sentences to be dropped or inserted, which is how the aligner copes with untranslated boilerplate. The (2,1)(2,1), (1,2)(1,2), and (2,2)(2,2) moves handle merges and splits. Each move has a log weight. In the toy below, every other move has a lower weight than the one-to-one move. A split or merge can make up the difference with a better length score. A gap has no length score, so its local cost comes from its log weight.

Gale-Church alignment

A dynamic-programming method for sentence alignment that scores segment moves using their length relationship. The original implementation turns a two-sided normal-tail probability into a distance. Gale and Church, 1993

Lexical alignment (Hunalign)

Hunalign (Varga et al., 2005) extends the length-based approach with a dictionary. If the source and target sentences share translation pairs, the alignment gets a bonus. This disambiguates cases where multiple alignments have similar length-based scores.

Dictionary evidence can break a tie when several candidate segments have similar lengths. If one target contains a known translation of a source word and another does not, the lexical signal can distinguish otherwise similar candidates.

Hunalign can use a supplied bilingual dictionary. In its automatic dictionary-building mode it first aligns without a dictionary, induces one from its initial alignment, and aligns the sentences again with that dictionary. Hunalign documentation

The second pass can use lexical evidence that the first pass lacked. Check a sample of alignments in your domain, especially when the initial length matches are weak enough to produce misleading dictionary entries.

Translation-based alignment (Bleualign)

Bleualign (Sennrich and Volk, 2010) aligns documents using translations of one side. Bleualign paper

  1. Translate one side of the document with an MT system.
  2. Score each candidate sentence pair by BLEU between the translation and the target.
  3. Use high-similarity alignments as anchors, then fill gaps with BLEU-based and length-based heuristics.

The method requires translations for one side of the document. Compare its alignment quality with a length-based baseline on checked examples, particularly if the available MT system performs poorly on the language pair or domain.

A correct target may phrase the sentence differently from the MT output, and a wrong target may share many words with it. BLEU provides evidence of text overlap. Errors in the MT output or repeated phrasing can give the wrong correspondence a high score.

Embedding-based alignment (Vecalign)

Vecalign (Thompson and Koehn, 2019) scores candidate segments using embeddings and searches for a monotonic alignment. It uses a coarse-to-fine approximation to restrict the dynamic-programming search instead of comparing all sentence pairs in the document. The paper reports linear time and space in the number of sentences aligned for its procedure.

The four approaches compared here use different bilingual signals:

Sentence alignment methods and their requirements.
MethodSignalInput needed
Gale-ChurchCharacter lengthsSegmented sentences
HunalignLength and dictionary evidenceSegmented text, optionally a bilingual dictionary
BleualignTranslated-text overlapMachine translations for one side
VecalignSegment embeddingsBilingual sentence embeddings

If you already have an encoder that covers both languages, compare Vecalign with a length-based baseline on some hand-aligned documents.

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