Cross-Lingual Transfer and Alignment › Alignment Objectives

Michael BrenndoerferNovember 26, 20265 min read
Language AI HandbookAll chapters
Part 26 of 67Multilingual Language Models and Cross-Lingual Transfer
Chapter 186Cross-Lingual Transfer and Alignment › Alignment Objectives
Reading section 4 of 11 · Alignment Objectives · 5 minSection 4 of 11 · 5 min

Section 4 of 11 · 5 min read

Reading settings

Definitions

Choose how many terms have tooltips.

Article links

Make inline references clickable

Notes & comments

Alignment objectives give the optimizer a direct signal about which representations or predictions should agree across languages. In the examples below, some objectives supply a paired translation as an extra source of context, and others train a model to rank translations ahead of mismatches. Compare these approaches on the language pair and task you intend to use.

Translation Language Modeling

XLM introduced translation language modeling (TLM) as a version of masked language modeling for parallel data. Join a sentence and its translation, mask tokens in both, and use the available context from either language to predict the masked tokens. XLM, §3.4

For example, pair "The cat [MASK] on the mat" with "Le chat s'est assis [MASK] le tapis." The French verb can help recover the missing English verb, and the English preposition can help recover the masked French preposition. XLM resets the position indices for the target sentence, and a token in either half can attend to the other half.

The loss is still cross-entropy over the vocabulary at each masked position. The difference is the context used to compute the logits. The masked English position can now draw on the French half, so improving those predictions rewards the model for using information in the translation.

Cross-lingual contrastive learning

Sentence-level contrastive learning scores whole sentences. Given a batch of BB pairs (ai,pi)(a_i, p_i) where aia_i is a sentence in one language and pip_i is its translation, the row-wise objective raises sim(ai,pi)\text{sim}(a_i, p_i) relative to sim(ai,pj)\text{sim}(a_i, p_j) for j≠ij \neq i.

InfoNCE Loss

Given a batch of normalized anchor embeddings a1,…,aBa_1, \dots, a_B and target embeddings p1,…,pBp_1, \dots, p_B:

LInfoNCE=−1B∑i=1Blog⁡exp⁡(sim(ai,pi)/τ)∑j=1Bexp⁡(sim(ai,pj)/τ)\mathcal{L}_{\text{InfoNCE}} = -\frac{1}{B}\sum_{i=1}^{B} \log\frac{\exp(\text{sim}(a_i, p_i)/\tau)}{\sum_{j=1}^{B} \exp(\text{sim}(a_i, p_j)/\tau)}

where τ>0\tau > 0 is a temperature and sim\text{sim} is cosine similarity.

Each row compares the designated translation with the other candidates. With one candidate the loss is zero. With B>1, equal scores give log B. For example, when two targets in the batch are valid paraphrases of one anchor but only one is paired with it, the other still appears in the denominator as a competing candidate.

LaBSE uses a related contrastive recipe: bidirectional translation ranking with an additive-margin objective that subtracts the margin from the matched pair’s score during training. SONAR's text encoder uses a different recipe that combines translation, denoising autoencoding, and a mean squared error term between embeddings of paired translations. Both produce sentence embeddings for multilingual retrieval. LaBSE, §2 and SONAR, §5.5

Word alignment objectives

Sentence-level alignment supports retrieval and similarity. Word alignment is useful when the output needs to connect individual tokens across languages, for example when projecting NER tags through a parallel corpus. Statistical methods such as IBM Model 4, fast_align (Dyer et al. 2013), and eflomal fit alignment models to bitext and can return discrete links between words.

Embedding-based methods can score word correspondences before selecting discrete links. SimAlign uses pretrained multilingual embeddings and extracts links from token similarities without fitting an aligner on parallel training data. Awesome-align can fine-tune a multilingual encoder on parallel text. Its extraction code supports softmax and entmax thresholding. The paper also evaluated optimal transport, which was slower and performed worse in its comparison. SimAlign, §2.1, Awesome-align paper, §§2.1 and 4.2, and Awesome-align toolkit

Use word alignment diagnostics when the transfer task depends on projecting labels. Evaluate link quality and target-language tagging separately, and examine examples where the two results diverge.

Code-switching and mixed-language training

Code-switching augmentation mixes languages within a training example. Multilingual batch mixing changes which languages appear across the examples in a batch.

  • Word substitution can produce a mixed sentence such as "Le chat sat on the mat."
  • A batch can also combine complete monolingual sentences in different languages. If each example is a single sentence, each example in that batch can stay monolingual.

Use these as augmentation experiments at a named stage of training. A mixed example can still carry language cues. Measure convergence and task accuracy against a monolingual or unmixed control. Code-Switching and Mixed-Language Text develops these comparisons.

Sentence embedding alignment at scale

LASER, LaBSE, and SONAR all use parallel text, with different ways to make it useful. LASER learns sentence embeddings through multilingual translation. LaBSE ranks translations against other sentences in its batch. SONAR learns a fixed-size representation that its decoder can translate from, with an explicit distance penalty on translation pairs. For a retrieval task, compare how well each model ranks translations for the languages and domains you need. LASER

In a distillation setup, fit a student to approximate the teacher’s sentence embeddings on a chosen multilingual dataset. Validate which pairs the student preserves in the intended domain. In the implementation below, we specify the shared features directly so the downstream comparison has a controlled alignment mechanism.

When parallel text is available, compare TLM for token prediction with a contrastive objective for sentence retrieval. Both use paired sentences. With only monolingual text, shared multilingual pre-training is a starting point. Code-switching augmentation is another option if you have a source of cross-language substitutions, such as a bilingual lexicon.

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