Parallel Data Mining and Quality Control › Bitext Mining

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 › Bitext Mining
Reading section 3 of 14 · Bitext Mining · 7 minSection 3 of 14 · 7 min

Section 3 of 14 · 7 min read

Reading settings

Definitions

Choose how many terms have tooltips.

Article links

Make inline references clickable

Notes & comments

The retrieval workflow here uses document retrieval, sentence embeddings, and margin scoring. These stages restrict where to search, represent what to compare, and score the proposed pairs.

Start document screening with recall in mind. If it drops a page pair, no later sentence filter can recover pairs from those pages. The sentence encoder provides comparable vectors, and margin scoring compares a candidate to nearby alternatives. Check the errors at each stage because a downstream score can miss mistakes made upstream.

Document-level retrieval

Before aligning sentences in two different languages, retrieve pages likely to contain translations of each other. This workflow uses two kinds of clues.

  • Structural signals. Use repeated URL patterns, alternate-language links, or corresponding page layouts to propose document pairs. Resnik and Smith used document structure together with a separate textual-equivalence check. Resnik and Smith, 2003
  • Content signals. Embed the page (or a sample of sentences from it) and retrieve pages in the other language with high aggregate similarity.

An alternate-language link only proposes a page pair. A translated page without a link can still be found by text retrieval, and an unrelated page about the same event can score highly. Check candidate pairs from both sources.

A site can reuse the same navigation, layout, image positions, and headings across unrelated pages. Treat matching DOM structure as a retrieval feature and compare the text in corresponding sections before accepting the pair.

You can represent a page by pooling embeddings for a sample of its sentences. A second check of several corresponding passages or a structural clue can help distinguish a translation from an independent page on the same topic.

An all-pairs comparison of 10 billion sentences on each side would score 102010^{20} pairs. Restrict comparisons to proposed document pairs and add up the products of their respective sentence counts to estimate the remaining work. The reduction depends on the number and lengths of the candidate documents.

With n source sentences and m target sentences, the full search scores nm pairs. A document shortlist limits any subsequent exhaustive comparisons to the selected blocks. The separate page-retrieval cost depends on how the shortlist is built.

Sentence embeddings

A multilingual sentence encoder maps source and target sentences into a space where they can be compared. LaBSE trains for bilingual sentence retrieval with a translation-ranking objective. Feng et al., §2

A translation-ranking objective gives the model known translations as positives and other candidate sentences as negatives. It rewards a higher score for the positives. Check actual retrieval on the languages and domains you need because the training objective alone does not establish score separation on a new corpus.

The key properties to look for in an encoder are:

  • Cross-lingual alignment. Translations of the same sentence land near each other regardless of language.
  • Semantic sensitivity. Paraphrases are close; unrelated sentences are far.
  • Robustness to translationese. Machine-translated text and human text are embedded similarly.
  • Efficient inference. Estimate total encoding time from measured throughput and the number of sentences to encode.

Include both human-written and translated text in a calibration sample if both occur in the candidate pool. If the two groups have different score distributions, a shared cutoff can retain them at different rates.

The encoders in Table mining-encoders offer examples of different coverage and architectures.

Examples of multilingual sentence encoders for retrieving candidate bitext.
ModelDimensionsReleasedNotes
LASER and LASER210242019 and 2022Meta released the original LASER encoder for 93 languages. LASER2 updates that encoder. LASER3 adds language-specific encoders for broader coverage.
LaBSE7682020Google's BERT-based sentence encoder for 109 languages
SONAR10242023Meta reports 200 languages for its text models and 37 for its speech encoders
paraphrase-multilingual-MiniLM-L12-v23842021Sentence Transformers multilingual sentence encoder
multilingual-e5-large10242023Microsoft, trained on diverse retrieval tasks

Choose an encoder by measuring retrieval quality and throughput on your target languages and domain. The worked example uses constructed unit vectors to show the scoring and filtering steps without downloading a pretrained encoder. In production, the sentence vectors would come from the encoder you evaluated.

Normalize each nonzero source and target vector to unit length, so ∥ui∥=∥vj∥=1\|\mathbf{u}_i\| = \|\mathbf{v}_j\| = 1. Cosine similarity between a source vector and a target vector is:

cos⁡(ui,vj)=ui⊤vj∥ui∥ ∥vj∥=ui⊤vj\cos(\mathbf{u}_i, \mathbf{v}_j) = \frac{\mathbf{u}_i^\top \mathbf{v}_j}{\|\mathbf{u}_i\| \, \|\mathbf{v}_j\|} = \mathbf{u}_i^\top \mathbf{v}_j

where:

  • ui\mathbf{u}_i: the unit-length embedding of source sentence xix_i
  • vj\mathbf{v}_j: the unit-length embedding of target sentence yjy_j
  • ui⊤vj\mathbf{u}_i^\top \mathbf{v}_j: the dot product of the two unit vectors, which equals their cosine similarity

The divisor ∥ui∥ ∥vj∥\|\mathbf{u}_i\| \, \|\mathbf{v}_j\| drops out because both norms equal 11, so the similarity reduces to a dot product. Approximate search can propose the top target candidates. Measure retrieval recall and latency with your index, hardware, and corpus size.

An unnormalized dot product depends on vector norms as well as direction. A less similar target can outrank another if its norm is large enough. After unit normalization, the inner product equals cosine similarity, so the same inner-product ranking can serve either score.

Margin-based scoring

A high cosine can be ambiguous if many competing targets score almost as well. Artetxe and Schwenk (2019) compare candidates with neighborhoods in both languages. Their ratio divides the candidate cosine by the average of the source-to-target and target-to-source neighborhood means. They also evaluate a distance margin that subtracts this background instead of dividing.

The small example here uses a one-sided variant so you can inspect each source independently. Let Aₖ(xᵢ, yⱼ) contain the k highest-cosine target alternatives to xᵢ after excluding yⱼ. The toy ratio is:

rij=cos⁡(ui,vj)k−1∑y′∈Ak(xi,yj)cos⁡(ui,vy′).r_{ij} = \frac{\cos(\mathbf{u}_i, \mathbf{v}_j)} {k^{-1}\sum_{y'\in A_k(x_i,y_j)}\cos(\mathbf{u}_i,\mathbf{v}_{y'})}.

The numerator is the candidate cosine. The denominator is the mean cosine of exactly k other targets, so k must be at least one and smaller than the target count. The example uses positive competitor means. A nonpositive mean is outside this ratio's intended range, and the code marks that score undefined. If two pairs have the same positive cosine, the pair with stronger alternatives receives the lower ratio. A small positive background can still inflate the ratio of a weak match, so also inspect the cosine itself.

You can separately require mutual top-one retrieval, in which each sentence chooses the other as its best neighbor under a specified score. With one tie-broken winner per sentence, this prevents several sources from claiming the same target but can also discard correct alternatives.

Thresholds and calibration

Collect a labeled sample of retrieved candidates for each language pair and domain. Sweep a candidate cutoff and inspect precision and recall before choosing an operating point. Recalibrate after changing the encoder, extraction method, or composition of the candidate pool. A held-out sample for evaluation serves a different purpose from the labeled sample used to select the threshold.

Using an explicit cosine floor can block a low-cosine candidate whose background is especially weak. It does not guarantee adequacy, and the cutoffs in the worked example apply only to its constructed scores. The general calibration procedure is described in Part XX, Ch 6: Quality Filtering.

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